1/20 龙海参数优化1.0

Lhxyy
wangwei 2 months ago
parent 49b4527ecb
commit 4d7c6ff1b3

File diff suppressed because one or more lines are too long

@ -1,41 +0,0 @@
package com.glxp.mipsdl.client.ctqyy.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@NoArgsConstructor
@Data
public class InvCodeResultEntity {
@JsonProperty("recordNo")
private Integer recordNo;
@JsonProperty("visitNo")
private String visitNo;
@JsonProperty("sickName")
private String sickName;
@JsonProperty("inDept")
private String inDept;
@JsonProperty("deptName")
private String deptName;
@JsonProperty("materialCode")
private String materialCode;
@JsonProperty("materialName")
private String materialName;
@JsonProperty("materialPrc")
private Integer materialPrc;
@JsonProperty("dictBarcode")
private String dictBarcode;
@JsonProperty("Barcode")
private String barcode;
@JsonProperty("feeTime")
private String feeTime;
@JsonProperty("feeOper")
private String feeOper;
}

@ -1,41 +0,0 @@
package com.glxp.mipsdl.client.ctqyy.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@NoArgsConstructor
@Data
public class InvProjectResultEntity {
@JsonProperty("seqNo")
private String seqNo;
@JsonProperty("visitNo")
private String visitNo;
@JsonProperty("sickName")
private String sickName;
@JsonProperty("applyDept")
private String applyDept;
@JsonProperty("deptName")
private String deptName;
@JsonProperty("itemCode")
private String itemCode;
@JsonProperty("itemName")
private String itemName;
@JsonProperty("Price")
private Double price;
@JsonProperty("quantity")
private Integer quantity;
@JsonProperty("Cost")
private Double cost;
@JsonProperty("materialCode")
private String materialCode;
@JsonProperty("materialName")
private String materialName;
@JsonProperty("OperTime")
private String operTime;
}

@ -1,60 +0,0 @@
package com.glxp.mipsdl.client.ctqyy.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@NoArgsConstructor
@Data
public class InvResultEntity {
@JsonProperty("applyNo")
private String applyNo;
@JsonProperty("ioFlag")
private String ioFlag;
@JsonProperty("ioType")
private String ioType;
@JsonProperty("ioTypeName")
private String ioTypeName;
@JsonProperty("Debit")
private String debit;
@JsonProperty("DebitName")
private String debitName;
@JsonProperty("Credit")
private String credit;
@JsonProperty("CreditName")
private String creditName;
@JsonProperty("AccoutDate")
private String accoutDate;
@JsonProperty("Accoutant")
private String accoutant;
@JsonProperty("receiveOper")
private String receiveOper;
@JsonProperty("materialCode")
private String materialCode;
@JsonProperty("materialName")
private String materialName;
@JsonProperty("materialSpec")
private String materialSpec;
@JsonProperty("materialUnit")
private String materialUnit;
@JsonProperty("batchNo")
private String batchNo;
@JsonProperty("invoiceNo")
private String invoiceNo;
@JsonProperty("invoiceDate")
private String invoiceDate;
@JsonProperty("quantity")
private Integer quantity;
@JsonProperty("importPrc")
private Double importPrc;
@JsonProperty("importMoney")
private Integer importMoney;
@JsonProperty("factoryCode")
private String factoryCode;
@JsonProperty("factoryName")
private String factoryName;
}

@ -1,492 +0,0 @@
package com.glxp.mipsdl.client.dsxyy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
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.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.IoCodeDao;
import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
import com.glxp.mipsdl.dao.thrsys.*;
import com.glxp.mipsdl.entity.auth.AuthUserEntity;
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
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.inout.IoCodeEntity;
import com.glxp.mipsdl.entity.inout.IoOrderDetailBizEntity;
import com.glxp.mipsdl.entity.inout.IoOrderEntity;
import com.glxp.mipsdl.entity.inout.IoOrderInvoiceEntity;
import com.glxp.mipsdl.entity.thrsys.*;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.dsxyy.DsBusTypeRequest;
import com.glxp.mipsdl.req.dsxyy.DsOrderRequest;
import com.glxp.mipsdl.req.dsxyy.DsProductRequest;
import com.glxp.mipsdl.req.dsxyy.DsUnitRequest;
import com.glxp.mipsdl.req.post.PostFileThrOrderRequest;
import com.glxp.mipsdl.req.post.PostThrCorpRequest;
import com.glxp.mipsdl.req.post.PostThrInvProductsRequest;
import com.glxp.mipsdl.req.post.PostThrProductsRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.PageSimpleResponse;
import com.glxp.mipsdl.res.udiwms.ThrProductsResponse;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.order.OrderUploadLogService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
*
*/
@Slf4j
@Service(value = "100006HttpClient") //bean注册名称使用编码 + HttpClient文件接口加 FileClient
public class DsxyyClient extends CommonHttpClient {
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private HttpClient httpClient;
@Resource
private ThrBustypeOriginDao thrBustypeOriginDao;
@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 SubmitOrderUtil submitOrderUtil;
@Resource
AuthUserDao authUserDao;
@Resource
private BasicUdirelDao basicUdirelDao;
@Resource
private BasicProductsDao basicProductsDao;
@Resource
private ThrProductsDao thrProductsDao;
@Resource
private OrderUploadLogService orderUploadLogService;
@Resource
private ThrOrderUploadBustypesMapper thrOrderUploadBustypesMapper;
@Resource
ThrCorpDao thrCorpDao;
@Override
public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) {
DsUnitRequest dsUnitRequest = new DsUnitRequest();
BeanUtil.copyProperties(udiwmsUnitRequest, dsUnitRequest);
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_CORP_URL), dsUnitRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
DsProductRequest dsProductRequest = new DsProductRequest();
BeanUtil.copyProperties(udiwmsProductRequest, dsProductRequest);
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), dsProductRequest);
BaseResponse<PageSimpleResponse<ThrProductsResponse>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThrProductsResponse>>>() {
});
// 过滤西药库产品
if (CollUtil.isNotEmpty(baseResponse.getData().getList())) {
Iterator<ThrProductsResponse> iterator = baseResponse.getData().getList().iterator();
while (iterator.hasNext()) {
ThrProductsResponse item = iterator.next();
if (item.getRemark() != null && item.getRemark().contains("西药库")) {
iterator.remove();
baseResponse.getData().setTotal(-555l);
}
}
}
// BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) {
DsBusTypeRequest dsBusTypeRequest = new DsBusTypeRequest();
BeanUtil.copyProperties(udiwmsBusTypeRequest, dsBusTypeRequest);
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_BUS_TYPE_QUERY_URL), udiwmsBusTypeRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) {
if (StrUtil.isBlank(udiwmsOrderQueryRequest.getBillType())) {
return ResultVOUtils.error(500, "单据类型不能为空");
}
//查询绑定的第三方单据类型
String thirdAction = thrBustypeOriginDao.findThirdActionByBillType(udiwmsOrderQueryRequest.getBillType(), DictUtl.CURRENT_HOSP_CODE);
udiwmsOrderQueryRequest.setBillType(thirdAction);
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_ORDER_QUERY_URL), udiwmsOrderQueryRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) {
return ResultVOUtils.error(500, "单据号不能为空");
}
DsOrderRequest dsOrderRequest = new DsOrderRequest();
BeanUtil.copyProperties(udiwmsOrderRequest, dsOrderRequest);
//查询单据和详情信息,组装第三方系统接口参数
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()).last("limit 1"));
if (orderEntity.getAuditTime() == null)
dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
else {
dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getAuditTime()));
}
//设置操作人
if (orderEntity.getReviewUser() != null) {
AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getReviewUser());
dsOrderRequest.setOperUser(authAdmin.getUserName());
} else if (orderEntity.getCreateUser() != null) {
AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getCreateUser());
dsOrderRequest.setOperUser(authAdmin.getUserName());
}
//查询对应的第三方单据类型
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper<ThrSystemBusApiEntity>().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType()));
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
return ResultVOUtils.error(500, "接口未配置,无法提交!");
}
dsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode());
if (orderEntity.getInvCode().equals("1000000")) {
dsOrderRequest.setLocInvCode("1161");
dsOrderRequest.setLocInvName("设备科");
} else {
dsOrderRequest.setLocInvCode("4050");
dsOrderRequest.setLocInvName("西药库");
}
//查询单据类型,设置往来单位信息
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType());
if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) {
//医院客户
dsOrderRequest.setCorpId(orderEntity.getFromCorp());
//查询客户名称
String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp());
dsOrderRequest.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) {
dsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
dsOrderRequest.setCorpName(basicCorpEntity.getName());
List<ThrCorpEntity> thrCorpEntities = thrCorpDao.selectList(new QueryWrapper<ThrCorpEntity>().eq("name", basicCorpEntity.getThirdName()));
if (CollUtil.isNotEmpty(thrCorpEntities)) {
for (ThrCorpEntity temp : thrCorpEntities) {
if (StrUtil.isNotEmpty(temp.getKfdm()) && temp.getKfdm().equals(udiwmsOrderRequest.getLocInvCode())) {
udiwmsOrderRequest.setCorpId(temp.getUnitId()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(temp.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()));
dsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode());
dsOrderRequest.setCorpName(thrInvWarehouseEntity.getName());
} catch (Exception e) {
String msg = "查询单据对应往来单位的第三方仓库信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
//供应商
BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
if (null != basicCorpEntity) {
dsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
dsOrderRequest.setCorpName(basicCorpEntity.getName());
List<ThrCorpEntity> thrCorpEntities = thrCorpDao.selectList(new QueryWrapper<ThrCorpEntity>().eq("name", basicCorpEntity.getThirdName()));
if (CollUtil.isNotEmpty(thrCorpEntities)) {
for (ThrCorpEntity temp : thrCorpEntities) {
if (StrUtil.isNotEmpty(temp.getKfdm()) && temp.getKfdm().equals(udiwmsOrderRequest.getLocInvCode())) {
udiwmsOrderRequest.setCorpId(temp.getUnitId()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(temp.getName()); //往来单位名称,需转换为第三方系统的名称
}
}
}
} else {
String msg = "查询单据对应的第三方往来单位信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
// //查询仓库信息
// AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode()));
// try {
// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
// .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
//
// dsOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
// dsOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
//
// dsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
// dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
// } catch (Exception e) {
// log.info("查询第三方系统仓库信息异常", e);
// }
// if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) {
// dsOrderRequest.setCorpId(dsOrderRequest.getLocStorageCode());
// dsOrderRequest.setCorpName(dsOrderRequest.getLocStorageName());
//
// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, "29")
// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
// dsOrderRequest.setLocStorageCode("29");
// dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
// }
dsOrderRequest.setBillFlag("1");
//设置单据出入库类型
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
dsOrderRequest.setInoutType(1); //入库
} else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
dsOrderRequest.setInoutType(2); //出库
}
dsOrderRequest.setRemark("udi管理系统提交单据");
//组装单据明细数据
List<IoCodeEntity> ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper<IoCodeEntity>()
.eq(IoCodeEntity::getOrderId, orderEntity.getBillNo())
);
List<UdiwmsOrderDetailRequest> items = new ArrayList<>();
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) {
//查询产品信息
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(detailBizEntity.getBindRlFk());
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()).last("limit 1"));
UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest();
BeanUtil.copyProperties(detailBizEntity, item);
item.setProductDate(StrUtil.isBlank(detailBizEntity.getProductDate()) ? "19990101" : "20" + detailBizEntity.getProductDate());
item.setExpireDate(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? "20991231" : "20" + detailBizEntity.getExpireDate());
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
item.setProductId(thirdProductId); //产品ID
//查询第三方产品名称
ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new LambdaQueryWrapper<ThrProductsEntity>()
.eq(ThrProductsEntity::getCode, thirdProductId).last("limit 1"));
if (thrProductsEntity == null) {
String errMsg = "提交失败,错误信息:" + detailBizEntity.getCoName() + "产品DI未关联第三方产品信息";
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
if (StrUtil.isEmpty(thrProductsEntity.getPrice())) {
item.setPrice(new BigDecimal(0));
} else
item.setPrice(new BigDecimal(thrProductsEntity.getPrice()));
String fphm = "";
String fprq = null;
List<IoOrderInvoiceEntity> invoiceList = IoOrderInvoiceEntity.builder().build()
.selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo())
.eq(IoOrderInvoiceEntity::getBindRlFk, detailBizEntity.getBindRlFk())
.eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, detailBizEntity.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());
}
item.setFirstSalesInvNo(fphm);
item.setSecSalesInvNo(fphm);
item.setInvoiceDate(fprq);
boolean isNeedFp = false;
ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesMapper.selectOne(new QueryWrapper<ThrOrderUploadBustypesEntity>().eq("action", basicBussinessTypeEntity.getAction()).last("limit 1"));
if (thrOrderUploadBustypesEntity != null && IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) {
isNeedFp = true;
}
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT) && StrUtil.isEmpty(fphm) && isNeedFp) {
String errMsg = "提交失败,错误信息:" + detailBizEntity.getCoName() + "发票缺失,请补齐后重新提交";
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
item.setProductName(thrProductsEntity.getName()); //产品名称
item.setBindRlFk(detailBizEntity.getBindRlFk());
item.setStandard(detailBizEntity.getSpec()); //规格型号
item.setBillNo(detailBizEntity.getOrderIdFk()); //单据号
item.setRegisterNo(detailBizEntity.getCertCode()); //注册/备案证号
item.setManufactory(basicProducts.getManufactory()); //生产厂家
item.setMeasname(basicProducts.getMeasname()); //计量单位
item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号
item.setManufactoryCode(thrProductsEntity.getManufactoryCode());
item.setSupCode(thrProductsEntity.getSupCode());
item.setCplb(thrProductsEntity.getFlbm());
item.setCount(detailBizEntity.getCount());
//封装条码信息
submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item);
items.add(item);
}
Collections.reverse(items);
dsOrderRequest.setItem(items);
return submitOrderUtil.submitOrder(orderEntity, dsOrderRequest);
}
@Override
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_INV_PI_URL), udiwmsInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_WAREHOUSE_QUERY_URL), udiwmsWarehouseRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) {
postThrProductsRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) {
postThrCorpRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) {
postFileThrOrderRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse testConnect() {
UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
udiwmsUnitRequest.setPage(1);
udiwmsUnitRequest.setLimit(1);
BaseResponse baseResponse = getUnit(udiwmsUnitRequest);
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("连接成功");
}
return ResultVOUtils.error(500, "连接失败!");
}
@Override
public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) {
return null;
}
@Override
public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) {
return null;
}
@Override
public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) {
return null;
}
}

