|
|
|
@ -69,7 +69,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -81,7 +84,7 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
private final String[] buyType_3502 = {"SC73200069614118"};
|
|
|
|
|
private final String[] buyType_3504 = {};
|
|
|
|
|
|
|
|
|
|
private final String[] buyType_3505 = {"QXCF001", "YPCF002"};
|
|
|
|
|
private final String[] buyType_3505 = {"YPCF003", "YPCF002"};
|
|
|
|
|
private final String[] buyType_35051 = {"SC72197936495755"};
|
|
|
|
|
private final String[] buyType_3506 = {};
|
|
|
|
|
@Resource
|
|
|
|
@ -1439,6 +1442,16 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
.or().like(VInsurNationGoodsPhysic::getPSN_NO, "%" + key + "%")
|
|
|
|
|
);
|
|
|
|
|
wrapper.and(StrUtil.isNotEmpty(fromCorpName), t -> t.eq(VInsurNationGoodsPhysic::getPSN_NAME, fromCorpName));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(udiwmsBasicSkPrescribeRequest.getCode())) {
|
|
|
|
|
udiwmsBasicSkPrescribeRequest.setQueryCode("'" + udiwmsBasicSkPrescribeRequest.getCode() + "'");
|
|
|
|
|
} else if (StringUtils.isNotEmpty(udiwmsBasicSkPrescribeRequest.getKey())) {
|
|
|
|
|
udiwmsBasicSkPrescribeRequest.setQueryCode("'" + udiwmsBasicSkPrescribeRequest.getKey() + "'");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
udiwmsBasicSkPrescribeRequest.setQueryCode("null");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (udiwmsBasicSkPrescribeRequest.getBusType().equals("YPCF003")) {
|
|
|
|
|
udiwmsBasicSkPrescribeRequest.setIN_HOSP("1");
|
|
|
|
|
} else {
|
|
|
|
@ -1457,6 +1470,21 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
pageSimpleResponse.setList(null);
|
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
|
}
|
|
|
|
|
// 分组
|
|
|
|
|
if (StringUtils.isNotEmpty(udiwmsBasicSkPrescribeRequest.getQueryCode()) && !udiwmsBasicSkPrescribeRequest.getQueryCode().equals("null")) {
|
|
|
|
|
Map<String, List<VYpzsPresInfo>> groupedRecords = page.getRecords().stream()
|
|
|
|
|
.collect(Collectors.groupingBy(VYpzsPresInfo::getQUERY_CODE));
|
|
|
|
|
List<VYpzsPresInfo> latestRecords = new ArrayList<>();
|
|
|
|
|
for (List<VYpzsPresInfo> group : groupedRecords.values()) {
|
|
|
|
|
VYpzsPresInfo latest = group.stream()
|
|
|
|
|
.max(Comparator.comparing(VYpzsPresInfo::getLAY_TIME))
|
|
|
|
|
.orElse(null);
|
|
|
|
|
if (latest != null) {
|
|
|
|
|
latestRecords.add(latest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
page.setRecords(latestRecords);
|
|
|
|
|
}
|
|
|
|
|
return this.covertSellOrder(udiwmsBasicSkPrescribeRequest, page);
|
|
|
|
|
} else {
|
|
|
|
|
LambdaQueryWrapper<VInsurNationGoodsReturn> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
@ -1760,20 +1788,106 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
private BaseResponse covertSellOrder(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage<VYpzsPresInfo> page) {
|
|
|
|
|
List<VYpzsPresInfo> presInfoEntities = page.getRecords();
|
|
|
|
|
List<VYpzsPresInfo> vInsurNationGoodsPhysics = new ArrayList<>();
|
|
|
|
|
String summaryNo;
|
|
|
|
|
if (CollUtil.isNotEmpty(presInfoEntities)) {
|
|
|
|
|
List<String> collect = presInfoEntities.stream().map(VYpzsPresInfo::getPRESCRIBE_NUMBER).collect(Collectors.toList());
|
|
|
|
|
// if (presInfoEntities.size() == 1) {//进入拉取周边的同患者同处方 通过患者id 和 周边时间 上下10分钟
|
|
|
|
|
// VYpzsPresInfo vYpzsPresInfo = presInfoEntities.get(0);
|
|
|
|
|
//
|
|
|
|
|
// LambdaQueryWrapper<VYpzsPresInfo> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
|
// wrapper1.eq(VYpzsPresInfo::getPRESCRIBE_NUMBER, vYpzsPresInfo.getPRESCRIBE_NUMBER());
|
|
|
|
|
// presInfoEntities = vYpzsPresInfoMapper.selectList(wrapper1);
|
|
|
|
|
// vYpzsPresInfo = presInfoEntities.get(0);
|
|
|
|
|
//
|
|
|
|
|
// String layTimeStr = vYpzsPresInfo.getLAY_TIME();//当前处方的时间
|
|
|
|
|
// String sickId = vYpzsPresInfo.getSICK_ID();
|
|
|
|
|
// String icCardId = vYpzsPresInfo.getIC_CARD_ID();
|
|
|
|
|
//
|
|
|
|
|
// // 时间格式处理(补充格式定义)
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
//
|
|
|
|
|
// // 转换为 LocalDateTime 并计算时间范围
|
|
|
|
|
// LocalDateTime layTime;
|
|
|
|
|
// try {
|
|
|
|
|
// layTimeStr = layTimeStr.replace(".0", "");
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// layTime = LocalDateTime.parse(layTimeStr, formatter);
|
|
|
|
|
//
|
|
|
|
|
// }catch (Exception e){
|
|
|
|
|
// formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// layTime = LocalDateTime.parse(layTimeStr, formatter);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// LocalDateTime startTime = layTime.minusMinutes(10); // 向前10分钟
|
|
|
|
|
// LocalDateTime endTime = layTime.plusMinutes(10); // 向后10分钟
|
|
|
|
|
//
|
|
|
|
|
// summaryNo = layTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + icCardId;
|
|
|
|
|
//
|
|
|
|
|
// LambdaQueryWrapper<VYpzsPresInfo> wrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
|
// wrapper2.eq(VYpzsPresInfo::getSICK_ID, sickId);
|
|
|
|
|
// // 使用 TO_TIMESTAMP 函数进行转换
|
|
|
|
|
// wrapper2.apply("LAY_TIME BETWEEN TO_TIMESTAMP({0}, 'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP({1}, 'YYYY-MM-DD HH24:MI:SS')",
|
|
|
|
|
// startTime.format(formatter), endTime.format(formatter));
|
|
|
|
|
//
|
|
|
|
|
// vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper2);
|
|
|
|
|
//
|
|
|
|
|
// }else {
|
|
|
|
|
//区分住院、门诊处方
|
|
|
|
|
LambdaQueryWrapper<VYpzsPresInfo> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(udiwmsBasicSkPrescribeRequest.getQueryCode()) && !udiwmsBasicSkPrescribeRequest.getQueryCode().equals("null") && udiwmsBasicSkPrescribeRequest.getBusType().equals("YPCF003")
|
|
|
|
|
&& udiwmsBasicSkPrescribeRequest.getQueryCode().startsWith("'5")) {
|
|
|
|
|
|
|
|
|
|
List<String> collect = presInfoEntities.stream().map(VYpzsPresInfo::getQUERY_CODE).collect(Collectors.toList());
|
|
|
|
|
wrapper1.in(VYpzsPresInfo::getSTOOUT_NO, collect);
|
|
|
|
|
vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper1);
|
|
|
|
|
String sickId = vInsurNationGoodsPhysics.get(0).getSICK_ID();
|
|
|
|
|
String layTimeStr = vInsurNationGoodsPhysics.get(0).getLAY_TIME();//当前处方的时间
|
|
|
|
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
String result="";
|
|
|
|
|
try {
|
|
|
|
|
Date date = inputFormat.parse(layTimeStr.replace(".000", "").replace(".0", ""));
|
|
|
|
|
result = outputFormat.format(date);
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
summaryNo = result + sickId;
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
List<String> collect = presInfoEntities.stream().map(VYpzsPresInfo::getPRESCRIBE_NUMBER).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
wrapper1.in(VYpzsPresInfo::getPRESCRIBE_NUMBER, collect);
|
|
|
|
|
vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper1);
|
|
|
|
|
summaryNo = "";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
summaryNo = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: 2024/9/19 这边在转换的时候就不能用VInsurNationGoodsPhysic
|
|
|
|
|
if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) {
|
|
|
|
|
Map<String, List<VYpzsPresInfo>> groupedByPrescribeNumber = vInsurNationGoodsPhysics.stream()
|
|
|
|
|
Map<String, List<VYpzsPresInfo>> groupedByPrescribeNumber;
|
|
|
|
|
groupedByPrescribeNumber = vInsurNationGoodsPhysics.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(VYpzsPresInfo::getPRESCRIBE_NUMBER));
|
|
|
|
|
|
|
|
|
|
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
|
|
|
|
|
groupedByPrescribeNumber.forEach((key, value) -> {
|
|
|
|
|
VYpzsPresInfo presInfoEntity = value.get(0);
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 根据实际时间格式调整
|
|
|
|
|
VYpzsPresInfo presInfoEntity = Optional.ofNullable(value)
|
|
|
|
|
.flatMap(l -> l.stream()
|
|
|
|
|
.max(Comparator.comparing(info -> LocalDateTime.parse(info.getLAY_TIME().replace(".000", "").replace(".0", ""), formatter))))
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
StringBuilder errorMsg = new StringBuilder();
|
|
|
|
|
IoCollectOrder ioCollectOrder = new IoCollectOrder();
|
|
|
|
|
|
|
|
|
@ -1796,11 +1910,15 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser());
|
|
|
|
|
ioCollectOrder.setBackupOrderRemark1(presInfoEntity.getSTOOUT_NO());
|
|
|
|
|
ioCollectOrder.setBackupOrderRemark2(presInfoEntity.getSICK_ID());
|
|
|
|
|
// ioCollectOrder.setBackupOrderRemark3(presInfoEntity.getPSN_NAME());
|
|
|
|
|
// ioCollectOrder.setBackupOrderRemark4(presInfoEntity.getPSN_NO());
|
|
|
|
|
ioCollectOrder.setBackupOrderRemark3(presInfoEntity.getCONFECT_MAN());
|
|
|
|
|
ioCollectOrder.setBackupOrderRemark4(presInfoEntity.getTAKE_OPERATOR());
|
|
|
|
|
|
|
|
|
|
ioCollectOrder.setUpdateTime(new Date());
|
|
|
|
|
ioCollectOrder.setSplitStatus(0);
|
|
|
|
|
ioCollectOrder.setTagStatus(0);
|
|
|
|
|
if (StrUtil.isNotEmpty(summaryNo)) {
|
|
|
|
|
ioCollectOrder.setSummaryNo(summaryNo);
|
|
|
|
|
}
|
|
|
|
|
List<IoCollectOrderBiz> bizList = new ArrayList<>();
|
|
|
|
|
value.forEach(entity -> {
|
|
|
|
|
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
|
|
|
|
@ -2069,13 +2187,31 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
// log.error("stoout_no===",stoout_no);
|
|
|
|
|
List<VYpzsPresInfo> list = vYpzsPresInfoMapper
|
|
|
|
|
.selectList(
|
|
|
|
|
new QueryWrapper<VYpzsPresInfo>().eq("PRESCRIBE_NUMBER",ioCollectOrder.getBillNo())
|
|
|
|
|
new QueryWrapper<VYpzsPresInfo>()
|
|
|
|
|
.eq("PRESCRIBE_NUMBER", ioCollectOrder.getBillNo())
|
|
|
|
|
);
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
|
|
|
|
|
String stoout_no = list.get(0).getPRESCRIBE_NUMBER();
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 根据实际时间格式调整
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VYpzsPresInfo vYpzsPresInfo = Optional.ofNullable(list)
|
|
|
|
|
.flatMap(l -> l.stream()
|
|
|
|
|
.max(Comparator.comparing(info -> LocalDateTime.parse(info.getLAY_TIME().replace(".000", "").replace(".0", ""), formatter))))
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<VInsurNationGoodsPhysic> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
queryWrapper.eq(VInsurNationGoodsPhysic::getRXNO, vYpzsPresInfo.getPRESCRIBE_NUMBER());
|
|
|
|
|
// 使用 apply 方法嵌入原生 SQL 进行日期格式转换
|
|
|
|
|
if (getDataSourceType().equals("Oracle")) {
|
|
|
|
|
queryWrapper.apply("TO_CHAR(SEL_RETN_TIME, 'yyyy-MM-dd HH24:MI:SS') = {0}", vYpzsPresInfo.getLAY_TIME().replace(".000", "").replace(".0", ""));
|
|
|
|
|
|
|
|
|
|
List<VInsurNationGoodsPhysic> vInsurNationGoodsPhysics = goodsPhysicMapper.selectList(new LambdaQueryWrapper<VInsurNationGoodsPhysic>().eq(VInsurNationGoodsPhysic::getRXNO, stoout_no));
|
|
|
|
|
} else {
|
|
|
|
|
queryWrapper.apply("DATE_FORMAT(SEL_RETN_TIME, '%Y-%m-%d %H:%i:%s') = DATE_FORMAT({0}, '%Y-%m-%d %H:%i:%s')", vYpzsPresInfo.getLAY_TIME().replace(".000", "").replace(".0", ""));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<VInsurNationGoodsPhysic> vInsurNationGoodsPhysics = goodsPhysicMapper.selectList(queryWrapper);
|
|
|
|
|
if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) {
|
|
|
|
|
List<CollectOrderBizResponse> collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList();
|
|
|
|
|
|
|
|
|
@ -2142,7 +2278,7 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
.expy_end(vInsurNationGoodsPhysic.getEXPY_END())
|
|
|
|
|
.rx_flag(vInsurNationGoodsPhysic.getRX_FLAG())
|
|
|
|
|
.trdn_flag(collectOrderBizResponse.getTrdnFlag())
|
|
|
|
|
.finl_trns_pric(vInsurNationGoodsPhysic.getFINL_TRNS_PRIC())
|
|
|
|
|
.finl_trns_pric(null)
|
|
|
|
|
.rxno(vInsurNationGoodsPhysic.getRXNO())
|
|
|
|
|
.rx_circ_flag(vInsurNationGoodsPhysic.getRX_CIRC_FLAG())
|
|
|
|
|
.rtal_docno(vInsurNationGoodsPhysic.getRTAL_DOCNO())
|
|
|
|
@ -2150,7 +2286,7 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
.bchno(vInsurNationGoodsPhysic.getBCHNO())
|
|
|
|
|
.drug_prod_barc(vInsurNationGoodsPhysic.getRUG_PROD_BARC())
|
|
|
|
|
.shelf_posi(vInsurNationGoodsPhysic.getSHELF_POSI())
|
|
|
|
|
.sel_retn_cnt(vInsurNationGoodsPhysic.getSEL_RETN_CNT())
|
|
|
|
|
.sel_retn_cnt(collectOrderBizResponse.getCount())
|
|
|
|
|
.sel_retn_time(vInsurNationGoodsPhysic.getSEL_RETN_TIME())
|
|
|
|
|
.sel_retn_opter_name(vInsurNationGoodsPhysic.getSEL_RETN_OPTER_NAME())
|
|
|
|
|
.memo(vInsurNationGoodsPhysic.getMEMO())
|
|
|
|
|