MesDeviceController.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. package com.jeesite.modules.mes.web;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Map;
  4. import java.util.List;
  5. import java.util.Date;
  6. import java.util.Calendar;
  7. import java.util.stream.Collectors;
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.servlet.http.HttpServletResponse;
  10. import com.alibaba.fastjson.JSON;
  11. import com.jeesite.common.entity.Page;
  12. import com.jeesite.common.lang.ObjectUtils;
  13. import com.jeesite.modules.mes.entity.MesDeviceCate;
  14. import com.jeesite.modules.mes.entity.MesDeviceForm;
  15. import com.jeesite.modules.mes.entity.MesDevicePreventTask;
  16. import com.jeesite.modules.mes.entity.MesDeviceState;
  17. import com.jeesite.modules.mes.entity.MesDeviceUrgency;
  18. import com.jeesite.modules.mes.entity.MesLineProcess;
  19. import com.jeesite.modules.mes.resp.CommonResp;
  20. import com.jeesite.modules.mes.service.MesDeviceCateService;
  21. import com.jeesite.modules.mes.service.MesDevicePreventTaskService;
  22. import com.jeesite.modules.mes.service.MesDeviceUrgencyService;
  23. import org.apache.shiro.authz.annotation.RequiresPermissions;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.stereotype.Controller;
  26. import org.springframework.ui.Model;
  27. import org.springframework.validation.annotation.Validated;
  28. import org.springframework.web.bind.annotation.ModelAttribute;
  29. import org.springframework.web.bind.annotation.PostMapping;
  30. import org.springframework.web.bind.annotation.RequestBody;
  31. import org.springframework.web.bind.annotation.RequestMapping;
  32. import org.springframework.web.bind.annotation.ResponseBody;
  33. import com.jeesite.common.config.Global;
  34. import com.jeesite.common.collect.ListUtils;
  35. import com.jeesite.common.collect.MapUtils;
  36. import com.jeesite.common.lang.StringUtils;
  37. import com.jeesite.common.idgen.IdGen;
  38. import com.jeesite.modules.sys.utils.UserUtils;
  39. import com.jeesite.common.lang.DateUtils;
  40. import com.jeesite.common.utils.excel.ExcelExport;
  41. import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
  42. import org.springframework.web.multipart.MultipartFile;
  43. import com.jeesite.common.web.BaseController;
  44. import com.jeesite.modules.mes.entity.MesDevice;
  45. import com.jeesite.modules.mes.req.MesDeviceReportStateReq;
  46. import com.jeesite.modules.mes.service.MesDeviceOeeStatsService;
  47. import com.jeesite.modules.mes.service.MesDeviceStateReportService;
  48. import com.jeesite.modules.mes.service.MesDeviceService;
  49. /**
  50. * 设备Controller
  51. * @author mes
  52. * @version 2023-07-12
  53. */
  54. @Controller
  55. @RequestMapping(value = "${adminPath}/mes/mesDevice")
  56. public class MesDeviceController extends BaseController {
  57. @Autowired
  58. private MesDeviceService mesDeviceService;
  59. @Autowired
  60. private MesDeviceCateService mesDeviceCateService;
  61. @Autowired
  62. private MesDevicePreventTaskService mesDevicePreventTaskService;
  63. @Autowired
  64. private MesDeviceUrgencyService mesDeviceUrgencyService;
  65. @Autowired
  66. private MesDeviceStateReportService mesDeviceStateReportService;
  67. @Autowired
  68. private MesDeviceOeeStatsService mesDeviceOeeStatsService;
  69. /**
  70. * 获取数据
  71. */
  72. @ModelAttribute
  73. public MesDevice get(String treeCode, boolean isNewRecord) {
  74. return mesDeviceService.get(treeCode, isNewRecord);
  75. }
  76. /**
  77. * 管理主页
  78. */
  79. @RequiresPermissions("mes:mesDevice:view")
  80. @RequestMapping(value = "index")
  81. public String index(MesDevice mesDevice, Model model) {
  82. model.addAttribute("mesDevice", mesDevice);
  83. return "modules/mes/mesDeviceIndex";
  84. }
  85. /**
  86. * 查询列表
  87. */
  88. @RequiresPermissions("mes:mesDevice:view")
  89. @RequestMapping(value = {"list", ""})
  90. public String list(MesDevice mesDevice, MesDeviceCate mesDeviceCate, Model model) {
  91. model.addAttribute("mesDevice", mesDevice);
  92. model.addAttribute("mesDeviceCate", mesDeviceCateService.findList(mesDeviceCate));
  93. return "modules/mes/mesDeviceList";
  94. }
  95. /**
  96. * 查询列表数据
  97. */
  98. // @RequiresPermissions("mes:mesDevice:view")
  99. // @RequestMapping(value = "listData")
  100. // @ResponseBody
  101. // public List<MesDevice> listData(MesDevice mesDevice) {
  102. // if (StringUtils.isBlank(mesDevice.getParentCode())) {
  103. // mesDevice.setParentCode(MesDevice.ROOT_CODE);
  104. // }
  105. // if (StringUtils.isNotBlank(mesDevice.getRemark())){
  106. // mesDevice.setParentCode(null);
  107. // }
  108. // if (StringUtils.isNotBlank(mesDevice.getTreeName())){
  109. // mesDevice.setParentCode(null);
  110. // }
  111. // if (StringUtils.isNotBlank(mesDevice.getSn())){
  112. // mesDevice.setParentCode(null);
  113. // }
  114. // if (StringUtils.isNotBlank(mesDevice.getIp())){
  115. // mesDevice.setParentCode(null);
  116. // }
  117. // List<MesDevice> list = mesDeviceService.findList(mesDevice);
  118. // for (MesDevice i:list){
  119. // mesDevice.setTreeCode(i.getParentCode());
  120. // MesDevice parent = mesDeviceService.findByInfo(mesDevice);
  121. // if(parent==null){
  122. // i.setParentSn("");
  123. // }else {
  124. // i.setParentSn(parent.getSn());
  125. // }
  126. // }
  127. //
  128. // return list;
  129. // }
  130. @RequiresPermissions("mes:mesDevice:view")
  131. @RequestMapping(value = "listData")
  132. @ResponseBody
  133. public Page<MesDevice> listData(MesDevice mesDevice, HttpServletRequest request, HttpServletResponse response) {
  134. // System.out.println(request.getParameterMap());
  135. mesDevice.setPage(new Page<>(request, response));
  136. Page<MesDevice> page = mesDeviceService.findPage(mesDevice);
  137. return page;
  138. }
  139. /**
  140. * 查看编辑表单
  141. */
  142. @RequiresPermissions("mes:mesDevice:view")
  143. @RequestMapping(value = "form")
  144. public String form(MesDevice mesDevice,MesDeviceCate mesDeviceCate, Model model) {
  145. // 创建并初始化下一个节点信息
  146. mesDevice = createNextNode(mesDevice);
  147. logger.info(JSON.toJSONString(mesDevice));
  148. model.addAttribute("mesDevice", mesDevice);
  149. model.addAttribute("mesDeviceCate", mesDeviceCateService.findList(mesDeviceCate));
  150. return "modules/mes/mesDeviceForm";
  151. }
  152. /**
  153. * 详情
  154. */
  155. @RequiresPermissions("mes:mesDevice:view")
  156. @RequestMapping(value = "detail")
  157. public String detail(MesDevice mesDevice,MesDeviceCate mesDeviceCate, Model model) {
  158. // 创建并初始化下一个节点信息
  159. mesDevice.setTreeCode(mesDevice.getParentCode());
  160. MesDevice parent = mesDeviceService.findByInfo(mesDevice);
  161. if(parent==null){
  162. mesDevice.setParentSn("");
  163. }else {
  164. mesDevice.setParentSn(parent.getSn());
  165. }
  166. mesDevice = createNextNode(mesDevice);
  167. model.addAttribute("mesDevice", mesDevice);
  168. model.addAttribute("mesDeviceCate", mesDeviceCateService.findList(mesDeviceCate));
  169. return "modules/mes/mesDeviceDetail";
  170. }
  171. /**
  172. * 创建并初始化下一个节点信息,如:排序号、默认值
  173. */
  174. @RequiresPermissions("mes:mesDevice:edit")
  175. @RequestMapping(value = "createNextNode")
  176. @ResponseBody
  177. public MesDevice createNextNode(MesDevice mesDevice) {
  178. if (StringUtils.isNotBlank(mesDevice.getParentCode())){
  179. mesDevice.setParent(mesDeviceService.get(mesDevice.getParentCode()));
  180. }
  181. if (mesDevice.getIsNewRecord()) {
  182. MesDevice where = new MesDevice();
  183. where.setParentCode(mesDevice.getParentCode());
  184. MesDevice last = mesDeviceService.getLastByParentCode(where);
  185. // 获取到下级最后一个节点
  186. if (last != null){
  187. mesDevice.setTreeSort(last.getTreeSort() + 30);
  188. mesDevice.setTreeCode(IdGen.nextCode(last.getTreeCode()));
  189. }else if (mesDevice.getParent() != null){
  190. mesDevice.setTreeCode(mesDevice.getParent().getTreeCode() + "001");
  191. }
  192. }
  193. // 以下设置表单默认数据
  194. if (mesDevice.getTreeSort() == null){
  195. mesDevice.setTreeSort(MesDevice.DEFAULT_TREE_SORT);
  196. }
  197. return mesDevice;
  198. }
  199. /**
  200. * 保存数据
  201. */
  202. @RequiresPermissions("mes:mesDevice:edit")
  203. @PostMapping(value = "save")
  204. @ResponseBody
  205. public String save(@Validated MesDevice mesDevice) {
  206. logger.info(JSON.toJSONString(mesDevice));
  207. MesDevice mesDevice1 = new MesDevice();
  208. mesDevice1.setDeviceCode(mesDevice.getDeviceCode());
  209. MesDevice info = mesDeviceService.getByEntity(mesDevice1);
  210. if (info != null && !StringUtils.equals(info.getTreeCode(), mesDevice.getTreeCode())){
  211. return renderResult(Global.FALSE, text("保存失败,设备编码已存在!"));
  212. }
  213. mesDeviceService.save(mesDevice);
  214. return renderResult(Global.TRUE, text("保存设备成功!"));
  215. }
  216. /**
  217. * 导出数据
  218. */
  219. @RequiresPermissions("mes:mesDevice:view")
  220. @RequestMapping(value = "exportData")
  221. public void exportData(MesDevice mesDevice, HttpServletResponse response) {
  222. List<MesDevice> list = mesDeviceService.findList(mesDevice);
  223. String fileName = "设备" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
  224. try(ExcelExport ee = new ExcelExport("设备", MesDevice.class)){
  225. ee.setDataList(list).write(response, fileName);
  226. }
  227. }
  228. /**
  229. * 下载模板
  230. */
  231. @RequiresPermissions("mes:mesDevice:view")
  232. @RequestMapping(value = "importTemplate")
  233. public void importTemplate(HttpServletResponse response) {
  234. MesDevice mesDevice = new MesDevice();
  235. List<MesDevice> list = ListUtils.newArrayList(mesDevice);
  236. String fileName = "设备模板.xlsx";
  237. try(ExcelExport ee = new ExcelExport("设备", MesDevice.class, Type.IMPORT)){
  238. ee.setDataList(list).write(response, fileName);
  239. }
  240. }
  241. /**
  242. * 导入数据
  243. */
  244. @ResponseBody
  245. @RequiresPermissions("mes:mesDevice:edit")
  246. @PostMapping(value = "importData")
  247. public String importData(MultipartFile file) {
  248. try {
  249. String message = mesDeviceService.importData(file);
  250. return renderResult(Global.TRUE, "posfull:"+message);
  251. } catch (Exception ex) {
  252. return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
  253. }
  254. }
  255. /**
  256. * 停用数据
  257. */
  258. @RequiresPermissions("mes:mesDevice:edit")
  259. @RequestMapping(value = "disable")
  260. @ResponseBody
  261. public String disable(MesDevice mesDevice) {
  262. MesDevice where = new MesDevice();
  263. where.setStatus(MesDevice.STATUS_NORMAL);
  264. where.setParentCodes("," + mesDevice.getId() + ",");
  265. long count = mesDeviceService.findCount(where);
  266. if (count > 0) {
  267. return renderResult(Global.FALSE, text("该设备包含未停用的子设备!"));
  268. }
  269. mesDevice.setStatus(MesDevice.STATUS_DISABLE);
  270. mesDeviceService.updateStatus(mesDevice);
  271. return renderResult(Global.TRUE, text("停用设备成功"));
  272. }
  273. /**
  274. * 启用数据
  275. */
  276. @RequiresPermissions("mes:mesDevice:edit")
  277. @RequestMapping(value = "enable")
  278. @ResponseBody
  279. public String enable(MesDevice mesDevice) {
  280. mesDevice.setStatus(MesDevice.STATUS_NORMAL);
  281. mesDeviceService.updateStatus(mesDevice);
  282. return renderResult(Global.TRUE, text("启用设备成功"));
  283. }
  284. /**
  285. * 删除数据
  286. */
  287. @RequiresPermissions("mes:mesDevice:edit")
  288. @RequestMapping(value = "delete")
  289. @ResponseBody
  290. public String delete(MesDevice mesDevice) {
  291. mesDeviceService.delete(mesDevice);
  292. return renderResult(Global.TRUE, text("删除设备成功!"));
  293. }
  294. /**
  295. * 获取树结构数据
  296. * @param excludeCode 排除的Code
  297. * @param parentCode 设置父级编码返回一级
  298. * @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
  299. * @return
  300. */
  301. @RequiresPermissions("mes:mesDevice:view")
  302. @RequestMapping(value = "treeData")
  303. @ResponseBody
  304. public List<Map<String, Object>> treeData(String excludeCode, String parentCode, String isShowCode) {
  305. List<Map<String, Object>> mapList = ListUtils.newArrayList();
  306. MesDevice where = new MesDevice();
  307. where.setStatus(MesDevice.STATUS_NORMAL);
  308. if (StringUtils.isNotBlank(parentCode)){
  309. where.setParentCode(parentCode);
  310. }
  311. List<MesDevice> list = mesDeviceService.findList(where);
  312. for (int i=0; i<list.size(); i++){
  313. MesDevice e = list.get(i);
  314. // 过滤非正常的数据
  315. if (!MesDevice.STATUS_NORMAL.equals(e.getStatus())){
  316. continue;
  317. }
  318. // 过滤被排除的编码(包括所有子级)
  319. if (StringUtils.isNotBlank(excludeCode)){
  320. if (e.getId().equals(excludeCode)){
  321. continue;
  322. }
  323. if (e.getParentCodes().contains("," + excludeCode + ",")){
  324. continue;
  325. }
  326. }
  327. Map<String, Object> map = MapUtils.newHashMap();
  328. map.put("id", e.getId());
  329. map.put("pId", e.getParentCode());
  330. map.put("name", StringUtils.getTreeNodeName(isShowCode, e.getTreeCode(), e.getTreeName()));
  331. map.put("isParent", !e.getIsTreeLeaf());
  332. mapList.add(map);
  333. }
  334. return mapList;
  335. }
  336. /**
  337. * 修复表结构相关数据
  338. */
  339. @RequiresPermissions("mes:mesDevice:edit")
  340. @RequestMapping(value = "fixTreeData")
  341. @ResponseBody
  342. public String fixTreeData(MesDevice mesDevice){
  343. if (!UserUtils.getUser().isAdmin()){
  344. return renderResult(Global.FALSE, "操作失败,只有管理员才能进行修复!");
  345. }
  346. mesDeviceService.fixTreeData();
  347. return renderResult(Global.TRUE, "数据修复成功");
  348. }
  349. /**
  350. * api列表数据
  351. */
  352. @RequestMapping(value = "getList")
  353. @ResponseBody
  354. public CommonResp getList(MesDevice mesDevice) {
  355. List<MesDevice> list = mesDeviceService.findList(mesDevice);
  356. CommonResp<List<MesDevice>> resp = new CommonResp<>();
  357. resp.setData(list);
  358. return resp;
  359. }
  360. @RequiresPermissions("mes:mesDevice:view")
  361. @RequestMapping(value = "qrcode")
  362. public String qrcode(MesDevice mesDevice, Model model) {
  363. model.addAttribute("mesDevice", mesDevice);
  364. return "modules/mes/mesDeviceQrcode";
  365. }
  366. @RequestMapping(value = "infoBySn")
  367. @ResponseBody
  368. public CommonResp infoBySn(MesDevice mesDevice) {
  369. CommonResp<MesDevice> resp = new CommonResp<>();
  370. MesDevice info = mesDeviceService.findInfoBySn(mesDevice.getSn());
  371. if(ObjectUtils.isEmpty(info)){
  372. resp.setResult("false");
  373. resp.setMessage("设备不存在");
  374. return resp;
  375. }
  376. resp.setData(info);
  377. return resp;
  378. }
  379. @RequiresPermissions("mes:mesDevice:view")
  380. @RequestMapping(value = "map")
  381. public String map(MesDevice mesDevice, Model model) {
  382. model.addAttribute("mesDevice", mesDevice);
  383. return "modules/mes/equipment/equipment_map";
  384. }
  385. @RequestMapping(value = "oeeScreen")
  386. public String oeeScreen(Model model) {
  387. return "modules/mes/mesDeviceOeeScreen";
  388. }
  389. /**
  390. * 工位客户端按 gw + lineSn 上报设备状态(无需登录)
  391. */
  392. @PostMapping(value = "reportState")
  393. @ResponseBody
  394. public CommonResp<Map<String, Object>> reportState(@RequestBody(required = false) MesDeviceReportStateReq req, HttpServletRequest request) {
  395. CommonResp<Map<String, Object>> resp = new CommonResp<>();
  396. if (req == null) {
  397. req = new MesDeviceReportStateReq();
  398. }
  399. if (StringUtils.isBlank(req.getGw())) {
  400. req.setGw(request.getParameter("gw"));
  401. }
  402. if (StringUtils.isBlank(req.getLineSn())) {
  403. req.setLineSn(request.getParameter("lineSn"));
  404. }
  405. if (StringUtils.isBlank(req.getState())) {
  406. req.setState(request.getParameter("state"));
  407. }
  408. if (StringUtils.isBlank(req.getContent())) {
  409. req.setContent(request.getParameter("content"));
  410. }
  411. try {
  412. MesDevice device = mesDeviceStateReportService.reportByGw(req.getGw(), req.getLineSn(), req.getState(), req.getContent());
  413. Map<String, Object> data = MapUtils.newHashMap();
  414. data.put("deviceSn", device.getSn());
  415. data.put("gw", device.getGw());
  416. data.put("lineSn", device.getLineSn());
  417. data.put("state", req.getState());
  418. resp.setData(data);
  419. resp.setResult(Global.TRUE);
  420. resp.setMessage(text("操作成功!"));
  421. } catch (Exception e) {
  422. logger.error("设备状态上报失败", e);
  423. resp.setResult(Global.FALSE);
  424. resp.setMessage(e.getMessage());
  425. }
  426. return resp;
  427. }
  428. @RequestMapping(value = "screen5Data")
  429. @ResponseBody
  430. public CommonResp<Map<String, Object>> screen5Data() {
  431. CommonResp<Map<String, Object>> resp = new CommonResp<>();
  432. Map<String, Object> data = MapUtils.newHashMap();
  433. Date now = new Date();
  434. Date weekStart = DateUtils.addDays(now, -7);
  435. data.put("deviceCount", mesDeviceService.findList(new MesDevice()).size());
  436. MesDevicePreventTask preventQuery = new MesDevicePreventTask();
  437. preventQuery.setStartDate_gte(weekStart);
  438. preventQuery.setStartDate_lte(now);
  439. List<MesDevicePreventTask> preventList = mesDevicePreventTaskService.findList(preventQuery);
  440. data.put("preventiveCount", preventList.size());
  441. List<Map<String, Object>> preventiveStatus = ListUtils.newArrayList();
  442. long pending = preventList.stream().filter(p -> "0".equals(p.getState())).count();
  443. long processing = preventList.stream().filter(p -> "1".equals(p.getState())).count();
  444. long completed = preventList.stream().filter(p -> "2".equals(p.getState())).count();
  445. long unfinished = preventList.stream().filter(p -> "3".equals(p.getState())).count();
  446. Map<String, Object> pendingMap = MapUtils.newHashMap();
  447. pendingMap.put("name", "未开始");
  448. pendingMap.put("value", pending);
  449. preventiveStatus.add(pendingMap);
  450. Map<String, Object> processingMap = MapUtils.newHashMap();
  451. processingMap.put("name", "进行中");
  452. processingMap.put("value", processing);
  453. preventiveStatus.add(processingMap);
  454. Map<String, Object> completedMap = MapUtils.newHashMap();
  455. completedMap.put("name", "已完成");
  456. completedMap.put("value", completed);
  457. preventiveStatus.add(completedMap);
  458. Map<String, Object> unfinishedMap = MapUtils.newHashMap();
  459. unfinishedMap.put("name", "未完成");
  460. unfinishedMap.put("value", unfinished);
  461. preventiveStatus.add(unfinishedMap);
  462. data.put("preventiveStatus", preventiveStatus);
  463. data.put("preventiveList", preventList.stream().limit(10).collect(Collectors.toList()));
  464. MesDeviceUrgency urgencyQuery = new MesDeviceUrgency();
  465. urgencyQuery.setStartDate_gte(weekStart);
  466. urgencyQuery.setStartDate_lte(now);
  467. List<MesDeviceUrgency> urgencyList = mesDeviceUrgencyService.findList(urgencyQuery);
  468. data.put("urgencyCount", urgencyList.size());
  469. List<Map<String, Object>> urgencyStatus = ListUtils.newArrayList();
  470. long urgencyPending = urgencyList.stream().filter(u -> "0".equals(u.getState())).count();
  471. long urgencyCompleted = urgencyList.stream().filter(u -> "1".equals(u.getState())).count();
  472. Map<String, Object> urgencyPendingMap = MapUtils.newHashMap();
  473. urgencyPendingMap.put("name", "维修中");
  474. urgencyPendingMap.put("value", urgencyPending);
  475. urgencyPendingMap.put("color", "#ff9800");
  476. urgencyStatus.add(urgencyPendingMap);
  477. Map<String, Object> urgencyCompletedMap = MapUtils.newHashMap();
  478. urgencyCompletedMap.put("name", "已完成");
  479. urgencyCompletedMap.put("value", urgencyCompleted);
  480. urgencyCompletedMap.put("color", "#00d5d8");
  481. urgencyStatus.add(urgencyCompletedMap);
  482. data.put("urgencyStatus", urgencyStatus);
  483. Map<String, Long> contentCount = urgencyList.stream()
  484. .filter(u -> StringUtils.isNotBlank(u.getContent()))
  485. .collect(Collectors.groupingBy(u -> u.getContent(), Collectors.counting()));
  486. List<Map<String, Object>> urgencyContent = ListUtils.newArrayList();
  487. contentCount.entrySet().stream()
  488. .sorted((a, b) -> Long.compare(b.getValue(), a.getValue()))
  489. .limit(6)
  490. .forEach(e -> {
  491. Map<String, Object> contentMap = MapUtils.newHashMap();
  492. contentMap.put("name", e.getKey());
  493. contentMap.put("value", e.getValue());
  494. urgencyContent.add(contentMap);
  495. });
  496. data.put("urgencyContent", urgencyContent);
  497. data.put("urgencyList", urgencyList.stream().limit(10).collect(Collectors.toList()));
  498. data.put("weekStart", DateUtils.formatDate(weekStart, "yyyy-MM-dd HH:mm:ss"));
  499. data.put("weekEnd", DateUtils.formatDate(now, "yyyy-MM-dd HH:mm:ss"));
  500. resp.setData(data);
  501. resp.setResult(Global.TRUE);
  502. return resp;
  503. }
  504. @RequestMapping(value = "oeeScreenData")
  505. @ResponseBody
  506. public CommonResp<Map<String, Object>> oeeScreenData() {
  507. CommonResp<Map<String, Object>> resp = new CommonResp<>();
  508. resp.setData(mesDeviceOeeStatsService.buildOeeScreenData());
  509. resp.setResult(Global.TRUE);
  510. return resp;
  511. }
  512. }