月度生产数据报表开发
正在显示
10 个修改的文件
包含
210 行增加
和
5 行删除
... | @@ -11,7 +11,7 @@ public interface ReportConstant { | ... | @@ -11,7 +11,7 @@ public interface ReportConstant { |
11 | 11 | ||
12 | public static final String view3a24 = "3a243d5715b9e1a3753c180872ca0df9"; | 12 | public static final String view3a24 = "3a243d5715b9e1a3753c180872ca0df9"; |
13 | 13 | ||
14 | 14 | //上产月报 | |
15 | public static final String view4411 = "4411ed3d78634bcdcd700f6e33724025"; | 15 | public static final String view4411 = "4411ed3d78634bcdcd700f6e33724025"; |
16 | 16 | ||
17 | //化验日报 | 17 | //化验日报 | ... | ... |
sk-module-datafill/src/main/java/com/skua/modules/custom/handle/impl/ScybReportHandle.java
0 → 100644
1 | package com.skua.modules.custom.handle.impl; | ||
2 | |||
3 | import com.skua.common.constant.ReportConstant; | ||
4 | import com.skua.common.report.ReportViewUtil; | ||
5 | import com.skua.common.report.entity.ValueEntity; | ||
6 | import com.skua.core.util.ConvertUtils; | ||
7 | import com.skua.modules.common.service.ICommonSqlService; | ||
8 | import com.skua.modules.common.vo.DepartVO; | ||
9 | import com.skua.modules.custom.handle.ICustomHandle; | ||
10 | import com.skua.modules.custom.service.IFCustomReportDatasetService; | ||
11 | import com.skua.modules.custom.vo.FCustomReportDatasetVO; | ||
12 | import org.apache.commons.lang.StringUtils; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | ||
14 | import org.springframework.stereotype.Component; | ||
15 | |||
16 | import java.util.*; | ||
17 | |||
18 | /** | ||
19 | * <pre> | ||
20 | * 生产月报自定义逻辑 | ||
21 | * </pre> | ||
22 | * @author zhanglei | ||
23 | * @version V0.1, 2024年12月17日 上午9:40:17 | ||
24 | */ | ||
25 | @Component("scybReportHandle") | ||
26 | public class ScybReportHandle implements ICustomHandle{ | ||
27 | @Autowired | ||
28 | private IFCustomReportDatasetService fCustomReportDatasetService; | ||
29 | @Autowired | ||
30 | private ICommonSqlService commonSqlService; | ||
31 | |||
32 | @Override | ||
33 | public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime, | ||
34 | String departId,String indexCode) { | ||
35 | String departIds = ""; | ||
36 | List<DepartVO> departList = commonSqlService.getChildDepartList(departId); | ||
37 | for (DepartVO departVO : departList) { | ||
38 | departIds = departVO.getDepartId() + "," + departIds; | ||
39 | } | ||
40 | String month = startTime.split("-")[0] + "-" + startTime.split("-")[1]; | ||
41 | Map<String,List<Map<String,ValueEntity>>> resMap = new HashMap<String,List<Map<String,ValueEntity>>>(); | ||
42 | Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>(); | ||
43 | //获取填报数据及报表数据项信息,组装报表所需数据机构 | ||
44 | List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>(); | ||
45 | //根据数据集id获取数据项及填报数据 | ||
46 | List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(ReportConstant.view4411); | ||
47 | Map<String,String> dataFieldDict = new HashMap<String,String>(); | ||
48 | for(FCustomReportDatasetVO dataField : dataFieldList) { | ||
49 | dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName()); | ||
50 | } | ||
51 | //添加厂站、时间字段 | ||
52 | dataFieldDict.put("depart_name", "厂站名称"); | ||
53 | dataFieldDict.put("time", "时间"); | ||
54 | dataFieldDict.put("paramDepart", "参数机构"); | ||
55 | dataFieldDict.put("depart_id", "厂站编码"); | ||
56 | //获取填报数据 | ||
57 | String dataViewName4411 = ReportViewUtil.buildViewLike(ReportConstant.view4411,"", departIds, month); | ||
58 | //结果集 | ||
59 | List<Map<String, Object>> nhMapList = fCustomReportDatasetService.queryScybReport(dataViewName4411, month, departIds); | ||
60 | list = changeDataList(nhMapList,list,startTime,dataFieldDict); | ||
61 | dataMap.put("生产数据报表", list); | ||
62 | |||
63 | List<Map<String,ValueEntity>> dList = new ArrayList<>(); | ||
64 | for (DepartVO departVO : departList) { | ||
65 | String departStr = departVO.getDepartId(); | ||
66 | Map<String,ValueEntity> newDataMap = new HashMap<>(); | ||
67 | ValueEntity codeEntity = new ValueEntity(); | ||
68 | codeEntity.setValue(departStr); | ||
69 | newDataMap.put("厂站编码", codeEntity); | ||
70 | ValueEntity nameEntity = new ValueEntity(); | ||
71 | nameEntity.setValue(departVO.getDepartName()); | ||
72 | newDataMap.put("厂站名称", nameEntity); | ||
73 | for (Map.Entry<String, List<Map<String,ValueEntity>>> entry : dataMap.entrySet()) { | ||
74 | List<Map<String,ValueEntity>> dataList = entry.getValue(); | ||
75 | for (Map<String,ValueEntity> dMap: dataList) { | ||
76 | if(departStr.equals(dMap.get("厂站编码").getValue())){ | ||
77 | newDataMap.putAll(dMap); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | dList.add(newDataMap); | ||
82 | } | ||
83 | resMap.put("月度生产数据报表", dList); | ||
84 | return resMap; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public String buildWaterQualityAlarmValue(String reportId, String departId, String json) { | ||
89 | return json; | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * 构造LIST | ||
94 | * @param szMapList | ||
95 | * @param list | ||
96 | * @param startTime | ||
97 | * @param dataFieldDict | ||
98 | * @return | ||
99 | */ | ||
100 | private List<Map<String, ValueEntity>> changeDataList(List<Map<String, Object>> szMapList, List<Map<String, ValueEntity>> list, | ||
101 | String startTime, Map<String, String> dataFieldDict) { | ||
102 | for(Map<String,Object> valueMap : szMapList) { | ||
103 | Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>(); | ||
104 | //添加时间参数 | ||
105 | ValueEntity startTimeValueEntity = new ValueEntity(); | ||
106 | startTimeValueEntity.setValue(startTime); | ||
107 | handleMap.put("参数机构", startTimeValueEntity); | ||
108 | Set<String> keySet = valueMap.keySet(); | ||
109 | for(String key : keySet) { | ||
110 | if(!StringUtils.isEmpty(dataFieldDict.get(key))) { | ||
111 | ValueEntity valueEntity = new ValueEntity(); | ||
112 | valueEntity.setValue(ConvertUtils.getString(valueMap.get(key))); | ||
113 | handleMap.put(dataFieldDict.get(key),valueEntity); | ||
114 | } | ||
115 | } | ||
116 | list.add(handleMap); | ||
117 | } | ||
118 | return list; | ||
119 | } | ||
120 | |||
121 | } |
... | @@ -148,4 +148,7 @@ public interface FCustomReportDatasetMapper extends BaseMapper<FCustomReportData | ... | @@ -148,4 +148,7 @@ public interface FCustomReportDatasetMapper extends BaseMapper<FCustomReportData |
148 | List<Map<String, Object>> queryHyReport(@Param(value="dataViewName9bff") String dataViewName9bff, | 148 | List<Map<String, Object>> queryHyReport(@Param(value="dataViewName9bff") String dataViewName9bff, |
149 | @Param(value="startTime") String startTime, @Param(value="endTime") String endTime, | 149 | @Param(value="startTime") String startTime, @Param(value="endTime") String endTime, |
150 | @Param(value="departId") String departId); | 150 | @Param(value="departId") String departId); |
151 | |||
152 | List<Map<String, Object>> queryScybReport(@Param(value="dataViewName4411") String dataViewName4411, | ||
153 | @Param(value="month") String month, @Param(value="departId") String departId); | ||
151 | } | 154 | } | ... | ... |
... | @@ -808,4 +808,45 @@ | ... | @@ -808,4 +808,45 @@ |
808 | AND v.time <= #{endTime} | 808 | AND v.time <= #{endTime} |
809 | GROUP BY v.depart_id | 809 | GROUP BY v.depart_id |
810 | </select> | 810 | </select> |
811 | <select id="queryScybReport" resultType="java.util.HashMap"> | ||
812 | SELECT | ||
813 | d.depart_name, | ||
814 | #{month} AS time, | ||
815 | d.id AS depart_id, | ||
816 | v4.ysjsl, | ||
817 | v4.tqysjsl, | ||
818 | v4.sjsldbbhl, | ||
819 | v4.ysjsldyqntqyy, | ||
820 | v4.qntqsfsl, | ||
821 | v4.ysfsl, | ||
822 | v4.sfsldbbhl, | ||
823 | v4.ndslmb, | ||
824 | v4.yslwcbl, | ||
825 | v4.sldyyqyy, | ||
826 | v4.qntqdh, | ||
827 | v4.ydh, | ||
828 | v4.dhdbbhl, | ||
829 | v4.dhgyqntqyy, | ||
830 | v4.qntqyh, | ||
831 | v4.yyf, | ||
832 | v4.yyh, | ||
833 | v4.yhdbbhl, | ||
834 | v4.yhgyqntqyy, | ||
835 | v4.bndhmb, | ||
836 | v4.bnsjdh, | ||
837 | v4.dhcmbzyy, | ||
838 | v4.bnyhmb, | ||
839 | v4.bnsjyh, | ||
840 | v4.yhcyqyy | ||
841 | FROM | ||
842 | sys_depart d | ||
843 | LEFT JOIN ( SELECT * FROM ${dataViewName4411} v WHERE v.time = #{month} ) v4 ON v4.depart_id = d.id | ||
844 | WHERE | ||
845 | d.id IN | ||
846 | <foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")"> | ||
847 | '${item}' | ||
848 | </foreach> | ||
849 | ORDER BY | ||
850 | v4.time DESC,d.depart_order ASC | ||
851 | </select> | ||
811 | </mapper> | 852 | </mapper> | ... | ... |
... | @@ -142,4 +142,6 @@ public interface IFCustomReportDatasetService extends IService<FCustomReportData | ... | @@ -142,4 +142,6 @@ public interface IFCustomReportDatasetService extends IService<FCustomReportData |
142 | List<Map<String, Object>> queryNhYyrbReport(String dataViewName3a24, String startTime, String endTime, String departId); | 142 | List<Map<String, Object>> queryNhYyrbReport(String dataViewName3a24, String startTime, String endTime, String departId); |
143 | 143 | ||
144 | List<Map<String, Object>> queryHyReport(String dataViewName9bff, String startTime, String endTime, String departIds); | 144 | List<Map<String, Object>> queryHyReport(String dataViewName9bff, String startTime, String endTime, String departIds); |
145 | |||
146 | List<Map<String, Object>> queryScybReport(String dataViewName4411, String month, String departIds); | ||
145 | } | 147 | } | ... | ... |
... | @@ -472,6 +472,12 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa | ... | @@ -472,6 +472,12 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa |
472 | return list; | 472 | return list; |
473 | } | 473 | } |
474 | 474 | ||
475 | @Override | ||
476 | public List<Map<String, Object>> queryScybReport(String dataViewName4411, String month, String departIds) { | ||
477 | List<Map<String, Object>> list = mapper.queryScybReport(dataViewName4411, month, departIds); | ||
478 | return list; | ||
479 | } | ||
480 | |||
475 | /**转换为Map<部门编号,JnhbReportData> */ | 481 | /**转换为Map<部门编号,JnhbReportData> */ |
476 | private Map<String,JnhbReportData> convertJnhbReportDataMap(List<JnhbReportData> dataList){// Map<部门编号,JnhbReportData> | 482 | private Map<String,JnhbReportData> convertJnhbReportDataMap(List<JnhbReportData> dataList){// Map<部门编号,JnhbReportData> |
477 | Map<String,JnhbReportData> dataMap = new HashMap<>(); | 483 | Map<String,JnhbReportData> dataMap = new HashMap<>(); | ... | ... |
... | @@ -54,10 +54,10 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -54,10 +54,10 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
54 | startTime = startTime + "-01"; | 54 | startTime = startTime + "-01"; |
55 | endTime = endTime + "-31"; | 55 | endTime = endTime + "-31"; |
56 | }else if("2".equals(reportInfo.getReportTimeQueryType())){//月 | 56 | }else if("2".equals(reportInfo.getReportTimeQueryType())){//月 |
57 | startTime = startTime + "-01"; | 57 | if("1".equals(reportInfo.getReportType())){ |
58 | endTime = endTime + "-31"; | 58 | startTime = startTime + "-01"; |
59 | }else{ | 59 | endTime = endTime + "-31"; |
60 | //无需转换时间 | 60 | } |
61 | } | 61 | } |
62 | String customService = reportInfo.getCustomService(); | 62 | String customService = reportInfo.getCustomService(); |
63 | //锁定行号 | 63 | //锁定行号 | ... | ... |
... | @@ -57,6 +57,10 @@ public class ReportDataController { | ... | @@ -57,6 +57,10 @@ public class ReportDataController { |
57 | String time = ConvertUtils.getString(data.get("time")); | 57 | String time = ConvertUtils.getString(data.get("time")); |
58 | reportDataService.insertOrUpdateReportData(departId, time, data, reportId); | 58 | reportDataService.insertOrUpdateReportData(departId, time, data, reportId); |
59 | } | 59 | } |
60 | //同步修改生产运营月报 | ||
61 | if(dataList.size() > 0){ | ||
62 | reportDataService.syncUpdateScybData(dataList.get(0).get("departId"),dataList.get(0).get("time")); | ||
63 | } | ||
60 | return Result.ok("报表批量添加成功"); | 64 | return Result.ok("报表批量添加成功"); |
61 | } | 65 | } |
62 | 66 | ... | ... |
... | @@ -9,4 +9,5 @@ public interface IReportDataService { | ... | @@ -9,4 +9,5 @@ public interface IReportDataService { |
9 | 9 | ||
10 | void insertOrUpdateReportData(String departId, String time, Map<String, String> data, String reportId); | 10 | void insertOrUpdateReportData(String departId, String time, Map<String, String> data, String reportId); |
11 | 11 | ||
12 | void syncUpdateScybData(String departId,String time); | ||
12 | } | 13 | } | ... | ... |
1 | package com.skua.modules.report.service.impl; | 1 | package com.skua.modules.report.service.impl; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
4 | import com.skua.core.util.ConvertUtils; | ||
5 | import com.skua.modules.custom.service.IFCustomReportDatasetService; | ||
4 | import com.skua.modules.report.entity.FReportItem; | 6 | import com.skua.modules.report.entity.FReportItem; |
5 | import com.skua.modules.report.entity.FReportItemv; | 7 | import com.skua.modules.report.entity.FReportItemv; |
6 | import com.skua.modules.report.service.IReportDataService; | 8 | import com.skua.modules.report.service.IReportDataService; |
7 | import com.skua.modules.report.service.IFReportItemService; | 9 | import com.skua.modules.report.service.IFReportItemService; |
8 | import com.skua.modules.report.service.IFReportItemvService; | 10 | import com.skua.modules.report.service.IFReportItemvService; |
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
10 | 13 | ||
11 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
... | @@ -21,6 +24,8 @@ public class ReportDataServiceImpl implements IReportDataService { | ... | @@ -21,6 +24,8 @@ public class ReportDataServiceImpl implements IReportDataService { |
21 | private IFReportItemvService fReportItemvService; | 24 | private IFReportItemvService fReportItemvService; |
22 | @Resource | 25 | @Resource |
23 | private IFReportItemService fReportItemService; | 26 | private IFReportItemService fReportItemService; |
27 | @Autowired | ||
28 | private IFCustomReportDatasetService fCustomReportDatasetService; | ||
24 | 29 | ||
25 | @Override | 30 | @Override |
26 | public void insertOrUpdateReportData(String departId, String dataTime, Map<String, String> dataMap, String reportId) { | 31 | public void insertOrUpdateReportData(String departId, String dataTime, Map<String, String> dataMap, String reportId) { |
... | @@ -88,6 +93,28 @@ public class ReportDataServiceImpl implements IReportDataService { | ... | @@ -88,6 +93,28 @@ public class ReportDataServiceImpl implements IReportDataService { |
88 | } | 93 | } |
89 | } | 94 | } |
90 | 95 | ||
96 | @Override | ||
97 | public void syncUpdateScybData(String departId,String dataTime) { | ||
98 | String year = dataTime.split("-")[0]; | ||
99 | List<Map<String, Object>> valueList = fCustomReportDatasetService.getDataFromHY(year, departId); | ||
100 | List<Map<String, String>> list = new ArrayList<>(); | ||
101 | for (Map<String, Object> map : valueList) { | ||
102 | Map<String, String> newMap = new HashMap<>(); | ||
103 | for (Map.Entry<String, Object> entry : map.entrySet()) { | ||
104 | String key = entry.getKey(); | ||
105 | Object value = entry.getValue(); | ||
106 | String valueAsString = value != null ? value.toString() : ""; | ||
107 | newMap.put(key, valueAsString); | ||
108 | } | ||
109 | list.add(newMap); | ||
110 | } | ||
111 | for (Map<String, String> data : list) { | ||
112 | String reportId = ConvertUtils.getString(data.get("reportId")); | ||
113 | String time = ConvertUtils.getString(data.get("time")); | ||
114 | insertOrUpdateReportData(departId, time, data, reportId); | ||
115 | } | ||
116 | } | ||
117 | |||
91 | //生成ID | 118 | //生成ID |
92 | private static String generateUniqueId() { | 119 | private static String generateUniqueId() { |
93 | long timestamp = System.currentTimeMillis(); | 120 | long timestamp = System.currentTimeMillis(); | ... | ... |
-
请 注册 或 登录 后发表评论