|
|
|
@ -21,10 +21,7 @@ import com.glxp.mipsdl.admin.dao.inventory.InvWarehouseDao;
|
|
|
|
|
import com.glxp.mipsdl.admin.dao.phxyy.BasicThirdSysDetailDao;
|
|
|
|
|
import com.glxp.mipsdl.admin.dao.thrsys.ThrInvWarehouseDao;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.auth.AuthAdmin;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.basic.BasicThirdSysBusApiEntity;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.basic.BussinessLocalTypeEntity;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.basic.UdiRelevanceEntity;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.basic.UnitMaintainEntity;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.basic.*;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.business.StockOrderDetailEntity;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.business.StockOrderEntity;
|
|
|
|
|
import com.glxp.mipsdl.admin.entity.business.StockOrderUploadLogEntity;
|
|
|
|
@ -45,6 +42,7 @@ import com.glxp.mipsdl.admin.res.system.PageSimpleResponse;
|
|
|
|
|
import com.glxp.mipsdl.admin.res.system.UdiwmsWarehouseDetail;
|
|
|
|
|
import com.glxp.mipsdl.admin.util.DateUtil;
|
|
|
|
|
import com.glxp.mipsdl.admin.util.HttpClient;
|
|
|
|
|
import com.glxp.mipsdl.admin.util.ThirdUtils;
|
|
|
|
|
import com.glxp.mipsdl.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.mipsdl.common.util.ResultVOUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -115,20 +113,27 @@ public class ZaxyyClient {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseResponse testConnect() {
|
|
|
|
|
String msgHead = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
|
|
|
|
"<root>" +
|
|
|
|
|
"<serverName>getMasterialInput</serverName>" +
|
|
|
|
|
"</root>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String msgBody = "{\"billNo\":\"ZY202205070001\",\"billdate\":\"2022-05-07\",\"corpId\":\"65119908299161\",\"corpName\":\"福建片仔癀诊断技术有限公司\",\"billType\":\"采购入库\",\"billFlag\":\"1\",\"thirdSys\":\"thirdId\",\"locInvCode\":\"11001\",\"locInvName\":\"总仓库\",\"inoutType\":\"1\",\"remark\":\"\",\"item\":[{\"billNo\":\"ZY202205070001\",\"productId\":\"7864\",\"productName\":\"通用脊柱内固定器-6.0 连接棒\",\"standard\":\"70-450mm/理贝尔\",\"expireDate\":\"2025-01-03\",\"productDate\":\"2021-03-01\",\"batchNo\":\"202003\",\"count\":10,\"measname\":\"计量单位\",\"registerNo\":\"国食药监械(准)字 2006 第 3460057 号\",\"price\":10.0,\"secSalesInvNo\":\"21232424\",\"invoiceDate\":\"2323243\",\"secSalesListNo\":\"42342\",\"firstSalesInvNo\":\"423424\",\"remark\":\"\",\"remakr1\":\"\",\"remakr2\":\"\",\"codeList\":[{\"code\":\"01069125473843801121041410210290075\",\"nameCode\":\"06912547384380\",\"count\":1}]},{\"productId\":\"7901\",\"productName\":\"亲水性丙烯酸折叠式人工晶状体 Hydrophilic AcrylicFoldableIntraocular Lens\",\"standard\":\"S1AW00\",\"batchNo\":\"202103\",\"expireDate\":\"2025-01-03\",\"productDate\":\"2021-03-01\",\"count\":10,\"measname\":\"计量单位\",\"registerNo\":\"国械注进 20153162635\",\"price\":10.0,\"secSalesInvNo\":\"21232424\",\"invoiceDate\":\"2323243\",\"secSalesListNo\":\"42342\",\"firstSalesInvNo\":\"423424\",\"remark\":\"\",\"remakr1\":\"\",\"remakr2\":\"\",\"codeList\":[{\"code\":\"01069125473843801121041410210290075\",\"nameCode\":\"06912547384380\",\"count\":1}]}]}";
|
|
|
|
|
|
|
|
|
|
PhUnitRequest unitRequest = new PhUnitRequest();
|
|
|
|
|
unitRequest.setPage(1);
|
|
|
|
|
unitRequest.setLimit(1);
|
|
|
|
|
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("corpUrl", thirdSysConfig.getThirdSysConfig().getThirdId());
|
|
|
|
|
ZaZyHeareRequest zaZyHeareRequest = new ZaZyHeareRequest();
|
|
|
|
|
zaZyHeareRequest.setMsgHeader(msgHead);
|
|
|
|
|
zaZyHeareRequest.setMsgBody(msgBody);
|
|
|
|
|
String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl(), zaZyHeareRequest, getHeaderArray());
|
|
|
|
|
log.info(response);
|
|
|
|
|
return ResultVOUtils.error(500, "连接成功!");
|
|
|
|
|
zaZyHeareRequest.setMsgHeader(getMsgHeader("getMaterialUnit"));
|
|
|
|
|
zaZyHeareRequest.setMsgBody(JSONUtil.toJsonStr(unitRequest));
|
|
|
|
|
String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), zaZyHeareRequest, getHeaderArray());
|
|
|
|
|
response = parseErrorMsg(response);
|
|
|
|
|
try {
|
|
|
|
|
BaseResponse baseResponse =
|
|
|
|
|
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
|
|
|
});
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
return ResultVOUtils.success("连接成功!");
|
|
|
|
|
}
|
|
|
|
|
return baseResponse;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果" + "(" + response + ")");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -239,8 +244,12 @@ public class ZaxyyClient {
|
|
|
|
|
}
|
|
|
|
|
//查询单据和详情信息,组装第三方系统接口参数所需数据
|
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.findById(udiwmsOrderRequest.getId());
|
|
|
|
|
|
|
|
|
|
OrderEntity orderEntity = orderDao.findById(stockOrderEntity.getOrderIdFk());
|
|
|
|
|
List<StockOrderDetailEntity> stockOrderDetailEntities = stockOrderDetailDao.findByOrderIdFk(stockOrderEntity.getId());
|
|
|
|
|
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeDao.selectByAction(orderEntity.getAction());
|
|
|
|
|
|
|
|
|
|
udiwmsOrderRequest.setBillDate(stockOrderEntity.getBilldate());
|
|
|
|
|
udiwmsOrderRequest.setBillNo(stockOrderEntity.getBillNo());
|
|
|
|
|
|
|
|
|
@ -254,8 +263,14 @@ public class ZaxyyClient {
|
|
|
|
|
if (StrUtil.isBlank(thirdSysBusApiEntity.getUrl())) {
|
|
|
|
|
return ResultVOUtils.error(500, "接口未配置,无法提交!");
|
|
|
|
|
}
|
|
|
|
|
String thirdId = getThirdId(thirdSysBusApiEntity);
|
|
|
|
|
udiwmsOrderRequest.setThirdSys(thirdId); //第三方系统标识
|
|
|
|
|
String thirdId = ThirdUtils.getThirdId(thirdSysBusApiEntity);
|
|
|
|
|
Integer userId = 0;
|
|
|
|
|
if (orderEntity.getReviewUser() != null) {
|
|
|
|
|
userId = orderEntity.getReviewUser();
|
|
|
|
|
} else userId = orderEntity.getCreateUser();
|
|
|
|
|
|
|
|
|
|
AuthAdmin authAdmin = authAdminDao.findById(userId.longValue());
|
|
|
|
|
udiwmsOrderRequest.setThirdSys(authAdmin.getEmployeeName()); //第三方系统标识
|
|
|
|
|
udiwmsOrderRequest.setBillType(thirdSysBusApiEntity.getThirdBuyCode());
|
|
|
|
|
|
|
|
|
|
if (bussinessLocalTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT) {
|
|
|
|
@ -283,7 +298,7 @@ public class ZaxyyClient {
|
|
|
|
|
String thirdCorpId = (String) ReflectUtil.getFieldValue(unitMaintainEntity, unitMaintainEntity.getClass().getField(thirdId));
|
|
|
|
|
udiwmsOrderRequest.setCorpId(thirdCorpId); //往来单位编码,需转换为第三方系统的ID
|
|
|
|
|
|
|
|
|
|
String thirdName = getThirdName(thirdId);
|
|
|
|
|
String thirdName = ThirdUtils.getThirdName(thirdId);
|
|
|
|
|
String thirdCorpName = (String) ReflectUtil.getFieldValue(unitMaintainEntity, unitMaintainEntity.getClass().getField(thirdName));
|
|
|
|
|
udiwmsOrderRequest.setCorpName(thirdCorpName); //往来单位名称,需转换为第三方系统的名称
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -291,7 +306,7 @@ public class ZaxyyClient {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOneByCode(stockOrderEntity.getLocStorageCode());
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOneByCode(orderEntity.getFromSubInvCode());
|
|
|
|
|
try {
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectByCode(invWarehouseEntity.getThirdId(), thirdId);
|
|
|
|
|
udiwmsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
|
|
|
|
@ -299,9 +314,7 @@ public class ZaxyyClient {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("查询第三方系统仓库异常", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
udiwmsOrderRequest.setBillFlag(stockOrderEntity.getBillFlag()); //单据状态
|
|
|
|
|
|
|
|
|
|
//查询单据出入库类型
|
|
|
|
|
String mainAction = bussinessTypeDao.selectInoutTypebByLocalAction(stockOrderEntity.getBillType());
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(mainAction)) {
|
|
|
|
@ -309,7 +322,6 @@ public class ZaxyyClient {
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(mainAction)) {
|
|
|
|
|
udiwmsOrderRequest.setInoutType(2); //出入库类型:出库
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
udiwmsOrderRequest.setRemark("udi管理系统提交单据"); //备注
|
|
|
|
|
|
|
|
|
|
//组装明细数据
|
|
|
|
@ -325,7 +337,6 @@ public class ZaxyyClient {
|
|
|
|
|
if (StrUtil.isNotEmpty(stockOrderDetailEntity.getExpireDate())) {
|
|
|
|
|
item.setExpireDate(DateUtil.formatExpireTime("20" + stockOrderDetailEntity.getExpireDate()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.setMeasname(udiRelevanceEntity.getMeasname());
|
|
|
|
|
item.setStandard(stockOrderDetailEntity.getSpec());
|
|
|
|
|
item.setRegisterNo(stockOrderDetailEntity.getZczbhhzbapzbh());
|
|
|
|
@ -343,7 +354,7 @@ public class ZaxyyClient {
|
|
|
|
|
String thirdProductId = (String) ReflectUtil.getFieldValue(udiRelevanceEntity, thirdId);
|
|
|
|
|
item.setProductId(thirdProductId);
|
|
|
|
|
|
|
|
|
|
String thirdName = getThirdName(thirdId);
|
|
|
|
|
String thirdName = ThirdUtils.getThirdName(thirdId);
|
|
|
|
|
String thirdProductName = (String) ReflectUtil.getFieldValue(udiRelevanceEntity, thirdName);
|
|
|
|
|
item.setProductName(thirdProductName);
|
|
|
|
|
items.add(item);
|
|
|
|
@ -355,11 +366,11 @@ public class ZaxyyClient {
|
|
|
|
|
udiwmsOrderRequest.setItem(items);
|
|
|
|
|
|
|
|
|
|
//查询扫码单据
|
|
|
|
|
OrderEntity orderEntity = orderDao.findById(stockOrderEntity.getOrderIdFk());
|
|
|
|
|
|
|
|
|
|
ZaZyHeareRequest zaZyHeareRequest = new ZaZyHeareRequest();
|
|
|
|
|
|
|
|
|
|
String key = null;
|
|
|
|
|
|
|
|
|
|
//提交订单到第三方系统
|
|
|
|
|
if (thirdSysBusApiEntity.getUrl().equals("saveMasterialInput")) {
|
|
|
|
|
//采购入库单据
|
|
|
|
@ -367,9 +378,9 @@ public class ZaxyyClient {
|
|
|
|
|
key = "orderSubmitUrl";
|
|
|
|
|
zaZyHeareRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsOrderRequest));
|
|
|
|
|
} else if (thirdSysBusApiEntity.getUrl().equals("saveMaterialHight")) {
|
|
|
|
|
udiwmsOrderRequest.setLocStorageCode("1001304");
|
|
|
|
|
udiwmsOrderRequest.setLocStorageName("骨科耗材及试剂仓库");
|
|
|
|
|
//临床出库
|
|
|
|
|
udiwmsOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode());
|
|
|
|
|
udiwmsOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName());
|
|
|
|
|
zaZyHeareRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
|
|
|
|
|
key = "preInOrderSubmit";
|
|
|
|
|
|
|
|
|
@ -377,9 +388,6 @@ public class ZaxyyClient {
|
|
|
|
|
zaZyHeareRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByOrderType(key, thirdSysConfig.getThirdSysConfig().getThirdId(), udiwmsOrderRequest.getBillType());
|
|
|
|
|
|
|
|
|
|
//记录日志
|
|
|
|
|
StockOrderUploadLogEntity uploadLog = new StockOrderUploadLogEntity();
|
|
|
|
|
uploadLog.setBillDate(DateUtil.parseDate(udiwmsOrderRequest.getBillDate()));
|
|
|
|
@ -399,9 +407,10 @@ public class ZaxyyClient {
|
|
|
|
|
orderEntity.setExportStatus(1);
|
|
|
|
|
orderEntity.setThirdBillNo(thirdBillNo);
|
|
|
|
|
uploadLog.setStatus(2);
|
|
|
|
|
uploadLog.setThrBillNo(null);
|
|
|
|
|
uploadLog.setThrBillNo(thirdBillNo);
|
|
|
|
|
uploadLog.setResult("提交成功");
|
|
|
|
|
stockOrderUploadLogDao.insert(uploadLog);
|
|
|
|
|
orderDao.updateOrder(orderEntity);
|
|
|
|
|
return ResultVOUtils.success("提交成功");
|
|
|
|
|
}
|
|
|
|
|
uploadLog.setStatus(3);
|
|
|
|
@ -411,7 +420,7 @@ public class ZaxyyClient {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
uploadLog.setStatus(3);
|
|
|
|
|
uploadLog.setResult("提交失败,错误信息:" + e.getMessage());
|
|
|
|
|
uploadLog.setResult("提交失败,错误信息:" + response);
|
|
|
|
|
stockOrderUploadLogDao.insert(uploadLog);
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败");
|
|
|
|
|
}
|
|
|
|
@ -475,17 +484,18 @@ public class ZaxyyClient {
|
|
|
|
|
|
|
|
|
|
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("warehouseQueryUrl", thirdSysConfig.getThirdSysConfig().getThirdId());
|
|
|
|
|
String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), zaZyHeareRequest, getHeaderArray());
|
|
|
|
|
// String response = FileUtils.readFileAll("E:\\第三方测试数据\\仓库第三发.json");
|
|
|
|
|
response = parseErrorMsg(response);
|
|
|
|
|
try {
|
|
|
|
|
BaseResponse<PageSimpleResponse<UdiwmsWarehouseDetail>> baseResponse =
|
|
|
|
|
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
|
|
|
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<UdiwmsWarehouseDetail>>>() {
|
|
|
|
|
});
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
List<UdiwmsWarehouseDetail> udiwmsWarehouseDetails = baseResponse.getData().getList();
|
|
|
|
|
UdiwmsWarehouseDetail resultData = new UdiwmsWarehouseDetail();
|
|
|
|
|
if (CollUtil.isNotEmpty(udiwmsWarehouseDetails)) {
|
|
|
|
|
resultData.setCode("7071568");
|
|
|
|
|
resultData.setCode("总仓库");
|
|
|
|
|
resultData.setName("总仓库");
|
|
|
|
|
List<UdiwmsWarehouseDetail.SubWarehouse> subWarehouseList = new ArrayList<>();
|
|
|
|
|
for (UdiwmsWarehouseDetail udiwmsWarehouseDetail : udiwmsWarehouseDetails) {
|
|
|
|
|
UdiwmsWarehouseDetail.SubWarehouse subWarehouse = new UdiwmsWarehouseDetail.SubWarehouse();
|
|
|
|
@ -572,62 +582,5 @@ public class ZaxyyClient {
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取第三方名称字段
|
|
|
|
|
*
|
|
|
|
|
* @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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|