refactor(module-datafill): 优化自定义报表相关代码
-调整日期处理逻辑,增加注释提高可读性 - 优化报表导出功能,规范代码格式 - 更新自定义报表信息及其权限的方法,增加事务管理 - 移除未使用的变量和注释掉的代码 - 优化 HyrbReportHandle 类,删除未使用的依赖 -简化 RealTimeAlarmJob 类中的报警记录保存逻辑
正在显示
3 个修改的文件
包含
38 行增加
和
25 行删除
... | @@ -502,23 +502,19 @@ public class RealTimeAlarmJob implements Job { | ... | @@ -502,23 +502,19 @@ public class RealTimeAlarmJob implements Job { |
502 | 502 | ||
503 | //${start}采集数据${conent}已超标,请注意! | 503 | //${start}采集数据${conent}已超标,请注意! |
504 | alarmRecordHistory.setAlarmContent("采集数据" + content + suffix); | 504 | alarmRecordHistory.setAlarmContent("采集数据" + content + suffix); |
505 | alarmRecordHistory.setCreateBy("system");//标记为系统创建 | 505 | //标记为系统创建 |
506 | //alarmRecordHistory.setHandleUser(alarmRuleLevelConfig.getAlarmWorkRecipient()); | 506 | alarmRecordHistory.setCreateBy("system"); |
507 | //流程添加定义ID | 507 | //流程添加定义ID |
508 | String processDefinitionId = flowBusinessService.getProcessDefinitionLastVersionId("productAlarmProcess"); | 508 | String processDefinitionId = flowBusinessService.getProcessDefinitionLastVersionId("productAlarmProcess"); |
509 | alarmRecordHistory.setProcessDefinitionId(processDefinitionId); | 509 | alarmRecordHistory.setProcessDefinitionId(processDefinitionId); |
510 | alarmRecordHistoryService.save(alarmRecordHistory); | 510 | alarmRecordHistoryService.save(alarmRecordHistory); |
511 | 511 | ||
512 | |||
513 | //判断是否需要发送系统通知 (内容跟报警记录信息相同) | 512 | //判断是否需要发送系统通知 (内容跟报警记录信息相同) |
514 | if ("1".equals(alarmRuleLevelConfig.getIsSendNotice())) { | 513 | if ("1".equals(alarmRuleLevelConfig.getIsSendNotice())) { |
515 | if (StringUtils.isNotBlank(alarmRuleLevelConfig.getAlarmNoticeRecipient())) { | 514 | if (StringUtils.isNotBlank(alarmRuleLevelConfig.getAlarmNoticeRecipient())) { |
516 | //义乌报警存在特定参数逻辑,不适用产品原有消息推送流程 | 515 | //义乌报警存在特定参数逻辑,不适用产品原有消息推送流程 |
517 | SysMessagePushService sysMessagePushService = (SysMessagePushService) SpringContextUtils.getBean("sysMessagePushService"); | 516 | SysMessagePushService sysMessagePushService = (SysMessagePushService) SpringContextUtils.getBean("sysMessagePushService"); |
518 | sysMessagePushService.pushAlarmRecordMsgNoProcess(alarmRecordHistory); | 517 | sysMessagePushService.pushAlarmRecordMsgNoProcess(alarmRecordHistory); |
519 | |||
520 | //SystemNoticeVO systemNoticeVO = new SystemNoticeVO(alarmRuleLevelConfig.getAlarmNoticeRecipient(),alarmRuleLevelName, "在" + date + "时" + departName + "采集数据" + content + suffix, departId, alarmRuleType); | ||
521 | //systemNoticeUtils.dealNoticeMessage(systemNoticeVO); | ||
522 | } | 518 | } |
523 | } | 519 | } |
524 | //判断是否需要自动发起工作流 | 520 | //判断是否需要自动发起工作流 |
... | @@ -536,10 +532,6 @@ public class RealTimeAlarmJob implements Job { | ... | @@ -536,10 +532,6 @@ public class RealTimeAlarmJob implements Job { |
536 | Date allowEndDate = null; | 532 | Date allowEndDate = null; |
537 | Date nowDate = null; | 533 | Date nowDate = null; |
538 | try { | 534 | try { |
539 | //JSONObject jsonObject = (JSONObject) JSONObject.toJSON(alarmRuleLevelConfig); | ||
540 | //System.err.println("****************************************************"); | ||
541 | //System.out.println(jsonObject); | ||
542 | //System.err.println("****************************************************"); | ||
543 | allowEndDate = simpleDateFormat.parse(alarmRuleLevelConfig.getSmsAllowSendTime().split("-")[1]); | 535 | allowEndDate = simpleDateFormat.parse(alarmRuleLevelConfig.getSmsAllowSendTime().split("-")[1]); |
544 | allowStartDate = simpleDateFormat.parse(alarmRuleLevelConfig.getSmsAllowSendTime().split("-")[0]); | 536 | allowStartDate = simpleDateFormat.parse(alarmRuleLevelConfig.getSmsAllowSendTime().split("-")[0]); |
545 | nowDate = simpleDateFormat.parse(date.substring(11, 16)); | 537 | nowDate = simpleDateFormat.parse(date.substring(11, 16)); |
... | @@ -582,9 +574,8 @@ public class RealTimeAlarmJob implements Job { | ... | @@ -582,9 +574,8 @@ public class RealTimeAlarmJob implements Job { |
582 | phoneStringBuilder.append(phone1); | 574 | phoneStringBuilder.append(phone1); |
583 | aliAlarm.setTime(date); | 575 | aliAlarm.setTime(date); |
584 | aliAlarm.setPhone(phone1); | 576 | aliAlarm.setPhone(phone1); |
585 | //发送短信 | 577 | //新版短息发送工具 |
586 | // HttpSenderMsg.sendMsg(prefix + date + "时" + departName + "采集数据" + content + suffix, phone1); | 578 | AliSmsUtil.sendLimitAlarmMsg(aliAlarm); |
587 | AliSmsUtil.sendLimitAlarmMsg(aliAlarm);//新版短息发送工具 | ||
588 | log.info("短信发送成功手机号:" + phone1 + ",内容:" + content); | 579 | log.info("短信发送成功手机号:" + phone1 + ",内容:" + content); |
589 | } | 580 | } |
590 | } | 581 | } | ... | ... |
... | @@ -30,8 +30,6 @@ public class HyrbReportHandle implements ICustomHandle{ | ... | @@ -30,8 +30,6 @@ public class HyrbReportHandle implements ICustomHandle{ |
30 | private IFCustomReportDatasetService fCustomReportDatasetService; | 30 | private IFCustomReportDatasetService fCustomReportDatasetService; |
31 | @Resource | 31 | @Resource |
32 | private IFactoryCenterService factoryCenterService; | 32 | private IFactoryCenterService factoryCenterService; |
33 | @Autowired | ||
34 | private ICommonSqlService commonSqlService; | ||
35 | 33 | ||
36 | @Override | 34 | @Override |
37 | public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime, | 35 | public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime, | ... | ... |
... | @@ -50,10 +50,12 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -50,10 +50,12 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
50 | } | 50 | } |
51 | //获取自定义报表对象 | 51 | //获取自定义报表对象 |
52 | FCustomReportInfo reportInfo = this.getById(reportId); | 52 | FCustomReportInfo reportInfo = this.getById(reportId); |
53 | if("3".equals(reportInfo.getReportTimeQueryType())){//年 | 53 | //年 |
54 | if("3".equals(reportInfo.getReportTimeQueryType())){ | ||
54 | startTime = startTime + "-01"; | 55 | startTime = startTime + "-01"; |
55 | endTime = endTime + "-31"; | 56 | endTime = endTime + "-31"; |
56 | }else if("2".equals(reportInfo.getReportTimeQueryType())){//月 | 57 | //月 |
58 | }else if("2".equals(reportInfo.getReportTimeQueryType())){ | ||
57 | if("1".equals(reportInfo.getReportType())){ | 59 | if("1".equals(reportInfo.getReportType())){ |
58 | startTime = startTime + "-01"; | 60 | startTime = startTime + "-01"; |
59 | endTime = endTime + "-31"; | 61 | endTime = endTime + "-31"; |
... | @@ -86,9 +88,7 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -86,9 +88,7 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
86 | dataFieldDict.put("time", "时间"); | 88 | dataFieldDict.put("time", "时间"); |
87 | dataFieldDict.put("paramTime", "参数时间"); | 89 | dataFieldDict.put("paramTime", "参数时间"); |
88 | //获取填报数据 | 90 | //获取填报数据 |
89 | //String dataViewName = "view_"+dataSetId.substring(0,4); | ||
90 | String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime,endTime); | 91 | String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime,endTime); |
91 | //String dataViewName = ReportViewUtil.buildViewLike(dataSetId,"", departId, startTime); | ||
92 | //结果集 | 92 | //结果集 |
93 | List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId); | 93 | List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId); |
94 | for(Map<String,Object> valueMap : valueMapList) { | 94 | for(Map<String,Object> valueMap : valueMapList) { |
... | @@ -124,17 +124,27 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -124,17 +124,27 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
124 | map.put("html", html); | 124 | map.put("html", html); |
125 | return map; | 125 | return map; |
126 | } | 126 | } |
127 | /* (non-Javadoc) | 127 | |
128 | * @see com.skua.modules.custom.service.IFCustomReportInfoService#reportExport(java.lang.String) | 128 | /** |
129 | * 生成并导出报表 | ||
130 | * @param reportId 报表ID | ||
131 | * @param startTime 开始时间 | ||
132 | * @param endTime 结束时间 | ||
133 | * @param departId 部门ID | ||
134 | * @param sheetName 工作表名称 | ||
135 | * @param indexCode 指标代码 | ||
136 | * @return 返回Workbook对象,用于导出报表 | ||
129 | */ | 137 | */ |
130 | @Override | 138 | @Override |
131 | public Workbook reportExport(String reportId,String startTime,String endTime,String departId,String sheetName,String indexCode) { | 139 | public Workbook reportExport(String reportId,String startTime,String endTime,String departId,String sheetName,String indexCode) { |
132 | //获取自定义报表对象 | 140 | //获取自定义报表对象 |
133 | FCustomReportInfo reportInfo = this.getById(reportId); | 141 | FCustomReportInfo reportInfo = this.getById(reportId); |
134 | if("3".equals(reportInfo.getReportTimeQueryType())){//年 | 142 | //年 |
143 | if("3".equals(reportInfo.getReportTimeQueryType())){ | ||
135 | startTime = startTime + "-01"; | 144 | startTime = startTime + "-01"; |
136 | endTime = endTime + "-31"; | 145 | endTime = endTime + "-31"; |
137 | }else if("2".equals(reportInfo.getReportTimeQueryType())){//月 | 146 | //月 |
147 | }else if("2".equals(reportInfo.getReportTimeQueryType())){ | ||
138 | if("1".equals(reportInfo.getReportType())){ | 148 | if("1".equals(reportInfo.getReportType())){ |
139 | startTime = startTime + "-01"; | 149 | startTime = startTime + "-01"; |
140 | endTime = endTime + "-31"; | 150 | endTime = endTime + "-31"; |
... | @@ -160,7 +170,6 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -160,7 +170,6 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
160 | dataFieldDict.put("depart_name", "厂站名称"); | 170 | dataFieldDict.put("depart_name", "厂站名称"); |
161 | dataFieldDict.put("time", "时间"); | 171 | dataFieldDict.put("time", "时间"); |
162 | //获取填报数据 | 172 | //获取填报数据 |
163 | //String dataViewName = "view_"+dataSetId.substring(0,4); | ||
164 | String dataViewName = ReportViewUtil.buildViewLike(dataSetId,"", departId, startTime); | 173 | String dataViewName = ReportViewUtil.buildViewLike(dataSetId,"", departId, startTime); |
165 | //结果集 | 174 | //结果集 |
166 | List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId); | 175 | List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId); |
... | @@ -189,7 +198,8 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -189,7 +198,8 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
189 | @Override | 198 | @Override |
190 | @Transactional(rollbackFor = Exception.class) | 199 | @Transactional(rollbackFor = Exception.class) |
191 | public FCustomReportInfo saveData(FCustomReportInfo fCustomReportInfo) { | 200 | public FCustomReportInfo saveData(FCustomReportInfo fCustomReportInfo) { |
192 | String orgCode = BaseContextHandler.getOrgCode();// 查询集团编码 | 201 | // 查询集团编码 |
202 | String orgCode = BaseContextHandler.getOrgCode(); | ||
193 | //创建菜单 | 203 | //创建菜单 |
194 | String menuId = iSysBaseAPI.saveReportMenu("report/custom/ReportShow","/ReportShow/"+fCustomReportInfo.getId(),fCustomReportInfo.getReportParentMenuId(),fCustomReportInfo.getReportName(),orgCode,1); | 204 | String menuId = iSysBaseAPI.saveReportMenu("report/custom/ReportShow","/ReportShow/"+fCustomReportInfo.getId(),fCustomReportInfo.getReportParentMenuId(),fCustomReportInfo.getReportName(),orgCode,1); |
195 | //保存逻辑 | 205 | //保存逻辑 |
... | @@ -199,11 +209,25 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM | ... | @@ -199,11 +209,25 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM |
199 | iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth()); | 209 | iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth()); |
200 | return fCustomReportInfo; | 210 | return fCustomReportInfo; |
201 | } | 211 | } |
212 | |||
213 | /** | ||
214 | * 更新自定义报表信息及其权限 | ||
215 | * | ||
216 | * 当更新报表信息时,需要确保对应的权限也被正确更新此方法首先删除与报表关联的菜单的现有权限, | ||
217 | * 然后根据提供的信息保存新的权限设置整个过程需要事务管理,以确保数据的一致性 | ||
218 | * | ||
219 | * @param fCustomReportInfo 包含报表信息和权限的对象 | ||
220 | */ | ||
202 | @Override | 221 | @Override |
203 | @Transactional(rollbackFor = Exception.class) | 222 | @Transactional(rollbackFor = Exception.class) |
204 | public void updateDataAndAuthById(FCustomReportInfo fCustomReportInfo) { | 223 | public void updateDataAndAuthById(FCustomReportInfo fCustomReportInfo) { |
224 | // 获取报表对应的菜单ID | ||
205 | String menuId = fCustomReportInfo.getReportMenuId(); | 225 | String menuId = fCustomReportInfo.getReportMenuId(); |
226 | |||
227 | // 删除现有权限,为后续的权限重新设置做准备 | ||
206 | iSysBaseAPI.deleteRoleAuth(menuId); | 228 | iSysBaseAPI.deleteRoleAuth(menuId); |
229 | |||
230 | // 保存新的权限设置,确保报表的权限与新的设置保持一致 | ||
207 | iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth()); | 231 | iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth()); |
208 | } | 232 | } |
209 | } | 233 | } | ... | ... |
-
请 注册 或 登录 后发表评论