|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 持久化数据
|
|
|
*
|