opt:回传优化

This commit is contained in:
DESKTOP-5DIJMF9\admin
2025-08-11 16:05:12 +08:00
parent da2489386c
commit 80c6dcacaf
6 changed files with 172 additions and 73 deletions

View File

@@ -46,7 +46,7 @@ public class FIFORuleHandler extends Decisioner<StrategyStructMaterialVO, Strate
, "sect_code", param.getSect_code() , "sect_code", param.getSect_code()
, "plan_qty", planQty , "plan_qty", planQty
, "is_lock", "false" , "is_lock", "false"
, "order_by", "gro.update_time asc") , "order_by", "gro.update_time asc, gro.qty asc")
); );
if (ObjectUtils.isEmpty(vechielDtos)) { if (ObjectUtils.isEmpty(vechielDtos)) {
throw new BadRequestException("当前出库策略:先进先出,库存分配失败,失败原因:库存不足!"); throw new BadRequestException("当前出库策略:先进先出,库存分配失败,失败原因:库存不足!");

View File

@@ -23,7 +23,8 @@ public class WmsToErpServiceImpl implements WmsToErpService {
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ERP_URL).getValue(); String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ERP_URL).getValue();
url = url + EXTConstant.IN_STOR_INFO; url = url + EXTConstant.IN_STOR_INFO;
String is_connect_erp = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.IS_CONNECT_ERP).getValue();
if(is_connect_erp.equals("1")){
try { try {
String resultMsg = HttpRequest.post(url) String resultMsg = HttpRequest.post(url)
.body(String.valueOf(whereJson)) .body(String.valueOf(whereJson))
@@ -41,6 +42,7 @@ public class WmsToErpServiceImpl implements WmsToErpService {
} catch (Exception e) { } catch (Exception e) {
throw new BadRequestException("ERP提示错误" + e.getMessage()); throw new BadRequestException("ERP提示错误" + e.getMessage());
} }
}
return result; return result;
} }
@@ -52,6 +54,8 @@ public class WmsToErpServiceImpl implements WmsToErpService {
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ERP_URL).getValue(); String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ERP_URL).getValue();
url = url + EXTConstant.OUT_STOR_INFO; url = url + EXTConstant.OUT_STOR_INFO;
String is_connect_erp = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.IS_CONNECT_ERP).getValue();
if(is_connect_erp.equals("1")){
try { try {
String resultMsg = HttpRequest.post(url) String resultMsg = HttpRequest.post(url)
@@ -70,6 +74,7 @@ public class WmsToErpServiceImpl implements WmsToErpService {
} catch (Exception e) { } catch (Exception e) {
throw new BadRequestException("ERP提示错误" + e.getMessage()); throw new BadRequestException("ERP提示错误" + e.getMessage());
} }
}
return result; return result;
} }

View File

@@ -92,7 +92,7 @@ public class PmFormData implements Serializable {
*/ */
private BigDecimal assign_qty; private BigDecimal assign_qty;
private BigDecimal total_qty;
/** /**
* 数量单位 * 数量单位
*/ */

View File

@@ -12,6 +12,9 @@ public class SysParamConstant {
*/ */
public final static String IS_CONNECT_ACS = "is_connect_acs"; public final static String IS_CONNECT_ACS = "is_connect_acs";
public final static String IS_CONNECT_ERP = "is_connect_erp";
/** /**
* ACS系统IP * ACS系统IP
*/ */

View File

@@ -1181,15 +1181,6 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
form.setIs_finish("1"); form.setIs_finish("1");
form.setAssign_qty(form.getQty()); form.setAssign_qty(form.getQty());
iPmFormDataService.updateById(form); iPmFormDataService.updateById(form);
//更新被合单单据
if(ObjectUtil.isNotEmpty(form.getMerge_codes())){
String[] codes = form.getMerge_codes().split(",");
pmFormDataMapper.update(null,new LambdaUpdateWrapper<>(PmFormData.class)
.set(PmFormData::getStatus,IOSEnum.BILL_STATUS.code("完成"))
.set(PmFormData::getIs_finish,"1")
.in(PmFormData::getCode,codes)
);
}
} }
// 查看明细是否全部完成 // 查看明细是否全部完成
int countDtl = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) int countDtl = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)

View File

