zhuang 8 місяців тому
батько
коміт
ae9f750044

+ 11 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxProjectManageDao.java

@@ -3,6 +3,8 @@ package com.rongwei.bscommon.sys.dao;
 import com.rongwei.bsentity.domain.ZhcxProjectManageDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifyMachineVo;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
@@ -59,4 +61,13 @@ public interface ZhcxProjectManageDao extends BaseMapper<ZhcxProjectManageDo> {
             "</where>" +
             "</script>")
     List<ZhcxProjectRectifyMachineVo> getRectifyListData(Map<String, Object> map);
+
+    @Insert("INSERT INTO ZHCX_PROJECT_RECTIFY_SNAP \n" +
+            "(ID,DATE,CREATEDATE,MODIFYDATE,PROJECTID,FIRSTORGID,FIRSTORGNAME,MACHINENO,RECTIFYTOTAL,FINISHNUM) \n" +
+            "SELECT * FROM (SELECT lower(replace(md5(NEWID()), '-', '')) AS ID,SYSDATE AS DATE,SYSDATE AS CREATEDATE,SYSDATE AS MODIFYDATE,a.PRJID,a.FIRSTDEPTID ,MAX(a.FIRSTDEPTNAME) AS FIRSTDEPTNAME,MAX(a.REALMACHINENO) AS REALMACHINENO,count(*),COUNT(CASE WHEN (a.STATUS =='ok' or a.STATUS == '√')  THEN 1 END) AS filtered_count\n" +
+            "FROM ZHCX_PROJECT_RECTIFY_MACHINE a WHERE a.FIRSTDEPTID IS NOT NULL GROUP BY a.PRJID ,a.FIRSTDEPTID ,a.REALMACHINEID ) a ")
+    void generateRectifyData();
+
+    @Delete("DELETE FROM ZHCX_PROJECT_RECTIFY_SNAP WHERE TRUNC(DATE) = TRUNC(SYSDATE) ")
+    void deleteSnap();
 }

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxProjectManageService.java

@@ -82,4 +82,11 @@ public interface ZhcxProjectManageService extends IService<ZhcxProjectManageDo>
     List<ZhcxProjectRectifyMachineVo> getListData(Map<String, Object> map);
 
     R getRectifyListData(Map<String, Object> map);
+
+    R generateRectifyData();
+
+    R searchRectifyData(Map<String, Object> map);
+
+    void deleteSnap();
+
 }

+ 16 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxProjectRectifySnapService.java

@@ -0,0 +1,16 @@
+package com.rongwei.bscommon.sys.service;
+
+import com.rongwei.bsentity.domain.ZhcxProjectRectifySnapDo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 整改快照 服务类
+ * </p>
+ *
+ * @author wm
+ * @since 2024-11-12
+ */
+public interface ZhcxProjectRectifySnapService extends IService<ZhcxProjectRectifySnapDo> {
+
+}

+ 108 - 8
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

@@ -9,7 +9,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aspose.cells.*;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.rongwei.bscommon.sys.dao.LuckysheetDao;
 import com.rongwei.bscommon.sys.feign.LuckySheetService;
 import com.rongwei.bscommon.sys.service.*;
@@ -19,11 +21,10 @@ import com.rongwei.bscommon.sys.utils.XlsSheetUtil;
 import com.rongwei.bsentity.domain.*;
 import com.rongwei.bscommon.sys.dao.ZhcxProjectManageDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.rongwei.bsentity.dto.RectifyDto;
-import com.rongwei.bsentity.dto.RectifyListDto;
-import com.rongwei.bsentity.dto.RectifyMachineDto;
-import com.rongwei.bsentity.dto.RectifyReportDto;
+import com.rongwei.bsentity.dto.*;
 import com.rongwei.bsentity.dto.project.*;
+import com.rongwei.bsentity.vo.RectifySnapTotalVo;
+import com.rongwei.bsentity.vo.RectifySnapVo;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifyMachineVo;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifyVo;
 import com.rongwei.rwcommon.base.R;
@@ -34,12 +35,9 @@ import com.rongwei.rwcommoncomponent.excel.aspose.ExcelUtils;
 import com.rongwei.rwcommoncomponent.file.dto.SysFileItemParamDto;
 import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
-import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cglib.beans.BeanCopier;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
@@ -47,7 +45,8 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
-import java.lang.reflect.InvocationTargetException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -90,6 +89,8 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     private LuckySheetService luckySheetFeignService;
     @Autowired
     private ZhcxProjectManageRectifyBatchService projectManageRectifyBatchService;
+    @Autowired
+    private ZhcxProjectRectifySnapService zhcxProjectRectifySnapService;
 
 
     private static final Color[] COLORS = {Color.fromArgb(255, 255, 204),
@@ -1839,4 +1840,103 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         rightBorder.setLineStyle(CellBorderType.THIN);
         return style1;
     }