@ -1,641 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.client.ptxhyy.entity.HisProductEntity;
import com.glxp.mipsdl.client.ptxhyy.entity.OrderUploadResponse;
import com.glxp.mipsdl.client.ptxhyy.entity.ThrHslbEntity;
import com.glxp.mipsdl.client.ptxhyy.entity.ThrHslbService;
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.*;
import com.glxp.mipsdl.dao.inout.IoCodeDao;
import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
import com.glxp.mipsdl.dao.inout.IoOrderUploadLogDao;
import com.glxp.mipsdl.dao.thrsys.ThrDeptDao;
import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.mipsdl.dao.thrsys.ThrProductsDao;
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.BasicSkProjectEntity;
import com.glxp.mipsdl.entity.inout.*;
import com.glxp.mipsdl.entity.ptxhyy.SickerEntity;
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.UdiwmsInvProductsRequest;
import com.glxp.mipsdl.req.base.UdiwmsOrderDetailRequest;
import com.glxp.mipsdl.req.base.UdiwmsOrderRequest;
import com.glxp.mipsdl.req.ctqyy.DlThirdProjectRequest;
import com.glxp.mipsdl.req.ctqyy.GetSickRequest;
import com.glxp.mipsdl.req.ptxhyy.PtxhyyInvRequest;
import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderDetailRequest;
import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.PageSimpleResponse;
import com.glxp.mipsdl.res.ptxhyy.PtxhInvResponse;
import com.glxp.mipsdl.res.udiwms.BasicSkSickerResponse;
import com.glxp.mipsdl.res.udiwms.ThrInvResultResponse;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.order.OrderUploadLogService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.thirddao.ptxhyy.PtxhyySickerMapper;
import com.glxp.mipsdl.util.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
*
*/
@Slf4j
@Service(value = "100008HttpClient")
@RequiredArgsConstructor
public class PtxhyyClient extends CommonHttpClient {
private final ThirdSysConfig thirdSysConfig;
private final IoOrderDao orderDao;
private final ThrSystemBusApiDao thrSystemBusApiDao;
private final BasicBussinessTypeDao basicBussinessTypeDao;
private final BasicCorpDao basicCorpDao;
private final AuthWarehouseDao authWarehouseDao;
private final ThrInvWarehouseDao thrInvWarehouseDao;
private final AuthWarehouseService authWarehouseService;
private final IoCodeDao codeDao;
private final IoOrderDetailBizDao orderDetailBizDao;
private final SubmitOrderUtil submitOrderUtil;
@Resource
ThrHslbService thrHslbService;
@Resource
PtxhyySickerMapper ptxhyySickerMapper;
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) {
return ResultVOUtils.error(500, "单据号不能为空");
}
//查询单据和详情信息,组装第三方系统接口参数
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()));
Date billDate = orderEntity.getConfirmTime() == null ? orderEntity.getUpdateTime() : orderEntity.getConfirmTime();
udiwmsOrderRequest.setBillDate(DateUtil.formatDateTime(billDate));
//查询对应的第三方单据类型
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper<ThrSystemBusApiEntity>().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType()));
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
String errMsg = "接口未配置,无法提交!";
updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
udiwmsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode());
//查询单据类型,设置往来单位信息
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction());
if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) {
//医院客户
udiwmsOrderRequest.setCorpId(orderEntity.getFromCorp());
//查询客户名称
String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp());
udiwmsOrderRequest.setCorpName(corpName);
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) {
BasicCorpEntity basicCorpEntity = null;
if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) {
basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
if (null != basicCorpEntity) {
udiwmsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
udiwmsOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
String msg = "查询单据对应的第三方往来单位信息异常";
updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
} else {
//内部科室
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, orderEntity.getFromInvCode()));
try {
//根据第三方系统标识,获取对应字段的值
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
udiwmsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode());
udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName());
} catch (Exception e) {
String msg = "查询单据对应往来单位的第三方仓库信息异常";
updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg + ExceptionUtil.stacktraceToString(e));
return ResultVOUtils.error(500, msg);
}
}
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
//供应商
BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
if (null != basicCorpEntity) {
udiwmsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
udiwmsOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
String msg = "查询单据对应的第三方往来单位信息异常";
updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
//查询仓库信息
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode()));
try {
List<ThrInvWarehouseEntity> thrInvWarehouseEntitys = thrInvWarehouseDao.selectList(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
if (CollUtil.isNotEmpty(thrInvWarehouseEntitys)) {
udiwmsOrderRequest.setLocInvCode(thrInvWarehouseEntitys.get(0).getCode());
udiwmsOrderRequest.setLocInvName(thrInvWarehouseEntitys.get(0).getName());
}
} catch (Exception e) {
log.error("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e));
updateLocalErr(orderEntity, "查询第三方系统仓库信息异常" + ExceptionUtil.stacktraceToString(e));
return ResultVOUtils.error(500, "查询第三方系统仓库信息异常");
}
udiwmsOrderRequest.setBillFlag("1");
//设置单据出入库类型
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
udiwmsOrderRequest.setInoutType(1); //入库
} else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
udiwmsOrderRequest.setInoutType(2); //出库
}
udiwmsOrderRequest.setRemark("udi管理系统提交单据:" + orderEntity.getBillNo());
//组装单据明细数据
List<IoCodeEntity> ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper<IoCodeEntity>()
.eq(IoCodeEntity::getOrderId, orderEntity.getBillNo())
.ne(IoCodeEntity::getAction, "StockCheck")
);
List<UdiwmsOrderDetailRequest> items = new ArrayList<>();
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
//单据金额
BigDecimal djje = detailBizEntities.stream()
.filter(x -> x.getPrice() != null).
map(IoOrderDetailBizEntity::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
List<IoOrderInvoiceEntity> ioOrderInvoiceEntities = IoOrderInvoiceEntity.builder().build()
.selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()).groupBy(IoOrderInvoiceEntity::getInvoiceEncode));
int fbbz = 0;
if (CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) && ioOrderInvoiceEntities.size() > 0) {
fbbz = 1;
}
String userName;
try {
userName = getUserName(orderEntity);
if (StrUtil.isEmpty(userName)) {
updateLocalErr(orderEntity, "该单据无创建人!");
return ResultVOUtils.error(500, "该单据无创建人!");
}
} catch (Exception e) {
log.error("----单据提交-----" + orderEntity.getBillNo() + "查询操作人异常", ExceptionUtil.stacktraceToString(e));
userName = getUserName(orderEntity);
}
PtxhyyOrderRequest ptxhyyOrderRequest = PtxhyyOrderRequest
.builder()
.kfxh(udiwmsOrderRequest.getLocInvCode())
.czgh(userName)
.lzfs(udiwmsOrderRequest.getBillType())
.dwxh(udiwmsOrderRequest.getCorpId())
.rkrq(udiwmsOrderRequest.getBillDate())
.djje(djje)
.fpbz(fbbz)
.zdrq(udiwmsOrderRequest.getBillDate())
.lsje(djje)
.fpzs(CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) ? ioOrderInvoiceEntities.size() : 0)
.udixh(udiwmsOrderRequest.getBillNo())
.lzdh(udiwmsOrderRequest.getBillNo())
.build();
ptxhyyOrderRequest.setDetailList(new ArrayList<>());
String errMs = setOrderDetailList(ioCodeEntities, items, detailBizEntities);
if (errMs != null) {
updateLocalErr(orderEntity, errMs);
log.error(errMs);
return ResultVOUtils.error(500, errMs);
}
Collections.reverse(items);
for (UdiwmsOrderDetailRequest i : items) {
// String udim = "";
// if (CollectionUtil.isNotEmpty(i.getCodeList())) {
// udim = i.getCodeList().stream().map(UdiwmsOrderDetailRequest.CodeDetailEntity::getCode).collect(Collectors.joining(","));
// }
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());
}
String hsfl = "";
if (StrUtil.isNotEmpty(i.getHslb())) {
ThrHslbEntity thrHslbEntity = thrHslbService.getOne(new QueryWrapper<ThrHslbEntity>().eq("hslb", i.getHslb()), false);
if (thrHslbEntity != null) {
hsfl = thrHslbEntity.getHsbm();
}
}
// .udim(udim)
BigDecimal wzje = null;
if (i.getPrice() != null)
wzje = i.getPrice().multiply(BigDecimal.valueOf(i.getCount().intValue()));
PtxhyyOrderDetailRequest detailRequest = PtxhyyOrderDetailRequest.builder()
.wzxh(i.getProductId())
.cjxh(i.getManufactoryCode())
.bzdw(i.getMeasname())
.bzsl(i.getCount())
.wzjg(i.getPrice())
.lsjg(i.getPrice() + "")
.lsje(wzje)
.wzje(wzje + "")
.hsfl(i.getHslb())
// .hsfl(hsfl)
.wzph(i.getBatchNo())
.fphm(fphm)
.fprq(fprq)
.djrq(DateUtil.formatDate(orderEntity.getCreateTime(), "yyyy-MM-dd"))
.producedDate(i.getProductDate())
.expireDate(i.getExpireDate())
.registerNo(i.getRegisterNo())
.build();
ptxhyyOrderRequest.getDetailList().add(detailRequest);
}
return submitOrder(orderEntity, ptxhyyOrderRequest);
}
/**
*
*
* @param orderEntity
* @param errMsg
*/
public void updateLocalErr(IoOrderEntity orderEntity, String errMsg) {
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);
orderDao.updateById(orderEntity);
uploadLog.setStatus(4);
uploadLog.setResult("单据数据异常:" + errMsg);
orderUploadLogService.insertOrUpdate(uploadLog);
}
/**
*
*
* @param ioCodeEntities
* @param orderDetailRequests
* @param detailBizEntities
*/
private String setOrderDetailList(List<IoCodeEntity> ioCodeEntities, List<UdiwmsOrderDetailRequest> orderDetailRequests, List<IoOrderDetailBizEntity> detailBizEntities) {
for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) {
UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity);
if (item == null) {
return detailBizEntity.getNameCode() + "第三方产品编码未关联";
}
//封装条码信息
submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item);
orderDetailRequests.add(item);
}
return null;
}
@Resource
AuthUserDao authUserDao;
@Resource
AuthWarehouseUserMapper authWarehouseUserMapper;
@Resource
private HttpClient httpClient;
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private OrderUploadLogService orderUploadLogService;
public String getUserName(IoOrderEntity orderEntity) {
//创建人非供应商
if (StrUtil.isNotEmpty(orderEntity.getConfirmUser())) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getConfirmUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser());
return authUserEntity.getUserName();
} else {
List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
return authWarehouseUsers.get(0).getUserName();
}
}
return null;
}
public String getDefaultUserName(IoOrderEntity orderEntity) {
List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
return authWarehouseUsers.get(0).getUserName();
}
return null;
}
/**
*
*
* @param orderEntity
* @param udiwmsOrderRequest
* @return
*/
public BaseResponse submitOrder(IoOrderEntity orderEntity, Object udiwmsOrderRequest) {
//记录日志
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.getUrl(Constants.URL_NAME_ORDER_SUBMIT_URL), udiwmsOrderRequest);
if (StrUtil.isNotBlank(response)) {
try {
BaseResponse<OrderUploadResponse> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<OrderUploadResponse>>() {
});
if (baseResponse.getCode() == 20000) {
String thirdBillNo = baseResponse.getData().getDjxh();
orderEntity.setThirdBillNo(thirdBillNo);
orderEntity.setExportStatus(1); //上传成功
uploadLog.setStatus(2);
uploadLog.setThrBillNo(thirdBillNo);
uploadLog.setResult("提交成功");
orderDao.updateById(orderEntity);
orderUploadLogService.insertOrUpdate(uploadLog);
return ResultVOUtils.success("提交成功");
}
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage());
orderUploadLogService.insertOrUpdate(uploadLog);
return baseResponse;
} catch (Exception e) {
log.error("解析提交单据返回结果异常,结果信息:{}", response);
log.error("异常信息:{}", e);
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + response);
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogService.insertOrUpdate(uploadLog);
return ResultVOUtils.error(500, "提交失败");
}
} else {
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,调用接口返回为空");
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogService.insertOrUpdate(uploadLog);
return ResultVOUtils.error(500, "提交失败");
}
}
/**
* /
*/
@Override
public BaseResponse getInvFeeResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
PtxhyyInvRequest ptxhyyInvRequest = new PtxhyyInvRequest();
ptxhyyInvRequest.setKssj(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd"));
ptxhyyInvRequest.setJssj(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd"));
String response = null;
try {
response = FileUtils.getFileContent("D://UDI/response.json");
} catch (IOException e) {
e.printStackTrace();
}
// response = httpClient.postJson(thrSystemDetailService.getUrlExclude(null) + "/CKCX", ptxhyyInvRequest);
// String response = "{\"code\": 20000,\"data\": {\"list\": [{\"zsl\": 1,\"fyxh\": 30274,\"dw\": \"根\",\"lb\": \"住院\",\"fymc\": \"一次性使用避光压力延长管/根\",\"fydj\": 13,\"rq\": 1709222400000,\"zxks\": \"新10区\"},{\"zsl\": 3,\"fyxh\": 35550,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"静脉林华留置针(苏州林华)/个\",\"fydj\": 3.12,\"rq\": 1709222400000,\"zxks\": \"精神科病区\"},{\"zsl\": 2,\"fyxh\": 29290,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性采血针/支 (100.000%)\",\"fydj\": 0.28,\"rq\": 1709222400000,\"zxks\": \"精神科病区\"},{\"zsl\": 6,\"fyxh\": 29976,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"雾化面罩(口含式)/个 (100.000%)\",\"fydj\": 14.4,\"rq\": 1709222400000,\"zxks\": \"新11区\"},{\"zsl\": 1,\"fyxh\": 29298,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性无菌注射器(1ml 带针)/支\",\"fydj\": 0.27,\"rq\": 1709222400000,\"zxks\": \"03区\"},{\"zsl\": 1,\"fyxh\": 29291,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性使用静脉输液针(头皮针)/支 (100.000%)\",\"fydj\": 0.14,\"rq\": 1709222400000,\"zxks\": \"03区\"},{\"zsl\": 62,\"fyxh\": 29292,\"dw\": \"副\",\"lb\": \"住院\",\"fymc\": \"一次性使用代贴输液器(带针)/副 (100.000%)\",\"fydj\": 0.95,\"rq\": 1709222400000,\"zxks\": \"16区\"},{\"zsl\": 9,\"fyxh\": 30621,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"一次性使用真空采血管(促凝剂)/个\",\"fydj\": 0.58,\"rq\": 1709222400000,\"zxks\": \"05区\"},{\"zsl\": 66,\"fyxh\": 29294,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性无菌注射器5ml 带针)/支\",\"fydj\": 0.28,\"rq\": 1709222400000,\"zxks\": \"16区\"},{\"zsl\": 4,\"fyxh\": 29278,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"一次性使用负压引流袋/个\",\"fydj\": 5.8,\"rq\": 1709222400000,\"zxks\": \"04区\"}]}}";
BaseResponse<PageSimpleResponse<PtxhInvResponse>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<PtxhInvResponse>>>() {
});
if (baseResponse.getCode() == 20000) {
List<PtxhInvResponse> ptxhInvResponses = baseResponse.getData().getList();
List<ThrInvResultResponse> thrInvResultResponses = new ArrayList<>();
Set<String> seenNames = new HashSet<>();
List<PtxhInvResponse> itemData = new ArrayList<>();
if (CollUtil.isNotEmpty(ptxhInvResponses)) {
for (PtxhInvResponse ptxhInvResponse : ptxhInvResponses) {
ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse();
thrInvResultResponse.setBillType("SC71021292871198"); //科室收费出库
thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT);
List<ThrInvWarehouseEntity> thrInvWarehouseEntitys = thrInvWarehouseDao.selectList(new QueryWrapper<ThrInvWarehouseEntity>().eq("code", ptxhInvResponse.getZxksdm()));
if (CollUtil.isNotEmpty(thrInvWarehouseEntitys)) {
for (ThrInvWarehouseEntity thrInvWarehouseEntity : thrInvWarehouseEntitys) {
AuthWarehouseEntity authWarehouseEntity = authWarehouseDao.selectOne(new QueryWrapper<AuthWarehouseEntity>().eq("thirdId", thrInvWarehouseEntity.getCode()).last("limit 1"));
if (authWarehouseEntity != null) {
thrInvResultResponse.setInvCode(authWarehouseEntity.getCode());
thrInvResultResponse.setDeptCode(authWarehouseEntity.getParentId());
thrInvResultResponse.setDeptName(ptxhInvResponse.getZxks());
thrInvResultResponse.setInvName(ptxhInvResponse.getZxks());
thrInvResultResponse.setThrCode(ptxhInvResponse.getFyxh());
thrInvResultResponse.setCpmctymc(ptxhInvResponse.getFymc());
thrInvResultResponse.setPrice(BigDecimal.valueOf(Double.parseDouble(ptxhInvResponse.getFydj())));
thrInvResultResponse.setMeasname(ptxhInvResponse.getDw());
thrInvResultResponse.setType(ptxhInvResponse.getLb());
thrInvResultResponse.setOutCount(ptxhInvResponse.getZsl());
thrInvResultResponse.setReCount(ptxhInvResponse.getZsl());
thrInvResultResponse.setBatchNo(null);
thrInvResultResponse.setSickerName(ptxhInvResponse.getBrxm());
thrInvResultResponse.setSickerCode(ptxhInvResponse.getJzhm());
if (StrUtil.isNotEmpty(ptxhInvResponse.getRq())) {
thrInvResultResponse.setChargeTime(ptxhInvResponse.getRq());
}
thrInvResultResponses.add(thrInvResultResponse);
if (seenNames.add(ptxhInvResponse.getFyxh())) {
itemData.add(ptxhInvResponse);
break;
}
} else {
// thrInvWarehouseEntity.setCode(CustomUtil.getId());
// thrInvWarehouseEntity.setName(ptxhInvResponse.getZxks());
// thrInvWarehouseEntity.setThirdSysFk("thirdId");
// thrInvWarehouseEntity.setId(IdUtil.getSnowflakeNextId() + "");
// thrInvWarehouseEntity.setParentId(thrInvWarehouseEntity.getCode());
// thrInvWarehouseEntity.setRemark("收费出库自动生成");
// thrInvWarehouseEntity.setUpdateTime(new Date());
// thrInvWarehouseDao.insert(thrInvWarehouseEntity);
//
// ThrDeptEntity thrDeptEntity = new ThrDeptEntity();
// thrDeptEntity.setCode(thrInvWarehouseEntity.getCode());
// thrDeptEntity.setName(thrInvWarehouseEntity.getName());
// thrDeptEntity.setPId(0);
// thrDeptEntity.setId(IdUtil.getSnowflakeNextId());
// thrDeptEntity.setStatus(1);
// thrDeptEntity.setRemark("收费出库自动生成");
// thrInvWarehouseEntity.setUpdateTime(new Date());
// thrDeptEntity.setThirdSysFk(thrDeptEntity.getThirdSysFk());
// thrDeptDao.insert(thrDeptEntity);
// return ResultVOUtils.error(500, ptxhInvResponse.getZxks() + "第三方科室仓库未创建!");
log.error(ptxhInvResponse.getZxks() + "--科室仓库未对照!");
}
}
} else {
log.error(ptxhInvResponse.getZxks() + "第三方科室仓库未创建!");
}
}
}
// for (PtxhInvResponse invProjectResultEntity : itemData) {
// if (!basicSkProjectMapper.exists(new QueryWrapper<BasicSkProjectEntity>().eq("code", invProjectResultEntity.getFyxh()))) {
// BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity();
// basicSkProjectEntity.setCode(invProjectResultEntity.getFyxh());
// basicSkProjectEntity.setName(invProjectResultEntity.getFymc());
// basicSkProjectEntity.setType(2);
// basicSkProjectEntity.setCreateTime(new Date());
// basicSkProjectEntity.setUpdateTime(new Date());
// basicSkProjectEntity.setRemark("出入库明细自动生成");
// basicSkProjectEntity.setId(IdUtil.getSnowflakeNextId());
// basicSkProjectMapper.insert(basicSkProjectEntity);
// }
// }
PageSimpleResponse<ThrInvResultResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(thrInvResultResponses.size() + 0l);
pageSimpleResponse.setList(thrInvResultResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
return baseResponse;
}
// public void getHslb() {
// String response = httpClient.postJson(thrSystemDetailService.getUrl(null), udiwmsUnitRequest);
// BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
// return baseResponse;
// }
/**
*
*
* @param dlThirdProjectRequest
* @return
*/
@Override
public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) {
dlThirdProjectRequest.setFygb("14");
dlThirdProjectRequest.setPage(1);
dlThirdProjectRequest.setLimit(10000);
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(null) + "/YLSF", dlThirdProjectRequest);
BaseResponse<PageSimpleResponse<HisProductEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<HisProductEntity>>>() {
});
if (baseResponse.getCode() == 20000) {
PageSimpleResponse<HisProductEntity> pageSimpleResponse = baseResponse.getData();
List<HisProductEntity> list = pageSimpleResponse.getList();
List<BasicSkProjectEntity> basicSkProjectEntities = new ArrayList<>();
int index = 1;
int index2 = 1;
log.info("总数:" + list.size());
for (HisProductEntity hisProductEntity : list) {
BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity();
basicSkProjectEntity.setCode(hisProductEntity.getFyxh());
basicSkProjectEntity.setName(hisProductEntity.getFymc());
basicSkProjectEntity.setType(2);
basicSkProjectEntity.setCreateTime(new Date());
basicSkProjectEntity.setUpdateTime(new Date());
basicSkProjectEntity.setRemark("自动下载");
basicSkProjectEntity.setCategory(hisProductEntity.getFydw());
basicSkProjectEntity.setGgxh(hisProductEntity.getSm());
basicSkProjectEntity.setUnit(hisProductEntity.getFydw());
basicSkProjectEntity.setPrice(hisProductEntity.getFydj());
if (hisProductEntity.getZfpb().equals("0")) {
log.info("在用" + index++ + "");
basicSkProjectEntities.add(basicSkProjectEntity);
} else {
log.info("作废" + index2++ + "");
}
}
PageSimpleResponse<BasicSkProjectEntity> dataResponse = new PageSimpleResponse<>();
dataResponse.setTotal(-666l);
dataResponse.setList(basicSkProjectEntities);
return ResultVOUtils.success(dataResponse);
}
return ResultVOUtils.error(500, "获取项目组套字典失败!");
}
@Override
public BaseResponse getSickInfo(GetSickRequest getSickRequest) {
IPage<SickerEntity> page = new Page<>(getSickRequest.getPage(), getSickRequest.getLimit());
IPage<SickerEntity> productEntityIPage = ptxhyySickerMapper.selectPage(page, new QueryWrapper<SickerEntity>()
.lambda()
.like(StringUtils.isNotBlank(getSickRequest.getCode()), SickerEntity::getZYHM, getSickRequest.getCode())
.like(StringUtils.isNotBlank(getSickRequest.getName()), SickerEntity::getBRXM, getSickRequest.getName()));
List<BasicSkSickerResponse> basicSkSickerResponses = new ArrayList<>();
productEntityIPage.getRecords().forEach(sickerEntity -> {
basicSkSickerResponses.add(BasicSkSickerResponse.builder()
.sickerId(sickerEntity.getZYH())
.code(sickerEntity.getZYH())
.name(sickerEntity.getBRXM())
.adNum(sickerEntity.getZYHM())
.inHospTime(sickerEntity.getRYRQ())
.outHospTime(sickerEntity.getCYRQ())
.build());
});
PageSimpleResponse<BasicSkSickerResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(productEntityIPage.getTotal());
pageSimpleResponse.setList(basicSkSickerResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
}

@ -1,64 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy;
import cn.hutool.core.thread.ThreadUtil;
import com.glxp.mipsdl.client.BaseFileClient;
import com.glxp.mipsdl.client.CommonFileClient;
import com.glxp.mipsdl.req.post.PostThrProductsRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.udiwms.UdiwmsProductInfoResponse;
import com.glxp.mipsdl.service.file.UdiInfoUploadService;
import com.glxp.mipsdl.util.ExcelUtil;
import com.glxp.mipsdl.util.ExecutorUtil;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.vo.file.ptxhyy.PtxhyyProductEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
*
*/
@Slf4j
@Service(value = "100008FileClient")
public class PtxhyyFileClient extends CommonFileClient {
@Resource
private UdiInfoUploadService udiInfoUploadService;
@Resource
private ExecutorUtil executorUtil;
@Override
public BaseResponse uploadPi(List<MultipartFile> files, String thirdSys) {
for (int i = 0; i < files.size(); i++) {
MultipartFile file = files.get(i);
if (file.isEmpty()) {
return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败");
}
try {
InputStream inputStream = file.getInputStream();
ExcelUtil<PtxhyyProductEntity> util = new ExcelUtil(PtxhyyProductEntity.class);
List<UdiwmsProductInfoResponse> udiwmsProductInfoResponses = util.importPi(inputStream);
PostThrProductsRequest postThrProductsRequest = new PostThrProductsRequest();
postThrProductsRequest.setDatas(udiwmsProductInfoResponses);
postThrProductsRequest.setUploadType("文件导入");
postThrProductsRequest.setThirdSys(thirdSys);
executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> {
udiInfoUploadService.postProducts(postThrProductsRequest);
}, "uploadPi"));
log.error("上传完" + System.currentTimeMillis());
} catch (IOException e) {
log.error("解析上传excel文件IO异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
} catch (Exception e) {
log.error("处理产品信息excel文件异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
}
}
return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看");
}
}

@ -1,173 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.client.ptxhyy.entity.HisFyRequest;
import com.glxp.mipsdl.client.ptxhyy.entity.HisProductEntity;
import com.glxp.mipsdl.client.ptxhyy.entity.PostHisDetailRequest;
import com.glxp.mipsdl.client.ptxhyy.entity.PostHisRequest;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.Constants;
import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao;
import com.glxp.mipsdl.dao.basic.BasicProductsDao;
import com.glxp.mipsdl.dao.basic.BasicUdirelDao;
import com.glxp.mipsdl.dao.inout.IoCodeDao;
import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
import com.glxp.mipsdl.entity.basic.BasicProductsEntity;
import com.glxp.mipsdl.entity.basic.BasicUdirelEntity;
import com.glxp.mipsdl.entity.inout.IoCodeEntity;
import com.glxp.mipsdl.entity.inout.IoOrderDetailBizEntity;
import com.glxp.mipsdl.entity.inout.IoOrderEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.UdiwmsOrderRequest;
import com.glxp.mipsdl.req.base.UdiwmsProductRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.PageSimpleResponse;
import com.glxp.mipsdl.res.udiwms.ThrProductsResponse;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.util.DateUtil;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.util.SubmitOrderUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* HIS
*/
@Slf4j
@Service(value = "100009HttpClient")
public class PtxhyyHisClient extends CommonHttpClient {
@Resource
private HttpClient httpClient;
@Resource
private ThirdSysConfig thirdSysConfig;
@Autowired
private ThrSystemDetailService thrSystemDetailService;
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
HisFyRequest hisFyRequest = new HisFyRequest();
hisFyRequest.setFyxh(udiwmsProductRequest.getCode());
hisFyRequest.setFymc(udiwmsProductRequest.getName());
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), hisFyRequest);
BaseResponse<PageSimpleResponse<HisProductEntity>> baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<HisProductEntity>>>() {
});
List<ThrProductsResponse> thrProductsResponses = new ArrayList<>();
List<HisProductEntity> hisProductEntities = baseResponse.getData().getList();
if (CollUtil.isNotEmpty(hisProductEntities)) {
for (HisProductEntity hisProductEntity : hisProductEntities) {
ThrProductsResponse thrProductsResponse = new ThrProductsResponse();
thrProductsResponse.setCode(hisProductEntity.getFyxh());
thrProductsResponse.setName(hisProductEntity.getFymc());
thrProductsResponse.setFlbm(hisProductEntity.getFygb());
thrProductsResponse.setPrice(hisProductEntity.getFydj());
thrProductsResponse.setQtbm(hisProductEntity.getSm());
thrProductsResponse.setCpms(hisProductEntity.getSfmc());
thrProductsResponse.setMeasname(hisProductEntity.getFydw());
thrProductsResponses.add(thrProductsResponse);
}
}
PageSimpleResponse<ThrProductsResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setList(thrProductsResponses);
pageSimpleResponse.setTotal(-666l); //表示全量下载
return ResultVOUtils.success(pageSimpleResponse);
}
@Resource
private IoOrderDao orderDao;
@Resource
private ThrSystemBusApiDao thrSystemBusApiDao;
@Resource
private BasicBussinessTypeDao basicBussinessTypeDao;
@Resource
private IoCodeDao codeDao;
@Resource
private IoOrderDetailBizDao orderDetailBizDao;
@Resource
private BasicUdirelDao basicUdirelDao;
@Resource
private BasicProductsDao basicProductsDao;
@Resource
private SubmitOrderUtil submitOrderUtil;
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) {
return ResultVOUtils.error(500, "单据号不能为空");
}
//查询单据和详情信息,组装第三方系统接口参数
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()));
udiwmsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
//查询对应的第三方单据类型
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper<ThrSystemBusApiEntity>().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType()));
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
return ResultVOUtils.error(500, "接口未配置,无法提交!");
}
PostHisRequest postHisRequest = new PostHisRequest();
//查询单据类型,设置往来单位信息
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction());
if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) {
//医院客户
postHisRequest.setZyh(orderEntity.getFromCorp());
} else {
return ResultVOUtils.error(500, "非使用出库单据");
}
//组装单据明细数据
List<IoCodeEntity> ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper<IoCodeEntity>()
.eq(IoCodeEntity::getOrderId, orderEntity.getBillNo())
);
List<PostHisDetailRequest> items = new ArrayList<>();
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
for (IoOrderDetailBizEntity orderDetailBizEntity : detailBizEntities) {
List<IoCodeEntity> codeEntities = filterCodes(orderDetailBizEntity, ioCodeEntities);
String udibm = codeEntities.stream().map(IoCodeEntity::getCode).collect(Collectors.joining(","));
PostHisDetailRequest postHisDetailRequest = new PostHisDetailRequest();
postHisDetailRequest.setUdibm(udibm);
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(orderDetailBizEntity.getBindRlFk());
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()));
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
postHisDetailRequest.setYldj(basicProducts.getPrice() + "");
postHisDetailRequest.setYlsl(orderDetailBizEntity.getReCount() + "");
postHisDetailRequest.setYlxh(thirdProductId);
items.add(postHisDetailRequest);
}
postHisRequest.setDetailList(items);
return submitOrderUtil.submitOrder(orderEntity, postHisRequest);
}
public List<IoCodeEntity> filterCodes(IoOrderDetailBizEntity orderDetailBizEntity, List<IoCodeEntity> codeEntities) {
List<IoCodeEntity> result = new ArrayList<>();
if (CollUtil.isNotEmpty(codeEntities)) {
for (IoCodeEntity codeEntity : codeEntities) {
if ((codeEntity.getRelId() + "").equals(orderDetailBizEntity.getBindRlFk())
&& StrUtil.trimToEmpty(codeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(orderDetailBizEntity.getBatchNo()))) {
result.add(codeEntity);
}
}
}
return result;
}
}

