|
@@ -8,6 +8,7 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.targetmanagement.TargetManagementDao;
|
|
|
import thyyxxk.webserver.dao.his.targetmanagement.ZbZdBaseInfoDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.highreport.HighReportDto;
|
|
|
import thyyxxk.webserver.entity.highreport.ReportBaseInfo;
|
|
|
import thyyxxk.webserver.entity.targetmanagement.TargetDictTree;
|
|
|
import thyyxxk.webserver.entity.targetmanagement.TargetManagement;
|
|
@@ -55,6 +56,18 @@ public class TargetManagementService {
|
|
|
return ResultVoUtil.success(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description: 根据id查询指标字典基本信息
|
|
|
+ * @author: hsh
|
|
|
+ * @date: 2023/7/5 10:58
|
|
|
+ * @param: [dto]
|
|
|
+ * @return: ResultVo<ZbZdBaseInfo>
|
|
|
+ **/
|
|
|
+ public ResultVo<ZbZdBaseInfo> selectTargetDictById(TargetManagement dto) {
|
|
|
+ ZbZdBaseInfo info = zbZdDao.selectZbZdBaseInfoById(dto);
|
|
|
+ return ResultVoUtil.success(info);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @description: 查询指标树
|
|
|
* @author: hsh
|
|
@@ -178,13 +191,15 @@ public class TargetManagementService {
|
|
|
message = "指标计分细则不存在,请检查!";
|
|
|
}
|
|
|
if(StringUtil.notBlank(sqlChild)){
|
|
|
- if(sqlChild.contains("drop") || sqlChild.contains("truncate") || sqlChild.contains("delete") || sqlChild.contains("update")){
|
|
|
+ if(sqlChild.contains("drop") || sqlChild.contains("truncate") || sqlChild.contains("delete") || sqlChild.contains("update")
|
|
|
+ || sqlChild.contains("DROP") || sqlChild.contains("TRUNCATE") || sqlChild.contains("DELETE") || sqlChild.contains("UPDATE")){
|
|
|
log.info("保存指标字典失败,分子sql语句存在非查询语句关键字,请检查!");
|
|
|
message = "保存指标字典失败,分子sql语句存在非查询语句关键字,请检查!";
|
|
|
}
|
|
|
}
|
|
|
if(StringUtil.notBlank(sqlMom)){
|
|
|
- if(sqlMom.contains("drop") || sqlMom.contains("truncate") || sqlMom.contains("delete") || sqlMom.contains("update")){
|
|
|
+ if(sqlMom.contains("drop") || sqlMom.contains("truncate") || sqlMom.contains("delete") || sqlMom.contains("update")
|
|
|
+ || sqlMom.contains("DROP") || sqlMom.contains("TRUNCATE") || sqlMom.contains("DELETE") || sqlMom.contains("UPDATE")){
|
|
|
log.info("保存指标字典失败,分母sql语句存在非查询语句关键字,请检查!");
|
|
|
message = "保存指标字典失败,分母sql语句存在非查询语句关键字,请检查!";
|
|
|
}
|
|
@@ -193,6 +208,13 @@ public class TargetManagementService {
|
|
|
return message;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description: 查询分子分母指标报表结果
|
|
|
+ * @author: hsh
|
|
|
+ * @date: 2023/7/6 9:31
|
|
|
+ * @param: [dto]
|
|
|
+ * @return: ResultVo<Map<String,Object>>
|
|
|
+ **/
|
|
|
public ResultVo<Map<String, Object>> targetSqlExecute(TargetManagement dto) {
|
|
|
String sqlChild = dto.getCalcChild();
|
|
|
String sqlMom = dto.getCalcMom();
|
|
@@ -212,12 +234,75 @@ public class TargetManagementService {
|
|
|
}
|
|
|
|
|
|
// 转换sql的查询条件
|
|
|
- ReportUtil.callSqlFormatTarget(dto);
|
|
|
+ Map<String, ReportBaseInfo> map = ReportUtil.assertReportForTarget(dto);
|
|
|
+ ReportBaseInfo r1 = map.get("calcChild");
|
|
|
+ ReportBaseInfo r2 = map.get("calcMom");
|
|
|
+
|
|
|
+ // 转换查询dto
|
|
|
+ HighReportDto d = ReportUtil.TargetManagementConvertHighReportDto(dto);
|
|
|
+
|
|
|
+ // 计算结果
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ String child = null;
|
|
|
+ String mom = null;
|
|
|
+ if(r1 != null){
|
|
|
+ String childSql = ReportUtil.callSqlFormat(d, r1.getBaseSql(), r1.getGatherSql(), null, null, null);
|
|
|
+ child = dao.targetSqlExecute(childSql);
|
|
|
+ }
|
|
|
+ if(r2 != null){
|
|
|
+ String momSql = ReportUtil.callSqlFormat(d, r2.getBaseSql(), r2.getGatherSql(), null, null, null);
|
|
|
+ mom = dao.targetSqlExecute(momSql);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.notBlank(child)) {
|
|
|
+ resultMap.put("r1", child);
|
|
|
+ } else {
|
|
|
+ resultMap.put("r1", "无");
|
|
|
+ }
|
|
|
+ if (StringUtil.notBlank(mom)) {
|
|
|
+ resultMap.put("r2", mom);
|
|
|
+ resultMap.put("r3", DecimalUtil.divide(new BigDecimal(child), new BigDecimal(mom), 2));
|
|
|
+ } else {
|
|
|
+ resultMap.put("r2", "无");
|
|
|
+ if (StringUtil.notBlank(child)) {
|
|
|
+ resultMap.put("r3", child);
|
|
|
+ } else {
|
|
|
+ resultMap.put("r3", "无");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 根据id查询分子分母指标报表结果
|
|
|
+ * @author: hsh
|
|
|
+ * @date: 2023/7/6 9:30
|
|
|
+ * @param: [dto]
|
|
|
+ * @return: ResultVo<Map<String,Object>>
|
|
|
+ **/
|
|
|
+ public ResultVo<Map<String, Object>> targetSqlExecuteById(TargetManagement dto) {
|
|
|
+ ReportBaseInfo reportChild = dao.selectReportBaseInfoByCalcId(dto.getChildId());
|
|
|
+ ReportBaseInfo reportMom = dao.selectReportBaseInfoByCalcId(dto.getMomId());
|
|
|
+
|
|
|
+ if(null == reportChild && null == reportMom){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, dto.getName() + "计算-分子或分母指标都不存在,请联系管理员!");
|
|
|
+ }
|
|
|
+
|
|
|
+ HighReportDto d = ReportUtil.TargetManagementConvertHighReportDto(dto);
|
|
|
|
|
|
// 计算结果
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- String child = dao.targetSqlExecute(dto.getCalcChild());
|
|
|
- String mom = dao.targetSqlExecute(dto.getCalcMom());
|
|
|
+ String child = null;
|
|
|
+ String mom = null;
|
|
|
+ if(reportChild != null){
|
|
|
+ String childSql = ReportUtil.callSqlFormat(d, reportChild.getBaseSql(), reportChild.getGatherSql(), null, null, null);
|
|
|
+ child = dao.targetSqlExecute(childSql);
|
|
|
+ }
|
|
|
+ if(reportMom != null){
|
|
|
+ String momSql = ReportUtil.callSqlFormat(d, reportMom.getBaseSql(), reportMom.getGatherSql(), null, null, null);
|
|
|
+ mom = dao.targetSqlExecute(momSql);
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtil.notBlank(child)) {
|
|
|
resultMap.put("r1", child);
|
|
|
} else {
|
|
@@ -240,35 +325,58 @@ public class TargetManagementService {
|
|
|
public ResultVo<Map<String, Object>> targetSqlSave(TargetManagement dto) {
|
|
|
String sqlChild = dto.getCalcChild();
|
|
|
String sqlMom = dto.getCalcMom();
|
|
|
- if(StringUtil.isBlank(sqlChild)){
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "计算-分子sql不存在,请检查!");
|
|
|
- } else {
|
|
|
- if(sqlChild.contains("drop") || sqlChild.contains("truncate") || sqlChild.contains("delete") || sqlChild.contains("update")){
|
|
|
+ if(StringUtil.notBlank(sqlChild)) {
|
|
|
+ if (!sqlChild.contains("/") && !(sqlChild.contains("select") || sqlChild.contains("SELECT"))) {
|
|
|
+ log.info("分子sql语句不合法,请检查!");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "分子sql语句不合法,请检查!");
|
|
|
+ }
|
|
|
+ if (sqlChild.contains("drop") || sqlChild.contains("truncate") || sqlChild.contains("delete") || sqlChild.contains("update")
|
|
|
+ || sqlChild.contains("DROP") || sqlChild.contains("TRUNCATE") || sqlChild.contains("DELETE") || sqlChild.contains("UPDATE")) {
|
|
|
log.info("分子sql语句存在非查询语句关键字,请检查!");
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "分子sql语句存在非查询语句关键字,请检查!");
|
|
|
}
|
|
|
}
|
|
|
if(StringUtil.notBlank(sqlMom)){
|
|
|
- if(sqlMom.contains("drop") || sqlMom.contains("truncate") || sqlMom.contains("delete") || sqlMom.contains("update")){
|
|
|
+ if (!sqlMom.contains("/") && !(sqlMom.contains("select") || sqlMom.contains("SELECT"))) {
|
|
|
+ log.info("分母sql语句不合法,请检查!");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "分母sql语句不合法,请检查!");
|
|
|
+ }
|
|
|
+ if(sqlMom.contains("drop") || sqlMom.contains("truncate") || sqlMom.contains("delete") || sqlMom.contains("update")
|
|
|
+ || sqlMom.contains("DROP") || sqlMom.contains("TRUNCATE") || sqlMom.contains("DELETE") || sqlMom.contains("UPDATE")){
|
|
|
log.info("分母sql语句存在非查询语句关键字,请检查!");
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "分母sql语句存在非查询语句关键字,请检查!");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- ReportBaseInfo report = new ReportBaseInfo();
|
|
|
- report.setReportId(dto.getId());
|
|
|
- report.setReportName(dto.getName());
|
|
|
- report.setLevel(dto.getPid());
|
|
|
- report.setCalcChild(dto.getCalcChild());
|
|
|
- report.setCalcMom(dto.getCalcMom());
|
|
|
- report.setReportSort(dto.getSort());
|
|
|
- report.setReportType("zb");
|
|
|
- report.setBaseSql("/");
|
|
|
- report.setFlag("Y");
|
|
|
- report.setDisplayType("fbt,mx");
|
|
|
try {
|
|
|
+ int num = 0;
|
|
|
+ // 获取指标字典sql信息
|
|
|
+ Map<String, ReportBaseInfo> map = ReportUtil.assertReportForTarget(dto);
|
|
|
+
|
|
|
+ // 查询指标字典是否以及存在分子分母的sql指标报表信息
|
|
|
+ ZbZdBaseInfo info = zbZdDao.selectZbZdBaseInfoById(dto);
|
|
|
+ if(null != map.get("calcChild")){
|
|
|
+ // 已经配置分子sql指标报表信息
|
|
|
+ ReportBaseInfo r1 = map.get("calcChild");
|
|
|
+ // 更新分子指标报表的sql信息
|
|
|
+ if(StringUtil.notBlank(info.getChildId())){
|
|
|
+ dao.deleteReportBaseInfoById(r1.getReportId());
|
|
|
+ } else {
|
|
|
+ // 保存分子指标报表的id
|
|
|
+ zbZdDao.updateZbZdBaseInfoCalcId(dto.getId(), dto.getPid() ,r1.getReportId(), null);
|
|
|
+ }
|
|
|
+ num += dao.insert(r1);
|
|
|
+ }
|
|
|
+ if(null != map.get("calcMom")){
|
|
|
+ ReportBaseInfo r2 = map.get("calcMom");
|
|
|
+ if(StringUtil.notBlank(info.getMomId())){
|
|
|
+ dao.deleteReportBaseInfoById(r2.getReportId());
|
|
|
+ } else {
|
|
|
+ // 保存分母指标报表的id
|
|
|
+ zbZdDao.updateZbZdBaseInfoCalcId(dto.getId(), dto.getPid(), null, r2.getReportId());
|
|
|
+ }
|
|
|
+ num += dao.insert(r2);
|
|
|
+ }
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- int num = dao.insert(report);
|
|
|
if(num == 0){
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存指标sql以及报表失败!");
|
|
|
}
|
|
@@ -303,4 +411,51 @@ public class TargetManagementService {
|
|
|
resultMap.put("cg", "删除指标字典成功!");
|
|
|
return ResultVoUtil.success(resultMap);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 查询指标字典的分子分母sql
|
|
|
+ * @author: hsh
|
|
|
+ * @date: 2023/6/30 15:19
|
|
|
+ * @param: [dto]
|
|
|
+ * @return: ResultVo<Map<String,Object>>
|
|
|
+ **/
|
|
|
+ public ResultVo<Map<String, Object>> selectTargetSql(TargetManagement dto) {
|
|
|
+ if (StringUtil.isBlank(dto.getId())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "id不存在,请检查!");
|
|
|
+ }
|
|
|
+ if (StringUtil.isBlank(dto.getPid())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "父id不存在,请检查!");
|
|
|
+ }
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ ReportBaseInfo reportChild = dao.selectReportBaseInfoByCalcId(dto.getChildId());
|
|
|
+ ReportBaseInfo reportMom = dao.selectReportBaseInfoByCalcId(dto.getMomId());
|
|
|
+ resultMap.put("reportChild", reportChild);
|
|
|
+ resultMap.put("reportMom", reportMom);
|
|
|
+ return ResultVoUtil.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 查询指标字典的分子分母sql的详细内容
|
|
|
+ * @author: hsh
|
|
|
+ * @date: 2023/6/30 15:20
|
|
|
+ * @param: [dto]
|
|
|
+ * @return: ResultVo<Map<String,Object>>
|
|
|
+ **/
|
|
|
+ public ResultVo<Map<String, Object>> selectTargetSqlDetail(TargetManagement dto) {
|
|
|
+ if (StringUtil.isBlank(dto.getId())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "id不存在,请检查!");
|
|
|
+ }
|
|
|
+ if (StringUtil.isBlank(dto.getPid())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "父id不存在,请检查!");
|
|
|
+ }
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ ReportBaseInfo reportBaseInfo = dao.selectReportBaseInfoById(dto.getId(), dto.getPid());
|
|
|
+ if (reportBaseInfo == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "查询指标不存在!");
|
|
|
+ }
|
|
|
+ resultMap.put("report", reportBaseInfo);
|
|
|
+ return ResultVoUtil.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
}
|