zouyu
2025-10-23 0e5bddf6084d3dfb7bcad7217d4320898416eba3
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java
@@ -1,14 +1,18 @@
package com.ruoyi.inspect.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -18,22 +22,33 @@
import com.ruoyi.basic.dto.*;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
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.properties.WechatProperty;
import com.ruoyi.common.config.WechatProperty;
import com.ruoyi.common.enums.OrderType;
import com.ruoyi.common.utils.LimsDateUtil;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.WxCpUtils;
import com.ruoyi.common.utils.api.IfsApiUtils;
import com.ruoyi.common.utils.api.MesApiUtils;
import com.ruoyi.inspect.dto.CopperInsOrderDto;
import com.ruoyi.inspect.dto.OrderSplitDTO;
import com.ruoyi.inspect.dto.RawMaterialStandardTreeDto;
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.mapper.StandardTreeMapper;
import com.ruoyi.inspect.dto.SampleProductDto;
import com.ruoyi.inspect.excel.OrderSplitExcelData;
import com.ruoyi.inspect.excel.OrderSplitExcelListener;
import com.ruoyi.inspect.mapper.InsOrderMapper;
import com.ruoyi.inspect.mapper.InsProductMapper;
import com.ruoyi.inspect.mapper.InsSampleMapper;
import com.ruoyi.inspect.mapper.InsUnqualifiedHandlerMapper;
import com.ruoyi.inspect.pojo.IfsSplitOrderRecord;
import com.ruoyi.inspect.pojo.InsOrder;
import com.ruoyi.inspect.pojo.InsReport;
import com.ruoyi.inspect.pojo.InsUnqualifiedHandler;
import com.ruoyi.inspect.service.IfsSplitOrderRecordService;
import com.ruoyi.inspect.service.InsOrderService;
import com.ruoyi.inspect.service.InsReportService;
import com.ruoyi.inspect.service.RawMaterialOrderService;
@@ -45,13 +60,18 @@
import lombok.AllArgsConstructor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -80,43 +100,31 @@
    private InsProductMapper insProductMapper;
    private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
    private IfsApiUtils ifsApiUtils;
    private IfsSplitOrderRecordService ifsSplitOrderRecordService;
    private InsUnqualifiedHandlerMapper insUnqualifiedHandlerMapper;
    @Override
    public RawMaterialStandardTreeDto selectStandardTreeListByPartNo(String partNo) {
        if (StringUtils.isBlank(partNo)) {
            throw new ErrorException("零件号丢失");
        }
    public Result selectStandardTreeListByPartNo(String partNo) {
        List<FactoryDto> factoryDtos = standardTreeMapper.selectStandardTreeListByPartNo(partNo);
        if (CollectionUtil.isEmpty(factoryDtos)) {
            throw new ErrorException("零件号为" + partNo + "的原材料没有对应的标准库配置");
            return Result.success(null, "零件号为" + partNo + "的原材料没有对应的标准库配置");
        }
        RawMaterialStandardTreeDto rawMaterialStandardTreeDto = new RawMaterialStandardTreeDto();
        Set<String> sampleTypeValues = new HashSet<>();
        for (FactoryDto factoryDto : factoryDtos) {
            for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
                for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
                    if (sampleTypeDto.getChildren().size() == 0) {
                        sampleTypeValues.add(sampleTypeDto.getValue());
                    }
                }
            }
        }
        // 批量查询所有 sampleTypeDto 的数据
        List<SampleDto> standardList = standardTreeMapper.getStandardTree3Batch(sampleTypeValues);
        Map<String, List<SampleDto>> standardTreeMap = standardList.stream().collect(Collectors.groupingBy(SampleDto::getValue));
        for (FactoryDto factoryDto : factoryDtos) {
            for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
                for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
                    List<SampleDto> standardTreeList = standardTreeMap.get(sampleTypeDto.getValue());
                    if (sampleTypeDto.getChildren().size() == 0) {
                        sampleTypeDto.getChildren().addAll(standardTreeList);
                        sampleTypeDto.setChildren(standardTreeMapper.getStandardTree3(sampleTypeDto.getValue()));
                    }
                    // 判断绑定的是否是当前零件号
                    if (sampleTypeDto.getPartNo() != null && sampleTypeDto.getPartNo().equals(partNo)) {
                        // 添加对象
                        rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                + laboratoryDto.getValue() + "-"
                        rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + " - "
                                + laboratoryDto.getValue() + " - "
                                + sampleTypeDto.getValue());
                        rawMaterialStandardTreeDto.setCode(sampleTypeDto.getCode());
                        rawMaterialStandardTreeDto.setLabel(sampleTypeDto.getLabel());
@@ -126,9 +134,9 @@
                        for (SampleDto sampleDto : sampleTypeDto.getChildren()) {
                            if (sampleDto.getPartNo() != null && sampleDto.getPartNo().equals(partNo)) {
                                // 添加对象
                                rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                        + laboratoryDto.getValue() + "-"
                                        + sampleTypeDto.getValue() + "-"
                                rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + " - "
                                        + laboratoryDto.getValue() + " - "
                                        + sampleTypeDto.getValue() + " - "
                                        + sampleDto.getValue());
                                rawMaterialStandardTreeDto.setCode(sampleDto.getCode());
                                rawMaterialStandardTreeDto.setLabel(sampleDto.getLabel());
@@ -140,16 +148,20 @@
                }
            }
        }
        return rawMaterialStandardTreeDto;
        return Result.success(rawMaterialStandardTreeDto);
    }
    @Override
    public IPage<IfsInventoryQuantity> getWarehouseSubmit(IPage<IfsInventoryQuantity> page, IfsInventoryQuantity ifsInventoryQuantity) {
        if(ifsInventoryQuantity.getIsInspect().equals(1)){
            ifsInventoryQuantity.setOrderType(OrderType.RAW.getValue());
        }
        return standardTreeMapper.selectIfsPage(page, QueryWrappers.queryWrappers(ifsInventoryQuantity));
    }
    @Override
    public IPage<IfsInventoryQuantityDto> getIfsByStateOne(IPage<IfsInventoryQuantityDto> page, IfsInventoryQuantityDto ifsInventoryQuantityDto) {
        ifsInventoryQuantityDto.setOrderType(OrderType.RAW.getValue());
        return standardTreeMapper.getIfsByStateOne(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto));
    }