@ -1,64 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy;
import cn.hutool.core.thread.ThreadUtil;
import com.glxp.mipsdl.client.BaseFileClient;
import com.glxp.mipsdl.client.CommonFileClient;
import com.glxp.mipsdl.req.post.PostThrProductsRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.udiwms.UdiwmsProductInfoResponse;
import com.glxp.mipsdl.service.file.UdiInfoUploadService;
import com.glxp.mipsdl.util.ExcelUtil;
import com.glxp.mipsdl.util.ExecutorUtil;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.vo.file.ptxhyy.PtxhyyHisProductEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* His
*/
@Slf4j
@Service(value = "100009FileClient")
public class PtxhyyHisFileClient extends CommonFileClient {
@Resource
private UdiInfoUploadService udiInfoUploadService;
@Resource
private ExecutorUtil executorUtil;
@Override
public BaseResponse uploadPi(List<MultipartFile> files, String thirdSys) {
for (int i = 0; i < files.size(); i++) {
MultipartFile file = files.get(i);
if (file.isEmpty()) {
return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败");
}
try {
InputStream inputStream = file.getInputStream();
ExcelUtil<PtxhyyHisProductEntity> util = new ExcelUtil(PtxhyyHisProductEntity.class);
List<UdiwmsProductInfoResponse> udiwmsProductInfoResponses = util.importPi(inputStream);
PostThrProductsRequest postThrProductsRequest = new PostThrProductsRequest();
postThrProductsRequest.setDatas(udiwmsProductInfoResponses);
postThrProductsRequest.setUploadType("文件导入");
postThrProductsRequest.setThirdSys(thirdSys);
executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> {
udiInfoUploadService.postProducts(postThrProductsRequest);
}, "uploadPi"));
log.error("上传完" + System.currentTimeMillis());
} catch (IOException e) {
log.error("解析上传excel文件IO异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
} catch (Exception e) {
log.error("处理产品信息excel文件异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
}
}
return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看");
}
}

