From 0190d769aba20a498f07290f0ec3e981dd8986d7 Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期三, 26 二月 2025 15:54:03 +0800 Subject: [PATCH] 原始模板查询排除没有引用的检验项 --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 104 insertions(+), 1 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java index ea73459..f441573 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java @@ -34,7 +34,6 @@ import com.ruoyi.common.constant.InsOrderTypeConstants; import com.ruoyi.common.core.domain.entity.Custom; import com.ruoyi.common.core.domain.entity.InformationNotification; -import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.domain.entity.User; import com.ruoyi.common.utils.*; import com.ruoyi.framework.exception.ErrorException; @@ -56,6 +55,7 @@ import com.ruoyi.system.service.InformationNotificationService; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xwpf.usermodel.*; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; import org.springframework.mock.web.MockMultipartFile; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -593,6 +593,20 @@ private void getTemplateThing(InsOrder order, List<InsProduct> insProducts) { Set<Integer> set = new HashSet<>(); + // 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴 + List<String> itemNameList = insProducts.stream().map(insProduct -> { + String itemName = ""; + if (StringUtils.isNotBlank(insProduct.getInspectionItemClass())) { + itemName += insProduct.getInspectionItemClass().trim(); + } + if (StringUtils.isNotBlank(insProduct.getInspectionItem())) { + itemName += insProduct.getInspectionItem().trim(); + } + if (StringUtils.isNotBlank(insProduct.getInspectionItemSubclass())) { + itemName += insProduct.getInspectionItemSubclass().trim(); + } + return itemName; + }).collect(Collectors.toList()); // 鏌ヨ璁㈠崟鐘舵�佸垽鏂槸鍚︽槸鏌ュ巻鍙叉ā鏉� if (order.getIsFirstSubmit() != null && order.getIsFirstSubmit().equals(1)) { InsOrderState insOrderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() @@ -614,6 +628,9 @@ if (StrUtil.isNotEmpty(thing)) { thing = GZipUtil.uncompress(thing); JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0))); + // 娓呴櫎娌℃湁鍏宠仈鐨勬楠岄」 + eliminateItem(sheet, itemNameList); + JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config"))); List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class); Map<String, Object> style = new HashMap<>(); @@ -638,6 +655,8 @@ } if (StrUtil.isNotEmpty(thing)) { JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0))); + // 娓呴櫎娌℃湁鍏宠仈鐨勬楠岄」 + eliminateItem(sheet, itemNameList); JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config"))); List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class); Map<String, Object> style = new HashMap<>(); @@ -650,6 +669,90 @@ } } + /** + * 娓呴櫎娌℃湁浣跨敤鐨勬楠岄」 + * @param sheet + * @param itemNameList + */ + private static void eliminateItem(JSONObject sheet, List<String> itemNameList) { + // 鑾峰彇鍒� 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴,濡傛灉妯℃澘閲岀殑淇℃伅璺熸帴鍙h繑鍥炵殑妫�楠岄」淇℃伅鑳藉鍖归厤鍒欏睍绀哄嚭鏉� + + // 寰幆琛屾暟鍒ゆ柇鏄惁 + JSONArray dataListJSONArray = sheet.getJSONArray("data"); + + // 娣诲姞鍧愭爣map + Map<String, String> coordinatesMap = new HashMap<>(); + + // 闇�瑕佺Щ闄ょ殑绱㈠紩 + List<Integer> deleteIndex = new ArrayList<>(); + // 寰幆鍒� + for (int r = 0; r < dataListJSONArray.size(); r++) { + JSONArray dataList = dataListJSONArray.getJSONArray(r); + // 寰幆琛� + String itemName = ""; + // 鍒ゆ柇鏄惁鏄剧ず + boolean isShow = false; + + for (int c = 0; c < dataList.size(); c++) { + // 鏌ヨ鎵规敞 + JSONObject jsonObject = dataList.getJSONObject(c); + try { + if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠岄」鍒嗙被")) { + String value = jsonObject.getString("v").trim(); + itemName += value; + // 娣诲姞鍧愭爣 + String coordinates = coordinatesJoint(r, c); + coordinatesMap.put(coordinates, value); + isShow = true; + } else if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠岄」")) { + String value = jsonObject.getString("v").trim(); + itemName += value; + // 娣诲姞鍧愭爣 + String coordinates = coordinatesJoint(r, c); + coordinatesMap.put(coordinates, value); + isShow = true; + } else if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠屽瓙椤�")) { + String value = jsonObject.getString("v").trim(); + itemName += value; + // 娣诲姞鍧愭爣 + String coordinates = coordinatesJoint(r, c); + coordinatesMap.put(coordinates, value); + isShow = true; + } + } catch (Exception e) { + // 鍒ゆ柇鏄惁鏈塵c鍚堝苟鍗曞厓鏍� + if (jsonObject != null && jsonObject.getJSONObject("mc") != null) { + // 鏌ヨ鍧愭爣杩涜娣诲姞 + String value = coordinatesMap.get(coordinatesJoint(jsonObject.getJSONObject("mc").getInteger("r"), jsonObject.getJSONObject("mc").getInteger("c"))); + if (StringUtils.isNotBlank(value) && !itemName.contains(value)) { + itemName += value; + } + } + } + } + // 鍒ゆ柇璇ヨ鍗曟槸鍚︽湁鏀规楠岄」, 娌℃湁鍓旈櫎 + if (isShow) { + if (!itemNameList.contains(itemName)) { + dataListJSONArray.remove(r); + r--; + } + } + } + } + + + /** + * 鍧愭爣鎷兼帴 + * @param r 妯潗鏍� + * @param c 绾靛潗鏍� + * @return + */ + private static String coordinatesJoint(int r, int c) { + String coordinates = ""; + coordinates = "r:" + r + ",c:" + c; + return coordinates; + } + @Override @Transactional(rollbackFor = Exception.class) public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) { -- Gitblit v1.9.3