Merge remote-tracking branch 'origin/master' into master
正在显示
3 个修改的文件
包含
110 行增加
和
8 行删除
1 | package com.skua.tool.dfs; | ||
2 | |||
3 | /** | ||
4 | * <pre> | ||
5 | * cash when 拼接 | ||
6 | * </pre> | ||
7 | * | ||
8 | * @author sonin | ||
9 | * @version 1.0 2023/11/23 16:49 | ||
10 | */ | ||
11 | public class CaseWhen { | ||
12 | |||
13 | private String SPACE = " "; | ||
14 | |||
15 | private String COMMA = ","; | ||
16 | |||
17 | private String DOUBLE_QUOTES = "\""; | ||
18 | |||
19 | private StringBuilder caseWhenSB = new StringBuilder(); | ||
20 | |||
21 | public CaseWhen selectCaseWhen(String caseWhen, String then, String els, String alias) { | ||
22 | caseWhenSB.append(COMMA).append(SPACE).append("ifnull(sum(case when (").append(caseWhen).append(") then ").append(then).append(" else ").append(els).append(" end), 0) as ").append(DOUBLE_QUOTES).append(alias).append(DOUBLE_QUOTES); | ||
23 | return this; | ||
24 | } | ||
25 | |||
26 | public CaseWhen selectCaseWhen(String caseWhen, String alias) { | ||
27 | selectCaseWhen(caseWhen, "1", "0", alias); | ||
28 | return this; | ||
29 | } | ||
30 | |||
31 | public CaseWhen selectPgCaseWhen(String caseWhen, String then, String els, String alias) { | ||
32 | caseWhenSB.append(COMMA).append(SPACE).append("COALESCE(sum(case when (").append(caseWhen).append(") then cast(").append(then).append(" as float) else ").append(els).append(" end), 0) as ").append(DOUBLE_QUOTES).append(alias).append(DOUBLE_QUOTES); | ||
33 | return this; | ||
34 | } | ||
35 | |||
36 | public CaseWhen selectPgCaseWhen(String caseWhen, String alias) { | ||
37 | selectPgCaseWhen(caseWhen, "1", "0", alias); | ||
38 | return this; | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * <pre> | ||
43 | * mysql返回BigDecimal类型; pg返回Double类型 | ||
44 | * </pre> | ||
45 | * | ||
46 | * @param | ||
47 | * @author sonin | ||
48 | * @Description: TODO(这里描述这个方法的需求变更情况) | ||
49 | */ | ||
50 | public String print() { | ||
51 | return caseWhenSB.toString().replaceFirst(COMMA + SPACE, ""); | ||
52 | } | ||
53 | |||
54 | } |
1 | package com.skua.modules.emergency.service.impl; | 1 | package com.skua.modules.emergency.service.impl; |
2 | 2 | ||
3 | import cn.hutool.json.JSONUtil; | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
4 | import com.skua.core.context.BaseContextHandler; | 5 | import com.skua.core.context.BaseContextHandler; |
5 | import com.skua.core.context.SpringContextUtils; | 6 | import com.skua.core.context.SpringContextUtils; |
6 | import com.skua.core.exception.JeecgBootException; | 7 | import com.skua.core.exception.JeecgBootException; |
7 | import com.skua.core.util.ConvertUtils; | 8 | import com.skua.core.util.ConvertUtils; |
8 | import com.skua.core.util.DateUtils; | 9 | import com.skua.core.util.DateUtils; |
10 | import com.skua.modules.base.service.IBaseService; | ||
9 | import com.skua.modules.emergency.dto.EmergencyRiskEventAddDTO; | 11 | import com.skua.modules.emergency.dto.EmergencyRiskEventAddDTO; |
10 | import com.skua.modules.emergency.dto.EmergencyRiskEventHandleDto; | 12 | import com.skua.modules.emergency.dto.EmergencyRiskEventHandleDto; |
11 | import com.skua.modules.emergency.entity.EmergencyRiskEvent; | 13 | import com.skua.modules.emergency.entity.EmergencyRiskEvent; |
... | @@ -43,10 +45,7 @@ import org.springframework.stereotype.Service; | ... | @@ -43,10 +45,7 @@ import org.springframework.stereotype.Service; |
43 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 45 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
44 | import org.springframework.transaction.annotation.Transactional; | 46 | import org.springframework.transaction.annotation.Transactional; |
45 | 47 | ||
46 | import java.util.ArrayList; | 48 | import java.util.*; |
47 | import java.util.HashMap; | ||
48 | import java.util.List; | ||
49 | import java.util.Map; | ||
50 | 49 | ||
51 | /** | 50 | /** |
52 | * 应急风险事件 | 51 | * 应急风险事件 |
... | @@ -65,6 +64,8 @@ public class EmergencyRiskEventServiceImpl extends ServiceImpl<EmergencyRiskEven | ... | @@ -65,6 +64,8 @@ public class EmergencyRiskEventServiceImpl extends ServiceImpl<EmergencyRiskEven |
65 | private DangerLevelManageShareMapper dangerLevelManageShareMapper; | 64 | private DangerLevelManageShareMapper dangerLevelManageShareMapper; |
66 | @Autowired | 65 | @Autowired |
67 | private DangerInspectionRecordMapper dangerInspectionRecordMapper; | 66 | private DangerInspectionRecordMapper dangerInspectionRecordMapper; |
67 | @Autowired | ||
68 | private IBaseService baseService; | ||
68 | 69 | ||
69 | @Override | 70 | @Override |
70 | @Transactional(rollbackFor = Exception.class) | 71 | @Transactional(rollbackFor = Exception.class) |
... | @@ -185,6 +186,19 @@ public class EmergencyRiskEventServiceImpl extends ServiceImpl<EmergencyRiskEven | ... | @@ -185,6 +186,19 @@ public class EmergencyRiskEventServiceImpl extends ServiceImpl<EmergencyRiskEven |
185 | sql += getRiskLibraryStatisticsSql(departIds, startDate, endDate); | 186 | sql += getRiskLibraryStatisticsSql(departIds, startDate, endDate); |
186 | 187 | ||
187 | List<RiskDatabaseResult> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<RiskDatabaseResult>(RiskDatabaseResult.class)); | 188 | List<RiskDatabaseResult> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<RiskDatabaseResult>(RiskDatabaseResult.class)); |
189 | try { | ||
190 | Map<String, Object> entityMap = new HashMap<>(); | ||
191 | entityMap.put("id", null); | ||
192 | entityMap.put("log_name", "riskLibraryStatistics"); | ||
193 | entityMap.put("log_content1",departIds); | ||
194 | entityMap.put("log_content2",sql); | ||
195 | entityMap.put("log_content3", JSONUtil.toJsonStr(dataList)); | ||
196 | entityMap.put("create_time", new Date()); | ||
197 | entityMap.put("create_by", BaseContextHandler.getUserName()); | ||
198 | baseService.insert("test_log", entityMap); | ||
199 | } catch (Exception e) { | ||
200 | e.printStackTrace(); | ||
201 | } | ||
188 | if(dataList != null && !dataList.isEmpty()){ | 202 | if(dataList != null && !dataList.isEmpty()){ |
189 | return dataList.get(0); | 203 | return dataList.get(0); |
190 | } | 204 | } | ... | ... |
... | @@ -4,9 +4,12 @@ package com.skua.modules.equipment.controller; | ... | @@ -4,9 +4,12 @@ package com.skua.modules.equipment.controller; |
4 | * @auther kangwei | 4 | * @auther kangwei |
5 | * @create 2025-03-08-14:08 | 5 | * @create 2025-03-08-14:08 |
6 | */ | 6 | */ |
7 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
8 | import com.skua.common.constant.BusinessConstant; | ||
7 | import com.skua.core.api.vo.Result; | 9 | import com.skua.core.api.vo.Result; |
8 | import com.skua.core.aspect.annotation.AutoLog; | 10 | import com.skua.core.aspect.annotation.AutoLog; |
9 | import com.skua.core.context.BaseContextHandler; | 11 | import com.skua.core.context.BaseContextHandler; |
12 | import com.skua.modules.base.service.IBaseService; | ||
10 | import com.skua.modules.common.service.ICommonSqlService; | 13 | import com.skua.modules.common.service.ICommonSqlService; |
11 | import com.skua.modules.equipment.service.IEquipmentMaintainTaskService; | 14 | import com.skua.modules.equipment.service.IEquipmentMaintainTaskService; |
12 | import com.skua.modules.equipment.service.IEquipmentRepairService; | 15 | import com.skua.modules.equipment.service.IEquipmentRepairService; |
... | @@ -15,6 +18,7 @@ import com.skua.modules.equipment.vo.EquipmentMaintainTaskForm; | ... | @@ -15,6 +18,7 @@ import com.skua.modules.equipment.vo.EquipmentMaintainTaskForm; |
15 | import com.skua.modules.equipment.vo.EquipmentRepairForm; | 18 | import com.skua.modules.equipment.vo.EquipmentRepairForm; |
16 | import com.skua.modules.system.entity.SysDepart; | 19 | import com.skua.modules.system.entity.SysDepart; |
17 | import com.skua.modules.system.service.ISysDepartService; | 20 | import com.skua.modules.system.service.ISysDepartService; |
21 | import com.skua.tool.dfs.CaseWhen; | ||
18 | import com.skua.tool.util.JSUtils; | 22 | import com.skua.tool.util.JSUtils; |
19 | import io.swagger.annotations.Api; | 23 | import io.swagger.annotations.Api; |
20 | import io.swagger.annotations.ApiOperation; | 24 | import io.swagger.annotations.ApiOperation; |
... | @@ -25,10 +29,7 @@ import org.springframework.web.bind.annotation.GetMapping; | ... | @@ -25,10 +29,7 @@ import org.springframework.web.bind.annotation.GetMapping; |
25 | import org.springframework.web.bind.annotation.RequestMapping; | 29 | import org.springframework.web.bind.annotation.RequestMapping; |
26 | import org.springframework.web.bind.annotation.RestController; | 30 | import org.springframework.web.bind.annotation.RestController; |
27 | 31 | ||
28 | import java.util.ArrayList; | 32 | import java.util.*; |
29 | import java.util.HashMap; | ||
30 | import java.util.List; | ||
31 | import java.util.Map; | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * 维修维护报表 | 35 | * 维修维护报表 |
... | @@ -47,6 +48,8 @@ public class EquipmentInfoMonthReportController { | ... | @@ -47,6 +48,8 @@ public class EquipmentInfoMonthReportController { |
47 | private IEquipmentMaintainTaskService equipmentMaintainTaskService; | 48 | private IEquipmentMaintainTaskService equipmentMaintainTaskService; |
48 | @Autowired | 49 | @Autowired |
49 | private IEquipmentRepairService equipmentRepairService; | 50 | private IEquipmentRepairService equipmentRepairService; |
51 | @Autowired | ||
52 | private IBaseService baseService; | ||
50 | 53 | ||
51 | @AutoLog(value = "设备月报-设备管理情况") | 54 | @AutoLog(value = "设备月报-设备管理情况") |
52 | @ApiOperation(value = "设备月报-设备管理情况", notes = "设备月报-设备管理情况") | 55 | @ApiOperation(value = "设备月报-设备管理情况", notes = "设备月报-设备管理情况") |
... | @@ -71,6 +74,37 @@ public class EquipmentInfoMonthReportController { | ... | @@ -71,6 +74,37 @@ public class EquipmentInfoMonthReportController { |
71 | //5 设备更新情况 | 74 | //5 设备更新情况 |
72 | List<Map<String,Object>> equipmentUpdateList = equipmentUpdateList(departIds, startDate, endDate); | 75 | List<Map<String,Object>> equipmentUpdateList = equipmentUpdateList(departIds, startDate, endDate); |
73 | dataMap.put("equipmentUpdateList",equipmentUpdateList); | 76 | dataMap.put("equipmentUpdateList",equipmentUpdateList); |
77 | // 补充:获取子集结果 南京,武汉,恩菲 | ||
78 | List<Map<String, Object>> childDataList = new ArrayList<>(); | ||
79 | List<String> childDepartIdList = Arrays.asList("1892199062790823936", "1892199890272477184", "1818215543140909056"); | ||
80 | List<SysDepart> sysDepartList = departService.list(new QueryWrapper<SysDepart>().in("id", childDepartIdList).orderByAsc("depart_order")); | ||
81 | for (SysDepart childSysDepart: sysDepartList) { | ||
82 | String childDepartIds = departService.getChildDepartId(childSysDepart.getId()); | ||
83 | // 设备管理情况 | ||
84 | Map<String,Object> childDataMap = equipmentDetail(childDepartIds, startDate, endDate); | ||
85 | // 设备大修、更新开展情况 | ||
86 | CaseWhen caseWhen = new CaseWhen(); | ||
87 | caseWhen.selectCaseWhen("equipment_maintain_task.results_enforcement = 3", "hasFinish"); | ||
88 | caseWhen.selectCaseWhen("equipment_maintain_task.results_enforcement != 3", "notFinish"); | ||
89 | QueryWrapper<?> queryWrapper0 = new QueryWrapper<>(); | ||
90 | queryWrapper0.ge("equipment_maintain_task.maintain_time", startDate + BusinessConstant.startTimeSuffix) | ||
91 | .le("equipment_maintain_task.maintain_time", endDate + BusinessConstant.endTimeSuffix) | ||
92 | .eq("equipment_maintain_plan.maintenance_type", "dxjg") | ||
93 | .eq("equipment_maintain_plan.release_status", "1") | ||
94 | .ge("equipment_maintain_plan.start_time", startDate + BusinessConstant.startTimeSuffix) | ||
95 | .le("equipment_maintain_plan.end_time", endDate + BusinessConstant.endTimeSuffix) | ||
96 | .in("equipment_maintain_plan.depart_id", Arrays.asList(childDepartIds.split(","))); | ||
97 | Map<String, Object> queryMap0 = baseService.queryForMap("select " + caseWhen.print() + " from equipment_maintain_task left join equipment_maintain_plan on equipment_maintain_task.plan_id = equipment_maintain_plan.id", queryWrapper0); | ||
98 | childDataMap.put("hasFinish", queryMap0.get("hasFinish")); | ||
99 | childDataMap.put("notFinish", queryMap0.get("notFinish")); | ||
100 | // 设备更新情况 | ||
101 | List<Map<String,Object>> childEquipmentUpdateList = equipmentUpdateList(childDepartIds, startDate, endDate); | ||
102 | childDataMap.put("equipmentUpdateList", childEquipmentUpdateList); | ||
103 | childDataMap.put("departName", childSysDepart.getDepartName()); | ||
104 | childDataMap.put("departId", childSysDepart.getId()); | ||
105 | childDataList.add(childDataMap); | ||
106 | } | ||
107 | dataMap.put("childData", childDataList); | ||
74 | result.setSuccess(true); | 108 | result.setSuccess(true); |
75 | result.setResult(dataMap); | 109 | result.setResult(dataMap); |
76 | return result; | 110 | return result; | ... | ... |
-
请 注册 或 登录 后发表评论