opt: 1.出库分配
This commit is contained in:
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext;
|
||||
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@@ -29,7 +30,13 @@ public interface MdPbStoragevehicleextMapper extends BaseMapper<MdPbStoragevehic
|
||||
*/
|
||||
IPage<JSONObject> getCanuseIvt(Page<JSONObject> page, @Param("param") Map whereJson);
|
||||
|
||||
BigDecimal queryCanuseSumByPcsn(@Param("pcsn") String pcsn);
|
||||
/**
|
||||
* 根据批次和物料查看可用库存总和
|
||||
* @param pcsn
|
||||
* @param material_id
|
||||
* @return
|
||||
*/
|
||||
BigDecimal queryCanuseSum(@Param("pcsn") String pcsn,@Param("material_id") String material_id);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
@@ -50,6 +57,14 @@ public interface MdPbStoragevehicleextMapper extends BaseMapper<MdPbStoragevehic
|
||||
*/
|
||||
List<JSONObject> erpQueryIvt(@Param("param") JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 出库分配查询货位信息
|
||||
* @param pcsn
|
||||
* @param material_id
|
||||
* @return
|
||||
*/
|
||||
List<MdPbStoragevehicleextDto> queryOutAllocation(@Param("pcsn") String pcsn,@Param("material_id") String material_id);
|
||||
|
||||
/**
|
||||
* 手持出库确认查询明细
|
||||
* @param whereJson {
|
||||
|
||||
@@ -108,15 +108,32 @@
|
||||
ORDER BY ext.insert_time Desc
|
||||
</select>
|
||||
|
||||
<select id="queryCanuseSumByPcsn" resultType="java.math.BigDecimal">
|
||||
<select id="queryCanuseSum" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
SUM(canuse_qty)
|
||||
FROM
|
||||
md_pb_storagevehicleext
|
||||
md_pb_storagevehicleext ex
|
||||
LEFT JOIN st_ivt_structattr st on ex.storagevehicle_code = st.storagevehicle_code
|
||||
<where>
|
||||
pcsn = #{pcsn}
|
||||
ex.material_id = #{material_id}
|
||||
<if test="pcsn!= null and pcsn!= ''">
|
||||
AND
|
||||
ex.pcsn = #{pcsn}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY ext.insert_time Desc
|
||||
</select>
|
||||
|
||||
<select id="queryOutAllocation" resultType="org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto">
|
||||
SELECT ex.*,st.sect_id,st.sect_code,st.sect_name,st.struct_id,st.struct_code,st.struct_name
|
||||
FROM md_pb_storagevehicleext ex LEFT JOIN st_ivt_structattr st on ex.storagevehicle_code = st.storagevehicle_code
|
||||
<where>
|
||||
material_id = #{material_id}
|
||||
<if test="pcsn!= null and pcsn!= ''">
|
||||
AND
|
||||
pcsn = #{pcsn}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY ex.insert_time,ex.canuse_qty
|
||||
</select>
|
||||
|
||||
<select id="erpQueryIvt" resultType="com.alibaba.fastjson.JSONObject">
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.nl.wms.basedata_manage.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/5
|
||||
*/
|
||||
@Data
|
||||
public class MdPbStoragevehicleextDto extends MdPbStoragevehicleext{
|
||||
|
||||
/**
|
||||
* 库区标识
|
||||
*/
|
||||
private String sect_id;
|
||||
|
||||
/**
|
||||
* 库区编码
|
||||
*/
|
||||
private String sect_code;
|
||||
|
||||
/**
|
||||
* 库区名称
|
||||
*/
|
||||
private String sect_name;
|
||||
|
||||
/**
|
||||
* 仓位标识
|
||||
*/
|
||||
private String struct_id;
|
||||
|
||||
/**
|
||||
* 仓位编码
|
||||
*/
|
||||
private String struct_code;
|
||||
|
||||
/**
|
||||
* 仓位名称
|
||||
*/
|
||||
private String struct_name;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
|
||||
.set(Structattr::getInv_id,jsonObject.getString("inv_id"))
|
||||
.set(Structattr::getInv_code,jsonObject.getString("inv_code"))
|
||||
.set(Structattr::getInv_type,jsonObject.getString("inv_type"))
|
||||
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("入库锁"))
|
||||
.set(Structattr::getLock_type, jsonObject.getString("lock_type"))
|
||||
.eq(Structattr::getStruct_code,jsonObject.getString("struct_code"))
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -64,4 +64,25 @@ public class OutBillController {
|
||||
iOutBillService.allDiv(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/allCancel")
|
||||
@Log("出库单全部取消")
|
||||
public ResponseEntity<Object> allCancel(@RequestBody JSONObject whereJson) {
|
||||
iOutBillService.allCancel(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/autoDiv")
|
||||
@Log("出库单自动分配")
|
||||
public ResponseEntity<Object> autoDiv(@RequestBody JSONObject whereJson) {
|
||||
iOutBillService.autoDiv(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/autoCancel")
|
||||
@Log("出库单自动取消分配")
|
||||
public ResponseEntity<Object> autoCancel(@RequestBody JSONObject whereJson) {
|
||||
iOutBillService.autoCancel(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,4 +75,23 @@ public interface IOutBillService extends IService<IOStorInv> {
|
||||
*/
|
||||
void allDiv(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 全部取消
|
||||
*
|
||||
* @param whereJson /
|
||||
*/
|
||||
void allCancel(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
*
|
||||
* 自动分配 单条出库单明细
|
||||
* @param whereJson
|
||||
*/
|
||||
void autoDiv(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 自动取消分配 单条出库单明细
|
||||
* @param whereJson
|
||||
*/
|
||||
void autoCancel(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class IOStorInvDis implements Serializable {
|
||||
/**
|
||||
* 计划数量
|
||||
*/
|
||||
private String plan_qty;
|
||||
private BigDecimal plan_qty;
|
||||
|
||||
/**
|
||||
* 实际数量
|
||||
|
||||
@@ -82,13 +82,11 @@
|
||||
dtl.*,
|
||||
mb.material_code,
|
||||
mb.material_name,
|
||||
mst.bill_code,
|
||||
gp.storagevehicle_code
|
||||
mst.bill_code
|
||||
FROM
|
||||
st_ivt_iostorinvdtl dtl
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = dtl.material_id
|
||||
LEFT JOIN ST_IVT_IOStorInv mst ON mst.iostorinv_id = dtl.iostorinv_id
|
||||
LEFT JOIN md_pb_groupplate gp ON gp.pcsn = dtl.pcsn
|
||||
where
|
||||
1=1
|
||||
<if test="params.bill_code != null and params.bill_code != ''">
|
||||
|
||||
@@ -7,6 +7,8 @@ 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.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -18,11 +20,16 @@ import org.nl.config.IdUtil;
|
||||
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
|
||||
import org.nl.wms.basedata_manage.service.IBsrealStorattrService;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.BsrealStorattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
|
||||
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_management.service.IOutBillService;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInvDis;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper;
|
||||
@@ -50,6 +57,12 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
@Resource
|
||||
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||
|
||||
@Resource
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
@Resource
|
||||
private IMdPbStoragevehicleextService iMdPbStoragevehicleextService;
|
||||
|
||||
/**
|
||||
* 载具扩展属性mapper
|
||||
*/
|
||||
@@ -245,8 +258,10 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void allDiv(JSONObject whereJson) {
|
||||
|
||||
//定义需要更新的仓位集合
|
||||
HashMap<String, JSONObject> Struct_map = new HashMap<String, JSONObject>();
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||
|
||||
//查询主表信息
|
||||
@@ -255,12 +270,219 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
throw new BadRequestException("查不到出库单信息");
|
||||
}
|
||||
|
||||
String bill_type = ioStorInv.getBill_type();
|
||||
//查询生成和未分配完的明细
|
||||
JSONObject queryDtl = new JSONObject();
|
||||
queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完"));
|
||||
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
queryDtl.put("iostorinv_id", iostorinv_id);
|
||||
List<IOStorInvDtlDto> dtls = ioStorInvMapper.getIODtl(queryDtl);
|
||||
// List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDtl.class)
|
||||
// .le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完"))
|
||||
// .gt(IOStorInvDtl::getUnassign_qty,0)
|
||||
// .eq(IOStorInvDtl::getIostorinv_id, iostorinv_id));
|
||||
if (ObjectUtil.isEmpty(dtls)) {
|
||||
throw new BadRequestException("当前订单无可分配出库明细");
|
||||
}
|
||||
|
||||
for (int i = 0; i < dtls.size(); i++) {
|
||||
IOStorInvDtlDto dtl = dtls.get(i);
|
||||
double unassign_qty = dtl.getUnassign_qty().doubleValue();
|
||||
String pcsn = dtl.getPcsn();
|
||||
String material_id = dtl.getMaterial_id();
|
||||
|
||||
// 根据物料和批次号查询库存可用
|
||||
BigDecimal canuseSum = mdPbStoragevehicleextMapper.queryCanuseSum(pcsn,material_id);
|
||||
|
||||
if (canuseSum.doubleValue()<unassign_qty){
|
||||
throw new BadRequestException("物料编号:"+ dtl.getMaterial_code() +"出库分配数量不满足");
|
||||
}
|
||||
|
||||
/*
|
||||
* 分配规则:
|
||||
* 1.按批次先进先出
|
||||
* 2.相同批次载具量小优先
|
||||
*/
|
||||
|
||||
//出库分配查询货位信息
|
||||
List<MdPbStoragevehicleextDto> outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id);
|
||||
|
||||
int seq_no = 1;
|
||||
for (MdPbStoragevehicleextDto outAllocation : outAllocationList) {
|
||||
//分配明细
|
||||
IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
||||
ioStorInvDis.setIostorinv_id(dtl.getIostorinv_id());
|
||||
ioStorInvDis.setIostorinvdtl_id(dtl.getIostorinvdtl_id());
|
||||
ioStorInvDis.setSeq_no((seq_no++)+"");
|
||||
ioStorInvDis.setSect_id(outAllocation.getSect_id());
|
||||
ioStorInvDis.setPcsn(outAllocation.getPcsn());
|
||||
ioStorInvDis.setMaterial_id(material_id);
|
||||
ioStorInvDis.setSect_name(outAllocation.getSect_name());
|
||||
ioStorInvDis.setSect_code(outAllocation.getSect_code());
|
||||
ioStorInvDis.setStruct_id(outAllocation.getStruct_id());
|
||||
ioStorInvDis.setStruct_name(outAllocation.getStruct_name());
|
||||
ioStorInvDis.setStruct_code(outAllocation.getStruct_code());
|
||||
ioStorInvDis.setStoragevehicle_code(outAllocation.getStoragevehicle_code());
|
||||
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
ioStorInvDis.setQty_unit_id(outAllocation.getQty_unit_id());
|
||||
ioStorInvDis.setQty_unit_name(outAllocation.getQty_unit_name());
|
||||
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("生成"));
|
||||
|
||||
// 未分配数量 - 该库位上的可用数量 < 0 目前做整出
|
||||
unassign_qty = unassign_qty-outAllocation.getCanuse_qty().doubleValue();
|
||||
if (unassign_qty<0){
|
||||
unassign_qty=0;
|
||||
}
|
||||
ioStorInvDis.setPlan_qty(outAllocation.getCanuse_qty());
|
||||
|
||||
//锁定货位
|
||||
JSONObject lock_map = new JSONObject();
|
||||
lock_map.put("struct_code", outAllocation.getStruct_code());
|
||||
lock_map.put("inv_id", ioStorInv.getIostorinv_id());
|
||||
lock_map.put("inv_code", ioStorInv.getBill_code());
|
||||
lock_map.put("inv_type", ioStorInv.getBill_type());
|
||||
lock_map.put("lock_type", IOSEnum.LOCK_TYPE.code("出库锁"));
|
||||
iStructattrService.updateStatusByCode("0",lock_map);
|
||||
|
||||
//生成分配明细
|
||||
ioStorInvDisMapper.insert(ioStorInvDis);
|
||||
|
||||
//更新库存 加冻结减可用
|
||||
List<JSONObject> updateIvtList = new ArrayList<>();
|
||||
JSONObject jsonIvt = new JSONObject();
|
||||
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_ADD_FROZEN);
|
||||
jsonIvt.put("storagevehicle_code", outAllocation.getStoragevehicle_code());
|
||||
jsonIvt.put("material_id", outAllocation.getMaterial_id());
|
||||
jsonIvt.put("pcsn", outAllocation.getPcsn());
|
||||
jsonIvt.put("qty_unit_id", outAllocation.getQty_unit_id());
|
||||
jsonIvt.put("qty_unit_name", outAllocation.getQty_unit_name());
|
||||
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty());
|
||||
updateIvtList.add(jsonIvt);
|
||||
iMdPbStoragevehicleextService.updateIvt(updateIvtList);
|
||||
|
||||
//分配完成 结束分配
|
||||
if (unassign_qty==0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//更新详情
|
||||
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完"));
|
||||
double assign_qty = dtl.getUnassign_qty().doubleValue() + dtl.getAssign_qty().doubleValue();
|
||||
dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty));
|
||||
dtl.setAssign_qty(BigDecimal.valueOf(assign_qty));
|
||||
ioStorInvDtlMapper.updateById(dtl);
|
||||
}
|
||||
|
||||
//更新主表
|
||||
//根据单据标识判断明细是否都已经分配完成
|
||||
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
|
||||
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
|
||||
.lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完"))
|
||||
);
|
||||
// 根据分配货位情况 更新主表单据状态
|
||||
IOStorInv ios = new IOStorInv();
|
||||
ios.setIostorinv_id(iostorinv_id);
|
||||
ios.setUpdate_optid(currentUserId);
|
||||
ios.setUpdate_optname(nickName);
|
||||
ios.setUpdate_time(now);
|
||||
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完"));
|
||||
ioStorInvMapper.updateById(ios);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void allCancel(JSONObject whereJson) {
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||
|
||||
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
.le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("生成"))
|
||||
.eq(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("否"))
|
||||
.eq(IOStorInvDis::getIostorinv_id,iostorinv_id)
|
||||
);
|
||||
if (ObjectUtil.isEmpty(ioStorInvDisList)){
|
||||
throw new BadRequestException("不存在可取消的出库分配明细");
|
||||
}
|
||||
//需要更新的出入库单明细
|
||||
Set<String> dtlSet = new HashSet<>();
|
||||
|
||||
for (IOStorInvDis ioStorInvDis:ioStorInvDisList){
|
||||
|
||||
//添加需要更新的明细标识
|
||||
dtlSet.add(ioStorInvDis.getIostorinvdtl_id());
|
||||
|
||||
//更新库存 减冻结加可用
|
||||
List<JSONObject> updateIvtList = new ArrayList<>();
|
||||
JSONObject jsonIvt = new JSONObject();
|
||||
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_FROZEN_ADD_CANUSE);
|
||||
jsonIvt.put("storagevehicle_code", ioStorInvDis.getStoragevehicle_code());
|
||||
jsonIvt.put("material_id", ioStorInvDis.getMaterial_id());
|
||||
jsonIvt.put("pcsn", ioStorInvDis.getPcsn());
|
||||
jsonIvt.put("qty_unit_id", ioStorInvDis.getQty_unit_id());
|
||||
jsonIvt.put("qty_unit_name", ioStorInvDis.getQty_unit_name());
|
||||
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty());
|
||||
updateIvtList.add(jsonIvt);
|
||||
iMdPbStoragevehicleextService.updateIvt(updateIvtList);
|
||||
|
||||
//解锁库位
|
||||
JSONObject unlock_map = new JSONObject();
|
||||
unlock_map.put("struct_code", ioStorInvDis.getStruct_code());
|
||||
unlock_map.put("inv_type", null);
|
||||
unlock_map.put("inv_id", null);
|
||||
unlock_map.put("inv_code", null);
|
||||
iStructattrService.updateStatusByCode("2",unlock_map);
|
||||
|
||||
//删除出入库单分配表
|
||||
ioStorInvDisMapper.deleteById(ioStorInvDis.getIostorinvdis_id());
|
||||
|
||||
}
|
||||
|
||||
//更新出库明细单状态
|
||||
for (String dtlId:dtlSet){
|
||||
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(dtlId);
|
||||
ioStorInvDtl.setAssign_qty(BigDecimal.ZERO);
|
||||
ioStorInvDtl.setUnassign_qty(ioStorInvDtl.getPlan_qty());
|
||||
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
|
||||
|
||||
ioStorInvDtlMapper.updateById(ioStorInvDtl);
|
||||
}
|
||||
|
||||
//更新主表单据状态
|
||||
IOStorInv ios = new IOStorInv();
|
||||
ios.setIostorinv_id(iostorinv_id);
|
||||
ios.setUpdate_optid(currentUserId);
|
||||
ios.setUpdate_optname(nickName);
|
||||
ios.setUpdate_time(now);
|
||||
ios.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
|
||||
ioStorInvMapper.updateById(ios);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void autoDiv(JSONObject whereJson) {
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||
|
||||
//查询主表信息
|
||||
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id);
|
||||
if (ObjectUtil.isEmpty(ioStorInv)) {
|
||||
throw new BadRequestException("查不到出库单信息");
|
||||
}
|
||||
|
||||
//查询生成和未分配完的明细
|
||||
JSONObject queryDtl = new JSONObject();
|
||||
queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完"));
|
||||
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
queryDtl.put("iostorinv_id", iostorinv_id);
|
||||
queryDtl.put("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id"));
|
||||
List<IOStorInvDtlDto> dtls = ioStorInvMapper.getIODtl(queryDtl);
|
||||
@@ -272,228 +494,186 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
IOStorInvDtlDto dtl = dtls.get(i);
|
||||
double unassign_qty = dtl.getUnassign_qty().doubleValue();
|
||||
String pcsn = dtl.getPcsn();
|
||||
String material_id = dtl.getMaterial_id();
|
||||
|
||||
// 根据物料和批次号查询库存可用
|
||||
BigDecimal canuseSum = mdPbStoragevehicleextMapper.queryCanuseSum(pcsn,material_id);
|
||||
|
||||
if (canuseSum.doubleValue()<unassign_qty){
|
||||
throw new BadRequestException("物料编号:"+ dtl.getMaterial_code() +"出库分配数量不满足");
|
||||
}
|
||||
|
||||
/*
|
||||
* 分配规则:
|
||||
* 1.按批次先进先出
|
||||
* 2.相同批次载具量小优先
|
||||
*/
|
||||
|
||||
//出库分配查询货位信息
|
||||
List<MdPbStoragevehicleextDto> outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id);
|
||||
|
||||
if (StrUtil.isBlank(pcsn)) {
|
||||
throw new BadRequestException("出库明细存在批次号为空");
|
||||
}
|
||||
// 根据批次号查询库存可用
|
||||
BigDecimal canuseSum = mdPbStoragevehicleextMapper.queryCanuseSumByPcsn(pcsn);
|
||||
int seq_no = 1;
|
||||
for (MdPbStoragevehicleextDto outAllocation : outAllocationList) {
|
||||
//分配明细
|
||||
IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
||||
ioStorInvDis.setIostorinv_id(dtl.getIostorinv_id());
|
||||
ioStorInvDis.setIostorinvdtl_id(dtl.getIostorinvdtl_id());
|
||||
ioStorInvDis.setSeq_no((seq_no++)+"");
|
||||
ioStorInvDis.setSect_id(outAllocation.getSect_id());
|
||||
ioStorInvDis.setPcsn(outAllocation.getPcsn());
|
||||
ioStorInvDis.setMaterial_id(material_id);
|
||||
ioStorInvDis.setSect_name(outAllocation.getSect_name());
|
||||
ioStorInvDis.setSect_code(outAllocation.getSect_code());
|
||||
ioStorInvDis.setStruct_id(outAllocation.getStruct_id());
|
||||
ioStorInvDis.setStruct_name(outAllocation.getStruct_name());
|
||||
ioStorInvDis.setStruct_code(outAllocation.getStruct_code());
|
||||
ioStorInvDis.setStoragevehicle_code(outAllocation.getStoragevehicle_code());
|
||||
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
ioStorInvDis.setQty_unit_id(outAllocation.getQty_unit_id());
|
||||
ioStorInvDis.setQty_unit_name(outAllocation.getQty_unit_name());
|
||||
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("生成"));
|
||||
|
||||
if (canuseSum.doubleValue()<unassign_qty){
|
||||
throw new BadRequestException("出库分配数量不满足");
|
||||
// 未分配数量 - 该库位上的可用数量 < 0 目前做整出
|
||||
unassign_qty = unassign_qty-outAllocation.getCanuse_qty().doubleValue();
|
||||
if (unassign_qty<0){
|
||||
unassign_qty=0;
|
||||
}
|
||||
ioStorInvDis.setPlan_qty(outAllocation.getCanuse_qty());
|
||||
|
||||
//锁定货位
|
||||
JSONObject lock_map = new JSONObject();
|
||||
lock_map.put("struct_code", outAllocation.getStruct_code());
|
||||
lock_map.put("inv_id", ioStorInv.getIostorinv_id());
|
||||
lock_map.put("inv_code", ioStorInv.getBill_code());
|
||||
lock_map.put("inv_type", ioStorInv.getBill_type());
|
||||
lock_map.put("lock_type", IOSEnum.LOCK_TYPE.code("出库锁"));
|
||||
iStructattrService.updateStatusByCode("0",lock_map);
|
||||
|
||||
//生成分配明细
|
||||
ioStorInvDisMapper.insert(ioStorInvDis);
|
||||
|
||||
//更新库存 加冻结减可用
|
||||
List<JSONObject> updateIvtList = new ArrayList<>();
|
||||
JSONObject jsonIvt = new JSONObject();
|
||||
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_ADD_FROZEN);
|
||||
jsonIvt.put("storagevehicle_code", outAllocation.getStoragevehicle_code());
|
||||
jsonIvt.put("material_id", outAllocation.getMaterial_id());
|
||||
jsonIvt.put("pcsn", outAllocation.getPcsn());
|
||||
jsonIvt.put("qty_unit_id", outAllocation.getQty_unit_id());
|
||||
jsonIvt.put("qty_unit_name", outAllocation.getQty_unit_name());
|
||||
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty());
|
||||
updateIvtList.add(jsonIvt);
|
||||
iMdPbStoragevehicleextService.updateIvt(updateIvtList);
|
||||
|
||||
//分配完成 结束分配
|
||||
if (unassign_qty==0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// boolean is_top3 = false;
|
||||
// if (ObjectUtil.isEmpty(dtl.getString("source_bill_code")) && ObjectUtil.isEmpty(dtl.getString("pcsn"))) {
|
||||
// is_top3 = true;
|
||||
// }
|
||||
// JSONObject jsonMap = new JSONObject();
|
||||
// // 已分配重量
|
||||
// double assign_qty = dtl.getDoubleValue("assign_qty");
|
||||
//
|
||||
// if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) {
|
||||
// while (unassign_qty > 0) {
|
||||
// // 1.有销售订单号
|
||||
// jsonMap.put("flag", "1");
|
||||
// jsonMap.put("material_id", dtl.getString("material_id"));
|
||||
// jsonMap.put("sale_order_name", dtl.getString("source_bill_code"));
|
||||
// jsonMap.put("sect_id", whereJson.getString("sect_id"));
|
||||
// jsonMap.put("stor_id", whereJson.getString("stor_id"));
|
||||
//
|
||||
// JSONObject jsonOneIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0);
|
||||
// if (ObjectUtil.isEmpty(jsonOneIvt)) {
|
||||
// throw new BadRequestException("库存不足");
|
||||
// }
|
||||
//
|
||||
// // 查询这一巷道所有此物料此库存此销售订单的库存
|
||||
// jsonMap.put("flag", "2");
|
||||
// jsonMap.put("row_num", jsonOneIvt.getString("row_num"));
|
||||
// jsonMap.put("block_num", jsonOneIvt.getString("block_num"));
|
||||
// JSONArray ivtAllArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
||||
//
|
||||
// for (int j = 0; j < ivtAllArr.size(); j++) {
|
||||
// JSONObject ivt = ivtAllArr.getJSONObject(j);
|
||||
// double canuse_qty = ivt.getDoubleValue("canuse_qty");
|
||||
// assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
||||
//
|
||||
// if (unassign_qty >= canuse_qty) {
|
||||
// unassign_qty = NumberUtil.sub(unassign_qty, canuse_qty);
|
||||
// } else {
|
||||
// unassign_qty = 0;
|
||||
// }
|
||||
//
|
||||
// // 查询此木箱下的所有子卷
|
||||
// jsonMap.put("flag", "3");
|
||||
// jsonMap.put("storagevehicle_code", ivt.getString("storagevehicle_code"));
|
||||
// JSONArray ivtAllArr2 = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
||||
//
|
||||
// for (int k = 0; k < ivtAllArr2.size(); k++) {
|
||||
// // 更新库存
|
||||
// JSONObject ivt2 = ivtAllArr2.getJSONObject(k);
|
||||
// ivt2.put("change_qty", ivt2.getDoubleValue("canuse_qty"));
|
||||
// ivt2.put("bill_type_scode", jo_mst.getString("bill_type"));
|
||||
// ivt2.put("inv_id", dtl.getString("iostorinv_id"));
|
||||
// ivt2.put("bill_code", jo_mst.getString("bill_code"));
|
||||
// ivt2.put("bill_table", "ST_IVT_IOStorInv");
|
||||
// storPublicService.IOStor(ivt2, "11");
|
||||
//
|
||||
// //生成分配明细
|
||||
// dtl.put("iostorinvdis_id", cn.hutool.core.util.IdUtil.getSnowflake(1, 1).nextId());
|
||||
// dtl.put("sect_id", ivt2.getString("sect_id"));
|
||||
// dtl.put("sect_code", ivt2.getString("sect_code"));
|
||||
// dtl.put("sect_name", ivt2.getString("sect_name"));
|
||||
// dtl.put("struct_id", ivt2.getString("struct_id"));
|
||||
// dtl.put("struct_code", ivt2.getString("struct_code"));
|
||||
// dtl.put("struct_name", ivt2.getString("struct_name"));
|
||||
// dtl.put("pcsn", ivt2.getString("pcsn"));
|
||||
// dtl.put("box_no", ivt2.getString("storagevehicle_code"));
|
||||
// dtl.put("storagevehicle_id", ivt2.getString("storagevehicle_id"));
|
||||
// dtl.put("storagevehicle_code", ivt2.getString("storagevehicle_code"));
|
||||
// dtl.put("storagevehicle_type", ivt2.getString("storagevehicle_type"));
|
||||
// dtl.put("is_issued", "0");
|
||||
// dtl.put("plan_qty", ivt2.getDoubleValue("change_qty"));
|
||||
// dtl.put("real_qty", ivt2.getDoubleValue("change_qty"));
|
||||
// dtl.put("is_overdue", ivt2.getString("is_overdue"));
|
||||
// dtl.put("instorage_time", ivt2.getString("instorage_time"));
|
||||
//
|
||||
// // 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
||||
// JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt2.getString("sect_id") + "'").uniqueResult(0);
|
||||
// if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) {
|
||||
// dtl.put("work_status", "01");
|
||||
// } else {
|
||||
// dtl.put("work_status", "00");
|
||||
// }
|
||||
//
|
||||
// if (jo_mst.getString("is_overdue").equals("1")) {
|
||||
// // 判断是否超期
|
||||
// if (ivt2.getString("is_overdue").equals("1")) {
|
||||
// dtl.put("work_status", "01");
|
||||
// }
|
||||
// }
|
||||
// wo_dis.insert(dtl);
|
||||
// }
|
||||
// //记录需锁定的仓位
|
||||
// Struct_map.put(ivt.getString("struct_id"), ivt);
|
||||
// // 为零结束
|
||||
// if (unassign_qty == 0) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// // 确定子卷: 根据子卷找到库存出掉
|
||||
// jsonMap.put("flag", "1");
|
||||
// jsonMap.put("material_id", dtl.getString("material_id"));
|
||||
// jsonMap.put("pcsn", dtl.getString("pcsn"));
|
||||
// jsonMap.put("box_no", dtl.getString("box_no"));
|
||||
// jsonMap.put("sect_id", whereJson.getString("sect_id"));
|
||||
// jsonMap.put("stor_id", whereJson.getString("stor_id"));
|
||||
//
|
||||
// JSONObject jsonIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0);
|
||||
// if (ObjectUtil.isEmpty(jsonIvt)) {
|
||||
// throw new BadRequestException("库存不足");
|
||||
// }
|
||||
//
|
||||
// double canuse_qty ;
|
||||
// if (StrUtil.equals(bill_type, "1011")) {
|
||||
// canuse_qty = dtl.getDoubleValue("plan_qty");
|
||||
// } else {
|
||||
// canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
|
||||
// }
|
||||
//
|
||||
// jsonIvt.put("change_qty", canuse_qty + "");
|
||||
// unassign_qty = 0;
|
||||
// assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
||||
//
|
||||
// //更新库存
|
||||
// jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
||||
// jsonIvt.put("inv_id", dtl.getString("iostorinv_id"));
|
||||
// jsonIvt.put("bill_code", jo_mst.getString("bill_code"));
|
||||
// jsonIvt.put("bill_table", "ST_IVT_IOStorInv");
|
||||
// storPublicService.IOStor(jsonIvt, "11");
|
||||
// //生成分配明细
|
||||
// dtl.put("iostorinvdis_id", cn.hutool.core.util.IdUtil.getSnowflake(1, 1).nextId());
|
||||
// dtl.put("sect_id", jsonIvt.getString("sect_id"));
|
||||
// dtl.put("sect_code", jsonIvt.getString("sect_code"));
|
||||
// dtl.put("sect_name", jsonIvt.getString("sect_name"));
|
||||
// dtl.put("struct_id", jsonIvt.getString("struct_id"));
|
||||
// dtl.put("struct_code", jsonIvt.getString("struct_code"));
|
||||
// dtl.put("struct_name", jsonIvt.getString("struct_name"));
|
||||
// dtl.put("pcsn", jsonIvt.getString("pcsn"));
|
||||
// dtl.put("box_no", jsonIvt.getString("storagevehicle_code"));
|
||||
// dtl.put("storagevehicle_id", jsonIvt.getString("storagevehicle_id"));
|
||||
// dtl.put("storagevehicle_code", jsonIvt.getString("storagevehicle_code"));
|
||||
// dtl.put("storagevehicle_type", jsonIvt.getString("storagevehicle_type"));
|
||||
// dtl.put("is_issued", "0");
|
||||
// dtl.put("plan_qty", jsonIvt.getDoubleValue("change_qty"));
|
||||
// dtl.put("real_qty", jsonIvt.getDoubleValue("change_qty"));
|
||||
// dtl.put("is_overdue", jsonIvt.getString("is_overdue"));
|
||||
// dtl.put("instorage_time", jsonIvt.getString("instorage_time"));
|
||||
// // 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
||||
// JSONObject jsonSect = wo_sect.query("sect_id = '" + jsonIvt.getString("sect_id") + "'").uniqueResult(0);
|
||||
// if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) {
|
||||
// dtl.put("work_status", "01");
|
||||
// } else {
|
||||
// dtl.put("work_status", "00");
|
||||
// }
|
||||
//
|
||||
// // 判断是否超期
|
||||
// if (jo_mst.getString("is_overdue").equals("1")) {
|
||||
// if (jsonIvt.getString("is_overdue").equals("1")) {
|
||||
// dtl.put("work_status", "01");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// wo_dis.insert(dtl);
|
||||
//
|
||||
// //记录需锁定的仓位 (如果此明细有相同物料的且子卷号不能为空的则在最后一个明细分配完成后锁定仓位)
|
||||
// JSONObject map = new JSONObject();
|
||||
// map.put("flag", "5");
|
||||
// map.put("material_id", dtl.getString("material_id"));
|
||||
// map.put("box_no", dtl.getString("box_no"));
|
||||
// map.put("iostorinv_id", iostorinv_id);
|
||||
// map.put("iostorinvdtl_id", dtl.getString("iostorinvdtl_id"));
|
||||
// JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(map).process().getResultJSONArray(0);
|
||||
// if (dtlArr.size() == 0) {
|
||||
// Struct_map.put(jsonIvt.getString("struct_id"), jsonIvt);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// HashMap<String, String> map_dtl = new HashMap<String, String>();
|
||||
// //更新明细
|
||||
// map_dtl.put("unassign_qty", unassign_qty + "");
|
||||
// map_dtl.put("assign_qty", assign_qty + "");
|
||||
// if (unassign_qty == 0) {
|
||||
// map_dtl.put("bill_status", "40");
|
||||
// } else {
|
||||
// map_dtl.put("bill_status", "30");
|
||||
// }
|
||||
// wo_dtl.update(map_dtl, "iostorinvdtl_id='" + dtl.getString("iostorinvdtl_id") + "'");
|
||||
//
|
||||
// //更新主表状态
|
||||
// this.updateMststatus(iostorinv_id);
|
||||
//
|
||||
// //锁定起点点位、仓位
|
||||
// Collection<JSONObject> c = Struct_map.values();
|
||||
// Iterator<JSONObject> it = c.iterator();
|
||||
// JSONObject from_start = new JSONObject();
|
||||
// from_start.put("lock_type", "3");
|
||||
// for (; it.hasNext(); ) {
|
||||
// JSONObject Struct = it.next();
|
||||
// from_start.put("struct_id", Struct.getString("struct_id"));
|
||||
// from_start.put("inv_type", jo_mst.getString("bill_type"));
|
||||
// from_start.put("inv_id", jo_mst.getString("iostorinv_id"));
|
||||
// from_start.put("inv_code", jo_mst.getString("bill_code"));
|
||||
// storPublicService.updateStructAndPoint(from_start);
|
||||
// }
|
||||
//更新详情
|
||||
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完"));
|
||||
double assign_qty = dtl.getUnassign_qty().doubleValue() + dtl.getAssign_qty().doubleValue();
|
||||
dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty));
|
||||
dtl.setAssign_qty(BigDecimal.valueOf(assign_qty));
|
||||
ioStorInvDtlMapper.updateById(dtl);
|
||||
}
|
||||
|
||||
//更新主表
|
||||
//根据单据标识判断明细是否都已经分配完成
|
||||
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
|
||||
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
|
||||
.lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完"))
|
||||
);
|
||||
|
||||
// 根据分配货位情况 更新主表单据状态
|
||||
IOStorInv ios = new IOStorInv();
|
||||
ios.setIostorinv_id(iostorinv_id);
|
||||
ios.setUpdate_optid(currentUserId);
|
||||
ios.setUpdate_optname(nickName);
|
||||
ios.setUpdate_time(now);
|
||||
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完"));
|
||||
ioStorInvMapper.updateById(ios);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoCancel(JSONObject whereJson) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||
|
||||
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
.le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("生成"))
|
||||
.eq(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("否"))
|
||||
.eq(IOStorInvDis::getIostorinv_id,iostorinv_id)
|
||||
.eq(IOStorInvDis::getIostorinvdtl_id,whereJson.getString("iostorinvdtl_id"))
|
||||
);
|
||||
if (ObjectUtil.isEmpty(ioStorInvDisList)){
|
||||
throw new BadRequestException("不存在可取消的出库分配明细");
|
||||
}
|
||||
//需要更新的出入库单明细
|
||||
Set<String> dtlSet = new HashSet<>();
|
||||
|
||||
for (IOStorInvDis ioStorInvDis:ioStorInvDisList){
|
||||
|
||||
//添加需要更新的明细标识
|
||||
dtlSet.add(ioStorInvDis.getIostorinvdtl_id());
|
||||
|
||||
//更新库存 减冻结加可用
|
||||
List<JSONObject> updateIvtList = new ArrayList<>();
|
||||
JSONObject jsonIvt = new JSONObject();
|
||||
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_FROZEN_ADD_CANUSE);
|
||||
jsonIvt.put("storagevehicle_code", ioStorInvDis.getStoragevehicle_code());
|
||||
jsonIvt.put("material_id", ioStorInvDis.getMaterial_id());
|
||||
jsonIvt.put("pcsn", ioStorInvDis.getPcsn());
|
||||
jsonIvt.put("qty_unit_id", ioStorInvDis.getQty_unit_id());
|
||||
jsonIvt.put("qty_unit_name", ioStorInvDis.getQty_unit_name());
|
||||
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty());
|
||||
updateIvtList.add(jsonIvt);
|
||||
iMdPbStoragevehicleextService.updateIvt(updateIvtList);
|
||||
|
||||
//解锁库位
|
||||
JSONObject unlock_map = new JSONObject();
|
||||
unlock_map.put("struct_code", ioStorInvDis.getStruct_code());
|
||||
unlock_map.put("inv_type", null);
|
||||
unlock_map.put("inv_id", null);
|
||||
unlock_map.put("inv_code", null);
|
||||
iStructattrService.updateStatusByCode("2",unlock_map);
|
||||
|
||||
//删除出入库单分配表
|
||||
ioStorInvDisMapper.deleteById(ioStorInvDis.getIostorinvdis_id());
|
||||
|
||||
}
|
||||
|
||||
//更新出库明细单状态
|
||||
for (String dtlId:dtlSet){
|
||||
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(dtlId);
|
||||
ioStorInvDtl.setAssign_qty(BigDecimal.ZERO);
|
||||
ioStorInvDtl.setUnassign_qty(ioStorInvDtl.getPlan_qty());
|
||||
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
|
||||
|
||||
ioStorInvDtlMapper.updateById(ioStorInvDtl);
|
||||
}
|
||||
|
||||
//更新主表
|
||||
//根据单据标识判断明细是否都已经分配完成
|
||||
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
|
||||
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
|
||||
.le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完"))
|
||||
.gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("生成"))
|
||||
);
|
||||
|
||||
// 根据分配货位情况 更新主表单据状态
|
||||
IOStorInv ios = new IOStorInv();
|
||||
ios.setIostorinv_id(iostorinv_id);
|
||||
ios.setUpdate_optid(currentUserId);
|
||||
ios.setUpdate_optname(nickName);
|
||||
ios.setUpdate_time(now);
|
||||
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("生成"));
|
||||
ioStorInvMapper.updateById(ios);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,6 +186,8 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
ioStorInvDtl.put("bill_status",IOSEnum.BILL_STATUS.code("生成"));
|
||||
ioStorInvDtl.put("qty_unit_id",row.get("qty_unit_id"));
|
||||
ioStorInvDtl.put("qty_unit_name",row.get("qty_unit_name"));
|
||||
ioStorInvDtl.put("source_bill_type",row.get("ext_type"));
|
||||
ioStorInvDtl.put("source_bill_code",row.get("ext_code"));
|
||||
ioStorInvDtl.put("assign_qty","0");
|
||||
ioStorInvDtl.put("unassign_qty",row.get("plan_qty"));
|
||||
ioStorInvDtl.put("plan_qty",row.get("plan_qty"));
|
||||
@@ -343,7 +345,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
//判断该分配明细是否已经分配货位
|
||||
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id"))
|
||||
.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code,""));
|
||||
.and(wrapper-> wrapper.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code,"")));
|
||||
if (ObjectUtil.isEmpty(ioStorInvDis)){
|
||||
throw new BadRequestException("该明细已经分配过货位,无法继续分配!");
|
||||
}
|
||||
@@ -405,6 +407,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
lock_map.put("inv_id", ioStorInv.getIostorinv_id());
|
||||
lock_map.put("inv_code", ioStorInv.getBill_code());
|
||||
lock_map.put("inv_type", ioStorInv.getBill_type());
|
||||
lock_map.put("lock_type", IOSEnum.LOCK_TYPE.code("入库锁"));
|
||||
iStructattrService.updateStatusByCode("0",lock_map);
|
||||
|
||||
// 更新分配明细表
|
||||
@@ -429,7 +432,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
//根据单据标识判断分配明细是否都已经分配完成
|
||||
int disCount = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
.eq(IOStorInvDis::getIostorinv_id,map.get("iostorinv_id"))
|
||||
.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code,""));
|
||||
.and(wrapper -> wrapper.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code,"")));
|
||||
|
||||
// 根据分配货位情况 更新主表单据状态
|
||||
IOStorInv ios = new IOStorInv();
|
||||
@@ -482,7 +485,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
//根据单据标识判断分配明细是否都已经分配完成
|
||||
int disCount = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
.eq(IOStorInvDis::getIostorinv_id,jo.get("iostorinv_id"))
|
||||
.isNotNull(IOStorInvDis::getStruct_code).or().ne(IOStorInvDis::getStruct_code,""));
|
||||
.and(wrapper -> wrapper.isNotNull(IOStorInvDis::getStruct_code).or().ne(IOStorInvDis::getStruct_code,"")));
|
||||
|
||||
// 根据分配货位情况 更新主表单据状态
|
||||
IOStorInv ios = new IOStorInv();
|
||||
@@ -504,7 +507,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
//判断是否已经分配好货位
|
||||
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id"))
|
||||
.isNotNull(IOStorInvDis::getStruct_code).or().ne(IOStorInvDis::getStruct_code,""));
|
||||
.and(wrapper -> wrapper.isNotNull(IOStorInvDis::getStruct_code).or().ne(IOStorInvDis::getStruct_code,"")));
|
||||
if (ObjectUtil.isEmpty(ioStorInvDis)){
|
||||
throw new BadRequestException("该明细还没分配货位,请先分配货位");
|
||||
}
|
||||
@@ -630,9 +633,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
List<Structattr> structattrList = iStructattrService.list(new LambdaQueryWrapper<>(Structattr.class)
|
||||
.eq(Structattr::getSect_id,sect_id)
|
||||
.eq(Structattr::getLock_type,IOSEnum.LOCK_TYPE.code("未锁定"))
|
||||
.and(row -> row.isNull(Structattr::getStoragevehicle_code).or(
|
||||
it -> it.eq(Structattr::getStoragevehicle_code,"")
|
||||
))
|
||||
.and(wrapper -> wrapper.isNull(Structattr::getStoragevehicle_code).or().eq(Structattr::getStoragevehicle_code,""))
|
||||
);
|
||||
if (ObjectUtil.isEmpty(structattrList)){
|
||||
throw new BadRequestException("该库区没有仓位");
|
||||
|
||||
Reference in New Issue
Block a user