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/hlfyyy/HlfyyyClient.java

2439 lines
132 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.hlfyyy;
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.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.client.hlfyyy.entity.InvCodeResultEntity;
import com.glxp.mipsdl.client.hlfyyy.entity.InvProjectResultEntity;
import com.glxp.mipsdl.client.hlfyyy.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.hlfyyy.*;
import com.glxp.mipsdl.entity.inout.*;
import com.glxp.mipsdl.entity.system.ThrYbSetupMapper;
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.PageSimpleResponseNew;
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.hlfyyy.*;
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.thirddao.hlfyyy.*;
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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service(value = "100015HttpClient")
public class HlfyyyClient 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"};
@Value("${DSF_XML_SQL_TYPE:Mysql}")
private String defXmlSqlType;
@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 ThrYbSetupMapper thrYbSetupMapper;
@Resource
private RelCodeDetailService relCodeDetailService;
@Resource
private VA001Service va001Service;
@Resource
private VA005Service va005Service;
@Resource
private VA004Service va004Service;
@Resource
private VA011MxService va011MxService;
@Resource
private VA002Service va002Service;
@Resource
private VA011Service va011Service;
@Resource
private VA010Service va010Service;
@Resource
private VA006MxService va006MxService;
@Resource
private VA015MxService va015MxService;
@Resource
private VA006Service va006Service;
@Resource
private VA015Service va015Service;
@Resource
private VA002Mapper va002Mapper;
@Resource
private VA003Mapper va003Mapper;
@Resource
private VA006Mapper va006Mapper;
@Resource
private VA006MxMapper va006MxMapper;
@Resource
private VA010Mapper va010Mapper;
@Resource
private VA010MxMapper va010MxMapper;
@Resource
private VA011Mapper va011Mapper;
@Resource
private VA011MxMapper va011MxMapper;
@Resource
private VA015Mapper va015Mapper;
@Resource
private VA015MxMapper va015MxMapper;
/**
* 拼接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) {
udiwmsUnitRequest.setDatabaseProductName(getDataSourceType());
IPage<VA001> iPage = va001Service.filterList(udiwmsUnitRequest);
log.info("解析湖里妇幼返回往来单位,返回结果:{}", iPage.getRecords());
PageSimpleResponse<VA001> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(iPage.getTotal());
pageSimpleResponse.setList(iPage.getRecords());
return ResultVOUtils.success(pageSimpleResponse);
}
@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)) {
List<ThrProductsEntity> list = udiwmsProductRequest.getThrProductsEntities();
List codeList = new ArrayList();
List nameList = new ArrayList();
List registerNoList = new ArrayList();
if (list != null && list.size() > 0) {
for (ThrProductsEntity thrProductsEntity : list) {
if (StringUtils.isNotEmpty(thrProductsEntity.getCode())) {
codeList.add(thrProductsEntity.getCode());
}
if (StringUtils.isNotEmpty(thrProductsEntity.getName())) {
nameList.add(thrProductsEntity.getName());
}
if (StringUtils.isNotEmpty(thrProductsEntity.getRegisterNo())) {
registerNoList.add(thrProductsEntity.getRegisterNo());
}
}
}
LambdaQueryWrapper<VA002> wrapper = new LambdaQueryWrapper();
//补充其他查询条件
wrapper.in(codeList != null && codeList.size() > 0, VA002::getCode, codeList);
wrapper.in(nameList != null && nameList.size() > 0, VA002::getName, nameList);
wrapper.in(registerNoList != null && registerNoList.size() > 0, VA002::getRegisterno, registerNoList);
// 保留之前的查询方法怕有用到
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getCode()), VA002::getCode, udiwmsProductRequest.getCode());
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getName()), VA002::getName, udiwmsProductRequest.getName());
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getRegisterNo()), VA002::getRegisterno, udiwmsProductRequest.getRegisterNo());
wrapper.eq(VA002::getRemark, "Y");
IPage<VA002> page = va002Mapper.selectPage(new Page<VA002>(udiwmsProductRequest.getPage(), udiwmsProductRequest.getLimit()), wrapper);
List<VA002> physicDictEntities = page.getRecords();
List<ZzzyyProductsResponse> zzzyyProductsResponseList = null;
if (CollUtil.isNotEmpty(physicDictEntities)) {
//数据处理以thr_products 返回
zzzyyProductsResponseList = physicDictEntities.stream().map(dict -> {
ZzzyyProductsResponse products = new ZzzyyProductsResponse();
// BeanUtil.copyProperties(dict,products);
oracleCompatibleCopy(dict, products);
products.setProductType(1);
// products.setRegisterNo(dict.getRegisterno());
return products;
}).collect(Collectors.toList());
}
PageSimpleResponse<ZzzyyProductsResponse> zzzyyProductsResponse = new PageSimpleResponse<>();
zzzyyProductsResponse.setTotal(page.getTotal());
zzzyyProductsResponse.setList(zzzyyProductsResponseList);
return ResultVOUtils.success(zzzyyProductsResponse);
} else if (udiwmsProductRequest.getProductType().equals(Constants.PRODUCT_TYPE_DRUG)) {
List<ThrProductsEntity> list = udiwmsProductRequest.getThrProductsEntities();
List codeList = new ArrayList();
List nameList = new ArrayList();
List registerNoList = new ArrayList();
if (list != null && list.size() > 0) {
for (ThrProductsEntity thrProductsEntity : list) {
if (StringUtils.isNotEmpty(thrProductsEntity.getCode())) {
codeList.add(thrProductsEntity.getCode());
}
if (StringUtils.isNotEmpty(thrProductsEntity.getName())) {
nameList.add(thrProductsEntity.getName());
}
if (StringUtils.isNotEmpty(thrProductsEntity.getRegisterNo())) {
registerNoList.add(thrProductsEntity.getRegisterNo());
}
}
}
LambdaQueryWrapper<VA003> wrapper = new LambdaQueryWrapper();
//补充其他查询条件
wrapper.in(codeList != null && codeList.size() > 0, VA003::getCode, codeList);
wrapper.in(nameList != null && nameList.size() > 0, VA003::getName, nameList);
wrapper.in(registerNoList != null && registerNoList.size() > 0, VA003::getRegisterno, registerNoList);
// 保留之前的查询方法怕有用到
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getCode()), VA003::getCode, udiwmsProductRequest.getCode());
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getName()), VA003::getName, udiwmsProductRequest.getName());
wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getRegisterNo()), VA003::getRegisterno, udiwmsProductRequest.getRegisterNo());
wrapper.eq(VA003::getRemark, "Y");
IPage<VA003> page = va003Mapper.selectPage(new Page<VA003>(udiwmsProductRequest.getPage(), udiwmsProductRequest.getLimit()), wrapper);
List<VA003> physicDictEntities = page.getRecords();
List<ThrProductsEntity> thrProductsEntityList = null;
if (CollUtil.isNotEmpty(physicDictEntities)) {
//数据处理以thr_products 返回
thrProductsEntityList = physicDictEntities.stream().map(dict -> {
ThrProductsEntity products = new ThrProductsEntity();
oracleCompatibleCopy(dict, products);
products.setSpec(dict.getBzgg());
products.setProductType(2);
products.setRegisterNo(dict.getRegisterno());
return products;
}).collect(Collectors.toList());
}
thrProductsDao.batchInsert(thrProductsEntityList);
for (ThrProductsEntity entity : thrProductsEntityList) {
entity.setId(null);
entity.setRemark(entity.getCode());
entity.setCode(entity.getYbbm());
}
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);
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) {
udiwmsWarehouseRequest.setDatabaseProductName(getDataSourceType());
PageSimpleResponseNew<VA004> pageSimpleResponseNew = va004Service.filterList(udiwmsWarehouseRequest);
log.info("解析四川武平县医院返回仓库信息,返回结果:{}", pageSimpleResponseNew.getList());
return ResultVOUtils.success(pageSimpleResponseNew);
}
@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;
}
// @Value("${DBTYPE}")
// private String DBTYPE;
/**
* ------------------------------------------现场管理医保相关接口方法--------------------------------------------------------------
*/
/**
* 处方拉取视图
*
* @param udiwmsBasicSkPrescribeRequest
* @return
*/
@Override
public BaseResponse getPrescribes(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest) {
if (IntUtil.value(udiwmsBasicSkPrescribeRequest.getInOutType()) == 0) {
udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType());
IPage<VA010> iPage = va010Service.getList(new Page<VA010>(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), udiwmsBasicSkPrescribeRequest);
return this.covertSellOrder(udiwmsBasicSkPrescribeRequest, iPage);
} else {
udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType());
IPage<VA011> iPage = va011Service.getList(new Page<VA011>(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), udiwmsBasicSkPrescribeRequest);
return this.covertReturnOrder(udiwmsBasicSkPrescribeRequest, iPage);
}
}
@Override
public BaseResponse getPrescribesQx(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest) {
if (IntUtil.value(udiwmsBasicSkPrescribeRequest.getInOutType()) == 0) {
udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType());
IPage<VA006> iPage = va006Service.getList(new Page<VA006>(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), udiwmsBasicSkPrescribeRequest);
return this.covertSellOrderQx(udiwmsBasicSkPrescribeRequest, iPage);
} else {
udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType());
IPage<VA015> iPage = va015Service.getList(new Page<VA015>(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), udiwmsBasicSkPrescribeRequest);
return this.covertReturnOrderQx(udiwmsBasicSkPrescribeRequest, iPage);
}
}
/**
* 采购计划拉取视图
*
* @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)) {
return 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<VA010> iPage) {
List<VA010> headList = iPage.getRecords();
// log.info("udiwmsBasicSkPrescribeRequest=="+udiwmsBasicSkPrescribeRequest+"====="+headList);
if (CollUtil.isNotEmpty(headList)) {
List<String> codefks = headList.stream().map(VA010::getCode).collect(Collectors.toList());
LambdaQueryWrapper<VA010Mx> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VA010Mx::getCodefk, codefks);
List<VA010Mx> a010details = va010MxMapper.selectList(wrapper1);
Map<String, List<VA010Mx>> detailsMap = new HashMap<>();
if (CollUtil.isNotEmpty(a010details)) {
detailsMap = a010details.stream()
.collect(Collectors.groupingBy(VA010Mx::getCodefk));
}
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
Map<String, List<VA010Mx>> finalDetailsMap = detailsMap;
headList.forEach(item -> {
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(item.getCode());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setFromCorp(item.getDeptcode());
ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode());
ioCollectOrder.setFromCorpName(item.getSickname());
ioCollectOrder.setShipperName(item.getDeptname());
if (item.getRemark().equals("门诊")) {
ioCollectOrder.setBusType("YPCF002");
} else {
ioCollectOrder.setBusType("YPCF003");
}
Date date = null;
try {
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(item.getPrescribedate());
} catch (ParseException e) {
}
ioCollectOrder.setBillTime(date);
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
// ioCollectOrder.setBusType(udiwmsBasicSkPrescribeRequest.getBusType());
ioCollectOrder.setBackupOrderRemark1(item.getCode());
// 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<VA010Mx> itemDetails = finalDetailsMap.get(item.getCode());
List<IoCollectOrderBiz> bizList = new ArrayList<>();
if (CollUtil.isNotEmpty(itemDetails)) {
itemDetails.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BeanUtils.copyProperties(entity,collectOrderBiz);
List<BasicUdirelEntity> basicUdirelEntities = basicUdirelDao.selectList(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getItemcode()));
if (CollUtil.isNotEmpty(basicUdirelEntities)) {
BasicUdirelEntity basicUdirelEntity = basicUdirelEntities.get(0);
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getItemname()).append("字典未对照").append(";");
}
collectOrderBiz.setGgxh(entity.getBzgg());
collectOrderBiz.setMeasureUnit(entity.getMeasureunit());
collectOrderBiz.setCount(IntUtil.value(entity.getMeasurecount()));
collectOrderBiz.setThrCode(entity.getItemcode());
collectOrderBiz.setCpmctymc(entity.getItemname());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
// collectOrderBiz.setRemark1(entity.getRemark());
collectOrderBiz.setNameCode(entity.getItemcode());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
}
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(summarizeByCode(bizList));
ioCollectOrders.add(ioCollectOrder);
});
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(iPage.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
return ResultVOUtils.success(pageSimpleResponse);
} else {
return ResultVOUtils.error(500, "未查询到数据!");
}
}
public static List<IoCollectOrderBiz> summarizeByCode(List<IoCollectOrderBiz> bizList) {
Map<String, IoCollectOrderBiz> summarizedMap = new HashMap<>();
for (IoCollectOrderBiz biz : bizList) {
String code = biz.getThrCode();
if (summarizedMap.containsKey(code)) {
IoCollectOrderBiz existingBiz = summarizedMap.get(code);
existingBiz.setCount(existingBiz.getCount() + biz.getCount());
} else {
summarizedMap.put(code, biz);
}
}
return new ArrayList<>(summarizedMap.values());
}
private BaseResponse covertReturnOrder(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage<VA011> iPage) {
List<VA011> headList = iPage.getRecords();
// log.info("udiwmsBasicSkPrescribeRequest=="+udiwmsBasicSkPrescribeRequest+"====="+headList);
if (CollUtil.isNotEmpty(headList)) {
List<String> codefks = headList.stream().map(VA011::getCode).collect(Collectors.toList());
LambdaQueryWrapper<VA011Mx> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VA011Mx::getCodefk, codefks);
List<VA011Mx> va011MxList = va011MxMapper.selectList(wrapper1);
Map<String, List<VA011Mx>> detailsMap = new HashMap<>();
if (CollUtil.isNotEmpty(va011MxList)) {
detailsMap = va011MxList.stream()
.collect(Collectors.groupingBy(VA011Mx::getCodefk));
}
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
Map<String, List<VA011Mx>> finalDetailsMap = detailsMap;
headList.forEach(item -> {
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(item.getCode());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setFromCorp(item.getDeptcode());
ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode());
ioCollectOrder.setFromCorpName(item.getSickname());
ioCollectOrder.setShipperName(item.getDeptname());
if (item.getRemark().equals("门诊")) {
ioCollectOrder.setBusType("YPCF002");
} else {
ioCollectOrder.setBusType("YPCF003");
}
Date date = null;
try {
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(item.getPrescribedate());
} catch (ParseException e) {
}
ioCollectOrder.setBillTime(date);
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
// ioCollectOrder.setBusType(udiwmsBasicSkPrescribeRequest.getBusType());
ioCollectOrder.setBackupOrderRemark1(item.getCode());
// 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<VA011Mx> itemDetails = finalDetailsMap.get(item.getCode());
List<IoCollectOrderBiz> bizList = new ArrayList<>();
if (CollUtil.isNotEmpty(itemDetails)) {
itemDetails.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BeanUtils.copyProperties(entity,collectOrderBiz);
List<BasicUdirelEntity> basicUdirelEntities = basicUdirelDao.selectList(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getItemcode()));
if (CollUtil.isNotEmpty(basicUdirelEntities)) {
BasicUdirelEntity basicUdirelEntity = basicUdirelEntities.get(0);
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getItemname()).append("字典未对照").append(";");
}
collectOrderBiz.setGgxh(entity.getBzgg());
collectOrderBiz.setMeasureUnit(entity.getMeasureunit());
collectOrderBiz.setCount(IntUtil.value(entity.getMeasurecount()));
collectOrderBiz.setThrCode(entity.getItemcode());
collectOrderBiz.setCpmctymc(entity.getItemname());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
// collectOrderBiz.setRemark1(entity.getRemark());
collectOrderBiz.setNameCode(entity.getItemcode());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
}
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(summarizeByCode(bizList));
ioCollectOrders.add(ioCollectOrder);
});
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(iPage.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
return ResultVOUtils.success(pageSimpleResponse);
} else {
return ResultVOUtils.error(500, "未查询到数据!");
}
}
public BaseResponse optionUploadCollectOrder3505(IoCollectOrder ioCollectOrder) {
//摆药流水号
// String stoout_no = ioCollectOrder.getBackupOrderRemark1();
String stoout_no = StringUtils.isBlank(ioCollectOrder.getBackupOrderRemark1()) ? ioCollectOrder.getBackupOrderRemark2() : 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) {
for (RelCodeDetail relCodeDetail : relCodeDetailList) {
DrugInfoRequest request = new DrugInfoRequest();
request.setDrug_trac_codg(relCodeDetail.getCurCode());
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);
return ybClient.ybPostScyh("3505A", dataJson);
} else {
return ResultVOUtils.error(500, "医保视图数据查不到,请核实");
}
}
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.ybPostScyh("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.setSelinfoDetail(kcbg3502Requests);
String jsonStr = JSONUtil.toJsonStr(baseKcbg3502Request);
JSONObject dataJson = JSONObject.parseObject(jsonStr);
ybClient.ybPostScyh("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.ybPostScyh("3506A", dataJson);
}
@Override
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);
}
public void oracleCompatibleCopy(Object source, Object target) {
try {
Class sourceClass = source.getClass();//得到对象的Class
Class targetClass = target.getClass();//得到对象的Class
Field[] sourceFields = sourceClass.getDeclaredFields();//得到Class对象的所有属性
Field[] targetFields = targetClass.getDeclaredFields();//得到Class对象的所有属性
for (Field sourceField : sourceFields) {
sourceField.setAccessible(true);
String name = sourceField.getName();//属性名
Class type = sourceField.getType();//属性类型
Object value = sourceField.get(source);
for (Field targetField : targetFields) {
targetField.setAccessible(true);
String targetName = targetField.getName();//目标对象的属性名
if (targetName.toLowerCase().equals(name.toLowerCase()) && !Objects.isNull(value)) {
targetField.set(target, value);
}
}
}
} catch (Exception e) {
BeanUtil.copyProperties(source, target);
}
}
public String getDataSourceType(){
return defXmlSqlType;
}
/**
* 单据
*
* @param udiwmsBasicSkPrescribeRequest
* @return
*/
private BaseResponse covertSellOrderQx(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage<VA006> iPage) {
List<VA006> headList = iPage.getRecords();
// log.info("udiwmsBasicSkPrescribeRequest=="+udiwmsBasicSkPrescribeRequest+"====="+headList);
if (CollUtil.isNotEmpty(headList)) {
List<String> codefks = headList.stream().map(VA006::getCode).collect(Collectors.toList());
LambdaQueryWrapper<VA006Mx> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VA006Mx::getCodefk, codefks);
List<VA006Mx> va006MxList = va006MxMapper.selectList(wrapper1);
Map<String, List<VA006Mx>> detailsMap = new HashMap<>();
if (CollUtil.isNotEmpty(va006MxList)) {
detailsMap = va006MxList.stream()
.collect(Collectors.groupingBy(VA006Mx::getCodefk));
}
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
Map<String, List<VA006Mx>> finalDetailsMap = detailsMap;
headList.forEach(item -> {
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(item.getCode());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setFromCorp(item.getDeptcode());
ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode());
ioCollectOrder.setFromCorpName(item.getSickname());
ioCollectOrder.setShipperName(item.getDeptname());
if (item.getRemark().equals("门诊")) {
ioCollectOrder.setBusType("YPCF002");
} else {
ioCollectOrder.setBusType("YPCF003");
}
Date date = null;
try {
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(item.getPrescribedate());
} catch (ParseException e) {
}
ioCollectOrder.setBillTime(date);
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
// ioCollectOrder.setBusType(udiwmsBasicSkPrescribeRequest.getBusType());
ioCollectOrder.setBackupOrderRemark1(item.getCode());
// 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<VA006Mx> itemDetails = finalDetailsMap.get(item.getCode());
List<IoCollectOrderBiz> bizList = new ArrayList<>();
if (CollUtil.isNotEmpty(itemDetails)) {
itemDetails.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BeanUtils.copyProperties(entity,collectOrderBiz);
List<BasicUdirelEntity> basicUdirelEntities = basicUdirelDao.selectList(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getItemcode()));
if (CollUtil.isNotEmpty(basicUdirelEntities)) {
BasicUdirelEntity basicUdirelEntity = basicUdirelEntities.get(0);
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getItemname()).append("字典未对照").append(";");
}
collectOrderBiz.setGgxh(entity.getGgxh());
collectOrderBiz.setMeasureUnit(entity.getMeasureunit());
collectOrderBiz.setCount(IntUtil.value(entity.getMeasurecount()));
collectOrderBiz.setThrCode(entity.getItemcode());
collectOrderBiz.setCpmctymc(entity.getItemname());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
// collectOrderBiz.setRemark1(entity.getRemark());
collectOrderBiz.setNameCode(entity.getItemcode());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
}
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(summarizeByCode(bizList));
ioCollectOrders.add(ioCollectOrder);
});
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(iPage.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
return ResultVOUtils.success(pageSimpleResponse);
} else {
return ResultVOUtils.error(500, "未查询到数据!");
}
}
private BaseResponse covertReturnOrderQx(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage<VA015> iPage) {
List<VA015> headList = iPage.getRecords();
// log.info("udiwmsBasicSkPrescribeRequest=="+udiwmsBasicSkPrescribeRequest+"====="+headList);
if (CollUtil.isNotEmpty(headList)) {
List<String> codefks = headList.stream().map(VA015::getCode).collect(Collectors.toList());
LambdaQueryWrapper<VA015Mx> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(VA015Mx::getCodefk, codefks);
List<VA015Mx> va015MxList = va015MxMapper.selectList(wrapper1);
Map<String, List<VA015Mx>> detailsMap = new HashMap<>();
if (CollUtil.isNotEmpty(va015MxList)) {
detailsMap = va015MxList.stream()
.collect(Collectors.groupingBy(VA015Mx::getCodefk));
}
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
Map<String, List<VA015Mx>> finalDetailsMap = detailsMap;
headList.forEach(item -> {
StringBuilder errorMsg = new StringBuilder();
IoCollectOrder ioCollectOrder = new IoCollectOrder();
ioCollectOrder.setBillNo(item.getCode());
ioCollectOrder.setFromType("HIS系统");
ioCollectOrder.setFromCorp(item.getDeptcode());
ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode());
ioCollectOrder.setFromCorpName(item.getSickname());
ioCollectOrder.setShipperName(item.getDeptname());
if (item.getRemark().equals("门诊")) {
ioCollectOrder.setBusType("YPCF002");
} else {
ioCollectOrder.setBusType("YPCF003");
}
Date date = null;
try {
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(item.getPrescribedate());
} catch (ParseException e) {
}
ioCollectOrder.setBillTime(date);
ioCollectOrder.setCreateTime(new Date());
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
// ioCollectOrder.setBusType(udiwmsBasicSkPrescribeRequest.getBusType());
ioCollectOrder.setBackupOrderRemark1(item.getCode());
// 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<VA015Mx> itemDetails = finalDetailsMap.get(item.getCode());
List<IoCollectOrderBiz> bizList = new ArrayList<>();
if (CollUtil.isNotEmpty(itemDetails)) {
itemDetails.forEach(entity -> {
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
BeanUtils.copyProperties(entity,collectOrderBiz);
List<BasicUdirelEntity> basicUdirelEntities = basicUdirelDao.selectList(new LambdaQueryWrapper<BasicUdirelEntity>().eq(BasicUdirelEntity::getMainId, entity.getItemcode()));
if (CollUtil.isNotEmpty(basicUdirelEntities)) {
BasicUdirelEntity basicUdirelEntity = basicUdirelEntities.get(0);
collectOrderBiz.setRelId(basicUdirelEntity.getId());
} else {
errorMsg.append(entity.getItemname()).append("字典未对照").append(";");
}
collectOrderBiz.setGgxh(entity.getGgxh());
collectOrderBiz.setMeasureUnit(entity.getMeasureunit());
collectOrderBiz.setCount(IntUtil.value(entity.getMeasurecount()));
collectOrderBiz.setThrCode(entity.getItemcode());
collectOrderBiz.setCpmctymc(entity.getItemname());
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
// collectOrderBiz.setRemark1(entity.getRemark());
collectOrderBiz.setNameCode(entity.getItemcode());
collectOrderBiz.setTagStatus(1);
collectOrderBiz.setUnTagCount(0);
bizList.add(collectOrderBiz);
});
}
if (StrUtil.isNotBlank(errorMsg)) {
ioCollectOrder.setErrorMsg(errorMsg.toString());
ioCollectOrder.setTagStatus(4);
}
ioCollectOrder.setBizList(summarizeByCode(bizList));
ioCollectOrders.add(ioCollectOrder);
});
PageSimpleResponse<IoCollectOrder> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(iPage.getTotal());
pageSimpleResponse.setList(ioCollectOrders);
return ResultVOUtils.success(pageSimpleResponse);
} else {
return ResultVOUtils.error(500, "未查询到数据!");
}
}
}