Browse Source

领料委外过期时间获取修改

master
shenzhouyu 6 months ago
parent
commit
030629f133
  1. 5
      src/main/java/com/gaotao/modules/handlingunit/dao/HandlingUnitMapper.java
  2. 10
      src/main/java/com/gaotao/modules/handlingunit/service/HandlingUnitGetIfsService.java
  3. 100
      src/main/java/com/gaotao/modules/handlingunit/service/impl/HandlingUnitGetIfsServiceImpl.java
  4. 77
      src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingReturnServiceImpl.java
  5. 90
      src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java
  6. 63
      src/main/resources/mapper/handlingunit/HandlingUnitMapper.xml
  7. 1
      src/main/resources/mapper/outsourcing/OutsourcingReturnMapper.xml

5
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<HandlingUnit> {
@ -62,4 +63,8 @@ public interface HandlingUnitMapper extends BaseMapper<HandlingUnit> {
* @date 2025/11/01
*/
void cancelReserve(@Param("site") String site, @Param("unitId") String unitId);
List<HandlingUnit> selectByUnitIds(@Param("unitIds") Set<String> unitIds,@Param("site") String site);
int updateExpiredDate(@Param("handlingUnits") List<HandlingUnit> handlingUnits);
}

10
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<String> unitIds, String site, String partNo)throws Exception;
}

100
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<HandlingUnitMapper, HandlingUnit> implements HandlingUnitGetIfsService {
@Autowired
private IfsApiIssueAndReturnService ifsApiIssueAndReturnService;
@Autowired
private HandlingUnitMapper handlingUnitMapper;
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public String getHandlingUnitGetIfs(Set<String> unitIds, String site, String partNo) throws Exception {
List<AnInventoryPartInStockVo> partInStock = ifsApiIssueAndReturnService.getAnInventoryPartInStock(site, partNo);
List<HandlingUnit> 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;
}
}

77
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<PurchaseOrderLineVo> searchOutsourcingOrdersForReturn(String searchValue, String site) throws Exception {
@ -99,7 +103,7 @@ public class OutsourcingReturnServiceImpl implements OutsourcingReturnService {
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public List<String> 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<HandlingUnit> handlingUnits = new ArrayList<>();
List<String> unitIdPrints = new ArrayList<>();
Set<String> unitIds = dto.getSelectedMaterials().stream()
Set<String> 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<MrIssueMaterialDto> selectedMaterials, String site) throws Exception{
// 校验库位
Set<String> 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", "保存成功"

90
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<String> 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<HandlingUnit> handlingUnits = new ArrayList<>();
List<String> unitIdPrints = new ArrayList<>();
Set<String> unitIds = returnDto.getSelectedMaterials().stream()
Set<String> 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<String> 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<HandlingUnit> handlingUnits = new ArrayList<>();
List<String> unitIdPrints = new ArrayList<>();
Set<String> unitIds = returnDto.getSelectedMaterials().stream()
Set<String> unitIds = newSelectMaterials.stream()
.map(WorkOrderMaterialDto::getLabelCode)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
@ -492,10 +512,10 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
Map<String, HandlingUnit> 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<AnInventoryPartInStockVo> 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());

63
src/main/resources/mapper/handlingunit/HandlingUnitMapper.xml

@ -191,5 +191,68 @@
modified_date = GETDATE()
WHERE site = #{site} AND unit_id = #{unitId}
</update>
<!-- 增加 NOLOCK 避免与上游事务更新 handling_unit 时的锁等待/死锁 -->
<select id="selectByUnitIds" resultType="com.gaotao.modules.handlingunit.entity.HandlingUnit">
SELECT
unit_id,
site,
parent_unit_id,
unit_type,
unit_type_db,
part_no,
part_desc,
qty,
batch_no,
location_id,
warehouse_id,
wdr,
availability_control_id,
status,
status_db,
freeze_flag,
merged_flag,
in_stock_flag,
created_date,
created_by,
remark,
print_count,
last_print_date
FROM handling_unit WITH (NOLOCK)
WHERE site = #{site} AND unit_id IN
<foreach collection="unitIds" item="unitId" open="(" separator="," close=")">
#{unitId}
</foreach>
</select>
<!-- 批量更新HandlingUnit的收货日期和失效日期 -->
<!-- 单条 UPDATE + CASE WHEN,避免多语句被 Druid 拦截 -->
<!-- 优化:添加 WITH (ROWLOCK) 避免锁升级导致死锁 -->
<update id="updateExpiredDate">
<if test="handlingUnits != null and handlingUnits.size() > 0">
UPDATE handling_unit WITH (ROWLOCK)
SET
receive_date = CASE
<foreach collection="handlingUnits" item="item">
<if test="item.receiveDate != null">
WHEN site = #{item.site} AND unit_id = #{item.unitId} THEN #{item.receiveDate}
</if>
</foreach>
ELSE receive_date
END,
expired_date = CASE
<foreach collection="handlingUnits" item="item">
<if test="item.expiredDate != null">
WHEN site = #{item.site} AND unit_id = #{item.unitId} THEN #{item.expiredDate}
</if>
</foreach>
ELSE expired_date
END,
modified_date = GETDATE()
WHERE
<foreach collection="handlingUnits" item="item" separator=" OR ">
(site = #{item.site} AND unit_id = #{item.unitId})
</foreach>
</if>
</update>
</mapper>

1
src/main/resources/mapper/outsourcing/OutsourcingReturnMapper.xml

@ -88,6 +88,7 @@
WHERE unit_id = #{hu.unitId}
</foreach>
</update>
<!-- 查询标签时带 NOLOCK,避免被其他事务持有排他锁时长时间阻塞 -->
<select id="selectByUnitIds" resultType="com.gaotao.modules.handlingunit.entity.HandlingUnit">
SELECT
unit_id,

Loading…
Cancel
Save