| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.InventoryDetailDTO; |
| | | import com.ruoyi.basic.dto.StandardTreeTemplateBindingVo; |
| | | import com.ruoyi.basic.dto.TemplateInspectionItemDto; |
| | | import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; |
| | | import com.ruoyi.basic.mapper.StandardProductListMapper; |
| | | import com.ruoyi.basic.mapper.StructureItemParameterMapper; |
| | | import com.ruoyi.basic.pojo.IfsInventoryQuantity; |
| | | import com.ruoyi.basic.pojo.StandardProductList; |
| | | import com.ruoyi.basic.pojo.StandardMethod; |
| | | import com.ruoyi.basic.pojo.StructureItemParameter; |
| | | import com.ruoyi.basic.pojo.StructureTestObject; |
| | | import com.ruoyi.basic.pojo.StandardTree; |
| | | import com.ruoyi.basic.pojo.StandardTemplate; |
| | | import com.ruoyi.basic.service.StandardTemplateService; |
| | | import com.ruoyi.basic.service.StandardMethodService; |
| | | import com.ruoyi.basic.service.StandardTreeService; |
| | | import com.ruoyi.basic.utils.StandardTreePathParser; |
| | | import com.ruoyi.common.constant.InsOrderTypeConstants; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.enums.OrderType; |
| | | import com.ruoyi.common.numgen.NumberGenerator; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.api.IfsApiUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.dto.*; |
| | |
| | | import com.ruoyi.inspect.service.InsOrderStateService; |
| | | import com.ruoyi.inspect.service.InsProductService; |
| | | import com.ruoyi.inspect.service.InsSampleService; |
| | | import com.ruoyi.inspect.vo.IfsOrderVO; |
| | | import com.ruoyi.inspect.vo.InsOrderPrintingVo; |
| | | import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary; |
| | | import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService; |
| | | import com.ruoyi.inspect.vo.OrderTemplateSummaryVo; |
| | | import com.ruoyi.inspect.vo.TemplateConditionVo; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | private IfsApiUtils ifsApiUtils; |
| | | private SpotCheckQuarterItemMapper spotCheckQuarterItemMapper; |
| | | private StandardProductListMapper standardProductListMapper; |
| | | private AuxiliaryOutputWorkingHoursTemporaryService auxiliaryOutputWorkingHoursTemporaryService; |
| | | private StructureItemParameterMapper structureItemParameterMapper; |
| | | private StandardTreeService standardTreeService; |
| | | private StandardMethodService standardMethodService; |
| | | private StandardTemplateService standardTemplateService; |
| | | private InsOrderStandardTemplateMapper insOrderStandardTemplateMapper; |
| | | private InsOrderTemplateDeviceMapper insOrderTemplateDeviceMapper; |
| | | |
| | | |
| | | |
| | | //获取检验下单数据 |
| | | @Override |
| | | public IPage<SampleOrderDto> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto) { |
| | | //todo: 只看我判断全部,个人,组织的权限 |
| | | String laboratory = null; |
| | | // 判断是否是全部 |
| | | String isOrderAll = null; |
| | |
| | | spotCheckQuarterItemMapper.updateById(spotCheckQuarterItem); |
| | | } |
| | | |
| | | // 创建工时暂存 |
| | | // 缓存样品id, 编号map |
| | | // addWorkingHoursTemporary(userId, insSamples, ids, order); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 创建工时暂存 |
| | | * @param userId |
| | | * @param insSamples |
| | | * @param ids |
| | | * @param order |
| | | */ |
| | | private void addWorkingHoursTemporary(Integer userId, List<InsSample> insSamples, List<Integer> ids, InsOrder order) { |
| | | Map<Integer, String> sampleMap = insSamples.stream().collect(Collectors.toMap(InsSample::getId, InsSample::getSampleCode)); |
| | | List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .in(InsProduct::getInsSampleId, ids) |
| | | .eq(InsProduct::getState, 1)); |
| | | List<AuxiliaryOutputWorkingHoursTemporary> outputWorkingHours = insProductList.stream().map(insProduct -> { |
| | | AuxiliaryOutputWorkingHoursTemporary auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHoursTemporary(); |
| | | auxiliaryOutputWorkingHours.setInspectionItemClass(insProduct.getInspectionItemClass());//检测项分类 |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | | auxiliaryOutputWorkingHours.setSample(sampleMap.get(insProduct.getInsSampleId()));//样品编号 |
| | | auxiliaryOutputWorkingHours.setOrderId(order.getId());//订单id |
| | | auxiliaryOutputWorkingHours.setOrderNo(order.getEntrustCode());//非加班委托单号 |
| | | auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//非加班工时 |
| | | auxiliaryOutputWorkingHours.setAmount(1);//非加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : BigDecimal.ZERO).add(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : BigDecimal.ZERO));//产量工时 |
| | | auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期 |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | auxiliaryOutputWorkingHours.setPrice(insProduct.getPrice());//单价 |
| | | auxiliaryOutputWorkingHours.setSampleId(insProduct.getInsSampleId());//样品id |
| | | auxiliaryOutputWorkingHours.setInsProductId(insProduct.getId());//检验项id |
| | | |
| | | return auxiliaryOutputWorkingHours; |
| | | }).collect(Collectors.toList()); |
| | | auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours); |
| | | } |
| | | |
| | | public static String getWeek(String dayStr) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | default: |
| | | return "未知"; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 如果你使用 Java 8+,也可以用 Stream API 简化代码: |
| | | public List<StandardProductList> findMissingItemsWithStream(List<StandardProductList> standardList, |
| | | List<InsProduct> insList) { |
| | | Set<Integer> insIds = insList.stream() |
| | | .map(InsProduct::getStructureItemParameterId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | return standardList.stream() |
| | | .filter(product -> !insIds.contains(product.getStructureItemParameterId())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | }); |
| | | //是否为原材料下单 |
| | | if (insOrder.getTypeSource() != null && insOrder.getTypeSource().equals(1)) { |
| | | // 原材料下单: 委托人就是报检人, 生产单位就是供应商单位 |
| | | //原材料下单或外购成品下单 |
| | | if (Objects.nonNull(insOrder.getTypeSource())&&Objects.nonNull(insOrder.getIfsInventoryId())) { |
| | | // 委托人就是报检人, 生产单位就是供应商单位 |
| | | IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId()); |
| | | Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); |
| | | User user = userMapper.selectById(declareUserId); |
| | |
| | | upInsOrderOfState(insOrder); |
| | | |
| | | // 分配检验人 |
| | | upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "原材料"); |
| | | String sonLaboratory = insOrder.getTypeSource().equals(1)?"原材料":"成品实验室"; |
| | | upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), sonLaboratory); |
| | | |
| | | // 根据零件号判断是否是辅材 |
| | | boolean isRaw = false; |
| | | StructureTestObject productObject = insOrderMapper.selectProductByPartNo(ifsInventoryQuantity.getPartNo()); |
| | | // 查询产品 |
| | | if (productObject != null && StrUtil.isNotBlank(productObject.getObjectType()) && productObject.getObjectType().equals("1")) { |
| | | isRaw = true; |
| | | } else { |
| | | // 查询对象 |
| | | StructureTestObject testObject = insOrderMapper.selectByPartNo(ifsInventoryQuantity.getPartNo()); |
| | | if (testObject != null && StrUtil.isNotBlank(testObject.getObjectType()) && testObject.getObjectType().equals("1")) { |
| | | //是否为原材料下单 |
| | | if(insOrder.getTypeSource().equals(1)){ |
| | | // 根据零件号判断是否是辅材 |
| | | boolean isRaw = false; |
| | | StructureTestObject productObject = insOrderMapper.selectProductByPartNo(ifsInventoryQuantity.getPartNo()); |
| | | // 查询产品 |
| | | if (productObject != null && StrUtil.isNotBlank(productObject.getObjectType()) && productObject.getObjectType().equals("1")) { |
| | | isRaw = true; |
| | | } else { |
| | | // 查询对象 |
| | | StructureTestObject testObject = insOrderMapper.selectByPartNo(ifsInventoryQuantity.getPartNo()); |
| | | if (testObject != null && StrUtil.isNotBlank(testObject.getObjectType()) && testObject.getObjectType().equals("1")) { |
| | | isRaw = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (isRaw) { |
| | | // 获取当前季度的开始时间和结束时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 获取当前月份 |
| | | int month = now.getMonthValue(); |
| | | // 确定当前季度的开始月份 |
| | | int startMonth = (month - 1) / 3 * 3 + 1; |
| | | // 构造季度的开始时间 |
| | | LocalDateTime startOfQuarter = LocalDateTime.of(now.getYear(), Month.of(startMonth), 1, 0, 0); |
| | | // 计算下一个季度的开始时间 |
| | | LocalDateTime startOfNextQuarter = startOfQuarter.plusMonths(3); |
| | | // 计算当前季度的结束时间 |
| | | LocalDateTime endOfQuarter = startOfNextQuarter.minusSeconds(1); |
| | | if (isRaw) { |
| | | // 获取当前季度的开始时间和结束时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 获取当前月份 |
| | | int month = now.getMonthValue(); |
| | | // 确定当前季度的开始月份 |
| | | int startMonth = (month - 1) / 3 * 3 + 1; |
| | | // 构造季度的开始时间 |
| | | LocalDateTime startOfQuarter = LocalDateTime.of(now.getYear(), Month.of(startMonth), 1, 0, 0); |
| | | // 计算下一个季度的开始时间 |
| | | LocalDateTime startOfNextQuarter = startOfQuarter.plusMonths(3); |
| | | // 计算当前季度的结束时间 |
| | | LocalDateTime endOfQuarter = startOfNextQuarter.minusSeconds(1); |
| | | |
| | | // 根据下单的规格型号判断是否为季度首次出现 |
| | | Integer count = ifsInventoryQuantityMapper.selectIsFirst(insOrder.getPartDetail(), |
| | | ifsInventoryQuantity.getSupplierName(), |
| | | startOfNextQuarter, |
| | | endOfQuarter); |
| | | // 根据下单的规格型号判断是否为季度首次出现 |
| | | Integer count = ifsInventoryQuantityMapper.selectIsFirst(insOrder.getPartDetail(), |
| | | ifsInventoryQuantity.getSupplierName(), |
| | | startOfNextQuarter, |
| | | endOfQuarter); |
| | | |
| | | if(count == 0) { |
| | | ifsInventoryQuantity.setIsFirst(1); |
| | | ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() |
| | | .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) |
| | | .set(IfsInventoryQuantity::getIsFirst, 1)); |
| | | if (count == 0) { |
| | | ifsInventoryQuantity.setIsFirst(1); |
| | | ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() |
| | | .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) |
| | | .set(IfsInventoryQuantity::getIsFirst, 1)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return insOrder.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 新聚标准库直绑模板的下单流程:一个订单、一个样品,检验记录完全由模板标记生成。 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addNewJuInsOrder(InsPlaceOrderDto dto) { |
| | | if (dto == null || dto.getInsOrder() == null || dto.getStandardTreeId() == null) { |
| | | throw new ErrorException("下单信息或标准不能为空"); |
| | | } |
| | | StandardTree standard = standardTreeService.getById(dto.getStandardTreeId()); |
| | | if (standard == null || StringUtils.isBlank(standard.getSample()) |
| | | || standard.getSampleType() != null || standard.getModel() != null) { |
| | | throw new ErrorException("请选择标准库二级标准"); |
| | | } |
| | | List<StandardTreeTemplateBindingVo> bindings = standardTreeService.selectTemplateBindings(dto.getStandardTreeId()); |
| | | if (bindings.isEmpty()) { |
| | | throw new ErrorException("该标准尚未绑定可用的原始记录模板"); |
| | | } |
| | | Map<Integer, StandardTreeTemplateBindingVo> bindingMap = bindings.stream() |
| | | .collect(Collectors.toMap(StandardTreeTemplateBindingVo::getTemplateId, |
| | | binding -> binding, (first, ignored) -> first)); |
| | | List<OrderTemplateSelectionDto> selections = dto.getTemplateList(); |
| | | if (selections == null) { |
| | | selections = bindings.stream().map(binding -> { |
| | | OrderTemplateSelectionDto selection = new OrderTemplateSelectionDto(); |
| | | selection.setTemplateId(binding.getTemplateId()); |
| | | selection.setSort(binding.getSort()); |
| | | return selection; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | if (selections.isEmpty()) { |
| | | throw new ErrorException("请至少保留一个原始记录模板"); |
| | | } |
| | | Set<Integer> selectedTemplateIds = new HashSet<>(); |
| | | for (int index = 0; index < selections.size(); index++) { |
| | | OrderTemplateSelectionDto selection = selections.get(index); |
| | | if (selection == null || selection.getTemplateId() == null |
| | | || !bindingMap.containsKey(selection.getTemplateId())) { |
| | | throw new ErrorException("所选原始记录模板不属于当前标准"); |
| | | } |
| | | if (!selectedTemplateIds.add(selection.getTemplateId())) { |
| | | throw new ErrorException("原始记录模板不能重复选择"); |
| | | } |
| | | if (selection.getSort() == null) { |
| | | selection.setSort(index); |
| | | } |
| | | } |
| | | selections.sort(Comparator.comparing(OrderTemplateSelectionDto::getSort) |
| | | .thenComparing(OrderTemplateSelectionDto::getTemplateId)); |
| | | Map<Integer, Integer> templateSortMap = selections.stream() |
| | | .collect(Collectors.toMap(OrderTemplateSelectionDto::getTemplateId, |
| | | OrderTemplateSelectionDto::getSort)); |
| | | List<TemplateInspectionItemDto> templateItems = standardTreeService |
| | | .selectTemplateInspectionItems(dto.getStandardTreeId()).stream() |
| | | .filter(item -> selectedTemplateIds.contains(item.getTemplateId())) |
| | | .sorted(Comparator |
| | | .comparing((TemplateInspectionItemDto item) -> templateSortMap.get(item.getTemplateId())) |
| | | .thenComparing(item -> item.getTemplateRowIndex() == null |
| | | ? Integer.MAX_VALUE : item.getTemplateRowIndex())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | StandardMethod standardMethod = standardMethodService.getById(standard.getStandardMethodId()); |
| | | if (standardMethod == null || StringUtils.isBlank(standardMethod.getCode())) { |
| | | throw new ErrorException("标准编号不存在"); |
| | | } |
| | | String standardCode = standardMethod.getCode().trim(); |
| | | |
| | | InsOrder order = dto.getInsOrder(); |
| | | order.setId(null); |
| | | order.setState(0); |
| | | order.setIsExemption(0); |
| | | order.setFactory(null); |
| | | order.setLaboratory(standard.getLaboratory()); |
| | | order.setSampleType(null); |
| | | order.setSample(standardCode); |
| | | order.setPrepareUserEn(null); |
| | | order.setPrepareCode(null); |
| | | order.setRemarkEn(null); |
| | | // 新聚订单的环境条件由检验任务填写,避免下单模板或浏览器缓存带入旧值。 |
| | | order.setTemperature(null); |
| | | order.setHumidity(null); |
| | | insOrderMapper.insert(order); |
| | | |
| | | InsSample sample = new InsSample(); |
| | | sample.setInsOrderId(order.getId()); |
| | | sample.setSampleCode(dto.getSampleCode()); |
| | | sample.setFactory(null); |
| | | sample.setLaboratory(standard.getLaboratory()); |
| | | sample.setSampleType(null); |
| | | sample.setSample(standardCode); |
| | | sample.setModel(null); |
| | | sample.setQuantity(1); |
| | | sample.setStandardMethodListId(null); |
| | | insSampleMapper.insert(sample); |
| | | |
| | | int productSort = 0; |
| | | for (TemplateInspectionItemDto item : templateItems) { |
| | | InsProduct product = new InsProduct(); |
| | | product.setInsSampleId(sample.getId()); |
| | | product.setInspectionItem(item.getInspectionItem()); |
| | | product.setInspectionItemClass(""); |
| | | product.setInspectionItemSubclass(""); |
| | | product.setFactory(null); |
| | | product.setLaboratory(standard.getLaboratory()); |
| | | product.setSampleType(null); |
| | | product.setSample(standardCode); |
| | | product.setModel(null); |
| | | product.setTemplateId(item.getTemplateId()); |
| | | product.setTemplateRowIndex(item.getTemplateRowIndex()); |
| | | product.setSonLaboratory("新聚"); |
| | | product.setState(1); |
| | | product.setSort(productSort++); |
| | | insProductMapper.insert(product); |
| | | } |
| | | saveTemplateSnapshots(order.getId(), selections); |
| | | return order.getId(); |
| | | } |
| | | |
| | | private void saveTemplateSnapshots(Integer orderId, List<OrderTemplateSelectionDto> selections) { |
| | | for (OrderTemplateSelectionDto selection : selections) { |
| | | StandardTemplate template = standardTemplateService.getById(selection.getTemplateId()); |
| | | if (template == null) { |
| | | throw new ErrorException("原始记录模板不存在"); |
| | | } |
| | | InsOrderStandardTemplate snapshot = new InsOrderStandardTemplate(); |
| | | snapshot.setInsOrderId(orderId); |
| | | snapshot.setTemplateId(template.getId()); |
| | | snapshot.setName(template.getName()); |
| | | snapshot.setNumber(template.getNumber()); |
| | | snapshot.setRemark(template.getRemark()); |
| | | snapshot.setThing(template.getThing()); |
| | | snapshot.setSort(selection.getSort()); |
| | | insOrderStandardTemplateMapper.insert(snapshot); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | list = insSampleMapper.selectSampleProductListByOrderId2(id); |
| | | } |
| | | Map<String, Object> map1 = insSampleMapper.selectInsOrder(id); |
| | | List<InsSample> orderSamples = insSampleMapper.selectList( |
| | | Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getInsOrderId, id) |
| | | .select(InsSample::getSampleCode) |
| | | .orderByAsc(InsSample::getId)); |
| | | List<OrderTemplateSummaryVo> templateList = insOrderStandardTemplateMapper.selectList( |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, id) |
| | | .orderByAsc(InsOrderStandardTemplate::getSort, |
| | | InsOrderStandardTemplate::getId)) |
| | | .stream() |
| | | .map(template -> { |
| | | OrderTemplateSummaryVo summary = new OrderTemplateSummaryVo(); |
| | | summary.setTemplateId(template.getTemplateId()); |
| | | summary.setName(template.getName()); |
| | | summary.setNumber(template.getNumber()); |
| | | summary.setRemark(template.getRemark()); |
| | | summary.setSort(template.getSort()); |
| | | return summary; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | map.put("insOrder", insOrder); |
| | | map.put("sampleProduct", list); |
| | | // 样品编号直接从样品表读取,不依赖检验项目关联查询是否有结果。 |
| | | map.put("sampleCode", orderSamples.isEmpty() ? null : orderSamples.get(0).getSampleCode()); |
| | | map.put("insOrderTemplate", map1); |
| | | map.put("templateList", templateList); |
| | | return map; |
| | | } |
| | | |
| | |
| | | insOrder.setExamineTime(LocalDateTime.now()); |
| | | if (insOrder.getState() == 1) { |
| | | //审核通过才会生成委托编号 |
| | | // todo: 检验类型编号 |
| | | InsOrder order = this.getById(insOrder.getId()); |
| | | String code = ""; |
| | | switch (order.getOrderType()) { |
| | | case InsOrderTypeConstants.SPOT_CHECK: |
| | | code = "C"; |
| | | break; |
| | | case InsOrderTypeConstants.CUSTOMER_ORDERED: |
| | | code = "W"; |
| | | break; |
| | | case InsOrderTypeConstants.ENTER_THE_FACTORY: |
| | | case InsOrderTypeConstants.QUARTERLY_TEST: |
| | | code = "Y"; |
| | | break; |
| | | } |
| | | // 生成编号 |
| | | String no = numberGenerator.generateNumberWithPrefix(3, |
| | | "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), |
| | | // 委托编号按送样日期独立流水,例如:LMSY-20260909-01。 |
| | | // 历史/外部订单未填写送样日期时回退到当天,避免影响原有流程。 |
| | | LocalDate entrustDate = order.getSampleDate() == null ? LocalDate.now() : order.getSampleDate(); |
| | | String entrustCodePrefix = "LMSY-" |
| | | + entrustDate.format(DateTimeFormatter.BASIC_ISO_DATE) |
| | | + "-"; |
| | | String no = numberGenerator.generateNumberWithPrefix(2, |
| | | entrustCodePrefix, |
| | | InsOrder::getEntrustCode); |
| | | // 判断是否是季度检验, 是季度检验取消原材料季度检验下单 |
| | | if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) { |
| | |
| | | @Override |
| | | public Map<String, Object> getInsOrderAndSample(Integer id, String laboratory) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | InsOrder insOrder = insOrderMapper.selectById(id); |
| | | // InsOrder insOrder = insOrderMapper.selectById(id); |
| | | IfsOrderVO ifsOrderVO = insOrderMapper.selectOrderInfoById(id); |
| | | Map<Integer, List<Integer>> templateDeviceIds = insOrderTemplateDeviceMapper.selectList( |
| | | Wrappers.<InsOrderTemplateDevice>lambdaQuery() |
| | | .eq(InsOrderTemplateDevice::getInsOrderId, id) |
| | | .orderByAsc(InsOrderTemplateDevice::getSort, |
| | | InsOrderTemplateDevice::getId)) |
| | | .stream().collect(Collectors.groupingBy( |
| | | InsOrderTemplateDevice::getTemplateId, |
| | | LinkedHashMap::new, |
| | | Collectors.mapping(InsOrderTemplateDevice::getDeviceId, Collectors.toList()))); |
| | | List<TemplateConditionVo> templateConditions = insOrderStandardTemplateMapper.selectList( |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, id) |
| | | .select(InsOrderStandardTemplate::getTemplateId, |
| | | InsOrderStandardTemplate::getTemperature, |
| | | InsOrderStandardTemplate::getHumidity, |
| | | InsOrderStandardTemplate::getDetectionTime, |
| | | InsOrderStandardTemplate::getDetectionPlace, |
| | | InsOrderStandardTemplate::getInsResult) |
| | | .orderByAsc(InsOrderStandardTemplate::getSort, |
| | | InsOrderStandardTemplate::getId)) |
| | | .stream().map(snapshot -> { |
| | | TemplateConditionVo condition = new TemplateConditionVo(); |
| | | condition.setTemplateId(snapshot.getTemplateId()); |
| | | condition.setTemperature(snapshot.getTemperature()); |
| | | condition.setHumidity(snapshot.getHumidity()); |
| | | condition.setDetectionTime(snapshot.getDetectionTime()); |
| | | condition.setDetectionPlace(snapshot.getDetectionPlace()); |
| | | condition.setInsResult(snapshot.getInsResult()); |
| | | condition.setDeviceIds(templateDeviceIds.getOrDefault( |
| | | snapshot.getTemplateId(), Collections.emptyList())); |
| | | return condition; |
| | | }).collect(Collectors.toList()); |
| | | ifsOrderVO.setTemplateConditions(templateConditions); |
| | | List<SampleProductDto> list = insSampleMapper.getInsOrderAndSample(id, laboratory); |
| | | map.put("insOrder", insOrder); |
| | | map.put("insOrder", ifsOrderVO); |
| | | map.put("sampleProduct", list); |
| | | //查询所有记录模版去重 |
| | | List<Map<Integer, Object>> list2 = insOrderMapper.selectReportModelByOrderId(id, laboratory); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void getIfsOrder() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("LOCATION_NO","1302"); |
| | | map.put("STATE_DB","To be Inspected"); |
| | | public void getIfsOrder(Map<String, Object> map,Boolean isSplitOrder) { |
| | | List<Map<String, Object>> inventory = ifsApiUtils.getInventory(JSONUtil.toJsonStr(map)); |
| | | if(inventory.size() == 0) { |
| | | if(inventory.isEmpty()) { |
| | | return; |
| | | } |
| | | // 进行保存 |
| | |
| | | ifsInventoryQuantity.setIsSource(1); |
| | | ifsInventoryQuantity.setState(0); |
| | | |
| | | IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() |
| | | Long count = ifsInventoryQuantityMapper.selectCount(new LambdaQueryWrapper<IfsInventoryQuantity>() |
| | | .eq(IfsInventoryQuantity::getOrderNo, ifsInventoryQuantity.getOrderNo()) |
| | | .eq(IfsInventoryQuantity::getLineNo, ifsInventoryQuantity.getLineNo()) |
| | | .eq(IfsInventoryQuantity::getReleaseNo, ifsInventoryQuantity.getReleaseNo()) |
| | |
| | | .eq(IfsInventoryQuantity::getWaivDevRejNo, ifsInventoryQuantity.getWaivDevRejNo()) |
| | | .eq(IfsInventoryQuantity::getActivitySeq, ifsInventoryQuantity.getActivitySeq()) |
| | | ); |
| | | if(Objects.isNull(one)) { |
| | | |
| | | if(count == 0) { |
| | | ifsInventoryQuantity.setIsFirst(0); |
| | | // 查询产业链检测数据 |
| | | String industryChainAttrFields = IndustryChainUtils.getIndustryChainAttrFields(ifsInventoryQuantity.getOrderNo(), |
| | | ifsInventoryQuantity.getLineNo(), |
| | | ifsInventoryQuantity.getReleaseNo()); |
| | | ifsInventoryQuantity.setIndustryChain(industryChainAttrFields); |
| | | |
| | | if(isSplitOrder){ |
| | | ifsInventoryQuantity.setIsSplitOrder(1); |
| | | } |
| | | ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); |
| | | } |
| | | } |
| | |
| | | * @param id |
| | | */ |
| | | @Transactional |
| | | public void updateIfsInventoryQuantity(Integer id) { |
| | | public void updateIfsInventoryQuantity(Long id) { |
| | | ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() |
| | | .set(IfsInventoryQuantity::getIsRegister, 1) |
| | | .eq(IfsInventoryQuantity::getId, id)); |
| | |
| | | ifsInventoryQuantity.setIsCopper(1); |
| | | ifsInventoryQuantity.setIsQuarter(0); |
| | | ifsInventoryQuantity.setInspectStatus(0); |
| | | //铜材料下单默认值 |
| | | ifsInventoryQuantity.setOrderType(OrderType.RAW.getValue()); |
| | | ifsInventoryQuantity.setMaterialProp("01Cu"); |
| | | |
| | | ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived()); |
| | | ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas()); |
| | |
| | | |
| | | ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); |
| | | |
| | | |
| | | insOrder.setIfsInventoryId(ifsInventoryQuantity.getId()); |
| | | insOrder.setState(1); |
| | | |
| | | |
| | | upInsOrderOfState(insOrder); |
| | | upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "原材料"); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean updateInsOrder(InsOrderUpdateDto insOrderUpdateDto) { |
| | | InsOrder currentOrder = insOrderMapper.selectById(insOrderUpdateDto.getInsOrder().getId()); |
| | | if (currentOrder == null || !Objects.equals(currentOrder.getState(), 2)) { |
| | | throw new ErrorException("只有退回的检验单可以修改"); |
| | | } |
| | | boolean hasSelectedProduct = CollectionUtils.isNotEmpty(insOrderUpdateDto.getSampleProduct()) |
| | | && insOrderUpdateDto.getSampleProduct().stream() |
| | | .filter(sample -> CollectionUtils.isNotEmpty(sample.getInsProduct())) |
| | | .flatMap(sample -> sample.getInsProduct().stream()) |
| | | .anyMatch(product -> Objects.equals(product.getState(), 1)); |
| | | if (!hasSelectedProduct) { |
| | | throw new ErrorException("请至少选择一个检验项"); |
| | | } |
| | | |
| | | // 修改订单 |
| | | insOrderUpdateDto.getInsOrder().setState(0); |
| | | insOrderUpdateDto.getInsOrder().setTell(""); |
| | |
| | | |
| | | // 修改检验项 |
| | | for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) { |
| | | insProductService.updateBatchById(sampleProductDto.getInsProduct()); |
| | | Long sampleCount = insSampleMapper.selectCount(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getId, sampleProductDto.getId()) |
| | | .eq(InsSample::getInsOrderId, insOrderUpdateDto.getInsOrder().getId())); |
| | | if (sampleCount == 0) { |
| | | throw new ErrorException("检验样品数据异常"); |
| | | } |
| | | |
| | | insSampleService.update(Wrappers.<InsSample>lambdaUpdate() |
| | | .eq(InsSample::getId, sampleProductDto.getId()) |
| | | .set(InsSample::getSpecialStandardMethod, sampleProductDto.getSpecialStandardMethod())); |
| | | |
| | | List<InsProduct> products = sampleProductDto.getInsProduct(); |
| | | if (CollectionUtils.isEmpty(products)) { |
| | | continue; |
| | | } |
| | | |
| | | Set<Integer> productIds = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleProductDto.getId())) |
| | | .stream() |
| | | .map(InsProduct::getId) |
| | | .collect(Collectors.toSet()); |
| | | if (products.stream().anyMatch(product -> product.getId() != null && !productIds.contains(product.getId()))) { |
| | | throw new ErrorException("检验项数据异常"); |
| | | } |
| | | |
| | | List<Integer> removedIds = products.stream() |
| | | .filter(product -> product.getId() != null && !Objects.equals(product.getState(), 1)) |
| | | .map(InsProduct::getId) |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(removedIds)) { |
| | | insProductService.removeByIds(removedIds); |
| | | } |
| | | |
| | | List<InsProduct> existingProducts = products.stream() |
| | | .filter(product -> product.getId() != null && Objects.equals(product.getState(), 1)) |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(existingProducts)) { |
| | | insProductService.updateBatchById(existingProducts); |
| | | } |
| | | |
| | | List<InsProduct> newProducts = products.stream() |
| | | .filter(product -> product.getId() == null && Objects.equals(product.getState(), 1)) |
| | | .collect(Collectors.toList()); |
| | | addInsProductMethod(sampleProductDto.getId(), newProducts); |
| | | } |
| | | |
| | | return true; |
| | |
| | | return insOrderMapper.labelOrderPrinting(ids); |
| | | } |
| | | |
| | | @Override |
| | | public List<InventoryDetailDTO> labelOutsideOrderPrinting(List<Integer> ids) { |
| | | return insOrderMapper.labelOutsideOrderPrinting(ids); |
| | | } |
| | | |
| | | /** |
| | | * 根据样品id查询检验项树 |
| | | * @param insSampleId |
| | |
| | | InsProduct insProduct = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSampleId) |
| | | .last("limit 1")); |
| | | String tree = insProduct.getFactory() + " - " + |
| | | insProduct.getLaboratory() + " - " + |
| | | insProduct.getSampleType() + " - " + |
| | | insProduct.getSample() + " - " + |
| | | insProduct.getModel(); |
| | | String tree; |
| | | if (insProduct.getSampleType() == null && insProduct.getModel() == null |
| | | && StringUtils.isNotBlank(insProduct.getLaboratory()) |
| | | && StringUtils.isNotBlank(insProduct.getSample())) { |
| | | tree = StandardTreePathParser.canonical(insProduct.getLaboratory(), insProduct.getSample()); |
| | | } else { |
| | | tree = insProduct.getFactory() + " - " + |
| | | insProduct.getLaboratory() + " - " + |
| | | insProduct.getSampleType() + " - " + |
| | | insProduct.getSample() + " - " + |
| | | insProduct.getModel(); |
| | | } |
| | | // 查询标准树 |
| | | List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() |
| | | .eq(StandardProductList::getStandardMethodListId, insProduct.getStandardMethodListId()) |
| | |
| | | product.setCreateUser(null); |
| | | product.setUpdateTime(null); |
| | | product.setUpdateUser(null); |
| | | product.setSection(null); |
| | | product.setInsSampleId(omitOrderProductDto.getInsSampleId()); |
| | | if (StringUtils.isBlank(product.getCableTag())) { |
| | | product.setCableTag(null); |
| | |
| | | */ |
| | | @Override |
| | | public void rawAllInsOrderExport(SampleOrderDto sampleOrderDto, HttpServletResponse response) { |
| | | //判断全部,个人,组织的权限 |
| | | //todo:仅看我获取当前人所属实验室id |
| | | String laboratory = null; |
| | | // 判断是否是全部 |
| | | String isOrderAll = null; |
| | | if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { |
| | | isOrderAll = "1"; |
| | | sampleOrderDto.setState(null); |
| | | List<SampleOrderDto> sampleOrderDtoList = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(sampleOrderDto.getIds())) { |
| | | List<String> orderIds = StrUtil.split(sampleOrderDto.getIds(), ","); |
| | | sampleOrderDtoList = insOrderMapper.getInsOrderExportByIds(orderIds); |
| | | } else { |
| | | String laboratory = null; |
| | | // 判断是否是全部 |
| | | String isOrderAll = null; |
| | | if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { |
| | | isOrderAll = "1"; |
| | | sampleOrderDto.setState(null); |
| | | } |
| | | sampleOrderDto.setIds(null); |
| | | sampleOrderDtoList = insOrderMapper.rawAllInsOrderExport(QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); |
| | | } |
| | | List<SampleOrderDto> sampleOrderDtoList = insOrderMapper.rawAllInsOrderExport(QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); |
| | | |
| | | // 判断是否是不合格, 不合格查询不合格项 |
| | | for (SampleOrderDto orderDto : sampleOrderDtoList) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改样品型号 |
| | | * @param insSample |
| | | */ |
| | | @Override |
| | | public void updateSampleModel(InsSample insSample) { |
| | | // 判断当前订单是否生成了报告, 生成了报告不能修改单号 |
| | | Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, insSample.getInsOrderId())); |
| | | if (count > 0 ) { |
| | | throw new ErrorException("当前订单已经生成了报告不能修改编号"); |
| | | } |
| | | |
| | | insSampleService.update(Wrappers.<InsSample>lambdaUpdate() |
| | | .eq(InsSample::getId, insSample.getId()) |
| | | .set(InsSample::getModel, insSample.getModel())); |
| | | } |
| | | |
| | | /** |
| | | * 查询当前时间是否没有该检测项的抽样计划 |
| | | * @param sampleList |
| | | * @param insOrder |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result judgeNotSpotCheckOrder(List<SampleProductDto> sampleList, InsOrder insOrder) { |
| | | // todo: 下单判断抽样计划的唯一性 |
| | | if (insOrder.getQuarterItemId() != null) { |
| | | Long quarterItemCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() |
| | | .eq(InsOrder::getQuarterItemId, insOrder.getQuarterItemId()) |
| | | .notIn(InsOrder::getState, -1 ,2 ,3)); |
| | | if (quarterItemCount > 0) { |
| | | throw new ErrorException("该抽样计划已被绑定过"); |
| | | } |
| | | } |
| | | |
| | | // 判断是否是抽样检测 |
| | | if (insOrder.getOrderType().equals(InsOrderTypeConstants.SPOT_CHECK)) { |
| | | Set<String> monthMessageSet = new HashSet<>(); |
| | | Set<String> quarterMessageSet = new HashSet<>(); |
| | | Set<String> yearMessageSet = new HashSet<>(); |
| | | |
| | | String formatTime = "yyyy-MM-dd HH:mm:ss"; |
| | | // 查询当前所有样品的检验项 |
| | | for (SampleProductDto sampleProductDto : sampleList) { |
| | | List<StandardProductList> standardProductList = getProductTreeBySampleId(sampleProductDto.getId()); |
| | | |
| | | Set<Integer> insIds = sampleProductDto.getInsProduct().stream() |
| | | .map(InsProduct::getStructureItemParameterId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | List<StandardProductList> productLists = standardProductList.stream() |
| | | .filter(product -> !insIds.contains(product.getStructureItemParameterId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 查询检验项基础表, 查询是否有月度, 季度, 年度的检验项 |
| | | List<StructureItemParameter> itemParameterList = structureItemParameterMapper.selectList(Wrappers.<StructureItemParameter>lambdaQuery() |
| | | .in(StructureItemParameter::getId, productLists.stream().map(StandardProductList::getStructureItemParameterId).collect(Collectors.toList()))); |
| | | |
| | | for (StructureItemParameter item : itemParameterList) { |
| | | if (StringUtils.isNotBlank(item.getSpotCheckType())) { |
| | | switch (item.getSpotCheckType()) { |
| | | case "1": // 月度 |
| | | // 查询当月是否有该检测项的抽样计划 |
| | | // 当月开始时间 |
| | | DateTime monthStart = DateUtil.beginOfMonth(DateUtil.date()); |
| | | String monthStartTime = monthStart.toString(formatTime); |
| | | // 当月结束时间 |
| | | DateTime monthEnd = DateUtil.endOfMonth(DateUtil.date()); |
| | | String monthEndTime = monthEnd.toString(formatTime); |
| | | Integer count = insOrderMapper.selectNotSpotCheckOrder(item.getId(), monthStartTime, monthEndTime); |
| | | if (count == 0) { |
| | | String monthMessage = item.getInspectionItemClass() + |
| | | item.getInspectionItem() + |
| | | item.getInspectionItemSubclass(); |
| | | monthMessageSet.add(monthMessage); |
| | | } |
| | | break; |
| | | case "2": // 季度 |
| | | DateTime quarterStart = DateUtil.beginOfQuarter(DateUtil.date()); |
| | | String quarterStartTime = quarterStart.toString(formatTime); |
| | | // 当月结束时间 |
| | | DateTime quarterEnd = DateUtil.endOfQuarter(DateUtil.date()); |
| | | String quarterEndTime = quarterEnd.toString(formatTime); |
| | | Integer quarterCount = insOrderMapper.selectNotSpotCheckOrder(item.getId(), quarterStartTime, quarterEndTime); |
| | | if (quarterCount == 0) { |
| | | String quarterMessage = item.getInspectionItemClass() + |
| | | item.getInspectionItem() + |
| | | item.getInspectionItemSubclass(); |
| | | quarterMessageSet.add(quarterMessage); |
| | | } |
| | | |
| | | break; |
| | | case "3": // 年度 |
| | | DateTime yearStart = DateUtil.beginOfQuarter(DateUtil.date()); |
| | | String yearStartTime = yearStart.toString(formatTime); |
| | | // 当月结束时间 |
| | | DateTime yearEnd = DateUtil.endOfQuarter(DateUtil.date()); |
| | | String yearEndTime = yearEnd.toString(formatTime); |
| | | Integer yearCount = insOrderMapper.selectNotSpotCheckOrder(item.getId(), yearStartTime, yearEndTime); |
| | | if (yearCount == 0) { |
| | | String yearMessage = item.getInspectionItemClass() + |
| | | item.getInspectionItem() + |
| | | item.getInspectionItemSubclass(); |
| | | yearMessageSet.add(yearMessage); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | String message = ""; |
| | | if (CollectionUtils.isNotEmpty(monthMessageSet)) { |
| | | message += StrUtil.format("<p>检验项<span style=\"color: red\">{}</span>当月还未进行抽样检测, 请查看是否需要添加当前检验项</p>", CollUtil.join(monthMessageSet, ", ")); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(quarterMessageSet)) { |
| | | message += StrUtil.format("<p>检验项<span style=\"color: red\">{}</span>当前季度还未进行抽样检测, 请看是否需要添加当前检验项</p>", CollUtil.join(quarterMessageSet, ", ")); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(yearMessageSet)) { |
| | | message += StrUtil.format("<p>检验项<span style=\"color: red\">{}</span>今年还未进行抽样检测, 请看是否需要添加当前检验项</p>", CollUtil.join(yearMessageSet, ", ")); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(message)) { |
| | | return Result.success(false, message); |
| | | } |
| | | } |
| | | return Result.success(true); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * ifs移库操作 |
| | | * @param inventoryQuantity |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | public String moveRawMaterial(IfsInventoryQuantity inventoryQuantity) { |
| | | //查询ifs订单详情 |
| | | IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectById(inventoryQuantity.getId()); |
| | | String toLocation; |
| | | // 登记采购检验结果STD |
| | | if (one.getIsRegister().equals(0)) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("ORDER_NO", one.getOrderNo()); // 采购订单号 |
| | | map.put("LINE_NO", one.getLineNo()); // 行号 |
| | | map.put("RELEASE_NO", one.getReleaseNo()); // 下达号 |
| | | map.put("RECEIPT_NO", one.getReceiptNo()); // 接收号 |
| | | map.put("PURCH_QTY", one.getQtyToInspect()); // 要检验的采购数量 |
| | | resultList.add(map); |
| | | resultMap.put("RECORD_ID", UUID.randomUUID().toString()); |
| | | resultMap.put("SYSCODE", "LIMS"); |
| | | resultMap.put("SYSMODEL", "登记采购检验结果"); |
| | | resultMap.put("BATCH_INFO", resultList); |
| | | Result result = ifsApiUtils.getProcurementResults(JSONUtil.toJsonStr(resultMap)); |
| | | if (result.getCode() != 200) { |
| | | throw new ErrorException("IFS登记采购检验结果失败: " + result.getMessage()); |
| | | } |
| | | //如果是拆分订单,则将同一接收号的订单标记已登记校验 |
| | | if(one.getIsSplitOrder()==1){ |
| | | //查询其余拆分的订单 |
| | | List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery() |
| | | .eq(IfsInventoryQuantity::getOrderNo, one.getOrderNo()) |
| | | .eq(IfsInventoryQuantity::getPartNo, one.getPartNo()) |
| | | .eq(IfsInventoryQuantity::getLineNo, one.getLineNo()) |
| | | .eq(IfsInventoryQuantity::getReleaseNo, one.getReleaseNo()) |
| | | .eq(IfsInventoryQuantity::getReceiptNo, one.getReceiptNo()) |
| | | .eq(IfsInventoryQuantity::getIsSplitOrder, 1) |
| | | ); |
| | | if(Objects.nonNull(quantityList) && !quantityList.isEmpty()){ |
| | | //修改采购订单登记状态 |
| | | List<Long> ids = quantityList.stream().map(IfsInventoryQuantity::getId).collect(Collectors.toList()); |
| | | ifsInventoryQuantityMapper.update(null,Wrappers.<IfsInventoryQuantity>lambdaUpdate() |
| | | .set(IfsInventoryQuantity::getIsRegister,1) |
| | | .in(IfsInventoryQuantity::getId, ids) |
| | | ); |
| | | } |
| | | }else{ |
| | | this.updateIfsInventoryQuantity(one.getId()); |
| | | } |
| | | } |
| | | /** |
| | | * TODO 后续需要调用IFS的接口 移入的库位号 toLocation |
| | | */ |
| | | // 检验后移库 |
| | | //1301:原材料合格库,CP-02-001:成品库 |
| | | if(StringUtils.equals(inventoryQuantity.getOrderType(), OrderType.RAW.getValue())){ |
| | | toLocation = "1301"; |
| | | }else if(StringUtils.equals(inventoryQuantity.getOrderType(), OrderType.WG.getValue())){ |
| | | toLocation = "CP-02-001"; |
| | | }else{ |
| | | toLocation = "1301"; |
| | | } |
| | | Map<String, Object> moveResultMap = new HashMap<>(); |
| | | List<Map<String, Object>> moveResultList = new ArrayList<>(); |
| | | Map<String, Object> moveMap = new HashMap<>(); |
| | | moveMap.put("ORDER_NO", one.getOrderNo()); // 采购订单号 |
| | | moveMap.put("LINE_NO", one.getLineNo()); |
| | | moveMap.put("RELEASE_NO", one.getReleaseNo()); |
| | | moveMap.put("RECEIPT_NO", one.getReceiptNo()); |
| | | moveMap.put("PART_NO", one.getPartNo()); |
| | | moveMap.put("QTY", one.getPurQtyInStore()); |
| | | moveMap.put("LOCATION_NO", one.getLocationNo()); |
| | | moveMap.put("TO_LOCATION_NO", toLocation); |
| | | moveMap.put("LOT_BATCH_NO", one.getLotBatchNo()); |
| | | moveMap.put("SERIAL_NO", one.getSerialNo()); |
| | | moveMap.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); |
| | | moveMap.put("ENG_CHG_LEVEL", one.getEngChgLevel()); |
| | | moveMap.put("ACTIVITY_SEQ", one.getActivitySeq()); |
| | | moveResultList.add(moveMap); |
| | | moveResultMap.put("RECORD_ID", UUID.randomUUID().toString()); |
| | | moveResultMap.put("SYSCODE", "LIMS"); |
| | | moveResultMap.put("SYSMODEL", "检验后移库"); |
| | | moveResultMap.put("BATCH_INFO", moveResultList); |
| | | |
| | | Result result1 = ifsApiUtils.moveReceipt(JSONUtil.toJsonStr(moveResultMap)); |
| | | // 如果有必须为零件指定批号报错需要重新提交移库信息去指定批号 |
| | | if (result1.getCode() != 200) { |
| | | String message = result1.getMessage(); |
| | | if (message.contains("必须为零件") && message.contains("指定批号")) { |
| | | updaeBatch(one, toLocation); |
| | | } else { |
| | | throw new ErrorException("IFS检验后移库失败: " + result1.getMessage()); |
| | | } |
| | | } |
| | | return toLocation; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 先修改采购订单批次号, 后进行移库操作 |
| | | * @param one |
| | | * @param toLocation |
| | | */ |
| | | private void updaeBatch(IfsInventoryQuantity one, String toLocation) { |
| | | if (one.getIsUpdateBatch().equals(0)) { |
| | | // 先修改批次号后进行移库 |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("ORDER_NO", one.getOrderNo()); // 采购订单号 |
| | | map.put("LINE_NO", one.getLineNo()); // 行号 |
| | | map.put("RELEASE_NO", one.getReleaseNo()); // 下达号 |
| | | map.put("RECEIPT_NO", one.getReceiptNo()); // 接收号 |
| | | map.put("PART_NO", one.getPartNo()); //零件号 |
| | | map.put("CONFIGURATION_ID", one.getConfigurationId()); // 配置标识 |
| | | map.put("LOCATION_NO", one.getLocationNo()); // 库位号 |
| | | map.put("LOT_BATCH_NO", one.getLotBatchNo());// 批次号 |
| | | map.put("NEW_LOT_BATCH_NO", one.getUpdateBatchNo()); // 目标批次号 |
| | | map.put("SERIAL_NO", one.getSerialNo()); // 序列号 |
| | | map.put("ENG_CHG_LEVEL", one.getEngChgLevel()); // 版本号 |
| | | map.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); // wdr号 |
| | | map.put("ACTIVITY_SEQ", one.getActivitySeq()); // 活动序号 |
| | | map.put("QTY_TO_CHANGE", one.getQtyArrived()); // 变更数量 |
| | | resultList.add(map); |
| | | resultMap.put("RECORD_ID", UUID.randomUUID().toString()); |
| | | resultMap.put("SYSCODE", "LIMS"); |
| | | resultMap.put("SYSMODEL", "修改采购订单批次号"); |
| | | resultMap.put("BATCH_INFO", resultList); |
| | | |
| | | Result result = ifsApiUtils.updateMoveReceiptLot(JSONUtil.toJsonStr(resultMap)); |
| | | |
| | | if (result.getCode() != 200) { |
| | | throw new ErrorException("IFS修改批次号失败: " + result.getMessage()); |
| | | } |
| | | ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() |
| | | .set(IfsInventoryQuantity::getIsUpdateBatch, 1) |
| | | .eq(IfsInventoryQuantity::getId, one.getId())); |
| | | } |
| | | |
| | | Map<String, Object> moveResultMap = new HashMap<>(); |
| | | List<Map<String, Object>> moveResultList = new ArrayList<>(); |
| | | Map<String, Object> moveMap = new HashMap<>(); |
| | | moveMap.put("ORDER_NO", one.getOrderNo()); // 采购订单号 |
| | | moveMap.put("LINE_NO", one.getLineNo()); |
| | | moveMap.put("RELEASE_NO", one.getReleaseNo()); |
| | | moveMap.put("RECEIPT_NO", one.getReceiptNo()); |
| | | moveMap.put("PART_NO", one.getPartNo()); |
| | | moveMap.put("QTY", one.getQtyArrived()); |
| | | moveMap.put("LOCATION_NO", one.getLocationNo()); |
| | | moveMap.put("TO_LOCATION_NO", toLocation); |
| | | moveMap.put("LOT_BATCH_NO", one.getUpdateBatchNo()); |
| | | moveMap.put("SERIAL_NO", one.getSerialNo()); |
| | | moveMap.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); |
| | | moveMap.put("ENG_CHG_LEVEL", one.getEngChgLevel()); |
| | | moveMap.put("ACTIVITY_SEQ", one.getActivitySeq()); |
| | | moveResultList.add(moveMap); |
| | | moveResultMap.put("RECORD_ID", UUID.randomUUID().toString()); |
| | | moveResultMap.put("SYSCODE", "LIMS"); |
| | | moveResultMap.put("SYSMODEL", "检验后移库"); |
| | | moveResultMap.put("BATCH_INFO", moveResultList); |
| | | |
| | | Result result1 = ifsApiUtils.moveReceipt(JSONUtil.toJsonStr(moveResultMap)); |
| | | if (result1.getCode() != 200) { |
| | | throw new ErrorException("IFS检验后移库失败: " + result1.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |