|
@@ -4,12 +4,15 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.constants.Capacity;
|
|
|
+import thyyxxk.webserver.constants.ResponceType;
|
|
|
import thyyxxk.webserver.dao.his.reports.IllegalChargesAnalysisDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.dictionary.PureCodeName;
|
|
|
import thyyxxk.webserver.entity.reports.illegalChargesAnalysis.IllegalChargeData;
|
|
|
import thyyxxk.webserver.entity.reports.illegalChargesAnalysis.IllegalChargeTemplate;
|
|
|
import thyyxxk.webserver.entity.reports.illegalChargesAnalysis.SearchChargeItem;
|
|
|
+import thyyxxk.webserver.utils.DecimalUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.StringUtil;
|
|
|
import thyyxxk.webserver.utils.TokenUtil;
|
|
@@ -98,6 +101,7 @@ public class IllegalChargesAnalysisService {
|
|
|
}
|
|
|
template.setId(id.toString());
|
|
|
dao.insertNewTemplate(template);
|
|
|
+ log.info("创建模板:{}", template);
|
|
|
return ResultVoUtil.success("创建成功。");
|
|
|
}
|
|
|
|
|
@@ -122,15 +126,21 @@ public class IllegalChargesAnalysisService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> saveTemplateChanges(IllegalChargeTemplate template) {
|
|
|
+ if (template.getType() == 0) {
|
|
|
+ dao.updateTemplate(template);
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
if (null == template.getMainCharges() || template.getMainCharges().isEmpty()) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "收费主体不能为空!");
|
|
|
}
|
|
|
- if (null == template.getConflictCharges() || template.getConflictCharges().isEmpty()) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "冲突收费不能为空!");
|
|
|
+ StringBuilder value = genTemplateValue(template.getMainCharges());
|
|
|
+ if (template.getAttribute() == 1) {
|
|
|
+ if (null == template.getConflictCharges() || template.getConflictCharges().isEmpty()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "冲突收费不能为空!");
|
|
|
+ }
|
|
|
+ value.append("$").append(genTemplateValue(template.getConflictCharges()));
|
|
|
}
|
|
|
- String value = genTemplateValue(template.getMainCharges()).append("$")
|
|
|
- .append(genTemplateValue(template.getConflictCharges())).toString();
|
|
|
- template.setValue(value);
|
|
|
+ template.setValue(value.toString());
|
|
|
dao.updateTemplate(template);
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
@@ -148,15 +158,37 @@ public class IllegalChargesAnalysisService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<IllegalChargeData>> analyzeTargetData(IllegalChargeTemplate template) {
|
|
|
- String start = template.getStart() + " 00:00:00";
|
|
|
- String end = template.getEnd() + " 23:59:59";
|
|
|
+ template.setStart(template.getStart() + " 00:00:00");
|
|
|
+ template.setEnd(template.getEnd() + " 23:59:59");
|
|
|
+ if (null == template.getResponces()) {
|
|
|
+ template.setResponces(new ArrayList<>());
|
|
|
+ }
|
|
|
+ if (template.getResponces().isEmpty()) {
|
|
|
+ template.getResponces().add(ResponceType.HUNAN_PROVINCIAL_MEDICAL_INSURANCE);
|
|
|
+ template.getResponces().add(ResponceType.HUNAN_PROVINCE_REMOTE_MEDICAL_INSURANCE);
|
|
|
+ template.getResponces().add(ResponceType.CHANGSHA_CITY_RESIDENTS_MEDICAL_INSURANCE);
|
|
|
+ template.getResponces().add(ResponceType.CHANGSHA_CITY_WORKERS_MEDICAL_INSURANCE);
|
|
|
+ template.getResponces().add(ResponceType.NEW_RURAL_COOPERATIVE_MEDICAL_INSURANCE);
|
|
|
+ }
|
|
|
+ log.info("违规收费分析:{}", template);
|
|
|
+ if (template.getAttribute() == 1) {
|
|
|
+ return sameTimeCharge(template);
|
|
|
+ }
|
|
|
+ return overLimitCharge(template);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ResultVo<List<IllegalChargeData>> sameTimeCharge(IllegalChargeTemplate template) {
|
|
|
List<IllegalChargeData> mainList = new ArrayList<>();
|
|
|
for (PureCodeName mainCharge : template.getMainCharges()) {
|
|
|
- mainList.addAll(dao.selectChargeData(start, end, mainCharge.getCode()));
|
|
|
+ List<IllegalChargeData> temp = dao.selectChargeDataForSameTime(template.getStart(), template.getEnd(), mainCharge.getCode());
|
|
|
+ temp.removeIf(item -> !template.getResponces().contains(item.getResponceType()));
|
|
|
+ mainList.addAll(temp);
|
|
|
}
|
|
|
List<IllegalChargeData> conflictList = new ArrayList<>();
|
|
|
for (PureCodeName conflictCharge : template.getConflictCharges()) {
|
|
|
- conflictList.addAll(dao.selectChargeData(start, end, conflictCharge.getCode()));
|
|
|
+ List<IllegalChargeData> temp = dao.selectChargeDataForSameTime(template.getStart(), template.getEnd(), conflictCharge.getCode());
|
|
|
+ temp.removeIf(item -> !template.getResponces().contains(item.getResponceType()));
|
|
|
+ conflictList.addAll(temp);
|
|
|
}
|
|
|
Map<String, IllegalChargeData> map = new HashMap<>(mainList.size());
|
|
|
for (IllegalChargeData item : mainList) {
|
|
@@ -179,4 +211,29 @@ public class IllegalChargesAnalysisService {
|
|
|
}
|
|
|
return ResultVoUtil.success(resultList);
|
|
|
}
|
|
|
+
|
|
|
+ private ResultVo<List<IllegalChargeData>> overLimitCharge(IllegalChargeTemplate template) {
|
|
|
+ List<IllegalChargeData> mainList = new ArrayList<>();
|
|
|
+ for (PureCodeName mainCharge : template.getMainCharges()) {
|
|
|
+ List<IllegalChargeData> temp = dao.selectChargeDataForOverLimit(template.getStart(), template.getEnd(), mainCharge.getCode());
|
|
|
+ temp.removeIf(item -> !template.getResponces().contains(item.getResponceType()));
|
|
|
+ mainList.addAll(temp);
|
|
|
+ }
|
|
|
+ Map<String, IllegalChargeData> map = new HashMap<>(Capacity.DEFAULT);
|
|
|
+ for (IllegalChargeData item : mainList) {
|
|
|
+ String key = item.getInpatientNo() + "-" + item.getAdmissTimes();
|
|
|
+ if (map.containsKey(key)) {
|
|
|
+ IllegalChargeData temp = map.get(key);
|
|
|
+ temp.setChargeAmount(DecimalUtil.add(temp.getChargeAmount(), item.getChargeAmount()));
|
|
|
+ temp.setChargeFee(DecimalUtil.add(temp.getChargeFee(), item.getChargeFee()));
|
|
|
+ } else {
|
|
|
+ map.put(key, item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<IllegalChargeData> resultList = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, IllegalChargeData> entry : map.entrySet()) {
|
|
|
+ resultList.add(entry.getValue());
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(resultList);
|
|
|
+ }
|
|
|
}
|