From 23adbd6fd679e293c4c8118713b9e1e8b0a463bb Mon Sep 17 00:00:00 2001 From: 123456 <123456> Date: 星期三, 17 七月 2024 16:11:46 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 103 insertions(+), 2 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java index a9cc3f9..b7c2c51 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java @@ -318,7 +318,67 @@ } } insProductService.saveBatch(insProductes); - } else { + } + //鍒ゆ柇鐑惊鐜」鐩殑娣诲姞鍜屾俯鍗囪瘯楠岄」鐩殑娣诲姞 + else if (product.getInspectionItem().equals("鐑惊鐜�") || product.getInspectionItem().equals("娓╁崌璇曢獙")) { + List<InsProduct> insProductess = new ArrayList<>(); + insProductess.add(product); + List<InsProduct> insProductes = new ArrayList<>(); + List<InsProduct> insProducts = new ArrayList<>(); + String[] strings = product.getAsk().split(";"); + //寰幆娆℃暟 + int count = Integer.parseInt(strings[strings.length - 1]); + for (int i = 0; i < strings.length - 1; i++) { + String[] split = strings[i].split(","); + InsProduct insProduct = new InsProduct(); + insProduct.setInspectionItem("1");//妫�楠岀埗椤�--寰幆娆℃暟 + insProduct.setInspectionItemSubclass(split[0]);//妫�楠屽瓙椤�--鐜娓╁害/瀵肩嚎娓╁害/鑰愬紶娓╁害/鎺ョ画娓╁害 + insProduct.setInspectionItemSubclassEn(split[1]);//妫�楠屽瓙椤硅嫳鏂�--鐜娓╁害/瀵肩嚎娓╁害/鑰愬紶娓╁害/鎺ョ画娓╁害 + insProduct.setAsk(null);//妫�楠岃姹� + insProduct.setTell(null);//妫�楠屾弿杩� + insProduct.setInsSampleId(sampleId); + insProduct.setState(1); + insProduct.setFactory(product.getFactory()); + insProduct.setLaboratory(product.getLaboratory()); + insProduct.setSampleType(product.getSampleType()); + insProduct.setSample(product.getSample()); + insProduct.setModel(product.getModel()); + insProduct.setSonLaboratory(product.getSonLaboratory()); + insProduct.setUnit("鈩�");//鍗曚綅 + insProduct.setManHourGroup(product.getManHourGroup()); + insProduct.setInspectionItemType("0"); + insProduct.setInspectionValueType("1"); + insProducts.add(insProduct); + insProductes.add(insProduct); + insProductess.add(insProduct); + } + //鐑惊鐜墠鏈夊娆″惊鐜鏁� + if (product.getInspectionItem().equals("鐑惊鐜�")) { + //鐑惊鐜繕瑕佸姞涓婄洿娴佺數闃� + for (InsProduct insProduct : insProducts) { + InsProduct insProduct1 = new InsProduct(); + BeanUtils.copyProperties(insProduct, insProduct1); + insProduct1.setInspectionItemClass("鐩存祦鐢甸樆");//妫�楠屽瓙瀛愰」--鐩存祦鐢甸樆 + insProduct1.setInspectionItemClassEn("DC resistance");//妫�楠屽瓙瀛愰」鑻辨枃--鐩存祦鐢甸樆 + insProduct1.setUnit("惟/km");//鍗曚綅 + insProductes.add(insProduct1); + insProductess.add(insProduct1); + } + } + if (count > 1) { + //寰幆瓒呰繃1娆� + for (int j = 2; j <= count; j++) { + for (InsProduct insProduct : insProductes) { + InsProduct insProduct1 = new InsProduct(); + BeanUtils.copyProperties(insProduct, insProduct1); + insProduct1.setInspectionItem(j + "");//寰幆娆℃暟 + insProductess.add(insProduct1); + } + } + } + insProductService.saveBatch(insProductess); + } + else { if (!is) { switch (type) { case 1: @@ -399,7 +459,48 @@ map.put("head", PrintChina.printChina(CostStatisticsDto.class)); Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("costStatistics"); if (map1.get("look") == 1) costStatisticsDto.setCreateUser(map1.get("userId")); - map.put("body", insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"))); + IPage<CostStatisticsDto> costStatisticsDtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); + List<CostStatisticsDto> costStatisticsDtoList = costStatisticsDtoIPage.getRecords(); + for (CostStatisticsDto statisticsDto : costStatisticsDtoList) { + statisticsDto.setNum(1); + } + List<CostStatisticsDto> costStatisticsDtoList1 = deduplicateAndSumCounts(costStatisticsDtoList); + costStatisticsDtoIPage.setRecords(costStatisticsDtoList1); + map.put("body", costStatisticsDtoIPage); + return map; + } + private static List<CostStatisticsDto> deduplicateAndSumCounts(List<CostStatisticsDto> list) { + // 浣跨敤涓�涓� Map 鏉ュ瓨鏀惧凡缁忓嚭鐜拌繃鐨� inspectionItem + entrustCode + sample 鐨勭粍鍚� + Map<String, CostStatisticsDto> map = new HashMap<>(); + // 閬嶅巻鍒楄〃杩涜鍘婚噸鍜岃鏁� + for (CostStatisticsDto dto : list) { + String key = dto.getInspectionItem() + dto.getEntrustCode() + dto.getSample(); + if (map.containsKey(key)) { + // 濡傛灉宸茬粡瀛樺湪锛屽垯绱姞鏁伴噺 + CostStatisticsDto existingDto = map.get(key); + existingDto.setNum(existingDto.getNum() + dto.getNum()); + existingDto.setPrice(existingDto.getPrice().add(dto.getPrice())); + } else { + // 濡傛灉涓嶅瓨鍦紝鍒欐斁鍏� Map 涓� + map.put(key, dto); + } + } + // 灏� Map 涓殑鍊艰浆涓� List 杩斿洖 + return new ArrayList<>(map.values()); + } + + @Override + public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) { + Map<String, Object> map = new HashMap<>(); + String dates = costStatisticsDto.getDates(); + String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); + costStatisticsDto.setDates(null); + List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); + double totalPrice = costStatisticsDtos.stream() + .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞� + .mapToDouble(value -> value.getPrice().doubleValue()) + .sum(); + map.put("total", totalPrice); return map; } -- Gitblit v1.9.3