From c7e24959364e65e6632e71546d607433560bb403 Mon Sep 17 00:00:00 2001 From: 李林 <z1292839451@163.com> Date: 星期六, 06 四月 2024 17:46:30 +0800 Subject: [PATCH] 检验任务的缺漏代码 --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 83 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 81 insertions(+), 2 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java index b370cb7..7332011 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java @@ -17,9 +17,9 @@ import com.yuanchu.mom.common.PrintChina; import com.yuanchu.mom.dto.InsOrderPlanDTO; import com.yuanchu.mom.dto.SampleProductDto; -import com.yuanchu.mom.exception.ErrorException; import com.yuanchu.mom.mapper.*; import com.yuanchu.mom.pojo.*; +import com.yuanchu.mom.exception.ErrorException; import com.yuanchu.mom.service.InsOrderPlanService; import com.yuanchu.mom.service.InsOrderService; import com.yuanchu.mom.service.StandardTemplateService; @@ -40,6 +40,8 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicInteger; /** * 妫�楠屼换鍔�-涓氬姟瀹炵幇灞� @@ -73,6 +75,10 @@ @Resource private InsReportMapper insReportMapper; + + private InsProductResultMapper insProductResultMapper; + + private InsProductMapper insProductMapper; @Override public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) { @@ -147,7 +153,7 @@ } } if (tableData.size() > 0) { - if (Integer.parseInt(o.get("r") + "") == r + 1 || Integer.parseInt(o.get("r") + "") == r) { + if ((Integer.parseInt(o.get("r") + "") == r + 1 || Integer.parseInt(o.get("r") + "") == r) && !(o.get("v") + "").equals("{\"ht\":\"0\"}")) { r = Integer.parseInt(o.get("r") + ""); tableData.add(o); } else { @@ -166,6 +172,79 @@ } @Override + @Transactional(rollbackFor = Exception.class) + public void saveInsContext(Map<String, Object> insContext) { + Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); + CompletableFuture.supplyAsync(() -> { + AtomicInteger count = new AtomicInteger(); + insContext.forEach((k, v) -> { + JSONObject jo = JSON.parseObject(JSON.toJSONString(v)); + InsProduct insProduct = new InsProduct(); + insProduct.setId(Integer.parseInt(k)); + InsProductResult result = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); + if (BeanUtil.isEmpty(result)) { + result = new InsProductResult(); + } + result.setInsProductId(Integer.parseInt(k)); + JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue"))); + List<Map<String, Object>> iv = new ArrayList<>(); + for (Object o : jsonArray) { + JSONObject insValue = JSON.parseObject(JSON.toJSONString(o)); + Map<String, Object> map = new HashMap<>(); + map.put("v", JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v")); + if (insValue.get("u") == null && StrUtil.isNotEmpty(JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v").toString())) { + map.put("u", userId); + }else { + map.put("u", insValue.get("u")); + } + iv.add(map); + } + result.setInsValue(JSON.toJSONString(iv)); + JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("comValue"))); + List<Map<String, Object>> cv = new ArrayList<>(); + for (Object o : jsonArray2) { + JSONObject comValue = JSON.parseObject(JSON.toJSONString(o)); + Map<String, Object> map = new HashMap<>(); + map.put("v", JSON.parseObject(JSON.toJSONString(comValue.get("v"))).get("v")); + cv.add(map); + } + result.setComValue(JSON.toJSONString(cv)); + JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue"))); + insProduct.setLastValue(JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v") + ""); + JSONObject equipValue = JSON.parseObject(JSON.toJSONString(jo.get("equipValue"))); + try { + result.setEquipValue(JSON.parseObject(JSON.toJSONString(equipValue.get("v"))).get("v") + ""); + }catch (Exception ignored){ + result.setEquipValue(null); + } + JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult"))); + insProduct.setInsResult(Integer.parseInt(JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + "")); + if (BeanUtil.isEmpty(result.getId())) { + result.setCreateUser(userId); + result.setUpdateUser(userId); + insProductResultMapper.insert(result); + } else { + result.setUpdateUser(userId); + result.setUpdateTime(LocalDateTime.now()); + insProductResultMapper.updateById(result); + } + insProduct.setUpdateUser(userId); + insProductMapper.updateById(insProduct); + if(count.get() == 0){ + InsSample insSample = insSampleMapper.selectById(insProductMapper.selectById(insProduct.getId()).getInsSampleId()); + insSample.setInsState(1); + count.addAndGet(1); + } + }); + return null; + }).thenAccept(res -> { + }).exceptionally(e -> { + e.printStackTrace(); + return null; + }); + } + + @Override public int upPlanUser(Integer userId, Integer orderId) { InsSampleUser insSampleUser = new InsSampleUser(); insSampleUser.setUserId(userId); -- Gitblit v1.9.3