Browse Source

1.修复绩效bug
2.添加日志

lihui007 3 years ago
parent
commit
1d4a20fe09

+ 42 - 38
operation_manager/src/main/java/com/huaxu/aspect/DictAspect.java

@@ -71,7 +71,7 @@ public class  DictAspect {
      * sex:1,
      * sex_dictText:"男"
      * }
-     * 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
+     * 前端直接取值sext_dict在table里面无需再进行前端的字典转换了
      * customRender:function (text) {
      * if(text==1){
      * return "男";
@@ -85,45 +85,49 @@ public class  DictAspect {
      * @param result
      */
     private void parseDictText(Object result) {
-        if (result instanceof AjaxMessage) {
-            if (((AjaxMessage) result).getData() instanceof Pagination) {
-                List<JSONObject> items = new ArrayList<>();
-                for (Object record : ((Pagination) ((AjaxMessage) result).getData()).getList()) {
-                    ObjectMapper mapper = new ObjectMapper();
-                    String json = "{}";
-                    try {
-                        //解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
-                        json = mapper.writeValueAsString(record);
-                    } catch (JsonProcessingException e) {
-                        log.error("json解析失败" + e.getMessage(), e);
-                    }
-                    JSONObject item = JSONObject.parseObject(json);
-                    for (Field field : getAllFields(record)) {
-                        if (field.getAnnotation(Dict.class) != null) {
-                            String code = field.getAnnotation(Dict.class).dicCode();
-                            String text = field.getAnnotation(Dict.class).dicText();
-                            String table = field.getAnnotation(Dict.class).dictTable();
-                            String key = String.valueOf(item.get(field.getName()));
-
-                            //翻译字典值对应的txt
-                            String textValue = translateDictValue(code, text, table, key);
-
-                            log.debug(" 字典Val : " + textValue);
-                            log.debug(" __翻译字典字段__ " + field.getName() + DICT_TEXT_SUFFIX + ": " + textValue);
-                            item.put(field.getName() + DICT_TEXT_SUFFIX, textValue);
-                        }
-                        //date类型默认转换string格式化日期
-                        if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
-                            SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                            //解决日期较小的情况下被解析为Integer,最后导致导致强转为Long的报错问题
-                            item.put(field.getName(), aDate.format(new Date(Long.valueOf(String.valueOf(item.get(field.getName()))))));
-                        }
-                    }
-                    items.add(item);
+        if (!(result instanceof AjaxMessage)) {
+            return;
+        }
+        if (!(((AjaxMessage) result).getData() instanceof Pagination)) {
+            return;
+        }
+        List<JSONObject> items = new ArrayList<>();
+        List dataList = ((Pagination) ((AjaxMessage) result).getData()).getList();
+        for (Object record : dataList) {
+            ObjectMapper mapper = new ObjectMapper();
+            String json = "{}";
+            try {
+                //解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
+                json = mapper.writeValueAsString(record);
+            } catch (JsonProcessingException e) {
+                log.error("json解析失败" + e.getMessage(), e);
+            }
+            JSONObject item = JSONObject.parseObject(json);
+            for (Field field : getAllFields(record)) {
+                if (field.getAnnotation(Dict.class) != null) {
+                    String code = field.getAnnotation(Dict.class).dicCode();
+                    String text = field.getAnnotation(Dict.class).dicText();
+                    String table = field.getAnnotation(Dict.class).dictTable();
+                    String key = String.valueOf(item.get(field.getName()));
+
+                    //翻译字典值对应的txt
+                    String textValue = translateDictValue(code, text, table, key);
+
+                    log.debug(" 字典Val : " + textValue);
+                    log.debug(" __翻译字典字段__ " + field.getName() + DICT_TEXT_SUFFIX + ": " + textValue);
+                    item.put(field.getName() + DICT_TEXT_SUFFIX, textValue);
+                }
+                //date类型默认转换string格式化日期
+                if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
+                    SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    //解决日期较小的情况下被解析为Integer,最后导致导致强转为Long的报错问题
+                    item.put(field.getName(), aDate.format(new Date(Long.valueOf(String.valueOf(item.get(field.getName()))))));
                 }
-                ((Pagination) ((AjaxMessage) result).getData()).setList(items);
             }
+            items.add(item);
         }
+        ((Pagination) ((AjaxMessage) result).getData()).setList(items);
+
     }
 
     /**
@@ -145,7 +149,7 @@ public class  DictAspect {
             String tmpValue = null;
             log.debug(" 字典 key : " + k);
             if (k.trim().length() == 0) {
-                continue; //跳过循环
+                continue;
             }
             tmpValue = dictUtil.getDictName(code, Integer.parseInt(k.trim()));
             if (tmpValue != null) {

+ 9 - 6
operation_manager/src/main/java/com/huaxu/evaluation/job/EvaluationResultJob.java

@@ -83,12 +83,12 @@ public class EvaluationResultJob {
 
     /***
      *
-     *  异步启动定时任务
+     *  异步启动定时任务,每天凌晨4点
      * @Author lihui
      * @Date 18:26 2021/5/17
      * @return void
      **/
-    @Scheduled(cron = "0/5 * * * * ?")
+    @Scheduled(cron="0 0 4 * * ?")
     @Async
     public void run(){
         if (lock){
@@ -98,8 +98,9 @@ public class EvaluationResultJob {
         log.info("============绩效考评数据生成begin=====================");
         String startTime = null;
         String endTime   = null;
+        int today = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
         EvaluationCycleEntity queryEntity = new EvaluationCycleEntity();
-        queryEntity.setEvaluationDay(Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
+        queryEntity.setEvaluationDay(today);
         // 首先查询当天哪些公司设置了绩效考评
         List<EvaluationCycleEntity> evaluationCycleEntities =  evaluationCycleMapper.findList(queryEntity);
         try {
@@ -110,8 +111,8 @@ public class EvaluationResultJob {
                     continue;
                 }
                 // 根据类型(0月度 1季度 2年度)得到当前的开始时间和结束时间,如果是按季度,当月必须是1,4,7,10
-                startTime = EvaluationUtil.getStartTime(evaluationCycleEntity.getType(), queryEntity.getEvaluationDay());
-                endTime   = EvaluationUtil.getEndTime(evaluationCycleEntity.getType(), queryEntity.getEvaluationDay());
+                startTime = EvaluationUtil.getStartTime(evaluationCycleEntity.getType(), today);
+                endTime   = EvaluationUtil.getEndTime(evaluationCycleEntity.getType(), today);
                 if (startTime == null || endTime == null) {
                     continue;
                 }
@@ -122,7 +123,8 @@ public class EvaluationResultJob {
         } finally {
             // 用完直接clear
             itemMap.clear();
-            //lock = false;
+            userInfoMap.clear();
+            lock = false;
         }
         log.info("============绩效考评数据生成end=====================");
     }
@@ -412,4 +414,5 @@ public class EvaluationResultJob {
         return null;
     }
 
+
 }

+ 2 - 0
operation_manager/src/main/java/com/huaxu/evaluation/service/impl/EvaluationResultServiceImpl.java

@@ -74,6 +74,8 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
         Map<String,String> gradMap  = userCenterClient.selectListByPCodes("SC_EVALUATION_GRADE");
         for (EvaluationReportRankingVo evaluationReportRankingVo: list) {
             evaluationReportRankingVo.setEvaluationGrade(gradMap.get(evaluationReportRankingVo.getEvaluationGrade()));
+            evaluationReportRankingVo.setCompletionRate(EvaluationUtil.onTimeCompletionRate(evaluationReportRankingVo.getCompleteCount(),
+                    evaluationReportRankingVo.getDelayCompleteCount(), evaluationReportRankingVo.getTotalCount()).divide(new BigDecimal("100"),2));
         }
         return list;
     }

+ 6 - 0
operation_manager/src/main/java/com/huaxu/evaluation/vo/EvaluationReportRankingVo.java

@@ -30,6 +30,12 @@ public class EvaluationReportRankingVo {
     @ApiModelProperty(value = "已完成")
     private int completeCount;
 
+    @ApiModelProperty(value = "延期完成数")
+    private int delayCompleteCount;
+
+    @ApiModelProperty(value = "延期完成数")
+    private int totalCount;
+
     @ApiModelProperty(value = "完成率")
     private BigDecimal completionRate;
 

+ 1 - 1
operation_manager/src/main/java/com/huaxu/utils/EvaluationUtil.java

@@ -73,7 +73,7 @@ public class EvaluationUtil {
     /**
      * 工单类型
      */
-    static List<Integer> workList = Arrays.asList(1,2,3,4,5,6);
+    static List<Integer> workList = Arrays.asList(1,2,3,4,5,6,10);
 
     /**
      * @Author lihui

+ 1 - 1
operation_manager/src/main/resources/mapper/evaluation/EvaluationResultMapper.xml

@@ -110,7 +110,7 @@
     </update>
     
     <select id="findRanking" resultType="com.huaxu.evaluation.vo.EvaluationReportRankingVo">
-        select a.EVALUATION_BE,a.VALUE,a.EVALUATION_GRADE,t.COMPLETE_COUNT,t.COMPLETION_RATE
+        select a.EVALUATION_BE,a.VALUE,a.EVALUATION_GRADE,t.COMPLETE_COUNT,t.COMPLETION_RATE,t.DELAY_COMPLETE_COUNT,t.TOTAL_COUNT
         from sc_evaluation_result a
         inner join sc_evaluation_result_task t on a.id = t.EVALUATION_RESULT_ID
         <where>

+ 1 - 0
sms_water/src/main/java/com/huaxu/rabbitmq/AlarmDataHandler.java

@@ -56,6 +56,7 @@ public class AlarmDataHandler {
 
     @Async
     public void hanlder(MonitorDataEntity monitorDataEntity, JSONObject receiveData, Date receiveDateTime){
+        log.info("rabbitMq处理报警,code:{},上报时间:{}",monitorDataEntity.getDeviceCode(), receiveDateTime);
         // 校验各参数异常情况
         Double receivedValue            = null;
         List<AlarmDetailsEntity> insert = null;

+ 1 - 0
sms_water/src/main/java/com/huaxu/rabbitmq/ReceiveClearData.java

@@ -80,6 +80,7 @@ public class ReceiveClearData {
         JSONObject jsonObject = JSONObject.parseObject(new String(receivedData));
         String eventTime      = jsonObject.getString("eventTime");
         String deviceCode     = jsonObject.getString("unitIdentifier");
+        log.info("rabbitMq接收消息处理,code:{},上报时间:{}",deviceCode, eventTime);
         // 对象有时间、有设备编码、有数据则解析,任何一个位空直接退出
         if (!jsonObject.containsKey("eventTime") || !jsonObject.containsKey("unitIdentifier") ||
                 !jsonObject.containsKey("parsedData")) {

+ 2 - 2
sms_water/src/main/java/com/huaxu/rabbitmq/ReportWaterPumpStateHandler.java

@@ -50,7 +50,7 @@ public class ReportWaterPumpStateHandler {
     @Async
     public void handler(MonitorDataEntity monitorDataEntity, JSONObject receiveData, Date receiveDateTime){
 
-        log.info("【水泵运行状态报表:{}】开始处理", monitorDataEntity.getDeviceCode());
+        log.info("【rabbitMq处理报警水泵运行状态报表:{}】开始处理", monitorDataEntity.getDeviceCode());
         // 0 运行, 1停止
         int state = 0;
         // 执行批量插入操作
@@ -85,7 +85,7 @@ public class ReportWaterPumpStateHandler {
                 reportWaterPumpStateMapper.batchInsertReportWaterPumpState(insertList);
             }
         }
-        log.info("【水泵运行状态报表:{}】结束处理,新增:{}", monitorDataEntity.getDeviceCode(),insertList.size());
+        log.info("【rabbitMq处理报警水泵运行状态报表:{}】结束处理,新增:{}", monitorDataEntity.getDeviceCode(),insertList.size());
     }
 
     private List<String> toList(List<DeviceAttributeSpecsEntity> list){