add:需求单增加批量操作,强制回传功能
This commit is contained in:
@@ -127,4 +127,12 @@ public class ResponseData<T> implements Serializable {
|
||||
rspData.setRespCode(1);
|
||||
return new ResponseEntity(rspData, org.springframework.http.HttpStatus.OK);
|
||||
}
|
||||
public static ResponseEntity buildMsg(String msg) {
|
||||
ResponseData rspData = new ResponseData<>();
|
||||
rspData.setCode(HttpStatus.OK.value());
|
||||
rspData.setMessage(msg);
|
||||
rspData.setRespMsg(msg);
|
||||
rspData.setRespCode(0);
|
||||
return new ResponseEntity(rspData, org.springframework.http.HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.BatchAllocateParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.DemandInventryDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
@@ -18,6 +19,7 @@ import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/pmDemand")
|
||||
@@ -70,6 +72,14 @@ public class PmDemandController {
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/batchAllocate")
|
||||
@Log("批量分配仓库")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> batchAllocate(@RequestBody BatchAllocateParam param) {
|
||||
pmDemandService.batchAllocateInventory(param.getIds(), param.getInventoryDis());
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/push")
|
||||
@Log("需求单下发")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -77,4 +87,12 @@ public class PmDemandController {
|
||||
pmDemandService.pushDemand(pmDemandDtos);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PutMapping("/issueReturnBill")
|
||||
@Log("强制回传EAS")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> issueReturnBill(@RequestBody Set<String> ids) {
|
||||
pmDemandService.issueReturnBill(ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IPmDemandService extends IService<PmDemand> {
|
||||
|
||||
@@ -36,6 +37,13 @@ public interface IPmDemandService extends IService<PmDemand> {
|
||||
*/
|
||||
void allocateInventory(String id, String inventoryDis);
|
||||
|
||||
/**
|
||||
* 批量分配仓库
|
||||
* @param ids 需求单ID列表
|
||||
* @param inventoryDis 分配仓库JSON
|
||||
*/
|
||||
void batchAllocateInventory(List<String> ids, String inventoryDis);
|
||||
|
||||
/**
|
||||
* 推送需求单
|
||||
* 1.需求单分配出库仓库
|
||||
@@ -45,4 +53,5 @@ public interface IPmDemandService extends IService<PmDemand> {
|
||||
* @param pmDemandDto
|
||||
*/
|
||||
void pushDemand(List<PmDemandDto> pmDemandDto);
|
||||
void issueReturnBill(Set<String> ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.wms.pm_manage.demand.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BatchAllocateParam implements Serializable {
|
||||
|
||||
private List<String> ids;
|
||||
|
||||
private String inventoryDis;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.nl.wms.pm_manage.demand.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -11,11 +14,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||
import org.nl.wms.ext_manage.purchase.service.dto.EasAuditRequestDto;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
|
||||
@@ -26,25 +31,31 @@ import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandQuery;
|
||||
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.Purchasemst;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
|
||||
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.inventory.dto.StInventoryDto;
|
||||
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryQuery;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -63,9 +74,15 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
@Autowired
|
||||
private ISysParamService iSysParamService;
|
||||
@Autowired
|
||||
private ISchBaseRegionService iSchBaseRegionService;
|
||||
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
@Autowired
|
||||
private IPmStockReturnService iPmStockReturnService;
|
||||
|
||||
@Override
|
||||
public Page<PmDemandDto> queryPage(PmDemandQuery query, PageQuery pageQuery) {
|
||||
trimStringFields(query);
|
||||
@@ -156,6 +173,26 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
this.updateById(demand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchAllocateInventory(List<String> ids, String inventoryDis) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("请选择需求单");
|
||||
}
|
||||
List<PmDemand> demands = this.listByIds(ids);
|
||||
if (CollectionUtils.isEmpty(demands)) {
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
for (PmDemand demand : demands) {
|
||||
if (!"0".equals(demand.getStatus())) {
|
||||
throw new BadRequestException("仅支持对生成状态的需求单进行批量分配");
|
||||
}
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getInventory_dis, inventoryDis)
|
||||
.set(PmDemand::getStatus, DemandStatus.DIS.getValue())
|
||||
.in(PmDemand::getId, ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DemandInventryDto> queryInventory(String skuCode) {
|
||||
List<DemandInventryDto> resultList = new ArrayList<>();
|
||||
@@ -211,9 +248,17 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
}
|
||||
Map<Boolean, List<PmDemandDto>> partitioned = pmDemandDtos.stream()
|
||||
.collect(Collectors.partitioningBy(a -> ZD_STOR_SET
|
||||
.contains(JSONObject.parseObject(a.getInventoryDis()).getString("horseCode"))));
|
||||
.contains(a.getInventoryDis())));
|
||||
List<PmDemandDto> zdDemands = partitioned.get(true);
|
||||
List<PmDemandDto> otherDemands = partitioned.get(false);
|
||||
if (!CollectionUtils.isEmpty(otherDemands)) {
|
||||
JSONObject billParam = convertDemandsToBillParam(otherDemands);
|
||||
iOutBillService.saveBill(billParam);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.SEND.getValue())
|
||||
.in(PmDemand::getId,otherDemands.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(zdDemands)) {
|
||||
wmsToZDWmdService.syncDemandOrder(zdDemands);
|
||||
//直接增加对应库存并做库存记录
|
||||
@@ -242,16 +287,12 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
}
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId,zdDemands.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(otherDemands)) {
|
||||
JSONObject billParam = convertDemandsToBillParam(otherDemands);
|
||||
iOutBillService.saveBill(billParam);
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.SEND.getValue())
|
||||
.in(PmDemand::getId,pmDemandDtos.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
private JSONObject convertDemandsToBillParam(List<PmDemandDto> demands) {
|
||||
@@ -260,10 +301,9 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
}
|
||||
|
||||
PmDemandDto firstDemand = demands.get(0);
|
||||
JSONObject inventoryDis = JSONObject.parseObject(firstDemand.getInventoryDis());
|
||||
|
||||
JSONObject billParam = new JSONObject();
|
||||
billParam.put("stor_code", inventoryDis.getString("horseCode"));
|
||||
billParam.put("stor_code", firstDemand.getInventoryDis());
|
||||
billParam.put("biz_date", DateUtil.today());
|
||||
billParam.put("bill_type", IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
billParam.put("remark", "需求单下推生成");
|
||||
@@ -294,6 +334,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
detailRow.put("callback_strategy", "DealLLDBBillPmDeamndCallBack");
|
||||
detailRow.put("source_bill_type", "需求单");
|
||||
detailRow.put("source_billdtl_id", demand.getId());
|
||||
detailRow.put("source_bill_table", "pm_demand");
|
||||
detailRow.put("remark", "关联工单:" + demand.getWorkOrder());
|
||||
detailRow.put("load_port", demand.getTargetArea());
|
||||
tableData.add(detailRow);
|
||||
@@ -301,4 +342,50 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
billParam.put("tableData", tableData);
|
||||
return billParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issueReturnBill(Set<String> ids) {
|
||||
final List<PmDemand> pmDemands = this.listByIds(ids);
|
||||
if (ObjectUtil.isEmpty(pmDemands)) {
|
||||
throw new BadRequestException("未找到选中的单据");
|
||||
}
|
||||
JSONObject callbackData = new JSONObject();
|
||||
callbackData.put("method", "DealLLDBBill");
|
||||
callbackData.put("type", "WMS");
|
||||
final String uuidBill = UUID.randomUUID().toString();
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
|
||||
data.put("bizTypeNo", "331"); // 业务日期
|
||||
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
|
||||
data.put("billNo", uuidBill); // 使用工单编号作为MES单号
|
||||
// 组装明细列表
|
||||
JSONArray entrys = new JSONArray();
|
||||
for (PmDemand pmDemand : pmDemands) {
|
||||
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||
.eq(SchBaseRegion::getRegion_code, pmDemand.getProduction_line())
|
||||
.select(SchBaseRegion::getPoint_type_explain));
|
||||
if (region==null){
|
||||
throw new BadRequestException("当前产线未配置对应仓库编码getPoint_type_explain");
|
||||
}
|
||||
cn.hutool.json.JSONObject entry = new cn.hutool.json.JSONObject();
|
||||
entry.put("unitNo", "PCS"); // 序号
|
||||
entry.put("qty", pmDemand.getQty()); // 数量
|
||||
entry.put("materialNo", pmDemand.getSku_code()); // 来源单据标识
|
||||
entry.put("issueWarehouseNo", pmDemand.getInventory_dis());
|
||||
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(uuidBill);
|
||||
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||
stockReturn.setCreate_time(DateUtil.now());
|
||||
stockReturn.setRequest_data(callbackData.toString());
|
||||
iPmStockReturnService.save(stockReturn);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId,ids));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.nl.wms.warehouse_manage.inAndOut.service.dto.OutBillManualDivReq;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dto.OutBillOneCancelReq;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -81,14 +82,16 @@ public class OutBillController {
|
||||
@PostMapping("/allDiv")
|
||||
@Log("出库单全部分配")
|
||||
public ResponseEntity<Object> allDiv(@RequestBody OutBillDivReq req) {
|
||||
iOutBillService.doDiv(req, false);
|
||||
return ResponseData.build();
|
||||
Assert.notNull(req.getSect_code(),"分配失败,全部分配请选出库库区");
|
||||
Map<String, String> StringMap = iOutBillService.doDiv(req, false);
|
||||
return ResponseData.buildMsg(StringMap.toString());
|
||||
}
|
||||
@PostMapping("/autoDiv")
|
||||
@Log("出库单自动分配")
|
||||
public ResponseEntity<Object> autoDiv(@RequestBody OutBillDivReq req) {
|
||||
iOutBillService.doDiv(req, true);
|
||||
return ResponseData.build();
|
||||
Assert.notNull(req.getSect_code(),"分配失败,全部分配请选出库库区");
|
||||
Map<String, String> StringMap = iOutBillService.doDiv(req, true);
|
||||
return ResponseData.buildMsg(StringMap.toString());
|
||||
}
|
||||
@PostMapping("/manualDiv")
|
||||
@Log("出库单手动分配")
|
||||
|
||||
@@ -87,7 +87,7 @@ public interface IOutBillService extends IService<IOStorInv> {
|
||||
*/
|
||||
List<IOStorInvDisDto> getOutBillDis(Map whereJson);
|
||||
|
||||
void doDiv(OutBillDivReq req, boolean singleDtl);
|
||||
Map<String,String> doDiv(OutBillDivReq req, boolean singleDtl);
|
||||
void doCancel(String iostorinvId, String iostorinvdtlId);
|
||||
|
||||
|
||||
|
||||
@@ -347,7 +347,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doDiv(OutBillDivReq req, boolean singleDtl) {
|
||||
public Map<String,String> doDiv(OutBillDivReq req, boolean singleDtl) {
|
||||
Map<String,String> result = new HashMap<>();
|
||||
List<String> flatWarehouse = getFlatWarehouseCodes();
|
||||
String iostorinvId = req.getIostorinv_id();
|
||||
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinvId);
|
||||
@@ -373,7 +374,13 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
.strategyMaters(list);
|
||||
if (singleDtl) {builder.inv_code(ioStorInv.getBill_code());}
|
||||
//库存分配
|
||||
List<StrategyStructMaterialVO> structMaterials = iStructattrService.outBoundSectDiv(builder.build());
|
||||
List<StrategyStructMaterialVO> structMaterials;
|
||||
try {
|
||||
structMaterials = iStructattrService.outBoundSectDiv(builder.build());
|
||||
}catch (Exception ex){
|
||||
result.put("物料"+dtl.getMaterial_code(),ex.getMessage());
|
||||
break;
|
||||
}
|
||||
int seqNo = 1;
|
||||
BigDecimal allocationCanuseQty = BigDecimal.ZERO;
|
||||
List<IOStorInvDis> disSet = new ArrayList<>();
|
||||
@@ -438,6 +445,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
}
|
||||
//更新主单子状态
|
||||
this.updateBillStatus(iostorinvId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -809,33 +817,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
throw new BadRequestException("未找到明细");
|
||||
}
|
||||
final IOStorInv ioStorInv = ioStorInvMapper.selectById(ioStorInvDtl.getIostorinv_id());
|
||||
if (ioStorInv.getBill_type().equals(IOSEnum.BILL_TYPE.code("库存调拨"))){
|
||||
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||
for (IOStorInvDis invDis : disList) {
|
||||
if (invDis.getTask_id() == null && !StringUtils.isEmpty(invDis.getPoint_code())){
|
||||
//出库点所属区域
|
||||
String sectCode = iSchBasePointService.getPointRegionMapperSect(invDis.getPoint_code());
|
||||
if (sectCode ==null){
|
||||
throw new BadRequestException("明细完成失败,当前点位未配置所属库区");
|
||||
}
|
||||
//更新库存,查询托盘
|
||||
final Structattr targetAttr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, sectCode));
|
||||
if (targetAttr ==null ||StringUtils.isEmpty(targetAttr.getStoragevehicle_code())){
|
||||
throw new BadRequestException("明细完成失败,当前调拨目标区域不存在"+invDis.getPoint_code());
|
||||
}
|
||||
AddInvParam addParam = new AddInvParam();
|
||||
addParam.setPcsn(invDis.getPcsn());
|
||||
addParam.setMaterialCode(invDis.getMaterial_code());
|
||||
addParam.setStoragevehicleCode(targetAttr.getStoragevehicle_code());
|
||||
addParam.setUnitName(invDis.getQty_unit_name());
|
||||
addParam.setUnitId(invDis.getQty_unit_id());
|
||||
addParam.setQty(invDis.getPlan_qty());
|
||||
addInvParams.add(addParam);
|
||||
}
|
||||
}
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
}
|
||||
//非标处理,到线边库的线边库要加库存
|
||||
// 如果分配明细全部完成则更新明细表状态
|
||||
if (countDis == 0){
|
||||
// 更新明细表状态
|
||||
|
||||
@@ -65,9 +65,6 @@ public class StInventoryServiceImpl implements IStInventoryService {
|
||||
if (!StringUtils.isEmpty(invParam.getPcsn())){
|
||||
query.eq(GroupPlate::getPcsn,invParam.getPcsn());
|
||||
}
|
||||
if (invParam.getStoragevehicleCode().startsWith("VTP")){
|
||||
query.last("limit 1");
|
||||
}
|
||||
GroupPlate groupPlate = iMdPbGroupplateService.getOne(query);
|
||||
if (groupPlate == null){
|
||||
GroupPlate groupDao = GroupPlate.builder()
|
||||
@@ -165,12 +162,16 @@ public class StInventoryServiceImpl implements IStInventoryService {
|
||||
queryWrapper.eq(GroupPlate::getPcsn, outFinishParam.getPcsn());
|
||||
}
|
||||
GroupPlate groupPlate = iMdPbGroupplateService.getOne(queryWrapper);
|
||||
groupPlate.setFrozen_qty(BigDecimal.ZERO.min(groupPlate.getFrozen_qty().subtract(outFinishParam.getChangeQty())));
|
||||
groupPlate.setQty(groupPlate.getQty().subtract(outFinishParam.getChangeQty()));
|
||||
groupPlate.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
groupPlate.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
groupPlate.setUpdate_time(DateUtil.now());
|
||||
iMdPbGroupplateService.updateById(groupPlate);
|
||||
if (groupPlate.getQty().subtract(outFinishParam.getChangeQty()).intValue() <= 0){
|
||||
iMdPbGroupplateService.removeById(groupPlate.getGroup_id());
|
||||
}else {
|
||||
groupPlate.setFrozen_qty(BigDecimal.ZERO.min(groupPlate.getFrozen_qty().subtract(outFinishParam.getChangeQty())));
|
||||
groupPlate.setQty(groupPlate.getQty().subtract(outFinishParam.getChangeQty()));
|
||||
groupPlate.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
groupPlate.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
groupPlate.setUpdate_time(DateUtil.now());
|
||||
iMdPbGroupplateService.updateById(groupPlate);
|
||||
}
|
||||
StIvtStructivtflow stIvtStructivtflow = new StIvtStructivtflow();
|
||||
stIvtStructivtflow.setId(IdUtil.getStringId());
|
||||
stIvtStructivtflow.setUpdate_time(DateUtil.now());
|
||||
|
||||
@@ -4,8 +4,13 @@ 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 com.google.common.collect.Lists;
|
||||
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.IPmDemandService;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.PmDemand;
|
||||
@@ -13,19 +18,26 @@ 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.IOStorInvDis;
|
||||
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.nl.wms.welding_manage.service.work_order.IWorkOrderService;
|
||||
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderDao;
|
||||
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;
|
||||
|
||||
@@ -33,6 +45,7 @@ import java.util.List;
|
||||
* 需求单库存调拨回传
|
||||
*/
|
||||
@Service(value = "DealLLDBBillPmDeamndCallBack")
|
||||
@Slf4j
|
||||
public class DealLLDBBillPmDeamndCallBack implements CallbackStrategy {
|
||||
|
||||
@Autowired
|
||||
@@ -44,6 +57,10 @@ public class DealLLDBBillPmDeamndCallBack implements CallbackStrategy {
|
||||
@Autowired
|
||||
private ISchBaseRegionService iSchBaseRegionService;
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
@Autowired
|
||||
private IStInventoryService iStInventoryService;
|
||||
@Autowired
|
||||
private MesApi mesApi;
|
||||
|
||||
@Override
|
||||
@@ -53,15 +70,40 @@ public class DealLLDBBillPmDeamndCallBack implements CallbackStrategy {
|
||||
if (one == null){
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
if (one.getStatus().equals(DemandStatus.FINISH.getValue())){
|
||||
return;
|
||||
}
|
||||
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());
|
||||
@@ -74,7 +116,7 @@ public class DealLLDBBillPmDeamndCallBack implements CallbackStrategy {
|
||||
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
|
||||
data.put("bizTypeNo", "331"); // 业务日期
|
||||
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
|
||||
data.put("billNo", param.getIostorinv_id()); // 使用工单编号作为MES单号
|
||||
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()));
|
||||
@@ -96,15 +138,20 @@ public class DealLLDBBillPmDeamndCallBack implements CallbackStrategy {
|
||||
stockReturn.setCreate_time(now);
|
||||
stockReturn.setRequest_data(callbackData.toString());
|
||||
//回传MES
|
||||
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())));
|
||||
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