Przeglądaj źródła

整改清单报表

zhuang 1 rok temu
rodzic
commit
f0ad33d022

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

@@ -4,8 +4,11 @@ import com.rongwei.bsentity.domain.ZhcxProjectManageDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.dto.project.ProjectSummaryParamExcelDto;
 import com.rongwei.bsentity.dto.project.SavePorjectSummaryDto;
+import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 
+import java.util.Map;
+
 /**
  * <p>
  * 项目管理表 服务类
@@ -37,4 +40,6 @@ public interface ZhcxProjectManageService extends IService<ZhcxProjectManageDo>
      * @param dto
      */
     void saveSummaryData(SavePorjectSummaryDto dto);
+
+    R getRectifyReportData(Map<String, Object> map);
 }

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

@@ -6,6 +6,9 @@ import cn.hutool.core.util.ObjectUtil;
 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.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bscommon.sys.dao.LuckysheetDao;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bscommon.sys.utils.ProjectSummaryExcelHelp;
@@ -15,7 +18,12 @@ import com.rongwei.bscommon.sys.dao.ZhcxProjectManageDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.domain.ZhcxProjectRectifyDo;
 import com.rongwei.bsentity.domain.ZhcxProjectRectifyMachineDo;
+import com.rongwei.bsentity.dto.RectifyDto;
+import com.rongwei.bsentity.dto.RectifyMachineDto;
+import com.rongwei.bsentity.dto.RectifyReportDto;
 import com.rongwei.bsentity.dto.project.*;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
@@ -28,10 +36,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -135,6 +141,83 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         saveSummaryData2Db(prjTitle, celldatas, summaryDataBo);
     }
 
+    @Override
+    public R getRectifyReportData(Map<String, Object> map) {
+        Object projectIdObj = map.get("projectId");
+        if(ObjectUtil.isEmpty(projectIdObj)){
+            return R.error();
+        }
+        String projectId = (String) projectIdObj;
+        LambdaQueryWrapper<ZhcxProjectRectifyDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.and(i -> i.eq(ZhcxProjectRectifyDo::getPrjid, projectId));
+        queryWrapper.and(i -> i.eq(ZhcxProjectRectifyDo::getDeleted, "0"));
+        ZhcxProjectRectifyDo zhcxProjectRectifyDo = projectRectifyService.getOne(queryWrapper);
+        if (zhcxProjectRectifyDo != null) {
+            RectifyReportDto rectifyReportDto = new RectifyReportDto();
+            String machineno = zhcxProjectRectifyDo.getMachineno();
+            if (StringUtils.isNotBlank(machineno)) {
+                List<String> machineNoList = Arrays.asList(machineno .split(","));
+                //这里要存机号列表
+                rectifyReportDto.setNoList(machineNoList);
+                QueryWrapper<ZhcxProjectRectifyMachineDo> wrapper = new QueryWrapper<>();
+                wrapper.eq("PRJID", zhcxProjectRectifyDo.getPrjid());
+                List<ZhcxProjectRectifyMachineDo> list = projectRectifyMachineService.list(wrapper);
+                Map<String, List<ZhcxProjectRectifyMachineDo>> groupDeptList
+                        = list.stream().collect(Collectors.groupingBy(ZhcxProjectRectifyMachineDo::getDeptname));
+                List<RectifyDto> rectifyDtoList = new ArrayList<>();
+                groupDeptList.forEach((k, v) ->{
+                    RectifyDto rectifyDto = new RectifyDto();
+                    rectifyDto.setFirstdeptid(v.get(0).getFirstdeptid());
+                    rectifyDto.setFirstdeptname(v.get(0).getFirstdeptname());
+                    rectifyDto.setDeptid(v.get(0).getDeptid());
+                    rectifyDto.setDeptname(v.get(0).getDeptname());
+                    Map<String, List<ZhcxProjectRectifyMachineDo>> groupMachineList
+                            = v.stream().collect(Collectors.groupingBy(ZhcxProjectRectifyMachineDo::getMachineno));
+                    List<RectifyMachineDto> rectifyMachineDtoList = new ArrayList<>();
+                    groupMachineList.forEach((k2, v2) ->{
+                        RectifyMachineDto rectifyMachine = new RectifyMachineDto();
+                        //设置机号
+                        rectifyMachine.setNo(v2.get(0).getMachineno());
+                        //设置整改总数
+                        rectifyMachine.setTotalCount(v2.size());
+                        Map<String, Long> collect = v2.stream().collect(Collectors.groupingBy(
+                                ZhcxProjectRectifyMachineDo::getStatus, Collectors.counting()));
+                        //关闭数量
+                        int ok = collect.getOrDefault("OK", 0L).intValue();
+                        rectifyMachine.setClosedCount(ok);
+                        //待确认数量
+                        int i = collect.getOrDefault("√", 0L).intValue();
+                        rectifyMachine.setTbcCount(i);
+                        //未完成数量
+                        int x = collect.getOrDefault("X", 0L).intValue();
+                        rectifyMachine.setUnfinishedCount(x);
+                        //完成率1
+                        int rateOne = divideAndRoundUp(ok + i,v2.size());
+                        rectifyMachine.setFinishRateOne(rateOne+"%");
+                        //完成率2
+                        int rateTwo = divideAndRoundUp(x,v2.size());
+                        rectifyMachine.setFinishRateTwo(rateTwo+"%");
+                        rectifyMachineDtoList.add(rectifyMachine);
+                    });
+                    rectifyDto.setData(rectifyMachineDtoList);
+                    rectifyDtoList.add(rectifyDto);
+                });
+                rectifyReportDto.setData(rectifyDtoList);
+                return R.ok(rectifyReportDto);
+            }
+        }
+        return R.ok();
+    }
+
+    private int divideAndRoundUp(int numerator, int denominator) {
+        if (denominator == 0) {
+            log.info("整改清单统计报错{},被除数是0");
+            throw new IllegalArgumentException("Denominator cannot be zero");
+        }
+
+        return (int) Math.ceil((double) numerator / denominator);
+    }
+
     /**
      * 持久化数据
      *

+ 4 - 4
business-entity/src/main/java/com/rongwei/bsentity/dto/RectifyDto.java

@@ -28,10 +28,10 @@ public class RectifyDto {
      * 施工部门
      */
     private String deptname;
