| | |
| | | import com.product.org.admin.service.StaffManagerService; |
| | | import com.product.quartz.service.impl.SysJobService; |
| | | import com.product.util.BaseUtil; |
| | | import com.product.util.SystemParamReplace; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | */ |
| | | @Transactional |
| | | public String addWarning(FieldSetEntity fse) throws BaseException, SchedulerException, TaskException { |
| | | FieldSetEntity fseJob = new FieldSetEntity(); |
| | | fseJob.setTableName("product_sys_timed_task"); |
| | | fseJob.setValue("concurrent", 1); |
| | | fseJob.setValue("job_name", fse.getString("config_name")); |
| | | fseJob.setValue("cron_expression", fse.getString("execution_frequency")); |
| | | fseJob.setValue("invoke_target", "warnTask.triggerSingleWarningTask('null')"); |
| | | fseJob.setValue("job_group", "system"); |
| | | fseJob.setValue("misfire_policy", 2); |
| | | fseJob.setValue("remark", ""); |
| | | if (fse.getInteger("config_status") == 0) { |
| | | fseJob.setValue("status", 0); |
| | | } else { |
| | | fseJob.setValue("status", 1); |
| | | } |
| | | fseJob.setValue("is_conceal", 1); |
| | | sysJobService.insertJob(fseJob); |
| | | |
| | | fse.setValue("time_task_uuid", fseJob.getUUID()); |
| | | fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | String uuid = baseDao.add(fse); |
| | | if (fse.getString("type").equals("0")){ |
| | | FieldSetEntity fseJob = new FieldSetEntity(); |
| | | fseJob.setTableName("product_sys_timed_task"); |
| | | fseJob.setValue("concurrent", 1); |
| | | fseJob.setValue("job_name", fse.getString("config_name")); |
| | | fseJob.setValue("cron_expression", fse.getString("execution_frequency")); |
| | | fseJob.setValue("invoke_target", "warnTask.triggerSingleWarningTask('null')"); |
| | | fseJob.setValue("job_group", "system"); |
| | | fseJob.setValue("misfire_policy", 2); |
| | | fseJob.setValue("remark", ""); |
| | | if (fse.getInteger("config_status") == 0) { |
| | | fseJob.setValue("status", 0); |
| | | } else { |
| | | fseJob.setValue("status", 1); |
| | | } |
| | | fseJob.setValue("is_conceal", 1); |
| | | sysJobService.insertJob(fseJob); |
| | | |
| | | fseJob.setValue("invoke_target", "warnTask.triggerSingleWarningTask('" + fse.getUUID() + "')"); |
| | | sysJobService.updateJob(fseJob); |
| | | fse.setValue("time_task_uuid", fseJob.getUUID()); |
| | | |
| | | return uuid; |
| | | String uuid = baseDao.add(fse); |
| | | |
| | | fseJob.setValue("invoke_target", "warnTask.triggerSingleWarningTask('" + fse.getUUID() + "')"); |
| | | sysJobService.updateJob(fseJob); |
| | | return uuid; |
| | | }else { |
| | | return baseDao.add(fse); |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Transactional |
| | | public boolean updateWarning(FieldSetEntity fse) throws BaseException, SchedulerException, TaskException { |
| | | FieldSetEntity fseJob = new FieldSetEntity(); |
| | | fseJob.setTableName("product_sys_timed_task"); |
| | | fseJob.setValue("concurrent", 1); |
| | | fseJob.setValue("job_name", fse.getString("config_name")); |
| | | fseJob.setValue("cron_expression", fse.getString("execution_frequency")); |
| | | fseJob.setValue("invoke_target", "warnTask.triggerSingleWarningTask('" + fse.getUUID() + "')"); |
| | | fseJob.setValue("job_group", "system"); |
| | | fseJob.setValue("misfire_policy", 2); |
| | | fseJob.setValue("remark", ""); |
| | | if (fse.getInteger("config_status") == 0) { |
| | | fseJob.setValue("status", 0); |
| | | sysJobService.pauseJob(fse.getString("time_task_uuid")); |
| | | } else { |
| | | fseJob.setValue("status", 1); |
| | | sysJobService.resumeJob(fse.getString("time_task_uuid")); |
| | | if (fse.getString("type").equals("0")) { |
| | | FieldSetEntity fseJob = new FieldSetEntity(); |
| | | fseJob.setTableName("product_sys_timed_task"); |
| | | fseJob.setValue("concurrent", 1); |
| | | fseJob.setValue("job_name", fse.getString("config_name")); |
| | | fseJob.setValue("cron_expression", fse.getString("execution_frequency")); |
| | | fseJob.setValue("invoke_target", "warnTask.triggerSingleWarningTask('" + fse.getUUID() + "')"); |
| | | fseJob.setValue("job_group", "system"); |
| | | fseJob.setValue("misfire_policy", 2); |
| | | fseJob.setValue("remark", ""); |
| | | if (fse.getInteger("config_status") == 0) { |
| | | fseJob.setValue("status", 0); |
| | | sysJobService.pauseJob(fse.getString("time_task_uuid")); |
| | | } else { |
| | | fseJob.setValue("status", 1); |
| | | sysJobService.resumeJob(fse.getString("time_task_uuid")); |
| | | } |
| | | fseJob.setValue("is_conceal", 1); |
| | | fseJob.setValue("uuid", fse.getString("time_task_uuid")); |
| | | sysJobService.updateJob(fseJob); |
| | | } |
| | | fseJob.setValue("is_conceal", 1); |
| | | fseJob.setValue("uuid", fse.getString("time_task_uuid")); |
| | | sysJobService.updateJob(fseJob); |
| | | |
| | | fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date()); |
| | | return baseDao.update(fse); |
| | |
| | | * @return |
| | | */ |
| | | public boolean conditionCheck(String mainTableName, String warnCondition) { |
| | | Map<String, String> tableNameAndAlias = new HashMap<>(); //相关表名-->表别名,tableName-->tableName1 |
| | | Map<String, String> fieldAndAlias = new HashMap<>(); //相关字段-->字段别名,tableName.fieldName-->tableName1fieldName |
| | | Map<String, String> fieldReference = new HashMap<>(); //组合相关字段的参照,tableName1fieldName-->referenceName |
| | | StringBuilder concatField = new StringBuilder(); //组合相关字段,tableName1.fieldName tableName1fieldName |
| | | Map<String, String> tableNameAndAlias = new HashMap<>();//相关表名-->表别名,tableName-->tableName1 |
| | | Map<String, String> fieldAndAlias = new HashMap<>(); //相关字段-->字段别名,tableName.fieldName-->tableName1fieldName |
| | | Map<String, String> fieldReference = new HashMap<>(); //组合相关字段的参照,tableName1fieldName-->referenceName |
| | | StringBuilder concatField = new StringBuilder(); //组合相关字段,tableName1.fieldName tableName1fieldName |
| | | earlyWarningServer.parseWarningContent(warnCondition, concatField, tableNameAndAlias, fieldAndAlias, fieldReference); |
| | | // 替换系统参数 |
| | | warnCondition = SystemParamReplace.systemParamsReplace(warnCondition); |
| | | |
| | | //生成主子表关联SQL |
| | | String relationSQL = earlyWarningServer.createTableRelation(tableNameAndAlias, mainTableName); |
| | | |
| | | StringBuilder serviceSQL = new StringBuilder(); |
| | | serviceSQL.append(" SELECT "); |
| | | serviceSQL.append(concatField.subSequence(1, concatField.length())); |
| | | serviceSQL.append(" FROM "); |
| | | serviceSQL.append("\nSELECT \n"); |
| | | serviceSQL.append(StringUtils.isEmpty(concatField) ? "*" : concatField.subSequence(1, concatField.length())); |
| | | serviceSQL.append("\nFROM \n"); |
| | | serviceSQL.append(relationSQL); |
| | | serviceSQL.append(" WHERE "); |
| | | serviceSQL.append("\nWHERE \n"); |
| | | serviceSQL.append(earlyWarningServer.parseWarnCondition(warnCondition, tableNameAndAlias)); |
| | | try { |
| | | baseDao.listTable(serviceSQL.toString(), new Object[]{}); |
| | |
| | | StaffManagerService staffManagerService; |
| | | |
| | | public void sendWarnFeedBackMessage(FieldSetEntity fse) throws BaseException { |
| | | String userId = String.valueOf(SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | fse.setValue( CmnConst.USER_ID,userId);//当前人作为消息发送人,其它预警接收人作为收消息人 |
| | | String parent_uuid = fse.getString("puuid"); |
| | | Set<String> receiverSet = this.getReceiver(fse.getString("parent_uuid")); |
| | | if (StringUtils.isEmpty(parent_uuid)) { |
| | |
| | | if (!StringUtils.isEmpty(leaderUserId)) { |
| | | receiverSet.add(leaderUserId); |
| | | } |
| | | String userId = String.valueOf(SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | receiverSet.remove(userId); |
| | | if(receiverSet.isEmpty()){ |
| | | logger.error("发送消息,失败"); |
| | |
| | | throw new BaseException(SystemCode.WARN_TRANSMIT_USER_REPEAT.getValue(), String.format("%s:%s", SystemCode.WARN_TRANSMIT_USER_REPEAT.getText(), transmitUserFse.getString(CmnConst.USER_NAME))); |
| | | } |
| | | }); |
| | | // 更新预警信息表 |
| | | warnMsgFse.setValue(CmnConst.RECEIVER, preReceiver + "," + messageAccepter); |
| | | baseDao.saveFieldSetEntity(warnMsgFse); |
| | | |
| | | // 发送消息给转发人 |
| | | SystemUser curUser = SpringMVCContextHolder.getCurrentUser(); |
| | | FieldSetEntity msgFse = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_MESSAGE, "source_table=? and source_uuid=?", new Object[]{CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, uuid}, false); |
| | | String title = String.format("%s向您转发了预警消息《%s》", curUser.getUser_name(), msgFse.getString(CmnConst.TITLE)); |