| | |
| | | |
| | | private static final int DETECTION_REPORT = 0; |
| | | private static final int INSPECTION_REPORT = 1; |
| | | private static final String DIRECT_TEMPLATE_LABORATORY = "新聚"; |
| | | |
| | | @Resource |
| | | private InsSampleMapper insSampleMapper; |
| | |
| | | |
| | | @Override |
| | | public Map<String, Object> doInsOrder(Integer id, String laboratory) { |
| | | ensureDirectTemplateOrderState(id); |
| | | InsOrder order = insOrderMapper.selectById(id); |
| | | Map<String, Object> map = insOrderService.getInsOrderAndSample(id, laboratory); |
| | | List<SampleProductDto> list = JSON.parseArray(JSON.toJSONString(map.get("sampleProduct")), SampleProductDto.class); |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<String> collect = new ArrayList<>(); |
| | | if (isDirectTemplateOrder(orderId)) { |
| | | map.put("errorMsg", Collections.emptyList()); |
| | | List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list( |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, orderId) |
| | | .orderByAsc(InsOrderStandardTemplate::getSort, |
| | | InsOrderStandardTemplate::getId)); |
| | | for (InsOrderStandardTemplate snapshot : snapshots) { |
| | | String templateName = StringUtils.defaultIfBlank(snapshot.getName(), |
| | | "模板ID " + snapshot.getTemplateId()); |
| | | if (snapshot.getDetectionTime() == null) { |
| | | collect.add("请选择“" + templateName + "”的检测时间"); |
| | | } |
| | | if (StringUtils.isBlank(snapshot.getDetectionPlace())) { |
| | | collect.add("请填写“" + templateName + "”的检测地点"); |
| | | } |
| | | } |
| | | map.put("errorMsg", collect); |
| | | map.put("missingExportItems", getMissingTemplateExportValues(orderId)); |
| | | map.put("unInsOrderCount", 0L); |
| | | return map; |
| | |
| | | if (snapshot == null) { |
| | | throw new ErrorException("未找到当前订单的原始记录模板快照"); |
| | | } |
| | | ensureDirectTemplateOrderState(dto.getOrderId()); |
| | | List<InsProduct> products = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, dto.getSampleId()) |
| | | .eq(InsProduct::getTemplateId, dto.getTemplateId()) |
| | |
| | | .map(InsProduct::getSonLaboratory) |
| | | .filter(StringUtils::isNotBlank) |
| | | .collect(Collectors.toSet()); |
| | | if (laboratories.isEmpty() && isDirectTemplateOrder(orderId)) { |
| | | laboratories.add(DIRECT_TEMPLATE_LABORATORY); |
| | | } |
| | | if (!laboratories.isEmpty()) { |
| | | insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode, Boolean registerInsResults) { |
| | | ensureDirectTemplateOrderState(orderId); |
| | | int reportType = DETECTION_REPORT; |
| | | InsOrder order = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery() |
| | | .eq(InsOrder::getId, orderId) |
| | |
| | | if (orderId == null || laboratory == null || type == null) { |
| | | throw new ErrorException("复核参数不完整"); |
| | | } |
| | | ensureDirectTemplateOrderState(orderId); |
| | | InsOrderState currentState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | | .eq(InsOrderState::getLaboratory, laboratory) |
| | |
| | | .isNotNull(InsProduct::getTemplateRowIndex)) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 兼容修复上线前已经下发、但因没有 ins_product 而缺少任务状态的直绑模板订单。 |
| | | */ |
| | | private void ensureDirectTemplateOrderState(Integer orderId) { |
| | | if (!isDirectTemplateOrder(orderId)) { |
| | | return; |
| | | } |
| | | Long stateCount = insOrderStateMapper.selectCount(Wrappers.<InsOrderState>lambdaQuery() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | | .eq(InsOrderState::getLaboratory, DIRECT_TEMPLATE_LABORATORY)); |
| | | if (stateCount > 0) { |
| | | return; |
| | | } |
| | | InsOrderState state = new InsOrderState(); |
| | | state.setInsOrderId(orderId); |
| | | state.setLaboratory(DIRECT_TEMPLATE_LABORATORY); |
| | | state.setInsState(0); |
| | | insOrderStateMapper.insert(state); |
| | | } |
| | | |
| | | private Integer resolveInspectionUserId(Integer orderId, String laboratory) { |
| | | InsSampleUser inspector = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() |
| | | .eq(InsSampleUser::getInsSampleId, orderId) |