| | |
| | | import com.ruoyi.basic.pojo.IfsInventoryQuantity; |
| | | import com.ruoyi.basic.pojo.StandardTemplate; |
| | | import com.ruoyi.basic.service.StandardTemplateService; |
| | | import com.ruoyi.basic.vo.IfsInventoryQuantityVO; |
| | | import com.ruoyi.common.constant.DictDataConstants; |
| | | import com.ruoyi.common.constant.InsOrderTypeConstants; |
| | | import com.ruoyi.common.constant.MenuJumpPathConstants; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<String> checkSubmitPlan(Integer orderId, String laboratory) { |
| | | public Map<String,Object> checkSubmitPlan(Integer orderId, String laboratory) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<String> collect = new ArrayList<>(); |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); |
| | | List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); |
| | |
| | | return insProduct.getInspectionItem() + "-" + insProduct.getInspectionItemSubclass(); |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | return collect; |
| | | //查询ifs拆分订单是否有已下单但是未检完的单子 |
| | | long count = 0L; |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | if(Objects.nonNull(insOrder.getIfsInventoryId())){ |
| | | IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId()); |
| | | //过滤出不合格或未提交的单子 |
| | | count = ifsInventoryQuantityMapper.selectSplitOrderList(one.getPartNo(),one.getLineNo(),one.getReleaseNo(),one.getReceiptNo(),one.getOrderNo()) |
| | | .stream() |
| | | .filter(f->(Objects.nonNull(f.getInsOrderId()) && !Objects.equals(f.getInsOrderId(),orderId)) && (Objects.isNull(f.getInsResult()) || 0==f.getInsResult())).count(); |
| | | } |
| | | map.put("errorMsg",collect); |
| | | map.put("unInsOrderCount",count); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) { |
| | | public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode,Boolean registerInsResults) { |
| | | InsOrder order = insOrderMapper.selectById(orderId); |
| | | // 1. 判断是否有重复编号, 有重复编号做提醒 |
| | | Long codeCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | |
| | | // 14.ifs移库(原材料需要进行移库操作) --> 最后执行,因为失败无法回滚 |
| | | if (ifsInventoryQuantity != null) { |
| | | // 登记检验结果 |
| | | // 判断是否有不合格, 有不合格不能移库 |
| | | // todo: ifs移库 |
| | | insReportService.isRawMaterial(order); |
| | | insReportService.isRawMaterial(order,registerInsResults,false); |
| | | |
| | | // 15 判断当前样品是否为原材料, 原材料需要进行数据分析, 判断之前10条数据同一个供应商, 同一个检验项的偏差是否超过10% |
| | | // 查询ifs信息获取获取前10个供应商一样的, 检验项一样信息 |
| | |
| | | // 添加分析数据 |
| | | addAnalysis(productList, ifsInventoryQuantity, order, sendUserAccount); |
| | | }); |
| | | |
| | | |
| | | } else { |
| | | // 修改成品状态 |
| | | // 判断是否有不合格 |
| | |
| | | .set(InsOrder::getInsResult, 0)); |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | |
| | | if (insProduct.getInspectionValueType().equals("1") && insProduct.getInsResult().equals(1)) { |
| | | List<InsProductDeviationWarningDetail> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName()); |
| | | |
| | | if (insProductAnalysisDtoList.size() < 10) { |
| | | if (CollectionUtils.isEmpty(insProductAnalysisDtoList)) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | .collect(Collectors.toList()); |
| | | |
| | | double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue()); |
| | | |
| | | double asked = isDeviationOverTenPercentByAsked(insProduct.getAsk(), insProduct.getLastValue()); |
| | | // 判断偏差是否大于10 |
| | | if (deviation > 10) { |
| | | if (deviation > 10 || asked > 10) { |
| | | // 判断之前是否添加过, 添加过不需要添加 |
| | | long count = insProductDeviationWarningService.count(Wrappers.<InsProductDeviationWarning>lambdaQuery() |
| | | .eq(InsProductDeviationWarning::getInsProductId, insProduct.getId())); |
| | |
| | | deviationWarningDetail.setSupplierName(ifsInventoryQuantity.getSupplierName()); |
| | | deviationWarningDetail.setTestValue(insProduct.getLastValue()); |
| | | deviationWarningDetail.setDetectionTime(insProduct.getCreateTime()); |
| | | deviationWarningDetail.setIsIssue(1); |
| | | deviationWarningDetail.setIsIssue(deviation > 10 ? 1 : 0); |
| | | deviationWarningDetail.setIsIssueAsked(asked > 10 ? 1 : 0); |
| | | |
| | | insProductAnalysisDtoList.add(deviationWarningDetail); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * *****计算偏差**** |
| | | * @param targetStr |
| | | * @return |
| | | */ |
| | | public static double isDeviationOverTenPercentByAsked(String asked, String targetStr) { |
| | | if(!isNumeric(asked)) return 0; |
| | | double average = Double.parseDouble(asked); |
| | | |
| | | double target = Double.parseDouble(targetStr); |
| | | double deviationPercent = Math.abs(target - average) / average * 100; |
| | | |
| | | // 保留两位小数 |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String formatted = df.format(deviationPercent); |
| | | return Double.parseDouble(formatted); |
| | | } |
| | | |
| | | /** |
| | | * ******原始记录模板复制***** |
| | | * @param orderId |
| | | * @param ids |