@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -96,48 +97,147 @@ public class RetrunServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
@Override @Override
public void upload(JSONObject whereJson) { public void upload(JSONObject whereJson) {
List<JSONObject> rows = whereJson.getJSONArray("rows").toJavaList(JSONObject.class); List<JSONObject> rows = whereJson.getJSONArray("rows").toJavaList(JSONObject.class);
for(int i=0;i<rows.size();i++) {
JSONObject row = rows.get(i);
IOStorInv mst = ioStorInvMapper.selectById(row.getString("iostorinv_id"));
//入库
if ("0".equals(mst.getIo_type())) {
// 根据主表id查询所有分配明细 // 根据主表id查询所有分配明细
List<IOStorInvDis> iosDisList = ioStorInvDisMapper.selectList( List<IOStorInvDis> iosDisList = ioStorInvDisMapper.selectList(
new QueryWrapper<IOStorInvDis>().lambda() new QueryWrapper<IOStorInvDis>().lambda()
.in(IOStorInvDis::getIostorinv_id, rows.stream() .eq(IOStorInvDis::getIostorinv_id, row.getString("iostorinv_id")));
.map(row -> row.getString("iostorinv_id")) for (IOStorInvDis disDao : iosDisList) {
.collect(Collectors.toList())
)
);
for(IOStorInvDis disDao : iosDisList) {
IOStorInv mst = ioStorInvMapper.selectById(disDao.getIostorinv_id());
IOStorInvDtl dtl = ioStorInvDtlMapper.selectById(disDao.getIostorinvdtl_id());
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
//入库
if("0".equals(mst.getIo_type())){
// 载具编码 // 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code()); param.put("pallet_sn", disDao.getStoragevehicle_code());
param.put("instor_time", mst.getConfirm_time()); param.put("instor_time", mst.getConfirm_time());
wmsToErpService.instorinfoToErp(param); wmsToErpService.instorinfoToErp(param);
}else {//出 }
}else{
//按明细回传
List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(
new QueryWrapper<IOStorInvDtl>().lambda()
.eq(IOStorInvDtl::getIostorinv_id, row.getString("iostorinv_id")));
for (IOStorInvDtl dtlDao : dtls) {
//如果是用料出库,则需回传 //如果是用料出库,则需回传
if(ObjectUtil.isNotEmpty(dtl.getSource_bill_code())){ if (ObjectUtil.isNotEmpty(dtlDao.getSource_bill_code())) {
//判断用料清单是否合单 //判断用料清单是否合单
PmFormData pmform = pmFormDataMapper.selectById(dtl.getSource_billdtl_id()); PmFormData pmform = pmFormDataMapper.selectById(dtlDao.getSource_billdtl_id());
if("0".equals(pmform.getNew_merge_flag())){ if ("0".equals(pmform.getNew_merge_flag())) {
List<IOStorInvDis> iosDisList = ioStorInvDisMapper.selectList(
new QueryWrapper<IOStorInvDis>().lambda()
.eq(IOStorInvDis::getIostorinv_id, row.getString("iostorinv_id")));
for (IOStorInvDis disDao : iosDisList) {
JSONObject param = new JSONObject();
// 载具编码 // 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code()); param.put("pallet_sn", disDao.getStoragevehicle_code());
// 数量 // 数量
param.put("qty", disDao.getReal_qty()); param.put("qty", disDao.getReal_qty());
// 单据号 // 单据号
param.put("order_code", dtl.getSource_bill_code()); param.put("order_code", dtlDao.getSource_bill_code());
// 业务类型 // 业务类型
param.put("order_type", dtl.getSource_bill_type()); param.put("order_type", dtlDao.getSource_bill_type());
// 业务类型 // 业务类型
param.put("outstor_time", mst.getConfirm_time()); param.put("outstor_time", mst.getConfirm_time());
}else{//合单
}
wmsToErpService.outstorinfoToErp(param); wmsToErpService.outstorinfoToErp(param);
}
}
}
BigDecimal total_qty = pmform.getTotal_qty();
total_qty.add(disDao.getReal_qty());
//更新分配数量
pmform.setTotal_qty(total_qty);
if(total_qty.compareTo(pmform.getQty()) >=0){
//更新订单是否完成
pmform.setIs_finish("1");
pmFormDataMapper.updateById(pmform);
}
}
} else {//合单
String[] codes = pmform.getMerge_codes().split(",");
List<IOStorInvDis> iosDisList = ioStorInvDisMapper.selectList(
new QueryWrapper<IOStorInvDis>().lambda()
.eq(IOStorInvDis::getIostorinv_id, row.getString("iostorinv_id")));
for (IOStorInvDis disDao : iosDisList) {
//查询未完成分配的订单
List<PmFormData> pmformList = pmFormDataMapper.selectList( new QueryWrapper<PmFormData>().lambda()
.in(PmFormData::getCode, codes)
.eq(PmFormData::getIs_finish,"0")
);
//明细数量
BigDecimal real_qty = disDao.getReal_qty();
for (PmFormData formDao : pmformList) {
JSONObject param = new JSONObject();
//剩余数量
BigDecimal un_qty = formDao.getQty().subtract(formDao.getTotal_qty());
//订单数刚好等于明细数
if(real_qty.compareTo(un_qty) == 0){
//更新分配数量
formDao.setTotal_qty(formDao.getQty());
//更新订单是否完成
formDao.setIs_finish("1");
pmFormDataMapper.updateById(formDao);
// 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code());
// 数量
param.put("qty", real_qty);
// 单据号
param.put("order_code", formDao.getCode());
// 业务类型
param.put("order_type", formDao.getForm_type());
// 业务类型
param.put("outstor_time", mst.getConfirm_time());
wmsToErpService.outstorinfoToErp(param);
break;
}else //明细数大于订单数
if(real_qty.compareTo(un_qty) > 0){
//更新分配数量
formDao.setTotal_qty(formDao.getQty());
//更新订单是否完成
formDao.setIs_finish("1");
pmFormDataMapper.updateById(formDao);
// 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code());
// 数量
param.put("qty", un_qty);
// 单据号
param.put("order_code", formDao.getCode());
// 业务类型
param.put("order_type", formDao.getForm_type());
// 业务类型
param.put("outstor_time", mst.getConfirm_time());
wmsToErpService.outstorinfoToErp(param);
//更新明细可分配数
real_qty = real_qty.subtract(un_qty);
}else //明细数小于订单数
if(real_qty.compareTo(un_qty) < 0){
//更新分配数量
formDao.setTotal_qty(formDao.getTotal_qty().add(real_qty));
pmFormDataMapper.updateById(formDao);
// 载具编码
param.put("pallet_sn", disDao.getStoragevehicle_code());
// 数量
param.put("qty", real_qty);
// 单据号
param.put("order_code", formDao.getCode());
// 业务类型
param.put("order_type", formDao.getForm_type());
// 业务类型
param.put("outstor_time", mst.getConfirm_time());
wmsToErpService.outstorinfoToErp(param);
break;
}
}
}
}
}
}
}
}
// 更新主表 // 更新主表
this.update( this.update(
new UpdateWrapper<IOStorInv>().lambda() new UpdateWrapper<IOStorInv>().lambda()