|
@@ -3,6 +3,8 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.db.handler.HandleHelper;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -15,13 +17,18 @@ import com.rongwei.bsentity.dto.lowaltitude.AddHoistingPlanDateRequest;
|
|
|
import com.rongwei.bsentity.dto.lowaltitude.DeleteCheckRequest;
|
|
|
import com.rongwei.bsentity.dto.lowaltitude.SaveCheckDetailDto;
|
|
|
import com.rongwei.bsentity.dto.lowaltitude.SaveCheckRequest;
|
|
|
+import com.rongwei.bsentity.dto.project.indicator.DelPhysicalParam;
|
|
|
+import com.rongwei.bsentity.vo.lowaltiude.LowaltitedeDebtfreddCheckVo;
|
|
|
import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.vo.generalsql.GeneralUpdateVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -61,6 +68,12 @@ public class ZhcxLowaltitudeDebtfreeCheckServiceImpl extends ServiceImpl<ZhcxLow
|
|
|
@Autowired
|
|
|
private SysGeneralCRUDService generalCRUDService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZhcxLowaltitudeDebtfreeCheckDao dao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxProjectDeviceIndicatorService projectDeviceIndicatorService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加吊装日期
|
|
|
*
|
|
@@ -282,6 +295,126 @@ public class ZhcxLowaltitudeDebtfreeCheckServiceImpl extends ServiceImpl<ZhcxLow
|
|
|
lowaltitudeDebtfreeCheckMainService.saveMain4Power(req, checkDo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加统计指标
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void addUpComplateIndicators() {
|
|
|
+
|
|
|
+ //删除低空数据
|
|
|
+ DelPhysicalParam param = DelPhysicalParam.builder()
|
|
|
+ .type("lowaltitude_complate")
|
|
|
+ .build();
|
|
|
+ projectDeviceIndicatorService.delPhysical(param);
|
|
|
+
|
|
|
+ final List<LowaltitedeDebtfreddCheckVo> debtfreddCheckVos = dao.getStatisticalIndicators();
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(debtfreddCheckVos)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 存放统计数据
|
|
|
+ * key:项目id_机号id
|
|
|
+ * value:{
|
|
|
+ * numerator: 0, //分子
|
|
|
+ * denominator: 0 //分母
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ Map<String, JSONObject> prjMachineMap = new HashMap<>();
|
|
|
+
|
|
|
+ //数据分组并统计
|
|
|
+ debtfreddCheckVos.stream().forEach(item -> {
|
|
|
+ StringBuilder keySb = new StringBuilder();
|
|
|
+ keySb.append(item.getProjectid()).append("_").append(item.getMachinenoid());
|
|
|
+
|
|
|
+ JSONObject valueObj = prjMachineMap.get(keySb.toString());
|
|
|
+ if(ObjectUtil.isNull(valueObj)) {
|
|
|
+ valueObj = new JSONObject();
|
|
|
+ valueObj.put("numerator", BigDecimal.ZERO);//分子
|
|
|
+ valueObj.put("denominator", BigDecimal.ZERO);//分母
|
|
|
+
|
|
|
+ valueObj.put("hoistingplandate", item.getHoistingplandate());
|
|
|
+ valueObj.put("finalassembledate", item.getFinalassembledate());
|
|
|
+ valueObj.put("projectid", item.getProjectid());
|
|
|
+ valueObj.put("projectcode", item.getProjectcode());
|
|
|
+ valueObj.put("projectename", item.getProjectename());
|
|
|
+ valueObj.put("projectname", item.getProjectname());
|
|
|
+ valueObj.put("machinenoid", item.getMachinenoid());
|
|
|
+ valueObj.put("machineno", item.getMachineno());
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取完成情况
|
|
|
+ String completionstatus = getCompletionstatus(item);
|
|
|
+
|
|
|
+ final String[] split = completionstatus.split("//");
|
|
|
+ valueObj.put("numerator", valueObj.getBigDecimal("numerator").add(new BigDecimal(split[0])));
|
|
|
+ valueObj.put("denominator", valueObj.getBigDecimal("denominator").add(new BigDecimal(split[1])));
|
|
|
+
|
|
|
+ prjMachineMap.put(keySb.toString(), valueObj);
|
|
|
+ });
|
|
|
+
|
|
|
+ List<ZhcxProjectDeviceIndicatorDo> list = new ArrayList<>();
|
|
|
+ for(String key : prjMachineMap.keySet()) {
|
|
|
+ final JSONObject row = prjMachineMap.get(key);
|
|
|
+
|
|
|
+ ZhcxProjectDeviceIndicatorDo indicator = new ZhcxProjectDeviceIndicatorDo();
|
|
|
+ indicator.setId(SecurityUtil.getUUID());
|
|
|
+ indicator.setDate(row.getDate("finalassembledate"));
|
|
|
+ indicator.setDeleted("0");
|
|
|
+ indicator.setProjectid(row.getString("projectid"));
|
|
|
+ indicator.setProjectcode(row.getString("projectcode"));
|
|
|
+ indicator.setProjectname(row.getString("projectname"));
|
|
|
+ indicator.setProjectshortname(row.getString("projectename"));
|
|
|
+ indicator.setMachineid(row.getString("machinenoid"));
|
|
|
+ indicator.setMachineno(row.getString("machineno"));
|
|
|
+ indicator.setDisplayboard("红");
|
|
|
+ indicator.setIndicatorname("低空不欠债完成情况");
|
|
|
+ indicator.setType("lowaltitude_complate");
|
|
|
+ indicator.setSort(1);
|
|
|
+
|
|
|
+ indicator.setCompleted(row.getInteger("numerator"));
|
|
|
+ indicator.setTotal(row.getInteger("denominator"));
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(row.getInteger("denominator"))) { //分母为空,完成率为0
|
|
|
+ indicator.setCompletionrate(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ BigDecimal completionRate = row.getBigDecimal("numerator")
|
|
|
+ .divide(row.getBigDecimal("denominator"))
|
|
|
+ .multiply(new BigDecimal("100"))
|
|
|
+ .setScale(2, RoundingMode.DOWN);
|
|
|
+ indicator.setCompletionrate(completionRate);
|
|
|
+ }
|
|
|
+ list.add(indicator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(list)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ projectDeviceIndicatorService.saveBatch(list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取完成情况
|
|
|
+ *
|
|
|
+ * @param check
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getCompletionstatus(ZhcxLowaltitudeDebtfreeCheckDo check) {
|
|
|
+ if(ObjectUtil.isNotEmpty(check.getPowercompletionstatus())) {
|
|
|
+ return check.getCompletionstatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(check.getCompletionstatus())) {//总装完成情况
|
|
|
+ return check.getCompletionstatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ return "0/0";
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更新检查表
|
|
|
*
|