-    /**
-     * 机号列表
-     */
-    private List<String> machineNoList;
+//    /**
+//     * 机号列表
+//     */
+//    private List<String> machineNoList;
     /**
      * 统计数据
      */

+ 6 - 2
business-entity/src/main/java/com/rongwei/bsentity/dto/RectifyMachineDto.java

@@ -18,11 +18,11 @@ public class RectifyMachineDto {
     /**
      * 完成率1
      */
-    private BigDecimal finishRateOne;
+    private String finishRateOne;
     /**
      * 完成率2
      */
-    private BigDecimal finishRateTwo;
+    private String finishRateTwo;
     /**
      * 关闭数
      */
@@ -35,4 +35,8 @@ public class RectifyMachineDto {
      * 待确认数
      */
     private Integer tbcCount;
+    /**
+     * 机号
+     */
+    private String no;
 }

+ 21 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/RectifyReportDto.java

@@ -0,0 +1,21 @@
+package com.rongwei.bsentity.dto;
+
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class RectifyReportDto {
+    /**
+     * 机号列表
+     */
+    private List<String> noList;
+    /**
+     * 整改数据列表
+     */
+    private List<RectifyDto> data;
+}

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

@@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Map;
+
 /**
  * <p>
  * 项目管理表 前端控制器
@@ -56,5 +58,12 @@ public class ZhcxProjectManageController {
         service.saveSummaryData(dto);
         return R.ok();
     }
+
+    @PostMapping("/getRectifyReportData")
+    @ApiOperation("获取整改报表数据")
+    public R getRectifyReportData(@RequestBody Map<String,Object> map) {
+        R r = service.getRectifyReportData(map);
+        return r;
+    }
 }