| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveInsContext(Map<String, Object> insContext, Integer currentTable, Integer currentSampleId, Integer orderId, String sonLaboratory) { |
| | | public void saveInsContext(SaveInsContextDto saveInsContextDto) { |
| | | Map<String, Object> insContext = JSON.parseObject(saveInsContextDto.getParam(), Map.class); |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | InsSample insSample = insSampleMapper.selectById(currentSampleId); |
| | | InsSample insSample = insSampleMapper.selectById(saveInsContextDto.getSampleId()); |
| | | insContext.forEach((k, v) -> { |
| | | JSONObject jo = JSON.parseObject(JSON.toJSONString(v)); |
| | | InsProduct insProduct = new InsProduct(); |
| | | insProduct.setId(Integer.parseInt(k)); |
| | | InsProduct product = insProductMapper.selectById(insProduct.getId()); |
| | | if (currentTable.equals(product.getTemplateId()) && currentSampleId.equals(product.getInsSampleId())) { |
| | | if (saveInsContextDto.getCurrentTable().equals(product.getTemplateId()) && saveInsContextDto.getSampleId().equals(product.getInsSampleId())) { |
| | | List<InsProductResult> oldResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | InsProductResult newResult = new InsProductResult(); |
| | |
| | | // 添加工时 |
| | | // 判断是否只是参与计算值, 参与计算值实际没有填写 |
| | | if (StringUtils.isNotBlank(newResult.getInsValue()) && !newResult.getInsValue().equals("[]")) { |
| | | InsProduct finalInsProduct = insProductMapper.selectById(product.getId()); |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | InsProduct finalInsProduct = insProductMapper.selectById(product.getId()); |
| | | InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId()); |
| | | this.addAuxiliary(userId, finalInsProduct, insOrder); |
| | | }); |
| | | } else { |
| | | // 判断是否是没有检验值的内容 |
| | | if (saveInsContextDto.getIsNoTestValue() != null && saveInsContextDto.getIsNoTestValue() == 1) { |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | InsProduct finalInsProduct = insProductMapper.selectById(product.getId()); |
| | | InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId()); |
| | | this.addAuxiliary(userId, finalInsProduct, insOrder); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | String sampleIdStr = insContext.keySet().stream().findFirst().orElse(null); |
| | | if (sampleIdStr != null) { |
| | | int count = insProductMapper.selectInsProductCountByOrderId(orderId); |
| | | int count = insProductMapper.selectInsProductCountByOrderId(saveInsContextDto.getOrderId()); |
| | | if (count == 0) { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | | .eq(InsOrderState::getLaboratory, sonLaboratory) |
| | | .eq(InsOrderState::getInsOrderId, saveInsContextDto.getOrderId()) |
| | | .eq(InsOrderState::getLaboratory, saveInsContextDto.getSonLaboratory()) |
| | | .set(InsOrderState::getInsState, 2)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | 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() |