+
+    @Override
+    public R generateRectifyData() {
+        zhcxProjectManageDao.generateRectifyData();
+        return R.ok();
+    }
+
+    @Override
+    public R searchRectifyData(Map<String, Object> map) {
+        Object projectIdObj = map.get("projectId");
+        Object machineNoObj = map.get("machineNo");
+//        Object currentObj = map.get("current");
+//        Object sizeObj = map.get("size");
+        if (ObjectUtil.isEmpty(projectIdObj) || ObjectUtil.isEmpty(machineNoObj)) {
+            return R.error();
+        }
+        String projectId = (String) projectIdObj;
+        String machineNo = (String) machineNoObj;
+//        int current = (Integer) currentObj;
+//        int size = (Integer) sizeObj;
+        //Page<ZhcxProjectRectifySnapDo> page = new Page<>(current, size);
+        LambdaQueryWrapper<ZhcxProjectRectifySnapDo> eq = Wrappers.<ZhcxProjectRectifySnapDo>lambdaQuery()
+                .eq(ZhcxProjectRectifySnapDo::getProjectid, projectId)
+                .eq(ZhcxProjectRectifySnapDo::getMachineno, machineNo)
+                .eq(ZhcxProjectRectifySnapDo::getDeleted, "0")
+                .between(ZhcxProjectRectifySnapDo::getDate, LocalDateTime.now().minusDays(30), LocalDateTime.now());
+        //IPage<ZhcxProjectRectifySnapDo> pageData = zhcxProjectRectifySnapService.page(page, eq);
+//        List<ZhcxProjectRectifySnapDo> list = pageData.getRecords();
+//        Long total = pageData.getTotal();  // 总记录数
+//        Long pages = pageData.getPages();   // 总页数
+        //zhcxProjectManageDao.searchRectifyData();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
+        List<ZhcxProjectRectifySnapDo> list = zhcxProjectRectifySnapService.list(eq);
+        Map<String, List<ZhcxProjectRectifySnapDo>> collect = list.stream()
+                .filter(e -> Objects.nonNull(e.getFirstorgid()))
+                .collect(Collectors.groupingBy(ZhcxProjectRectifySnapDo:: getFirstorgid));
+        RectifySnapDto rectifySnapDto = new RectifySnapDto();
+        Set<String> dateList = new HashSet<>();
+        List<RectifySnapVo> rectifySnapVos = new ArrayList<>();
+        collect.forEach((k, v) -> {
+            RectifySnapVo rectifySnapVo = new RectifySnapVo();
+            List<ZhcxProjectRectifySnapDo> data = new ArrayList<>();
+            rectifySnapVo.setFirstdeptname(v.get(0).getFirstorgname());
+            Map<String, List<ZhcxProjectRectifySnapDo>> collect2 = v.stream()
+                    .filter(e -> Objects.nonNull(e.getDate()))
+                    .collect(Collectors.groupingBy(e -> dateFormat.format(e.getDate())));
+            collect2.forEach((k2, v2) -> {
+                dateList.add(k2);
+                data.addAll(v2);
+            });
+            rectifySnapVo.setData(data);
+            rectifySnapVos.add(rectifySnapVo);
+        });
+//        Map<String, List<ZhcxProjectRectifySnapDo>> collect = list.stream()
+//                .filter(e -> Objects.nonNull(e.getDate()))
+//                .collect(Collectors.groupingBy(e -> dateFormat.format(e.getDate())));
+//        collect.forEach((k, v) -> {
+//
+//            dateList.add(k);
+//            Map<String, List<ZhcxProjectRectifySnapDo>> collect2 = v.stream()
+//                    .filter(e -> Objects.nonNull(e.getFirstorgid()))
+//                    .collect(Collectors.groupingBy(ZhcxProjectRectifySnapDo:: getFirstorgid));
+//            collect2.forEach((k2, v2) -> {
+//                RectifySnapVo rectifySnapVo = new RectifySnapVo();
+//                rectifySnapVo.setFirstdeptname(v2.get(0).getFirstorgname());
+//                rectifySnapVo.setData(v2);
+//                rectifySnapVos.add(rectifySnapVo);
+//            });
+//
+//        });
+        List<String> sortedDateList = dateList.stream()
+                .map(date -> {
+                    try {
+                        return dateFormat.parse(date);
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
+                })
+                .sorted(Collections.reverseOrder())
+                .map(dateFormat::format)
+                .collect(Collectors.toList());
+        rectifySnapVos.forEach(snapVo -> {
+            List<ZhcxProjectRectifySnapDo> dataList = snapVo.getData();
+            if (dataList != null) {
+                // 按 date 字段倒序排序
+                dataList.sort(Comparator.comparing(ZhcxProjectRectifySnapDo::getDate, Comparator.nullsLast(Comparator.reverseOrder())));
+            }
+        });
+        rectifySnapDto.setDateList(sortedDateList);
+        rectifySnapDto.setData(rectifySnapVos);
+//        rectifySnapDto.setTotal(total.intValue());
+//        rectifySnapDto.setPage(pages.intValue());
+        return R.ok(rectifySnapDto);
+    }
+
+    @Override
+    public void deleteSnap() {
+        zhcxProjectManageDao.deleteSnap();
+    }
 }

