add: 出库强制确认

This commit is contained in:
2023-05-26 15:56:06 +08:00
parent ce340a9951
commit 5dc0a51695
17 changed files with 625 additions and 104 deletions

View File

@@ -6,6 +6,7 @@ import java.util.Date;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
@@ -17,6 +18,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("md_pb_storagevehicleext")
public class MdPbStoragevehicleext implements Serializable {

View File

@@ -72,10 +72,10 @@ public class SectattrController {
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getSect")
@PostMapping("/getSect")
@Log("查询库区下拉框")
@ApiOperation("查询库区下拉框")
public ResponseEntity<Object> querySect(@RequestBody(required = false) JSONObject query) {
public ResponseEntity<Object> querySect(@RequestBody JSONObject query) {
List<Map> list = isectattrService.getSect(query);
return new ResponseEntity<>(TableDataInfo.build(list), HttpStatus.OK);
}

View File

@@ -9,6 +9,7 @@ import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
@@ -19,6 +20,7 @@ import lombok.EqualsAndHashCode;
* @since 2023-05-11
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@TableName("sch_base_task")
public class SchBaseTask implements Serializable {

View File

@@ -78,5 +78,29 @@ public class IStivtlostorivnCpOutController {
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/allCancel")
@Log("全部取消")
@ApiOperation("全部取消")
public ResponseEntity<Object> allCancel(@RequestBody JSONObject whereJson){
iStIvtIostorinvCpOutService.allCancel(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/setPoint")
@Log("设置站点")
@ApiOperation("设置站点")
public ResponseEntity<Object> setPoint(@RequestBody JSONObject whereJson){
iStIvtIostorinvCpOutService.setPoint(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/confirm")
@Log("强制确认")
@ApiOperation("强制确认")
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson){
iStIvtIostorinvCpOutService.confirm(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -94,4 +94,32 @@ public interface IStIvtIostorinvCpOutService extends IService<StIvtIostorinvCp>
* }
*/
void allDivIvt(JSONObject whereJson);
/**
* 全部取消
* @param whereJson
* {
* iostorinv_id : 主表标识,
* iostorinvdtl_id : 明细标识,
* }
*/
void allCancel(JSONObject whereJson);
/**
* 设置站点
* @param whereJson
* {
* iostorinvdis_id : 分配标识
* }
*/
void setPoint(JSONObject whereJson);
/**
* 强制确认
* @param whereJson
* {
* iostorinv_id : 主表标识
* }
*/
void confirm(JSONObject whereJson);
}

View File

@@ -104,7 +104,6 @@ public class StIvtIostorinvdisCp implements Serializable {
/**
* 执行状态
*/
@Deprecated
private String work_status;
/**

View File

@@ -3,6 +3,7 @@ package org.nl.wms.storage_manage.productmanage.service.iostorInv.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -11,6 +12,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jetbrains.annotations.NotNull;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.publish.BussEventMulticaster;
import org.nl.common.publish.event.PointEvent;
import org.nl.common.utils.IdUtil;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
@@ -18,18 +21,24 @@ import org.nl.modules.system.util.CodeUtil;
import org.nl.wms.masterdata_manage.service.vehicle.IMdPbBucketrecordService;
import org.nl.wms.masterdata_manage.service.vehicle.IMdPbStoragevehicleextService;
import org.nl.wms.masterdata_manage.service.vehicle.IMdPbStoragevehicleinfoService;
import org.nl.wms.masterdata_manage.service.vehicle.dao.MdPbStoragevehicleext;
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.masterdata_manage.storage.service.storage.dao.StIvtStructattr;
import org.nl.wms.product_manage.sch.manage.TaskStatusEnum;
import org.nl.wms.scheduler_manage.service.point.ISchBasePointService;
import org.nl.wms.scheduler_manage.service.point.dao.SchBasePoint;
import org.nl.wms.scheduler_manage.service.task.ISchBaseTaskService;
import org.nl.wms.scheduler_manage.service.task.dao.SchBaseTask;
import org.nl.wms.storage_manage.CHANGE_BILL_TYPE_ENUM;
import org.nl.wms.storage_manage.IOSEnum;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.IStIvtIostorinvCpOutService;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.IStIvtIostorinvdisCpService;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.IStIvtIostorinvdisdtlCpService;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.IStIvtIostorinvdtlCpService;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.dao.StIvtIostorinvCp;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.dao.StIvtIostorinvdisCp;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.dao.StIvtIostorinvdtlCp;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.dao.mapper.StIvtIostorinvCpMapper;
import org.nl.wms.storage_manage.productmanage.service.iostorInv.dto.IostorInvQuery;
@@ -47,6 +56,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
/**
* <p>
@@ -185,11 +195,29 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
StIvtIostorinvCp mstDao = this.getById(whereJson.getString("iostorinv_id"));
// 1.查找出所有需要分配的明细
List<StIvtIostorinvdtlCp> dtlDaoList = iostorinvdtlCpService.list(
new QueryWrapper<StIvtIostorinvdtlCp>().lambda()
.eq(StIvtIostorinvdtlCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
.orderByAsc(StIvtIostorinvdtlCp::getSeq_no)
);
List<StIvtIostorinvdtlCp> dtlDaoList = new ArrayList<>();
if (whereJson.getBoolean("type")) {
dtlDaoList = iostorinvdtlCpService.list(
new QueryWrapper<StIvtIostorinvdtlCp>().lambda()
.eq(StIvtIostorinvdtlCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
.lt(StIvtIostorinvdtlCp::getBill_status, IOSEnum.BILL_STATUS.code("分配完"))
.orderByAsc(StIvtIostorinvdtlCp::getSeq_no)
);
} else {
dtlDaoList = iostorinvdtlCpService.list(
new QueryWrapper<StIvtIostorinvdtlCp>().lambda()
.eq(StIvtIostorinvdtlCp::getIostorinvdtl_id, whereJson.getString("iostorinvdtl_id"))
.lt(StIvtIostorinvdtlCp::getBill_status, IOSEnum.BILL_STATUS.code("分配完"))
.orderByAsc(StIvtIostorinvdtlCp::getSeq_no)
);
if (ObjectUtil.isNotEmpty(mstDao))
mstDao = this.getById(dtlDaoList.get(0).getIostorinv_id());
}
if (ObjectUtil.isEmpty(mstDao))
throw new BadRequestException("没有可分配的库存!");
// 2.找库存
for (StIvtIostorinvdtlCp dtlDao : dtlDaoList) {
@@ -200,7 +228,11 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
param.put("sect_id", whereJson.getString("sect_id"));
param.put("material_id", dtlDao.getMaterial_id());
param.put("sale_id", dtlDao.getSource_billdtl_id());
param.put("rule_type", RuleUtil.PRODUCTION_OUT_1);
if (ObjectUtil.isEmpty(dtlDao.getSource_billdtl_id())) {
param.put("rule_type", RuleUtil.PRODUCTION_OUT_2);
} else {
param.put("rule_type", RuleUtil.PRODUCTION_OUT_1);
}
List<StIvtStructivtCp> ivtList = new ArrayList<>(); // 需要更新库存、仓位、插入分配明细的集合
@@ -229,7 +261,7 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
iostorinvdtlCpService.updateById(dtlDao);
// 5.更新库存冻结数 、 锁定仓位
updateIvt(ivtList,mstDao);
updateIvtDiv(ivtList,mstDao);
// 6.更新主表
updateMst(mstDao.getIostorinv_id());
@@ -237,6 +269,197 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
}
@Override
@Transactional(rollbackFor = Exception.class)
public void allCancel(JSONObject whereJson) {
/*
* 1.查找出所有需要取消分配的明细
* 2.删除生成状态中的任务
* 3.更新库存
* 4.更新仓位
* 5.删除分配明细
* 6.更新明细
* 7.更新主表
*
*/
// 1.找出所有分配
List<StIvtIostorinvdisCp> disDaoList = new ArrayList<>();
if (whereJson.getBoolean("type")) {
disDaoList = iostorinvdisCpService.list(
new QueryWrapper<StIvtIostorinvdisCp>().lambda()
.eq(StIvtIostorinvdisCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
.orderByAsc(StIvtIostorinvdisCp::getSeq_no)
);
} else {
disDaoList = iostorinvdisCpService.list(
new QueryWrapper<StIvtIostorinvdisCp>().lambda()
.eq(StIvtIostorinvdisCp::getIostorinvdtl_id, whereJson.getString("iostorinvdtl_id"))
.orderByAsc(StIvtIostorinvdisCp::getSeq_no)
);
}
if (ObjectUtil.isEmpty(disDaoList))
throw new BadRequestException("没有可取消的分配!");
// 判断是否有已经有正在执行中的任务
boolean is_create_task = disDaoList.stream()
.anyMatch(row -> Integer.parseInt(row.getWork_status()) > Integer.parseInt(IOSEnum.WORK_STATUS.code("生成")));
if (is_create_task) throw new BadRequestException("任务已执行或已完成,不可取消!");
// 2.更新库存,删除任务
for (StIvtIostorinvdisCp disDao : disDaoList) {
// 更新库存、更新仓位
updateIvtUnDiv(disDao,ChangeIvtUtil.SUBFROZEN_ADDIVT_QTY);
// 删除任务
iSchBaseTaskService.update(
new SchBaseTask()
.setIs_delete(true),
new QueryWrapper<SchBaseTask>().lambda()
.eq(SchBaseTask::getTask_id, disDao.getTask_id())
);
// 3.删除分配
iostorinvdisCpService.removeById(disDao.getIostorinvdis_id());
}
// 4.更新明细
if (!whereJson.getBoolean("type")) {
StIvtIostorinvdtlCp dtlDao = iostorinvdtlCpService.getById(whereJson.getString("iostorinvdtl_id"));
dtlDao.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
dtlDao.setAssign_qty(BigDecimal.valueOf(0));
dtlDao.setUnassign_qty(dtlDao.getReal_qty());
iostorinvdtlCpService.updateById(dtlDao);
// 5.更新主表
updateMst(dtlDao.getIostorinv_id());
} else {
List<StIvtIostorinvdtlCp> dtlDaoList = iostorinvdtlCpService.list(
new QueryWrapper<StIvtIostorinvdtlCp>().lambda()
.eq(StIvtIostorinvdtlCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
);
for (StIvtIostorinvdtlCp dtlDao : dtlDaoList) {
dtlDao.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
dtlDao.setAssign_qty(BigDecimal.valueOf(0));
dtlDao.setUnassign_qty(dtlDao.getReal_qty());
iostorinvdtlCpService.updateById(dtlDao);
}
// 5.更新主表
updateMst(whereJson.getString("iostorinv_id"));
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void setPoint(JSONObject whereJson) {
/*
* 1.生成任务
* 2.更新分配状态
*/
// 1.校验是否设置过起点
StIvtIostorinvdisCp disDao = iostorinvdisCpService.getById(whereJson.getString("iostorinvdis_id"));
if (ObjectUtil.isNotEmpty(disDao.getPoint_id())) throw new BadRequestException("此明细已生成任务!");
// 2.下发任务
SchBasePoint pointDao = iSchBasePointService.getOne(
new QueryWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, whereJson.getString("point_code"))
);
PointEvent event = PointEvent.builder()
.type(CHANGE_BILL_TYPE_ENUM.IOSTORINV_IN_SEND.getCode())
.point_code1(disDao.getStruct_code())
.point_code2(pointDao.getPoint_code())
.callback((Consumer<String>) disDao::setTask_id)
.build();
BussEventMulticaster.Publish(event);
// 3.更新分配表
iostorinvdisCpService.updateById(
disDao.setPoint_id(pointDao.getPoint_id())
.setPoint_code(pointDao.getPoint_code())
.setPoint_name(pointDao.getPoint_name())
.setWork_status(IOSEnum.WORK_STATUS.code("生成"))
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void confirm(JSONObject whereJson) {
// 1.更新主表为完成
StIvtIostorinvCp mstDao = this.getById(whereJson.getString("iostorinv_id"));
mstDao.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
mstDao.setConfirm_id(SecurityUtils.getCurrentUserId());
mstDao.setConfirm_name(SecurityUtils.getCurrentNickName());
mstDao.setConfirm_time(DateUtil.now());
this.updateById(mstDao);
// 2.判断所有明细是否为分配完
List<StIvtIostorinvdtlCp> dtlDaoList = iostorinvdtlCpService.list(
new QueryWrapper<StIvtIostorinvdtlCp>().lambda()
.eq(StIvtIostorinvdtlCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
);
boolean is_dis = dtlDaoList.stream()
.anyMatch(row -> row.getBill_status().equals(IOSEnum.BILL_STATUS.code("分配完")));
if (!is_dis) throw new BadRequestException("请先分配单据!");
// 3.更新明细表为完成
iostorinvdtlCpService.update(
new StIvtIostorinvdtlCp()
.setBill_status(IOSEnum.BILL_STATUS.code("完成")),
new QueryWrapper<StIvtIostorinvdtlCp>().lambda()
.eq(StIvtIostorinvdtlCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
);
// 4.更新任务为完成、更新库存、解锁点位
List<StIvtIostorinvdisCp> disDaoList = iostorinvdisCpService.list(
new QueryWrapper<StIvtIostorinvdisCp>().lambda()
.eq(StIvtIostorinvdisCp::getIostorinv_id, whereJson.getString("iostorinv_id"))
);
for (StIvtIostorinvdisCp dao : disDaoList) {
// 1更新任务为完成
SchBaseTask taskDao = iSchBaseTaskService.getById(dao.getTask_id());
if (ObjectUtil.isNotEmpty(taskDao)) {
// 更新有任务分配
if (!StrUtil.equals(taskDao.getTask_id(), TaskStatusEnum.FINISHED.getCode())) {
taskDao.setTask_status(TaskStatusEnum.FINISHED.getCode());
iSchBaseTaskService.updateById(taskDao);
}
}
// 2更新库存
StIvtIostorinvdtlCp dtlDao = dtlDaoList.stream()
.filter(row -> row.getIostorinvdtl_id().equals(dao.getIostorinvdtl_id()))
.findAny().get();
iStIvtStructivtCpService.UpdateIvt(ivtDataParam(dao,ChangeIvtUtil.SUBFROZEN_SUBIVT_QTY,dtlDao.getSource_billdtl_id()));
// 3解锁终点
unLockNext(dao.getStruct_id());
// 4) 更新载具扩展属性
iMdPbStoragevehicleextService.update(
new MdPbStoragevehicleext()
.setMaterial_id(""),
new QueryWrapper<MdPbStoragevehicleext>().lambda()
.eq(MdPbStoragevehicleext::getStoragevehicle_code,dao.getStoragevehicle_code())
);
}
}
@NotNull
private StIvtIostorinvCp packageMstForm(StIvtIostorinvCp stIvtIostorinvCp,JSONObject whereJson,Boolean isUpdate) {
JSONArray rows = whereJson.getJSONArray("tableData");
@@ -329,8 +552,9 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
this.updateById(mstDao);
}
private void updateIvt(List<StIvtStructivtCp> ivtList,StIvtIostorinvCp mstDao) {
private void updateIvtDiv(List<StIvtStructivtCp> ivtList,StIvtIostorinvCp mstDao) {
/*
入库分配
更新库存冻结数
*/
for (StIvtStructivtCp ivtDao : ivtList) {
@@ -359,4 +583,64 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
}
}
private void updateIvtUnDiv(StIvtIostorinvdisCp dao, String type) {
/*
出库取消
更新库存冻结数
*/
StIvtIostorinvdtlCp dtlDao = iostorinvdtlCpService.getById(dao.getIostorinvdtl_id());
// 更新库存
JSONObject param = new JSONObject();
param.put("struct_id", dao.getStruct_id());
param.put("material_id", dao.getMaterial_id());
param.put("pcsn", dao.getPcsn());
param.put("ivt_level", dao.getIvt_level());
param.put("quality_scode", dao.getQuality_scode());
param.put("change_qty", dao.getReal_qty());
param.put("sale_id", dtlDao.getSource_billdtl_id());
param.put("change_type", type);
iStIvtStructivtCpService.UpdateIvt(param);
// 解锁仓位
iStIvtStructattrService.update(
new StIvtStructattr()
.setLock_type("1") // TODO 暂时写死
.setInv_id("")
.setInv_type("")
.setInv_code(""),
new QueryWrapper<StIvtStructattr>().lambda()
.eq(StIvtStructattr::getStruct_id, dao.getStruct_id())
);
}
public JSONObject ivtDataParam(StIvtIostorinvdisCp disDao,String change_type,String sale_id) {
JSONObject ivtParam = new JSONObject();
ivtParam.put("struct_id", disDao.getStruct_id());
ivtParam.put("material_id", disDao.getMaterial_id());
ivtParam.put("pcsn", disDao.getPcsn());
ivtParam.put("quality_scode", disDao.getQuality_scode());
ivtParam.put("ivt_level", disDao.getIvt_level());
ivtParam.put("change_qty", disDao.getReal_qty());
ivtParam.put("change_type", change_type);
ivtParam.put("sale_id", sale_id);
return ivtParam;
}
public void unLockNext(String struct_id) {
StIvtStructattr attrDao = iStIvtStructattrService.getById(struct_id);
if (ObjectUtil.isEmpty(attrDao)) throw new BadRequestException("仓位不存在!");
attrDao.setInv_code("");
attrDao.setInv_type("");
attrDao.setInv_id("");
attrDao.setStoragevehicle_code("");
attrDao.setLock_type("1");
iStIvtStructattrService.updateById(attrDao);
}
}

View File

@@ -431,12 +431,12 @@ public class StIvtIostorinvCpServiceImpl extends ServiceImpl<StIvtIostorinvCpMap
);
// 3.更新任务
// iSchBaseTaskService.update(
// new SchBaseTask().setIs_delete(true),
// new QueryWrapper<SchBaseTask>().lambda()
// .eq(SchBaseTask::getTask_id, disDao.getTask_id())
// .lt(SchBaseTask::getTask_status, TaskStatusEnum.ISSUE.getCode())
// );
iSchBaseTaskService.update(
new SchBaseTask().setIs_delete(true),
new QueryWrapper<SchBaseTask>().lambda()
.eq(SchBaseTask::getTask_id, disDao.getTask_id())
.lt(SchBaseTask::getTask_status, TaskStatusEnum.ISSUE.getCode())
);
// 解锁货位
iStIvtStructattrService.update(
@@ -459,6 +459,7 @@ public class StIvtIostorinvCpServiceImpl extends ServiceImpl<StIvtIostorinvCpMap
.setSect_code("").setSect_name("")
.setPoint_id("").setPoint_code("")
.setPoint_name("")
.setWork_status(IOSEnum.WORK_STATUS.code("生成"))
);
// 5.更新明细
@@ -503,8 +504,8 @@ public class StIvtIostorinvCpServiceImpl extends ServiceImpl<StIvtIostorinvCpMap
PointEvent event = PointEvent.builder()
.type(CHANGE_BILL_TYPE_ENUM.IOSTORINV_IN_SEND.getCode())
.point_code1(disDao.getStruct_code())
.point_code2(pointDao.getPoint_code())
.point_code2(disDao.getStruct_code())
.point_code1(pointDao.getPoint_code())
.callback((Consumer<String>) disDao::setTask_id)
.build();
BussEventMulticaster.Publish(event);
@@ -514,6 +515,7 @@ public class StIvtIostorinvCpServiceImpl extends ServiceImpl<StIvtIostorinvCpMap
disDao.setPoint_id(pointDao.getPoint_id())
.setPoint_code(pointDao.getPoint_code())
.setPoint_name(pointDao.getPoint_name())
.setWork_status(IOSEnum.WORK_STATUS.code("生成"))
);
}

View File

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
/**
* <p>
@@ -64,6 +65,14 @@ public class StIvtStructivtCpServiceImpl extends ServiceImpl<StIvtStructivtCpMap
// 加冻结、减可用
addFrozenSubQty(json);
break;
case ChangeIvtUtil.SUBFROZEN_ADDIVT_QTY:
// 减冻结、加可用
subFrozenAddQty(json);
break;
case ChangeIvtUtil.SUBFROZEN_SUBIVT_QTY:
// 减冻结、减库存
subFrozenSubQty(json);
break;
default:
throw new BadRequestException("变动类型异常!");
}
@@ -191,12 +200,22 @@ public class StIvtStructivtCpServiceImpl extends ServiceImpl<StIvtStructivtCpMap
*/
private void addFrozenSubQty(JSONObject json) {
// 找到对应库存
StIvtStructivtCp ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getSale_id,json.getString("sale_id"))
);
StIvtStructivtCp ivtDao = new StIvtStructivtCp();
if (ObjectUtil.isEmpty(json.getString("sale_id"))) {
ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getPcsn, json.getString("pcsn"))
);
} else {
ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getSale_id,json.getString("sale_id"))
);
}
if (ObjectUtil.isEmpty(ivtDao)) throw new BadRequestException("库存异常,请检查!");
@@ -212,6 +231,84 @@ public class StIvtStructivtCpServiceImpl extends ServiceImpl<StIvtStructivtCpMap
this.updateById(ivtDao);
}
/*
减冻结、加可用
*/
private void subFrozenAddQty(JSONObject json) {
// 找到对应库存
StIvtStructivtCp ivtDao = new StIvtStructivtCp();
if (ObjectUtil.isEmpty(json.getString("sale_id"))) {
ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getPcsn, json.getString("pcsn"))
);
} else {
ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getSale_id,json.getString("sale_id"))
);
}
if (ObjectUtil.isEmpty(ivtDao)) throw new BadRequestException("库存异常,请检查!");
// 冻结数
double frozen_qty = NumberUtil.sub(ivtDao.getFrozen_qty().doubleValue(), json.getDoubleValue("change_qty"));
// 可用数
double canuse_qty = NumberUtil.add(ivtDao.getCanuse_qty().doubleValue(), json.getDoubleValue("change_qty"));
if (frozen_qty < 0) throw new BadRequestException("库存异常,请检查!");
ivtDao.setCanuse_qty(BigDecimal.valueOf(canuse_qty));
ivtDao.setFrozen_qty(BigDecimal.valueOf(frozen_qty));
this.updateById(ivtDao);
}
/*
减冻结、减库存
*/
private void subFrozenSubQty(JSONObject json) {
// 找到对应库存
StIvtStructivtCp ivtDao = new StIvtStructivtCp();
if (ObjectUtil.isEmpty(json.getString("sale_id"))) {
ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getPcsn, json.getString("pcsn"))
);
} else {
ivtDao = this.getOne(
new QueryWrapper<StIvtStructivtCp>().lambda()
.eq(StIvtStructivtCp::getStruct_id, json.getString("struct_id"))
.eq(StIvtStructivtCp::getMaterial_id, json.getString("material_id"))
.eq(StIvtStructivtCp::getSale_id,json.getString("sale_id"))
);
}
if (ObjectUtil.isEmpty(ivtDao)) throw new BadRequestException("库存异常,请检查!");
// 冻结数
double frozen_qty = NumberUtil.sub(ivtDao.getFrozen_qty().doubleValue(), json.getDoubleValue("change_qty"));
// 库存数
double ivt_qty = NumberUtil.sub(ivtDao.getIvt_qty().doubleValue(), json.getDoubleValue("change_qty"));
if (frozen_qty < 0) throw new BadRequestException("库存异常,请检查!");
if (frozen_qty == 0 && ivtDao.getCanuse_qty().doubleValue() == 0 && ivt_qty == 0 && ivtDao.getWarehousing_qty().doubleValue() == 0) {
// 删除
this.removeById(ivtDao.getStockrecord_id());
} else {
ivtDao.setFrozen_qty(BigDecimal.valueOf(frozen_qty));
ivtDao.setIvt_qty(BigDecimal.valueOf(ivt_qty));
this.updateById(ivtDao);
}
}
/*
校验数据
*/

View File

@@ -22,5 +22,15 @@ public class ChangeIvtUtil {
*/
public static final String ADDFROZEN_SUBIVT_QTY = "4";
/*
* 减冻结、加可用
*/
public static final String SUBFROZEN_ADDIVT_QTY = "5";
/*
* 减冻结、减库存
*/
public static final String SUBFROZEN_SUBIVT_QTY = "6";
}

View File

@@ -14,5 +14,11 @@ public class RuleUtil {
*/
public static final String PRODUCTION_OUT_1 = "out_1";
/*
* 出库分配:
* 根据 仓库、库区、物料找库存
*/
public static final String PRODUCTION_OUT_2 = "out_2";
}

View File

@@ -77,6 +77,11 @@ public class DivRuleCpServiceImpl implements DivRuleCpService {
throw new BadRequestException("销售单不能为空");
ivtDao = iStIvtStructivtCpService.queryIvtOutOne(whereJson);
break;
case RuleUtil.PRODUCTION_OUT_2 :
if (ObjectUtil.isEmpty(whereJson.getString("material_id")))
throw new BadRequestException("物料不能为空");
ivtDao = iStIvtStructivtCpService.queryIvtOutOne(whereJson);
break;
}
return ivtDao;