厂区人员、周报、设备、数字孪生数据接口修改
正在显示
13 个修改的文件
包含
301 行增加
和
32 行删除
sk-module-biz/src/main/java/com/skua/modules/digitaltwins/DigitalEquipmentController.java
0 → 100644
1 | package com.skua.modules.digitaltwins; | ||
2 | |||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
4 | import com.skua.core.api.vo.Result; | ||
5 | import com.skua.core.api.vo.TransTreeModel; | ||
6 | import com.skua.core.api.vo.TreeData; | ||
7 | import com.skua.core.context.SpringContextUtils; | ||
8 | import com.skua.core.util.ConvertUtils; | ||
9 | import com.skua.core.util.TreeUtils; | ||
10 | import com.skua.modules.equipment.entity.EquipmentInfo; | ||
11 | import com.skua.modules.equipment.service.IEquipmentInfoService; | ||
12 | import com.skua.modules.system.datestandard.entity.SysMonitorMetricInfo; | ||
13 | import com.skua.modules.system.datestandard.service.ISysMonitorMetricInfoService; | ||
14 | import io.swagger.annotations.Api; | ||
15 | import io.swagger.annotations.ApiOperation; | ||
16 | import lombok.extern.slf4j.Slf4j; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | ||
18 | import org.springframework.jdbc.core.JdbcTemplate; | ||
19 | import org.springframework.web.bind.annotation.GetMapping; | ||
20 | import org.springframework.web.bind.annotation.RequestMapping; | ||
21 | import org.springframework.web.bind.annotation.RequestParam; | ||
22 | import org.springframework.web.bind.annotation.RestController; | ||
23 | |||
24 | import java.text.ParseException; | ||
25 | import java.util.*; | ||
26 | import java.util.stream.Collectors; | ||
27 | |||
28 | /** | ||
29 | * <pre> | ||
30 | * 设备中心 | ||
31 | * </pre> | ||
32 | * @author Li Yuanyuan | ||
33 | * @version V0.1, 2024年8月5日 下午5:02:16 | ||
34 | */ | ||
35 | @Slf4j | ||
36 | @Api(tags="/数字孪生/设备中心") | ||
37 | @RestController | ||
38 | @RequestMapping("/v1/digital/equipmentAnalysis") | ||
39 | public class DigitalEquipmentController { | ||
40 | @Autowired | ||
41 | private IEquipmentInfoService equipmentInfoService; | ||
42 | @Autowired | ||
43 | private ISysMonitorMetricInfoService sysMonitorMetricInfoService; | ||
44 | /** | ||
45 | * 智能报警按构筑物统计 | ||
46 | * @return | ||
47 | * @throws ParseException | ||
48 | * @author Li Yuanyuan, 2024年8月6日 下午2:54:53 | ||
49 | * @Description: TODO(这里描述这个方法的需求变更情况) | ||
50 | */ | ||
51 | @ApiOperation(value="构筑物设备树", notes="构造构筑物和设备分组树") | ||
52 | @GetMapping(value = "/getEquipmentTree") | ||
53 | public Result<List<TreeData>> getEquipmentTree() throws ParseException{ | ||
54 | Result<List<TreeData>> result = new Result<List<TreeData>>(); | ||
55 | JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
56 | //使用sql统计 | ||
57 | String sql = "SELECT id,struct_name AS title,'root' AS pid,'struct' as tree_type FROM sys_struct_dict \r\n" + | ||
58 | "UNION ALL\r\n" + | ||
59 | "SELECT id,equipment_name,structures AS pid,'equipment' as tree_type FROM equipment_info where digital_twins_struct_code!='' and digital_twins_struct_code is not null"; | ||
60 | List<Map<String,Object>> dataList = masterDB.queryForList(sql); | ||
61 | List<TransTreeModel> transTreeModels = dataList.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList()); | ||
62 | List<TreeData> treeList=TreeUtils.buildTreeForParentId(transTreeModels, "root"); | ||
63 | result.setResult(treeList); | ||
64 | result.setSuccess(true); | ||
65 | return result; | ||
66 | } | ||
67 | /** | ||
68 | * 将SysDcodeConfig对象数据填充到TransTreeModel中 | ||
69 | * @param dataMap | ||
70 | * @return | ||
71 | */ | ||
72 | private TransTreeModel convertToTreeModel(Map<String,Object> dataMap) { | ||
73 | TransTreeModel transTreeModel = new TransTreeModel(); | ||
74 | transTreeModel.setId(ConvertUtils.getString(dataMap.get("id"))); | ||
75 | transTreeModel.setPid(ConvertUtils.getString(dataMap.get("pid"))); | ||
76 | transTreeModel.setTitle(ConvertUtils.getString(dataMap.get("title"))); | ||
77 | Map<String,String> map=new HashMap<String,String>(); | ||
78 | map.put("treeType", ConvertUtils.getString(dataMap.get("tree_type"))); | ||
79 | transTreeModel.setMap(map); | ||
80 | return transTreeModel; | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * 根据传入的构筑物id或设备id获取相关设备运行状态 | ||
85 | * @param treeType | ||
86 | * @param ids | ||
87 | * @return | ||
88 | */ | ||
89 | @ApiOperation(value = "设备-设备运行状态", notes = "设备-设备运行状态,根据构筑物id/设备id获取设备状态【0停止/1运行/2故障】") | ||
90 | @GetMapping(value = "/queryEquipmentStatusById") | ||
91 | public Result<Map<String,Object>> queryEquipmentStatusById(@RequestParam(value = "treeType") String treeType,@RequestParam(value = "ids") String ids) { | ||
92 | Result<Map<String,Object>> result = new Result<>(); | ||
93 | //结果接收对象 | ||
94 | Map<String,Object> resultMap = new HashMap<String,Object>(); | ||
95 | List<EquipmentInfo> equipmentInfoList = new ArrayList<EquipmentInfo>(); | ||
96 | //判断参数类型,如果是构筑物类型,则先获取设备id集合,如果是设备类型,则直接使用 | ||
97 | if("struct".equals(treeType)) { | ||
98 | QueryWrapper<EquipmentInfo> equipmentQueryWrapper = new QueryWrapper<>(); | ||
99 | equipmentQueryWrapper.isNotNull("digital_twins_struct_code"); | ||
100 | equipmentQueryWrapper.ne("digital_twins_struct_code", ""); | ||
101 | equipmentInfoList = equipmentInfoService.list(equipmentQueryWrapper); | ||
102 | }else { | ||
103 | List<String> idList = Arrays.asList(ids.split(",")); | ||
104 | QueryWrapper<EquipmentInfo> equipmentQueryWrapper = new QueryWrapper<>(); | ||
105 | equipmentQueryWrapper.in("id", idList); | ||
106 | equipmentInfoList = equipmentInfoService.list(equipmentQueryWrapper); | ||
107 | } | ||
108 | //获取已关联设备的运行状态点 | ||
109 | List<String> equipmentIdList = new ArrayList<>(); | ||
110 | for(EquipmentInfo equipmentInfo : equipmentInfoList) { | ||
111 | equipmentIdList.add(equipmentInfo.getId()); | ||
112 | } | ||
113 | //根据设备id集合获取设备运行点位 | ||
114 | QueryWrapper<SysMonitorMetricInfo> queryWrapper = new QueryWrapper<>(); | ||
115 | queryWrapper.eq("metric_type", "1"); | ||
116 | queryWrapper.ne("metric_express1", ""); | ||
117 | queryWrapper.isNotNull("metric_express1"); | ||
118 | queryWrapper.in("equipment_code", equipmentIdList); | ||
119 | List<SysMonitorMetricInfo> sysMonitorMetricInfoList = sysMonitorMetricInfoService.list(queryWrapper); | ||
120 | |||
121 | List<String> equipmentRunPointList = new ArrayList<>(); | ||
122 | Map<String,String> equipmentToPointMap = new HashMap<String,String>(); | ||
123 | for(SysMonitorMetricInfo sysMonitorMetricInfo : sysMonitorMetricInfoList) { | ||
124 | equipmentRunPointList.add(sysMonitorMetricInfo.getId()); | ||
125 | equipmentToPointMap.put(sysMonitorMetricInfo.getEquipmentCode(), sysMonitorMetricInfo.getId()); | ||
126 | } | ||
127 | Map<String, Map<String, Object>> tempEquipmentStateMap = sysMonitorMetricInfoService.getEquipRunState(equipmentRunPointList); | ||
128 | |||
129 | for(EquipmentInfo equipmentInfo : equipmentInfoList) { | ||
130 | String equipmentId = equipmentInfo.getId(); | ||
131 | String point = equipmentToPointMap.get(equipmentId); | ||
132 | Map<String, Object> tempMap = tempEquipmentStateMap.get(point); | ||
133 | if(tempMap!=null&&tempMap.size()>0) { | ||
134 | resultMap.put(equipmentInfo.getId(), ConvertUtils.getString(tempMap.get("value"))); | ||
135 | }else{ | ||
136 | resultMap.put(equipmentInfo.getId(), "-1"); | ||
137 | } | ||
138 | } | ||
139 | result.setResult(resultMap); | ||
140 | return result; | ||
141 | } | ||
142 | |||
143 | } |
... | @@ -336,7 +336,7 @@ | ... | @@ -336,7 +336,7 @@ |
336 | SELECT | 336 | SELECT |
337 | RIGHT(LEFT( v.time, 7 ),2) AS time, | 337 | RIGHT(LEFT( v.time, 7 ),2) AS time, |
338 | v2.sjwscll, | 338 | v2.sjwscll, |
339 | v2.rwscll, | 339 | f.pro_scale AS rwscll, |
340 | v2.scsj, | 340 | v2.scsj, |
341 | ROUND(v2.scsj*f.pro_scale,2) AS wsclnl, | 341 | ROUND(v2.scsj*f.pro_scale,2) AS wsclnl, |
342 | ROUND( SUM( v.DLHJ ) / 10000, 2 ) AS dl, | 342 | ROUND( SUM( v.DLHJ ) / 10000, 2 ) AS dl, | ... | ... |
... | @@ -11,7 +11,6 @@ import com.skua.modules.custom.mapper.FCustomReportDatasetMapper; | ... | @@ -11,7 +11,6 @@ import com.skua.modules.custom.mapper.FCustomReportDatasetMapper; |
11 | import com.skua.modules.custom.service.IFCustomReportDatasetService; | 11 | import com.skua.modules.custom.service.IFCustomReportDatasetService; |
12 | import com.skua.modules.custom.vo.DepartWeekReportVO; | 12 | import com.skua.modules.custom.vo.DepartWeekReportVO; |
13 | import com.skua.modules.custom.vo.FCustomReportDatasetVO; | 13 | import com.skua.modules.custom.vo.FCustomReportDatasetVO; |
14 | |||
15 | import java.text.DecimalFormat; | 14 | import java.text.DecimalFormat; |
16 | import java.time.LocalDate; | 15 | import java.time.LocalDate; |
17 | import java.time.format.DateTimeFormatter; | 16 | import java.time.format.DateTimeFormatter; |
... | @@ -22,14 +21,12 @@ import com.skua.modules.report.vo.*; | ... | @@ -22,14 +21,12 @@ import com.skua.modules.report.vo.*; |
22 | import com.skua.modules.report.vo.largeScreen.*; | 21 | import com.skua.modules.report.vo.largeScreen.*; |
23 | import com.skua.tool.util.DateUtils; | 22 | import com.skua.tool.util.DateUtils; |
24 | import com.skua.tool.util.JSUtils; | 23 | import com.skua.tool.util.JSUtils; |
25 | import io.swagger.annotations.ApiModelProperty; | 24 | import io.micrometer.core.instrument.util.TimeUtils; |
26 | import org.apache.commons.lang.StringUtils; | 25 | import org.apache.commons.lang.StringUtils; |
27 | import org.springframework.beans.factory.annotation.Autowired; | ||
28 | import org.springframework.jdbc.core.BeanPropertyRowMapper; | 26 | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
29 | import org.springframework.jdbc.core.JdbcTemplate; | 27 | import org.springframework.jdbc.core.JdbcTemplate; |
30 | import org.springframework.stereotype.Service; | 28 | import org.springframework.stereotype.Service; |
31 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 29 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
32 | |||
33 | import javax.annotation.Resource; | 30 | import javax.annotation.Resource; |
34 | 31 | ||
35 | /** | 32 | /** |
... | @@ -42,6 +39,8 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa | ... | @@ -42,6 +39,8 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa |
42 | private FCustomReportDatasetMapper mapper; | 39 | private FCustomReportDatasetMapper mapper; |
43 | @Resource | 40 | @Resource |
44 | private CommonSqlMapper commonSqlMapper; | 41 | private CommonSqlMapper commonSqlMapper; |
42 | private static DecimalFormat df = new DecimalFormat("#.##"); | ||
43 | |||
45 | /* (non-Javadoc) | 44 | /* (non-Javadoc) |
46 | * @see com.skua.modules.custom.service.IFCustomReportDatasetService#getFillReportList() | 45 | * @see com.skua.modules.custom.service.IFCustomReportDatasetService#getFillReportList() |
47 | */ | 46 | */ |
... | @@ -603,21 +602,54 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa | ... | @@ -603,21 +602,54 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa |
603 | public Map<String, Object> reportWeekShow(String dataTime, String week) { | 602 | public Map<String, Object> reportWeekShow(String dataTime, String week) { |
604 | Map<String, Object> map = new HashMap<>(); | 603 | Map<String, Object> map = new HashMap<>(); |
605 | List<DepartWeekReportVO> list = new ArrayList<>(); | 604 | List<DepartWeekReportVO> list = new ArrayList<>(); |
605 | List<DepartWeekReportVO> hbList = new ArrayList<>(); | ||
606 | Map<String,String> weekMap = getWeekDate(dataTime,week); | 606 | Map<String,String> weekMap = getWeekDate(dataTime,week); |
607 | String startDate = weekMap.get("start"); | 607 | String startDate = weekMap.get("start"); |
608 | String endDate = weekMap.get("end"); | 608 | String endDate = weekMap.get("end"); |
609 | String startDateHb = getBeforeDate(startDate,7); | ||
610 | String endDateHb = getBeforeDate(endDate,7); | ||
609 | String field3a24 = ReportConstant.fieldDl + "," + ReportConstant.fieldYj + "," + ReportConstant.fieldWnl; | 611 | String field3a24 = ReportConstant.fieldDl + "," + ReportConstant.fieldYj + "," + ReportConstant.fieldWnl; |
610 | String dataViewName3a24 = ReportViewUtil.buildView(ReportConstant.view3a24, field3a24, "", startDate, endDate); | 612 | String dataViewName3a24 = ReportViewUtil.buildView(ReportConstant.view3a24, field3a24, "", startDate, endDate); |
611 | String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.fieldClsl, "", startDate, endDate); | 613 | String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.fieldClsl, "", startDate, endDate); |
612 | list = mapper.getWeekReportData(startDate, endDate, dataViewName3a24, dataViewName2119); | 614 | list = mapper.getWeekReportData(startDate, endDate, dataViewName3a24, dataViewName2119); |
615 | String dataViewName3a24Hb = ReportViewUtil.buildView(ReportConstant.view3a24, field3a24, "", startDateHb, endDateHb); | ||
616 | String dataViewName2119Hb = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.fieldClsl, "", startDateHb, endDateHb); | ||
617 | hbList = mapper.getWeekReportData(startDateHb, endDateHb, dataViewName3a24Hb, dataViewName2119Hb); | ||
618 | Map<String, Object> totalMap = getTotalData(list); | ||
619 | Map<String, Object> totalMapHb = getTotalData(hbList); | ||
613 | map.put("start", startDate);//开始时间 | 620 | map.put("start", startDate);//开始时间 |
614 | map.put("end", endDate);//结束时间 | 621 | map.put("end", endDate);//结束时间 |
615 | map.put("zclsl", "776");//处理水量合计 | 622 | String zclsl = totalMap.getOrDefault("zclsl","0").toString(); |
616 | map.put("rjclsl", "110.7");//日均处理水量 | 623 | map.put("zclsl", zclsl);//处理水量合计 |
617 | map.put("rjclsl_hb", "2");//较上周增减量 | 624 | |
618 | map.put("dsdh", "0.329");//吨水电耗 | 625 | String rjclsl = totalMap.getOrDefault("rjclsl","0").toString(); |
619 | map.put("dsdh_hb", "0.002");//吨水电耗较上周增减量 | 626 | map.put("rjclsl", rjclsl);//日均处理水量 |
620 | map.put("cnl", "3978.8");//产泥量 | 627 | String rjclslHb = totalMapHb.getOrDefault("rjclsl","0").toString(); |
628 | String rjclslStr = "";//文字描述 | ||
629 | String dsdhStr = "";//文字描述 | ||
630 | //较上周增减量 rjclsl - rjclslHb | ||
631 | if(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb) > 0){ | ||
632 | rjclslStr = "+"+df.format(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb))+"万吨/日"; | ||
633 | }else if(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb) < 0){ | ||
634 | rjclslStr = df.format(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb))+"万吨/日"; | ||
635 | }else{ | ||
636 | rjclslStr = "持平"; | ||
637 | } | ||
638 | map.put("rjclsl_hb", rjclslStr); | ||
639 | String dsdh = totalMap.getOrDefault("dsdh","0").toString(); | ||
640 | map.put("dsdh", dsdh);//吨水电耗 | ||
641 | String dsdhHb = totalMapHb.getOrDefault("dsdh","0").toString(); | ||
642 | //吨水电耗较上周增减量 dsdh - dsdhHb | ||
643 | if(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb) > 0){ | ||
644 | dsdhStr = "+"+df.format(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb))+"Kwh/吨"; | ||
645 | }else if(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb) < 0){ | ||
646 | dsdhStr = df.format(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb))+"Kwh/吨"; | ||
647 | }else{ | ||
648 | dsdhStr = "持平"; | ||
649 | } | ||
650 | map.put("dsdh_hb", dsdhStr); | ||
651 | String cnl = totalMap.getOrDefault("cnl","0").toString(); | ||
652 | map.put("cnl", cnl);//产泥量 | ||
621 | map.put("list", list); | 653 | map.put("list", list); |
622 | map.put("scqk", "(1)本周暂无生产情况说明");//生产情况 | 654 | map.put("scqk", "(1)本周暂无生产情况说明");//生产情况 |
623 | map.put("wxqk", "(1)本周暂无设备大修、更新情况");// | 655 | map.put("wxqk", "(1)本周暂无设备大修、更新情况");// |
... | @@ -625,4 +657,46 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa | ... | @@ -625,4 +657,46 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa |
625 | map.put("qt", "(1)本周暂无其他情况说明");//其他 | 657 | map.put("qt", "(1)本周暂无其他情况说明");//其他 |
626 | return map; | 658 | return map; |
627 | } | 659 | } |
660 | |||
661 | private Map<String, Object> getTotalData(List<DepartWeekReportVO> list) { | ||
662 | Map<String, Object> map = new HashMap<>(); | ||
663 | int num = 0;//计数 | ||
664 | double zclsl = 0.00;//处理水量 | ||
665 | double dsdh = 0.00;//吨水电耗 | ||
666 | double cnl = 0.00;//产泥量 | ||
667 | for (DepartWeekReportVO departWeekReportVO : list) { | ||
668 | num = num+1; | ||
669 | if(ConvertUtils.isNotEmpty(departWeekReportVO.getClsl())){ | ||
670 | zclsl = zclsl + Double.parseDouble(departWeekReportVO.getClsl()); | ||
671 | } | ||
672 | if(ConvertUtils.isNotEmpty(departWeekReportVO.getDsdh())){ | ||
673 | dsdh = dsdh + Double.parseDouble(departWeekReportVO.getDsdh()); | ||
674 | } | ||
675 | if(ConvertUtils.isNotEmpty(departWeekReportVO.getWnl())){ | ||
676 | cnl = cnl + Double.parseDouble(departWeekReportVO.getWnl()); | ||
677 | } | ||
678 | } | ||
679 | map.put("zclsl", df.format(zclsl));//处理水量合计 | ||
680 | map.put("rjclsl", df.format(zclsl/num));//日均处理水量 | ||
681 | map.put("dsdh", df.format(dsdh/num));//吨水电耗 | ||
682 | map.put("cnl", df.format(cnl));//产泥量 | ||
683 | return map; | ||
684 | } | ||
685 | |||
686 | /** | ||
687 | * 获取n天前的日期 | ||
688 | * @param day | ||
689 | * @param num | ||
690 | * @return | ||
691 | */ | ||
692 | public static String getBeforeDate(String day,int num) { | ||
693 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
694 | try { | ||
695 | LocalDate date = LocalDate.parse(day, formatter); | ||
696 | LocalDate daysAgo = date.minusDays(num); | ||
697 | return daysAgo.format(formatter); | ||
698 | } catch (Exception e) { | ||
699 | return day; | ||
700 | } | ||
701 | } | ||
628 | } | 702 | } | ... | ... |
... | @@ -7,6 +7,7 @@ import java.util.*; | ... | @@ -7,6 +7,7 @@ import java.util.*; |
7 | import javax.servlet.http.HttpServletRequest; | 7 | import javax.servlet.http.HttpServletRequest; |
8 | import javax.servlet.http.HttpServletResponse; | 8 | import javax.servlet.http.HttpServletResponse; |
9 | 9 | ||
10 | import cn.hutool.json.JSONObject; | ||
10 | import com.skua.core.context.BaseContextHandler; | 11 | import com.skua.core.context.BaseContextHandler; |
11 | import org.apache.commons.lang.StringUtils; | 12 | import org.apache.commons.lang.StringUtils; |
12 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; | 13 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
... | @@ -153,6 +154,12 @@ public class EquipmentController { | ... | @@ -153,6 +154,12 @@ public class EquipmentController { |
153 | public Result<List<EquipmentStatisticVO>> statisticsCtrl(EquipmentStatisticDTO equipmentStatisticDTO) throws Exception { | 154 | public Result<List<EquipmentStatisticVO>> statisticsCtrl(EquipmentStatisticDTO equipmentStatisticDTO) throws Exception { |
154 | Result<List<EquipmentStatisticVO>> result = new Result<>(); | 155 | Result<List<EquipmentStatisticVO>> result = new Result<>(); |
155 | List<EquipmentStatisticVO> voList = new ArrayList<>(); | 156 | List<EquipmentStatisticVO> voList = new ArrayList<>(); |
157 | String departs = "";//机构 | ||
158 | if(ConvertUtils.isNotEmpty(equipmentStatisticDTO.getDepartId())){ | ||
159 | departs = equipmentStatisticDTO.getDepartId(); | ||
160 | }else{ | ||
161 | departs = BaseContextHandler.getDeparts(); | ||
162 | } | ||
156 | // 统计 departId => 所属机构 | 163 | // 统计 departId => 所属机构 |
157 | if (equipmentStatisticDTO.getShowDepartId()) { | 164 | if (equipmentStatisticDTO.getShowDepartId()) { |
158 | List<Map<String, Object>> departIdMapList = WrapperFactory.joinWrapper() | 165 | List<Map<String, Object>> departIdMapList = WrapperFactory.joinWrapper() |
... | @@ -162,6 +169,7 @@ public class EquipmentController { | ... | @@ -162,6 +169,7 @@ public class EquipmentController { |
162 | .innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) | 169 | .innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) |
163 | .where() | 170 | .where() |
164 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) | 171 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) |
172 | .in(true,"depart_id", Arrays.asList(departs.split(","))) | ||
165 | .groupBy(true, "depart_id") | 173 | .groupBy(true, "depart_id") |
166 | .queryWrapperForList(); | 174 | .queryWrapperForList(); |
167 | EquipmentStatisticVO departIdVO = new EquipmentStatisticVO(); | 175 | EquipmentStatisticVO departIdVO = new EquipmentStatisticVO(); |
... | @@ -190,6 +198,7 @@ public class EquipmentController { | ... | @@ -190,6 +198,7 @@ public class EquipmentController { |
190 | .innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) | 198 | .innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) |
191 | .where() | 199 | .where() |
192 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) | 200 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) |
201 | .in(true,"depart_id", Arrays.asList(departs.split(","))) | ||
193 | .groupBy(true, "asset_type") | 202 | .groupBy(true, "asset_type") |
194 | .queryWrapperForList(); | 203 | .queryWrapperForList(); |
195 | EquipmentStatisticVO assetTypeVO = new EquipmentStatisticVO(); | 204 | EquipmentStatisticVO assetTypeVO = new EquipmentStatisticVO(); |
... | @@ -215,6 +224,7 @@ public class EquipmentController { | ... | @@ -215,6 +224,7 @@ public class EquipmentController { |
215 | .innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) | 224 | .innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) |
216 | .where() | 225 | .where() |
217 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) | 226 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) |
227 | .in(true,"depart_id", Arrays.asList(departs.split(","))) | ||
218 | .eq(true, "asset_type", "assets-material-type") | 228 | .eq(true, "asset_type", "assets-material-type") |
219 | .groupBy(true, "supplies_type") | 229 | .groupBy(true, "supplies_type") |
220 | .queryWrapperForList(); | 230 | .queryWrapperForList(); |
... | @@ -241,6 +251,7 @@ public class EquipmentController { | ... | @@ -241,6 +251,7 @@ public class EquipmentController { |
241 | .leftJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) | 251 | .leftJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id")) |
242 | .where() | 252 | .where() |
243 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) | 253 | .eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial()) |
254 | .in(true,"depart_id", Arrays.asList(departs.split(","))) | ||
244 | .groupBy(true, "equipment_top_type") | 255 | .groupBy(true, "equipment_top_type") |
245 | .queryWrapperForList(); | 256 | .queryWrapperForList(); |
246 | EquipmentStatisticVO equipmentTypeVO = new EquipmentStatisticVO(); | 257 | EquipmentStatisticVO equipmentTypeVO = new EquipmentStatisticVO(); |
... | @@ -479,9 +490,8 @@ public class EquipmentController { | ... | @@ -479,9 +490,8 @@ public class EquipmentController { |
479 | .like(StringUtils.isNotEmpty(equipmentCode), "equipment_code", equipmentCode) | 490 | .like(StringUtils.isNotEmpty(equipmentCode), "equipment_code", equipmentCode) |
480 | .eq(StringUtils.isNotEmpty(equipmentStatus), "equipment_status", equipmentStatus) | 491 | .eq(StringUtils.isNotEmpty(equipmentStatus), "equipment_status", equipmentStatus) |
481 | .like(StringUtils.isNotEmpty(installPosition), EquipmentInfo::getInstallPosition, installPosition) | 492 | .like(StringUtils.isNotEmpty(installPosition), EquipmentInfo::getInstallPosition, installPosition) |
482 | 493 | .eq(StringUtils.isNotEmpty(equipmentDTO.getEquipmentInfo().getId()), "equipment_info.id", equipmentDTO.getEquipmentInfo().getId()) | |
483 | .eq(StringUtils.isNotEmpty(equipmentDTO.getEquipmentInfo().getId()), "equipment_info.id", equipmentDTO.getEquipmentInfo().getId()); | 494 | .orderBy(true,false,"equipment_info.create_time"); |
484 | |||
485 | Page<Map<String, Object>> mapPage = (Page<Map<String, Object>>) base.queryForPage(new Page<>(equipmentDTO.getPageNo(), equipmentDTO.getPageSize())); | 495 | Page<Map<String, Object>> mapPage = (Page<Map<String, Object>>) base.queryForPage(new Page<>(equipmentDTO.getPageNo(), equipmentDTO.getPageSize())); |
486 | 496 | ||
487 | // 转义 | 497 | // 转义 |
... | @@ -795,4 +805,19 @@ public class EquipmentController { | ... | @@ -795,4 +805,19 @@ public class EquipmentController { |
795 | return result; | 805 | return result; |
796 | } | 806 | } |
797 | 807 | ||
808 | @ApiOperation(value = "设备台账-孪生体批量配置", notes = "设备台账-孪生体批量配置") | ||
809 | @PostMapping(value = "/batchConfigDigitaltwins") | ||
810 | public Result<String> batchConfigDigitaltwins(@RequestBody JSONObject jsonObject) { | ||
811 | Result<String> result = new Result<>(); | ||
812 | try { | ||
813 | equipmentInfoService.batchConfigDigitaltwins(jsonObject); | ||
814 | result.setSuccess(true); | ||
815 | result.setResult("批量配置成功"); | ||
816 | } catch (Exception e) { | ||
817 | e.printStackTrace(); | ||
818 | result.error500("批量配置失败"); | ||
819 | } | ||
820 | return result; | ||
821 | } | ||
822 | |||
798 | } | 823 | } | ... | ... |
... | @@ -290,4 +290,7 @@ public class EquipmentInfo { | ... | @@ -290,4 +290,7 @@ public class EquipmentInfo { |
290 | @ApiModelProperty(value = "企业负责人") | 290 | @ApiModelProperty(value = "企业负责人") |
291 | private String enterpriseManager; | 291 | private String enterpriseManager; |
292 | 292 | ||
293 | @ApiModelProperty(value = "数字孪生模型区域编码") | ||
294 | private java.lang.String digitalTwinsStructCode; | ||
295 | |||
293 | } | 296 | } | ... | ... |
... | @@ -23,4 +23,5 @@ public interface EquipmentInfoMapper extends BaseMapper<EquipmentInfo> { | ... | @@ -23,4 +23,5 @@ public interface EquipmentInfoMapper extends BaseMapper<EquipmentInfo> { |
23 | */ | 23 | */ |
24 | List<EquipmentInfoForMonitorVO> queryCustomPageList(Page<EquipmentInfoForMonitorVO> pageList, EquipmentInfoForMonitorVO equipmentInfoForMonitorVO); | 24 | List<EquipmentInfoForMonitorVO> queryCustomPageList(Page<EquipmentInfoForMonitorVO> pageList, EquipmentInfoForMonitorVO equipmentInfoForMonitorVO); |
25 | 25 | ||
26 | void clearDigitaltwins(); | ||
26 | } | 27 | } | ... | ... |
... | @@ -23,6 +23,9 @@ | ... | @@ -23,6 +23,9 @@ |
23 | </if> | 23 | </if> |
24 | <if test="equipmentInfoForMonitorVO.equipmentName!=null and equipmentInfoForMonitorVO.equipmentName!=''"> | 24 | <if test="equipmentInfoForMonitorVO.equipmentName!=null and equipmentInfoForMonitorVO.equipmentName!=''"> |
25 | and a.equipment_name LIKE CONCAT(CONCAT('%', #{equipmentInfoForMonitorVO.equipmentName}),'%') | 25 | and a.equipment_name LIKE CONCAT(CONCAT('%', #{equipmentInfoForMonitorVO.equipmentName}),'%') |
26 | </if> | 26 | </if> |
27 | </select> | 27 | </select> |
28 | </mapper> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
28 | <update id="clearDigitaltwins"> | ||
29 | update equipment_info set digital_twins_struct_code = '' | ||
30 | </update> | ||
31 | </mapper> | ... | ... |
... | @@ -4,6 +4,7 @@ import java.io.IOException; | ... | @@ -4,6 +4,7 @@ import java.io.IOException; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | import java.util.Map; | 5 | import java.util.Map; |
6 | 6 | ||
7 | import cn.hutool.json.JSONObject; | ||
7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 8 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
8 | import com.baomidou.mybatisplus.extension.service.IService; | 9 | import com.baomidou.mybatisplus.extension.service.IService; |
9 | import com.skua.core.api.vo.Result; | 10 | import com.skua.core.api.vo.Result; |
... | @@ -84,4 +85,6 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> { | ... | @@ -84,4 +85,6 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> { |
84 | void importExcel(MultipartFile file, String departId) throws Exception; | 85 | void importExcel(MultipartFile file, String departId) throws Exception; |
85 | 86 | ||
86 | String reCreateQrCode(String id); | 87 | String reCreateQrCode(String id); |
88 | |||
89 | void batchConfigDigitaltwins(JSONObject jsonObject); | ||
87 | } | 90 | } | ... | ... |
... | @@ -9,6 +9,7 @@ import java.util.List; | ... | @@ -9,6 +9,7 @@ import java.util.List; |
9 | import java.util.Map; | 9 | import java.util.Map; |
10 | import java.util.Set; | 10 | import java.util.Set; |
11 | 11 | ||
12 | import cn.hutool.json.JSONObject; | ||
12 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 13 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
13 | import com.skua.core.context.BaseContextHandler; | 14 | import com.skua.core.context.BaseContextHandler; |
14 | import com.skua.core.excel.CustomExcelUtil; | 15 | import com.skua.core.excel.CustomExcelUtil; |
... | @@ -340,4 +341,23 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E | ... | @@ -340,4 +341,23 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E |
340 | return qrCodePath; | 341 | return qrCodePath; |
341 | } | 342 | } |
342 | 343 | ||
344 | @Override | ||
345 | public void batchConfigDigitaltwins(JSONObject json) { | ||
346 | List<String> idList = (List<String>)json.get("equip_id_list"); | ||
347 | //清空孪生体配置数据 | ||
348 | equipmentInfoMapper.clearDigitaltwins(); | ||
349 | //组装需要更新的设备集合 | ||
350 | List<EquipmentInfo> equipmentInfoList = new ArrayList<EquipmentInfo>(); | ||
351 | EquipmentInfo equipmentInfo = null; | ||
352 | for(String id : idList) { | ||
353 | equipmentInfo = new EquipmentInfo(); | ||
354 | equipmentInfo.setId(id); | ||
355 | equipmentInfo.setDigitalTwinsStructCode(id); | ||
356 | equipmentInfoList.add(equipmentInfo); | ||
357 | } | ||
358 | if(equipmentInfoList!=null&&equipmentInfoList.size()>0) { | ||
359 | this.updateBatchById(equipmentInfoList); | ||
360 | } | ||
361 | } | ||
362 | |||
343 | } | 363 | } | ... | ... |
... | @@ -113,6 +113,8 @@ public class ShiroConfig { | ... | @@ -113,6 +113,8 @@ public class ShiroConfig { |
113 | // filterChainDefinitionMap.put("/v1/report/reportDisplay/**", "anon"); | 113 | // filterChainDefinitionMap.put("/v1/report/reportDisplay/**", "anon"); |
114 | filterChainDefinitionMap.put("/v1/sys/factoryMonitorData/**", "anon"); | 114 | filterChainDefinitionMap.put("/v1/sys/factoryMonitorData/**", "anon"); |
115 | filterChainDefinitionMap.put("/sys/dict/getDictItems/**", "anon"); | 115 | filterChainDefinitionMap.put("/sys/dict/getDictItems/**", "anon"); |
116 | //数字孪生设备、孪生体批量关联 | ||
117 | filterChainDefinitionMap.put("/equipment/batchConfigDigitaltwins", "anon"); | ||
116 | //性能监控 | 118 | //性能监控 |
117 | filterChainDefinitionMap.put("/actuator/metrics/**", "anon"); | 119 | filterChainDefinitionMap.put("/actuator/metrics/**", "anon"); |
118 | filterChainDefinitionMap.put("/actuator/httptrace/**", "anon"); | 120 | filterChainDefinitionMap.put("/actuator/httptrace/**", "anon"); |
... | @@ -124,6 +126,7 @@ public class ShiroConfig { | ... | @@ -124,6 +126,7 @@ public class ShiroConfig { |
124 | //flowable工作流权限过滤 | 126 | //flowable工作流权限过滤 |
125 | filterChainDefinitionMap.put("/process/diagram-view", "anon"); | 127 | filterChainDefinitionMap.put("/process/diagram-view", "anon"); |
126 | filterChainDefinitionMap.put("/process/resource-view","anon");//工作流流程图 | 128 | filterChainDefinitionMap.put("/process/resource-view","anon");//工作流流程图 |
129 | // filterChainDefinitionMap.put("/report/headerConfig/**","anon"); | ||
127 | 130 | ||
128 | filterChainDefinitionMap.put("/v1/monitor/**","anon");//点表初始化导入 | 131 | filterChainDefinitionMap.put("/v1/monitor/**","anon");//点表初始化导入 |
129 | filterChainDefinitionMap.put("/example/**","anon"); | 132 | filterChainDefinitionMap.put("/example/**","anon"); | ... | ... |
... | @@ -88,14 +88,6 @@ public class SysFactoryUserInfoController { | ... | @@ -88,14 +88,6 @@ public class SysFactoryUserInfoController { |
88 | HttpServletRequest req) { | 88 | HttpServletRequest req) { |
89 | Result<IPage<SysFactoryUserInfo>> result = new Result<IPage<SysFactoryUserInfo>>(); | 89 | Result<IPage<SysFactoryUserInfo>> result = new Result<IPage<SysFactoryUserInfo>>(); |
90 | Page<SysFactoryUserInfo> page = new Page<SysFactoryUserInfo>(pageNo, pageSize); | 90 | Page<SysFactoryUserInfo> page = new Page<SysFactoryUserInfo>(pageNo, pageSize); |
91 | // QueryWrapper<SysFactoryUserInfo> queryWrapper = QueryGenerator.initQueryWrapper(sysFactoryUserInfo, req.getParameterMap()); | ||
92 | // String departIds = BaseContextHandler.getDeparts(); | ||
93 | // String[] departIdArray = departIds.split(","); | ||
94 | // if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) { | ||
95 | // queryWrapper.in("depart_id", departIdArray); | ||
96 | // } | ||
97 | // queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId()); | ||
98 | // IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.page(page, queryWrapper); | ||
99 | IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.getPage(page, sysFactoryUserInfo); | 91 | IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.getPage(page, sysFactoryUserInfo); |
100 | result.setSuccess(true); | 92 | result.setSuccess(true); |
101 | result.setResult(pageList); | 93 | result.setResult(pageList); |
... | @@ -109,13 +101,6 @@ public class SysFactoryUserInfoController { | ... | @@ -109,13 +101,6 @@ public class SysFactoryUserInfoController { |
109 | Result<Map<String,Object>> result = new Result<Map<String,Object>>(); | 101 | Result<Map<String,Object>> result = new Result<Map<String,Object>>(); |
110 | Map<String,Object> map = new HashMap<>(); | 102 | Map<String,Object> map = new HashMap<>(); |
111 | int female = 0;int male = 0; | 103 | int female = 0;int male = 0; |
112 | // QueryWrapper<SysFactoryUserInfo> queryWrapper = new QueryWrapper<>(); | ||
113 | // String departIds = BaseContextHandler.getDeparts(); | ||
114 | // String[] departIdArray = departIds.split(","); | ||
115 | // if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) { | ||
116 | // queryWrapper.in("depart_id", departIdArray); | ||
117 | // } | ||
118 | // queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId()); | ||
119 | List<SysFactoryUserInfo> list = sysFactoryUserInfoService.getList(sysFactoryUserInfo); | 104 | List<SysFactoryUserInfo> list = sysFactoryUserInfoService.getList(sysFactoryUserInfo); |
120 | if(list.size()>0){ | 105 | if(list.size()>0){ |
121 | map.put("total", list.size()); | 106 | map.put("total", list.size()); | ... | ... |
... | @@ -3,6 +3,7 @@ package com.skua.modules.system.service.impl; | ... | @@ -3,6 +3,7 @@ package com.skua.modules.system.service.impl; |
3 | import com.baomidou.mybatisplus.core.metadata.IPage; | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; |
4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
5 | import com.skua.core.context.BaseContextHandler; | 5 | import com.skua.core.context.BaseContextHandler; |
6 | import com.skua.modules.common.service.ICommonSqlService; | ||
6 | import com.skua.modules.system.entity.SysFactoryUserInfo; | 7 | import com.skua.modules.system.entity.SysFactoryUserInfo; |
7 | import com.skua.modules.system.entity.SysUser; | 8 | import com.skua.modules.system.entity.SysUser; |
8 | import com.skua.modules.system.mapper.SysFactoryUserInfoMapper; | 9 | import com.skua.modules.system.mapper.SysFactoryUserInfoMapper; |
... | @@ -24,6 +25,8 @@ public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInf | ... | @@ -24,6 +25,8 @@ public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInf |
24 | 25 | ||
25 | @Autowired | 26 | @Autowired |
26 | private SysFactoryUserInfoMapper sysFactoryUserInfoMapper; | 27 | private SysFactoryUserInfoMapper sysFactoryUserInfoMapper; |
28 | @Autowired | ||
29 | private ICommonSqlService commonSqlService; | ||
27 | 30 | ||
28 | @Override | 31 | @Override |
29 | public IPage<SysFactoryUserInfo> getPage(Page<SysFactoryUserInfo> page, SysFactoryUserInfo sysFactoryUserInfo) { | 32 | public IPage<SysFactoryUserInfo> getPage(Page<SysFactoryUserInfo> page, SysFactoryUserInfo sysFactoryUserInfo) { |
... | @@ -38,7 +41,8 @@ public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInf | ... | @@ -38,7 +41,8 @@ public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInf |
38 | List<SysFactoryUserInfo> list = new ArrayList<>(); | 41 | List<SysFactoryUserInfo> list = new ArrayList<>(); |
39 | String departIds = BaseContextHandler.getDeparts(); | 42 | String departIds = BaseContextHandler.getDeparts(); |
40 | if(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId())){ | 43 | if(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId())){ |
41 | departIds = sysFactoryUserInfo.getDepartId(); | 44 | String departId = sysFactoryUserInfo.getDepartId(); |
45 | departIds = commonSqlService.getChildDepartId(departId); | ||
42 | } | 46 | } |
43 | list = sysFactoryUserInfoMapper.getList(departIds,sysFactoryUserInfo.getUserName()); | 47 | list = sysFactoryUserInfoMapper.getList(departIds,sysFactoryUserInfo.getUserName()); |
44 | return list; | 48 | return list; | ... | ... |
-
请 注册 或 登录 后发表评论