|
|
|
@ -70,6 +70,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -81,7 +83,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 +1441,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 +1469,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 +1787,73 @@ 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());
|
|
|
|
|
LambdaQueryWrapper<VYpzsPresInfo> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
|
wrapper1.in(VYpzsPresInfo::getPRESCRIBE_NUMBER, collect);
|
|
|
|
|
vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper1);
|
|
|
|
|
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 {
|
|
|
|
|
summaryNo = "";
|
|
|
|
|
|
|
|
|
|
List<String> collect = presInfoEntities.stream().map(VYpzsPresInfo::getPRESCRIBE_NUMBER).collect(Collectors.toList());
|
|
|
|
|
LambdaQueryWrapper<VYpzsPresInfo> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
|
wrapper1.in(VYpzsPresInfo::getPRESCRIBE_NUMBER, collect);
|
|
|
|
|
vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper1);
|
|
|
|
|
}
|
|
|
|
|
} 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);
|
|
|
|
|
VYpzsPresInfo presInfoEntity = value.stream()
|
|
|
|
|
.max(Comparator.comparing(VYpzsPresInfo::getLAY_TIME))
|
|
|
|
|
.orElse(null);;
|
|
|
|
|
StringBuilder errorMsg = new StringBuilder();
|
|
|
|
|
IoCollectOrder ioCollectOrder = new IoCollectOrder();
|
|
|
|
|
|
|
|
|
@ -1796,11 +1876,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();
|
|
|
|
@ -2075,7 +2159,10 @@ public class yxfyClient extends CommonHttpClient {
|
|
|
|
|
|
|
|
|
|
String stoout_no = list.get(0).getPRESCRIBE_NUMBER();
|
|
|
|
|
|
|
|
|
|
List<VInsurNationGoodsPhysic> vInsurNationGoodsPhysics = goodsPhysicMapper.selectList(new LambdaQueryWrapper<VInsurNationGoodsPhysic>().eq(VInsurNationGoodsPhysic::getRXNO, stoout_no));
|
|
|
|
|
List<VInsurNationGoodsPhysic> vInsurNationGoodsPhysics = goodsPhysicMapper.selectList(new LambdaQueryWrapper<VInsurNationGoodsPhysic>()
|
|
|
|
|
.eq(VInsurNationGoodsPhysic::getRXNO, stoout_no)
|
|
|
|
|
// 使用 apply 方法嵌入原生 SQL 进行日期格式转换
|
|
|
|
|
.apply("TO_CHAR(SEL_RETN_TIME, 'yyyy-MM-dd HH24:MI:SS') = TO_CHAR({0}, 'yyyy-MM-dd HH24:MI:SS')", list.get(0).getLAY_TIME()));
|
|
|
|
|
if ( CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) {
|
|
|
|
|
List<CollectOrderBizResponse> collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList();
|
|
|
|
|
|
|
|
|
@ -2142,7 +2229,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 +2237,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())
|
|
|
|
|