@@ -160,13 +172,14 @@
     * @return
     */
    @Override
    public int inspectionReport(List<Integer> ids) {
    public int inspectionReport(List<Long> ids,String orderType) {
        Integer userId = SecurityUtils.getUserId().intValue();
        ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
                .in(IfsInventoryQuantity::getId, ids)
                .set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName())
                .set(IfsInventoryQuantity::getDeclareUserId, userId)
                .set(IfsInventoryQuantity::getIsInspect, 1)
                .set(IfsInventoryQuantity::getOrderType,orderType)
                .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now())
        );
        threadPoolTaskExecutor.execute(() -> {
@@ -203,7 +216,7 @@
     * @return
     */
    @Override
    public int revokeInspectionReport(Integer id) {
    public int revokeInspectionReport(Long id) {
        return ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
                .eq(IfsInventoryQuantity::getId, id)
                .set(IfsInventoryQuantity::getIsInspect, 0)
@@ -228,6 +241,10 @@
    @Override
    public int inspectionReportOne(IfsInventoryQuantity ifsInventoryQuantity) {
        Integer userId = SecurityUtils.getUserId().intValue();
        boolean validateValue = OrderType.validateValue(ifsInventoryQuantity.getOrderType());
        if(!validateValue){
            throw new ErrorException("报检失败,非法的销售订单分类枚举");
        }
        ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
                .eq(IfsInventoryQuantity::getId, ifsInventoryQuantity.getId())
                .set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName())
@@ -235,6 +252,7 @@
                .set(IfsInventoryQuantity::getIsInspect, 1)
                .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now())
                .set(IfsInventoryQuantity::getUpdateBatchNo, ifsInventoryQuantity.getUpdateBatchNo())
                .set(IfsInventoryQuantity::getOrderType,ifsInventoryQuantity.getOrderType())
        );
        threadPoolTaskExecutor.execute(() -> {
@@ -266,7 +284,7 @@
     * @return
     */
    @Override
    public boolean repealRawOrder(Integer ifsInventoryId) {
    public boolean repealRawOrder(Long ifsInventoryId) {
        // 查询判断是否是铜单丝
        IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId);
        if (ifsInventoryQuantity.getIsCopper() != null && ifsInventoryQuantity.getIsCopper().equals(1)) {
@@ -306,7 +324,7 @@
        String code = "Y";
        // 生成编号
        String no = numberGenerator.generateNumberWithPrefix(3,
                "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                "JCZX/NS-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                InsOrder::getEntrustCode);
        insOrderMapper.insert(insOrder); // 主表
@@ -356,7 +374,7 @@
        addAuxiliary(insOrder, ifsInventoryQuantity);
        // todo: ifs直接移库
        insReportService.isRawMaterial(insOrder);
        insReportService.isRawMaterial(insOrder,true,true);
        return insOrder.getId();
    }
@@ -386,8 +404,9 @@
        String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
        ifsInventoryQuantityDto.setBeginDeclareDate(null);
        ifsInventoryQuantityDto.setEndDeclareDate(null);
        ifsInventoryQuantityDto.setOrderType(OrderType.RAW.getValue());
        IPage<IfsInventoryQuantitySupplierDto> ifsByOver = standardTreeMapper.getIfsByOver(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
        ifsByOver.getRecords().forEach(r->r.setOrderTypeName(OrderType.getLabelByValue(r.getOrderType())));
        return ifsByOver;
    }
@@ -408,7 +427,7 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean rawOrderRelease(Integer ifsInventoryId, String partDetail) {
    public boolean rawOrderRelease(Long ifsInventoryId, String partDetail) {
        // 修改原材料数据直接为已检验
        ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>()
                .set(IfsInventoryQuantity::getState, 2)
@@ -427,7 +446,7 @@
        String code = "Y";
        // 生成编号
        String no = numberGenerator.generateNumberWithPrefix(3,
                "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                "JCZX/NS-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                InsOrder::getEntrustCode);
        insOrder.setExamineTime(LocalDateTime.now());
        insOrder.setEntrustCode(no);
@@ -450,7 +469,7 @@
        addAuxiliary(insOrder, ifsInventoryQuantity);
        // todo: ifs直接移库
        insReportService.isRawMaterial(insOrder);
        insReportService.isRawMaterial(insOrder,true,true);
        return true;
    }
@@ -462,7 +481,7 @@
     * @return
     */
    @Override
    public int notificationRawOrder(Integer ifsInventoryId) {
    public int notificationRawOrder(Long ifsInventoryId) {
        IfsInventoryQuantity ifsInventory = ifsInventoryQuantityMapper.selectById(ifsInventoryId);
        // 查询当前批次, 供应商, 零件号的原材料是否超过了20吨, 超过了20吨需要进行多次检验提醒
        List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery()
@@ -504,6 +523,9 @@
        ifsInventoryQuantity.setIsSource(0);
        ifsInventoryQuantity.setState(0);
        ifsInventoryQuantity.setIsFinish(0);
        if(!OrderType.validateValue(ifsInventoryQuantity.getOrderType())){
            throw new ErrorException("新增报检信息失败,非法的销售订单分类枚举");
        }
        ifsInventoryQuantityMapper.insert(ifsInventoryQuantity);
    }
@@ -529,7 +551,7 @@
        String code = "Y";
        // 生成编号
        String no = numberGenerator.generateNumberWithPrefix(3,
                "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                "JCZX/NS-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                InsOrder::getEntrustCode);
        insOrderMapper.insert(insOrder); // 主表
@@ -588,22 +610,19 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean concessionRelease(Integer ifsInventoryId) {
    public boolean concessionRelease(Long ifsInventoryId) {
        // 查询原材料信息
        IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId);
        if (!ifsInventoryQuantity.getInspectStatus().equals(2)) {
            throw new ErrorException("不合格的原材料才能让步放行");
        }
        // todo:需要判断oa流程是否是让步放行
        String toLocation = insReportService.moveRawMaterial(ifsInventoryQuantity);
        String toLocation = insOrderService.moveRawMaterial(ifsInventoryQuantity);
        ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>()
        return ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>()
                .set(IfsInventoryQuantity::getInspectStatus, 4)
                .set(IfsInventoryQuantity::getToLocation, toLocation)
                .eq(IfsInventoryQuantity::getId, ifsInventoryId));
        return true;
                .eq(IfsInventoryQuantity::getId, ifsInventoryId))>0;
    }
    /**
@@ -691,12 +710,19 @@
     */
    @Override
    public void rawAllExport(IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto, HttpServletResponse response) throws UnsupportedEncodingException {
        //查询导出的费用统计数据
        String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate();
        String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
        ifsInventoryQuantityDto.setBeginDeclareDate(null);
        ifsInventoryQuantityDto.setEndDeclareDate(null);
        List<IfsInventoryQuantitySupplierDto> ifsByOverList = standardTreeMapper.getIfsByOverList(QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
        // 判断是否是根据选择的导出
        List<IfsInventoryQuantitySupplierDto> ifsByOverList = new ArrayList<>();
        if (StringUtils.isNotBlank(ifsInventoryQuantityDto.getIds())) {
            List<String> ifsIds = StrUtil.split(ifsInventoryQuantityDto.getIds(), ",");
            ifsByOverList = standardTreeMapper.getIfsByIds(ifsIds);
        } else {
            String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate();
            String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
            ifsInventoryQuantityDto.setBeginDeclareDate(null);
            ifsInventoryQuantityDto.setEndDeclareDate(null);
            ifsInventoryQuantityDto.setIds(null);
            ifsByOverList = standardTreeMapper.getIfsByOverList(QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
        }
        for (IfsInventoryQuantitySupplierDto dto : ifsByOverList) {
            dto.setSendTimeString(dto.getSendTime() == null ? "" : dto.getSendTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
@@ -760,7 +786,7 @@
        String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
        ifsInventoryQuantityDto.setBeginDeclareDate(null);
        ifsInventoryQuantityDto.setEndDeclareDate(null);
        ifsInventoryQuantityDto.setOrderType(OrderType.RAW.getValue());
        return standardTreeMapper.getIfsByQuarter(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
    }
@@ -770,7 +796,7 @@
     * @return
     */
    @Override
    public boolean advancedGodown(Integer ifsInventoryId) {
    public boolean advancedGodown(Long ifsInventoryId) {
        // 查询原材料信息
        IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId);
        if (!ifsInventoryQuantity.getInspectStatus().equals(0)
@@ -779,7 +805,7 @@
        }
        // todo:需要判断oa流程是否是让步放行
        String toLocation = insReportService.moveRawMaterial(ifsInventoryQuantity);
        String toLocation = insOrderService.moveRawMaterial(ifsInventoryQuantity);
        ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>()
                .set(IfsInventoryQuantity::getInspectStatus, 1)
@@ -790,6 +816,145 @@
        return true;
    }
    @Override
    public void downloadTemplate(HttpServletResponse response) {
        response.reset();
        try{
            String fileName = "订单拆分导入模板" + ExcelTypeEnum.XLSX.getValue();
            fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
            //订单拆分导入模板文件
            InputStream inputStream = this.getClass().getResourceAsStream("/static/split_order_import_template.xlsx");
            IoUtil.copy(inputStream,response.getOutputStream());
            inputStream.close();
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("模板下载失败");
        }
    }
    @Override
    public Result importSplitOrderData(MultipartFile file,Long ifsId, HttpServletRequest request) {
        try {
            IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsId);
            OrderSplitExcelListener listener = new OrderSplitExcelListener(ifsInventoryQuantity);
            EasyExcel.read(file.getInputStream(), listener).sheet().headRowNumber(2).doRead();
            if(StringUtils.isNotBlank(listener.errorMsg)){
                return Result.fail(201,listener.errorMsg);
            }
            return Result.success(listener.getDataList());
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("导入失败:"+e.getMessage());
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
    public boolean confirmSplitOrder(OrderSplitDTO orderSplitDTO) {
        //1.查询ifs订单信息
        IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(orderSplitDTO.getIfsId());
        if(Objects.isNull(ifsInventoryQuantity)){
            throw new RuntimeException("未查询到该IFS订单信息");
        }
        //2.对接ifs采购接收更改批号接口
        //组装请求参数inAttr
        List<String> newLotBathNo = new ArrayList<>();//新批号列表
        Map<String,Object> inAttrMap = new HashMap<>();
        inAttrMap.put("RECORD_ID",UUID.randomUUID().toString());
        inAttrMap.put("SYSCODE","LIMS_NS");
        inAttrMap.put("SYSMODEL","耐丝LIMS订单拆分");
        List<Map<String,Object>> batchInfoData = new ArrayList<>();
        if(Objects.nonNull(orderSplitDTO.getSplitDetailList()) && !orderSplitDTO.getSplitDetailList().isEmpty()){
            for (OrderSplitExcelData data : orderSplitDTO.getSplitDetailList()) {
                Map<String, Object> infoMap = new HashMap<>();
                infoMap.put("ORDER_NO",ifsInventoryQuantity.getOrderNo());
                infoMap.put("LINE_NO",ifsInventoryQuantity.getLineNo());
                infoMap.put("RELEASE_NO",ifsInventoryQuantity.getReleaseNo());
                infoMap.put("RECEIPT_NO",ifsInventoryQuantity.getReceiptNo());
                infoMap.put("PART_NO",ifsInventoryQuantity.getPartNo());
                infoMap.put("CONFIGURATION_ID",ifsInventoryQuantity.getConfigurationId());
                infoMap.put("LOCATION_NO",ifsInventoryQuantity.getLocationNo());
                infoMap.put("LOT_BATCH_NO",ifsInventoryQuantity.getLotBatchNo());
                infoMap.put("NEW_LOT_BATCH_NO",data.getLotBatchNo());
                newLotBathNo.add(data.getLotBatchNo());
                infoMap.put("SERIAL_NO",ifsInventoryQuantity.getSerialNo());
                infoMap.put("ENG_CHG_LEVEL",ifsInventoryQuantity.getEngChgLevel());
                infoMap.put("WAIV_DEV_REJ_NO",ifsInventoryQuantity.getWaivDevRejNo());
                infoMap.put("ACTIVITY_SEQ",ifsInventoryQuantity.getActivitySeq());
                infoMap.put("QTY_TO_CHANGE",data.getQtyStock());
                batchInfoData.add(infoMap);
            }
        }
        inAttrMap.put("BATCH_INFO", batchInfoData);
        String inAttr = JSONObject.toJSONString(inAttrMap);
        //调用ifs接口
        Result result = ifsApiUtils.updateMoveReceiptLot(inAttr);
        if(result.getCode()!=200){
            throw new RuntimeException("IFS采购接收更改批号请求异常:"+result.getMessage());
        }
        //更新主订单的抵达采购数量
        BigDecimal purQtyInStore = orderSplitDTO.getSplitDetailList()
                .stream()
                .map(OrderSplitExcelData::getQtyStock)
                .reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
        BigDecimal newPurQtyInStore = ifsInventoryQuantity.getPurQtyInStore().subtract(purQtyInStore);
        //如果拆分后,剩余的库存数量为0,则删除批号为*的订单信息
        if(newPurQtyInStore.compareTo(BigDecimal.ZERO)==0){
            ifsInventoryQuantityMapper.deleteById(ifsInventoryQuantity.getId());
        }else{
            ifsInventoryQuantityMapper.update(null,Wrappers.<IfsInventoryQuantity>lambdaUpdate()
                    .set(IfsInventoryQuantity::getPurQtyInStore,newPurQtyInStore)
                    .set(IfsInventoryQuantity::getInvQtyInStore,newPurQtyInStore)
                    .eq(IfsInventoryQuantity::getId,ifsInventoryQuantity.getId())
            );
        }
        //ifs更改批号接口调用成功,拉取新拆分的ifs订单并报检
        Map<String, Object> map = new HashMap<>();
        map.put("LOCATION_NO","1302");
        map.put("STATE_DB","To be Inspected");
        map.put("PART_NO",ifsInventoryQuantity.getPartNo());
        map.put("ORDER_NO",ifsInventoryQuantity.getOrderNo());
        map.put("LINE_NO",ifsInventoryQuantity.getLineNo());
        map.put("RELEASE_NO",ifsInventoryQuantity.getReleaseNo());
        map.put("RECEIPT_NO",ifsInventoryQuantity.getReceiptNo());
        map.put("LOT_BATCH_NO",String.join(";",newLotBathNo));
        insOrderService.getIfsOrder(map,true);
        //查询新拆分的订单信息
        List<IfsInventoryQuantity> splitOrderList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery()
                .eq(IfsInventoryQuantity::getLocationNo, "1302")
                .eq(IfsInventoryQuantity::getStatusDb, "To be Inspected")
                .eq(IfsInventoryQuantity::getPartNo, ifsInventoryQuantity.getPartNo())
                .eq(IfsInventoryQuantity::getOrderNo, ifsInventoryQuantity.getOrderNo())
                .eq(IfsInventoryQuantity::getLineNo, ifsInventoryQuantity.getLineNo())
                .eq(IfsInventoryQuantity::getReleaseNo, ifsInventoryQuantity.getReleaseNo())
                .eq(IfsInventoryQuantity::getReceiptNo, ifsInventoryQuantity.getReceiptNo())
                .in(IfsInventoryQuantity::getLotBatchNo, newLotBathNo)
        );
        //执行报检操作
        if(Objects.nonNull(splitOrderList) && !splitOrderList.isEmpty()){
            List<Long> ids = splitOrderList.stream().map(IfsInventoryQuantity::getId).collect(Collectors.toList());
            ids.add(ifsInventoryQuantity.getId());
            this.inspectionReport(ids,OrderType.RAW.getValue());
        }
        //勾选同步到MES,保存订单拆分记录
        if(orderSplitDTO.getPushToMes()){
            List<IfsSplitOrderRecord> collect = orderSplitDTO.getSplitDetailList().stream().map(m -> {
                IfsSplitOrderRecord record = new IfsSplitOrderRecord();
                BeanUtil.copyProperties(m, record);
                record.setOrderNo(ifsInventoryQuantity.getOrderNo());
                record.setLineNo(ifsInventoryQuantity.getLineNo());
                record.setReleaseNo(ifsInventoryQuantity.getReleaseNo());
                record.setReceiptNo(ifsInventoryQuantity.getReceiptNo());
                return record;
            }).collect(Collectors.toList());
            return ifsSplitOrderRecordService.saveBatch(collect);
        }
        return false;
    }
    /**
     * 添加工时