| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | 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() |
| | |
| | | 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<>(); |
| | |
| | | } |
| | | 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<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 清除没有使用的检验项 |
| | | * @param sheet |
| | | * @param itemNameList |
| | | */ |
| | | private static void eliminateItem(JSONObject sheet, List<String> itemNameList) { |
| | | // 获取到 检验项分类+检验项+检验子项的拼接,如果模板里的信息跟接口返回的检验项信息能够匹配则展示出来 |
| | | |
| | | // 循环行数判断是否 |
| | | 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) { |
| | | // 判断是否有mc合并单元格 |
| | | 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) { |