|
|
|
|
@ -14,13 +14,15 @@ import org.dromara.system.api.RemoteCodeRuleService;
|
|
|
|
|
import org.dromara.wms.domain.WmsInStockBill;
|
|
|
|
|
import org.dromara.wms.domain.WmsInStockDetails;
|
|
|
|
|
import org.dromara.wms.domain.WmsInventoryDetails;
|
|
|
|
|
import org.dromara.wms.domain.WmsInventoryLedger;
|
|
|
|
|
import org.dromara.wms.domain.bo.WmsInStockBillBo;
|
|
|
|
|
import org.dromara.wms.domain.bo.WmsInventoryDetailsBo;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsInStockBillVo;
|
|
|
|
|
import org.dromara.wms.mapper.WmsInStockBillMapper;
|
|
|
|
|
import org.dromara.wms.mapper.WmsInStockDetailsMapper;
|
|
|
|
|
import org.dromara.wms.mapper.WmsInventoryLedgerMapper;
|
|
|
|
|
import org.dromara.wms.service.IWmsInStockBillService;
|
|
|
|
|
import org.dromara.wms.service.IWmsInventoryDetailsService;
|
|
|
|
|
import org.dromara.wms.service.IWmsWarehouseInfoService;
|
|
|
|
|
import org.dromara.workflow.api.RemoteWorkflowService;
|
|
|
|
|
import org.dromara.workflow.api.domain.RemoteStartProcess;
|
|
|
|
|
import org.dromara.workflow.api.event.ProcessEvent;
|
|
|
|
|
@ -42,7 +44,8 @@ public class WmsInStockBillServiceImpl implements IWmsInStockBillService {
|
|
|
|
|
private final WmsInStockBillMapper baseMapper;
|
|
|
|
|
private final WmsInStockDetailsMapper wmsInStockDetailsMapper;
|
|
|
|
|
private final IWmsInventoryDetailsService inventoryService;
|
|
|
|
|
private final IWmsWarehouseInfoService warehouseService;
|
|
|
|
|
// private final IWmsWarehouseInfoService warehouseService;
|
|
|
|
|
private final WmsInventoryLedgerMapper wmsInventoryLedgerMapper;
|
|
|
|
|
@DubboReference
|
|
|
|
|
private RemoteCodeRuleService remoteCodeRuleService;
|
|
|
|
|
@DubboReference(timeout = 30000)//超时时间
|
|
|
|
|
@ -110,31 +113,57 @@ public class WmsInStockBillServiceImpl implements IWmsInStockBillService {
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean insertByBo(WmsInStockBillBo bo) {
|
|
|
|
|
WmsInStockBill add = MapstructUtils.convert(bo, WmsInStockBill.class);
|
|
|
|
|
add.setInStockCode(remoteCodeRuleService.selectCodeRuleCode("1005"));
|
|
|
|
|
String inStockType = add.getInStockType();
|
|
|
|
|
add.setInStockCode(remoteCodeRuleService.selectCodeRuleCode("1005"));// 物料入库编码
|
|
|
|
|
add.setInStockBillStatus("3");
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;//插入主表
|
|
|
|
|
if (flag) {
|
|
|
|
|
Long inStockBillId = add.getInStockBillId();
|
|
|
|
|
List<WmsInStockDetails> inStockDetailsList = bo.getInStockDetailsList();
|
|
|
|
|
List<WmsInventoryDetails> inventoryDetailsList = new ArrayList<>(inStockDetailsList.size());//库存集合
|
|
|
|
|
List<WmsInventoryLedger> wmsInventoryLedgers = new ArrayList<>(inStockDetailsList.size());//库存集合
|
|
|
|
|
Long projectId = bo.getProjectId();// 项目ID
|
|
|
|
|
inStockDetailsList.forEach(item -> {
|
|
|
|
|
item.setInStockBillId(inStockBillId); // 设置入库单明细的入库单ID
|
|
|
|
|
item.setProjectId(projectId); // 关联项目
|
|
|
|
|
|
|
|
|
|
WmsInventoryDetails inventory = new WmsInventoryDetails();
|
|
|
|
|
inventory.setWarehouseId(item.getWarehouseId()); // 关联仓库
|
|
|
|
|
inventory.setProjectId(projectId); // 关联项目
|
|
|
|
|
inventory.setBatchNumber(item.getBatchNumber()); // 关联批次号
|
|
|
|
|
inventory.setMaterielId(item.getMaterialId()); // 关联物料
|
|
|
|
|
inventory.setUnitPrice(item.getUnitPrice());
|
|
|
|
|
Double inStockAmount = item.getInStockAmount();
|
|
|
|
|
inventory.setInventoryAmount(inStockAmount);
|
|
|
|
|
inventory.setStartInventoryAmount(inStockAmount); // 初始库存数量
|
|
|
|
|
inventoryDetailsList.add(inventory);
|
|
|
|
|
Double inventoryTableAmount = 0.0;// 库存表数量
|
|
|
|
|
// 构建库存明细
|
|
|
|
|
WmsInventoryDetailsBo inventory = new WmsInventoryDetailsBo();
|
|
|
|
|
inventory.setWarehouseId(item.getWarehouseId());
|
|
|
|
|
inventory.setProjectId(projectId);
|
|
|
|
|
inventory.setBatchNumber(item.getBatchNumber());
|
|
|
|
|
inventory.setMaterielId(item.getMaterialId());
|
|
|
|
|
inventory.setUnitPrice(item.getUnitPrice());
|
|
|
|
|
// 查询相同项目 相同仓库 相同批次 相同单价的物料
|
|
|
|
|
WmsInventoryDetails queryInventory = inventoryService.queryInventory(inventory);
|
|
|
|
|
if (queryInventory != null) {
|
|
|
|
|
WmsInventoryDetailsBo inventoryUpdate = new WmsInventoryDetailsBo();
|
|
|
|
|
inventoryUpdate.setInventoryDetailsId(queryInventory.getInventoryDetailsId());
|
|
|
|
|
inventoryTableAmount = queryInventory.getInventoryAmount() ;
|
|
|
|
|
inventoryUpdate.setInventoryAmount(inventoryTableAmount+ inStockAmount);
|
|
|
|
|
inventoryService.updateByBo(inventoryUpdate); // 更新库存数量
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
inventory.setUnitName(item.getUnitName());
|
|
|
|
|
inventory.setInventoryAmount(inStockAmount);
|
|
|
|
|
inventory.setStartInventoryAmount(inStockAmount); // 初始库存数量
|
|
|
|
|
inventoryService.insertByBo(inventory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//库存变动
|
|
|
|
|
WmsInventoryLedger wmsInventoryLedger = new WmsInventoryLedger();
|
|
|
|
|
wmsInventoryLedger.setWarehouseId(item.getWarehouseId());
|
|
|
|
|
wmsInventoryLedger.setBatchNumber(item.getBatchNumber());
|
|
|
|
|
wmsInventoryLedger.setMaterielId(item.getMaterialId());
|
|
|
|
|
wmsInventoryLedger.setChangeType(inStockType);//变动类型
|
|
|
|
|
wmsInventoryLedger.setLedgerState("1");
|
|
|
|
|
wmsInventoryLedger.setChangeAmount(inStockAmount);
|
|
|
|
|
wmsInventoryLedger.setInventoryAmount(inventoryTableAmount);
|
|
|
|
|
wmsInventoryLedgers.add(wmsInventoryLedger);
|
|
|
|
|
});
|
|
|
|
|
wmsInStockDetailsMapper.insert(inStockDetailsList); //插入子表
|
|
|
|
|
inventoryService.insertList(inventoryDetailsList); //插入库存
|
|
|
|
|
wmsInventoryLedgerMapper.insert(wmsInventoryLedgers);
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|