|
|
|
@ -1,12 +1,15 @@ |
|
|
|
package com.gaotao.modules.po.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.gaotao.common.exception.XJException; |
|
|
|
import com.gaotao.common.utils.*; |
|
|
|
import com.gaotao.modules.factory.dao.AccessSiteMapper; |
|
|
|
import com.gaotao.modules.factory.dao.PartAttributeMapper; |
|
|
|
import com.gaotao.modules.factory.entity.PartAttribute; |
|
|
|
import com.gaotao.modules.factory.entity.Site; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
@ -77,6 +80,8 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
|
private com.gaotao.modules.handlingunit.service.HandlingUnitIdLogService handlingUnitIdLogService; |
|
|
|
@Autowired |
|
|
|
private LocationService locationService; |
|
|
|
@Autowired |
|
|
|
private PartAttributeMapper partAttributeMapper; |
|
|
|
|
|
|
|
@Value("${custom.ifs-url}") |
|
|
|
private String ifsUrl; |
|
|
|
@ -226,6 +231,8 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
|
if ("N".equals(inData.getNeedCheck())) { |
|
|
|
genInventoryStock(inData, transHeader, receiptDetail); |
|
|
|
} |
|
|
|
// 处理料件属性(创建或更新) |
|
|
|
handlePartAttribute(inData); |
|
|
|
// 同步到IFS |
|
|
|
syncToIFS(inData); |
|
|
|
/* Map<String, Object> weiwaiMap = isWeiwai(inData); |
|
|
|
@ -789,6 +796,60 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
|
return poReceiptDetail; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理料件属性(PartAttribute) |
|
|
|
* <p><b>业务规则:</b></p> |
|
|
|
* <ul> |
|
|
|
* <li>如果料件属性不存在,则新建,默认值:进立库=Y、常用料=Y、机械臂抓取=Y、高度=传入值</li> |
|
|
|
* <li>如果料件属性已存在且传入了高度,则只更新高度</li> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* @param inData 采购入库数据 |
|
|
|
*/ |
|
|
|
private void handlePartAttribute(TransDetailDto inData) { |
|
|
|
try { |
|
|
|
String site = inData.getSite(); |
|
|
|
String partNo = inData.getPartNo(); |
|
|
|
BigDecimal height = inData.getHeight(); |
|
|
|
|
|
|
|
log.info("开始处理料件属性,site: {}, partNo: {}, height: {}", site, partNo, height); |
|
|
|
|
|
|
|
// 检查料件属性是否已存在 |
|
|
|
PartAttribute existing = partAttributeMapper.getPartAttributeByKey(site, partNo); |
|
|
|
|
|
|
|
if (existing == null) { |
|
|
|
// 不存在则新建,设置默认值 |
|
|
|
PartAttribute partAttribute = new PartAttribute(); |
|
|
|
partAttribute.setSite(site); |
|
|
|
partAttribute.setPartNo(partNo); |
|
|
|
partAttribute.setIsInWh("Y"); // 默认进立库 |
|
|
|
partAttribute.setIsCommonlyUsed("Y"); // 默认常用料 |
|
|
|
partAttribute.setIsRobotPick("Y"); // 默认机械臂抓取 |
|
|
|
partAttribute.setHeight(height != null ? height : BigDecimal.ZERO); // 高度不能为空,默认0 |
|
|
|
|
|
|
|
partAttributeMapper.insert(partAttribute); |
|
|
|
log.info("料件属性创建成功,site: {}, partNo: {}, height: {}", site, partNo, height); |
|
|
|
} else { |
|
|
|
// 已存在且传入了高度,则只更新高度 |
|
|
|
if (height != null) { |
|
|
|
// 使用 UpdateWrapper 按照联合主键(site + partNo)更新 |
|
|
|
LambdaUpdateWrapper<PartAttribute> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
updateWrapper.eq(PartAttribute::getSite, site) |
|
|
|
.eq(PartAttribute::getPartNo, partNo) |
|
|
|
.set(PartAttribute::getHeight, height); |
|
|
|
partAttributeMapper.update(null, updateWrapper); |
|
|
|
log.info("料件属性高度更新成功,site: {}, partNo: {}, 新高度: {}", site, partNo, height); |
|
|
|
} else { |
|
|
|
log.debug("料件属性已存在且未传入高度,跳过更新,site: {}, partNo: {}", site, partNo); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
// 不抛出异常,避免影响主流程 |
|
|
|
log.error("处理料件属性失败,site: {}, partNo: {}, 错误: {}", |
|
|
|
inData.getSite(), inData.getPartNo(), e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> getPoReceiveRecords(String poNumber, String site, String warehouseId) { |
|
|
|
return poReceiptDetailService.getPoReceiveRecords(poNumber, site, warehouseId); |
|
|
|
|