package com.jtgh.qlyg.sync; import java.util.Date; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.jtgh.yjpt.common.Constants; import com.jtgh.yjpt.common.GlobalData; import com.jtgh.yjpt.common.Utils; import com.jtgh.yjpt.controller.BaseController; import com.jtgh.yjpt.entity.common.AccessoryEntity; import com.jtgh.yjpt.entity.qlyg.AlertEntity; import com.jtgh.yjpt.entity.qlyg.ApplyEntity; import com.jtgh.yjpt.entity.qlyg.ApplyProcessEntity; import com.jtgh.yjpt.service.common.AccessoryService; import com.jtgh.yjpt.service.qlyg.AlertService; import com.jtgh.yjpt.service.qlyg.ApplyProcessService; import com.jtgh.yjpt.service.qlyg.ApplyService; /** * 生成异常信息 * * @author liangz * */ @Component public class QlygSyncAlert extends BaseController { @Autowired private ApplyService applyService; @Autowired private AlertService alertService; @Autowired private ApplyProcessService applyProcessService; @Autowired private AccessoryService accessoryService; /** * 扫描办件相关数据 */ public void execute() { // logger.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") // .format(new Date()) + "执行QlygSyncAlert"); // ==============时效异常=================== // -----办件基本信息异常----- /* * 事项预警 */ List applyList = applyService.findAlarm(); if (applyList != null) { for (ApplyEntity applyEntity : applyList) { saveData(applyEntity, Constants.DATE_ALERT, Constants.WARN_TYPE, Constants.DATE_ALERT_1, Utils.getResource("qlyg", "monitor.logo.warn")); } } /* * 事项报警 */ List applyList2 = applyService.findWarn(); if (applyList2 != null) { for (ApplyEntity applyEntity : applyList2) { saveData(applyEntity, Constants.DATE_ALERT, Constants.ALARM_TYPE, Constants.DATE_ALERT_2, Utils.getResource("qlyg", "monitor.logo.alarm")); } } /* * 超过三个月未处理报警 */ List applyList3 = applyService.findThreeMon(); if (applyList3 != null) { for (ApplyEntity applyEntity : applyList3) { saveData(applyEntity, Constants.DATE_ALERT, Constants.ALARM_TYPE, Constants.DATE_ALERT_5, Utils.getResource("qlyg", "monitor.logo.three")); } } // ------办件过程异常--------- /* * 环节预警 */ List processList = applyProcessService.findAlarm(); if (processList != null) { for (ApplyProcessEntity applyProcessEntity : processList) { saveData2(applyProcessEntity, Constants.DATE_ALERT, Constants.WARN_TYPE, Constants.DATE_ALERT_3, Utils.getResource("qlyg", "monitor.logo.warn2")); } } /* * 环节报警 */ List processList2 = applyProcessService.findWarn(); if (processList2 != null) { for (ApplyProcessEntity applyProcessEntity : processList2) { saveData2(applyProcessEntity, Constants.DATE_ALERT, Constants.ALARM_TYPE, Constants.DATE_ALERT_4, Utils.getResource("qlyg", "monitor.logo.alarm2")); } } // ======================内容异常================== /* * 还没产生受理通知书异常的办件 */ List list1 = applyService .findDone(Constants.CONTENT_ALERT_1); if (list1 != null) { for (ApplyEntity applyEntity : list1) { List fjList = accessoryService .findByEntityIdAndEntityTypeAndType( applyEntity.getId(), Constants.GGDM_ID_APPLY, null); if (fjList != null) { boolean flag = false; for (AccessoryEntity accessoryEntity : fjList) { if (accessoryEntity.getName().indexOf("受理通知") != -1) { flag = true; } } if (flag == false) { saveData(applyEntity, Constants.CONTENT_ALERT, Constants.ALARM_TYPE, Constants.CONTENT_ALERT_1, Utils.getResource( "qlyg", "monitor.content.warn1")); } } } } /* * 还没产生决定书异常的办件 */ List list2 = applyService .findDone(Constants.CONTENT_ALERT_2); if (list2 != null) { for (ApplyEntity applyEntity : list2) { List fjList = accessoryService .findByEntityIdAndEntityTypeAndType( applyEntity.getId(), Constants.GGDM_ID_APPLY, null); if (fjList != null) { boolean flag = false; for (AccessoryEntity accessoryEntity : fjList) { if (accessoryEntity.getName().indexOf("决定书") != -1) { flag = true; } } if (flag == false) { saveData(applyEntity, Constants.CONTENT_ALERT, Constants.ALARM_TYPE, Constants.CONTENT_ALERT_2, Utils.getResource( "qlyg", "monitor.content.warn2")); } } } } /* * 还没产生申请材料异常的办件 */ List list3 = applyService .findDone(Constants.CONTENT_ALERT_3); if (list3 != null) { for (ApplyEntity applyEntity : list3) { List fjList = accessoryService .findByEntityIdAndEntityTypeAndType( applyEntity.getId(), Constants.GGDM_ID_APPLY, null); if (fjList == null) { saveData(applyEntity, Constants.CONTENT_ALERT, Constants.ALARM_TYPE, Constants.CONTENT_ALERT_3, Utils.getResource("qlyg", "monitor.content.warn3")); } } } /* * 权力编码未确认 */ List list4 = applyService .findDone(Constants.CONTENT_ALERT_4); if (list4 != null) { for (ApplyEntity applyEntity : list4) { if (applyEntity.getItemId() == null) { saveData(applyEntity, Constants.CONTENT_ALERT, Constants.ALARM_TYPE, Constants.CONTENT_ALERT_4, Utils.getResource("qlyg", "monitor.content.warn4")); } } } } /** * 往异常表中插入数据 * * @param applyEntity * @param string * @param i */ private void saveData(ApplyEntity applyEntity, String monitorType, int outWayType, String type, String logo) { AlertEntity alertEntity = new AlertEntity(); alertEntity.setId(generateEntityId(Constants.SEQ_T_QLYG_MONITOR_ALERT)); String dept_code = GlobalData.DEPT_CODE; if (Utils.getCurrentUser() != null) { dept_code = Utils.getCurrentUser().getSzd().getByzd4() + "JT"; } alertEntity.setNo(generateQlygNo(dept_code, alertEntity.getId())); alertEntity.setBjNo(applyEntity.getNo()); alertEntity.setInfApplyId(applyEntity); alertEntity.setBjType("1"); alertEntity.setOrgId(dept_code); alertEntity.setInternalNo(applyEntity.getInternalNo()); alertEntity.setQlRegId(applyEntity.getItemId()); alertEntity.setMonitorType(monitorType); alertEntity.setOutWayType(outWayType); alertEntity.setMonitorLogo(logo); alertEntity.setType(type); alertEntity.setAddDate(new Date()); alertService.save(alertEntity); } /** * 往异常表中插入数据2 * * @param applyEntity * @param string * @param i */ private void saveData2(ApplyProcessEntity applyEntity, String monitorType, int outWayType, String type, String logo) { AlertEntity alertEntity = new AlertEntity(); alertEntity.setId(generateEntityId(Constants.SEQ_T_QLYG_MONITOR_ALERT)); String dept_code = GlobalData.DEPT_CODE; if (Utils.getCurrentUser() != null) { dept_code = Utils.getCurrentUser().getSzd().getByzd4() + "JT"; } alertEntity.setNo(generateQlygNo(dept_code, alertEntity.getId())); alertEntity.setBjNo(applyEntity.getNo()); alertEntity.setInfApplyId(applyEntity.getInfApplyId()); alertEntity.setBjType("1"); alertEntity.setOrgId(dept_code); alertEntity.setInternalNo(applyEntity.getInternalNo()); alertEntity.setQlRegId(applyEntity.getItemId()); alertEntity.setMonitorType(monitorType); alertEntity.setOutWayType(outWayType); alertEntity.setMonitorLogo(logo); alertEntity.setType(type); alertEntity.setAddDate(new Date()); alertService.save(alertEntity); } }