hfxc226 2 жил өмнө
parent
commit
5a8e579e53

+ 9 - 0
platform-dao/src/main/java/com/platform/dao/dto/sb/SbInfoDTO.java

@@ -339,6 +339,15 @@ public class SbInfoDTO extends BaseDTO implements Serializable {
      */
     private String wbFile;
 
+
+    /**
+     * 是否需要检定:0否,1是,使用yesNo枚举类
+     */
+    private Integer isMeasure;
+    /**
+     * 检定状态:0正常无需检定,1待检定,使用yesNo枚举类
+     */
+    private Integer measureStatus;
     /**
      * 使用手册
      */

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/dto/sb/SbMeasureLogDTO.java

@@ -200,12 +200,12 @@ public class SbMeasureLogDTO extends BaseDTO implements Serializable {
     /**
      * 搜索开始日期
      */
-    private LocalDate searchStartTime;
+    private LocalDateTime searchStartTime;
 
     /**
      * 搜索结束日期
      */
-    private LocalDate searchEndTime;
+    private LocalDateTime searchEndTime;
 
     /**
      * 批量检定/校准设备

+ 8 - 0
platform-dao/src/main/java/com/platform/dao/entity/sb/SbInfo.java

@@ -288,6 +288,14 @@ public class SbInfo implements Serializable {
      * 验收文件
      */
     private String checkFile;
+    /**
+     * 是否需要检定:0否,1是,使用yesNo枚举类
+     */
+    private Integer isMeasure;
+    /**
+     * 检定状态:0正常无需检定,1待检定,使用yesNo枚举类
+     */
+    private Integer measureStatus;
     /**
      * 设备图片
      */

+ 0 - 2
platform-dao/src/main/java/com/platform/dao/entity/sb/SbMeasureLog.java

@@ -132,13 +132,11 @@ public class SbMeasureLog implements Serializable {
      * 更新时间
      */
     private LocalDateTime updateTime;
-
     /**
      * 数据权限
      */
     @Transient
     private DataScope dataScope;
-
     /**
      * 标准参数
      */

+ 54 - 0
platform-dao/src/main/java/com/platform/dao/vo/report/MeasureLogReportVO.java

@@ -0,0 +1,54 @@
+package com.platform.dao.vo.report;
+
+import com.platform.dao.vo.query.check.CheckJobVO;
+import com.platform.dao.vo.query.sb.SbMeasureLogVO;
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author cyz
+ */
+@Data
+@Accessors(chain = true)
+public class MeasureLogReportVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 月份
+     */
+    @Excel(name = "年", orderNum = "1")
+    private Integer year;
+    /**
+     * 月份
+     */
+    @Excel(name = "月份", orderNum = "2")
+    private Integer month;
+    /**
+     * 每月总数
+     */
+    @Excel(name = "总数", orderNum = "3")
+    private Integer totalNum;
+    /**
+     * 完成数
+     */
+    @Excel(name = "完成数", orderNum = "4")
+    private Integer totalFinishNum;
+    /**
+     * 未完成数
+     */
+    @Excel(name = "未完成数", orderNum = "5")
+    private Integer totalWaitNum;
+    /**
+     * 完成率
+     */
+    @Excel(name = "完成率", orderNum = "6")
+    private String finishRate;
+
+    /**
+     * 明细列表
+     */
+    List<SbMeasureLogVO> detailList;
+}

+ 8 - 0
platform-dao/src/main/java/com/platform/dao/vo/sb/SbInfoVO.java

@@ -439,6 +439,14 @@ public class SbInfoVO extends BaseVO implements Serializable {
 
     private List<SbInfoVO> children;
 
+    /**
+     * 是否需要检定:0否,1是,使用yesNo枚举类
+     */
+    private Integer isMeasure;
+    /**
+     * 检定状态:0正常无需检定,1待检定,使用yesNo枚举类
+     */
+    private Integer measureStatus;
     /**
      * 申请时间
      */

+ 20 - 2
platform-dao/src/main/resources/mapper/sb/SbInfoMapper.xml

@@ -11,7 +11,7 @@ financing_no_four,
 financing_no_five,
 param_list,
 name, model_id,
-        is_child,
+        is_child, is_measure, measure_status,
         is_show,
         is_financing,
         type_id, level, initial_value, current_value, cut_value,
@@ -92,7 +92,7 @@ sb.financing_no_five,
 sb.financing_no,
 sb.name,  sb.initial_value,
         sb.current_value, sb.cut_value,
-        sb.is_child,
+        sb.is_child, sb.is_measure, sb.measure_status,
         sb.is_financing,
         sb.parent_id,
 sb.param_list,
@@ -248,6 +248,12 @@ user.real_name as saveUserName,sb.repair_dept_id
         <if test="isChild != null">
             and sb.is_child = #{isChild}
         </if>
+        <if test="isMeasure != null">
+            and sb.is_measure = #{isMeasure}
+        </if>
+        <if test="measureStatus != null">
+            and sb.measure_status = #{measureStatus}
+        </if>
         <if test="isShow != null">
             and sb.is_show = #{isShow}
         </if>
@@ -399,6 +405,12 @@ user.real_name as saveUserName,sb.repair_dept_id
         <if test="typeId != null">
             and sb.type_id = #{typeId}
         </if>
+        <if test="isMeasure != null">
+            and sb.is_measure = #{isMeasure}
+        </if>
+        <if test="measureStatus != null">
+            and sb.measure_status = #{measureStatus}
+        </if>
         <if test="parentId != null">
             and sb.parent_id = #{parentId}
         </if>
@@ -479,6 +491,12 @@ user.real_name as saveUserName,sb.repair_dept_id
         <if test="useType != null">
             and sb.use_type = #{useType}
         </if>
+        <if test="isMeasure != null">
+            and sb.is_measure = #{isMeasure}
+        </if>
+        <if test="measureStatus != null">
+            and sb.measure_status = #{measureStatus}
+        </if>
         <if test="id != null">
             and sb.id = #{id}
         </if>

+ 3 - 3
platform-iec/src/main/java/com/platform/iec/IecApplication.java

@@ -48,11 +48,11 @@ public class IecApplication implements CommandLineRunner {
      * 每小时,五分钟
      * {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}
      */
-    @Scheduled(cron = "0 */1 * * * ?")
-   private void configureTasks() {
+  //  @Scheduled(cron = "0 */1 * * * ?")
+  /* private void configureTasks() {
         log.info("执行总召唤");
         Iec104ThreadLocal.getScheduledTaskPool().sendStartFrame();
         Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCall();
         log.info("执行总召唤,定时任务时间: " + LocalDateTime.now());
-    }
+    }*/
 }

+ 2 - 1
platform-iec/src/main/java/com/ydl/iec/iec104/core/ScheduledTaskPool.java

@@ -159,9 +159,10 @@ public class ScheduledTaskPool {
 			} else if (generalCallTThread == null) {
 				senGeneralCallStatus = true;
 				generalCallTThread = new Thread(() -> {
+					LOGGER.error("sendTestStatus: " + sendTestStatus);
 					while (sendTestStatus) {
 						try {
-							LOGGER.info("发送总召唤指令");
+							LOGGER.error("发送总召唤指令");
 							ctx.channel().writeAndFlush(BasicInstruction104.getGeneralCallRuleDetail104());
 							Thread.sleep(1000 * 60 * 15);// 15分钟
 						} catch (Exception e) {

+ 78 - 0
platform-rest/src/main/java/com/platform/rest/controller/report/MeasureLogReportController.java

@@ -0,0 +1,78 @@
+package com.platform.rest.controller.report;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.util.DateUtils;
+import com.platform.common.util.R;
+import com.platform.common.validation.group.AddGroup;
+import com.platform.dao.dto.check.CheckJobDTO;
+import com.platform.dao.dto.sb.SbMeasureLogDTO;
+import com.platform.dao.util.ExcelUtil;
+import com.platform.dao.vo.export.check.ExportCheckJobVO;
+import com.platform.dao.vo.query.check.CheckJobVO;
+import com.platform.dao.vo.report.CheckJobReportVO;
+import com.platform.dao.vo.report.CheckJobReportWeekHoursVO;
+import com.platform.dao.vo.report.MeasureLogReportVO;
+import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.check.CheckJobService;
+import com.platform.service.sb.SbMeasureLogService;
+import lombok.AllArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * @Description 设备计量记录报表 控制器
+ * 1: 按照月份统计,统计每个月完成数量
+ * 2:按照位置汇总,汇总某个时间段,每个位置完成多少,未完成
+ * 3:按照人员汇总,汇总某个时间段,每个人员完成多少,未完成
+ * @Author liuyu
+ * @Date 2020-05-29 10:39:40
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/report/measure/logs")
+public class MeasureLogReportController {
+
+    private final SbMeasureLogService sbMeasureLogService;
+
+    /**
+     * 检定记录每月统计报表导出
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @SysLog("检定记录每月统计报表")
+    @GetMapping("")
+    public R getMonthReportByYear(SbMeasureLogDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        return new R(sbMeasureLogService.getMonthReport(dto, year, startMonth, endMonth));
+    }
+
+    /**
+     * 检定记录每月统计报表导出
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @GetMapping("/export")
+    @SysLog("检定记录每月统计报表导出")
+    public void export(HttpServletResponse response, SbMeasureLogDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        List<MeasureLogReportVO> list = sbMeasureLogService.getMonthReport(dto, year, startMonth, endMonth);
+        String fileName = "";
+        if (year == null) {
+            fileName = DateUtils.dateToString(startMonth, DateUtils.PATTERN_YMD) + "-" + DateUtils.dateToString(endMonth, DateUtils.PATTERN_YMD) + "-检定记录统计报表";
+        } else {
+            fileName = year + "年-检定记录统计报表";
+        }
+        ExcelUtil.exportResponseDict(response, CheckJobReportVO.class, list, fileName);
+    }
+
+    
+}

+ 3 - 0
platform-service/src/main/java/com/platform/service/sb/SbMeasureLogService.java

@@ -7,8 +7,10 @@ import com.platform.dao.entity.check.CheckStandard;
 import com.platform.dao.entity.sb.SbMeasureLog;
 import com.platform.dao.vo.query.check.CheckStandardVO;
 import com.platform.dao.vo.query.sb.SbMeasureLogVO;
+import com.platform.dao.vo.report.MeasureLogReportVO;
 import com.platform.service.base.IBaseService;
 
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -42,4 +44,5 @@ public interface SbMeasureLogService extends IBaseService<SbMeasureLog, SbMeasur
      */
     void saveBatchByDTO(SbMeasureLogDTO record);
 
+    List<MeasureLogReportVO> getMonthReport(SbMeasureLogDTO dto, Integer year, LocalDate startMonth, LocalDate endMonth);
 }

+ 71 - 2
platform-service/src/main/java/com/platform/service/sb/impl/SbMeasureLogServiceImpl.java

@@ -4,20 +4,24 @@ import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.exception.DeniedException;
+import com.platform.common.util.BigDecimalUtil;
 import com.platform.common.util.DateUtils;
 import com.platform.common.util.ListUtils;
 import com.platform.common.util.StringUtils;
 import com.platform.dao.bean.MyPage;
+import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.sb.SbMeasureLogDTO;
 import com.platform.dao.entity.check.CheckProjectStandardRelation;
 import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.sb.SbMeasureLog;
 import com.platform.dao.entity.upms.SysFile;
-import com.platform.dao.enums.SbUseType;
-import com.platform.dao.enums.SysFileTypeEnum;
+import com.platform.dao.enums.*;
 import com.platform.dao.mapper.sb.SbInfoMapper;
 import com.platform.dao.mapper.sb.SbMeasureLogMapper;
+import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.dao.vo.query.sb.SbMeasureLogVO;
+import com.platform.dao.vo.report.CheckJobReportVO;
+import com.platform.dao.vo.report.MeasureLogReportVO;
 import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.sb.SbMeasureLogService;
 import com.platform.service.upms.SysFileService;
@@ -26,9 +30,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import tk.mybatis.mapper.weekend.Weekend;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description 点检标准 service 实现类
@@ -88,6 +94,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
             updInfo.setNextCheckDate(model.getLastDate().minusMonths(-sbInfo.getCheckPeriod()).minusDays(1));
             updInfo.setZaiz(model.getName());// 检定单位
             updInfo.setSbdh(serialNo);// 检定编号
+            updInfo.setMeasureStatus(YesNoEnum.NO.getValue());// 每次检定后, 检定状态改为正常
             updInfo.setRemark(model.getRemark());// 备注
             updInfo.setDph(model.getRequirement());// 检定人
             sbInfoMapper.updateByPrimaryKeySelective(updInfo);
@@ -149,6 +156,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
         sbInfo.setSbdh(model.getNo());// 检定编号
         sbInfo.setRemark(model.getRemark());// 备注
         sbInfo.setDph(model.getRequirement());// 检定人
+        sbInfo.setMeasureStatus(YesNoEnum.NO.getValue());// 每次检定后, 检定状态改为正常
         // sbInfo.setStatus(model.getSbStatus());// 每次检定后,状态变更也要更新
         sbInfoMapper.updateByPrimaryKey(sbInfo);
 
@@ -239,4 +247,65 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
         sbMeasureLog.setCheckFileList(checkFileList);
         return sbMeasureLog;
     }
+
+    @Override
+    public List<MeasureLogReportVO> getMonthReport(SbMeasureLogDTO sbMeasureLogDTO, Integer searchYear , LocalDate startMonth, LocalDate endMonth) {
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
+        LocalDateTime searchStartTime = null;
+        LocalDateTime searchEndTime = null;
+        if(searchYear != null){
+            LocalDate localDate = LocalDate.now();
+            int year = localDate.getYear();
+            // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
+            int month = localDate.getMonthValue();
+            if(searchYear<year){
+                month = 12;
+                year = searchYear;
+            }
+            monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
+            // 当前年份只统计到当前月,历史年份统计全年
+            searchStartTime = DateUtils.getFirstDayOfThisYear(year);
+            searchEndTime = DateUtils.getLastDayOfMonth(year, month);
+        }else{
+            monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(startMonth, endMonth);
+            searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
+            searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
+        }
+
+        // 总数
+        sbMeasureLogDTO.setSearchStartTime(searchStartTime);
+        sbMeasureLogDTO.setSearchEndTime(searchEndTime);
+        List<SbMeasureLogVO> list = mapper.selectList(sbMeasureLogDTO);
+
+        List<MeasureLogReportVO> result = new ArrayList<>();
+        for(Map<String, LocalDateTime> map: monthStartAndEndList){
+            MeasureLogReportVO vo = new MeasureLogReportVO();
+            List<SbMeasureLogVO> detailList = new ArrayList<>();
+            vo.setYear(map.get("searchStartTimeMonth").getYear());
+            vo.setMonth(map.get("searchStartTimeMonth").getMonthValue());
+            int totalNum = 0;
+            int totalFinishNum = 0;
+            int totalWaitNum = 0;
+            double finishRate = 0;
+            for(SbMeasureLogVO sbMeasureLogVO: list){
+                if(sbMeasureLogVO.getLastDate().isAfter(map.get("searchStartTimeMonth").toLocalDate()) && sbMeasureLogVO.getLastDate().isBefore(map.get("searchEndTimeMonth").toLocalDate())){
+                    totalNum ++;
+                    totalFinishNum ++;
+                    detailList.add(sbMeasureLogVO);
+                }
+            }
+
+            if(totalNum != 0){
+                totalWaitNum = totalNum - totalFinishNum;
+                finishRate = BigDecimalUtil.decimal(BigDecimalUtil.div(totalFinishNum*100, totalNum),2);
+            }
+            vo.setTotalNum(totalNum);
+            vo.setTotalFinishNum(totalFinishNum);
+            // vo.setTotalWaitNum(totalWaitNum);
+            // vo.setFinishRate(finishRate+"%");
+            vo.setDetailList(detailList);
+            result.add(vo);
+        }
+        return result;
+    }
 }