|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.hnthyy.thmz.service.impl.his.yf;
|
|
|
|
|
|
+import cn.hnthyy.thmz.Utils.DecimalUtil;
|
|
|
import cn.hnthyy.thmz.Utils.ListSizeControlUtil;
|
|
|
import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.entity.MzException;
|
|
|
@@ -9,10 +10,20 @@ import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
|
|
|
import cn.hnthyy.thmz.entity.his.yp.YpSummaryPrint;
|
|
|
import cn.hnthyy.thmz.entity.his.yp.YpYzSendRecord;
|
|
|
import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
|
|
|
-import cn.hnthyy.thmz.entity.his.yz.*;
|
|
|
+import cn.hnthyy.thmz.entity.his.yz.YzActOrderCy;
|
|
|
+import cn.hnthyy.thmz.entity.his.yz.YzActOrderCyDetail;
|
|
|
+import cn.hnthyy.thmz.entity.his.yz.YzSupplyType;
|
|
|
+import cn.hnthyy.thmz.entity.his.yz.YzYpPageNo;
|
|
|
+import cn.hnthyy.thmz.entity.his.yz.YzYpZyOrder;
|
|
|
import cn.hnthyy.thmz.entity.his.zd.ZdCommon;
|
|
|
import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
|
|
|
-import cn.hnthyy.thmz.entity.his.zy.*;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.APatientMi;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.Prescription;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.YpZyPatient;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.ZyActpatient;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.ZyDetailCharge;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.ZyDrug;
|
|
|
+import cn.hnthyy.thmz.entity.his.zy.ZyLedgerFile;
|
|
|
import cn.hnthyy.thmz.mapper.his.ResponceTypeMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.mz.EmployeeMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.mz.MzPharmacyMapper;
|
|
|
@@ -21,10 +32,23 @@ import cn.hnthyy.thmz.mapper.his.yp.YpMzFytjMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.yp.YpYzSendRecordMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
|
|
|
-import cn.hnthyy.thmz.mapper.his.yz.*;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzActOrderCyDetailMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzActOrderCyMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzActOrderMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzInactOrderMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzOrderFrequencyMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzSupplyTypeMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzYpPageNoMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yz.YzYpZyOrderMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.zd.MzYshZdFysmMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.zd.ZdUnitCodeMapper;
|
|
|
-import cn.hnthyy.thmz.mapper.his.zy.*;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.APatientMiMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.PrescriptionMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.YpZyPatientMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.ZyActpatientMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.ZyDetailChargeMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.ZyDrugMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.zy.ZyLedgerFileMapper;
|
|
|
import cn.hnthyy.thmz.service.his.yf.YfWardPrescriptionService;
|
|
|
import cn.hnthyy.thmz.service.his.yz.YzSequenceService;
|
|
|
import cn.hnthyy.thmz.vo.YfWardVo;
|
|
|
@@ -46,7 +70,13 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.UUID;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -1112,45 +1142,63 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
if(null == summaryData || summaryData.isEmpty()){
|
|
|
return resultMap;
|
|
|
}
|
|
|
- List<YfWardVo> yfWardVos;
|
|
|
- if ("A".equals(vo.getPageClass())) {//医技科室领药
|
|
|
- yfWardVos = queryZyDrug(vo.getPageNo(), vo.getSubmitFlag());
|
|
|
- } else {
|
|
|
- yfWardVos = queryYzYpOrder(vo.getPageNo(), vo.getPageClass(), vo.getSubmitFlag());
|
|
|
+ List<YfWardVo> yfWardVos = new ArrayList<>();
|
|
|
+ String pageNo = vo.getPageNo();
|
|
|
+ String[] pageNos = pageNo.split("/");
|
|
|
+ for (String page :pageNos) {
|
|
|
+ List<YfWardVo> ds;
|
|
|
+ if ("A".equals(vo.getPageClass())) {//医技科室领药
|
|
|
+ ds = queryZyDrug(page, vo.getSubmitFlag());
|
|
|
+ } else {
|
|
|
+ ds = queryYzYpOrder(page, vo.getPageClass(), vo.getSubmitFlag());
|
|
|
+ }
|
|
|
+ if(null != ds && !ds.isEmpty()){
|
|
|
+ yfWardVos.addAll(ds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(yfWardVos.isEmpty()){
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
+ Map<String, Map<String, List<YfWardVo>>> map = yfWardVos.stream().collect(
|
|
|
+ Collectors.groupingBy(YfWardVo::getChargeCode, Collectors.groupingBy(YfWardVo::getSerial)));
|
|
|
String msg = "";
|
|
|
boolean flag = false;
|
|
|
int pid = 1;
|
|
|
for(YpSummaryPrint ypPrint : summaryData){
|
|
|
String chargeCode = ypPrint.getChargeCode();
|
|
|
String serial = ypPrint.getSerial();
|
|
|
- BigDecimal amount = ypPrint.getAmount();
|
|
|
- for (YfWardVo yf : yfWardVos){
|
|
|
- if(chargeCode.equals(yf.getChargeCode()) && serial.equals(yf.getSerial())){
|
|
|
- if(amount.doubleValue() == yf.getAmount()){
|
|
|
- ypPrint.setResult("正常");
|
|
|
- } else {
|
|
|
- if(StringUtils.isBlank(msg)){
|
|
|
- msg += "有误差,实际发药数量: " + yf.getAmount() + ", 打印数量: " + amount + " 。。。";
|
|
|
- }
|
|
|
- ypPrint.setResult("有误差,实际发药数量: " + yf.getAmount() + ", 打印数量: " + amount);
|
|
|
- if(!flag){
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- ypPrint.setId(String.valueOf(System.currentTimeMillis()));
|
|
|
- ypPrint.setSort(pid);
|
|
|
- ypPrint.setPageNo(vo.getPageNo());
|
|
|
- ypPrint.setPageClass(vo.getPageClass());
|
|
|
- ypPrint.setSubmitFlag(String.valueOf(vo.getSubmitFlag()));
|
|
|
- ypPrint.setPrintFlag(vo.getPrintFlag());
|
|
|
- // 医嘱实际发药量
|
|
|
- ypPrint.setRealAmount(BigDecimal.valueOf(yf.getAmount()));
|
|
|
- ypPrint.setCreateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
- pid ++;
|
|
|
- break;
|
|
|
+ BigDecimal printAmount = ypPrint.getAmount();
|
|
|
+ Map<String, List<YfWardVo>> ff = map.get(chargeCode);
|
|
|
+ List<YfWardVo> data = ff.get(serial);
|
|
|
+ if(data.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal realAmount = BigDecimal.ZERO;
|
|
|
+ for (YfWardVo yf : data){
|
|
|
+ realAmount = DecimalUtil.add(realAmount, BigDecimal.valueOf(yf.getAmount()));
|
|
|
+ }
|
|
|
+ if(realAmount.compareTo(printAmount) != 0){
|
|
|
+ if(!flag){
|
|
|
+ flag = true;
|
|
|
}
|
|
|
+ if(StringUtils.isBlank(msg)){
|
|
|
+ msg += "有误差,实际发药数量: " + realAmount + ", 打印数量: " + printAmount + " 。。。";
|
|
|
+ }
|
|
|
+ ypPrint.setResult("有误差,实际发药数量: " + realAmount + ", 打印数量: " + printAmount);
|
|
|
+ } else {
|
|
|
+ ypPrint.setResult("正常");
|
|
|
}
|
|
|
+ ypPrint.setId(String.valueOf(System.currentTimeMillis()));
|
|
|
+ ypPrint.setSort(pid);
|
|
|
+ ypPrint.setPageNo(pageNo);
|
|
|
+ ypPrint.setPageClass(vo.getPageClass());
|
|
|
+ ypPrint.setSubmitFlag(String.valueOf(vo.getSubmitFlag()));
|
|
|
+ ypPrint.setPrintFlag(vo.getPrintFlag());
|
|
|
+ // 医嘱实际发药量
|
|
|
+ ypPrint.setRealAmount(realAmount);
|
|
|
+ ypPrint.setCreateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ pid ++;
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(msg)) {
|
|
|
vo.setMessage(msg);
|