bdceec32 张雷

refactor(module-datafill): 优化自定义报表相关代码

-调整日期处理逻辑,增加注释提高可读性
- 优化报表导出功能,规范代码格式
- 更新自定义报表信息及其权限的方法,增加事务管理
- 移除未使用的变量和注释掉的代码
- 优化 HyrbReportHandle 类,删除未使用的依赖
-简化 RealTimeAlarmJob 类中的报警记录保存逻辑
1 个父辈 a11f1f6b
......@@ -502,23 +502,19 @@ public class RealTimeAlarmJob implements Job {
//${start}采集数据${conent}已超标,请注意!
alarmRecordHistory.setAlarmContent("采集数据" + content + suffix);
alarmRecordHistory.setCreateBy("system");//标记为系统创建
//alarmRecordHistory.setHandleUser(alarmRuleLevelConfig.getAlarmWorkRecipient());
//标记为系统创建
alarmRecordHistory.setCreateBy("system");
//流程添加定义ID
String processDefinitionId = flowBusinessService.getProcessDefinitionLastVersionId("productAlarmProcess");
alarmRecordHistory.setProcessDefinitionId(processDefinitionId);
alarmRecordHistoryService.save(alarmRecordHistory);
//判断是否需要发送系统通知 (内容跟报警记录信息相同)
if ("1".equals(alarmRuleLevelConfig.getIsSendNotice())) {
if (StringUtils.isNotBlank(alarmRuleLevelConfig.getAlarmNoticeRecipient())) {
//义乌报警存在特定参数逻辑,不适用产品原有消息推送流程
SysMessagePushService sysMessagePushService = (SysMessagePushService) SpringContextUtils.getBean("sysMessagePushService");
sysMessagePushService.pushAlarmRecordMsgNoProcess(alarmRecordHistory);
//SystemNoticeVO systemNoticeVO = new SystemNoticeVO(alarmRuleLevelConfig.getAlarmNoticeRecipient(),alarmRuleLevelName, "在" + date + "时" + departName + "采集数据" + content + suffix, departId, alarmRuleType);
//systemNoticeUtils.dealNoticeMessage(systemNoticeVO);
}
}
//判断是否需要自动发起工作流
......@@ -536,10 +532,6 @@ public class RealTimeAlarmJob implements Job {
Date allowEndDate = null;
Date nowDate = null;
try {
//JSONObject jsonObject = (JSONObject) JSONObject.toJSON(alarmRuleLevelConfig);
//System.err.println("****************************************************");
//System.out.println(jsonObject);
//System.err.println("****************************************************");
allowEndDate = simpleDateFormat.parse(alarmRuleLevelConfig.getSmsAllowSendTime().split("-")[1]);
allowStartDate = simpleDateFormat.parse(alarmRuleLevelConfig.getSmsAllowSendTime().split("-")[0]);
nowDate = simpleDateFormat.parse(date.substring(11, 16));
......@@ -582,9 +574,8 @@ public class RealTimeAlarmJob implements Job {
phoneStringBuilder.append(phone1);
aliAlarm.setTime(date);
aliAlarm.setPhone(phone1);
//发送短信
// HttpSenderMsg.sendMsg(prefix + date + "时" + departName + "采集数据" + content + suffix, phone1);
AliSmsUtil.sendLimitAlarmMsg(aliAlarm);//新版短息发送工具
//新版短息发送工具
AliSmsUtil.sendLimitAlarmMsg(aliAlarm);
log.info("短信发送成功手机号:" + phone1 + ",内容:" + content);
}
}
......
......@@ -30,8 +30,6 @@ public class HyrbReportHandle implements ICustomHandle{
private IFCustomReportDatasetService fCustomReportDatasetService;
@Resource
private IFactoryCenterService factoryCenterService;
@Autowired
private ICommonSqlService commonSqlService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
......
......@@ -50,10 +50,12 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
}
//获取自定义报表对象
FCustomReportInfo reportInfo = this.getById(reportId);
if("3".equals(reportInfo.getReportTimeQueryType())){//年
//年
if("3".equals(reportInfo.getReportTimeQueryType())){
startTime = startTime + "-01";
endTime = endTime + "-31";
}else if("2".equals(reportInfo.getReportTimeQueryType())){//月
//月
}else if("2".equals(reportInfo.getReportTimeQueryType())){
if("1".equals(reportInfo.getReportType())){
startTime = startTime + "-01";
endTime = endTime + "-31";
......@@ -86,9 +88,7 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
dataFieldDict.put("time", "时间");
dataFieldDict.put("paramTime", "参数时间");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime,endTime);
//String dataViewName = ReportViewUtil.buildViewLike(dataSetId,"", departId, startTime);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
for(Map<String,Object> valueMap : valueMapList) {
......@@ -124,17 +124,27 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
map.put("html", html);
return map;
}
/* (non-Javadoc)
* @see com.skua.modules.custom.service.IFCustomReportInfoService#reportExport(java.lang.String)
/**
* 生成并导出报表
* @param reportId 报表ID
* @param startTime 开始时间
* @param endTime 结束时间
* @param departId 部门ID
* @param sheetName 工作表名称
* @param indexCode 指标代码
* @return 返回Workbook对象,用于导出报表
*/
@Override
public Workbook reportExport(String reportId,String startTime,String endTime,String departId,String sheetName,String indexCode) {
//获取自定义报表对象
FCustomReportInfo reportInfo = this.getById(reportId);
if("3".equals(reportInfo.getReportTimeQueryType())){//年
//年
if("3".equals(reportInfo.getReportTimeQueryType())){
startTime = startTime + "-01";
endTime = endTime + "-31";
}else if("2".equals(reportInfo.getReportTimeQueryType())){//月
//月
}else if("2".equals(reportInfo.getReportTimeQueryType())){
if("1".equals(reportInfo.getReportType())){
startTime = startTime + "-01";
endTime = endTime + "-31";
......@@ -160,7 +170,6 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
String dataViewName = ReportViewUtil.buildViewLike(dataSetId,"", departId, startTime);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
......@@ -189,7 +198,8 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
@Override
@Transactional(rollbackFor = Exception.class)
public FCustomReportInfo saveData(FCustomReportInfo fCustomReportInfo) {
String orgCode = BaseContextHandler.getOrgCode();// 查询集团编码
// 查询集团编码
String orgCode = BaseContextHandler.getOrgCode();
//创建菜单
String menuId = iSysBaseAPI.saveReportMenu("report/custom/ReportShow","/ReportShow/"+fCustomReportInfo.getId(),fCustomReportInfo.getReportParentMenuId(),fCustomReportInfo.getReportName(),orgCode,1);
//保存逻辑
......@@ -199,11 +209,25 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth());
return fCustomReportInfo;
}
/**
* 更新自定义报表信息及其权限
*
* 当更新报表信息时,需要确保对应的权限也被正确更新此方法首先删除与报表关联的菜单的现有权限,
* 然后根据提供的信息保存新的权限设置整个过程需要事务管理,以确保数据的一致性
*
* @param fCustomReportInfo 包含报表信息和权限的对象
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateDataAndAuthById(FCustomReportInfo fCustomReportInfo) {
String menuId = fCustomReportInfo.getReportMenuId();
iSysBaseAPI.deleteRoleAuth(menuId);
iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth());
// 获取报表对应的菜单ID
String menuId = fCustomReportInfo.getReportMenuId();
// 删除现有权限,为后续的权限重新设置做准备
iSysBaseAPI.deleteRoleAuth(menuId);
// 保存新的权限设置,确保报表的权限与新的设置保持一致
iSysBaseAPI.saveRoleAuth(menuId, fCustomReportInfo.getReportAuth());
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!