|
|
|
@ -1,44 +1,119 @@
|
|
|
|
|
package com.glxp.mipsdl.client.ctqyy;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.glxp.mipsdl.client.CommonHttpClient;
|
|
|
|
|
import com.glxp.mipsdl.config.ThirdSysConfig;
|
|
|
|
|
import com.glxp.mipsdl.constant.ConstantType;
|
|
|
|
|
import com.glxp.mipsdl.constant.Constants;
|
|
|
|
|
import com.glxp.mipsdl.dao.auth.AuthUserDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.auth.AuthWarehouseDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper;
|
|
|
|
|
import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.basic.BasicCorpDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.basic.BasicProductsDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.basic.BasicUdirelDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.inout.*;
|
|
|
|
|
import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
|
|
|
|
|
import com.glxp.mipsdl.entity.auth.AuthUserEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.auth.AuthWarehouseUser;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicCorpEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicProductsEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicUdirelEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.ctqyy.MaterialDictEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.ctqyy.PriceClassEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.ctqyy.ThrHslbEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.inout.*;
|
|
|
|
|
import com.glxp.mipsdl.entity.thrsys.ThrCorpEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
|
|
|
|
|
import com.glxp.mipsdl.http.HttpClient;
|
|
|
|
|
import com.glxp.mipsdl.req.base.*;
|
|
|
|
|
import com.glxp.mipsdl.req.ctqyy.*;
|
|
|
|
|
import com.glxp.mipsdl.req.post.*;
|
|
|
|
|
import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest;
|
|
|
|
|
import com.glxp.mipsdl.req.zzzyy.ZzzyyRequest;
|
|
|
|
|
import com.glxp.mipsdl.res.BaseResponse;
|
|
|
|
|
import com.glxp.mipsdl.res.ctqyy.CtBaseResponse;
|
|
|
|
|
import com.glxp.mipsdl.res.udiwms.*;
|
|
|
|
|
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
|
|
|
|
|
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
|
|
|
|
|
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
|
|
|
|
|
import com.glxp.mipsdl.util.DateUtil;
|
|
|
|
|
import com.glxp.mipsdl.util.IntUtil;
|
|
|
|
|
import com.glxp.mipsdl.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.mipsdl.util.SubmitOrderUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.dom4j.Document;
|
|
|
|
|
import org.dom4j.DocumentException;
|
|
|
|
|
import org.dom4j.DocumentHelper;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service(value = "100011HttpClient")
|
|
|
|
|
public class CtqyyClient extends CommonHttpClient {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
AuthWarehouseUserMapper authWarehouseUserMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrSystemDetailService thrSystemDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
private HttpClient httpClient;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SubmitOrderUtil submitOrderUtil;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderUploadLogDao orderUploadLogDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderDao orderDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrSystemBusApiDao thrSystemBusApiDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicBussinessTypeDao basicBussinessTypeDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicCorpDao basicCorpDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoCodeDao codeDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private AuthWarehouseDao authWarehouseDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrInvWarehouseDao thrInvWarehouseDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private AuthWarehouseService authWarehouseService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThirdSysConfig thirdSysConfig;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrCorpService thrCorpService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderDetailBizDao orderDetailBizDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderDetailCodeDao orderDetailCodeDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private AuthUserDao authUserDao;
|
|
|
|
|
@Resource
|
|
|
|
|
BasicUdirelDao basicUdirelDao;
|
|
|
|
|
@Resource
|
|
|
|
|
BasicProductsDao basicProductsDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拼接xml请求头
|
|
|
|
|
*
|
|
|
|
@ -151,7 +226,7 @@ public class CtqyyClient extends CommonHttpClient {
|
|
|
|
|
return ResultVOUtils.error(500, "提交产品列表不能为空!");
|
|
|
|
|
}
|
|
|
|
|
MaterialDictEntity materialDictEntity = new MaterialDictEntity();
|
|
|
|
|
if (udiRelevanceResponse.getMainId().isEmpty() && StrUtil.isNotEmpty(udiRelevanceResponse.getOriginUuid()))
|
|
|
|
|
if (StrUtil.isEmpty(udiRelevanceResponse.getMainId()) && StrUtil.isNotEmpty(udiRelevanceResponse.getOriginUuid()))
|
|
|
|
|
materialDictEntity.setOperatType("1");
|
|
|
|
|
else
|
|
|
|
|
materialDictEntity.setOperatType("2");
|
|
|
|
@ -183,7 +258,7 @@ public class CtqyyClient extends CommonHttpClient {
|
|
|
|
|
try {
|
|
|
|
|
log.error("提交新增产品信息:" + ctqyyRequest.getMsgBody());
|
|
|
|
|
CtBaseResponse baseResponse = JSONObject.parseObject(response, CtBaseResponse.class);
|
|
|
|
|
if (baseResponse.getReturnCode() != 20000) {
|
|
|
|
|
if (baseResponse.getCode() != 20000) {
|
|
|
|
|
String errMsg = "提交新增产品信息,异常:{}" + response;
|
|
|
|
|
log.error(errMsg);
|
|
|
|
|
return ResultVOUtils.error(500, "提交新增产品失败!");
|
|
|
|
@ -338,11 +413,208 @@ public class CtqyyClient extends CommonHttpClient {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
|
|
|
|
|
return null;
|
|
|
|
|
if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) {
|
|
|
|
|
return ResultVOUtils.error(500, "单据号不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZaxzyyOrderRequest zaxzyyOrderRequest = new ZaxzyyOrderRequest();
|
|
|
|
|
BeanUtil.copyProperties(udiwmsOrderRequest, zaxzyyOrderRequest);
|
|
|
|
|
//查询单据和详情信息,组装第三方系统接口所需参数
|
|
|
|
|
IoOrderEntity orderEntity = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().eq("billNo", udiwmsOrderRequest.getBillNo()));
|
|
|
|
|
|
|
|
|
|
zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
|
|
|
|
|
//查询对应的第三方单据类型
|
|
|
|
|
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new QueryWrapper<ThrSystemBusApiEntity>().eq("code", udiwmsOrderRequest.getBillType()));
|
|
|
|
|
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
|
|
|
|
|
// return ResultVOUtils.error(500, "接口未配置,无法提交!");
|
|
|
|
|
}
|
|
|
|
|
zaxzyyOrderRequest.setOperUser(getUserName(orderEntity));
|
|
|
|
|
zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode());
|
|
|
|
|
zaxzyyOrderRequest.setBillFlag("1");
|
|
|
|
|
|
|
|
|
|
//查询单据类型
|
|
|
|
|
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType());
|
|
|
|
|
if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) {
|
|
|
|
|
//医院客户
|
|
|
|
|
zaxzyyOrderRequest.setCorpId(orderEntity.getFromCorp());
|
|
|
|
|
//查询客户名称
|
|
|
|
|
String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp());
|
|
|
|
|
zaxzyyOrderRequest.setCorpName(corpName);
|
|
|
|
|
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) {
|
|
|
|
|
//内部科室
|
|
|
|
|
BasicCorpEntity basicCorpEntity = null;
|
|
|
|
|
if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) {
|
|
|
|
|
basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
|
|
|
|
|
}
|
|
|
|
|
if (basicCorpEntity != null) {
|
|
|
|
|
zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId());
|
|
|
|
|
zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName());
|
|
|
|
|
} else {
|
|
|
|
|
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper<AuthWarehouseEntity>().eq("code", udiwmsOrderRequest.getCorpId()));
|
|
|
|
|
try {
|
|
|
|
|
//根据第三方系统标识,获取对应字段的值
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
|
|
|
|
|
|
|
|
|
|
zaxzyyOrderRequest.setCorpId(thrInvWarehouseEntity.getCode());
|
|
|
|
|
zaxzyyOrderRequest.setCorpName(thrInvWarehouseEntity.getName());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("查询单据对应往来单位的第三方仓库信息异常", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//供应商
|
|
|
|
|
BasicCorpEntity basicCorpEntity = null;
|
|
|
|
|
if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) {
|
|
|
|
|
basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
|
|
|
|
|
}
|
|
|
|
|
if (basicCorpEntity != null) {
|
|
|
|
|
zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId());
|
|
|
|
|
zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("查询单据对应的第三方往来单位信息异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询仓库信息
|
|
|
|
|
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper<AuthWarehouseEntity>().eq("code", orderEntity.getInvCode()));
|
|
|
|
|
try {
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
|
|
|
|
|
|
|
|
|
|
zaxzyyOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
|
|
|
|
|
zaxzyyOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
|
|
|
|
|
|
|
|
|
|
zaxzyyOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
|
|
|
|
|
zaxzyyOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("查询第三方系统仓库信息异常", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置单据出入库类型
|
|
|
|
|
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
|
|
|
|
|
zaxzyyOrderRequest.setInoutType(1); //入库
|
|
|
|
|
} else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
|
|
|
|
|
zaxzyyOrderRequest.setInoutType(2); //出库
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置备注信息
|
|
|
|
|
zaxzyyOrderRequest.setRemark("udi管理系统提交单据");
|
|
|
|
|
//组装单据明细数据
|
|
|
|
|
List<IoCodeEntity> ioCodeEntities = codeDao.selectList(new QueryWrapper<IoCodeEntity>()
|
|
|
|
|
.eq("orderId", orderEntity.getBillNo())
|
|
|
|
|
.ne("action", "StockCheck")
|
|
|
|
|
);
|
|
|
|
|
List<UdiwmsOrderDetailRequest> items = new ArrayList<>();
|
|
|
|
|
//查询业务单据详情
|
|
|
|
|
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new QueryWrapper<IoOrderDetailBizEntity>().eq("orderIdFk", orderEntity.getBillNo()));
|
|
|
|
|
setOrderDetailList(ioCodeEntities, items, detailBizEntities);
|
|
|
|
|
zaxzyyOrderRequest.setItem(items);
|
|
|
|
|
if (CollUtil.isEmpty(items)) {
|
|
|
|
|
log.error("\"产品信息对照异常,无法上传\"");
|
|
|
|
|
return ResultVOUtils.error(500, "产品信息对照异常,无法上传");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (UdiwmsOrderDetailRequest i : items) {
|
|
|
|
|
String fphm = "";
|
|
|
|
|
String fprq = null;
|
|
|
|
|
List<IoOrderInvoiceEntity> invoiceList = IoOrderInvoiceEntity.builder().build()
|
|
|
|
|
.selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo())
|
|
|
|
|
.eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk())
|
|
|
|
|
.eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.getBatchNo()).
|
|
|
|
|
groupBy(IoOrderInvoiceEntity::getInvoiceEncode));
|
|
|
|
|
if (CollectionUtil.isNotEmpty(invoiceList)) {
|
|
|
|
|
fphm = invoiceList.stream().map(IoOrderInvoiceEntity::getInvoiceEncode).collect(Collectors.joining(","));
|
|
|
|
|
if (invoiceList.get(0).getInvoiceDate() != null)
|
|
|
|
|
fprq = DateUtil.formatDateTime(invoiceList.get(0).getInvoiceDate());
|
|
|
|
|
}
|
|
|
|
|
i.setFirstSalesInvNo(fphm);
|
|
|
|
|
i.setInvoiceDate(fprq);
|
|
|
|
|
}
|
|
|
|
|
//构造诏安接口参数
|
|
|
|
|
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
|
|
|
|
|
|
|
|
|
|
//提交到第三方系统
|
|
|
|
|
if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) {
|
|
|
|
|
//采购入库单据
|
|
|
|
|
|
|
|
|
|
if (vailHightMaterial(detailBizEntities.get(0))) {
|
|
|
|
|
zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
|
|
|
|
|
} else {
|
|
|
|
|
zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String key = "orderSubmitUrl";
|
|
|
|
|
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest));
|
|
|
|
|
} else if (thrSystemBusApiEntity.getUrl().equals("saveMaterialHight")) {
|
|
|
|
|
// zaxzyyOrderRequest.setLocStorageCode("1001304");
|
|
|
|
|
// zaxzyyOrderRequest.setLocStorageName("骨科耗材及试剂仓库");
|
|
|
|
|
//临床出库
|
|
|
|
|
zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
|
|
|
|
|
String key = "preInOrderSubmit";
|
|
|
|
|
|
|
|
|
|
UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity);
|
|
|
|
|
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return submitOrder(orderEntity, zaZyRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验是否高值耗材
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public boolean vailHightMaterial(IoOrderDetailBizEntity orderDetailBizEntity) {
|
|
|
|
|
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(orderDetailBizEntity.getBindRlFk());
|
|
|
|
|
BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne(new QueryWrapper<BasicProductsEntity>().eq("uuid", basicUdirel.getUuid()).last("limit 1"));
|
|
|
|
|
if (basicProductsEntity != null &&
|
|
|
|
|
(StrUtil.trimToEmpty(basicProductsEntity.getBasicPrductRemak7()).equals("1101")
|
|
|
|
|
|| StrUtil.trimToEmpty(basicProductsEntity.getBasicPrductRemak7()).equals("3601"))) {
|
|
|
|
|
return true;
|
|
|
|
|
} else
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getUserName(IoOrderEntity orderEntity) {
|
|
|
|
|
String userName = null;
|
|
|
|
|
//创建人非供应商
|
|
|
|
|
if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) {
|
|
|
|
|
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser());
|
|
|
|
|
if (authUserEntity == null)
|
|
|
|
|
userName = null;
|
|
|
|
|
userName = authUserEntity.getUserName();
|
|
|
|
|
} else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) {
|
|
|
|
|
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser());
|
|
|
|
|
userName = authUserEntity.getUserName();
|
|
|
|
|
} else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) {
|
|
|
|
|
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser());
|
|
|
|
|
userName = authUserEntity.getUserName();
|
|
|
|
|
} else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) {
|
|
|
|
|
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser());
|
|
|
|
|
userName = authUserEntity.getUserName();
|
|
|
|
|
}
|
|
|
|
|
if (userName == null) {
|
|
|
|
|
List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
|
|
|
|
|
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
|
|
|
|
|
return authWarehouseUsers.get(0).getUserName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return userName;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
|
|
|
|
|
return null;
|
|
|
|
@ -380,11 +652,6 @@ public class CtqyyClient extends CommonHttpClient {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) {
|
|
|
|
|
return null;
|
|
|
|
@ -406,4 +673,148 @@ public class CtqyyClient extends CommonHttpClient {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 封装单据详情参数
|
|
|
|
|
*
|
|
|
|
|
* @param ioCodeEntities 单据码明细
|
|
|
|
|
* @param orderDetailRequests 单据详情参数
|
|
|
|
|
* @param detailBizEntities 单据业务详情
|
|
|
|
|
*/
|
|
|
|
|
private void setOrderDetailList(List<IoCodeEntity> ioCodeEntities, List<UdiwmsOrderDetailRequest> orderDetailRequests, List<IoOrderDetailBizEntity> detailBizEntities) {
|
|
|
|
|
for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) {
|
|
|
|
|
|
|
|
|
|
IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeDao
|
|
|
|
|
.selectOne(new QueryWrapper<IoOrderDetailCodeEntity>()
|
|
|
|
|
.eq("orderIdFk", detailBizEntity.getOrderIdFk())
|
|
|
|
|
.eq("bindRlFk", detailBizEntity.getBindRlFk())
|
|
|
|
|
.eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), "batchNo", detailBizEntity.getBatchNo())
|
|
|
|
|
.isNull(StrUtil.isEmpty(detailBizEntity.getBatchNo()), "batchNo").last("LIMIT 1"));
|
|
|
|
|
if (orderDetailCodeEntity != null && IntUtil.value(orderDetailCodeEntity.getReCount()) > 0) {
|
|
|
|
|
detailBizEntity.setCount(orderDetailCodeEntity.getReCount());
|
|
|
|
|
UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity);
|
|
|
|
|
if (item != null) {
|
|
|
|
|
//封装条码信息
|
|
|
|
|
submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item);
|
|
|
|
|
orderDetailRequests.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理提交单据,记录日志,解析结果逻辑
|
|
|
|
|
*
|
|
|
|
|
* @param orderEntity
|
|
|
|
|
* @param zaZyRequest
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private BaseResponse submitOrder(IoOrderEntity orderEntity, ZzzyyRequest zaZyRequest) {
|
|
|
|
|
//记录日志
|
|
|
|
|
IoOrderUploadLogEntity uploadLog = new IoOrderUploadLogEntity();
|
|
|
|
|
uploadLog.setBillDate(orderEntity.getCreateTime());
|
|
|
|
|
uploadLog.setBillType(orderEntity.getAction());
|
|
|
|
|
uploadLog.setSubmitTime(new Date());
|
|
|
|
|
uploadLog.setBillNo(orderEntity.getBillNo());
|
|
|
|
|
uploadLog.setFromType(Constants.THIRD_ORDER_UPLOAD);
|
|
|
|
|
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest);
|
|
|
|
|
response = parserResult(response);
|
|
|
|
|
if (StrUtil.isNotBlank(response)) {
|
|
|
|
|
try {
|
|
|
|
|
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
String thirdBillNo = String.valueOf(baseResponse.getData());
|
|
|
|
|
orderEntity.setThirdBillNo(thirdBillNo);
|
|
|
|
|
orderEntity.setExportStatus(1); //提交成功
|
|
|
|
|
uploadLog.setStatus(2);
|
|
|
|
|
uploadLog.setThrBillNo(thirdBillNo);
|
|
|
|
|
uploadLog.setResult("提交成功");
|
|
|
|
|
orderDao.updateById(orderEntity);
|
|
|
|
|
orderUploadLogDao.insert(uploadLog);
|
|
|
|
|
return ResultVOUtils.success("提交成功");
|
|
|
|
|
}
|
|
|
|
|
uploadLog.setStatus(3);
|
|
|
|
|
uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage());
|
|
|
|
|
orderEntity.setExportStatus(2); //上传失败
|
|
|
|
|
orderDao.updateById(orderEntity);
|
|
|
|
|
orderUploadLogDao.insert(uploadLog);
|
|
|
|
|
return baseResponse;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("解析提交到智业单据返回结果异常,结果信息:{}", response);
|
|
|
|
|
log.error("异常信息:{}", e);
|
|
|
|
|
uploadLog.setStatus(3);
|
|
|
|
|
uploadLog.setResult("提交失败,错误信息:" + response);
|
|
|
|
|
orderEntity.setExportStatus(2); //上传失败
|
|
|
|
|
orderDao.updateById(orderEntity);
|
|
|
|
|
orderUploadLogDao.insert(uploadLog);
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
uploadLog.setStatus(3);
|
|
|
|
|
uploadLog.setResult("提交失败,调用接口返回为空");
|
|
|
|
|
orderEntity.setExportStatus(2); //上传失败
|
|
|
|
|
orderDao.updateById(orderEntity);
|
|
|
|
|
orderUploadLogDao.insert(uploadLog);
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) {
|
|
|
|
|
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
|
|
|
|
|
zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
|
|
|
|
|
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
|
|
|
|
|
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRE_IN_ORDER_SUBMIT_URL), zaZyRequest);
|
|
|
|
|
response = parserResult(response);
|
|
|
|
|
try {
|
|
|
|
|
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
|
|
|
|
|
return baseResponse;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("解析漳州中医院智业接口提交单据返回数据异常,返回结果:{}", response);
|
|
|
|
|
log.error("异常信息:{}", e);
|
|
|
|
|
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转换提交单据参数
|
|
|
|
|
*
|
|
|
|
|
* @param udiwmsOrderRequest
|
|
|
|
|
* @param orderEntity
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public UdiwmsPreInOrderRequest submitPreInOrderToThirdSys(ZaxzyyOrderRequest udiwmsOrderRequest, IoOrderEntity orderEntity) {
|
|
|
|
|
UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = new UdiwmsPreInOrderRequest();
|
|
|
|
|
if (udiwmsOrderRequest != null) {
|
|
|
|
|
BeanUtils.copyProperties(udiwmsOrderRequest, udiwmsPreInOrderRequest);
|
|
|
|
|
udiwmsPreInOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode());
|
|
|
|
|
udiwmsPreInOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName());
|
|
|
|
|
if (orderEntity.getReviewUser() != null) {
|
|
|
|
|
AuthUserEntity authUser = authUserDao.selectById(orderEntity.getReviewUser());
|
|
|
|
|
udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName());
|
|
|
|
|
} else if (orderEntity.getCreateUser() != null) {
|
|
|
|
|
AuthUserEntity authUser = authUserDao.selectById(orderEntity.getCreateUser());
|
|
|
|
|
udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName());
|
|
|
|
|
}
|
|
|
|
|
List<UdiwmsPreInOrderRequest.ItemDTO> itemDTOS = new ArrayList<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(udiwmsOrderRequest.getItem())) {
|
|
|
|
|
for (UdiwmsOrderDetailRequest udiwmsOrderDetail : udiwmsOrderRequest.getItem()) {
|
|
|
|
|
if (CollUtil.isNotEmpty(udiwmsOrderDetail.getCodeList())) {
|
|
|
|
|
for (UdiwmsOrderDetailRequest.CodeDetailEntity codeDetaiEntity : udiwmsOrderDetail.getCodeList()) {
|
|
|
|
|
UdiwmsPreInOrderRequest.ItemDTO itemDTO = new UdiwmsPreInOrderRequest.ItemDTO();
|
|
|
|
|
BeanUtils.copyProperties(udiwmsOrderDetail, itemDTO);
|
|
|
|
|
itemDTO.setCode(codeDetaiEntity.getCode());
|
|
|
|
|
itemDTO.setCount(codeDetaiEntity.getCount());
|
|
|
|
|
itemDTOS.add(itemDTO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
udiwmsPreInOrderRequest.setItems(itemDTOS);
|
|
|
|
|
}
|
|
|
|
|
return udiwmsPreInOrderRequest;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|