|
|
@ -8,34 +8,68 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelation; |
|
|
|
import org.nl.b_lms.pdm.subpackagerelation.service.IpdmBiSubpackagerelationService; |
|
|
|
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterConstant; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvService; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvdisService; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvdtlService; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinv; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinvdis; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinvdtl; |
|
|
|
import org.nl.b_lms.storage_manage.st.dao.StIvtStructivt; |
|
|
|
import org.nl.b_lms.storage_manage.st.service.StIvtStructivtService; |
|
|
|
import org.nl.common.domain.query.PageQuery; |
|
|
|
import org.nl.common.utils.CodeUtil; |
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
import org.nl.common.utils.CodeUtil; |
|
|
|
import org.nl.modules.wql.WQL; |
|
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
|
import org.nl.modules.wql.util.WqlUtil; |
|
|
|
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl; |
|
|
|
import org.nl.wms.st.inbill.service.OutChargeService; |
|
|
|
import org.nl.wms.st.inbill.service.dto.OutChargePageParam; |
|
|
|
import org.nl.wms.stat.service.enums.InBillTypeEnum; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static org.nl.common.utils.IdUtil.getStringId; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author Liuxy |
|
|
|
* @description 服务实现 |
|
|
|
* @date 2022-08-11 |
|
|
|
**/ |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Slf4j |
|
|
|
public class OutChargeServiceImpl implements OutChargeService { |
|
|
|
|
|
|
|
/** 单据表 */ |
|
|
|
@Autowired |
|
|
|
private IStIvtIostorinvService iStIvtIostorinvService; |
|
|
|
/** 出入库单分配表 */ |
|
|
|
@Autowired |
|
|
|
private IStIvtIostorinvdisService iostorinvdisService; |
|
|
|
/** 出入库单明细表 */ |
|
|
|
@Autowired |
|
|
|
private IStIvtIostorinvdtlService iostorinvdtlService; |
|
|
|
/** 仓位库存表 */ |
|
|
|
@Autowired |
|
|
|
private StIvtStructivtService structivtService; |
|
|
|
@Autowired |
|
|
|
private IpdmBiSubpackagerelationService subpackagerelationService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
|
|
|
String bill_code = MapUtil.getStr(whereJson, "bill_code"); |
|
|
@ -160,7 +194,10 @@ public class OutChargeServiceImpl implements OutChargeService { |
|
|
|
whereJson.put("writeoff_time", ""); |
|
|
|
whereJson.put("upload_mes", ""); |
|
|
|
whereJson.put("upload_sap", ""); |
|
|
|
mst_wql.insert(whereJson); |
|
|
|
// mst_wql.insert(whereJson);
|
|
|
|
// if (true) {
|
|
|
|
// throw new BadRequestException("测试中...");
|
|
|
|
// }
|
|
|
|
|
|
|
|
ArrayList<String> ivtList = new ArrayList<>(); // 存在库存的集合
|
|
|
|
for (int i = 0; i < dis_rows.size(); i++) { |
|
|
@ -191,7 +228,7 @@ public class OutChargeServiceImpl implements OutChargeService { |
|
|
|
dis_row.put("assign_qty", dis_row.getString("plan_qty")); |
|
|
|
dis_row.put("unassign_qty", "0"); |
|
|
|
//插入手工入库明细表
|
|
|
|
dtl_wql.insert(dis_row); |
|
|
|
// dtl_wql.insert(dis_row);
|
|
|
|
|
|
|
|
dis_row.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId()); |
|
|
|
dis_row.put("seq_no", 1); |
|
|
@ -206,7 +243,7 @@ public class OutChargeServiceImpl implements OutChargeService { |
|
|
|
dis_row.put("point_id", ""); |
|
|
|
dis_row.put("task_id", ""); |
|
|
|
//插入分配表
|
|
|
|
dis_wql.insert(dis_row); |
|
|
|
// dis_wql.insert(dis_row);
|
|
|
|
|
|
|
|
//将包装关系中对应的记录状态改为包装
|
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
@ -226,4 +263,115 @@ public class OutChargeServiceImpl implements OutChargeService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<StIvtIostorinv> outWriteOffPageDatas(OutChargePageParam paramMap, PageQuery page) { |
|
|
|
return iStIvtIostorinvService.outWriteOffPageDatas(paramMap, page); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void outWriteOffCharge(StIvtIostorinv outbound) { |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
String oldOutOrderId = outbound.getIostorinv_id(); |
|
|
|
// 1、校验主表状态为完成
|
|
|
|
StIvtIostorinv oldOutOrder = iStIvtIostorinvService.getById(oldOutOrderId); |
|
|
|
if (!"99".equals(oldOutOrder.getBill_status())) { |
|
|
|
throw new BadRequestException("出库单[" + outbound.getBill_code() + "]的状态必须为完成!"); |
|
|
|
} |
|
|
|
// 2、更新销售出库为已冲销
|
|
|
|
// 需要冲销的出库单Id
|
|
|
|
LambdaUpdateWrapper<StIvtIostorinv> iosInvLam = new LambdaUpdateWrapper<>(); |
|
|
|
iosInvLam.set(StIvtIostorinv::getIs_writeoff, SlitterConstant.SLITTER_YES) |
|
|
|
.set(StIvtIostorinv::getUpdate_time, now) |
|
|
|
.eq(StIvtIostorinv::getIostorinv_id, oldOutOrderId); |
|
|
|
iStIvtIostorinvService.update(iosInvLam); |
|
|
|
// 3、生成手工入库单
|
|
|
|
// 获取出库单对应的分配数据
|
|
|
|
List<StIvtIostorinvdis> outboundDisList = iostorinvdisService.getAllocationByIosId(oldOutOrderId); |
|
|
|
String manualInStorageOrderId = getStringId(); |
|
|
|
String manualInBillCode = CodeUtil.getNewCode("IO_CODE"); |
|
|
|
outbound.setIostorinv_id(manualInStorageOrderId); |
|
|
|
outbound.setBill_code(manualInBillCode); |
|
|
|
outbound.setIo_type("0"); |
|
|
|
outbound.setBill_type(InBillTypeEnum.MANUAL_IN.getCode()); |
|
|
|
outbound.setBuss_type("0009"); |
|
|
|
outbound.setBill_status("30"); |
|
|
|
outbound.setInput_optid(currentUserId); |
|
|
|
outbound.setInput_optname(nickName); |
|
|
|
outbound.setInput_time(now); |
|
|
|
outbound.setUpdate_optid(currentUserId); |
|
|
|
outbound.setUpdate_optname(nickName); |
|
|
|
outbound.setUpdate_time(now); |
|
|
|
outbound.setDis_optid(currentUserId); |
|
|
|
outbound.setDis_optname(nickName); |
|
|
|
outbound.setDis_time(now); |
|
|
|
outbound.setConfirm_optid("0"); |
|
|
|
outbound.setConfirm_optname(""); |
|
|
|
outbound.setConfirm_time(""); |
|
|
|
outbound.setIs_upload(""); |
|
|
|
outbound.setUpload_optid("0"); |
|
|
|
outbound.setUpload_time(""); |
|
|
|
outbound.setIs_writeoff("0"); |
|
|
|
outbound.setWriteoff_optid("0"); |
|
|
|
outbound.setWriteoff_time(""); |
|
|
|
outbound.setUpload_mes(""); |
|
|
|
outbound.setUpload_sap(""); |
|
|
|
iStIvtIostorinvService.save(outbound); |
|
|
|
// 4、插入明细表、分配表
|
|
|
|
// 存在库存的集合
|
|
|
|
ArrayList<String> ivtList = new ArrayList<>(); |
|
|
|
List<StIvtIostorinvdis> needSaveDisList = new ArrayList<>(); |
|
|
|
List<StIvtIostorinvdtl> needSaveDtlList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < outboundDisList.size(); i++) { |
|
|
|
//插入明细表
|
|
|
|
String newDtlId = getStringId(); |
|
|
|
StIvtIostorinvdis disRow = outboundDisList.get(i); |
|
|
|
// 校验是否存在库存
|
|
|
|
StIvtStructivt structivt = structivtService.getOneByPcsn(disRow.getPcsn(), false); |
|
|
|
if (ObjectUtil.isNotEmpty(structivt)) { |
|
|
|
ivtList.add(structivt.getPcsn()); |
|
|
|
} |
|
|
|
// 根据dis获取dtl(一个dis对应一个dtl【实际仓储中可能多对一】)
|
|
|
|
StIvtIostorinvdtl outDtl = iostorinvdtlService.getById(disRow.getIostorinvdtl_id()); |
|
|
|
StIvtIostorinvdtl oldDtl = outDtl; |
|
|
|
// 转换为冲销出库的手工入库明细
|
|
|
|
// 新的明细id
|
|
|
|
outDtl.setIostorinvdtl_id(newDtlId); |
|
|
|
// 新的单据id
|
|
|
|
outDtl.setIostorinv_id(manualInStorageOrderId); |
|
|
|
outDtl.setSeq_no(BigDecimal.valueOf(i + 1)); |
|
|
|
outDtl.setBill_status("30"); |
|
|
|
outDtl.setReal_qty(BigDecimal.ZERO); |
|
|
|
outDtl.setSource_billdtl_id(oldDtl.getSource_billdtl_id()); |
|
|
|
outDtl.setSource_bill_type(oldOutOrder.getBill_type()); |
|
|
|
outDtl.setSource_bill_code(oldOutOrder.getBill_code()); |
|
|
|
outDtl.setSource_bill_table("st_ivt_iostorinvdtl"); |
|
|
|
outDtl.setAssign_qty(disRow.getPlan_qty()); |
|
|
|
outDtl.setUnassign_qty(BigDecimal.ZERO); |
|
|
|
// 手工入库明细 后面批次插入
|
|
|
|
needSaveDtlList.add(outDtl); |
|
|
|
disRow.setIostorinvdis_id(getStringId()); |
|
|
|
disRow.setSeq_no(BigDecimal.ONE); |
|
|
|
disRow.setSect_id(""); |
|
|
|
disRow.setSect_code(""); |
|
|
|
disRow.setSect_name(""); |
|
|
|
disRow.setWork_status("00"); |
|
|
|
disRow.setReal_qty(BigDecimal.ZERO); |
|
|
|
disRow.setPoint_id(0L); |
|
|
|
disRow.setTask_id(""); |
|
|
|
needSaveDisList.add(disRow); |
|
|
|
//将包装关系中对应的记录状态改为包装
|
|
|
|
LambdaUpdateWrapper<PdmBiSubpackagerelation> upLam = new LambdaUpdateWrapper<>(); |
|
|
|
upLam.set(PdmBiSubpackagerelation::getStatus, "1") |
|
|
|
.eq(PdmBiSubpackagerelation::getPackage_box_sn, disRow.getBox_no()); |
|
|
|
if ("1001".equals(oldOutOrder.getBill_type())) { |
|
|
|
upLam.eq(PdmBiSubpackagerelation::getStatus, "3"); |
|
|
|
} |
|
|
|
subpackagerelationService.update(upLam); |
|
|
|
} |
|
|
|
iostorinvdtlService.updateBatchById(needSaveDtlList); |
|
|
|
iostorinvdisService.updateBatchById(needSaveDisList); |
|
|
|
} |
|
|
|
} |
|
|
|