+ 20 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectRectifySnapServiceImpl.java

@@ -0,0 +1,20 @@
+package com.rongwei.bscommon.sys.service.impl;
+
+import com.rongwei.bsentity.domain.ZhcxProjectRectifySnapDo;
+import com.rongwei.bscommon.sys.dao.ZhcxProjectRectifySnapDao;
+import com.rongwei.bscommon.sys.service.ZhcxProjectRectifySnapService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 整改快照 服务实现类
+ * </p>
+ *
+ * @author wm
+ * @since 2024-11-12
+ */
+@Service
+public class ZhcxProjectRectifySnapServiceImpl extends ServiceImpl<ZhcxProjectRectifySnapDao, ZhcxProjectRectifySnapDo> implements ZhcxProjectRectifySnapService {
+
+}

+ 96 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxProjectRectifySnapDo.java

@@ -0,0 +1,96 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.rongwei.rwcommon.base.BaseDo;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 整改快照
+ * </p>
+ *
+ * @author wm
+ * @since 2024-11-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("ZHCX_PROJECT_RECTIFY_SNAP")
+public class ZhcxProjectRectifySnapDo extends BaseDo {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键
+     */
+    @TableField("ID")
+    private String id;
+    /**
+     * 租户id
+     */
+    @TableField("TENANTID")
+    private String tenantid;
+    /**
+     * 扩展json格式配置
+     */
+    @TableField("ROPTION")
+    private String roption;
+    /**
+     * 项目id
+     */
+    @TableField("PROJECTID")
+    private String projectid;
+    /**
+     * 项目工号
+     */
+    @TableField("PROJECTCODE")
+    private String projectcode;
+    /**
+     * 项目名称
+     */
+    @TableField("PROJECTNAME")
+    private String projectname;
+    /**
+     * 项目简称
+     */
+    @TableField("PROJECTENAME")
+    private String projectename;
+    /**
+     * 机号
+     */
+    @TableField("MACHINENO")
+    private String machineno;
+    /**
+     * 日期
+     */
+    @TableField("DATE")
+    @JsonFormat(pattern = "yyyy/MM/dd")
+    private Date date;
+    /**
+     * 施工部门id
+     */
+    @TableField("FIRSTORGID")
+    private String firstorgid;
+    /**
+     * 施工部门
+     */
+    @TableField("FIRSTORGNAME")
+    private String firstorgname;
+    /**
+     * 整改总数
+     */
+    @TableField("RECTIFYTOTAL")
+    private Integer rectifytotal;
+    /**
+     * 完成数
+     */
+    @TableField("FINISHNUM")
+    private Integer finishnum;
+
+
+}

+ 24 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/RectifySnapDto.java

@@ -0,0 +1,24 @@
+package com.rongwei.bsentity.dto;
+
+import com.rongwei.bsentity.vo.RectifySnapVo;
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class RectifySnapDto {
+
+    /**
+     * 日期列表
+     */
+    private List<String> dateList;
+
+    private List<RectifySnapVo> data;
+
+//    private Integer total;
+//    private Integer page;
+}

+ 28 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/RectifySnapTotalVo.java

@@ -0,0 +1,28 @@
+package com.rongwei.bsentity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.*;
+
+import java.util.Date;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class RectifySnapTotalVo {
+
+    /**
+     * 日期
+     */
+    @JsonFormat(pattern = "yyyy/MM/dd")
+    private Date date;
+    /**
+     * 整改总数
+     */
+    private Integer rectifytotal;
+    /**
+     * 完成数
+     */
+    private Integer finishnum;
+}

+ 21 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/RectifySnapVo.java

@@ -0,0 +1,21 @@
+package com.rongwei.bsentity.vo;
+
+import com.rongwei.bsentity.domain.ZhcxProjectRectifySnapDo;
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class RectifySnapVo {
+
+    /**
+     * 一级部门
+     */
+    private String firstdeptname;
+
+    List<ZhcxProjectRectifySnapDo> data;
+}

+ 15 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxProjectManageController.java

@@ -165,5 +165,20 @@ public class ZhcxProjectManageController {
         projectManageRectifyBatchService.delPrjRectifyBatch(dto.getBatchId());
         return R.ok();
     }
+
+    @PostMapping("/generateRectifyData")
+    @ApiOperation("生成整改快照")
+    public R generateRectifyData(@RequestBody Map<String,Object> map) {
+        service.deleteSnap();
+        R r = service.generateRectifyData();
+        return r;
+    }
+
+    @PostMapping("/searchRectifyData")
+    @ApiOperation("查询整改快照")
+    public R searchRectifyData(@RequestBody Map<String,Object> map) {
+        R r = service.searchRectifyData(map);
+        return r;
+    }
 }