hfxc226 3 years ago
parent
commit
e21daaa362

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/enums/SysConfigEnum.java

@@ -35,8 +35,8 @@ public enum SysConfigEnum {
     REPAIR_WARN_MINUTE("维修单接收超时预警分钟"),
     REPAIR_OVERTIME_MINUTE_FIRST("维修超时预警第一阶段"),
     REPAIR_OVERTIME_MINUTE_SECOND("维修超时预警第二阶段"),
-    REPAIR_OVERTIME_MINUTE_THIRD("维修超时预警第三阶段");
-
+    REPAIR_OVERTIME_MINUTE_THIRD("维修超时预警第三阶段"),
+    CHECK_JOB_WORK("每周工作负荷");
     private final String typeName;
 
 }

+ 13 - 4
platform-dao/src/main/java/com/platform/dao/vo/report/CheckJobReportWeekHoursVO.java

@@ -19,19 +19,28 @@ public class CheckJobReportWeekHoursVO implements Serializable {
     /**
      * 周
      */
-    @Excel(name = "周", orderNum = "1")
+    @Excel(name = "年", orderNum = "1")
+    private String year;
+    /**
+     * 周
+     */
+    @Excel(name = "周", orderNum = "2")
     private String week;
     /**
      * 保养标准工时(小时)
      */
-    @Excel(name = "保养标准工时", orderNum = "2")
+    @Excel(name = "保养标准工时", orderNum = "3")
     private Double totalHours;
     /**
      * 可用工时
      */
-    @Excel(name = "可用工时", orderNum = "3")
+    @Excel(name = "可用工时", orderNum = "4")
     private Double useHours;
-
+    /**
+     * 可用工时
+     */
+    @Excel(name = "可用人数", orderNum = "5")
+    private Double usePeople;
     /**
      * 明细列表
      */

+ 14 - 0
platform-rest/src/main/java/com/platform/rest/controller/report/CheckJobReportController.java

@@ -69,6 +69,20 @@ public class CheckJobReportController {
         ExcelUtil.exportResponseDict(response, CheckJobReportVO.class, list, fileName);
     }
 
+    /**
+     * 新增保养任务负荷数据
+     *
+     * @param checkJobReportWeekHoursVO 任务DTO
+     * @return R
+     */
+    @SysLog("新增保养任务负荷数据")
+    @PostMapping
+    @PreAuthorize("@pms.hasPermission('check-polling-jobs-add')")
+    public R saveWorkHour(@Validated({AddGroup.class}) @RequestBody CheckJobReportWeekHoursVO checkJobReportWeekHoursVO) {
+        checkJobService.saveWorkHour(checkJobReportWeekHoursVO);
+        return new R("保存成功");
+    }
+
     /**
      * 保养任务每月统计报表导出
      * @param dto 查询条件

+ 12 - 0
platform-service/src/main/java/com/platform/service/check/CheckJobService.java

@@ -132,4 +132,16 @@ public interface CheckJobService extends IBaseService<CheckJob, CheckJobDTO> {
     List<CheckJobReportVO> getMonthReport(CheckJobDTO checkJobDTO, Integer month, LocalDate startMonth, LocalDate endMonth);
 
     List<CheckJobReportWeekHoursVO> getWeekReport(CheckJobDTO checkJobDTO, Integer month, LocalDate startMonth, LocalDate endMonth);
+
+
+    /**
+     * 保存每周工作负荷
+     * @param dto
+     */
+    void saveWorkHour(CheckJobReportWeekHoursVO dto );
+    /**
+     * 修改每周工作负荷
+     * @param dto
+     */
+    void modWorkHour(CheckJobReportWeekHoursVO dto );
 }

+ 79 - 16
platform-service/src/main/java/com/platform/service/check/impl/CheckJobServiceImpl.java

@@ -2,8 +2,11 @@ package com.platform.service.check.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.common.cache.ConfigCache;
 import com.platform.common.enums.DataFilterTypeEnum;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.model.OauthUser;
@@ -16,6 +19,8 @@ import com.platform.dao.dto.check.CheckProjectPlanRelationDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
 import com.platform.dao.entity.check.*;
 import com.platform.dao.entity.sb.SbInfo;
+import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
+import com.platform.dao.entity.upms.SysConfig;
 import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.enums.*;
 import com.platform.dao.mapper.check.*;
@@ -33,6 +38,7 @@ import com.platform.dao.vo.tuicalendar.TuiCalendarUtil;
 import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.check.CheckJobService;
 import com.platform.service.sb.SbInfoService;
+import com.platform.service.upms.SysConfigService;
 import com.platform.service.upms.SysUserDeptService;
 import com.platform.service.util.SysFileUtils;
 import lombok.AllArgsConstructor;
@@ -42,6 +48,7 @@ import org.springframework.util.CollectionUtils;
 import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
 
+import javax.annotation.Resource;
 import java.io.*;
 import java.math.BigDecimal;
 import java.time.DayOfWeek;
