From 030629f1338b482bba38d751a30f53d7d5e81f57 Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Fri, 12 Dec 2025 23:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E5=A7=94=E5=A4=96=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E8=8E=B7=E5=8F=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlingunit/dao/HandlingUnitMapper.java | 5 + .../service/HandlingUnitGetIfsService.java | 10 ++ .../impl/HandlingUnitGetIfsServiceImpl.java | 100 ++++++++++++++++++ .../impl/OutsourcingReturnServiceImpl.java | 77 +++++++------- .../impl/ProductionReturnServiceImpl.java | 90 +++++++++------- .../handlingunit/HandlingUnitMapper.xml | 63 +++++++++++ .../outsourcing/OutsourcingReturnMapper.xml | 1 + 7 files changed, 268 insertions(+), 78 deletions(-) create mode 100644 src/main/java/com/gaotao/modules/handlingunit/service/HandlingUnitGetIfsService.java create mode 100644 src/main/java/com/gaotao/modules/handlingunit/service/impl/HandlingUnitGetIfsServiceImpl.java diff --git a/src/main/java/com/gaotao/modules/handlingunit/dao/HandlingUnitMapper.java b/src/main/java/com/gaotao/modules/handlingunit/dao/HandlingUnitMapper.java index 37b24b7..e726442 100644 --- a/src/main/java/com/gaotao/modules/handlingunit/dao/HandlingUnitMapper.java +++ b/src/main/java/com/gaotao/modules/handlingunit/dao/HandlingUnitMapper.java @@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Set; @Mapper public interface HandlingUnitMapper extends BaseMapper { @@ -62,4 +63,8 @@ public interface HandlingUnitMapper extends BaseMapper { * @date 2025/11/01 */ void cancelReserve(@Param("site") String site, @Param("unitId") String unitId); + + List selectByUnitIds(@Param("unitIds") Set unitIds,@Param("site") String site); + + int updateExpiredDate(@Param("handlingUnits") List handlingUnits); } diff --git a/src/main/java/com/gaotao/modules/handlingunit/service/HandlingUnitGetIfsService.java b/src/main/java/com/gaotao/modules/handlingunit/service/HandlingUnitGetIfsService.java new file mode 100644 index 0000000..705f7c8 --- /dev/null +++ b/src/main/java/com/gaotao/modules/handlingunit/service/HandlingUnitGetIfsService.java @@ -0,0 +1,10 @@ +package com.gaotao.modules.handlingunit.service; + +import com.gaotao.modules.handlingunit.entity.HandlingUnit; + +import java.util.List; +import java.util.Set; + +public interface HandlingUnitGetIfsService { + String getHandlingUnitGetIfs(Set unitIds, String site, String partNo)throws Exception; +} diff --git a/src/main/java/com/gaotao/modules/handlingunit/service/impl/HandlingUnitGetIfsServiceImpl.java b/src/main/java/com/gaotao/modules/handlingunit/service/impl/HandlingUnitGetIfsServiceImpl.java new file mode 100644 index 0000000..f8fabc3 --- /dev/null +++ b/src/main/java/com/gaotao/modules/handlingunit/service/impl/HandlingUnitGetIfsServiceImpl.java @@ -0,0 +1,100 @@ +package com.gaotao.modules.handlingunit.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gaotao.modules.api.entity.issueAndReturnVo.AnInventoryPartInStockVo; +import com.gaotao.modules.api.service.IfsApiIssueAndReturnService; +import com.gaotao.modules.handlingunit.dao.HandlingUnitMapper; +import com.gaotao.modules.handlingunit.entity.HandlingUnit; +import com.gaotao.modules.handlingunit.service.HandlingUnitGetIfsService; +import com.gaotao.modules.handlingunit.service.HandlingUnitIdLogService; +import com.gaotao.modules.handlingunit.service.HandlingUnitService; +import com.gaotao.modules.production.entity.dto.WorkOrderMaterialDto; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +@Service +public class HandlingUnitGetIfsServiceImpl extends ServiceImpl implements HandlingUnitGetIfsService { + + @Autowired + private IfsApiIssueAndReturnService ifsApiIssueAndReturnService; + @Autowired + private HandlingUnitMapper handlingUnitMapper; + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) + public String getHandlingUnitGetIfs(Set unitIds, String site, String partNo) throws Exception { + List partInStock = ifsApiIssueAndReturnService.getAnInventoryPartInStock(site, partNo); + + List handlingUnits = handlingUnitMapper.selectByUnitIds(unitIds,site); + + // 遍历handlingUnits,匹配partInStock并回写数据 + if (handlingUnits != null && partInStock != null) { + for (HandlingUnit handlingUnit : handlingUnits) { + for (AnInventoryPartInStockVo stock : partInStock) { + // 匹配条件:site=Contract && partNo=PartNo && batchNo=LotBatchNo && locationId=LocationNo && wdr=WaivDevRejNo + if (Objects.equals(handlingUnit.getSite(), stock.getContract()) && + Objects.equals(handlingUnit.getPartNo(), stock.getPartNo()) && + Objects.equals(handlingUnit.getBatchNo(), stock.getLotBatchNo()) && + Objects.equals(handlingUnit.getLocationId(), stock.getLocationNo()) && + Objects.equals(handlingUnit.getWdr(), stock.getWaivDevRejNo())) { + + // 回写ReceiptDate + if (StringUtils.hasText(stock.getReceiptDate())) { + handlingUnit.setReceiveDate(parseDate(stock.getReceiptDate())); + } + + // 回写ExpirationDate + if (StringUtils.hasText(stock.getExpirationDate())) { + handlingUnit.setExpiredDate(parseDate(stock.getExpirationDate())); + } + + // 找到匹配项后跳出内层循环 + break; + } + } + } + } + int i = handlingUnitMapper.updateExpiredDate(handlingUnits); + if (i > 0){ + return "200"; + } + return "400"; + } + + /** + * 解析日期字符串为Date对象 + * @param dateStr 日期字符串 + * @return Date对象,解析失败返回null + */ + private Date parseDate(String dateStr) { + if (!StringUtils.hasText(dateStr)) { + return null; + } + try { + // 尝试常见的日期格式 + String[] patterns = {"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ss", "yyyy/MM/dd"}; + for (String pattern : patterns) { + try { + SimpleDateFormat sdf = new SimpleDateFormat(pattern); + return sdf.parse(dateStr); + } catch (ParseException e) { + // 继续尝试下一个格式 + } + } + } catch (Exception e) { + // 解析失败返回null + } + return null; + } +} diff --git a/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingReturnServiceImpl.java b/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingReturnServiceImpl.java index 102f900..600c554 100644 --- a/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingReturnServiceImpl.java +++ b/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingReturnServiceImpl.java @@ -3,6 +3,7 @@ package com.gaotao.modules.outsourcing.service.impl; import com.gaotao.modules.api.entity.issueAndReturnVo.*; import com.gaotao.modules.api.service.IfsApiIssueAndReturnService; import com.gaotao.modules.handlingunit.entity.HandlingUnit; +import com.gaotao.modules.handlingunit.service.HandlingUnitGetIfsService; import com.gaotao.modules.handlingunit.service.HandlingUnitIdGeneratorService; import com.gaotao.modules.handlingunit.service.HandlingUnitService; import com.gaotao.modules.outsourcing.dao.OutsourcingReturnMapper; @@ -17,10 +18,11 @@ import com.gaotao.modules.trans.entity.TransCommonSubDto; import com.gaotao.modules.trans.entity.TransDetail; import com.gaotao.modules.trans.service.TransHeaderService; import com.gaotao.modules.warehouse.entity.Location; -import jakarta.transaction.Transactional; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; @@ -50,6 +52,8 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { private HandlingUnitIdGeneratorService handlingUnitIdGeneratorService; @Autowired private com.gaotao.modules.handlingunit.service.HandlingUnitIdLogService handlingUnitIdLogService; + @Autowired + private HandlingUnitGetIfsService handlingUnitGetIfsService; @Override public List searchOutsourcingOrdersForReturn(String searchValue, String site) throws Exception { @@ -99,7 +103,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { } @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public List outsourcingReturnUnissueConfirm(OutsourcingReturnDto dto) throws Exception { if (dto.getSelectedMaterials() == null || dto.getSelectedMaterials().isEmpty()) { throw new Exception("没有选择要退料的物料"); @@ -120,6 +124,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { huRequest.setHeight(material.getHeight()); huRequest.setQty(material.getIssueQty()); huRequest.setOrderNo(dto.getOutsourcingOrderNo()); + huRequest.setEngChgLevel(material.getEngChgLevel()); String unitId = createNewReturnHandlingUnits(huRequest); material.setLabelCode(unitId); newSelectMaterials.add(material); @@ -157,7 +162,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { (oldVal, newVal) -> newVal )); // 处理每个选择的物料 - for (MrIssueMaterialDto material : dto.getSelectedMaterials()) { + for (MrIssueMaterialDto material : newSelectMaterials) { // 创建退料记录详情 TransCommonSubDto subDto = new TransCommonSubDto(); subDto.setPartNo(material.getPartNo()); @@ -183,7 +188,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { //前端打印新标签并跟新HandlingUnit的库位和长度 List handlingUnits = new ArrayList<>(); List unitIdPrints = new ArrayList<>(); - Set unitIds = dto.getSelectedMaterials().stream() + Set unitIds = newSelectMaterials.stream() .map(MrIssueMaterialDto::getLabelCode) .filter(Objects::nonNull) .collect(Collectors.toSet()); @@ -245,10 +250,25 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { reserveComponentDto.setIfsQty(dto.getAllQty()); // 退料 String s = ifsApiIssueAndReturnService.addPurchaseOrderUnIssueComponent(reserveComponentDto); } + try { + String getIfs = handlingUnitGetIfsService.getHandlingUnitGetIfs(unitIds, dto.getSite(), dto.getComponentPartNo()); + } catch (Exception ex) { + log.error("委外退料更新IFS过期日期异常, unitIds:{}, site:{}, partNo:{}", unitIds, dto.getSite(), dto.getComponentPartNo(), ex); + for (HandlingUnit un : handlingUnits) { + handlingUnitIdLogService.logUnitIdGeneration( + un.getUnitId(), un.getSite(), "OUTRE_CREATE", "", + "", un.getPartNo(), un.getBatchNo(), + un.getQty().doubleValue(), "SYSTEM", + "N", "过期日期更新异常:" + ex.getMessage() + ); + } + } return unitIdPrints; } + + public boolean validateLocal(List selectedMaterials, String site) throws Exception{ // 校验库位 Set unitIds = selectedMaterials.stream() @@ -297,37 +317,15 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { String newUmId = request.getUmid() == null?"":request.getUmid(); String newEngChgLevel = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'-'HH.mm.ss"); - if(onunit == null){ - partInStock = ifsApiIssueAndReturnService.getAnInventoryPartInStock(request.getSite(), request.getPartNo()); - if(partInStock == null || partInStock.size() == 0){ - //throw new Exception("无法获取物料信息"); - //todo 目前一些物料没有入库信息,所以使用当前时间作为入库时间 - newReceiveDate = new Date(); - newManufactureDate = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - calendar.add(Calendar.YEAR, 2); - Date datePlusTwoYears = calendar.getTime(); - newExpireData = datePlusTwoYears; - newEngChgLevel = "1"; - }else{ - for(AnInventoryPartInStockVo vo:partInStock){ - if(vo.getContract().equals(request.getSite()) && vo.getPartNo().equals(request.getPartNo()) && vo.getLotBatchNo().equals(request.getBatchNo()) && vo.getLocationNo().equals(request.getLocationId())){ - newReceiveDate = sdf.parse(vo.getReceiptDate()); - newManufactureDate = sdf.parse(vo.getReceiptDate()); - newExpireData = sdf.parse(vo.getExpirationDate()); - newEngChgLevel = vo.getEngChgLevel(); - } - } - } - }else{ - newReceiveDate = onunit.getReceiveDate(); - newManufactureDate = onunit.getManufactureDate(); - newExpireData = onunit.getExpiredDate(); - newUmId = onunit.getUmId(); - newEngChgLevel = onunit.getEngChgLevel() != null ? onunit.getEngChgLevel() : "1"; - } + //todo 目前一些物料没有入库信息,所以使用当前时间作为入库时间 + newReceiveDate = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.YEAR, 1); + Date datePlusTwoYears = calendar.getTime(); + newExpireData = datePlusTwoYears; + newEngChgLevel = request.getEngChgLevel() == null?"1":request.getEngChgLevel(); // 生成处理单元ID String unitId = handlingUnitIdGeneratorService.generateUnitId(request.getSite()); @@ -336,7 +334,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { handlingUnitIdLogService.logUnitIdGeneration( unitId, request.getSite(), - "IFS_INIT", + "OUTRE_CREATE", "", "", request.getPartNo(), @@ -368,7 +366,8 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { handlingUnit.setInStockFlag("N"); handlingUnit.setCreatedDate(new Date()); handlingUnit.setCreatedBy("SYSTEM"); - handlingUnit.setSourceType("IFS_INIT"); + handlingUnit.setRemark("委外退料创建"); + handlingUnit.setSourceType("OUTRE_CREATE"); handlingUnit.setOriginalQty(request.getQty()); // 使用计算后的数量 handlingUnit.setReceiveDate(newReceiveDate); handlingUnit.setHeight(request.getHeight()); @@ -408,7 +407,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { if (!saveResult) { log.error("严重错误:HandlingUnit保存返回失败!unitId={}", unitId); handlingUnitIdLogService.logUnitIdGeneration( - unitId, request.getSite(), "IFS_INIT", "", + unitId, request.getSite(), "OUTRE_CREATE", "", "", request.getPartNo(), request.getBatchNo(), request.getQty().doubleValue(), "SYSTEM", "N", "保存失败-save返回false" @@ -422,7 +421,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { log.error("严重错误:HandlingUnit保存验证失败!unitId={}", unitId); // 更新日志为失败 handlingUnitIdLogService.logUnitIdGeneration( - unitId, request.getSite(), "IFS_INIT", "", + unitId, request.getSite(), "OUTRE_CREATE", "", "", request.getPartNo(), request.getBatchNo(), request.getQty().doubleValue(), "SYSTEM", "N", "保存失败-验证未通过" @@ -432,7 +431,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService { // 更新日志为成功 handlingUnitIdLogService.logUnitIdGeneration( - unitId, request.getSite(), "IFS_INIT", "", + unitId, request.getSite(), "OUTRE_CREATE", "", "", request.getPartNo(), request.getBatchNo(), request.getQty().doubleValue(), "SYSTEM", "Y", "保存成功" diff --git a/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java b/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java index 8b3615f..d31d883 100644 --- a/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java +++ b/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java @@ -13,6 +13,7 @@ import com.gaotao.modules.api.entity.issueAndReturnVo.UnissueShopOrderDto; import com.gaotao.modules.api.service.IfsApiIssueAndReturnService; import com.gaotao.modules.base.entity.WmsLabel; import com.gaotao.modules.handlingunit.entity.HandlingUnit; +import com.gaotao.modules.handlingunit.service.HandlingUnitGetIfsService; import com.gaotao.modules.handlingunit.service.HandlingUnitIdGeneratorService; import com.gaotao.modules.handlingunit.service.HandlingUnitService; import com.gaotao.modules.notify.entity.UnissueNotifyHeader; @@ -77,6 +78,8 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { private HandlingUnitIdGeneratorService handlingUnitIdGeneratorService; @Autowired private com.gaotao.modules.handlingunit.service.HandlingUnitIdLogService handlingUnitIdLogService; + @Autowired + private HandlingUnitGetIfsService handlingUnitGetIfsService; /** * 获取当前用户的域控账号,如果开启了域控账号则获取用户的域控账号,否则使用配置的默认值 @@ -174,7 +177,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { } @Override - @Transactional + @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class) public List productionReturnConfirm(DirectUnissueDto returnDto) throws Exception{ // 验证工单状态 if (!validateWorkOrderStatus(returnDto.getWorkOrderNo(), returnDto.getSite())) { @@ -196,6 +199,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { huRequest.setQty(material.getIssueQty()); huRequest.setOrderNo(returnDto.getWorkOrderNo()); huRequest.setUmid(returnDto.getUmId()); + huRequest.setEngChgLevel(material.getEngChgLevel()); String unitId = createNewReturnHandlingUnits(huRequest); material.setLabelCode(unitId); newSelectMaterials.add(material); @@ -260,7 +264,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { //前端打印新标签并跟新HandlingUnit的库位和长度 List handlingUnits = new ArrayList<>(); List unitIdPrints = new ArrayList<>(); - Set unitIds = returnDto.getSelectedMaterials().stream() + Set unitIds = newSelectMaterials.stream() .map(WorkOrderMaterialDto::getLabelCode) .filter(Objects::nonNull) .collect(Collectors.toSet()); @@ -324,6 +328,21 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { unissueShopOrderDto.setIfsHandlingUnitID("0"); ifsApiIssueAndReturnService.addShopOrderManualUnIssue(unissueShopOrderDto); } + + try { + String getIfs = handlingUnitGetIfsService.getHandlingUnitGetIfs(unitIds, returnDto.getSite(), returnDto.getComponentPartNo()); + } catch (Exception ex) { + log.error("更新IFS过期日期异常, unitIds:{}, site:{}, partNo:{}", unitIds, returnDto.getSite(), returnDto.getComponentPartNo(), ex); + for (HandlingUnit un : handlingUnits) { + handlingUnitIdLogService.logUnitIdGeneration( + un.getUnitId(), un.getSite(), "IFS_INIT", "", + "", un.getPartNo(), un.getBatchNo(), + un.getQty().doubleValue(), "SYSTEM", + "N", "过期日期更新异常:" + ex.getMessage() + ); + } + } + return unitIdPrints; } @@ -377,7 +396,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { } @Override - @Transactional + @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class) public List productionReturnUnissueConfirm(DirectUnissueDto returnDto) throws Exception{ // 验证工单状态 if (!validateWorkOrderStatus(returnDto.getWorkOrderNo(), returnDto.getSite())) { @@ -401,6 +420,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { huRequest.setQty(material.getIssueQty()); huRequest.setOrderNo(returnDto.getWorkOrderNo()); huRequest.setUmid(returnDto.getUmId()); + huRequest.setEngChgLevel(material.getEngChgLevel()); String unitId = createNewReturnHandlingUnits(huRequest); material.setLabelCode(unitId); newSelectMaterials.add(material); @@ -439,7 +459,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { (oldVal, newVal) -> newVal )); // 处理每个选择的物料 - for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { + for (WorkOrderMaterialDto material : newSelectMaterials) { // 验证物料匹配 /*if (!material.getPartNo().equals(labelInfo.getPartNo())) { throw new XJException("扫描的物料[" + labelInfo.getPartNo() + "]与选择的物料[" + material.getPartNo() + "]不匹配"); @@ -481,7 +501,7 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { List handlingUnits = new ArrayList<>(); List unitIdPrints = new ArrayList<>(); - Set unitIds = returnDto.getSelectedMaterials().stream() + Set unitIds = newSelectMaterials.stream() .map(WorkOrderMaterialDto::getLabelCode) .filter(Objects::nonNull) .collect(Collectors.toSet()); @@ -492,10 +512,10 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { Map huMap = huList.stream() .collect(Collectors.toMap(HandlingUnit::getUnitId, hu -> hu, (existing, replacement) -> existing)); - for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { + for (WorkOrderMaterialDto material : newSelectMaterials) { HandlingUnit hu = new HandlingUnit(); hu.setUnitId(material.getLabelCode()); - hu.setWarehouseId(material.getWarehouseId()); + hu.setLocationId(material.getLocationId()); String targetWarehouseId = locationWarehouseMap.get(material.getLocationId()); if (targetWarehouseId != null) { hu.setWarehouseId(targetWarehouseId); @@ -551,6 +571,20 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { ifsApiIssueAndReturnService.addShopOrderManualUnIssue(unissueShopOrderDto); } + try { + String getIfs = handlingUnitGetIfsService.getHandlingUnitGetIfs(unitIds, returnDto.getSite(), returnDto.getComponentPartNo()); + } catch (Exception ex) { + log.error("更新IFS过期日期异常, unitIds:{}, site:{}, partNo:{}", unitIds, returnDto.getSite(), returnDto.getComponentPartNo(), ex); + for (HandlingUnit un : handlingUnits) { + handlingUnitIdLogService.logUnitIdGeneration( + un.getUnitId(), un.getSite(), "IFS_INIT", "", + "", un.getPartNo(), un.getBatchNo(), + un.getQty().doubleValue(), "SYSTEM", + "N", "过期日期更新异常:" + ex.getMessage() + ); + } + } + return unitIdPrints; } @@ -564,7 +598,6 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { } // 1. 先创建packageCount个完整HU - HandlingUnit onunit = productionReturnMapper.getOneHandlingUnit(request); List partInStock = null; Date newReceiveDate = null; Date newManufactureDate = null; @@ -572,37 +605,15 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { String newUmId = request.getUmid() == null?"":request.getUmid(); String newEngChgLevel = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'-'HH.mm.ss"); - if(onunit == null){ - partInStock = ifsApiIssueAndReturnService.getAnInventoryPartInStock(request.getSite(), request.getPartNo()); - if(partInStock == null || partInStock.size() == 0){ - //throw new Exception("无法获取物料信息"); - //todo 目前一些物料没有入库信息,所以使用当前时间作为入库时间 - newReceiveDate = new Date(); - newManufactureDate = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - calendar.add(Calendar.YEAR, 2); - Date datePlusTwoYears = calendar.getTime(); - newExpireData = datePlusTwoYears; - newEngChgLevel = "1"; - }else{ - for(AnInventoryPartInStockVo vo:partInStock){ - if(vo.getContract().equals(request.getSite()) && vo.getPartNo().equals(request.getPartNo()) && vo.getLotBatchNo().equals(request.getBatchNo()) && vo.getLocationNo().equals(request.getLocationId())){ - newReceiveDate = sdf.parse(vo.getReceiptDate()); - newManufactureDate = sdf.parse(vo.getReceiptDate()); - newExpireData = sdf.parse(vo.getExpirationDate()); - newEngChgLevel = vo.getEngChgLevel(); - } - } - } - }else{ - newReceiveDate = onunit.getReceiveDate(); - newManufactureDate = onunit.getManufactureDate(); - newExpireData = onunit.getExpiredDate(); - newUmId = onunit.getUmId(); - newEngChgLevel = onunit.getEngChgLevel() != null ? onunit.getEngChgLevel() : "1"; - } + //目前一些物料没有入库信息,所以使用当前时间作为入库时间,后续查ifs更新 + newReceiveDate = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.YEAR, 1); + Date datePlusTwoYears = calendar.getTime(); + newExpireData = datePlusTwoYears; + newEngChgLevel = request.getEngChgLevel() == null ? "1" : request.getEngChgLevel(); // 生成处理单元ID String unitId = handlingUnitIdGeneratorService.generateUnitId(request.getSite()); @@ -643,7 +654,8 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { handlingUnit.setInStockFlag("N"); handlingUnit.setCreatedDate(new Date()); handlingUnit.setCreatedBy("SYSTEM"); - handlingUnit.setSourceType("IFS_INIT"); + handlingUnit.setSourceType("PRORE_CREATE"); + handlingUnit.setRemark("生产退料"); handlingUnit.setOriginalQty(request.getQty()); // 使用计算后的数量 handlingUnit.setReceiveDate(newReceiveDate); handlingUnit.setHeight(request.getHeight()); diff --git a/src/main/resources/mapper/handlingunit/HandlingUnitMapper.xml b/src/main/resources/mapper/handlingunit/HandlingUnitMapper.xml index 9117644..0079f61 100644 --- a/src/main/resources/mapper/handlingunit/HandlingUnitMapper.xml +++ b/src/main/resources/mapper/handlingunit/HandlingUnitMapper.xml @@ -191,5 +191,68 @@ modified_date = GETDATE() WHERE site = #{site} AND unit_id = #{unitId} + + + + + + + + + UPDATE handling_unit WITH (ROWLOCK) + SET + receive_date = CASE + + + WHEN site = #{item.site} AND unit_id = #{item.unitId} THEN #{item.receiveDate} + + + ELSE receive_date + END, + expired_date = CASE + + + WHEN site = #{item.site} AND unit_id = #{item.unitId} THEN #{item.expiredDate} + + + ELSE expired_date + END, + modified_date = GETDATE() + WHERE + + (site = #{item.site} AND unit_id = #{item.unitId}) + + + diff --git a/src/main/resources/mapper/outsourcing/OutsourcingReturnMapper.xml b/src/main/resources/mapper/outsourcing/OutsourcingReturnMapper.xml index a0d3ed0..595f4c6 100644 --- a/src/main/resources/mapper/outsourcing/OutsourcingReturnMapper.xml +++ b/src/main/resources/mapper/outsourcing/OutsourcingReturnMapper.xml @@ -88,6 +88,7 @@ WHERE unit_id = #{hu.unitId} +