@ -1,10 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class DictHslbEntity {
private Integer hslb;
private String hsmc;
private String hsbm;
}

@ -1,13 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class HisFyRequest {
private String fyxh;
private String fymc;
private String fygb;
private String sm;
}

@ -1,22 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class HisProductEntity {
//费用序号
private String fyxh;
//费用单位
private String fydw;
//费用名称
private String fymc;
//费用单价
private String fydj;
private String sm;
private String sfmc;
private String fygb;
private String fygbmc;
private String RN;
private String zfpb;
}

@ -1,9 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class OrderUploadResponse {
private String djxh;
}

@ -1,16 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class PostHisDetailRequest {
// 费用序号
private String ylxh;
// 单价
private String yldj;
// 数量
private String ylsl;
// UDI编码
private String udibm;
}

@ -1,12 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
import java.util.List;
@Data
public class PostHisRequest {
private String zyh;
private List<PostHisDetailRequest> detailList;
}

@ -1,23 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;
@Data
@TableName(value = "thr_hslb")
public class ThrHslbEntity implements Serializable {
@TableField(value = "hslb")
private String hslb;
@TableField(value = "hsmc")
private String hsmc;
@TableField(value = "hsbm")
private String hsbm;
private static final long serialVersionUID = 1L;
}

@ -1,9 +0,0 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import com.glxp.mipsdl.dao.ptxyy.ThrHslbMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class ThrHslbService extends ServiceImpl<ThrHslbMapper, ThrHslbEntity> {
}

