|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
|
package org.nl.wms.storage_manage.semimanage.service.iostorInv.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
@@ -15,6 +16,9 @@ import org.nl.common.utils.IdUtil;
|
|
|
|
|
import org.nl.common.utils.SecurityUtils;
|
|
|
|
|
import org.nl.modules.common.exception.BadRequestException;
|
|
|
|
|
import org.nl.modules.system.util.CodeUtil;
|
|
|
|
|
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtSectattrService;
|
|
|
|
|
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtSectattr;
|
|
|
|
|
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtStructattr;
|
|
|
|
|
import org.nl.wms.storage_manage.IOSEnum;
|
|
|
|
|
import org.nl.wms.storage_manage.CHANGE_BILL_TYPE_ENUM;
|
|
|
|
|
import org.nl.wms.storage_manage.basedata.service.record.dto.StIvtStructivtflowDto;
|
|
|
|
|
@@ -22,6 +26,9 @@ import org.nl.wms.storage_manage.basedata.service.record.service.IStIvtStructivt
|
|
|
|
|
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtBsrealstorattrService;
|
|
|
|
|
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtStructattrService;
|
|
|
|
|
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtBsrealstorattr;
|
|
|
|
|
import org.nl.wms.storage_manage.productmanage.util.DivRuleCpService;
|
|
|
|
|
import org.nl.wms.storage_manage.productmanage.util.RuleUtil;
|
|
|
|
|
import org.nl.wms.storage_manage.rawmanage.service.structIvt.dao.StIvtStructivtYl;
|
|
|
|
|
import org.nl.wms.storage_manage.semimanage.service.iostorInv.dao.StIvtIostorinvBcp;
|
|
|
|
|
import org.nl.wms.storage_manage.semimanage.service.iostorInv.dao.mapper.StIvtIostorinvBcpMapper;
|
|
|
|
|
import org.nl.wms.storage_manage.semimanage.service.iostorInv.IStIvtIostorinvBcpService;
|
|
|
|
|
@@ -53,16 +60,20 @@ public class StIvtIostorinvBcpServiceImpl extends ServiceImpl<StIvtIostorinvBcpM
|
|
|
|
|
@Autowired
|
|
|
|
|
private IStIvtBsrealstorattrService storattrService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IStIvtStructivtBcpService structivtBcpService;
|
|
|
|
|
private IStIvtStructivtBcpService structivtBcpService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IStIvtStructivtflowService structivtflowService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IStIvtStructattrService structattrService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private DivRuleCpService divRuleCpService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IStIvtSectattrService sectattrService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object queryDtl(BcpIostorInvQuery query, PageQuery pageQuery) {
|
|
|
|
|
Page<Object> page = PageHelper.startPage(pageQuery.getPage()+1, pageQuery.getSize());
|
|
|
|
|
Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize());
|
|
|
|
|
TableDataInfo build = TableDataInfo.build(this.getIoDtl(query));
|
|
|
|
|
build.setTotalElements(page.getTotal());
|
|
|
|
|
return build;
|
|
|
|
|
@@ -76,19 +87,20 @@ public class StIvtIostorinvBcpServiceImpl extends ServiceImpl<StIvtIostorinvBcpM
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void create(JSONObject form) {
|
|
|
|
|
Assert.notNull(form,"参数不能为空");
|
|
|
|
|
Assert.notNull(form, "参数不能为空");
|
|
|
|
|
for (Object item : form.getJSONArray("tableData")) {
|
|
|
|
|
StIvtIostorinvBcp mst = new StIvtIostorinvBcp();
|
|
|
|
|
mst.setIostorinv_id(IdUtil.getStringId());
|
|
|
|
|
mst.setBill_code(CodeUtil.getNewCode("IO_CODE"));
|
|
|
|
|
mst.setBiz_date(form.getDate("biz_date"));
|
|
|
|
|
mst.setBiz_date(form.getString("biz_date"));
|
|
|
|
|
mst.setBill_type(form.getString("bill_type"));
|
|
|
|
|
mst.setIo_type(IOSEnum.IO_TYPE.code("入库"));
|
|
|
|
|
mst.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
|
|
|
|
|
mst.setRemark(form.getString("remark"));
|
|
|
|
|
mst.setProduct_area(form.getString("product_code"));
|
|
|
|
|
mst.setWorkshop_id(form.getString("product_code"));
|
|
|
|
|
mst.setPoint_code(form.getString("point_code"));
|
|
|
|
|
仓库数据:{
|
|
|
|
|
仓库数据:
|
|
|
|
|
{
|
|
|
|
|
StIvtBsrealstorattr stor = storattrService.getOne(new QueryWrapper<StIvtBsrealstorattr>().eq("stor_id", form.getString("stor_id")));
|
|
|
|
|
mst.setStor_id(stor.getStor_id());
|
|
|
|
|
mst.setStor_code(stor.getStor_code());
|
|
|
|
|
@@ -97,14 +109,14 @@ public class StIvtIostorinvBcpServiceImpl extends ServiceImpl<StIvtIostorinvBcpM
|
|
|
|
|
packageRow(mst, (JSONObject) item);
|
|
|
|
|
mst.setCreate_id(SecurityUtils.getCurrentUserId());
|
|
|
|
|
mst.setCreate_name(SecurityUtils.getCurrentNickName());
|
|
|
|
|
mst.setCreate_time(new Date());
|
|
|
|
|
mst.setCreate_time(DateUtil.now());
|
|
|
|
|
this.save(mst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void packageRow(StIvtIostorinvBcp mst, JSONObject row) {
|
|
|
|
|
mst.setMaterial_id(row.getString("material_id"));
|
|
|
|
|
mst.setPcsn(StringUtils.isNotEmpty(row.getString("pcsn"))? row.getString("pcsn"): DateUtil.today());
|
|
|
|
|
mst.setPcsn(StringUtils.isNotEmpty(row.getString("pcsn")) ? row.getString("pcsn") : DateUtil.today());
|
|
|
|
|
mst.setPlan_qty(row.getBigDecimal("plan_qty"));
|
|
|
|
|
mst.setQuality_scode(row.getString("quality_scode"));
|
|
|
|
|
mst.setBase_unit_id(row.getString("base_unit_id"));
|
|
|
|
|
@@ -118,17 +130,38 @@ public class StIvtIostorinvBcpServiceImpl extends ServiceImpl<StIvtIostorinvBcpM
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public String confirm(JSONObject form) {
|
|
|
|
|
Assert.notNull(new Object[]{form,form.get("iostorinv_id")},"请求参数不能为空");
|
|
|
|
|
Assert.notNull(new Object[]{form, form.get("iostorinv_id")}, "请求参数不能为空");
|
|
|
|
|
StIvtIostorinvBcp mst = this.getById(form.getString("iostorinv_id"));
|
|
|
|
|
checkParam(mst);
|
|
|
|
|
//checkParam(mst);
|
|
|
|
|
if (StringUtils.isEmpty(mst.getStruct_code())) {
|
|
|
|
|
throw new BadRequestException("当前入库单还未分配仓位!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mst.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
|
|
|
|
mst.setUpdate_time(new Date());
|
|
|
|
|
mst.setUpdate_time(DateUtil.now());
|
|
|
|
|
mst.setUpdate_id(SecurityUtils.getCurrentUserId());
|
|
|
|
|
mst.setUpdate_name(SecurityUtils.getCurrentNickName());
|
|
|
|
|
this.updateById(mst);
|
|
|
|
|
structivtBcpService.updateCashByParam(CHANGE_BILL_TYPE_ENUM.IOSTORINV_IN_CONFIRM,mst.getPlan_qty(),mst.getStruct_code());
|
|
|
|
|
|
|
|
|
|
structivtflowService.recordStructivtFlow(
|
|
|
|
|
//新增库存
|
|
|
|
|
structivtBcpService.save(StIvtStructivtBcp.builder()
|
|
|
|
|
.struct_id(mst.getStruct_id())
|
|
|
|
|
.struct_code(mst.getStruct_code())
|
|
|
|
|
.struct_name(mst.getStruct_name())
|
|
|
|
|
.material_id(mst.getMaterial_id())
|
|
|
|
|
.quality_scode(mst.getQuality_scode())
|
|
|
|
|
.pcsn(mst.getPcsn())
|
|
|
|
|
.ivt_level(mst.getIvt_level())
|
|
|
|
|
.is_active(mst.getIs_active())
|
|
|
|
|
.qty_unit_id(mst.getBase_unit_id())
|
|
|
|
|
.instorage_time(DateUtil.now())
|
|
|
|
|
.stor_id(mst.getStor_id())
|
|
|
|
|
.canuse_qty(mst.getPlan_qty())
|
|
|
|
|
.workshop_id(mst.getWorkshop_id())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*structivtflowService.recordStructivtFlow(
|
|
|
|
|
StIvtStructivtflowDto.builder()
|
|
|
|
|
.bill_code(mst.getBill_code()).change_type_scode(CHANGE_BILL_TYPE_ENUM.IOSTORINV_IN_CONFIRM).bill_table("st_ivt_iostorinv_bcp")
|
|
|
|
|
.material_id(mst.getMaterial_id()).pcsn(mst.getPcsn())
|
|
|
|
|
@@ -136,68 +169,72 @@ public class StIvtIostorinvBcpServiceImpl extends ServiceImpl<StIvtIostorinvBcpM
|
|
|
|
|
.task_id(mst.getTask_id())
|
|
|
|
|
.storagevehicle_code(mst.getStoragevehicle_code())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
);*/
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String confirmTask(JSONObject form) {
|
|
|
|
|
Assert.notNull(new Object[]{form,form.get("iostorinv_id")},"请求参数不能为空");
|
|
|
|
|
Assert.notNull(new Object[]{form, form.get("iostorinv_id")}, "请求参数不能为空");
|
|
|
|
|
StIvtIostorinvBcp mst = this.getById(form.getString("iostorinv_id"));
|
|
|
|
|
checkParam(mst);
|
|
|
|
|
//分配货位。下发任务,更新主单据状态。更新明细任务
|
|
|
|
|
List<StIvtStructivtBcp> struct_codes = structivtBcpService.allocationRules(1);
|
|
|
|
|
if (CollectionUtils.isEmpty(struct_codes)){
|
|
|
|
|
StIvtSectattr sect = sectattrService.getOne(new QueryWrapper<StIvtSectattr>().eq("sect_name", "半成品库区"));
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
jo.put("sect_id", sect.getSect_id());
|
|
|
|
|
jo.put("stor_id", sect.getStor_id());
|
|
|
|
|
jo.put("rule_type", RuleUtil.PRODUCTION_IN_1);
|
|
|
|
|
StIvtStructattr stIvtStructattr = divRuleCpService.divRuleIn(jo);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(stIvtStructattr)) {
|
|
|
|
|
throw new BadRequestException("无可分配货位");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
仓库信息:{
|
|
|
|
|
mst.setSect_id(stIvtStructattr.getSect_id());
|
|
|
|
|
mst.setSect_code(stIvtStructattr.getSect_code());
|
|
|
|
|
mst.setSect_name(stIvtStructattr.getSect_name());
|
|
|
|
|
mst.setStruct_id(stIvtStructattr.getStruct_id());
|
|
|
|
|
mst.setStruct_code(stIvtStructattr.getStruct_code());
|
|
|
|
|
mst.setStruct_name(stIvtStructattr.getStruct_name());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PointEvent event = PointEvent.builder()
|
|
|
|
|
.type(CHANGE_BILL_TYPE_ENUM.IOSTORINV_IN_SEND.getCode())
|
|
|
|
|
.point_code1(mst.getPoint_code())
|
|
|
|
|
.point_code2(struct_codes.get(0).getStruct_code())
|
|
|
|
|
.point_code2(stIvtStructattr.getStruct_code())
|
|
|
|
|
.callback((Consumer<String>) mst::setTask_id)
|
|
|
|
|
.build();
|
|
|
|
|
BussEventMulticaster.Publish(event);
|
|
|
|
|
|
|
|
|
|
mst.setBill_status(IOSEnum.BILL_STATUS.code("下发"));
|
|
|
|
|
mst.setUpdate_time(new Date());
|
|
|
|
|
mst.setWork_status(IOSEnum.WORK_STATUS.code("生成"));
|
|
|
|
|
mst.setBill_status(IOSEnum.BILL_STATUS.code("分配完"));
|
|
|
|
|
mst.setUpdate_time(DateUtil.now());
|
|
|
|
|
mst.setUpdate_id(SecurityUtils.getCurrentUserId());
|
|
|
|
|
mst.setUpdate_name(SecurityUtils.getCurrentNickName());
|
|
|
|
|
this.updateById(mst);
|
|
|
|
|
//更新库存
|
|
|
|
|
StIvtStructivtBcp struct = structivtBcpService.getOne(new QueryWrapper<StIvtStructivtBcp>().eq("struct_code", mst.getStruct_code()));
|
|
|
|
|
//插入库存变动表
|
|
|
|
|
structivtflowService.recordStructivtFlow(
|
|
|
|
|
StIvtStructivtflowDto.builder()
|
|
|
|
|
.bill_code(mst.getBill_code()).change_type_scode(CHANGE_BILL_TYPE_ENUM.IOSTORINV_IN_SEND).bill_table("st_ivt_iostorinv_bcp")
|
|
|
|
|
.material_id(mst.getMaterial_id()).pcsn(mst.getPcsn())
|
|
|
|
|
.struct_code(mst.getStruct_code()).result_qty(struct.getCanuse_qty()).change_qty(mst.getPlan_qty())
|
|
|
|
|
.task_id(mst.getTask_id())
|
|
|
|
|
.storagevehicle_code(mst.getStoragevehicle_code())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
return mst.getTask_id();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkParam(StIvtIostorinvBcp mst) {
|
|
|
|
|
if (mst == null || mst.getIs_delete()==true){
|
|
|
|
|
if (mst == null || mst.getIs_delete() == true) {
|
|
|
|
|
throw new BadRequestException("单据不存在");
|
|
|
|
|
}
|
|
|
|
|
if (!IOSEnum.BILL_STATUS.code("生成").equals(mst.getBill_status())){
|
|
|
|
|
throw new BadRequestException("单据"+ mst.getBill_code()+"状态不是生成状态");
|
|
|
|
|
if (!IOSEnum.BILL_STATUS.code("生成").equals(mst.getBill_status())) {
|
|
|
|
|
throw new BadRequestException("单据" + mst.getBill_code() + "状态不是生成状态");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public String updateBill(JSONObject form) {
|
|
|
|
|
Assert.notNull(new Object[]{form,form.get("iostorinv_id")},"请求参数不能为空");
|
|
|
|
|
Assert.notNull(new Object[]{form, form.get("iostorinv_id")}, "请求参数不能为空");
|
|
|
|
|
StIvtIostorinvBcp mst = form.toJavaObject(StIvtIostorinvBcp.class);
|
|
|
|
|
mst.setUpdate_id(SecurityUtils.getCurrentUserId());
|
|
|
|
|
mst.setUpdate_name(SecurityUtils.getCurrentNickName());
|
|
|
|
|
mst.setUpdate_time(new Date());
|
|
|
|
|
mst.setUpdate_time(DateUtil.now());
|
|
|
|
|
for (Object item : form.getJSONArray("tableData")) {
|
|
|
|
|
packageRow(mst,(JSONObject)item);
|
|
|
|
|
packageRow(mst, (JSONObject) item);
|
|
|
|
|
}
|
|
|
|
|
this.updateById(mst);
|
|
|
|
|
return mst.getIostorinv_id();
|
|
|
|
|
|