opt:回传优化
This commit is contained in:
@@ -46,7 +46,7 @@ public class FIFORuleHandler extends Decisioner<StrategyStructMaterialVO, Strate
|
||||
, "sect_code", param.getSect_code()
|
||||
, "plan_qty", planQty
|
||||
, "is_lock", "false"
|
||||
, "order_by", "gro.update_time asc")
|
||||
, "order_by", "gro.update_time asc, gro.qty asc")
|
||||
);
|
||||
if (ObjectUtils.isEmpty(vechielDtos)) {
|
||||
throw new BadRequestException("当前出库策略:先进先出,库存分配失败,失败原因:库存不足!");
|
||||
|
||||
@@ -23,23 +23,25 @@ public class WmsToErpServiceImpl implements WmsToErpService {
|
||||
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ERP_URL).getValue();
|
||||
url = url + EXTConstant.IN_STOR_INFO;
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(whereJson))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("instorinfoToErp回传接口输出参数为:-------------------" + result.toString());
|
||||
String is_connect_erp = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.IS_CONNECT_ERP).getValue();
|
||||
if(is_connect_erp.equals("1")){
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(whereJson))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("instorinfoToErp回传接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
|
||||
|
||||
String status = result.getString("status");
|
||||
if (!EXTConstant.ERROR.equals(status)) {
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
String status = result.getString("status");
|
||||
if (!EXTConstant.ERROR.equals(status)) {
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("ERP提示错误:" + e.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("ERP提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -52,23 +54,26 @@ public class WmsToErpServiceImpl implements WmsToErpService {
|
||||
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ERP_URL).getValue();
|
||||
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 {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(whereJson))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("outstorinfoToErp回传接口输出参数为:-------------------" + result.toString());
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(whereJson))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("outstorinfoToErp回传接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
|
||||
|
||||
String status = result.getString("status");
|
||||
if (!EXTConstant.ERROR.equals(status)) {
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
String status = result.getString("status");
|
||||
if (!EXTConstant.ERROR.equals(status)) {
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("ERP提示错误:" + e.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("ERP提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class PmFormData implements Serializable {
|
||||
*/
|
||||
private BigDecimal assign_qty;
|
||||
|
||||
|
||||
private BigDecimal total_qty;
|
||||
/**
|
||||
* 数量单位
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,9 @@ public class SysParamConstant {
|
||||
*/
|
||||
public final static String IS_CONNECT_ACS = "is_connect_acs";
|
||||
|
||||
public final static String IS_CONNECT_ERP = "is_connect_erp";
|
||||
|
||||
|
||||
/**
|
||||
* ACS系统IP
|
||||
*/
|
||||
|
||||
@@ -1181,15 +1181,6 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
form.setIs_finish("1");
|
||||
form.setAssign_qty(form.getQty());
|
||||
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)
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -96,48 +97,147 @@ public class RetrunServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
||||
@Override
|
||||
public void upload(JSONObject whereJson) {
|
||||
List<JSONObject> rows = whereJson.getJSONArray("rows").toJavaList(JSONObject.class);
|
||||
// 根据主表id查询所有分配明细
|
||||
List<IOStorInvDis> iosDisList = ioStorInvDisMapper.selectList(
|
||||
new QueryWrapper<IOStorInvDis>().lambda()
|
||||
.in(IOStorInvDis::getIostorinv_id, rows.stream()
|
||||
.map(row -> row.getString("iostorinv_id"))
|
||||
.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();
|
||||
//入库
|
||||
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{//合单
|
||||
|
||||
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查询所有分配明细
|
||||
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("instor_time", mst.getConfirm_time());
|
||||
wmsToErpService.instorinfoToErp(param);
|
||||
}
|
||||
}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(dtlDao.getSource_bill_code())) {
|
||||
//判断用料清单是否合单
|
||||
PmFormData pmform = pmFormDataMapper.selectById(dtlDao.getSource_billdtl_id());
|
||||
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("qty", disDao.getReal_qty());
|
||||
// 单据号
|
||||
param.put("order_code", dtlDao.getSource_bill_code());
|
||||
// 业务类型
|
||||
param.put("order_type", dtlDao.getSource_bill_type());
|
||||
// 业务类型
|
||||
param.put("outstor_time", mst.getConfirm_time());
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wmsToErpService.outstorinfoToErp(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新主表
|
||||
this.update(
|
||||
new UpdateWrapper<IOStorInv>().lambda()
|
||||
|
||||
Reference in New Issue
Block a user