@ -1,672 +0,0 @@
package com.glxp.mipsdl.client.zaxyy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.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.inout.*;
import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.mipsdl.dao.thrsys.ThrOrderUploadBustypesMapper;
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.inout.*;
import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.mipsdl.entity.thrsys.ThrOrderUploadBustypesEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.post.*;
import com.glxp.mipsdl.req.zaxyy.ZaZyRequest;
import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.udiwms.ZzzyyProductsResponse;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.order.OrderUploadLogService;
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;
/**
* V1
*/
@Slf4j
@Service(value = "100003HttpClient") //bean注册名称使用编码 + HttpClient文件接口加 FileClient
public class ZaxyyClient extends CommonHttpClient {
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private HttpClient httpClient;
@Resource
private IoOrderDao orderDao;
@Resource
private ThrSystemBusApiDao thrSystemBusApiDao;
@Resource
private AuthUserDao authUserDao;
@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 IoOrderUploadLogDao orderUploadLogDao;
@Resource
private SubmitOrderUtil submitOrderUtil;
@Resource
AuthWarehouseUserMapper authWarehouseUserMapper;
@Resource
private ThrOrderUploadBustypesMapper thrOrderUploadBustypesMapper;
/**
* xml
*
* @param methodName
* @return
*/
public String getMsgHeader(String methodName) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<root>" +
"<serverName>" +
methodName +
"</serverName>" +
"</root>";
}
public String parserResult(String response) {
if (response.contains("<root")) {
try {
Document document = DocumentHelper.parseText(response);
String message = document.getRootElement().element("message").getText();
return message;
} catch (DocumentException e) {
log.info("解析诏安智业接口返回结果异常, 返回结果:{}", response);
log.error("异常信息:", e);
}
}
return response;
}
@Override
public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialUnit"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsUnitRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_CORP_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 + ")");
}
}
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialDict"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsProductRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PI_QUERY_URL), zaZyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
Map map = (Map) baseResponse.getData();
List<ZzzyyProductsResponse> zzzyyProductsResponse = JSON.parseArray(map.get("list") + "", ZzzyyProductsResponse.class);
for (ZzzyyProductsResponse productsResponse : zzzyyProductsResponse) {
//判断要是规格和型号一致就是取规格 不一致就合并
if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isNotEmpty(productsResponse.getStandard())) {
if (productsResponse.getModel_number().equals(productsResponse.getStandard())) {
productsResponse.setStandard(productsResponse.getStandard());
} else {
productsResponse.setStandard(productsResponse.getStandard() + productsResponse.getModel_number());
}
} else if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isBlank(productsResponse.getStandard())) {
productsResponse.setStandard(productsResponse.getModel_number());
}
}
map.put("list", JSON.toJSON(zzzyyProductsResponse));
baseResponse.setData("");
baseResponse.setData(map);
return baseResponse;
} catch (Exception e) {
log.error("解析诏安智业接口返回产品信息字典数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
@Override
public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialType"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsBusTypeRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_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 + ")");
}
}
@Override
public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialApply"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsOrderQueryRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_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 + ")");
}
}
@Resource
private OrderUploadLogService orderUploadLogService;
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
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()).last("limit 1"));
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.setThirdSys(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 if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
//供应商
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()));
if (thrInvWarehouseEntity != null) {
zaxzyyOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
zaxzyyOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
zaxzyyOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
zaxzyyOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
} else {
orderUploadLogService.updateLocalErr(orderEntity, "查询第三方系统仓库信息异常");
return ResultVOUtils.error(500, "查询第三方系统仓库信息异常");
}
} catch (Exception e) {
log.error("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e));
orderUploadLogService.updateLocalErr(orderEntity, "查询第三方系统仓库信息异常" + ExceptionUtil.stacktraceToString(e));
return ResultVOUtils.error(500, "查询第三方系统仓库信息异常");
}
//设置单据出入库类型
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("\"产品信息对照异常,无法上传\"");
orderUploadLogService.updateLocalErr(orderEntity, "产品信息对照异常,无法上传");
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.setSecSalesInvNo(fphm);
i.setInvoiceDate(fprq);
boolean isNeedFp = false;
ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesMapper.selectOne(new QueryWrapper<ThrOrderUploadBustypesEntity>().eq("action", basicBussinessTypeEntity.getAction()).last("limit 1"));
if (thrOrderUploadBustypesEntity != null && IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) {
isNeedFp = true;
}
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT) && StrUtil.isEmpty(fphm) && isNeedFp) {
String errMsg = "提交失败,错误信息:" + i.getProductName() + "发票缺失,请补齐后重新提交";
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
}
//构造诏安接口参数
ZaZyRequest zaZyRequest = new ZaZyRequest();
//
//提交到第三方系统
if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) {
//采购入库单据
zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest));
return submitOrder(orderEntity, zaZyRequest);
} else if (thrSystemBusApiEntity.getUrl().equals("saveMaterialHight")) {
// 1.先提交到物资;
// zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput"));
// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest));
// submitOrder(orderEntity, zaZyRequest);
// 2.提交到预备货
zaxzyyOrderRequest.setLocStorageCode("1001304");
zaxzyyOrderRequest.setLocStorageName("骨科耗材及试剂仓库");
zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity);
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
return submitOrder(orderEntity, zaZyRequest);
}
return ResultVOUtils.error(500, "提交失败!");
}
public String getUserName(IoOrderEntity orderEntity) {
AuthUserEntity authUserEntity = null;
//创建人非供应商
if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) {
authUserEntity = authUserDao.selectById(orderEntity.getReviewUser());
} else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) {
authUserEntity = authUserDao.selectById(orderEntity.getCreateUser());
} else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) {
authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser());
} else {
List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
return authWarehouseUsers.get(0).getUserName();
}
}
if (authUserEntity != null)
return authUserEntity.getUserName();
return null;
}
/**
*
*
* @param orderEntity
* @param zaZyRequest
* @return
*/
private BaseResponse submitOrder(IoOrderEntity orderEntity, ZaZyRequest 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, "提交失败");
}
}
/**
*
*
* @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);
}
}
}
}
@Override
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialStorage"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsInvProductsRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_INV_PI_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 + ")");
}
}
@Override
public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialDept"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsWarehouseRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_WAREHOUSE_QUERY_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 + ")");
}
}
@Override
public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) {
postThrProductsRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) {
postThrCorpRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) {
postFileThrOrderRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) {
return null;
}
@Override
public BaseResponse testConnect() {
UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
udiwmsUnitRequest.setPage(1);
udiwmsUnitRequest.setLimit(1);
BaseResponse baseResponse = getUnit(udiwmsUnitRequest);
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("连接成功!");
}
return ResultVOUtils.error(500, "连接失败!");
}
@Override
public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) {
return null;
}
@Override
public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) {
return null;
}
@Override
public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) {
ZaZyRequest zaZyRequest = new ZaZyRequest();
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);
String code = codeDetaiEntity.getCode();
if (code.contains("\u001D")) {
// code = code.replace("\u001D", "zysoft"); 智业无法识别GS1符号
code = code.replace("\u001D", "");
}
itemDTO.setCode(code);
itemDTO.setNameCode(code.substring(0, 16));
itemDTO.setCount(codeDetaiEntity.getCount());
itemDTOS.add(itemDTO);
}
}
}
}
udiwmsPreInOrderRequest.setItems(itemDTOS);
}
return udiwmsPreInOrderRequest;
}
}

@ -1,162 +0,0 @@
package com.glxp.mipsdl.client.zaxyy;
import cn.hutool.core.thread.ThreadUtil;
import com.glxp.mipsdl.client.BaseFileClient;
import com.glxp.mipsdl.req.post.PostThrCorpRequest;
import com.glxp.mipsdl.req.post.PostThrProductsRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.udiwms.UdiwmsProductInfoResponse;
import com.glxp.mipsdl.res.udiwms.UdiwmsUnitResponse;
import com.glxp.mipsdl.service.file.UdiInfoUploadService;
import com.glxp.mipsdl.util.ExcelUtil;
import com.glxp.mipsdl.util.ExecutorUtil;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.vo.file.zazyy.ZyCorpEntity;
import com.glxp.mipsdl.vo.file.zazyy.ZyProductEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* V1
*/
@Slf4j
@Service
public class ZazyyFileClient implements BaseFileClient {
@Resource
private UdiInfoUploadService udiInfoUploadService;
@Resource
private ExecutorUtil executorUtil;
@Override
public BaseResponse uploadPi(List<MultipartFile> files, String thirdSys) {
for (int i = 0; i < files.size(); i++) {
MultipartFile file = files.get(i);
if (file.isEmpty()) {
return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败");
}
try {
InputStream inputStream = file.getInputStream();
ExcelUtil<ZyProductEntity> util = new ExcelUtil(ZyProductEntity.class);
List<ZyProductEntity> zyProductEntities = util.importExcel(inputStream);
List<UdiwmsProductInfoResponse> udiwmsProductInfoResponses = new ArrayList<>();
for (ZyProductEntity zyProductEntity : zyProductEntities) {
UdiwmsProductInfoResponse udiwmsProductInfoResponse = new UdiwmsProductInfoResponse();
BeanUtils.copyProperties(zyProductEntity, udiwmsProductInfoResponse);
udiwmsProductInfoResponses.add(udiwmsProductInfoResponse);
}
PostThrProductsRequest postThrProductsRequest = new PostThrProductsRequest();
postThrProductsRequest.setDatas(udiwmsProductInfoResponses);
postThrProductsRequest.setUploadType("文件导入");
postThrProductsRequest.setThirdSys(thirdSys);
executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> {
udiInfoUploadService.postProducts(postThrProductsRequest);
}, "uploadPi"));
log.error("上传完" + System.currentTimeMillis());
} catch (IOException e) {
log.error("解析上传excel文件IO异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
} catch (Exception e) {
log.error("处理产品信息excel文件异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
}
}
return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看");
}
@Override
public BaseResponse uploadCorps(List<MultipartFile> files, String thirdSys) {
for (int i = 0; i < files.size(); i++) {
MultipartFile file = files.get(i);
if (file.isEmpty()) {
return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败");
}
List<UdiwmsUnitResponse> udiwmsUnitResponses = new ArrayList<>();
try {
InputStream inputStream = file.getInputStream();
ExcelUtil<ZyCorpEntity> util = new ExcelUtil(ZyCorpEntity.class);
List<ZyCorpEntity> zyCorpEntities = util.importExcel(inputStream);
for (ZyCorpEntity zyCorpEntity : zyCorpEntities) {
UdiwmsUnitResponse udiwmsUnitResponse = new UdiwmsUnitResponse();
udiwmsUnitResponse.setName(zyCorpEntity.getCorpName());
udiwmsUnitResponse.setUnitId(zyCorpEntity.getCorpCode());
udiwmsUnitResponses.add(udiwmsUnitResponse);
}
PostThrCorpRequest postThrProductsRequest = new PostThrCorpRequest();
postThrProductsRequest.setCorps(udiwmsUnitResponses);
postThrProductsRequest.setThirdSys(thirdSys);
executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> {
udiInfoUploadService.postCorps(postThrProductsRequest);
}, "uploadCorps"));
} catch (IOException e) {
log.error("解析往来单位excel文件IO异常错误信息{}", e);
return ResultVOUtils.error(500, "数据异常");
} catch (Exception e) {
log.error("解析往来单位excel文件异常异常信息{}", e);
return ResultVOUtils.error(500, "数据异常");
}
}
return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看");
}
@Override
public BaseResponse uploadInvPi(List<MultipartFile> files, String thirdSys) {
return ResultVOUtils.error(500, "暂不支持库存产品信息上传!");
}
@Override
public BaseResponse uploadOrders(List<MultipartFile> files, String thirdSys) {
return ResultVOUtils.error(500, "暂不支持业务单据上传!");
}
public boolean filterEmpty(Row row) {
if (row.getCell(0) != null) {
row.getCell(0).setCellType(CellType.STRING);
}
if (row.getCell(1) != null) {
row.getCell(1).setCellType(CellType.STRING);
}
if (row.getCell(2) != null) {
row.getCell(2).setCellType(CellType.STRING);
}
if (row.getCell(3) != null) {
row.getCell(3).setCellType(CellType.STRING);
}
if (row.getCell(4) != null) {
row.getCell(4).setCellType(CellType.STRING);
}
if (row.getCell(5) != null) {
row.getCell(5).setCellType(CellType.STRING);
}
if (row.getCell(6) != null) {
row.getCell(6).setCellType(CellType.STRING);
}
if ((row.getCell(0) == null && row.getCell(1) == null && row.getCell(2) == null
&& row.getCell(3) == null && row.getCell(4) == null && row.getCell(5) == null && row.getCell(6) == null) ||
(
(row.getCell(0) != null && row.getCell(1) != null && row.getCell(2) != null
&& row.getCell(3) != null && row.getCell(4) != null && row.getCell(5) != null && row.getCell(6) != null) &&
("".equals(row.getCell(0).getStringCellValue())
&& "".equals(row.getCell(1).getStringCellValue())
&& "".equals(row.getCell(2).getStringCellValue())
&& "".equals(row.getCell(3).getStringCellValue())
&& "".equals(row.getCell(4).getStringCellValue())
&& "".equals(row.getCell(5).getStringCellValue())
&& "".equals(row.getCell(6).getStringCellValue()))
)) {
return true;
}
return false;
}
}

