|
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
@@ -182,17 +183,22 @@ public class SiZyFeeService {
|
|
|
}
|
|
|
|
|
|
private void beforeUpload(Overview o) {
|
|
|
+ Date disdate = zyDao.selectDscgDate(o.getInpatientNo(), o.getAdmissTimes());
|
|
|
+ if (null != disdate) {
|
|
|
+ int num = zyDao.updateChargedate(o.getInpatientNo(), o.getAdmissTimes(), disdate);
|
|
|
+ log.info("修改费用时间大于出院医嘱时间的费用条目数:{}", num);
|
|
|
+ }
|
|
|
List<FeeCounteract> negative = zyDao.selectNegativeFeesWithOriDetlSn(
|
|
|
o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
|
|
|
if (null == negative || negative.isEmpty()) {
|
|
|
log.info("正负相抵完成,抵消费用总条目:0");
|
|
|
return;
|
|
|
}
|
|
|
- List<Integer> positive = new ArrayList<>();
|
|
|
+ List<FeeCounteract> positive = new ArrayList<>();
|
|
|
List<Integer> tempSn = new ArrayList<>();
|
|
|
for (FeeCounteract feeCounteract : negative) {
|
|
|
tempSn.add(feeCounteract.getOriDetailSn());
|
|
|
- if (tempSn.size() == 20) {
|
|
|
+ if (tempSn.size() == 30) {
|
|
|
positive.addAll(zyDao.selectPositiveFeesByDetlSn(
|
|
|
o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn(), tempSn));
|
|
|
tempSn.clear();
|
|
@@ -202,12 +208,23 @@ public class SiZyFeeService {
|
|
|
positive.addAll(zyDao.selectPositiveFeesByDetlSn(
|
|
|
o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn(), tempSn));
|
|
|
}
|
|
|
+ ConcurrentHashMap<Integer, FeeCounteract> posKeyVal = new ConcurrentHashMap<>();
|
|
|
+ positive.forEach(itm -> {
|
|
|
+ if (!posKeyVal.containsKey(itm.getDetailSn())) {
|
|
|
+ posKeyVal.put(itm.getDetailSn(), itm);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
AtomicInteger count = new AtomicInteger();
|
|
|
negative.forEach(itm -> {
|
|
|
- if (positive.contains(itm.getOriDetailSn())) {
|
|
|
- zyDao.updateYbTransFlagInPair(o.getInpatientNo(),
|
|
|
- o.getAdmissTimes(), itm.getDetailSn(), itm.getOriDetailSn());
|
|
|
- count.addAndGet(2);
|
|
|
+ if (posKeyVal.containsKey(itm.getOriDetailSn())) {
|
|
|
+ FeeCounteract pos = posKeyVal.get(itm.getOriDetailSn());
|
|
|
+ if (itm.getChargeAmount() + pos.getChargeAmount() == 0d
|
|
|
+ && itm.getChargeFee() + pos.getChargeFee() == 0d) {
|
|
|
+ zyDao.updateYbTransFlagInPair(o.getInpatientNo(),
|
|
|
+ o.getAdmissTimes(), itm.getDetailSn(), itm.getOriDetailSn());
|
|
|
+ count.addAndGet(2);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
log.info("正负相抵完成,抵消费用总条目:{}", count.get());
|