otp:优化

This commit is contained in:
DESKTOP-5DIJMF9\admin
2025-08-07 10:58:00 +08:00
parent 94c9baf2a6
commit da2489386c

View File

@@ -18,17 +18,22 @@ import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService;
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
import org.nl.wms.basedata_manage.service.dao.MdPbMeasureunit;
import org.nl.wms.ext_manage.service.WmsToErpService;
import org.nl.wms.pm_manage.service.dao.PmFormData;
import org.nl.wms.pm_manage.service.dao.mapper.PmFormDataMapper;
import org.nl.wms.warehouse_manage.enums.IOSConstant;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.service.ReturnService;
import org.nl.wms.warehouse_manage.service.dao.IOStorInv;
import org.nl.wms.warehouse_manage.service.dao.IOStorInvDis;
import org.nl.wms.warehouse_manage.service.dao.IOStorInvDtl;
import org.nl.wms.warehouse_manage.service.dao.mapper.IOStorInvDisMapper;
import org.nl.wms.warehouse_manage.service.dao.mapper.IOStorInvDtlMapper;
import org.nl.wms.warehouse_manage.service.dao.mapper.IOStorInvMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -48,21 +53,14 @@ public class RetrunServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
/**
* 出入库mapper服务
*/
@Autowired
@Resource
private IOStorInvDisMapper ioStorInvDisMapper;
/**
* 物料基础服务
*/
@Autowired
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
/**
* 计量单位服务
*/
@Autowired
private IMdPbMeasureunitService iMdPbMeasureunitService;
@Resource
private IOStorInvDtlMapper ioStorInvDtlMapper;
@Resource
private IOStorInvMapper ioStorInvMapper;
@Resource
private PmFormDataMapper pmFormDataMapper;
/**
* WMS调用ERP服务类
*/
@@ -106,61 +104,39 @@ public class RetrunServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
.collect(Collectors.toList())
)
);
// 查询所有物料
List<MdMeMaterialbase> materList = iMdMeMaterialbaseService.list(
new QueryWrapper<MdMeMaterialbase>().lambda()
.in(MdMeMaterialbase::getMaterial_id, iosDisList.stream()
.map(IOStorInvDis::getMaterial_id)
.distinct()
.collect(Collectors.toList())
)
);
// 查询所有计量单位
List<MdPbMeasureunit> unitList = iMdPbMeasureunitService.list(
new QueryWrapper<MdPbMeasureunit>().lambda()
.in(MdPbMeasureunit::getMeasure_unit_id, iosDisList.stream()
.map(IOStorInvDis::getQty_unit_id)
.distinct()
.collect(Collectors.toList()))
);
// 需回传数据集合
List<JSONObject> paramList = new ArrayList<>();
for(IOStorInvDis disDao : iosDisList) {
IOStorInv mst = ioStorInvMapper.selectById(disDao.getIostorinv_id());
IOStorInvDtl dtl = ioStorInvDtlMapper.selectById(disDao.getIostorinvdtl_id());
JSONObject param = new JSONObject();
// 物料编码
MdMeMaterialbase materDao = materList.stream()
.filter(row -> row.getMaterial_id().equals(disDao.getMaterial_id()))
.findFirst().orElse(null);
param.put("mater_code", materDao.getMaterial_code());
// 批次
param.put("batch_no", disDao.getPcsn());
// 数量
param.put("quantity", disDao.getReal_qty());
// 计量单位
MdPbMeasureunit unitDao = unitList.stream()
.filter(row -> row.getMeasure_unit_id().equals(disDao.getQty_unit_id()))
.findFirst().orElse(null);
param.put("unit_code", unitDao.getUnit_code());
// 仓库编码
JSONObject jsonMst = rows.stream()
.filter(row -> row.getString("iostorinv_id").equals(disDao.getIostorinv_id()))
.findFirst().orElse(null);
param.put("stor_code", jsonMst.getString("stor_code"));
// 货位编码
param.put("point_code", disDao.getStruct_code());
// 载具编码
param.put("pallet_code", disDao.getStoragevehicle_code());
// 单据号
param.put("inv_code", jsonMst.getString("source_id"));
// 业务类型
param.put("task_type", jsonMst.getString("source_type"));
paramList.add(param);
//入库
if("0".equals(mst.getIo_type())){
// 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code());
param.put("instor_time", mst.getConfirm_time());
wmsToErpService.instorinfoToErp(param);
}else {//出
//如果是用料出库,则需回传
if(ObjectUtil.isNotEmpty(dtl.getSource_bill_code())){
//判断用料清单是否合单
PmFormData pmform = pmFormDataMapper.selectById(dtl.getSource_billdtl_id());
if("0".equals(pmform.getNew_merge_flag())){
// 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code());
// 数量
param.put("qty", disDao.getReal_qty());
// 单据号
param.put("order_code", dtl.getSource_bill_code());
// 业务类型
param.put("order_type", dtl.getSource_bill_type());
// 业务类型
param.put("outstor_time", mst.getConfirm_time());
}else{//合单
}
wmsToErpService.outstorinfoToErp(param);
}
}
}
JSONObject jsonParam = new JSONObject();
jsonParam.put("data", paramList);
wmsToErpService.instorinfoToErp(jsonParam);
// 更新主表
this.update(