From c3ee76c79cc5c5db479b548e1b4eca67327e7396 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期二, 06 八月 2024 11:28:06 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 175 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 129 insertions(+), 46 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 cbc5ab0..dc57054 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 @@ -154,13 +154,15 @@ laboratory = departLims; } } + String userName = null; Integer userId = null; if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) { userId = map1.get("userId"); - insOrderPlanDTO.setUserId(userId.longValue()); + userName = userMapper.selectById(map1.get("userId")).getName(); + insOrderPlanDTO.setUserId(null); } String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹� - IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId, sonLaboratory, laboratory); + IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userName, sonLaboratory, laboratory); map.put("body", insOrderPage); return map; } @@ -201,7 +203,7 @@ } Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null); Integer userId = map1.get("userId"); - InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1, entity.getSonLaboratory()); + InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 0, entity.getSonLaboratory()); return insSampleUserMapper.insert(insSampleUser) > 0; } @@ -239,41 +241,11 @@ insProducts = insSampleMapper.getInsProduct3(id); break; } - // 鏁伴噰鏂板 - getDeviceMessage(insProducts, request); Set<Integer> set = new HashSet<>(); Map<Integer, String> map2 = new HashMap<>(); if (BeanUtil.isEmpty(insProducts)) return null; getTemplateThing(set, map2, insProducts); - return insProducts; - } - - private List<InsProduct> getDeviceMessage(List<InsProduct> insProducts, HttpServletRequest request) { - String ipAddress = request.getRemoteAddr(); - // 闃叉鍥炵幆鍦板潃鍙樹负IPv6 - String ip = ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress; - insProducts.forEach(i -> { - Map<String, Object> devices = baseMapper.getDeviceMessage(ip, i.getInspectionItem(), i.getInspectionItemSubclass(), i.getSampleType()); - if (ObjectUtils.isNotEmpty(devices) && ObjectUtils.isNotEmpty(devices.get("file_type")) && ObjectUtils.isNotEmpty(devices.get("collect_url"))) { - InsProductResult insProductResult = i.getInsProductResult(); - if (ObjectUtils.isEmpty(insProductResult)) { - insProductResult = new InsProductResult(); - } - List<Object> list = new ArrayList<>(); - Map<Object, Object> hashMap = new HashMap<>(); - hashMap.put("v", devices.get("device_name")); - list.add(hashMap); - insProductResult.setEquipName(JSON.toJSON(list).toString()); - List<Object> listValue = new ArrayList<>(); - Map<Object, Object> hashMapValue = new HashMap<>(); - hashMapValue.put("v", devices.get("management_number")); - listValue.add(hashMapValue); - insProductResult.setEquipName(JSON.toJSON(list).toString()); - insProductResult.setEquipValue(JSON.toJSON(listValue).toString()); - i.setInsProductResult(insProductResult); - } - }); return insProducts; } @@ -515,7 +487,8 @@ JSONObject jo = JSON.parseObject(JSON.toJSONString(v)); InsProduct insProduct = new InsProduct(); insProduct.setId(Integer.parseInt(k)); - List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); + List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() + .eq(InsProductResult::getInsProductId, insProduct.getId())); InsProductResult result; if (CollectionUtils.isEmpty(results)) { result = new InsProductResult(); @@ -604,6 +577,52 @@ result.setUpdateTime(LocalDateTime.now()); insProductResultMapper.updateById(result); } + + /*濡傛灉鏄涓�娆¢�夋嫨璁惧淇℃伅,涓旇繕鏈夊叾浣欐牱鍝佷篃鏈夊悓涓�涓粡楠岄」鐩�,閭d箞鎵�鏈夋牱鍝佺殑璇ラ」鐩兘鐢ㄨ繖涓澶囦俊鎭�*/ + //鍏堟煡璇㈡槸鍚﹁繕鏈夊叾浣欐牱鍝� + InsProduct product = insProductMapper.selectById(insProduct.getId()); + + Integer insSampleId = product.getInsSampleId(); + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSampleMapper.selectById(insSampleId).getInsOrderId())); + if (insSamples.size() > 1 && !product.getInspectionItemType().equals("1")) { + //瀛樺湪鍏朵綑鏍峰搧,鏌ヨ鏄惁鏈夊悓涓�绉嶆楠岄」鐩� + for (InsSample sample : insSamples.stream().filter(insSample -> !insSample.getId().equals(insSampleId)).collect(Collectors.toList())) { + InsProduct product1 = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getState, 1) + .eq(InsProduct::getInsSampleId, sample.getId()) + .eq(InsProduct::getInspectionItem, product.getInspectionItem()) + .eq(InsProduct::getInspectionItemEn, product.getInspectionItemEn()) + .eq(InsProduct::getInspectionItemSubclass, product.getInspectionItemSubclass()) + .eq(InsProduct::getInspectionItemSubclassEn, product.getInspectionItemSubclassEn()) + .eq(InsProduct::getTemplateId, product.getTemplateId()) + .eq(InsProduct::getStandardMethodListId, product.getStandardMethodListId()) + ); + if (ObjectUtils.isNotEmpty(product1)){ + //濡傛灉瀛樺湪椤圭洰,鏌ヨ鏄惁鏈夎〃 + InsProductResult productResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, product1.getId())); + if (ObjectUtils.isEmpty(productResult)){ + //娌℃湁琛ㄦ柊寤鸿〃 + productResult = new InsProductResult(); + productResult.setInsProductId(product1.getId()); + productResult.setEquipValue(result.getEquipValue()); + productResult.setEquipName(result.getEquipValue()); + productResult.setCreateUser(userId); + productResult.setUpdateUser(userId); + insProductResultMapper.insert(productResult); + }else if(ObjectUtils.isEmpty(productResult.getEquipValue())){ + //鏈夎〃鍒ゆ柇鏄惁鏈夎澶� + productResult.setEquipValue(result.getEquipValue()); + productResult.setEquipName(result.getEquipValue()); + productResult.setUpdateUser(userId); + productResult.setUpdateTime(LocalDateTime.now()); + insProductResultMapper.updateById(productResult); + } + } + } + + } + + insProduct.setUpdateUser(userId); insProductMapper.updateById(insProduct); insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId())); @@ -697,15 +716,23 @@ Long l = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, insSample.getId())); Long l1 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() - .eq(InsProduct::getInsSampleId, insSample.getId()).isNotNull(InsProduct::getInsResult)); + .eq(InsProduct::getInsSampleId, insSample.getId()) + .and(wrapper -> wrapper + .isNull(InsProduct::getInsResult) + .or() + .eq(InsProduct::getInsResult, 2) + )); if (l == l1) { insSample.setInsState(2); } insSampleMapper.updateById(insSample); /*鏍¢獙涓�涓媟esult琛�*/ - List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId()).orderByDesc(InsProductResult::getId)); + List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() + .eq(InsProductResult::getInsProductId, insProduct.getId())); if (insProductResults.size() > 1) { - insProductResultMapper.deleteById(insProductResults.get(0)); + for (int i = 1; i < insProductResults.size(); i++) { + insProductResultMapper.deleteById(insProductResults.get(i)); + } } }); return insContext.keySet().stream().findFirst().orElse(null); @@ -719,8 +746,17 @@ int orderId = insSampleMapper.selectById(sampleId).getInsOrderId(); // 閫氳繃璁㈠崟id鏌ユ壘鎵�鏈夋牱鏈琲d List<Integer> sampleIds = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)).stream().map(InsSample::getId).collect(Collectors.toList()); - // 閫氳繃妫�鏌ユ瘡涓�涓牱鏈琲d鏌ュ埌灞炰簬妫�楠岄」缁撹 is null鐨勬暟閲� - Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, sampleIds).isNull(InsProduct::getInsResult).eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory()).eq(InsProduct::getState, 1)); + // 閫氳繃妫�鏌ユ瘡涓�涓牱鏈琲d鏌ュ埌灞炰簬妫�楠岄」缁撹 is null 鎴栬�� =2 鐨勬暟閲� + Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .in(InsProduct::getInsSampleId, sampleIds) + .and(wrapper -> wrapper + .isNull(InsProduct::getInsResult) + .or() + .eq(InsProduct::getInsResult, 2) + ) + //.isNull(InsProduct::getInsResult) + .eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory()) + .eq(InsProduct::getState, 1)); if (count == 0) { insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() .eq(InsOrderState::getInsOrderId, orderId) @@ -943,8 +979,48 @@ textRenderData.setText("鈭�"); break; case 0: - resultCh.set(resultCh.get() + "銆�" + p.getInspectionItem() + (Objects.equals(p.getInspectionItemSubclass(), "") ? "" : " " + p.getInspectionItemSubclass())); - resultEn.set(resultEn.get() + "銆�" + p.getInspectionItemEn() + ((Objects.equals(p.getInspectionItemSubclassEn(), "") || Objects.equals(p.getInspectionItemSubclassEn(), null)) ? "" : " " + p.getInspectionItemSubclassEn())); + String current = resultCh.get(); + // 浣跨敤 Set 鏉ヤ繚鎸佸敮涓�椤� + Set<String> uniqueItems = new HashSet<>(); + if (!current.isEmpty()) { + // 鍒嗗壊褰撳墠瀛楃涓插苟鍔犲叆鍒� Set 涓� + String[] items = current.split("銆�"); + for (String item : items) { + if (!item.isEmpty()) { + uniqueItems.add(item); + } + } + } + // 澶勭悊鏂版暟鎹� + String newItem = p.getInspectionItem() + + (Objects.equals(p.getInspectionItemSubclass(), "") ? "" : " " + p.getInspectionItemSubclass()); + uniqueItems.add(newItem); + + // 杩炴帴鍞竴椤瑰苟鏇存柊 AtomicReference + String result = String.join("銆�", uniqueItems); + resultCh.set(result); + //resultCh.set(resultCh.get() + "銆�" + p.getInspectionItem() + (Objects.equals(p.getInspectionItemSubclass(), "") ? "" : " " + p.getInspectionItemSubclass())); + + String current1 = resultEn.get(); + // 浣跨敤 Set 鏉ヤ繚鎸佸敮涓�椤� + Set<String> uniqueItems1 = new HashSet<>(); + if (!current1.isEmpty()) { + // 鍒嗗壊褰撳墠瀛楃涓插苟鍔犲叆鍒� Set 涓� + String[] items = current1.split("銆�"); + for (String item : items) { + if (!item.isEmpty()) { + uniqueItems1.add(item); + } + } + } + // 澶勭悊鏂版暟鎹� + String newItem1 = p.getInspectionItemEn() + + ((Objects.equals(p.getInspectionItemSubclassEn(), "") || Objects.equals(p.getInspectionItemSubclassEn(), null)) ? "" : " " + p.getInspectionItemSubclassEn()); + uniqueItems1.add(newItem1); + // 杩炴帴鍞竴椤瑰苟鏇存柊 AtomicReference + String result1 = String.join("銆�", uniqueItems1); + resultEn.set(result1); + //resultEn.set(resultEn.get() + "銆�" + p.getInspectionItemEn() + ((Objects.equals(p.getInspectionItemSubclassEn(), "") || Objects.equals(p.getInspectionItemSubclassEn(), null)) ? "" : " " + p.getInspectionItemSubclassEn())); textRenderData.setText("脳"); break; default: @@ -1013,7 +1089,7 @@ textRenderData.setText(v.get("v") == null ? "" : v.get("v") + ""); } } else { - textRenderData.setText(v.get("v") == null ? "" : v.get("v") + ""); + textRenderData.setText(v.get("v") == null ? "" : v.get("v") + "鈭�" + jo1.get("mc")); } if (jo1.get("mc") != null) { textRenderData.setText(textRenderData.getText() + "鈭�" + jo1.get("mc")); @@ -3519,7 +3595,11 @@ .in(InsProduct::getInsSampleId, ids) .eq(InsProduct::getSonLaboratory, laboratory) .eq(InsProduct::getState, 1) - .isNull(InsProduct::getInsResult) + .and(wrapper -> wrapper + .isNull(InsProduct::getInsResult) + .or() + .eq(InsProduct::getInsResult, 2) + ) .isNull(InsProduct::getInsFiberId) .isNull(InsProduct::getInsFibersId)); insProducts.addAll(insProductMapper.selectFiberInsProduct(ids, laboratory)); @@ -3586,16 +3666,19 @@ InsSampleUser insSampleUser = new InsSampleUser(); insSampleUser.setUserId(verifyUser); insSampleUser.setInsSampleId(orderId); - insSampleUser.setState(0); + insSampleUser.setState(1); insSampleUser.setSonLaboratory(laboratory); insSampleUserMapper.insert(insSampleUser); /*鏍¢獙涓�涓媟esult琛�*/ CompletableFuture.supplyAsync(() -> { List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList()); for (Integer ip : ips) { - List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, ip).orderByDesc(InsProductResult::getId)); + List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() + .eq(InsProductResult::getInsProductId, ip)); if (insProductResults.size() > 1) { - insProductResultMapper.deleteById(insProductResults.get(0)); + for (int i = 1; i < insProductResults.size(); i++) { + insProductResultMapper.deleteById(insProductResults.get(i)); + } } } return null; -- Gitblit v1.9.3