fix:喷涂领料单出库完成
This commit is contained in:
@@ -412,7 +412,7 @@ public class PmDemandPlatingServiceImpl extends ServiceImpl<PmDemandPlatingMappe
|
|||||||
detailRow.put("qty", demand.getQty());
|
detailRow.put("qty", demand.getQty());
|
||||||
detailRow.put("source_bill_code", demand.getId());
|
detailRow.put("source_bill_code", demand.getId());
|
||||||
//走调拨回传
|
//走调拨回传
|
||||||
detailRow.put("callback_strategy", "DealLLDBBillPmDeamndCallBack");
|
detailRow.put("callback_strategy", "DealLLDBBillPmDeamndPlatingCallBack");
|
||||||
detailRow.put("source_bill_type", "需求单");
|
detailRow.put("source_bill_type", "需求单");
|
||||||
detailRow.put("source_billdtl_id", demand.getId());
|
detailRow.put("source_billdtl_id", demand.getId());
|
||||||
detailRow.put("source_bill_table", "pm_demand");
|
detailRow.put("source_bill_table", "pm_demand");
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
package org.nl.wms.warehouse_manage.stockReturn.strategy.core.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.common.utils.MapOf;
|
||||||
|
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||||
|
import org.nl.wms.ext_manage.api.MesApi;
|
||||||
|
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||||
|
import org.nl.wms.pm_manage.demand.service.dao.PmDemandPlating;
|
||||||
|
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
|
||||||
|
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
|
||||||
|
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
|
||||||
|
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||||
|
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
|
||||||
|
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper;
|
||||||
|
import org.nl.wms.warehouse_manage.inAndOut.service.dto.IOStorInvDisDto;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.param.impl.AddInvParam;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.param.impl.InFinishParam;
|
||||||
|
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||||
|
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||||
|
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||||
|
import org.nl.wms.warehouse_manage.stockReturn.strategy.core.CallbackStrategy;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需求单库存调拨回传
|
||||||
|
*/
|
||||||
|
@Service(value = "DealLLDBBillPmDeamndPlatingCallBack")
|
||||||
|
@Slf4j
|
||||||
|
public class DealLLDBBillPmDeamndPlatingCallBack implements CallbackStrategy {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPmDemandPlatingService iPmDemandService;
|
||||||
|
@Autowired
|
||||||
|
private IPmStockReturnService iPmStockReturnService;
|
||||||
|
@Resource
|
||||||
|
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||||
|
@Autowired
|
||||||
|
private ISchBaseRegionService iSchBaseRegionService;
|
||||||
|
@Autowired
|
||||||
|
private IStructattrService iStructattrService;
|
||||||
|
@Autowired
|
||||||
|
private IStInventoryService iStInventoryService;
|
||||||
|
@Autowired
|
||||||
|
private MesApi mesApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildCallback(IOStorInvDtl param) {
|
||||||
|
final String orderCode = param.getSource_bill_code();
|
||||||
|
PmDemandPlating one = iPmDemandService.getOne(new LambdaQueryWrapper<PmDemandPlating>().eq(PmDemandPlating::getId, orderCode));
|
||||||
|
if (one == null){
|
||||||
|
throw new BadRequestException("需求单不存在");
|
||||||
|
}
|
||||||
|
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||||
|
.eq(SchBaseRegion::getRegion_code, one.getProduction_line())
|
||||||
|
.select(SchBaseRegion::getPoint_type_explain));
|
||||||
|
if (region==null){
|
||||||
|
throw new BadRequestException("当前产线未配置对应仓库编码getPoint_type_explain");
|
||||||
|
}
|
||||||
|
//更新库存,查询托盘
|
||||||
|
final Structattr targetAttr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||||
|
.eq(Structattr::getSect_code, region.getPoint_type_explain()));
|
||||||
|
if (targetAttr ==null ||StringUtils.isEmpty(targetAttr.getStoragevehicle_code())){
|
||||||
|
throw new BadRequestException("调拨失败,当前调拨目标区域缺少仓库熟悉"+targetAttr.getStruct_code());
|
||||||
|
}
|
||||||
|
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||||
|
AddInvParam addParam = new AddInvParam();
|
||||||
|
addParam.setPcsn(StringUtils.isEmpty(param.getPcsn())?"1":param.getPcsn());
|
||||||
|
addParam.setMaterialCode(param.getMaterial_code());
|
||||||
|
addParam.setStoragevehicleCode(targetAttr.getStoragevehicle_code());
|
||||||
|
addParam.setStructCode(targetAttr.getStruct_code());
|
||||||
|
addParam.setSectCode(targetAttr.getSect_code());
|
||||||
|
addParam.setStorCode(targetAttr.getStor_code());
|
||||||
|
addParam.setUnitName(param.getQty_unit_name());
|
||||||
|
addParam.setUnitId(param.getQty_unit_id());
|
||||||
|
addParam.setQty(param.getAssign_qty());
|
||||||
|
addInvParams.add(addParam);
|
||||||
|
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||||
|
final List<InFinishParam> inFinishParams = new ArrayList<>();
|
||||||
|
InFinishParam inFinishParam = new InFinishParam();
|
||||||
|
BeanUtils.copyProperties(addParam,inFinishParam);
|
||||||
|
inFinishParam.setRemark("需求单库存调拨");
|
||||||
|
inFinishParams.add(inFinishParam);
|
||||||
|
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||||
|
if (one.getStatus().equals(DemandStatus.FINISH.getValue())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
one.setAssign_qty(param.getAssign_qty());
|
||||||
|
if (one.getAssign_qty().intValue()>=one.getQty().intValue()){
|
||||||
|
one.setStatus(DemandStatus.FINISH.getValue());
|
||||||
|
final String now = DateUtil.now();
|
||||||
|
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", param.getIostorinvdtl_id()+"#"+param.getSeq_no()); // 使用工单编号作为MES单号
|
||||||
|
// 组装明细列表
|
||||||
|
JSONArray entrys = new JSONArray();
|
||||||
|
final List<IOStorInvDisDto> disSet = ioStorInvDisMapper.queryOutBillDisDtl(MapOf.of("iostorinvdtl_id", param.getIostorinvdtl_id()));
|
||||||
|
for (IOStorInvDisDto ioStorInvDisDto : disSet) {
|
||||||
|
JSONObject entry = new JSONObject();
|
||||||
|
entry.put("unitNo", "PCS"); // 序号
|
||||||
|
entry.put("qty", ioStorInvDisDto.getPlan_qty()); // 数量
|
||||||
|
entry.put("materialNo", ioStorInvDisDto.getMaterial_code()); // 来源单据标识
|
||||||
|
entry.put("issueWarehouseNo", ioStorInvDisDto.getSect_code());
|
||||||
|
entry.put("receiptWarehouseNo", region.getPoint_type_explain());
|
||||||
|
entrys.add(entry);
|
||||||
|
}
|
||||||
|
data.put("entrys", entrys);
|
||||||
|
callbackData.put("data", data);
|
||||||
|
PmStockReturn stockReturn = new PmStockReturn();
|
||||||
|
stockReturn.setRequest_Id(param.getIostorinv_id());
|
||||||
|
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||||
|
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||||
|
stockReturn.setCreate_time(now);
|
||||||
|
stockReturn.setRequest_data(callbackData.toString());
|
||||||
|
//回传MES
|
||||||
|
try {
|
||||||
|
mesApi.pmDemandCallback(Arrays.asList(new MesApi.PmDemandCall(
|
||||||
|
one.getId()
|
||||||
|
,one.getId()
|
||||||
|
,now,one.getTarget_area()
|
||||||
|
,1
|
||||||
|
,disSet.get(0).getStoragevehicle_code(),
|
||||||
|
param.getAssign_qty().toString())));
|
||||||
|
}catch (Exception ex){
|
||||||
|
log.error("DealLLDBBillPmDeamndCallBack#pmDemandCallback error:{}",ex.getMessage());
|
||||||
|
}
|
||||||
|
iPmStockReturnService.save(stockReturn);
|
||||||
|
}
|
||||||
|
this.iPmDemandService.updateById(one);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user