|
@@ -1,18 +1,18 @@
|
|
|
package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
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.service.ZhcxProjectManageService;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxLowaltitudeDebtfreeCheckDo;
|
|
|
+import com.rongwei.bscommon.sys.service.*;
|
|
|
+import com.rongwei.bsentity.domain.*;
|
|
|
import com.rongwei.bscommon.sys.dao.ZhcxLowaltitudeDebtfreeCheckDao;
|
|
|
-import com.rongwei.bscommon.sys.service.ZhcxLowaltitudeDebtfreeCheckService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxProjectManageDo;
|
|
|
import com.rongwei.bsentity.dto.lowaltitude.AddHoistingPlanDateRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -26,7 +26,65 @@ import java.util.List;
|
|
|
public class ZhcxLowaltitudeDebtfreeCheckServiceImpl extends ServiceImpl<ZhcxLowaltitudeDebtfreeCheckDao, ZhcxLowaltitudeDebtfreeCheckDo> implements ZhcxLowaltitudeDebtfreeCheckService {
|
|
|
|
|
|
@Autowired
|
|
|
- private ZhcxProjectManageService projectManageService;
|
|
|
+ private ZhcxProjectManageService projectManageService;
|
|
|
+ @Autowired
|
|
|
+ private ZhcxLowaltitudeDebtfreeCheckDetailService zhcxLowaltitudeDebtfreeCheckDetailService;
|
|
|
+// @Autowired
|
|
|
+// private ZhcxLowaltitudeDebtfreeCheckDetailDo zhcxLowaltitudeDebtfreeCheckDetailDo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxLowaltitudeDebtfreeBaseInfoDetailService zhcxLowaltitudeDebtfreeBaseInfoDetailService;
|
|
|
+// @Autowired
|
|
|
+// private ZhcxLowaltitudeDebtfreeCheckSubcontractorDo zhcxLowaltitudeDebtfreeCheckSubcontractorDo;
|
|
|
+ @Autowired
|
|
|
+ private ZhcxLowaltitudeDebtfreeCheckSubcontractorService zhcxLowaltitudeDebtfreeCheckSubcontractorService;
|
|
|
+// @Autowired
|
|
|
+// private ZhcxLowaltitudeDebtfreeBaseInfoDo zhcxLowaltitudeDebtfreeBaseInfoDo;
|
|
|
+// @Autowired
|
|
|
+// private ZhcxLowaltitudeDebtfreeBaseInfoDo ZhcxLowaltitudeDebtfreeBaseInfo;
|
|
|
+ @Autowired
|
|
|
+ private ZhcxLowaltitudeDebtfreeBaseInfoService zhcxLowaltitudeDebtfreeBaseInfoService;
|
|
|
+// @Autowired
|
|
|
+// private ZhcxLowaltitudeDebtfreeBaseInfoDetailDo zhcxLowaltitudeDebtfreeBaseInfoDetailDo;
|
|
|
+ private static final HashMap<String, List<String>> PLATE_CLASSIFICATION_MAP = new HashMap<String, List<String>>() {{
|
|
|
+ put("电装板块", Arrays.asList("电装"));
|
|
|
+ put("涂装板块", Arrays.asList("后大梁", "前大梁", "梯形架及整机整改"));
|
|
|
+ put("安装板块", Arrays.asList("安装"));
|
|
|
+ put("装配板块", Arrays.asList("起升机构", "俯仰机构", "小车机构", "其他辅助机构", "机房外", "机房内", "机房围棚", "主小车"));
|
|
|
+ }};
|
|
|
+
|
|
|
+ // 添加明细记录
|
|
|
+ private ZhcxLowaltitudeDebtfreeCheckSubcontractorDo createDetailRecord(String checkId, String classify) {
|
|
|
+ return new ZhcxLowaltitudeDebtfreeCheckSubcontractorDo()
|
|
|
+ .setCheckid(checkId)
|
|
|
+ .setClassify(classify)
|
|
|
+ .setId(UUID.randomUUID().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void LiftingBatchAdd(Map<String, Object> map){
|
|
|
+
|
|
|
+ //参数解析成条数据调用addHoistingPlanDate方法
|
|
|
+ // 获取包含多条记录的列表
|
|
|
+ List<Map<String, Object>> records = (List<Map<String, Object>>) map.get("records");
|
|
|
+
|
|
|
+ // 遍历每一条记录
|
|
|
+ if (records != null) {
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ // 创建 AddHoistingPlanDateRequest 实例
|
|
|
+ AddHoistingPlanDateRequest req = new AddHoistingPlanDateRequest();
|
|
|
+
|
|
|
+ // 从 record 中获取各个字段,并赋值给 req 对象
|
|
|
+ req.setProjectId((String) record.get("projectId"));
|
|
|
+ req.setMachineNoId((String) record.get("machineNoId"));
|
|
|
+ req.setHoistingPlanDate((Date) record.get("hoistingPlanDate"));
|
|
|
+ req.setMachineNo((String) record.get("MachineNo"));
|
|
|
+ addHoistingPlanDate(req);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 添加吊装日期
|
|
@@ -35,15 +93,169 @@ public class ZhcxLowaltitudeDebtfreeCheckServiceImpl extends ServiceImpl<ZhcxLow
|
|
|
*/
|
|
|
@Override
|
|
|
public void addHoistingPlanDate(AddHoistingPlanDateRequest req) {
|
|
|
-
|
|
|
final ZhcxProjectManageDo project = projectManageService.getById(req.getProjectId());
|
|
|
-
|
|
|
+ //根据 项目id和机号id获取 已有数据
|
|
|
LambdaQueryWrapper<ZhcxLowaltitudeDebtfreeCheckDo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(ZhcxLowaltitudeDebtfreeCheckDo::getProjectid, req.getProjectId())
|
|
|
.eq(ZhcxLowaltitudeDebtfreeCheckDo::getMachinenoid, req.getMachineNoId())
|
|
|
.eq(ZhcxLowaltitudeDebtfreeCheckDo::getDeleted, "0");
|
|
|
List<ZhcxLowaltitudeDebtfreeCheckDo> existsList = list(queryWrapper);
|
|
|
+ //判断获取到的列表中的plate 板块 (添加 电装板块 涂装板块 安装板块 装配板块)不在其中的
|
|
|
+ List<String> validPlates = Arrays.asList("电装板块", "涂装板块", "安装板块", "装配板块");
|
|
|
+
|
|
|
+ // 获取 existsList 中已经存在的板块
|
|
|
+ Set<String> existingPlates = existsList.stream()
|
|
|
+ .map(ZhcxLowaltitudeDebtfreeCheckDo::getPlate)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 遍历有效板块,检查是否存在,缺失则新增
|
|
|
+ for (String plate : validPlates) {
|
|
|
+ if (!existingPlates.contains(plate)) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ZhcxLowaltitudeDebtfreeBaseInfoDo> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.eq(ZhcxLowaltitudeDebtfreeBaseInfoDo::getPlate, plate)
|
|
|
+ .eq(ZhcxLowaltitudeDebtfreeBaseInfoDo::getState, "有效")
|
|
|
+ .eq(ZhcxLowaltitudeDebtfreeBaseInfoDo::getDeleted, "0");
|
|
|
+ ZhcxLowaltitudeDebtfreeBaseInfoDo baseInfo = zhcxLowaltitudeDebtfreeBaseInfoService.getOne(queryWrapper1);
|
|
|
+ LambdaQueryWrapper<ZhcxLowaltitudeDebtfreeBaseInfoDetailDo> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper2.eq(ZhcxLowaltitudeDebtfreeBaseInfoDetailDo::getPid, baseInfo.getId())
|
|
|
+ .eq(ZhcxLowaltitudeDebtfreeBaseInfoDetailDo::getStatus, "有效")
|
|
|
+ .eq(ZhcxLowaltitudeDebtfreeBaseInfoDetailDo::getDeleted, "0");
|
|
|
+ // 根据 baseInfo 的 id 查找 ZHCX_LOWALTITUDE_DEBTFREE_BASE_INFO_DETAIL 中的数据
|
|
|
+ List<ZhcxLowaltitudeDebtfreeBaseInfoDetailDo> baseInfoDetails =
|
|
|
+ zhcxLowaltitudeDebtfreeBaseInfoDetailService.list(queryWrapper2);
|
|
|
+
|
|
|
+
|
|
|
+ // 创建新的记录
|
|
|
+ ZhcxLowaltitudeDebtfreeCheckDo newRecord = new ZhcxLowaltitudeDebtfreeCheckDo();
|
|
|
+ newRecord.setProjectid(req.getProjectId());
|
|
|
+ newRecord.setMachinenoid(req.getMachineNoId());
|
|
|
+ newRecord.setMachineno(req.getMachineNo());
|
|
|
+ newRecord.setPlate(plate);
|
|
|
+ newRecord.setDeleted("0");
|
|
|
+ newRecord.setFinalassembledate(req.getHoistingPlanDate());
|
|
|
+ newRecord.setId(UUID.randomUUID().toString());
|
|
|
+ newRecord.setSectordebtratio("0.00%");
|
|
|
+ String completionStatus = "0/" + baseInfoDetails.size();
|
|
|
+ newRecord.setCompletionstatus(completionStatus);
|
|
|
+// newRecord.setAltitude(req)
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- }
|
|
|
|
|
|
-}
|
|
|
+
|
|
|
+ QueryWrapper<ZhcxLowaltitudeDebtfreeCheckDetailDo> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("cd.DELETED", "0")
|
|
|
+ .exists("SELECT * FROM ZHCX_LOWALTITUDE_DEBTFREE_CHECK WHERE cd.CHECKID = ID AND DELETED = '0' AND PROJECTID = " + req.getProjectId() + " AND MACHINENO = " + req.getMachineNo());
|
|
|
+ List<ZhcxLowaltitudeDebtfreeCheckDetailDo> baseInfoDetails1 = zhcxLowaltitudeDebtfreeCheckDetailService.list(wrapper);
|
|
|
+
|
|
|
+ int completeCount = 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (ZhcxLowaltitudeDebtfreeCheckDetailDo row : baseInfoDetails1) {
|
|
|
+ if ("✓".equals(row.getCheckresult()) || ("✕".equals(row.getCheckresult()) && "✓".equals(row.getRectifyesult()))) {
|
|
|
+ completeCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤不需要的记录
|
|
|
+ List<ZhcxLowaltitudeDebtfreeCheckDetailDo> resData = new ArrayList<>();
|
|
|
+ for (ZhcxLowaltitudeDebtfreeCheckDetailDo ev : resData) {
|
|
|
+ if (!"/".equals(ev.getCheckresult()) && !"/".equals(ev.getRectifyesult())) {
|
|
|
+ resData.add(ev);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 计算机器比率
|
|
|
+ String machineRatio;
|
|
|
+ int totalCount = resData.size();
|
|
|
+ if (totalCount == 0) {
|
|
|
+ machineRatio = "0.00%"; // 避免除以零
|
|
|
+ } else {
|
|
|
+ double ratio = (double) completeCount / totalCount * 100;
|
|
|
+ machineRatio = String.format("%.2f%%", ratio);
|
|
|
+ }
|
|
|
+
|
|
|
+ newRecord.setMachinedebtratio(machineRatio);
|
|
|
+ // 保存新记录到 ZHCX_LOWALTITUDE_DEBTFREE_CHECK 表
|
|
|
+ save(newRecord);
|
|
|
+
|
|
|
+ // 根据板块类型新增明细数据到 ZHCX_LOWALTITUDE_DEBTFREE_CHECK_SUBCONTRACTOR 表
|
|
|
+ List<ZhcxLowaltitudeDebtfreeCheckSubcontractorDo> detailRecords = new ArrayList<>();
|
|
|
+ List<String> classifications = PLATE_CLASSIFICATION_MAP.get(plate);
|
|
|
+
|
|
|
+ if (classifications != null) {
|
|
|
+ for (String classify : classifications) {
|
|
|
+// detailRecords.add(createDetailRecord(newRecord.getId(), classify));
|
|
|
+ ZhcxLowaltitudeDebtfreeCheckSubcontractorDo record = createDetailRecord(newRecord.getId(), classify);
|
|
|
+ record.setDeleted("0"); // 手动设置 deleted 字段
|
|
|
+ detailRecords.add(record);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量保存明细记录
|
|
|
+ for (ZhcxLowaltitudeDebtfreeCheckSubcontractorDo detailRecord : detailRecords) {
|
|
|
+ zhcxLowaltitudeDebtfreeCheckSubcontractorService.save(detailRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (baseInfo != null) {
|
|
|
+ // 将数据保存到 ZHCX_LOWALTITUDE_DEBTFREE_CHECK_DETAIL 表
|
|
|
+ for (ZhcxLowaltitudeDebtfreeBaseInfoDetailDo detail : baseInfoDetails) {
|
|
|
+ ZhcxLowaltitudeDebtfreeCheckDetailDo newDetail = new ZhcxLowaltitudeDebtfreeCheckDetailDo();
|
|
|
+ newDetail.setCheckid(newRecord.getId()); // 关联 ZHCX_LOWALTITUDE_DEBTFREE_CHECK 表的 id
|
|
|
+ newDetail.setClassify(detail.getClassify());
|
|
|
+ newDetail.setPart(detail.getPart());
|
|
|
+ newDetail.setContent(detail.getContent());
|
|
|
+ newDetail.setResume(detail.getResume());
|
|
|
+ newDetail.setStandart(detail.getStandart());
|
|
|
+ newDetail.setSquno(detail.getSquno());
|
|
|
+ newDetail.setId(UUID.randomUUID().toString());
|
|
|
+ newDetail.setDeleted("0"); // 默认未删除
|
|
|
+ zhcxLowaltitudeDebtfreeCheckDetailService.save(newDetail); // 保存到 ZHCX_LOWALTITUDE_DEBTFREE_CHECK_DETAIL 表
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } /*else {
|
|
|
+ // 更新总装日期
|
|
|
+ updateFinalAssembleDate(plate, req.getHoistingPlanDate());
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+// 遍历有效板块,检查是否存在,缺失则新增
|
|
|
+ for (String plate : validPlates) {
|
|
|
+ if (!existingPlates.contains(plate)) {
|
|
|
+ //根据plate 查出ZHCX_LOWALTITUDE_DEBTFREE_BASE_INFO中的数据 根据这条数据的id 查出ZHCX_LOWALTITUDE_DEBTFREE_BASE_INFO_DETAIL的数据 把数据塞到 ZHCX_LOWALTITUDE_DEBTFREE_CHECK_DETAIL表给生成uuid
|
|
|
+ // 创建新的记录
|
|
|
+ ZhcxLowaltitudeDebtfreeCheckDo newRecord = new ZhcxLowaltitudeDebtfreeCheckDo();
|
|
|
+ newRecord.setProjectid(req.getProjectId());
|
|
|
+ newRecord.setMachinenoid(req.getMachineNoId());
|
|
|
+ newRecord.setPlate(plate); // 设置为当前缺失的板块
|
|
|
+ newRecord.setDeleted("0"); // 设置为未删除
|
|
|
+ newRecord.setFinalassembledate(req.getHoistingPlanDate());
|
|
|
+// newRecord.setStandardlibid();//标准库id 通过 plate 获取 根据标准库id获取
|
|
|
+ //获取检查内容
|
|
|
+
|
|
|
+ newRecord.setProjectcode();
|
|
|
+ // 保存新记录
|
|
|
+ save(newRecord);
|
|
|
+ }else {
|
|
|
+ //更新总装日期
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果加的 是 电装板块 明细分类塞 电装 ZHCX_LOWALTITUDE_DEBTFREE_CHECK_SUBCONTRACTOR classify*/
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+//如果加的 是 电装板块 分包商 表明细分类塞 电装
|
|
|
+//如果加的 是 涂装板块 明细分类塞 后大梁 前大梁 梯形架及整机整改
|
|
|
+//如果加的 是 安装板块 明细分类塞 安装
|
|
|
+//如果加的 是 装配板块 明细分类塞 起升机构 俯仰机构 小车机构 其他辅助机构 机房外 机房内 机房围棚 主小车
|