1.修改提交单据查询第三方系统数据逻辑,变更默认取值thirdId为动态取值

master
x_z 3 years ago
parent 4338e206a3
commit bbf1313ee7

@ -2,9 +2,8 @@ package com.glxp.api.admin.service.business.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageHelper;
@ -27,15 +26,12 @@ import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.api.admin.httpclient.UdiwmsOrderResponse;
import com.glxp.api.admin.httpclient.req.UdiwmsOrderDetail;
import com.glxp.api.admin.httpclient.req.UdiwmsOrderRequest;
import com.glxp.api.admin.req.basic.BussinessLocalTypeFilterRequest;
import com.glxp.api.admin.req.business.StockOrderDetailFilterRequest;
import com.glxp.api.admin.req.business.StockOrderFilterRequest;
import com.glxp.api.admin.req.business.StockOrderQueryRequest;
import com.glxp.api.admin.res.basic.BussinessTypResponse;
import com.glxp.api.admin.res.business.StockOrderDetailEntityVo;
import com.glxp.api.admin.res.business.StockOrderExportResponse;
import com.glxp.api.admin.service.basic.BussinessLocalTypeService;
import com.glxp.api.admin.service.basic.BussinessTypeService;
import com.glxp.api.admin.service.basic.UdiRelevanceService;
import com.glxp.api.admin.service.business.StockOrderService;
import com.glxp.api.admin.service.inout.OrderService;
@ -44,6 +40,7 @@ import com.glxp.api.admin.service.thrsys.ThrInvWarehouseService;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -53,6 +50,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Slf4j
@Service
public class StockOrderServiceImpl implements StockOrderService {
@ -214,28 +212,46 @@ public class StockOrderServiceImpl implements StockOrderService {
BasicThirdSysBusApiEntity thirdSysBusApiEntity = thirdSysBusApiDao.selectByCode(stockOrderEntity.getBillType());
udiwmsOrderRequest.setThirdSys(thirdSysBusApiEntity.getThirdSys()); //第三方系统标识
udiwmsOrderRequest.setBillType(thirdSysBusApiEntity.getThirdBuyCode());
String thirdId = getThirdId(thirdSysBusApiEntity);
if (bussinessLocalTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT) {
udiwmsOrderRequest.setCorpId(stockOrderEntity.getCorpName()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(stockOrderEntity.getCorpName()); //往来单位名称,需转换为第三方系统的名称
} else if (bussinessLocalTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INNOR) {
InvWarehouseEntity invWarehouseEntity = invWarehouseService.selectByCode(stockOrderEntity.getCorpId());
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseService.selectByCode(invWarehouseEntity.getThirdId());
udiwmsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); //往来单位名称,需转换为第三方系统的名称
try {
//根据第三方系统标识,获取对应字段的值
String thirdSysFk = (String) ReflectUtil.getFieldValue(invWarehouseEntity, invWarehouseEntity.getClass().getField(thirdId));
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseService.selectByCode(invWarehouseEntity.getThirdId(), thirdSysFk);
udiwmsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); //往来单位名称,需转换为第三方系统的名称
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} else if (bussinessLocalTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) {
//查询往来单位第三方系统对照编码
UnitMaintainEntity
unitMaintainEntity = unitMaintainDao.selectThirdInfoByErpId(stockOrderEntity.getCorpId());
udiwmsOrderRequest.setCorpId(unitMaintainEntity.getThirdId()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(unitMaintainEntity.getThirdName()); //往来单位名称,需转换为第三方系统的名称
UnitMaintainEntity unitMaintainEntity = unitMaintainDao.selectThirdInfoByErpId(stockOrderEntity.getCorpId());
try {
String thirdCorpId = (String) ReflectUtil.getFieldValue(unitMaintainEntity, unitMaintainEntity.getClass().getField(thirdId));
udiwmsOrderRequest.setCorpId(thirdCorpId); //往来单位编码需转换为第三方系统的ID
String thirdName = getThirdName(thirdId);
String thirdCorpName = (String) ReflectUtil.getFieldValue(unitMaintainEntity, unitMaintainEntity.getClass().getField(thirdName));
udiwmsOrderRequest.setCorpName(thirdCorpName); //往来单位名称,需转换为第三方系统的名称
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
InvWarehouseEntity invWarehouseEntity = invWarehouseService.selectByCode(stockOrderEntity.getLocStorageCode());
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseService.selectByCode(invWarehouseEntity.getThirdId());
udiwmsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
udiwmsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
try {
String thirdSysFk = (String) ReflectUtil.getFieldValue(invWarehouseEntity, invWarehouseEntity.getClass().getField(thirdId));
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseService.selectByCode(invWarehouseEntity.getThirdId(), thirdSysFk);
udiwmsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
udiwmsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
udiwmsOrderRequest.setBillFlag(stockOrderEntity.getBillFlag());//单据状态
@ -252,13 +268,21 @@ public class StockOrderServiceImpl implements StockOrderService {
//组装明细数据
List<UdiwmsOrderDetail> items = new ArrayList<>(stockOrderDetailEntities.size());
for (StockOrderDetailEntity stockOrderDetailEntity : stockOrderDetailEntities) {
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectById(stockOrderDetailEntity.getRelId());
UdiwmsOrderDetail item = new UdiwmsOrderDetail();
BeanUtil.copyProperties(stockOrderDetailEntity, item);
item.setProductId(udiRelevanceEntity.getThirdId());
item.setProductName(udiRelevanceEntity.getThirdName());
items.add(item);
try {
String thirdProductId = (String) ReflectUtil.getFieldValue(udiRelevanceEntity, udiRelevanceEntity.getClass().getField(thirdId));
item.setProductId(thirdProductId);
String thirdName = getThirdName(thirdId);
String thirdProductName = (String) ReflectUtil.getFieldValue(udiRelevanceEntity, udiRelevanceEntity.getClass().getField(thirdName));
item.setProductName(thirdProductName);
items.add(item);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
udiwmsOrderRequest.setItem(items);
@ -293,4 +317,62 @@ public class StockOrderServiceImpl implements StockOrderService {
}
}
/**
*
*
* @param thirdId
* @return
*/
private String getThirdName(String thirdId) {
String thirdName = null;
switch (thirdId) {
case "thirdId":
thirdName = "thirdName";
break;
case "thirdId1":
thirdName = "thirdName1";
break;
case "thirdId2":
thirdName = "thirdName2";
break;
case "thirdId3":
thirdName = "thirdName3";
break;
case "thirdId4":
thirdName = "thirdName4";
break;
default:
break;
}
return thirdName;
}
/**
* @param thirdSysBusApiEntity
* @return
*/
private String getThirdId(BasicThirdSysBusApiEntity thirdSysBusApiEntity) {
String thirdId = null;
switch (thirdSysBusApiEntity.getThirdSys()) {
case "thirdId":
thirdId = "thirdId";
break;
case "third1":
thirdId = "thirdId1";
break;
case "third2":
thirdId = "thirdId2";
break;
case "third3":
thirdId = "thirdId3";
break;
case "third4":
thirdId = "thirdId4";
break;
default:
break;
}
return thirdId;
}
}

@ -24,7 +24,7 @@ public interface ThrInvWarehouseService {
ThrInvWarehouseEntity selectById(String id);
ThrInvWarehouseEntity selectByCode(String code);
ThrInvWarehouseEntity selectByCode(String code, String thirdSysFk);
boolean deleteById(String id);

@ -1,6 +1,5 @@
package com.glxp.api.admin.service.thrsys.impl;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.admin.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity;
@ -9,7 +8,6 @@ import com.glxp.api.admin.req.erp.UdiwmsWarehouseRequest;
import com.glxp.api.admin.req.thrsys.FilterThrInvWarehouseRequest;
import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.erp.UdiwmsWarehouseDetail;
import com.glxp.api.admin.res.erp.UdiwmsWarehouseResponse;
import com.glxp.api.admin.service.thrsys.ThrInvWarehouseService;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
@ -87,9 +85,10 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
}
@Override
public ThrInvWarehouseEntity selectByCode(String code) {
public ThrInvWarehouseEntity selectByCode(String code, String thirdSysFk) {
FilterThrInvWarehouseRequest thrInvWarehouseRequest = new FilterThrInvWarehouseRequest();
thrInvWarehouseRequest.setCode(code);
thrInvWarehouseRequest.setThirdSysFk(thirdSysFk);
List<ThrInvWarehouseEntity> invWarehouseEntities = thrInvWarehouseDao.filterThrInvWarehouse(thrInvWarehouseRequest);
if (invWarehouseEntities != null && invWarehouseEntities.size() > 0)
return invWarehouseEntities.get(0);

Loading…
Cancel
Save