add:物料打印;手工组盘入库支持无工单入库

This commit is contained in:
zhaoyf
2026-09-10 19:48:30 +08:00
parent dae0fae8db
commit c8e2a6d8ba
2 changed files with 177 additions and 34 deletions

View File

@@ -82,6 +82,9 @@ public class InboundPdaServiceImpl implements InboundPdaService {
@Autowired
private IMdPbGroupplateService iMdPbGroupplateService;
@Autowired
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService;
@Resource
private IStructattrService iStructattrService;
@Autowired
@@ -735,6 +738,7 @@ public class InboundPdaServiceImpl implements InboundPdaService {
if (dto.getItems().isEmpty()){
throw new BadRequestException("组盘物料为空");
}
iMdPbStoragevehicleinfoService.chackAndInsert(dto.getVehicle_code());
Structattr structattr = iStructattrService.getByCode(dto.getLocation_code());
BsrealStorattr storattrIn = storattrService.findByCode(structattr.getStor_code());
if (!StringUtils.isEmpty(structattr.getStoragevehicle_code())){
@@ -774,7 +778,8 @@ public class InboundPdaServiceImpl implements InboundPdaService {
ioStorInvIn.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
dto.getItems().forEach(item -> {
BigDecimal qty = item.getQty();
WorkOrderDao workOrder = workOrderService.getWorkOrder(item.getOrder_code());
boolean hasWorkOrder = StringUtils.isNotBlank(item.getOrder_code());
WorkOrderDao workOrder = hasWorkOrder ? workOrderService.getWorkOrder(item.getOrder_code()) : null;
MdMeMaterialbase material = iMdMeMaterialbaseService.getByCode(item.getMaterial_code());
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
@@ -790,8 +795,10 @@ public class InboundPdaServiceImpl implements InboundPdaService {
ioStorInvDtl.setAssign_qty(qty);
ioStorInvDtl.setPlan_qty(qty);
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
ioStorInvDtl.setSource_bill_code(workOrder.getOrder_code());
ioStorInvDtl.setSource_bill_type("work_order");
if (hasWorkOrder) {
ioStorInvDtl.setSource_bill_code(workOrder.getOrder_code());
ioStorInvDtl.setSource_bill_type("work_order");
}
ioStorInvDtls.add(ioStorInvDtl);
// 分配
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
@@ -801,7 +808,7 @@ public class InboundPdaServiceImpl implements InboundPdaService {
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
ioStorInvDis.setMaterial_id(material.getMaterial_id());
ioStorInvDis.setMaterial_code(material.getMaterial_code()); // 直接使用变量
ioStorInvDis.setSect_code(workOrder.getDefault_warehouse_code());
ioStorInvDis.setSect_code(hasWorkOrder ? workOrder.getDefault_warehouse_code() : structattr.getSect_code());
ioStorInvDis.setStruct_code(structattr.getStruct_code());
ioStorInvDis.setPcsn("1");
ioStorInvDis.setStoragevehicle_code(structattr.getStoragevehicle_code());
@@ -818,7 +825,9 @@ public class InboundPdaServiceImpl implements InboundPdaService {
addParam.setStoragevehicleCode(dto.getVehicle_code());
addParam.setUnitName(material.getQty_unit_name());
addParam.setUnitId(material.getQty_unit_id());
addParam.setExtCode(workOrder.getOrder_code());
if (hasWorkOrder) {
addParam.setExtCode(workOrder.getOrder_code());
}
addParam.setQty(qty);
addInvParams.add(addParam);
@@ -832,35 +841,36 @@ public class InboundPdaServiceImpl implements InboundPdaService {
inFinishParam.setSectCode(structattr.getSect_code());
inFinishParam.setStructCode(structattr.getStruct_code());
inFinishParams.add(inFinishParam);
//保存生产入库回传单定时回传
JSONObject callbackInData = new JSONObject();
callbackInData.put("method", "DealSCRKBill");
callbackInData.put("type", "MES");
// 组装data节点
JSONObject dataIn = new JSONObject();
dataIn.put("orgno", workOrder.getOrg_code());//库存组织
dataIn.put("billno", workOrder.getOrder_code()); // 单据编号
dataIn.put("biztype", "390");
dataIn.put("invscheme", "001");
dataIn.put("transtype", "024");
dataIn.put("biztime", LocalDate.now());
JSONArray entrysIn = new JSONArray();
JSONObject entry = new JSONObject();
entry.put("srcbillno", workOrder.getOrder_code());
entry.put("srcbillid", workOrder.getOrder_id()); // 数量
entry.put("srcbillentryid", workOrder.getOrder_id());
entry.put("qty", item.getQty());
entry.put("materialno", item.getMaterial_code());
entrysIn.add(entry);
dataIn.put("entrys", entrysIn);
callbackInData.put("data", dataIn);
PmStockReturn stockReturnIn = new PmStockReturn();
stockReturnIn.setRequest_Id(workOrder.getOrder_code());
stockReturnIn.setRequest_type(IOSEnum.BILL_TYPE.code("生产入库"));
stockReturnIn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
stockReturnIn.setCreate_time(now);
stockReturnIn.setRequest_data(callbackInData.toString());
iPmStockReturnService.save(stockReturnIn);
if (hasWorkOrder) {
// 有工单时才创建生产入库回传任务。
JSONObject callbackInData = new JSONObject();
callbackInData.put("method", "DealSCRKBill");
callbackInData.put("type", "MES");
JSONObject dataIn = new JSONObject();
dataIn.put("orgno", workOrder.getOrg_code());
dataIn.put("billno", workOrder.getOrder_code());
dataIn.put("biztype", "390");
dataIn.put("invscheme", "001");
dataIn.put("transtype", "024");
dataIn.put("biztime", LocalDate.now());
JSONArray entrysIn = new JSONArray();
JSONObject entry = new JSONObject();
entry.put("srcbillno", workOrder.getOrder_code());
entry.put("srcbillid", workOrder.getOrder_id());
entry.put("srcbillentryid", workOrder.getOrder_id());
entry.put("qty", item.getQty());
entry.put("materialno", item.getMaterial_code());
entrysIn.add(entry);
dataIn.put("entrys", entrysIn);
callbackInData.put("data", dataIn);
PmStockReturn stockReturnIn = new PmStockReturn();
stockReturnIn.setRequest_Id(workOrder.getOrder_code());
stockReturnIn.setRequest_type(IOSEnum.BILL_TYPE.code("生产入库"));
stockReturnIn.setStatus(StockReturnStatusEnum.TODO.getCode());
stockReturnIn.setCreate_time(now);
stockReturnIn.setRequest_data(callbackInData.toString());
iPmStockReturnService.save(stockReturnIn);
}
});
ioStorInvMapper.insert(ioStorInvIn);
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);