fix:喷涂下件区分车架门架

This commit is contained in:
zhaoyf
2026-09-15 20:37:36 +08:00
parent fcc1ee9354
commit 1c8408c6a2
2 changed files with 165 additions and 113 deletions

View File

@@ -34,6 +34,10 @@ public class RegionConstant {
* 焊接半成品
*/
public static final String WELDING_SEMI_MATERIAL_SIDE = "6.004";
/**
* 喷涂半成品
*/
public static final String PLATING_STORE_CODE = "6.005";
/**
* 喷涂半成品

View File

@@ -23,6 +23,7 @@ import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.ext_manage.service.MesToWmsService;
import org.nl.wms.ext_manage.service.dto.*;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
import org.nl.wms.sch_manage.service.core.tasks.LineCallFullTask;
import org.nl.wms.sch_manage.service.core.tasks.LineReturnEmptyTask;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
@@ -64,6 +65,8 @@ public class MesToWmsServiceImpl implements MesToWmsService {
@Autowired
private ISchBasePointService iSchBasePointService;
@Autowired
private ISchBaseRegionService iSchBaseRegionService;
@Autowired
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
@Autowired
private IWorkOrderService workOrderService;
@@ -270,6 +273,7 @@ public class MesToWmsServiceImpl implements MesToWmsService {
entry.put("srcbillentryid", item.getItem_id());
entry.put("qty", param.getLoadQty());//喷涂线边
entrysOut.add(entry);
break;
}
}
@@ -752,9 +756,13 @@ public class MesToWmsServiceImpl implements MesToWmsService {
@Transactional
@Override
public void platingOffline(PlatingOfflineDto param) {
//喷涂下线 喷涂半成品-> 装配线边
String storCode1 = "6.005";
String storCode2 = "6.007";
//喷涂下线 车架:喷涂半成品-> 装配线边
// 门架:从喷涂领料出库
String storCode1 = RegionConstant.PLATING_STORE_CODE;
String storCode2 = RegionConstant.ASSEMBLY_LINE_STORE_CODE;
String unloadPort = param.getUnloadPort();//下件位置
String storeMapper = iSchBasePointService.getPointRegionMapperSect(unloadPort);//映射仓库
boolean isAllocate = !StringUtils.isEmpty(storeMapper);//如果有映射仓库则调拨到线边库,没有则直接出库
String orderCode = param.getOrderCode();
WorkOrderDao workOrder = workOrderService.getOne(new LambdaQueryWrapper<WorkOrderDao>()
.eq(WorkOrderDao::getOrder_code, orderCode));
@@ -837,117 +845,157 @@ public class MesToWmsServiceImpl implements MesToWmsService {
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
ioStorInvDisMapper.batchSave(iOStorInvDiss);
iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams);
BsrealStorattr storattrIn = storattrService.findByCode(storCode2);
Structattr structattrIn = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getSect_code, storCode2)
.last("limit 1"));//部装线边库
ioStorInvDtls.clear();
iOStorInvDiss.clear();
//生成入库单
IOStorInv ioStorInvIn = new IOStorInv();
ioStorInvIn.setIostorinv_id(IdUtil.getStringId());
ioStorInvIn.setBill_code(CodeUtil.getNewCode("IN_STORE_CODE"));
ioStorInvIn.setIo_type(IOSEnum.IO_TYPE.code("入库"));
ioStorInvIn.setBill_type(IOSEnum.BILL_TYPE.code("生产入库"));
ioStorInvIn.setBiz_date(DateUtil.today());
ioStorInvIn.setStor_code(storattrIn.getStor_code());
ioStorInvIn.setStor_name(storattrIn.getStor_name());
ioStorInvIn.setStor_id(storattrIn.getStor_id());
ioStorInvIn.setDetail_count(1);
ioStorInvIn.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
ioStorInvIn.setCreate_mode(IOSEnum.CREATE_MODE.code("外部接口产生"));
ioStorInvIn.setInput_optid(currentUserId);
ioStorInvIn.setInput_optname(nickName);
ioStorInvIn.setInput_time(now);
ioStorInvIn.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
ioStorInvIn.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
ioStorInvDtl = new IOStorInvDtl();
ioStorInvDtl.setIostorinv_id(ioStorInvIn.getIostorinv_id());
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
ioStorInvDtl.setSeq_no(String.valueOf(seq));
ioStorInvDtl.setMaterial_code(materialCode);
ioStorInvDtl.setMaterial_id(material.getMaterial_id());
ioStorInvDtl.setQty_unit_id(material.getQty_unit_id());
ioStorInvDtl.setQty_unit_name(material.getQty_unit_name());
ioStorInvDtl.setPcsn("1");
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
ioStorInvDtl.setAssign_qty(qty);
ioStorInvDtl.setPlan_qty(qty);
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
ioStorInvDtl.setSource_bill_code(orderCode);
ioStorInvDtl.setSource_bill_type("work_order");
ioStorInvDtls.add(ioStorInvDtl);
// 分配
ioStorInvDis = new IOStorInvDis();
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
ioStorInvDis.setIostorinv_id(ioStorInvIn.getIostorinv_id()); // 修正变量名
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
ioStorInvDis.setMaterial_id(material.getMaterial_id());
ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量
ioStorInvDis.setSect_code(storCode2);
ioStorInvDis.setStruct_code(structattrIn.getStruct_code());
ioStorInvDis.setPcsn("1");
ioStorInvDis.setStoragevehicle_code(structattrIn.getStoragevehicle_code());
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
ioStorInvDis.setQty_unit_id(material.getQty_unit_id());
ioStorInvDis.setQty_unit_name(material.getQty_unit_name());
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
ioStorInvDis.setReal_qty(qty);
iOStorInvDiss.add(ioStorInvDis);
List<AddInvParam> addInvParams = new ArrayList<>();
AddInvParam addParam = new AddInvParam();
addParam.setPcsn("1");
addParam.setMaterialCode(materialCode);
addParam.setStoragevehicleCode(structattrIn.getStoragevehicle_code());
addParam.setUnitName(material.getQty_unit_name());
addParam.setUnitId(material.getQty_unit_id());
addParam.setQty(qty);
addInvParams.add(addParam);
ioStorInvMapper.insert(ioStorInvIn);
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
ioStorInvDisMapper.batchSave(iOStorInvDiss);
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
List<InFinishParam> inFinishParams = new ArrayList<>();
InFinishParam inFinishParam = new InFinishParam();
inFinishParam.setPcsn("1");
inFinishParam.setMaterialCode(materialCode);
inFinishParam.setStoragevehicleCode(structattrIn.getStoragevehicle_code());
inFinishParam.setUnitName(material.getQty_unit_name());
inFinishParam.setUnitId(material.getQty_unit_id());
inFinishParam.setQty(qty);
inFinishParam.setSectCode(structattrIn.getSect_code());
inFinishParam.setStructCode(structattrIn.getStruct_code());
inFinishParams.add(inFinishParam);
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
if (!isAllocate){//不需要调拨
BsrealStorattr storattrIn = storattrService.findByCode(storCode2);
Structattr structattrIn = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getSect_code, storCode2)
.last("limit 1"));//部装线边库
ioStorInvDtls.clear();
iOStorInvDiss.clear();
//生成入库单
IOStorInv ioStorInvIn = new IOStorInv();
ioStorInvIn.setIostorinv_id(IdUtil.getStringId());
ioStorInvIn.setBill_code(CodeUtil.getNewCode("IN_STORE_CODE"));
ioStorInvIn.setIo_type(IOSEnum.IO_TYPE.code("入库"));
ioStorInvIn.setBill_type(IOSEnum.BILL_TYPE.code("生产入库"));
ioStorInvIn.setBiz_date(DateUtil.today());
ioStorInvIn.setStor_code(storattrIn.getStor_code());
ioStorInvIn.setStor_name(storattrIn.getStor_name());
ioStorInvIn.setStor_id(storattrIn.getStor_id());
ioStorInvIn.setDetail_count(1);
ioStorInvIn.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
ioStorInvIn.setCreate_mode(IOSEnum.CREATE_MODE.code("外部接口产生"));
ioStorInvIn.setInput_optid(currentUserId);
ioStorInvIn.setInput_optname(nickName);
ioStorInvIn.setInput_time(now);
ioStorInvIn.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
ioStorInvIn.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
ioStorInvDtl = new IOStorInvDtl();
ioStorInvDtl.setIostorinv_id(ioStorInvIn.getIostorinv_id());
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
ioStorInvDtl.setSeq_no(String.valueOf(seq));
ioStorInvDtl.setMaterial_code(materialCode);
ioStorInvDtl.setMaterial_id(material.getMaterial_id());
ioStorInvDtl.setQty_unit_id(material.getQty_unit_id());
ioStorInvDtl.setQty_unit_name(material.getQty_unit_name());
ioStorInvDtl.setPcsn("1");
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
ioStorInvDtl.setAssign_qty(qty);
ioStorInvDtl.setPlan_qty(qty);
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
ioStorInvDtl.setSource_bill_code(orderCode);
ioStorInvDtl.setSource_bill_type("work_order");
ioStorInvDtls.add(ioStorInvDtl);
// 分配
ioStorInvDis = new IOStorInvDis();
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
ioStorInvDis.setIostorinv_id(ioStorInvIn.getIostorinv_id()); // 修正变量名
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
ioStorInvDis.setMaterial_id(material.getMaterial_id());
ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量
ioStorInvDis.setSect_code(storCode2);
ioStorInvDis.setStruct_code(structattrIn.getStruct_code());
ioStorInvDis.setPcsn("1");
ioStorInvDis.setStoragevehicle_code(structattrIn.getStoragevehicle_code());
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
ioStorInvDis.setQty_unit_id(material.getQty_unit_id());
ioStorInvDis.setQty_unit_name(material.getQty_unit_name());
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
ioStorInvDis.setReal_qty(qty);
iOStorInvDiss.add(ioStorInvDis);
List<AddInvParam> addInvParams = new ArrayList<>();
AddInvParam addParam = new AddInvParam();
addParam.setPcsn("1");
addParam.setMaterialCode(materialCode);
addParam.setStoragevehicleCode(structattrIn.getStoragevehicle_code());
addParam.setUnitName(material.getQty_unit_name());
addParam.setUnitId(material.getQty_unit_id());
addParam.setQty(qty);
addInvParams.add(addParam);
ioStorInvMapper.insert(ioStorInvIn);
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
ioStorInvDisMapper.batchSave(iOStorInvDiss);
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
List<InFinishParam> inFinishParams = new ArrayList<>();
InFinishParam inFinishParam = new InFinishParam();
inFinishParam.setPcsn("1");
inFinishParam.setMaterialCode(materialCode);
inFinishParam.setStoragevehicleCode(structattrIn.getStoragevehicle_code());
inFinishParam.setUnitName(material.getQty_unit_name());
inFinishParam.setUnitId(material.getQty_unit_id());
inFinishParam.setQty(qty);
inFinishParam.setSectCode(structattrIn.getSect_code());
inFinishParam.setStructCode(structattrIn.getStruct_code());
inFinishParams.add(inFinishParam);
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
}
if (isAllocate){
JSONObject callbackData = new JSONObject();
callbackData.put("method", "DealLLDBBill");
callbackData.put("type", "WMS");
// 组装data节点
JSONObject data = new JSONObject();
data.put("issueStorageOrgUnitNo", "01.09.14");
data.put("bizTypeNo", "331"); // 业务日期
data.put("receiptStorageOrgUnitNo", "01.09.14");
data.put("billNo", orderCode); // 使用工单编号作为MES单号
JSONArray entrys = new JSONArray();
JSONObject entry = new JSONObject();
entry.put("unitNo", "PCS");
entry.put("qty", param.getUnloadQty()); // 数量
entry.put("materialNo", materialCode);
entry.put("issueWarehouseNo", storCode1);//喷涂半成品库
entry.put("receiptWarehouseNo", storCode2);//到装配半成品
entrys.add(entry);
data.put("entrys", entrys);
callbackData.put("data", data);
PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setRequest_Id(orderCode);
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
stockReturn.setCreate_time(now);
stockReturn.setRequest_data(callbackData.toString());
iPmStockReturnService.save(stockReturn);
}else {
//领料出库
JSONObject callbackOutData = new JSONObject();
callbackOutData.put("method", "DealLLCKBill");
callbackOutData.put("type", "MES");
// 组装data节点
JSONObject dataOut = new JSONObject();
dataOut.put("orgno", workOrder.getOrg_code());//库存组织
dataOut.put("billno", workOrder.getOrder_code()); // 单据编号
dataOut.put("biztype", "340");
dataOut.put("invscheme", "002");
dataOut.put("transtype", "020");
dataOut.put("biztime", LocalDate.now());
dataOut.put("cztype", "02");
JSONArray entrysOut = new JSONArray();
for (WorkOrderBomDao item : orderBomItems) {
if (Objects.equals(item.getMaterial_code(), param.getMaterialCode())){
JSONObject entry = new JSONObject();
entry.put("srcbillno", orderCode);
entry.put("srcbillid", workOrder.getOrder_id()); // 数量
entry.put("srcbillentryid", item.getItem_id());
entry.put("qty", param.getUnloadQty());
entrysOut.add(entry);
break;
}
}
dataOut.put("entrys", entrysOut);
callbackOutData.put("data", dataOut);
PmStockReturn stockReturnOut = new PmStockReturn();
stockReturnOut.setRequest_Id(orderCode);
stockReturnOut.setRequest_type(IOSEnum.BILL_TYPE.code("生产出库"));
stockReturnOut.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
stockReturnOut.setCreate_time(now);
stockReturnOut.setRequest_data(callbackOutData.toString());
iPmStockReturnService.save(stockReturnOut);
}
JSONObject callbackData = new JSONObject();
callbackData.put("method", "DealLLDBBill");
callbackData.put("type", "WMS");
// 组装data节点
JSONObject data = new JSONObject();
data.put("issueStorageOrgUnitNo", "01.09.14");
data.put("bizTypeNo", "331"); // 业务日期
data.put("receiptStorageOrgUnitNo", "01.09.14");
data.put("billNo", orderCode); // 使用工单编号作为MES单号
JSONArray entrys = new JSONArray();
JSONObject entry = new JSONObject();
entry.put("unitNo", "PCS");
entry.put("qty", param.getUnloadQty()); // 数量
entry.put("materialNo", materialCode);
entry.put("issueWarehouseNo", storCode1);//喷涂半成品库
entry.put("receiptWarehouseNo", storCode2);//到装配半成品
entrys.add(entry);
data.put("entrys", entrys);
callbackData.put("data", data);
PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setRequest_Id(orderCode);
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
stockReturn.setCreate_time(now);
stockReturn.setRequest_data(callbackData.toString());
iPmStockReturnService.save(stockReturn);
}
@Transactional