@@ -50,10 +57,7 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalAdjusters;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description 点检记录 service 实现类
@@ -71,7 +75,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
     private CheckStandardMapper standardMapper;
     private SysUserDeptService sysUserDeptService;
     private SbInfoService sbInfoService;
-
+    private SysConfigService sysConfigService;
     private final SysFileMapper sysFileMapper;
 
     @Override
@@ -1112,17 +1116,6 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         });
     }
 
-    public static void main(String[] args) throws IOException {
-        FileInputStream inputStream = new FileInputStream("C:\\Users\\cyz\\Desktop\\需要被删除的id.txt");
-        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
-
-        String str = null;
-        while((str = bufferedReader.readLine()) != null)
-        {
-            System.out.println(str+"',");
-        }
-    }
-
     /**
      * 查询任务
      * 未登录查询当日任务
@@ -1301,6 +1294,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         for(Map<String, LocalDateTime> map: monthStartAndEndList){
             CheckJobReportWeekHoursVO vo = new CheckJobReportWeekHoursVO();
             List<CheckJobVO> detailList = new ArrayList<CheckJobVO>();
+            vo.setYear(searchYear+"");
             vo.setWeek((i++) + "周");
             double totalHours = 0;
             for(CheckJobVO checkJob: list){
@@ -1318,9 +1312,78 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
             vo.setDetailList(detailList);
             result.add(vo);
         }
+
+        SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.CHECK_JOB_WORK.toString());
+        if(sysConfig != null) {
+            List<CheckJobReportWeekHoursVO> voList = JSONArray.parseArray(sysConfig.getContent(), CheckJobReportWeekHoursVO.class);
+            for(CheckJobReportWeekHoursVO r: result){
+                for(CheckJobReportWeekHoursVO v: voList){
+                    if(r.getYear().equals(v.getYear()) && r.getWeek().equals(v.getWeek())){
+                        r.setUseHours(v.getUseHours());
+                        r.setUsePeople(v.getUsePeople());
+                        break;
+                    }
+                }
+            }
+        }
        /* for(CheckJobReportWeekHoursVO r: result){
             System.out.println(r.toString());
         }*/
         return result;
     }
+
+    @Override
+    public void saveWorkHour(CheckJobReportWeekHoursVO dto) {
+        SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.CHECK_JOB_WORK.toString());
+        if(sysConfig != null){
+            List<CheckJobReportWeekHoursVO> list = JSONArray.parseArray(sysConfig.getContent(), CheckJobReportWeekHoursVO.class);
+            boolean find = false;
+            Iterator<CheckJobReportWeekHoursVO> it = list.iterator();
+            while(it.hasNext()){
+                CheckJobReportWeekHoursVO vo = it.next();
+                if(vo.getYear().equals(dto.getYear()) && vo.getWeek().equals(dto.getWeek())){
+                    find = true;
+                    it.remove();
+                    break;
+                }
+            }
+            list.add(dto);
+            list.sort(Comparator.comparing(CheckJobReportWeekHoursVO::getYear).thenComparing(CheckJobReportWeekHoursVO::getWeek));
+            sysConfig.setContent(JSONObject.toJSONString(list));
+            sysConfigService.modModelByPrimaryKey(sysConfig);
+        }else{
+            throw new BusinessException("系统参数未配置,请先配置:CHECK_JOB_WORK,每周工作负荷");
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        List<CheckJobReportWeekHoursVO> list = new ArrayList<CheckJobReportWeekHoursVO>();
+        CheckJobReportWeekHoursVO vo = new CheckJobReportWeekHoursVO();
+        vo.setYear("2021");
+        vo.setWeek("12");
+        vo.setUseHours(3.0);
+        vo.setUsePeople(3.5);
+        list.add(vo);
+
+        CheckJobReportWeekHoursVO vo2 = new CheckJobReportWeekHoursVO();
+        vo2.setYear("2020");
+        vo2.setWeek("1");
+        vo2.setUseHours(5.0);
+        vo2.setUsePeople(4.5);
+        list.add(vo2);
+
+        CheckJobReportWeekHoursVO vo3 = new CheckJobReportWeekHoursVO();
+        vo3.setYear("2020");
+        vo3.setWeek("3");
+        vo3.setUseHours(3.0);
+        vo3.setUsePeople(4.3);
+        list.add(vo3);
+        list.sort(Comparator.comparing(CheckJobReportWeekHoursVO::getYear).thenComparing(CheckJobReportWeekHoursVO::getWeek));
+        System.out.println(JSONObject.toJSONString(list));
+    }
+
+    @Override
+    public void modWorkHour(CheckJobReportWeekHoursVO dto) {
+
+    }
 }

+ 0 - 1
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -49,7 +49,6 @@ import com.platform.service.event.WorkplaceBacklogEvent;
 import com.platform.service.repair.RepairApplicationFormService;
 import com.platform.service.repair.RepairFormService;
 import com.platform.service.sb.SbInfoService;
-import com.platform.service.upms.SysConfigService;
 import com.platform.service.upms.SysUserDeptService;
 import com.platform.service.upms.SysUserService;
 import com.platform.service.util.SysFileUtils;