@ -1,498 +0,0 @@
package com.glxp.mipsdl.client.zzzyy;
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 com.alibaba.fastjson.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.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.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.post.*;
import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest;
import com.glxp.mipsdl.res.BaseResponse;
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.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.stream.Collectors;
/**
* --HIS
*/
@Slf4j
@Service(value = "100010HttpClient")
public class ZzzyyClient extends CommonHttpClient {
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private HttpClient httpClient;
@Resource
private IoOrderDao orderDao;
@Resource
private ThrSystemBusApiDao thrSystemBusApiDao;
@Resource
private AuthUserDao authUserDao;
@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 IoOrderUploadLogDao orderUploadLogDao;
@Resource
private SubmitOrderUtil submitOrderUtil;
@Resource
AuthWarehouseUserMapper authWarehouseUserMapper;
@Override
public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_CORP_URL), udiwmsUnitRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), udiwmsProductRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_BUS_TYPE_QUERY_URL), udiwmsBusTypeRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) {
return ResultVOUtils.error(500, "这个接口暂时没用");
}
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
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", orderEntity.getAction()));
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
// return ResultVOUtils.error(500, "接口未配置,无法提交!");
}
zaxzyyOrderRequest.setThirdSys(getUserName(orderEntity));
zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode());
zaxzyyOrderRequest.setBillFlag("1");
//查询单据类型
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction());
ThrCorpEntity thrCorp = thrCorpService.getThrCorp(orderEntity.getFromCorp());
if (null != thrCorp) {
zaxzyyOrderRequest.setCorpId(thrCorp.getUnitId());
zaxzyyOrderRequest.setCorpName(thrCorp.getName());
} else {
log.error("查询单据对应的第三方往来单位信息异常");
}
// 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", orderEntity.getFromCorp()));
// 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 if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
// //供应商
// ThrCorpEntity thrCorp = thrCorpService.getThrCorp(orderEntity.getFromCorp());
// if (null != thrCorp) {
// zaxzyyOrderRequest.setCorpId(thrCorp.getUnitId());
// zaxzyyOrderRequest.setCorpName(thrCorp.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);
}
//构造诏安接口参数
// UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity);
return submitOrder(orderEntity, zaxzyyOrderRequest);
}
public String getUserName(IoOrderEntity orderEntity) {
//创建人非供应商
if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser());
return authUserEntity.getUserName();
} else {
List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
return authWarehouseUsers.get(0).getUserName();
}
}
return null;
}
/**
*
*
* @param orderEntity
* @param zaZyRequest
* @return
*/
private BaseResponse submitOrder(IoOrderEntity orderEntity, ZaxzyyOrderRequest 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.getUrl(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest);
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("解析提交到HIS单据返回结果异常结果信息{}", 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, "提交失败");
}
}
/**
*
*
* @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);
}
}
}
}
@Override
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
return ResultVOUtils.error(500, "该接口暂时不用");
}
@Override
public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_WAREHOUSE_QUERY_URL), udiwmsWarehouseRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) {
postThrProductsRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) {
postThrCorpRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) {
postFileThrOrderRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) {
return null;
}
@Override
public BaseResponse testConnect() {
UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
udiwmsUnitRequest.setPage(1);
udiwmsUnitRequest.setLimit(1);
BaseResponse baseResponse = getUnit(udiwmsUnitRequest);
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("连接成功!");
}
return ResultVOUtils.error(500, "连接失败!");
}
@Override
public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) {
return null;
}
@Override
public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) {
return null;
}
@Override
public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) {
return ResultVOUtils.error(500, "这接口暂时不用!");
}
/**
*
*
* @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;
}
}

@ -1,635 +0,0 @@
package com.glxp.mipsdl.client.zzzyy;
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.fastjson.JSON;
import com.alibaba.fastjson.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.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.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.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.udiwms.ZzzyyProductsResponse;
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
public class ZzzyyClient1 extends CommonHttpClient {
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private HttpClient httpClient;
@Resource
private IoOrderDao orderDao;
@Resource
private ThrSystemBusApiDao thrSystemBusApiDao;
@Resource
private AuthUserDao authUserDao;
@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 IoOrderUploadLogDao orderUploadLogDao;
@Resource
private SubmitOrderUtil submitOrderUtil;
@Resource
AuthWarehouseUserMapper authWarehouseUserMapper;
/**
* xml
*
* @param methodName
* @return
*/
public String getMsgHeader(String methodName) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<root>" +
"<serverName>" +
methodName +
"</serverName>" +
"</root>";
}
public String parserResult(String response) {
if (response.contains("<root")) {
try {
Document document = DocumentHelper.parseText(response);
String message = document.getRootElement().element("message").getText();
return message;
} catch (DocumentException e) {
log.info("解析漳州中医院智业接口返回结果异常, 返回结果:{}", response);
log.error("异常信息:", e);
}
}
return response;
}
@Override
public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialUnit"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsUnitRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_CORP_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 + ")");
}
}
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialDict"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsProductRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PI_QUERY_URL), zaZyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
Map map = (Map) baseResponse.getData();
List<ZzzyyProductsResponse> zzzyyProductsResponse = JSON.parseArray(map.get("list") + "", ZzzyyProductsResponse.class);
for (ZzzyyProductsResponse productsResponse : zzzyyProductsResponse) {
//判断要是规格和型号一致就是取规格 不一致就合并
if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isNotEmpty(productsResponse.getStandard())) {
if (productsResponse.getModel_number().equals(productsResponse.getStandard())) {
productsResponse.setStandard(productsResponse.getStandard());
} else {
productsResponse.setStandard(productsResponse.getStandard() + productsResponse.getModel_number());
}
} else if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isBlank(productsResponse.getStandard())) {
productsResponse.setStandard(productsResponse.getModel_number());
}
}
map.put("list", JSON.toJSON(zzzyyProductsResponse));
baseResponse.setData("");
baseResponse.setData(map);
return baseResponse;
} catch (Exception e) {
log.error("解析漳州中医院智业接口返回产品信息字典数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
@Override
public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialType"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsBusTypeRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_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 + ")");
}
}
@Override
public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialApply"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsOrderQueryRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_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 + ")");
}
}
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
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.setThirdSys(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 if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
//供应商
ThrCorpEntity thrCorp = thrCorpService.getThrCorp(udiwmsOrderRequest.getCorpId());
if (null != thrCorp) {
zaxzyyOrderRequest.setCorpId(thrCorp.getUnitId());
zaxzyyOrderRequest.setCorpName(thrCorp.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")) {
//采购入库单据
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);
}
public String getUserName(IoOrderEntity orderEntity) {
//创建人非供应商
if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser());
return authUserEntity.getUserName();
} else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) {
AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser());
return authUserEntity.getUserName();
} else {
List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
return authWarehouseUsers.get(0).getUserName();
}
}
return null;
}
/**
*
*
* @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, "提交失败");
}
}
/**
*
*
* @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);
}
}
}
}
@Override
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialStorage"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsInvProductsRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_INV_PI_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 + ")");
}
}
@Override
public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("getMaterialDept"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsWarehouseRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_WAREHOUSE_QUERY_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 + ")");
}
}
@Override
public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) {
postThrProductsRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) {
postThrCorpRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) {
postFileThrOrderRequest.setUploadType("文件导入");
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) {
return null;
}
@Override
public BaseResponse testConnect() {
UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
udiwmsUnitRequest.setPage(1);
udiwmsUnitRequest.setLimit(1);
BaseResponse baseResponse = getUnit(udiwmsUnitRequest);
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("连接成功!");
}
return ResultVOUtils.error(500, "连接失败!");
}
@Override
public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) {
String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
}
@Override
public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) {
return null;
}
@Override
public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) {
return null;
}
@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;
}
}

@ -1,9 +0,0 @@
package com.glxp.mipsdl.dao.ptxyy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.mipsdl.client.ptxhyy.entity.ThrHslbEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ThrHslbMapper extends BaseMapper<ThrHslbEntity> {
}

@ -0,0 +1,29 @@
package com.glxp.mipsdl.entity.lhsyy;
import lombok.Data;
@Data
public class MaterialDictEntity {
private String materialCode;
/**
* ID
*/
private Integer flid;
/**
* ID
*/
private Integer xlid;
/**
*
*/
private String ypspm;
// cd gg xh dw dw1 hsgx ybbm pfj lsj pzwh ghdw healthcode ybjsqr sfzht gjhcbm sfybfw
}

@ -22,10 +22,10 @@ public class UdiwmsOrderDetailRequest {
*/
private String productName;
/**
* ID
*/
private String bindRlFk;
// /**
// * 耗材字典ID外键
// */
// private String bindRlFk;
/**
*
@ -117,10 +117,7 @@ public class UdiwmsOrderDetailRequest {
*/
private String remark3;
/**
*
*/
private boolean allowNoBatch;
/**
*

@ -111,8 +111,11 @@ public class SubmitOrderUtil {
BeanUtil.copyProperties(detailBizEntity, item);
item.setProductDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getProductDate()) ? null : "20" + detailBizEntity.getProductDate()));
item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "20" + detailBizEntity.getExpireDate()));
if (StrUtil.isEmpty(detailBizEntity.getExpireDate())){
item.setExpireDate("");
}else {
item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "20" + detailBizEntity.getExpireDate()));
}
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
item.setProductId(thirdProductId); //产品ID
//查询第三方产品名称

Loading…
Cancel
Save