You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-third-java/src/main/java/com/glxp/mipsdl/client/yxfuyy/YxfyyyClient.java

2050 lines
136 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.glxp.mipsdl.client.yxfuyy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.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.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.client.yxfuyy.entity.InvCodeResultEntity;
import com.glxp.mipsdl.client.yxfuyy.entity.InvProjectResultEntity;
import com.glxp.mipsdl.client.yxfuyy.entity.InvResultEntity;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.BusTypeConstant;
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.*;
import com.glxp.mipsdl.dao.inout.*;
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.basic.*;
import com.glxp.mipsdl.entity.ctqyy.*;
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.ThrProductsEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.ctqyy.*;
import com.glxp.mipsdl.req.post.*;
import com.glxp.mipsdl.req.yb.*;
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.PageSimpleResponse;
import com.glxp.mipsdl.res.ctqyy.CtBaseResponse;
import com.glxp.mipsdl.res.udiwms.*;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.basic.RelCodeDetailService;
import com.glxp.mipsdl.service.order.OrderUploadLogService;
import com.glxp.mipsdl.service.system.SysParamConfigService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.service.yb.YbClient;
import com.glxp.mipsdl.thirddao.ctqyy.*;
import com.glxp.mipsdl.util.*;
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.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service(value = "100013HttpClient")
public class YxfyyyClient extends CommonHttpClient {
private final String[] buyType_3501 = {"24"};
private final String[] buyType_3502 = {"7", "6", "5", "4", "1", "16", "12", "28", "35"};
private final String[] buyType_3505 = {"QXCF001", "YPCF002"};
private final String[] buyType_3506 = {"YPTH001"};
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private HttpClient httpClient;
@Resource
private SubmitOrderUtil submitOrderUtil;
@Resource
private IoOrderUploadLogDao orderUploadLogDao;
@Resource
private IoOrderDao orderDao;
@Resource
private ThrSystemBusApiDao thrSystemBusApiDao;
@Resource
private BasicBussinessTypeDao basicBussinessTypeDao;
@Resource
private BasicCorpDao basicCorpDao;
@Resource
private IoCodeDao codeDao;
@Resource
private AuthWarehouseDao authWarehouseDao;
@Resource
private ThrInvWarehouseDao thrInvWarehouseDao;
@Resource
private AuthWarehouseService authWarehouseService;
@Resource
private ThirdSysConfig thirdSysConfig;
@Resource
private ThrCorpService thrCorpService;
@Resource
private IoOrderDetailBizDao orderDetailBizDao;
@Resource
private IoOrderDetailCodeDao orderDetailCodeDao;
@Resource
private AuthUserDao authUserDao;
@Resource
BasicUdirelDao basicUdirelDao;
@Resource
BasicProductsDao basicProductsDao;
@Resource
private OrderUploadLogService orderUploadLogService;
@Resource
VInsurNationGoodsPhysicMapper goodsPhysicMapper;
@Resource
VInsurNationGoodsReturnMapper vInsurNationGoodsReturnMapper;
@Resource
VYpzsPresInfoReturnMapper vYpzsPresInfoReturnMapper;
@Resource
private VYpzsPhysicDictMapper vYpzsPhysicDictMapper;
@Resource
private VYpzsPresInfoMapper vYpzsPresInfoMapper;
@Resource
private VYpzsPlanInfoMapper vYpzsPlanInfoMapper;
@Resource
private VYpzsIoInfoMapper vYpzsIoInfoMapper;
@Resource
private YbClient ybClient;
@Resource
private RelCodeDetailService relCodeDetailService;
/**
* 拼接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) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
// udiwmsUnitRequest.setUnitType("2");
ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialUnit"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsUnitRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_CORP_URL), ctqyyRequest);
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 getManu(UdiwmsManuRequest udiwmsManuRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialUnit"));
udiwmsManuRequest.setUnitType("2");
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsManuRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_CORP_URL), ctqyyRequest);
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 udiwmsProductRequest
* @return
*/
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
if (udiwmsProductRequest.getProductType().equals(Constants.PRODUCT_TYPE_DEVICE)) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialDict"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsProductRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PI_QUERY_URL), ctqyyRequest);
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());
}
productsResponse.setProductType(1);
}
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 + ")");
}
} else if (udiwmsProductRequest.getProductType().equals(Constants.PRODUCT_TYPE_DRUG)) {
LambdaQueryWrapper<VYpzsPhysicDict> wrapper = new LambdaQueryWrapper();
//补充其他查询条件
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getCode()), VYpzsPhysicDict::getPHYSIC_CODE, udiwmsProductRequest.getCode());
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getName()), VYpzsPhysicDict::getPHYSIC_NAME, udiwmsProductRequest.getName());
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getRegisterNo()), VYpzsPhysicDict::getPHYSIC_NO, udiwmsProductRequest.getRegisterNo());
IPage<VYpzsPhysicDict> page = vYpzsPhysicDictMapper.selectPage(new Page<VYpzsPhysicDict>(udiwmsProductRequest.getPage(), udiwmsProductRequest.getLimit()), wrapper);
List<VYpzsPhysicDict> physicDictEntities = page.getRecords();
List<ThrProductsEntity> thrProductsEntityList = null;
if (CollUtil.isNotEmpty(physicDictEntities)) {
//数据处理以thr_products 返回
thrProductsEntityList = physicDictEntities.stream().map(dict -> {
ThrProductsEntity products = new ThrProductsEntity();
products.setCode(dict.getPHYSIC_CODE());
products.setName(dict.getPHYSIC_NAME());
products.setMeasname(dict.getPACK_UNIT());
products.setSpec(dict.getPACK_SPEC());
products.setYbbm(dict.getCOUNTRY_CODE());
products.setPrepnSpec(dict.getPHYSIC_SPEC());
products.setPrepnUnit(dict.getPHYSIC_UNIT());
products.setProductType(2);
return products;
}).collect(Collectors.toList());
}
PageSimpleResponse<ThrProductsEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(thrProductsEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
log.error("解析长泰区医院医疗类型,返回结果:{}", udiwmsProductRequest.getProductType());
return ResultVOUtils.error(500, "医疗类型不正确productType" + udiwmsProductRequest.getProductType());
}
@Override
public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialType"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsBusTypeRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_URL), ctqyyRequest);
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 + ")");
}
}
/**
* 提交关联产品更新
*
* @return
*/
@Override
public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) {
UdiRelevanceResponse udiRelevanceResponse = postThrInvProductsRequest.getUdiRelevanceResponse();
if (udiRelevanceResponse == null) {
return ResultVOUtils.error(500, "提交产品列表不能为空!");
}
MaterialDictEntity materialDictEntity = new MaterialDictEntity();
if (StrUtil.isEmpty(udiRelevanceResponse.getMainId()) && StrUtil.isNotEmpty(udiRelevanceResponse.getOriginUuid()))
materialDictEntity.setOperatType("1");
else
materialDictEntity.setOperatType("2");
materialDictEntity.setMaterialName(udiRelevanceResponse.getCpmctymc());
materialDictEntity.setCostlySign("1");
if (StrUtil.isNotEmpty(udiRelevanceResponse.getMainId()) && udiRelevanceResponse.getMainId().endsWith("x")) {
materialDictEntity.setMaterialMasterCode(null);
materialDictEntity.setHisMaterialCode(null);
materialDictEntity.setCostlySign("0");
materialDictEntity.setOperatType("1");
} else {
materialDictEntity.setMaterialMasterCode(udiRelevanceResponse.getNameCode());
materialDictEntity.setHisMaterialCode(udiRelevanceResponse.getMainId());
}
materialDictEntity.setMaterialSpec(udiRelevanceResponse.getGgxh());
materialDictEntity.setMaterialUnit(udiRelevanceResponse.getMeasname());
//暂无区分进货价,零售价
materialDictEntity.setImportPrice(udiRelevanceResponse.getPrice() == null ? "0" : udiRelevanceResponse.getPrice().toString());
materialDictEntity.setRetailPrice(udiRelevanceResponse.getPrice() == null ? "0" : udiRelevanceResponse.getPrice().toString());
materialDictEntity.setFactoryName(udiRelevanceResponse.getManufactory());
materialDictEntity.setSupplierName(udiRelevanceResponse.getSupName());
materialDictEntity.setInsuranceCode(udiRelevanceResponse.getYbbm());
materialDictEntity.setRegeditNo(udiRelevanceResponse.getZczbhhzbapzbh());
materialDictEntity.setMaterialClass(udiRelevanceResponse.getBasicPrductRemak7());
//暂无中标标识
materialDictEntity.setPublicFlag("1");
materialDictEntity.setPriceItemClass(udiRelevanceResponse.getBasicPrductRemak8());
//暂无收费标志
materialDictEntity.setFeeFlag(udiRelevanceResponse.getBasicPrductRemak6());
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("addMaterialDict"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(materialDictEntity));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRODUCT_SUBMIT_URL), ctqyyRequest);
response = parserResult(response);
try {
log.error("提交新增产品信息:" + ctqyyRequest.getMsgBody());
CtBaseResponse baseResponse = JSONObject.parseObject(response, CtBaseResponse.class);
if (baseResponse.getCode() != 20000) {
String errMsg = "提交新增产品信息,异常:{}" + response;
log.error(errMsg);
return ResultVOUtils.error(500, "提交新增产品失败!");
} else {
// materialDictEntity.setMaterialNo(baseResponse.getMaterialNo());
log.error("提交新增产品信息,成功:{}", response);
return ResultVOUtils.success(baseResponse.getMaterialNo());
}
} catch (Exception e) {
String errMsg = "提交新增产品信息,异常:{}" + response;
log.error(errMsg);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, errMsg);
}
}
/**
* 获取患者信息
*
* @param getSickRequest
* @return
*/
public BaseResponse getSickInfo(GetSickRequest getSickRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getSickVisitInfo"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(getSickRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_SICKER), ctqyyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
Map map = (Map) baseResponse.getData();
List<BasicSkSickerResponse> basicSkSickerResponses = JSON.parseArray(map.get("list") + "", BasicSkSickerResponse.class);
// for (BasicSkSickerResponse productsResponse : basicSkSickerResponses) {
//
// }
map.put("list", JSON.toJSON(basicSkSickerResponses));
baseResponse.setData("");
baseResponse.setData(map);
return baseResponse;
} catch (Exception e) {
log.error("解析长泰医院智业返回病人信息数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
/**
* 获取患者处方信息
*
* @param getSickPrescribeRequest
* @return
*/
public BaseResponse getSickPescribe(GetSickPrescribeRequest getSickPrescribeRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getResiPresInfo"));
getSickPrescribeRequest.setResiNo(getSickPrescribeRequest.getAdNum());
getSickPrescribeRequest.setAdNum(null);
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(getSickPrescribeRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_SICKER_PRESCIRBE), ctqyyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
Map map = (Map) baseResponse.getData();
List<BasicSkPrescribeResponse> basicSkPrescribeResponses = JSON.parseArray(map.get("list") + "", BasicSkPrescribeResponse.class);
for (BasicSkPrescribeResponse basicSkPrescribeResponse : basicSkPrescribeResponses) {
List<BasicSkPrescribeItemEntity> itemEntities = basicSkPrescribeResponse.getItemList();
if (CollUtil.isNotEmpty(itemEntities)) {
for (BasicSkPrescribeItemEntity itemEntity : itemEntities) {
itemEntity.setCount("0");
}
}
}
map.put("list", JSON.toJSON(basicSkPrescribeResponses));
baseResponse.setData("");
baseResponse.setData(map);
return baseResponse;
} catch (Exception e) {
log.error("解析长泰医院智业返回处方信息数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
// public String getStrConut(String str) {
// if (StrUtil.isNotEmpty(str)) {
// return "0";
// }
// Pattern pattern = Pattern.compile("\\d+");
// Matcher matcher = pattern.matcher(str);
// String strCount = "";
// while (matcher.find()) {
// strCount = strCount + matcher.group();
// }
// return strCount;
// }
/**
* 获取项目组套字典
*
* @param dlThirdProjectRequest
* @return
*/
@Override
public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialDict"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(dlThirdProjectRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_PROJECT), ctqyyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
Map map = (Map) baseResponse.getData();
List<BasicSkProjectResponse> basicSkProjectResponses = JSON.parseArray(map.get("list") + "", BasicSkProjectResponse.class);
for (BasicSkProjectResponse basicSkProjectResponse : basicSkProjectResponses) {
}
map.put("list", JSON.toJSON(basicSkProjectResponses));
baseResponse.setData("");
baseResponse.setData(map);
return baseResponse;
} catch (Exception e) {
log.error("解析长泰医院智业返回项目信息数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
/**
* 获取核算类别
*
* @param hslbRequest
* @return
*/
@Override
public BaseResponse getHsfl(FilterThrHslbRequest hslbRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getItemClass"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(hslbRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_HSLB), ctqyyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
Map map = (Map) baseResponse.getData();
List<PriceClassEntity> priceClassEntities = JSON.parseArray(map.get("list") + "", PriceClassEntity.class);
List<ThrHslbEntity> hslbEntities = new ArrayList<>();
for (PriceClassEntity priceClassEntity : priceClassEntities) {
ThrHslbEntity thrHslbEntity = new ThrHslbEntity();
thrHslbEntity.setHsbm(priceClassEntity.getClassCode());
thrHslbEntity.setHsmc(priceClassEntity.getClassName());
hslbEntities.add(thrHslbEntity);
}
map.put("list", JSON.toJSON(hslbEntities));
baseResponse.setData("");
baseResponse.setData(map);
return baseResponse;
} catch (Exception e) {
log.error("解析长泰医院智业返回物价类别信息异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
@Override
public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) {
return null;
}
@Resource
SysParamConfigService sysParamConfigService;
@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()));
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) {
String msg = "查询单据对应往来单位的第三方仓库信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
} else {
//供应商
BasicCorpEntity basicCorpEntity = null;
if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) {
basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
}
if (basicCorpEntity != null) {
zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId());
zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
String msg = "查询单据对应的第三方往来单位信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
//查询仓库信息
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);
String msg = "查询第三方系统仓库信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
return ResultVOUtils.error(500, msg);
}
//设置单据出入库类型
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()));
String errMsg = setOrderDetailList(ioCodeEntities, items, detailBizEntities);
zaxzyyOrderRequest.setItem(items);
if (CollUtil.isEmpty(items)) {
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
if (StrUtil.isNotEmpty(errMsg)) {
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
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);
}
//构造诏安接口参数
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
//提交到第三方系统
if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) {
// //采购入库单据
// if (vailHightMaterial(detailBizEntities.get(0))) {
// zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
// UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity);
// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
// } else {
// zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput"));
// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest));
// }
Boolean b = sysParamConfigService.selectByKey("ct_split_groupbuy");
if (b) {
Map<String, List<UdiwmsOrderDetailRequest>> splitMap = items.stream()
.collect(Collectors.groupingBy(UdiwmsOrderDetailRequest::getFirstSalesInvNo));
BaseResponse baseResponse = null;
int index = 1;
if (splitMap.size() > 1) {
for (List<UdiwmsOrderDetailRequest> splitItems : splitMap.values()) {
zaxzyyOrderRequest.setItem(splitItems);
zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest));
orderEntity.setBillNo(orderEntity.getBillNo() + "-" + index);
baseResponse = submitOrder(orderEntity, zaZyRequest);
}
return baseResponse;
} else {
zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest));
return submitOrder(orderEntity, zaZyRequest);
}
} else {
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.提交到预备货
zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity);
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
return submitOrder(orderEntity, zaZyRequest);
}
return ResultVOUtils.error(500, "提交失败!");
}
/**
* 校验是否高值耗材
*
* @return
*/
public boolean vailHightMaterial(IoOrderDetailBizEntity orderDetailBizEntity) {
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(orderDetailBizEntity.getBindRlFk());
BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne(new QueryWrapper<BasicProductsEntity>().eq("uuid", basicUdirel.getUuid()).last("limit 1"));
if (basicProductsEntity != null &&
(StrUtil.trimToEmpty(basicProductsEntity.getBasicPrductRemak7()).equals("1101")
|| StrUtil.trimToEmpty(basicProductsEntity.getBasicPrductRemak7()).equals("3601"))) {
return true;
} else
return false;
}
public String getUserName(IoOrderEntity orderEntity) {
return "方奕生/1007";
// String userName = null;
// //创建人非供应商
// if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) {
// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser());
// if (authUserEntity == null)
// userName = null;
// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName();
// } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) {
// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser());
// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName();
// } else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) {
// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser());
// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName();
// } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) {
// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser());
// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName();
// }
// if (userName == null) {
// List<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
// if (CollUtil.isNotEmpty(authWarehouseUsers)) {
// AuthWarehouseUser authWarehouseUser = authWarehouseUsers.get(0);
// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser());
// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName();
// return userName;
// }
// }
// return userName;
}
/**
* 获取库存出入库明细 (普耗出库明细)
*
* @param udiwmsInvProductsRequest
* @return
*/
@Override
public BaseResponse getInvResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
CtqyyInvRequest ptxhyyInvRequest = new CtqyyInvRequest();
ptxhyyInvRequest.setStartdate(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd"));
ptxhyyInvRequest.setEnddate(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd"));
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialSheet"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(ptxhyyInvRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_GET_INV_RESULT), ctqyyRequest);
// String response = "{\"code\":20000,\"message\":\"success\",\"data\":{\"list\":[{\"applyNo\":\"74192\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"65\",\"CreditName\":\"急诊科\",\"AccoutDate\":\"2024-02-2210:36:28\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"66666666\",\"materialName\":\"一次性注射器2ml\",\"materialSpec\":\"0.6\",\"materialUnit\":\"支\",\"batchNo\":65212,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":200,\"importPrc\":0.21,\"importMoney\":42,\"factoryCode\":\"0006064349\",\"factoryName\":\"河南曙光汇知康生物科技股份有限公司\"},{\"applyNo\":\"74208\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"70\",\"CreditName\":\"手术室\",\"AccoutDate\":\"2024-02-2315:29:48\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"31585\",\"materialName\":\"一次性使用鼻氧管(吸氧管)\",\"materialSpec\":\"长单鼻/条\",\"materialUnit\":\"条\",\"batchNo\":64113,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":19,\"importPrc\":1.15,\"importMoney\":21.85,\"factoryCode\":\"0006063576\",\"factoryName\":\"苏州市麦克林医疗器械制品有限公司\"},{\"applyNo\":\"74208\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"70\",\"CreditName\":\"手术室\",\"AccoutDate\":\"2024-02-2315:29:48\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"31585\",\"materialName\":\"一次性使用鼻氧管(吸氧管)\",\"materialSpec\":\"长单鼻/条\",\"materialUnit\":\"条\",\"batchNo\":65526,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":81,\"importPrc\":1.15,\"importMoney\":93.15,\"factoryCode\":\"0006063576\",\"factoryName\":\"苏州市麦克林医疗器械制品有限公司\"},{\"applyNo\":\"74209\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"92\",\"CreditName\":\"儿科\",\"AccoutDate\":\"2024-02-2315:31:58\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"30936\",\"materialName\":\"一次性静脉输液针51/2\",\"materialSpec\":\"/条\",\"materialUnit\":\"条\",\"batchNo\":64898,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":250,\"importPrc\":0.17,\"importMoney\":42.5,\"factoryCode\":\"0006063565\",\"factoryName\":\"浙江康康\"}],\"total\":4}}";
BaseResponse<PageSimpleResponse<InvResultEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<InvResultEntity>>>() {
});
if (baseResponse.getCode() == 20000) {
List<InvResultEntity> ptxhInvResponses = baseResponse.getData().getList();
List<ThrInvResultResponse> thrInvResultResponses = new ArrayList<>();
if (CollUtil.isNotEmpty(ptxhInvResponses)) {
for (InvResultEntity ptxhInvResponse : ptxhInvResponses) {
ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse();
thrInvResultResponse.setThrCode(ptxhInvResponse.getMaterialCode());
thrInvResultResponse.setCpmctymc(ptxhInvResponse.getMaterialName());
thrInvResultResponse.setGgxh(ptxhInvResponse.getMaterialSpec());
thrInvResultResponse.setBatchNo(ptxhInvResponse.getBatchNo());
thrInvResultResponse.setMeasname(ptxhInvResponse.getMaterialUnit());
thrInvResultResponse.setPrice(BigDecimal.valueOf(ptxhInvResponse.getImportPrc()));
thrInvResultResponse.setAmount(BigDecimal.valueOf(ptxhInvResponse.getImportMoney()));
// thrInvResultResponse.setDeptName(ptxhInvResponse.getDebitName());
// thrInvResultResponse.setDeptCode(ptxhInvResponse.getDebit());
// thrInvResultResponse.setInvName(ptxhInvResponse.getCreditName());
// thrInvResultResponse.setInvCode(ptxhInvResponse.getCredit());
thrInvResultResponse.setDeptName(ptxhInvResponse.getDebitName());
thrInvResultResponse.setDeptCode("1002");
thrInvResultResponse.setInvName(ptxhInvResponse.getCreditName());
thrInvResultResponse.setInvCode("1000003");
thrInvResultResponse.setManufacturer(ptxhInvResponse.getFactoryName());
thrInvResultResponse.setManufactoryCode(ptxhInvResponse.getFactoryCode());
thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT);
thrInvResultResponse.setBillType(ptxhInvResponse.getIoType());
thrInvResultResponse.setType("1");
thrInvResultResponse.setOutCount(ptxhInvResponse.getQuantity() + "");
thrInvResultResponse.setReCount(ptxhInvResponse.getQuantity() + "");
thrInvResultResponses.add(thrInvResultResponse);
}
}
PageSimpleResponse<ThrInvResultResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(thrInvResultResponses.size() + 0l);
pageSimpleResponse.setList(thrInvResultResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
return baseResponse;
}
/**
* 获取库存扫码出入库明细(高值耗材出库明细)
*
* @param udiwmsInvProductsRequest
* @return
*/
@Override
public BaseResponse getInvCodeResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
CtqyyInvRequest ptxhyyInvRequest = new CtqyyInvRequest();
ptxhyyInvRequest.setStartdate(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd"));
ptxhyyInvRequest.setEnddate(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd"));
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getSickHighitem"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(ptxhyyInvRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_GET_INV_RESULT), ctqyyRequest);
// String response =
// "{\"code\": 20000,\"message\": \"success\",\"data\": {\"list\": [{\"recordNo\": 391,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63374\",\"materialName\": \"调节杠\",\"materialPrc\": 2100,\"dictBarcode\": \"0106971221560052\",\"Barcode\": \"111704022117000188340055\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 390,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63374\",\"materialName\": \"调节杠\",\"materialPrc\": 2100,\"dictBarcode\": \"0106946149100093\",\"Barcode\": \"111704022117000188340007\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 408,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63182\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106938695502193\",\"Barcode\": \"111703012117000076800035\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 401,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106938695522023\",\"Barcode\": \"111612212116120902040009\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 423,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106938695525055\",\"Barcode\": \"111701062116122700670005\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 400,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106921814249918\",\"Barcode\": \"111612212116120902040047\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 422,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106921814249918\",\"Barcode\": \"111701062116122700670013\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"}],\"total\": 7}}";
// String response = null;
// try {
// response = FileUtils.getFileContent("E://ghresponse.json");
// } catch (IOException e) {
// e.printStackTrace();
// }
BaseResponse<PageSimpleResponse<InvCodeResultEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<InvCodeResultEntity>>>() {
});
if (baseResponse.getCode() == 20000) {
Map<String, ThrInvResultResponse> mapArry = new HashMap<>();
List<ThrInvResultResponse> newArry = new ArrayList<>();
List<InvCodeResultEntity> ptxhInvResponses = baseResponse.getData().getList();
List<ThrInvResultResponse> thrInvResultResponses = new ArrayList<>();
if (CollUtil.isNotEmpty(ptxhInvResponses)) {
for (InvCodeResultEntity ptxhInvResponse : ptxhInvResponses) {
ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse();
thrInvResultResponse.setThrCode(ptxhInvResponse.getMaterialCode());
thrInvResultResponse.setCpmctymc(ptxhInvResponse.getMaterialName());
thrInvResultResponse.setPrice(BigDecimal.valueOf(ptxhInvResponse.getMaterialPrc()));
thrInvResultResponse.setInvName(ptxhInvResponse.getDeptName());
// AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getThirdId, ptxhInvResponse.getInDept()));
// if (warehouseEntity != null)
// thrInvResultResponse.setInvCode(warehouseEntity.getCode());
// else
// thrInvResultResponse.setInvCode(ptxhInvResponse.getInDept());
thrInvResultResponse.setInvCode("1000003");
thrInvResultResponse.setDeptCode("1002");
thrInvResultResponse.setSickerCode(ptxhInvResponse.getVisitNo());
thrInvResultResponse.setSickerName(ptxhInvResponse.getSickName());
thrInvResultResponse.setBillType("SC71090077430919");
thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT);
thrInvResultResponse.setType("1");
thrInvResultResponse.setOutCount("1");
thrInvResultResponse.setReCount("1");
IoCodeEntity codeEntity = codeDao.selectOne(new LambdaQueryWrapper<IoCodeEntity>().eq(IoCodeEntity::getCode, ptxhInvResponse.getBarcode()).last("limit 1"));
if (codeEntity == null) {
codeEntity = codeDao.selectOne(new LambdaQueryWrapper<IoCodeEntity>().eq(IoCodeEntity::getErrUdiCode, ptxhInvResponse.getBarcode()).last("limit 1"));
}
if (codeEntity != null)
thrInvResultResponse.setUdiCode(codeEntity.getCode());
else
thrInvResultResponse.setUdiCode(ptxhInvResponse.getBarcode());
thrInvResultResponses.add(thrInvResultResponse);
}
for (ThrInvResultResponse thrInvResultResponse : thrInvResultResponses) {
mapArry.merge(thrInvResultResponse.getUdiCode(), thrInvResultResponse, (existingValue, newValue) -> {
// Assuming reCount can be directly handled as an integer to avoid String to Integer conversions
int updatedReCount = Integer.parseInt(existingValue.getReCount()) + Integer.parseInt(newValue.getReCount());
existingValue.setReCount(String.valueOf(updatedReCount));
existingValue.setOutCount(existingValue.getReCount());
return existingValue;
});
}
for (String key : mapArry.keySet()) {
newArry.add(mapArry.get(key));
}
}
PageSimpleResponse<ThrInvResultResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(newArry.size() + 0l);
pageSimpleResponse.setList(newArry);
return ResultVOUtils.success(pageSimpleResponse);
}
return baseResponse;
}
@Resource
BasicSkProjectMapper basicSkProjectMapper;
@Resource
UdiRlSupDao udiRlSupDao;
@Resource
BasicDestinyRelMapper basicDestinyRelMapper;
@Override
public BaseResponse getInvFeeResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
CtqyyInvRequest ptxhyyInvRequest = new CtqyyInvRequest();
ptxhyyInvRequest.setStartdate(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd"));
ptxhyyInvRequest.setEnddate(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd"));
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("getSickPriceitem"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(ptxhyyInvRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_GET_INV_RESULT), ctqyyRequest);
// String response =
// "{\"code\": 20000,\"message\": \"success\",\"data\": {\"list\": [{\"seqNo\": \"97425947\",\"visitNo\": \"1471827014\",\"sickName\": \"杨玉聪\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 00:53:56\"},{\"seqNo\": \"97425950\",\"visitNo\": \"1471827014\",\"sickName\": \"杨玉聪\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 00:53:56\"},{\"seqNo\": \"97426036\",\"visitNo\": \"1940696001\",\"sickName\": \"郑良屹\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950057000000\",\"itemName\": \"热敏胶片 8in*10in/HQ-KX411 A型\",\"Price\": 7.8,\"quantity\": 4,\"Cost\": 31.2,\"materialCode\": \"00087\",\"materialName\": \"热敏胶片\",\"OperTime\": \"2024-02-21 01:39:39\"},{\"seqNo\": \"97426048\",\"visitNo\": \"1746585006\",\"sickName\": \"张杨妍\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 02:06:05\"},{\"seqNo\": \"97426113\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:49:46\"},{\"seqNo\": \"97426233\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 04:54:51\"},{\"seqNo\": \"97426247\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:54:55\"},{\"seqNo\": \"97426250\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950029000010\",\"itemName\": \"一次性使用输液器BI-IT带针0.7# /支)\",\"Price\": 0.81,\"quantity\": 1,\"Cost\": 0.81,\"materialCode\": \"02585\",\"materialName\": \"一次性使用输液器 带针\",\"OperTime\": \"2024-02-21 04:56:20\"},{\"seqNo\": \"97426251\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000006\",\"itemName\": \"一次性无菌注射器20ml(/支)\",\"Price\": 0.48,\"quantity\": 2,\"Cost\": 0.96,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:56:21\"},{\"seqNo\": \"97426252\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950031000025\",\"itemName\": \"一次性使用静脉留置针22GII型A直型连接座式安全型Y型2225601\",\"Price\": 4.82,\"quantity\": 1,\"Cost\": 4.82,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:56:21\"},{\"seqNo\": \"97426258\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 04:56:24\"},{\"seqNo\": \"97426284\",\"visitNo\": \"1801137003\",\"sickName\": \"杨立群\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 05:03:40\"},{\"seqNo\": \"97426357\",\"visitNo\": \"1940699001\",\"sickName\": \"严明祥\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950031000025\",\"itemName\": \"一次性使用静脉留置针22GII型A直型连接座式安全型Y型2225601\",\"Price\": 4.82,\"quantity\": 1,\"Cost\": 4.82,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 05:28:40\"},{\"seqNo\": \"97426358\",\"visitNo\": \"1940699001\",\"sickName\": \"严明祥\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000006\",\"itemName\": \"一次性无菌注射器20ml(/支)\",\"Price\": 0.48,\"quantity\": 2,\"Cost\": 0.96,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 05:28:40\"},{\"seqNo\": \"97426359\",\"visitNo\": \"1940699001\",\"sickName\": \"严明祥\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950029000010\",\"itemName\": \"一次性使用输液器BI-IT带针0.7# /支)\",\"Price\": 0.81,\"quantity\": 1,\"Cost\": 0.81,\"materialCode\": \"02585\",\"materialName\": \"一次性使用输液器 带针\",\"OperTime\": \"2024-02-21 05:28:40\"},{\"seqNo\": \"97426433\",\"visitNo\": \"1940702001\",\"sickName\": \"伍邦柏\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 06:51:25\"},{\"seqNo\": \"97426478\",\"visitNo\": \"1927463002\",\"sickName\": \"林海龙\",\"applyDept\": \"187\",\"deptName\": \"门诊呼吸与危重症医学科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:42:23\"},{\"seqNo\": \"97426486\",\"visitNo\": \"1927463002\",\"sickName\": \"林海龙\",\"applyDept\": \"187\",\"deptName\": \"门诊呼吸与危重症医学科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:42:24\"},{\"seqNo\": \"97426518\",\"visitNo\": \"1940705001\",\"sickName\": \"姚连菊\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:48:31\"},{\"seqNo\": \"97426521\",\"visitNo\": \"1940705001\",\"sickName\": \"姚连菊\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:48:31\"},{\"seqNo\": \"97426523\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:49:10\"},{\"seqNo\": \"97426529\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:49:11\"},{\"seqNo\": \"97426535\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:49:13\"},{\"seqNo\": \"97426537\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:49:15\"},{\"seqNo\": \"97426557\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:11\"},{\"seqNo\": \"97426559\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:12\"},{\"seqNo\": \"97426561\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:14\"},{\"seqNo\": \"97426567\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:15\"},{\"seqNo\": \"97426570\",\"visitNo\": \"1407999064\",\"sickName\": \"蔡美花\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:24\"},{\"seqNo\": \"97426572\",\"visitNo\": \"1407999064\",\"sickName\": \"蔡美花\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:24\"},{\"seqNo\": \"97426574\",\"visitNo\": \"1407999064\",\"sickName\": \"蔡美花\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:24\"},{\"seqNo\": \"97426576\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:44\"},{\"seqNo\": \"97426581\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:46\"},{\"seqNo\": \"97426583\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:47\"},{\"seqNo\": \"97426591\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:48\"},{\"seqNo\": \"97426642\",\"visitNo\": \"1613276019\",\"sickName\": \"黄英连\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:13\"},{\"seqNo\": \"97426649\",\"visitNo\": \"1613276019\",\"sickName\": \"黄英连\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:16\"},{\"seqNo\": \"97426654\",\"visitNo\": \"1613276019\",\"sickName\": \"黄英连\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:18\"},{\"seqNo\": \"97426704\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426705\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426713\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426714\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426719\",\"visitNo\": \"1900545011\",\"sickName\": \"李光婷\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:42\"},{\"seqNo\": \"97426724\",\"visitNo\": \"1900545011\",\"sickName\": \"李光婷\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:42\"},{\"seqNo\": \"97426934\",\"visitNo\": \"1719779006\",\"sickName\": \"吴玉秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 08:00:20\"},{\"seqNo\": \"97427072\",\"visitNo\": \"1719779006\",\"sickName\": \"吴玉秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 08:00:22\"},{\"seqNo\": \"97427377\",\"visitNo\": \"1537583008\",\"sickName\": \"刘阿花\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 08:02:37\"},{\"seqNo\": \"97427380\",\"visitNo\": \"1537583008\",\"sickName\": \"刘阿花\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 08:02:39\"},{\"seqNo\": \"97427383\",\"visitNo\": \"1537583008\",\"sickName\": \"刘阿花\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 08:02:41\"},{\"seqNo\": \"97427390\",\"visitNo\": \"1398769053\",\"sickName\": \"徐丽松\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 08:02:48\"}],\"total\": 12296}}";
BaseResponse<PageSimpleResponse<InvProjectResultEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<InvProjectResultEntity>>>() {
});
if (baseResponse.getCode() == 20000) {
List<InvProjectResultEntity> ptxhInvResponses = baseResponse.getData().getList();
List<ThrInvResultResponse> thrInvResultResponses = new ArrayList<>();
Set<String> seenNames = new HashSet<>();
List<InvProjectResultEntity> itemData = new ArrayList<>();
if (CollUtil.isNotEmpty(ptxhInvResponses)) {
for (InvProjectResultEntity ptxhInvResponse : ptxhInvResponses) {
ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse();
thrInvResultResponse.setThrCode(ptxhInvResponse.getMaterialCode());
thrInvResultResponse.setCpmctymc(ptxhInvResponse.getItemName());
thrInvResultResponse.setSickerCode(ptxhInvResponse.getVisitNo());
thrInvResultResponse.setSickerName(ptxhInvResponse.getSickName());
thrInvResultResponse.setPrice(BigDecimal.valueOf(ptxhInvResponse.getPrice()));
thrInvResultResponse.setAmount(BigDecimal.valueOf(ptxhInvResponse.getCost()));
thrInvResultResponse.setDeptName(ptxhInvResponse.getDeptName());
thrInvResultResponse.setDeptCode("1002");
thrInvResultResponse.setInvName(ptxhInvResponse.getDeptName());
thrInvResultResponse.setInvCode("1000003");
thrInvResultResponse.setThrCode(ptxhInvResponse.getItemCode());
thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT);
thrInvResultResponse.setType("1");
thrInvResultResponse.setOutCount(ptxhInvResponse.getQuantity() + "");
thrInvResultResponse.setReCount(ptxhInvResponse.getQuantity() + "");
thrInvResultResponses.add(thrInvResultResponse);
if (seenNames.add(ptxhInvResponse.getItemCode())) {
itemData.add(ptxhInvResponse);
}
}
}
for (InvProjectResultEntity invProjectResultEntity : itemData) {
if (!basicSkProjectMapper.exists(new QueryWrapper<BasicSkProjectEntity>().eq("code", invProjectResultEntity.getItemCode()))) {
BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity();
basicSkProjectEntity.setCode(invProjectResultEntity.getItemCode());
basicSkProjectEntity.setName(invProjectResultEntity.getItemName());
basicSkProjectEntity.setType(2);
basicSkProjectEntity.setCreateTime(new Date());
basicSkProjectEntity.setUpdateTime(new Date());
basicSkProjectEntity.setRemark("出入库明细自动生成");
basicSkProjectEntity.setId(IdUtil.getSnowflakeNextId());
basicSkProjectMapper.insert(basicSkProjectEntity);
List<ThrProductsEntity> thrProductsEntitys = thrProductsDao.selectList(new QueryWrapper<ThrProductsEntity>().eq("prcitmcode", invProjectResultEntity.getItemCode()));
if (CollUtil.isNotEmpty(thrProductsEntitys)) {
for (ThrProductsEntity thrProductsEntity : thrProductsEntitys) {
CompanyProductRelevanceRequest companyProductRelevanceRequest = new CompanyProductRelevanceRequest();
companyProductRelevanceRequest.setThirdId(thrProductsEntity.getCode());
List<UdiRlSupResponse> udiRlSupResponses = udiRlSupDao.filterUdiGp(companyProductRelevanceRequest);
if (CollUtil.isNotEmpty(udiRlSupResponses)) {
UdiRlSupResponse udiRlSupResponse = udiRlSupResponses.get(0);
BasicSkProjectDetailEntity basicSkProjectDetailEntity = new BasicSkProjectDetailEntity();
basicSkProjectDetailEntity.setId(IdUtil.getSnowflakeNextId());
basicSkProjectDetailEntity.setRelId(udiRlSupResponse.getRlId());
basicSkProjectDetailEntity.setSupId(udiRlSupResponse.getCustomerId());
basicSkProjectDetailEntity.setPId(basicSkProjectEntity.getId());
basicSkProjectDetailEntity.setThrCode(thrProductsEntity.getCode());
basicSkProjectDetailEntity.setThrName(thrProductsEntity.getName());
basicSkProjectDetailEntity.setCreateTime(DateUtil.formatDateTime(new Date()));
basicSkProjectDetailEntity.setCreateUser("1");
basicSkProjectDetailEntity.setUpdateTime(DateUtil.formatDateTime(new Date()));
basicSkProjectDetailEntity.setUpdateUser("1");
basicSkProjectDetailEntity.setRemark("出入库明细自动生成");
basicSkProjectDetailEntity.setCount(1);
basicDestinyRelMapper.insert(basicSkProjectDetailEntity);
}
}
}
}
}
PageSimpleResponse<ThrInvResultResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(thrInvResultResponses.size() + 0l);
pageSimpleResponse.setList(thrInvResultResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
return baseResponse;
}
@Override
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
return null;
}
@Override
public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) {
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) {
return null;
}
@Override
public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) {
return null;
}
@Override
public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
ctqyyRequest.setMsgHeader(getMsgHeader("addSupplierDict"));
ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsAddUnitRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRODUCT_SUBMIT_URL), ctqyyRequest);
response = parserResult(response);
try {
log.error("提交往来单位/生产厂家:" + ctqyyRequest.getMsgBody());
CtBaseResponse baseResponse = JSONObject.parseObject(response, CtBaseResponse.class);
if (baseResponse.getCode() != 20000) {
String errMsg = "提交往来单位/生产厂家,异常:{}" + response;
log.error(errMsg);
return ResultVOUtils.error(500, "提交往来单位/生产厂家失败!");
} else {
BasicCorpEntity basicCorpEntity = new BasicCorpEntity();
basicCorpEntity.setErpId(CustomUtil.getUnitId());
basicCorpEntity.setName(udiwmsAddUnitRequest.getSupplierName());
basicCorpEntity.setCorpType(2);
basicCorpEntity.setThirdId(baseResponse.getSupplierCode());
basicCorpDao.insert(basicCorpEntity);
log.error("提交往来单位/生产厂家,成功:{}", response);
return ResultVOUtils.success(baseResponse.getMaterialNo());
}
} catch (Exception e) {
String errMsg = "提交往来单位/生产厂家,异常:{}" + response;
log.error(errMsg);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, errMsg);
}
}
@Override
public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) {
return null;
}
@Override
public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) {
return null;
}
@Override
public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) {
return null;
}
@Override
public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) {
return null;
}
/**
* 封装单据详情参数
*
* @param ioCodeEntities 单据码明细
* @param orderDetailRequests 单据详情参数
* @param detailBizEntities 单据业务详情
*/
private String setOrderDetailList(List<IoCodeEntity> ioCodeEntities, List<UdiwmsOrderDetailRequest> orderDetailRequests, List<IoOrderDetailBizEntity> detailBizEntities) {
String errMsg = "";
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 = buildProductInfo(detailBizEntity);
if (item != null) {
//封装条码信息
submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item);
orderDetailRequests.add(item);
} else {
errMsg = detailBizEntity.getCoName() + "," + "第三方产品编码未关联";
}
}
}
return errMsg;
}
@Resource
private ThrProductsDao thrProductsDao;
public UdiwmsOrderDetailRequest buildProductInfo(IoOrderDetailBizEntity detailBizEntity) {
//查询产品信息
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(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getProductDate()) ? null : "20" + detailBizEntity.getProductDate()));
item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "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) {
log.error("第三方产品编码未关联");
return null;
}
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(thrProductsEntity.getMeasname()); //计量单位
item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号
if (StrUtil.isNotEmpty(item.getManufactory())) {
ThrCorpEntity thrCorpEntity = thrCorpService.getThrCorpByName(item.getManufactory());
if (thrCorpEntity != null)
item.setManufactoryCode(thrCorpEntity.getUnitId());
}
item.setSupCode(thrProductsEntity.getSupCode());
item.setCplb(thrProductsEntity.getFlbm());
item.setHslb(thrProductsEntity.getCplb());
item.setCount(detailBizEntity.getCount());
return item;
}
/**
* 处理提交单据,记录日志,解析结果逻辑
*
* @param orderEntity
* @param zaZyRequest
* @return
*/
private BaseResponse submitOrder(IoOrderEntity orderEntity, ZzzyyRequest zaZyRequest) {
//记录日志
IoOrderUploadLogEntity uploadLog = new IoOrderUploadLogEntity();
uploadLog.setBillDate(orderEntity.getCreateTime());
uploadLog.setBillType(orderEntity.getAction());
uploadLog.setSubmitTime(new Date());
uploadLog.setBillNo(orderEntity.getBillNo());
uploadLog.setFromType(Constants.THIRD_ORDER_UPLOAD);
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest);
response = parserResult(response);
if (StrUtil.isNotBlank(response)) {
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
if (baseResponse.getCode() == 20000) {
String thirdBillNo = String.valueOf(baseResponse.getData());
orderEntity.setThirdBillNo(thirdBillNo);
orderEntity.setExportStatus(1); //提交成功
uploadLog.setStatus(2);
uploadLog.setThrBillNo(thirdBillNo);
uploadLog.setResult("提交成功");
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return ResultVOUtils.success("提交成功");
}
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage());
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return baseResponse;
} catch (Exception e) {
log.error("解析提交到智业单据返回结果异常,结果信息:{}", response);
log.error("异常信息:{}", e);
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + response);
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return ResultVOUtils.error(500, "提交失败");
}
} else {
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,调用接口返回为空");
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return ResultVOUtils.error(500, "提交失败");
}
}
@Override
public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) {
ZzzyyRequest zaZyRequest = new ZzzyyRequest();
zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight"));
zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest));
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRE_IN_ORDER_SUBMIT_URL), zaZyRequest);
response = parserResult(response);
try {
BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
return baseResponse;
} catch (Exception e) {
log.error("解析云霄妇幼医院智业接口提交单据返回数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
}
/**
* 转换提交单据参数
*
* @param udiwmsOrderRequest
* @param orderEntity
* @return
*/
public UdiwmsPreInOrderRequest submitPreInOrderToThirdSys(ZaxzyyOrderRequest udiwmsOrderRequest, IoOrderEntity orderEntity) {
UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = new UdiwmsPreInOrderRequest();
if (udiwmsOrderRequest != null) {
BeanUtils.copyProperties(udiwmsOrderRequest, udiwmsPreInOrderRequest);
udiwmsPreInOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode());
udiwmsPreInOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName());
String deptCode = "70";
if (StrUtil.isNotEmpty(orderEntity.getOriginUllageSupNo())) {
IoOrderEntity temp = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().eq("billNo", orderEntity.getOriginUllageSupNo()).last("limit 1"));
if (temp != null && StrUtil.isNotEmpty(temp.getFromInvCode())) {
AuthWarehouseEntity authWarehouseEntity =
authWarehouseDao.selectOne(new QueryWrapper<AuthWarehouseEntity>().eq("code", temp.getFromInvCode()).last("limit 1"));
deptCode = authWarehouseEntity.getThirdId();
}
}
udiwmsPreInOrderRequest.setDeptCode(deptCode);
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);
if (StrUtil.isNotEmpty(itemDTO.getManufactory())) {
ThrCorpEntity thrCorpEntity = thrCorpService.getThrCorpByName(itemDTO.getManufactory());
if (thrCorpEntity != null)
itemDTO.setManufactoryCode(thrCorpEntity.getUnitId());
}
String code = codeDetaiEntity.getCode();
if (code.contains("\u001D")) {
// code = code.replace("\u001D", "zysoft"); 智业无法识别GS1符号
code = code.replace("\u001D", "");
}
itemDTO.setCode(code);
itemDTO.setNameCode(codeDetaiEntity.getNameCode());
if (IntUtil.value(codeDetaiEntity.getCount()) > 1) {
for (int i = 0; i < codeDetaiEntity.getCount(); i++) {
itemDTO.setCount(1);
itemDTOS.add(itemDTO);
}
} else {
itemDTO.setCount(codeDetaiEntity.getCount());
itemDTOS.add(itemDTO);
}
}
}
}
}
udiwmsPreInOrderRequest.setItems(itemDTOS);
}
return udiwmsPreInOrderRequest;
}
/**
* ------------------------------------------现场管理医保相关接口方法--------------------------------------------------------------
*/
/**
* 处方拉取视图
*
* @param udiwmsBasicSkPrescribeRequest
* @return
*/
@Override
public BaseResponse getPrescribes(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest) {
if (IntUtil.value(udiwmsBasicSkPrescribeRequest.getInOutType()) == 0) {
LambdaQueryWrapper<VInsurNationGoodsPhysic> wrapper = new LambdaQueryWrapper<>();
String startTime = udiwmsBasicSkPrescribeRequest.getStartTime();
String endTime = udiwmsBasicSkPrescribeRequest.getEndTime();
wrapper.ge(StrUtil.isNotEmpty(startTime), VInsurNationGoodsPhysic::getSEL_RETN_TIME, startTime);
wrapper.le(StrUtil.isNotEmpty(endTime), VInsurNationGoodsPhysic::getSEL_RETN_TIME, endTime);
String code = udiwmsBasicSkPrescribeRequest.getCode();
String fromCorpName = udiwmsBasicSkPrescribeRequest.getFromCorpName();
String key = udiwmsBasicSkPrescribeRequest.getKey();
wrapper.and(StrUtil.isNotEmpty(code), t -> t.eq(VInsurNationGoodsPhysic::getSTOOUT_NO, code).or().eq(VInsurNationGoodsPhysic::getRXNO, code));
wrapper.and(StrUtil.isNotEmpty(key), t -> t.like(VInsurNationGoodsPhysic::getSTOOUT_NO, key)
.or().like(VInsurNationGoodsPhysic::getRXNO, key)
.or().like(VInsurNationGoodsPhysic::getPSN_NAME, key)
.or().like(VInsurNationGoodsPhysic::getPSN_NO, key)
);
wrapper.and(StrUtil.isNotEmpty(fromCorpName), t -> t.eq(VInsurNationGoodsPhysic::getPSN_NAME, fromCorpName));
// 拉取处方时改成拉取v_ypzs_pres_info
IPage<VYpzsPresInfo> page = vYpzsPresInfoMapper.selectGroupedWithPagination(new Page<VYpzsPresInfo>(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()),
udiwmsBasicSkPrescribeRequest);
return this.covertSellOrder(udiwmsBasicSkPrescribeRequest, page);
} else {
LambdaQueryWrapper<VInsurNationGoodsReturn> wrapper = new LambdaQueryWrapper<>();
String startTime = udiwmsBasicSkPrescribeRequest.getStartTime();
String endTime = udiwmsBasicSkPrescribeRequest.getEndTime();
wrapper.ge(StrUtil.isNotEmpty(startTime), VInsurNationGoodsReturn::getSEL_RETN_TIME, startTime);
wrapper.le(StrUtil.isNotEmpty(endTime), VInsurNationGoodsReturn::getSEL_RETN_TIME, endTime);
String code = udiwmsBasicSkPrescribeRequest.getCode();
String fromCorpName = udiwmsBasicSkPrescribeRequest.getFromCorpName();
String key = udiwmsBasicSkPrescribeRequest.getKey();
wrapper.and(StrUtil.isNotEmpty(key), t -> t.like(VInsurNationGoodsReturn::getAPPLY_NO, key)
.or().like(VInsurNationGoodsReturn::getPSN_NAME, key)
.or().like(VInsurNationGoodsReturn::getPSN_NO, key)
);
wrapper.and(StrUtil.isNotEmpty(code), t -> t.eq(VInsurNationGoodsReturn::getAPPLY_NO, code));
wrapper.and(StrUtil.isNotEmpty(fromCorpName), t -> t.eq(VInsurNationGoodsReturn::getPSN_NAME, fromCorpName));
//拉取处方退货时改成拉取v_ypzs_pres_info_return
IPage<VYpzsPresInfoReturn> page = vYpzsPresInfoReturnMapper.selectGroupedWithPagination(new Page<VYpzsPresInfoReturn>(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()),
udiwmsBasicSkPrescribeRequest);
return this.covertReturnOrder(udiwmsBasicSkPrescribeRequest, page);
}
}
/**
* 采购计划拉取视图
*
* @param udiwmsThrOrderRequest
* @return
*/
@Override
public BaseResponse getThrOrders(UdiwmsThrOrderRequest udiwmsThrOrderRequest) {
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
if (BusTypeConstant.CGJH001.getBusType().equals(udiwmsThrOrderRequest.getBusType())) {
LambdaQueryWrapper<VYpzsPlanInfo> wrapper = new LambdaQueryWrapper<>();
// String startTime = udiwmsThrOrderRequest.getStartTime();
// String endTime = udiwmsThrOrderRequest.getEndTime();
// wrapper.ge(StrUtil.isNotEmpty(startTime),VYpzsPlanInfo::getKEEP_BOOK_TIME,startTime+" 00:00:00");
// wrapper.le(StrUtil.isNotEmpty(endTime),VYpzsPlanInfo::getKEEP_BOOK_TIME,endTime+" 23:59:59");
wrapper.eq(StrUtil.isNotBlank(udiwmsThrOrderRequest.getBillNo()), VYpzsPlanInfo::getCGDBH, udiwmsThrOrderRequest.getBillNo());
//关键字模糊处理
String keywords = udiwmsThrOrderRequest.getKeyWords();
wrapper.and(StrUtil.isNotEmpty(keywords), t -> t.like(VYpzsPlanInfo::getCGDBH, keywords)//单据号
);
wrapper.like(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getFromCorpName()), VYpzsPlanInfo::getSCQYMC, udiwmsThrOrderRequest.getFromCorpName());
Page<VYpzsPlanInfo> page = vYpzsPlanInfoMapper.selectGroupedWithPagination(new Page<VYpzsPlanInfo>(udiwmsThrOrderRequest.getPage(), udiwmsThrOrderRequest.getLimit()), udiwmsThrOrderRequest);
List<VYpzsPlanInfo> planInfos = page.getRecords();
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
if (CollUtil.isNotEmpty(planInfos)) {
List<String> collect = planInfos.stream().map(VYpzsPlanInfo::getCGDBH).collect(Collectors.toList());
LambdaQueryWrapper<VYpzsPlanInfo> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VYpzsPlanInfo::getCGDBH, collect);
List<VYpzsPlanInfo> vYpzsPlanInfos = vYpzsPlanInfoMapper.selectList(wrapper1);
Map<String, List<VYpzsPlanInfo>> groupedByBz = vYpzsPlanInfos.stream()
.collect(Collectors.groupingBy(VYpzsPlanInfo::getCGDBH));
groupedByBz.forEach((key, value) -> {
VYpzsPlanInfo planInfo = value.get(0);
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(planInfo.getCGDBH());
// ioCollectOrder.setBilldate(planInfo.());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setBillTime(new Date());
ioCollectOrder.setFromCorp(planInfo.getSCQYBM());
ioCollectOrder.setFromCorpName(planInfo.getSCQYMC());
ioCollectOrder.setBusType(udiwmsThrOrderRequest.getBusType());
ioCollectOrder.setWorkPlaceCode(udiwmsThrOrderRequest.getWorkPlaceCode());
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setUpdateTime(new Date());
ioCollectOrder.setSplitStatus(0);
ioCollectOrder.setTagStatus(0);
List<IoCollectOrderBiz> bizList = new ArrayList<>();
value.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getYPBM()));
if (basicUdirelEntity != null) {
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getYPMC()).append("字典未对照").append(";");
}
collectOrderBiz.setThrCode(entity.getYPBM());
collectOrderBiz.setCpmctymc(entity.getYPMC());
collectOrderBiz.setBatchNo(entity.getYPBM());
collectOrderBiz.setGgxh(entity.getGGMC());
collectOrderBiz.setCount(entity.getGMSL());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
collectOrderBiz.setMeasureUnit(entity.getBZDW());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
ioCollectOrder.setBizList(bizList);
ioCollectOrders.add(ioCollectOrder);
});
}
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
} else {
LambdaQueryWrapper<VYpzsIoInfo> wrapper = new LambdaQueryWrapper<>();
String startTime = udiwmsThrOrderRequest.getStartTime();
String endTime = udiwmsThrOrderRequest.getEndTime();
wrapper.ge(StrUtil.isNotEmpty(startTime), VYpzsIoInfo::getKEEP_BOOK_TIME, startTime);
wrapper.le(StrUtil.isNotEmpty(endTime), VYpzsIoInfo::getKEEP_BOOK_TIME, endTime);
wrapper.and(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getCorpName()), t -> t.like(VYpzsIoInfo::getCONSIGNEE_NAME, udiwmsThrOrderRequest.getCorpName()).or().eq(VYpzsIoInfo::getCONSIGNOR_NAME, udiwmsThrOrderRequest.getCorpName()));
wrapper.eq(StrUtil.isNotBlank(udiwmsThrOrderRequest.getBillNo()), VYpzsIoInfo::getPHYSIC_CODE, udiwmsThrOrderRequest.getBillNo());
wrapper.eq(StrUtil.isNotBlank(udiwmsThrOrderRequest.getBusType()), VYpzsIoInfo::getIO_SORT, udiwmsThrOrderRequest.getBusType());
wrapper.like(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getFromCorpName()), VYpzsIoInfo::getCONSIGNEE_NAME, udiwmsThrOrderRequest.getFromCorpName());
wrapper.like(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getShipperName()), VYpzsIoInfo::getCONSIGNOR_NAME, udiwmsThrOrderRequest.getShipperName());
//关键字模糊处理
String keywords = udiwmsThrOrderRequest.getKeyWords();
wrapper.and(StrUtil.isNotEmpty(keywords), t -> t.like(VYpzsIoInfo::getPHYSIC_CODE, keywords)//单据号
.or().like(VYpzsIoInfo::getCONSIGNOR_NAME, keywords)//发货方
.or().like(VYpzsIoInfo::getCONSIGNEE_NAME, keywords)//收货方
.or().like(VYpzsIoInfo::getKEEP_BOOK_TIME, keywords)//收货方
.or().like(VYpzsIoInfo::getIO_SORT, keywords)//收货方
);
Page<VYpzsIoInfo> page = vYpzsIoInfoMapper.selectGroupedWithPagination(new Page<VYpzsIoInfo>(udiwmsThrOrderRequest.getPage(), udiwmsThrOrderRequest.getLimit()), udiwmsThrOrderRequest);
List<VYpzsIoInfo> ioInfos = page.getRecords();
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
if (CollUtil.isNotEmpty(ioInfos)) {
List<String> collect = ioInfos.stream().map(VYpzsIoInfo::getRECEIPT_NUMBER).collect(Collectors.toList());
LambdaQueryWrapper<VYpzsIoInfo> vYpzsIoInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
vYpzsIoInfoLambdaQueryWrapper.in(VYpzsIoInfo::getRECEIPT_NUMBER, collect);
List<VYpzsIoInfo> vYpzsIoInfos = vYpzsIoInfoMapper.selectList(vYpzsIoInfoLambdaQueryWrapper);
Map<String, List<VYpzsIoInfo>> groupedByPhysicCode = vYpzsIoInfos.stream()
.collect(Collectors.groupingBy(VYpzsIoInfo::getRECEIPT_NUMBER));
groupedByPhysicCode.forEach((key, value) -> {
VYpzsIoInfo info = value.get(0);
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(info.getRECEIPT_NUMBER());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setBillTime(DateUtil.parseDate(info.getKEEP_BOOK_TIME()));
ioCollectOrder.setFromCorp(info.getCONSIGNEE());
ioCollectOrder.setFromCorpName(info.getCONSIGNEE_NAME());
ioCollectOrder.setShipper(info.getCONSIGNOR());
ioCollectOrder.setShipperName(info.getCONSIGNOR_NAME());
ioCollectOrder.setBusType(udiwmsThrOrderRequest.getBusType());
ioCollectOrder.setWorkPlaceCode(udiwmsThrOrderRequest.getWorkPlaceCode());
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setUpdateTime(new Date());
ioCollectOrder.setSplitStatus(0);
ioCollectOrder.setTagStatus(0);
List<IoCollectOrderBiz> bizList = new ArrayList<>();
value.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getPHYSIC_CODE()).last("limit 1"));
if (basicUdirelEntity != null) {
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getPHYSIC_NAME()).append("字典未对照").append(";");
}
collectOrderBiz.setThrCode(entity.getPHYSIC_CODE());
collectOrderBiz.setCpmctymc(entity.getPHYSIC_NAME());
collectOrderBiz.setBatchNo(entity.getBATCH_NO());
collectOrderBiz.setCount(entity.getQUANTITY());
collectOrderBiz.setYbbm(entity.getCOUNTRY_CODE());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
collectOrderBiz.setMeasureUnit(entity.getPACK_UNIT1());
collectOrderBiz.setGgxh(entity.getPACK_SPEC() + ":" + entity.getPHYSIC_UNIT());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
collectOrderBiz.setRemark1(entity.getRETAIL_PRICE().toString());
collectOrderBiz.setRemark2(entity.getRETAIL_MONEY().toString());
collectOrderBiz.setRemark3(entity.getIMPORT_PRICE().toString());
collectOrderBiz.setRemark4(entity.getIMPORT_MONEY().toString());
collectOrderBiz.setRemark5(entity.getFIXMEDINS_BCHNO());
collectOrderBiz.setRemark6(entity.getRX_FLAG());
collectOrderBiz.setRemark7(entity.getINV_CHG_TYPE());
bizList.add(collectOrderBiz);
});
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(bizList);
ioCollectOrders.add(ioCollectOrder);
});
}
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
}
return ResultVOUtils.success(pageSimpleResponse);
}
/**
* 业务单据上传医保
*
* @param postCollectOrderRequest
* @return
*/
@Override
public BaseResponse uploadCollectOrder(PostCollectOrderRequest postCollectOrderRequest) {
List<IoCollectOrder> collectOrderList = postCollectOrderRequest.getCollectOrderList();
if (CollUtil.isNotEmpty(collectOrderList)) {
for (IoCollectOrder ioCollectOrder : collectOrderList) {
String busType = ioCollectOrder.getBusType();
if (matchBusType(busType, buyType_3501)) {
optionUploadCollectOrder3501(ioCollectOrder);
} else if (matchBusType(busType, buyType_3502)) {
optionUploadCollectOrder3502(ioCollectOrder);
} else if (matchBusType(busType, buyType_3505)) {
optionUploadCollectOrder3505(ioCollectOrder);
} else if (matchBusType(busType, buyType_3506)) {
optionUploadCollectOrder3506(ioCollectOrder);
} else {
return ResultVOUtils.error(500, "业务类型未找到对应上传接口");
}
}
}
return ResultVOUtils.success();
}
// 辅助方法用于检查busType是否存在于指定的buyType数组中
private static boolean matchBusType(String busType, String[] buyTypes) {
for (String buyType : buyTypes) {
if (busType.equals(buyType)) {
return true; // 如果找到匹配项则返回true
}
}
return false; // 如果没有找到匹配项则返回false
}
/**
* 单据
*
* @param udiwmsBasicSkPrescribeRequest
* @return
*/
private BaseResponse covertSellOrder(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage<VYpzsPresInfo> page) {
List<VYpzsPresInfo> presInfoEntities = page.getRecords();
List<VYpzsPresInfo> vInsurNationGoodsPhysics = new ArrayList<>();
if (CollUtil.isNotEmpty(presInfoEntities)) {
List<String> collect = presInfoEntities.stream().map(VYpzsPresInfo::getPRESCRIBE_NUMBER).collect(Collectors.toList());
LambdaQueryWrapper<VYpzsPresInfo> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VYpzsPresInfo::getPRESCRIBE_NUMBER, collect);
vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper1);
}
// TODO: 2024/9/19 这边在转换的时候就不能用VInsurNationGoodsPhysic
if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) {
Map<String, List<VYpzsPresInfo>> groupedByPrescribeNumber = vInsurNationGoodsPhysics.stream()
.collect(Collectors.groupingBy(VYpzsPresInfo::getPHYSIC_CODE));
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
groupedByPrescribeNumber.forEach((key, value) -> {
VYpzsPresInfo presInfoEntity = value.get(0);
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(presInfoEntity.getSTOOUT_NO());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setFromCorp(presInfoEntity.getSICK_ID());
ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode());
ioCollectOrder.setFromCorpName(presInfoEntity.getSICK_NAME());
Date date = DateUtil.parseDate(presInfoEntity.getLAY_TIME());
ioCollectOrder.setBillTime(date);
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
ioCollectOrder.setBackupOrderRemark1(presInfoEntity.getSTOOUT_NO());
ioCollectOrder.setBackupOrderRemark2(presInfoEntity.getSICK_ID());
// ioCollectOrder.setBackupOrderRemark3(presInfoEntity.getPSN_NAME());
// ioCollectOrder.setBackupOrderRemark4(presInfoEntity.getPSN_NO());
ioCollectOrder.setUpdateTime(new Date());
ioCollectOrder.setSplitStatus(0);
ioCollectOrder.setTagStatus(0);
List<IoCollectOrderBiz> bizList = new ArrayList<>();
value.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
List<BasicUdirelEntity> basicUdirelEntities = basicUdirelDao.selectList(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getPHYSIC_CODE()));
if (CollUtil.isNotEmpty(basicUdirelEntities)) {
BasicUdirelEntity basicUdirelEntity = basicUdirelEntities.get(0);
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getPHYSIC_NAME()).append("字典未对照").append(";");
}
// List<VYpzsPresInfo> vYpzsPresInfos = vYpzsPresInfoMapper.selectList(new LambdaQueryWrapper<VYpzsPresInfo>().eq(VYpzsPresInfo::getPRESCRIBE_NUMBER, entity.getPRESCRIBE_NUMBER()).eq(VYpzsPresInfo::getPHYSIC_CODE, entity.getPHYSIC_CODE()));
// if (CollUtil.isNotEmpty(vYpzsPresInfos)) {
// VYpzsPresInfo vYpzsPresInfo = vYpzsPresInfos.get(0);
//
// }
collectOrderBiz.setGgxh(entity.getPACK_SPEC());
collectOrderBiz.setMeasureUnit(entity.getPHYSIC_UNIT());
collectOrderBiz.setCount(IntUtil.value(entity.getLAY_PHYSIC_QUANTITY()));
collectOrderBiz.setThrCode(entity.getPHYSIC_CODE());
collectOrderBiz.setCpmctymc(entity.getPHYSIC_NAME());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
collectOrderBiz.setYbbm(entity.getCOUNTRY_CODE());
// collectOrderBiz.setRemark1(entity.get() + "");
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(bizList);
ioCollectOrders.add(ioCollectOrder);
});
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
return ResultVOUtils.success(pageSimpleResponse);
} else {
return ResultVOUtils.error(500, "下载失败!");
}
}
private BaseResponse covertReturnOrder(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage<VYpzsPresInfoReturn> page) {
List<VYpzsPresInfoReturn> presInfoEntities = page.getRecords();
List<VYpzsPresInfoReturn> vInsurNationGoodsReturns = new ArrayList<>();
if (CollUtil.isNotEmpty(presInfoEntities)) {
List<String> collect = presInfoEntities.stream().map(VYpzsPresInfoReturn::getAPPLY_NO).collect(Collectors.toList());
LambdaQueryWrapper<VYpzsPresInfoReturn> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VYpzsPresInfoReturn::getAPPLY_NO, collect);
vInsurNationGoodsReturns = vYpzsPresInfoReturnMapper.selectList(wrapper1);
}
// TODO: 2024/9/19 这边在转换的时候就不能用vInsurNationGoodsReturns
if (CollUtil.isNotEmpty(vInsurNationGoodsReturns)) {
Map<String, List<VYpzsPresInfoReturn>> groupedByPrescribeNumber = vInsurNationGoodsReturns.stream()
.collect(Collectors.groupingBy(VYpzsPresInfoReturn::getAPPLY_NO));
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
groupedByPrescribeNumber.forEach((key, value) -> {
VYpzsPresInfoReturn presInfoEntity = value.get(0);
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(presInfoEntity.getAPPLY_NO());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setFromCorp(presInfoEntity.getSICK_ID());
ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode());
ioCollectOrder.setFromCorpName(presInfoEntity.getSICK_NAME());
// Date date = DateUtil.parseDate(presInfoEntity.get());
ioCollectOrder.setBillTime(presInfoEntity.getKEEP_BOOK_TIME());
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
ioCollectOrder.setUpdateTime(new Date());
ioCollectOrder.setSplitStatus(0);
ioCollectOrder.setTagStatus(0);
List<IoCollectOrderBiz> bizList = new ArrayList<>();
value.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getPHYSIC_CODE()));
if (basicUdirelEntity != null) {
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getPHYSIC_NAME()).append("字典未对照").append(";");
}
List<VYpzsPresInfoReturn> vYpzsPresInfoReturns = vYpzsPresInfoReturnMapper.selectList(new LambdaQueryWrapper<VYpzsPresInfoReturn>().eq(VYpzsPresInfoReturn::getAPPLY_NO, entity.getAPPLY_NO()).eq(VYpzsPresInfoReturn::getPHYSIC_CODE, entity.getPHYSIC_CODE()));
if (CollUtil.isNotEmpty(vYpzsPresInfoReturns)) {
VYpzsPresInfoReturn vYpzsPresInfo = vYpzsPresInfoReturns.get(0);
collectOrderBiz.setGgxh(vYpzsPresInfo.getPHYSIC_SPEC());
collectOrderBiz.setMeasureUnit(vYpzsPresInfo.getPHYSIC_UNIT());
}
collectOrderBiz.setThrCode(entity.getPHYSIC_CODE());
collectOrderBiz.setCpmctymc(entity.getPHYSIC_NAME());
// collectOrderBiz.setBatchNo(entity.getBATCH_NUMBER());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
collectOrderBiz.setYbbm(entity.getFEE_SEQUENCE_NO());
collectOrderBiz.setCount(entity.getQUANTITY());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(bizList);
ioCollectOrders.add(ioCollectOrder);
});
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
return ResultVOUtils.success(pageSimpleResponse);
} else {
return ResultVOUtils.error(500, "下载失败!");
}
}
public void optionUploadCollectOrder3505(IoCollectOrder ioCollectOrder) {
//摆药流水号
String stoout_no = ioCollectOrder.getBackupOrderRemark1();
List<VInsurNationGoodsPhysic> vInsurNationGoodsPhysics = goodsPhysicMapper.selectList(new LambdaQueryWrapper<VInsurNationGoodsPhysic>().eq(VInsurNationGoodsPhysic::getSTOOUT_NO, stoout_no));
if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) {
List<CollectOrderBizResponse> collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList();
List<Xsck3505Request> xsck3505Requests = new ArrayList<>();
for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponseList) {
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(collectOrderBizResponse.getRelId());
String itemCode = basicUdirelEntity.getMainId();
for (VInsurNationGoodsPhysic vInsurNationGoodsPhysic : vInsurNationGoodsPhysics) {
if (vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_ID().equals(itemCode)) {
String[] codes = collectOrderBizResponse.getFinishUdiCode().split(",");
List<DrugInfoRequest> drugTraceList = new ArrayList<>();
// 遍历fruits数组
for (String code : codes) {
if (StrUtil.isNotBlank(code)) {
List<RelCodeDetail> relCodeDetailList = relCodeDetailService.getAllNext(code);
if (relCodeDetailList != null && relCodeDetailList.size() > 0) {
DrugInfoRequest request = new DrugInfoRequest();
request.setDrug_trac_codg(code);
drugTraceList.add(request);
}
}
}
Xsck3505Request xsck3505Request = Xsck3505Request.builder()
.med_list_codg(vInsurNationGoodsPhysic.getMED_LIST_CODG())
.fixmedins_hilist_id(vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_ID())
.fixmedins_hilist_name(vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_NAME())
.fixmedins_bchno(vInsurNationGoodsPhysic.getFIXMEDINS_BCHNO())
.prsc_dr_cert_type(vInsurNationGoodsPhysic.getPRSC_DR_CERT_TYPE())
.prsc_dr_certno(vInsurNationGoodsPhysic.getPRSC_DR_CERTNO())
.prsc_dr_name(vInsurNationGoodsPhysic.getPRSC_DR_NAME())
.phar_cert_type(vInsurNationGoodsPhysic.getPHAR_CERT_TYPE())
.phar_certno(vInsurNationGoodsPhysic.getPHAR_CERTNO())
.phar_name(vInsurNationGoodsPhysic.getPHAR_NAME())
.phar_prac_cert_no(vInsurNationGoodsPhysic.getPHAR_PRAC_CERT_NO())
.hi_feesetl_type(vInsurNationGoodsPhysic.getHI_FEESETL_TYPE())
.setl_id(vInsurNationGoodsPhysic.getSETL_ID())
.mdtrt_sn(vInsurNationGoodsPhysic.getMDTRT_SN())
.psn_no(vInsurNationGoodsPhysic.getPSN_NO())
.psn_cert_type(vInsurNationGoodsPhysic.getPSN_CERT_TYPE())
.certno(vInsurNationGoodsPhysic.getCERTNO())
.psn_name(vInsurNationGoodsPhysic.getPSN_NAME())
.manu_lotnum(vInsurNationGoodsPhysic.getMANU_LOTNUM())
.manu_date(vInsurNationGoodsPhysic.getMANU_DATE())
.expy_end(vInsurNationGoodsPhysic.getEXPY_END())
.rx_flag(vInsurNationGoodsPhysic.getRX_FLAG())
.trdn_flag(vInsurNationGoodsPhysic.getTRDN_FLAG())
.finl_trns_pric(vInsurNationGoodsPhysic.getFINL_TRNS_PRIC())
.rxno(vInsurNationGoodsPhysic.getRXNO())
.rx_circ_flag(vInsurNationGoodsPhysic.getRX_CIRC_FLAG())
.rtal_docno(vInsurNationGoodsPhysic.getRTAL_DOCNO())
.stoout_no(vInsurNationGoodsPhysic.getSTOOUT_NO())
.bchno(vInsurNationGoodsPhysic.getBCHNO())
.drug_prod_barc(vInsurNationGoodsPhysic.getRUG_PROD_BARC())
.shelf_posi(vInsurNationGoodsPhysic.getSHELF_POSI())
.sel_retn_cnt(vInsurNationGoodsPhysic.getSEL_RETN_CNT())
.sel_retn_time(vInsurNationGoodsPhysic.getSEL_RETN_TIME())
.sel_retn_opter_name(vInsurNationGoodsPhysic.getSEL_RETN_OPTER_NAME())
.memo(vInsurNationGoodsPhysic.getMEMO())
.mdtrt_setl_type(vInsurNationGoodsPhysic.getMDTRT_SETL_TYPE())
.drugtracinfo(drugTraceList).build();
xsck3505Requests.add(xsck3505Request);
}
}
}
BaseXsck3505Request baseXsck3505Request = new BaseXsck3505Request();
baseXsck3505Request.setSelinfoDetail(xsck3505Requests);
String jsonStr = JSONUtil.toJsonStr(baseXsck3505Request);
JSONObject dataJson = JSONObject.parseObject(jsonStr);
ybClient.ybPost("3505A", dataJson);
}
}
public void optionUploadCollectOrder3501(IoCollectOrder ioCollectOrder) {
List<IoCollectOrderBiz> bizList = ioCollectOrder.getBizList();
if (CollUtil.isNotEmpty(bizList)) {
List<CollectOrderBizResponse> collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList();
List<Pcsc3501Request> pcsc3501Requests = new ArrayList<>();
for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponseList) {
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(collectOrderBizResponse.getRelId());
String itemCode = basicUdirelEntity.getMainId();
for (IoCollectOrderBiz item : bizList) {
if (item.getNameCode().equals(itemCode)) {
String[] codes = collectOrderBizResponse.getFinishUdiCode().split(",");
List<DrugInfoRequest> drugTraceList = new ArrayList<>();
// 遍历fruits数组
for (String code : codes) {
if (StrUtil.isNotBlank(code)) {
List<RelCodeDetail> relCodeDetailList = relCodeDetailService.getAllNext(code);
if (relCodeDetailList != null && relCodeDetailList.size() > 0) {
DrugInfoRequest request = new DrugInfoRequest();
request.setDrug_trac_codg(code);
drugTraceList.add(request);
}
}
}
// TODO: 2024/9/10 字段未完全正确对应
Pcsc3501Request pcsc3501Request = Pcsc3501Request.builder()
.med_list_codg(item.getYbbm())
.fixmedins_hilist_id(item.getThrCode())
.fixmedins_hilist_name(item.getCpmctymc())
.fixmedins_bchno(item.getRemark5())
.rx_flag(item.getRemark6())
.invdate(item.getUpdateTime())
.inv_cnt(item.getActCount())
.manu_lotnum(item.getBatchNo())
.manu_date(item.getProductDate())
.expy_end(item.getExpireDate())
.memo(item.getRemark())
.drugtracinfo(drugTraceList).build();
pcsc3501Requests.add(pcsc3501Request);
}
}
}
BasePcsc3501Request basePcsc3501Request = new BasePcsc3501Request();
basePcsc3501Request.setSelinfoDetail(pcsc3501Requests);
String jsonStr = JSONUtil.toJsonStr(basePcsc3501Request);
JSONObject dataJson = JSONObject.parseObject(jsonStr);
ybClient.ybPost("3501A", dataJson);
}
}
public void optionUploadCollectOrder3502(IoCollectOrder ioCollectOrder) {
List<IoCollectOrderBiz> bizList = ioCollectOrder.getBizList();
if (CollUtil.isNotEmpty(bizList)) {
List<CollectOrderBizResponse> collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList();
List<Kcbg3502Request> kcbg3502Requests = new ArrayList<>();
for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponseList) {
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(collectOrderBizResponse.getRelId());
String itemCode = basicUdirelEntity.getMainId();
for (IoCollectOrderBiz item : bizList) {
if (item.getNameCode().equals(itemCode)) {
String[] codes = collectOrderBizResponse.getFinishUdiCode().split(",");
List<DrugInfoRequest> drugTraceList = new ArrayList<>();
// 遍历fruits数组
for (String code : codes) {
if (StrUtil.isNotBlank(code)) {
List<RelCodeDetail> relCodeDetailList = relCodeDetailService.getAllNext(code);
if (relCodeDetailList != null && relCodeDetailList.size() > 0) {
DrugInfoRequest request = new DrugInfoRequest();
request.setDrug_trac_codg(code);
drugTraceList.add(request);
}
}
}
// TODO: 2024/9/10 字段未完全正确对应
Kcbg3502Request kcbg3502Request = Kcbg3502Request.builder()
.med_list_codg(item.getYbbm())
.inv_chg_type(item.getRemark7())
.fixmedins_hilist_id(item.getThrCode())
.fixmedins_hilist_name(item.getCpmctymc())
.fixmedins_bchno(item.getRemark5())
.pric(item.getRemark1())
.cnt(item.getActCount())
.rx_flag(item.getRemark6())
.inv_chg_time(item.getUpdateTime())
.inv_chg_opter_name(ioCollectOrder.getCreateUser())
.memo(item.getRemark())
.trdn_flag("0")
.drugtracinfo(drugTraceList).build();
kcbg3502Requests.add(kcbg3502Request);
}
}
}
BaseKcbg3502Request baseKcbg3502Request = new BaseKcbg3502Request();
baseKcbg3502Request.setInvinfoDetail(kcbg3502Requests);
String jsonStr = JSONUtil.toJsonStr(baseKcbg3502Request);
JSONObject dataJson = JSONObject.parseObject(jsonStr);
ybClient.ybPost("3502A", dataJson);
}
}
public void optionUploadCollectOrder3506(IoCollectOrder ioCollectOrder) {
// List<IoCollectOrderBiz> bizList = ioCollectOrder.getBizList();
List<CollectOrderBizResponse> collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList();
List<Xsth3506Request> xsth3506Requests = new ArrayList<>();
List<VInsurNationGoodsReturn> vInsurNationGoodsReturns = vInsurNationGoodsReturnMapper.selectList(new LambdaQueryWrapper<VInsurNationGoodsReturn>().eq(VInsurNationGoodsReturn::getAPPLY_NO, ioCollectOrder.getBillNo()));
if (CollUtil.isEmpty(vInsurNationGoodsReturns)) {
log.error("申请单号{}不存在", ioCollectOrder.getBillNo());
return;
}
for (CollectOrderBizResponse item : collectOrderBizResponseList) {
BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(item.getRelId());
String itemCode = basicUdirelEntity.getMainId();
for (VInsurNationGoodsReturn vInsurNationGoodsPhysic : vInsurNationGoodsReturns) {
if (vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_ID().equals(itemCode)) {
String[] codes = item.getFinishUdiCode().split(",");
List<DrugInfoRequest> drugTraceList = new ArrayList<>();
// 遍历fruits数组
for (String code : codes) {
if (StrUtil.isNotBlank(code)) {
List<RelCodeDetail> relCodeDetailList = relCodeDetailService.getAllNext(code);
if (relCodeDetailList != null && relCodeDetailList.size() > 0) {
DrugInfoRequest request = new DrugInfoRequest();
request.setDrug_trac_codg(code);
drugTraceList.add(request);
}
}
}
// TODO: 2024/9/10 字段未完全正确对应
Xsth3506Request xsth3506Request = Xsth3506Request.builder()
.med_list_codg(item.getYbbm())
.fixmedins_hilist_id(item.getThrCode())
.fixmedins_hilist_name(item.getCpmctymc())
.fixmedins_bchno(vInsurNationGoodsPhysic.getFIXMEDINS_BCHNO())
.setl_id(vInsurNationGoodsPhysic.getSETL_ID())
.psn_no(vInsurNationGoodsPhysic.getPSN_NO())
.psn_cert_type(vInsurNationGoodsPhysic.getPSN_CERT_TYPE())
.certno(vInsurNationGoodsPhysic.getCERTNO())
.psn_name(vInsurNationGoodsPhysic.getPSN_NAME())
.manu_lotnum(vInsurNationGoodsPhysic.getMANU_LOTNUM())
.manu_date(vInsurNationGoodsPhysic.getMANU_DATE())
.expy_end(vInsurNationGoodsPhysic.getEXPY_END())
.rx_flag(vInsurNationGoodsPhysic.getRX_FLAG())
.trdn_flag(vInsurNationGoodsPhysic.getTRDN_FLAG())
.finl_trns_pric(vInsurNationGoodsPhysic.getFINL_TRNS_PRIC())
.sel_retn_cnt(vInsurNationGoodsPhysic.getSEL_RETN_CNT())
.sel_retn_time(vInsurNationGoodsPhysic.getSEL_RETN_TIME())
.sel_retn_opter_name(vInsurNationGoodsPhysic.getSEL_RETN_OPTER_NAME())
.memo(item.getRemark())
.medins_prod_sel_no(vInsurNationGoodsPhysic.getMEDINS_PROL_SEL_NO())
.mdtrt_sn(vInsurNationGoodsPhysic.getMDTRT_SN())
.drugtracinfo(drugTraceList).build();
xsth3506Requests.add(xsth3506Request);
}
}
}
BaseXsth3506Request baseXsth3506Request = new BaseXsth3506Request();
baseXsth3506Request.setSelinfoDetail(xsth3506Requests);
String jsonStr = JSONUtil.toJsonStr(baseXsth3506Request);
JSONObject dataJson = JSONObject.parseObject(jsonStr);
ybClient.ybPost("3506A", dataJson);
}
/**
* 获取交易类型集合
*
* @return
*/
public BaseResponse getBuyType() {
Map<String,String[]> buyTypeMap= new HashMap<>();
buyTypeMap.put("buyType_3501",buyType_3501);
buyTypeMap.put("buyType_3502",buyType_3502);
buyTypeMap.put("buyType_3505",buyType_3505);
buyTypeMap.put("buyType_3506",buyType_3506);
return ResultVOUtils.success(buyTypeMap);
}
}