DataAnalysisFacade.java 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. package com.diagbot.facade;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.diagbot.dto.BehospitalCodeDetail;
  5. import com.diagbot.dto.BehospitalCodeInfo;
  6. import com.diagbot.dto.BehospitalInfoDTO;
  7. import com.diagbot.dto.DeptBaseDTO;
  8. import com.diagbot.dto.EntryDefectImprove;
  9. import com.diagbot.dto.EntryDefectImproveInner;
  10. import com.diagbot.dto.GetEntryDefectImproveDTO;
  11. import com.diagbot.dto.GetEntryInfoDTO;
  12. import com.diagbot.dto.GetQcClickDTO;
  13. import com.diagbot.dto.GetQcClickInnerPageDTO;
  14. import com.diagbot.dto.QcResultDetailInfo;
  15. import com.diagbot.entity.BehospitalInfo;
  16. import com.diagbot.entity.MedClickInfo;
  17. import com.diagbot.entity.MedQcresultClick;
  18. import com.diagbot.entity.QcresultDetail;
  19. import com.diagbot.entity.QcresultInfo;
  20. import com.diagbot.enums.IsDeleteEnum;
  21. import com.diagbot.exception.CommonErrorCode;
  22. import com.diagbot.exception.CommonException;
  23. import com.diagbot.service.MedQcresultClickService;
  24. import com.diagbot.service.impl.MedClickInfoServiceImpl;
  25. import com.diagbot.util.BeanUtil;
  26. import com.diagbot.util.DateUtil;
  27. import com.diagbot.util.ExcelUtils;
  28. import com.diagbot.util.ListUtil;
  29. import com.diagbot.util.StringUtil;
  30. import com.diagbot.util.SysUserUtils;
  31. import com.diagbot.vo.BasDeptInfoVO;
  32. import com.diagbot.vo.GetEntryDefectImproveInnerVO;
  33. import com.diagbot.vo.GetEntryDefectImproveVO;
  34. import com.diagbot.vo.GetQcClickInnerPageVO;
  35. import com.diagbot.vo.GetQcClickVO;
  36. import com.diagbot.vo.MedClickInfoVO;
  37. import org.apache.commons.lang3.StringUtils;
  38. import org.josql.Query;
  39. import org.josql.QueryExecutionException;
  40. import org.josql.QueryParseException;
  41. import org.josql.QueryResults;
  42. import org.springframework.beans.factory.annotation.Autowired;
  43. import org.springframework.beans.factory.annotation.Qualifier;
  44. import org.springframework.stereotype.Component;
  45. import javax.servlet.http.HttpServletResponse;
  46. import java.text.ParseException;
  47. import java.text.SimpleDateFormat;
  48. import java.util.ArrayList;
  49. import java.util.Date;
  50. import java.util.HashMap;
  51. import java.util.HashSet;
  52. import java.util.Iterator;
  53. import java.util.List;
  54. import java.util.Map;
  55. import java.util.Set;
  56. import java.util.stream.Collectors;
  57. /**
  58. * @Description:数据分析
  59. * @Author: cy
  60. * @time: 2021/11/16 18:28
  61. */
  62. @Component
  63. public class DataAnalysisFacade {
  64. @Autowired
  65. @Qualifier("medClickInfoServiceImpl")
  66. private MedClickInfoServiceImpl medClickInfoService;
  67. @Autowired
  68. private QcresultInfoFacade qcresultInfoFacade;
  69. @Autowired
  70. private QcresultDetailFacade qcresultDetailFacade;
  71. @Autowired
  72. private MedQcresultClickService medQcresultClickService;
  73. @Autowired
  74. private BehospitalInfoFacade behospitalInfoFacade;
  75. /**
  76. * @Description:医生质控信息次数
  77. * @Param: [medClickInfoVO]
  78. * @return: void
  79. * @Author: cy
  80. * @Date: 2021/11/10
  81. */
  82. public Boolean addMedClickInfo(MedClickInfoVO medClickInfoVO) {
  83. MedClickInfo medClickInfo = new MedClickInfo();
  84. BeanUtil.copyProperties(medClickInfoVO, medClickInfo);
  85. QcresultInfo qcresultInfo = qcresultInfoFacade.lambdaQuery()
  86. .eq(QcresultInfo::getHospitalId, medClickInfoVO.getHospitalId())
  87. .eq(QcresultInfo::getBehospitalCode, medClickInfoVO.getBehospitalCode())
  88. .eq(QcresultInfo::getIsDeleted, IsDeleteEnum.N.getKey())
  89. .select(QcresultInfo::getId).one();
  90. if (null == qcresultInfo || null == qcresultInfo.getId()
  91. ) {
  92. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "内部参数异常");
  93. }
  94. medClickInfo.setQcresultInfoId(qcresultInfo.getId());
  95. medClickInfo.setGmtCreate(new Date());
  96. medClickInfoService.save(medClickInfo);
  97. BehospitalInfo behospitalInfo = behospitalInfoFacade.lambdaQuery()
  98. .eq(BehospitalInfo::getHospitalId, medClickInfoVO.getHospitalId())
  99. .eq(BehospitalInfo::getBehospitalCode, medClickInfoVO.getBehospitalCode())
  100. .ne(BehospitalInfo::getQcTypeId, "0")
  101. .eq(BehospitalInfo::getIsDeleted, IsDeleteEnum.N.getKey())
  102. .one();
  103. List<QcresultDetail> list = qcresultDetailFacade.lambdaQuery()
  104. .eq(QcresultDetail::getHospitalId, medClickInfoVO.getHospitalId())
  105. .eq(QcresultDetail::getBehospitalCode, medClickInfoVO.getBehospitalCode())
  106. .eq(QcresultDetail::getQcresultInfoId, qcresultInfo.getId())
  107. .eq(QcresultDetail::getIsDeleted, IsDeleteEnum.N.getKey()).list();
  108. if (ListUtil.isNotEmpty(list)) {
  109. StringBuilder sbFir = new StringBuilder();
  110. for (QcresultDetail qcresultDetail : list) {
  111. if (1 == qcresultDetail.getGradeType()) {
  112. if (null != qcresultDetail.getCasesEntryId()) {
  113. sbFir.append(qcresultDetail.getCasesEntryId() + "、");
  114. }
  115. }
  116. }
  117. if (sbFir.length() > 0) {
  118. sbFir = sbFir.deleteCharAt(sbFir.length() - 1);
  119. }
  120. MedQcresultClick medQcresultClick = new MedQcresultClick();
  121. medQcresultClick.setHospitalId(medClickInfoVO.getHospitalId());
  122. medQcresultClick.setBehospitalCode(medClickInfoVO.getBehospitalCode());
  123. if (null != behospitalInfo) {
  124. medQcresultClick.setDeptId(behospitalInfo.getBehDeptId());
  125. medQcresultClick.setDeptName(behospitalInfo.getBehDeptName());
  126. medQcresultClick.setDoctorId(behospitalInfo.getDoctorId());
  127. medQcresultClick.setDoctorName(behospitalInfo.getDoctorName());
  128. }
  129. medQcresultClick.setQcresultInfoId(qcresultInfo.getId());
  130. medQcresultClick.setCasesEntryIds(sbFir.toString());
  131. medQcresultClickService.save(medQcresultClick);
  132. }
  133. return true;
  134. }
  135. public List<DeptBaseDTO> getQcClickDeptList(BasDeptInfoVO basDeptInfoVO) {
  136. long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
  137. List<DeptBaseDTO> deptDTO = new ArrayList<>();
  138. List<MedClickInfo> deptList = medClickInfoService.lambdaQuery()
  139. .eq(MedClickInfo::getHospitalId, hospitalId)
  140. .eq(MedClickInfo::getIsDeleted, IsDeleteEnum.N.getKey())
  141. .like(MedClickInfo::getDeptName, basDeptInfoVO.getInputStr())
  142. .select(MedClickInfo::getDeptId, MedClickInfo::getDeptName)
  143. .groupBy(MedClickInfo::getDeptId)
  144. .groupBy(MedClickInfo::getDeptName)
  145. .list();
  146. if (ListUtil.isNotEmpty(deptList)) {
  147. for (MedClickInfo kfc : deptList) {
  148. if (null == kfc) {
  149. return deptDTO;
  150. }
  151. DeptBaseDTO deptBaseDTO = new DeptBaseDTO();
  152. deptBaseDTO.setDeptId(kfc.getDeptId());
  153. deptBaseDTO.setDeptName(kfc.getDeptName());
  154. deptDTO.add(deptBaseDTO);
  155. }
  156. }
  157. return deptDTO;
  158. }
  159. public List<GetQcClickDTO> getQcClick(GetQcClickVO getQcClickVO) {
  160. clickPageSet(getQcClickVO);
  161. List<GetQcClickDTO> records = medClickInfoService.getBaseMapper().getQcClick(getQcClickVO);
  162. //没有科室过滤时增加全院数据
  163. if (StringUtil.isBlank(getQcClickVO.getDeptName()) || getQcClickVO.getDeptName().equals("全院")) {
  164. GetQcClickDTO item = getGlobleTitle(records);
  165. if (item != null) {
  166. records.add(0, item);
  167. }
  168. }
  169. return records;
  170. }
  171. public void getQcClickByExport(HttpServletResponse response, GetQcClickVO getQcClickVO) {
  172. List<GetQcClickDTO> records = getQcClick(getQcClickVO);
  173. String fileName = "临床质控使用统计.xls";
  174. ExcelUtils.exportExcel(records, null, "sheet1", GetQcClickDTO.class, fileName, response, 12.8f);
  175. }
  176. public IPage<GetQcClickInnerPageDTO> getQcClickInnerPage(GetQcClickInnerPageVO getQcClickInnerPageVO) {
  177. clickInnerPageSet(getQcClickInnerPageVO);
  178. IPage<GetQcClickInnerPageDTO> records = medClickInfoService.getBaseMapper().getQcClickInnerPage(getQcClickInnerPageVO);
  179. return records;
  180. }
  181. public void getQcClickInnerPageByExport(HttpServletResponse response, GetQcClickInnerPageVO getQcClickInnerPageVO) {
  182. getQcClickInnerPageVO.setCurrent(1L);
  183. getQcClickInnerPageVO.setSize(Long.MAX_VALUE);
  184. getQcClickInnerPageVO.setSearchCount(false);
  185. IPage<GetQcClickInnerPageDTO> page = getQcClickInnerPage(getQcClickInnerPageVO);
  186. String fileName = "临床质控使用统计内页.xls";
  187. ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", GetQcClickInnerPageDTO.class, fileName, response, 12.8f);
  188. }
  189. public IPage<GetEntryDefectImproveDTO> getEntryDefectImprove(GetEntryDefectImproveVO getEntryDefectImproveVO) {
  190. int current = (int) getEntryDefectImproveVO.getCurrent();
  191. int size = (int) getEntryDefectImproveVO.getSize();
  192. IPage<GetEntryDefectImproveDTO> page = new Page<>();
  193. entryDefectSet(getEntryDefectImproveVO);
  194. List<GetEntryDefectImproveDTO> getEntryDefectImproveDTO = new ArrayList<>();
  195. //获取标准缺陷信息
  196. List<GetEntryInfoDTO> entryInfo = medClickInfoService.getBaseMapper().getEntryInfo();
  197. //查询基础数据源
  198. List<EntryDefectImprove> records = medClickInfoService.getBaseMapper().getEntryDefectImprove(getEntryDefectImproveVO);
  199. //遍历科室
  200. for (EntryDefectImprove entryDefectImprove : records) {
  201. Map<String, Long> totalMap = new HashMap<>();
  202. Map<String, Long> improveleMap = new HashMap<>();
  203. List<BehospitalCodeInfo> behospitalCodeInfoList = entryDefectImprove.getBehospitalCodeInfos();
  204. //多份病历多次质控评分得到质控缺陷总量、待改善总量
  205. unitProcessing(behospitalCodeInfoList, totalMap, improveleMap);
  206. //按照全院维度进行数据封装
  207. for (Map.Entry<String, Long> stringLongEntry : totalMap.entrySet()) {
  208. //封装DTO
  209. GetEntryDefectImproveDTO getEntryDefectImprove = new GetEntryDefectImproveDTO();
  210. getEntryDefectImprove.setDeptId(entryDefectImprove.getDeptId());
  211. getEntryDefectImprove.setDeptName(entryDefectImprove.getDeptName());
  212. getEntryDefectImprove.setEntryId(stringLongEntry.getKey());
  213. getEntryInfo(entryInfo, stringLongEntry, getEntryDefectImprove);
  214. getEntryDefectImprove.setTotalNum(stringLongEntry.getValue());
  215. if (improveleMap.containsKey(stringLongEntry.getKey())) {
  216. getEntryDefectImprove.setImproveleNum(improveleMap.get(stringLongEntry.getKey()));
  217. }
  218. getEntryDefectImprove.setHandleNum(getEntryDefectImprove.getTotalNum() - getEntryDefectImprove.getImproveleNum());
  219. getEntryDefectImproveDTO.add(getEntryDefectImprove);
  220. }
  221. }
  222. //(部分模糊查询在此)
  223. if (ListUtil.isNotEmpty(getEntryDefectImproveDTO)) {
  224. if (StringUtils.isNotBlank(getEntryDefectImproveVO.getCasesName()) || StringUtils.isNotBlank(getEntryDefectImproveVO.getEntryName())) {
  225. getEntryDefectImproveQuery(getEntryDefectImproveVO, getEntryDefectImproveDTO);
  226. }
  227. }
  228. //导出操作
  229. if (getEntryDefectImproveVO.getExportType() == 1L) {
  230. size = getEntryDefectImproveDTO.size();
  231. }
  232. page.setSize(size);
  233. page.setTotal(getEntryDefectImproveDTO.size());
  234. page.setCurrent(current);
  235. //分页操作
  236. List<GetEntryDefectImproveDTO> getEntryDefectImproveDTOS = page(getEntryDefectImproveDTO, size, current);
  237. if (ListUtil.isNotEmpty(getEntryDefectImproveDTOS)) {
  238. //排序操作
  239. getEntryDefectImproveDTOS = sortList(getEntryDefectImproveDTOS, getEntryDefectImproveVO.getAsc() != null ? getEntryDefectImproveVO.getAsc() : getEntryDefectImproveVO.getDesc() + " desc");
  240. };
  241. page.setRecords(getEntryDefectImproveDTOS);
  242. return page;
  243. }
  244. /**
  245. * @Description: 缺陷信息封装
  246. * @Param: [entryInfo, stringLongEntry, getEntryDefectImprove]
  247. * @return: com.diagbot.dto.GetEntryDefectImproveDTO
  248. * @Author: cy
  249. * @Date: 2021/12/3
  250. */
  251. public GetEntryDefectImproveDTO getEntryInfo(List<GetEntryInfoDTO> entryInfo, Map.Entry<String, Long> stringLongEntry,
  252. GetEntryDefectImproveDTO getEntryDefectImprove) {
  253. entryInfo.parallelStream().filter(kfc -> kfc.getEntryId().equals(stringLongEntry.getKey())).forEach(
  254. obj -> {
  255. getEntryDefectImprove.setCasesId(obj.getCasesId());
  256. getEntryDefectImprove.setCasesName(obj.getCasesName());
  257. getEntryDefectImprove.setEntryName(obj.getEntryName());
  258. }
  259. );
  260. return getEntryDefectImprove;
  261. }
  262. /**
  263. * @Description: 多份病历多次质控评分得到质控缺陷总量、待改善总量
  264. * @Param: [behospitalCodeInfoList, totalMap, improveleMap]
  265. * @return: void
  266. * @Author: cy
  267. * @Date: 2021/12/3
  268. */
  269. public static void unitProcessing(List<BehospitalCodeInfo> behospitalCodeInfoList, Map<String, Long> totalMap,
  270. Map<String, Long> improveleMap) {
  271. for (BehospitalCodeInfo behospitalCodeInfo : behospitalCodeInfoList) {
  272. //病历下
  273. List<QcResultDetailInfo> qcResultDetailInfos = behospitalCodeInfo.getQcResultDetailInfos();
  274. //获取多病历多质控质控缺陷总量
  275. totalMap = getEntryTotalMap(qcResultDetailInfos, totalMap);
  276. //获取多病历多质控质控缺陷待改善总量
  277. QcResultDetailInfo qcResultDetailInfo = qcResultDetailInfos.get(qcResultDetailInfos.size() - 1);
  278. improveleMap = getEntryImproveleMap(qcResultDetailInfo, improveleMap);
  279. }
  280. }
  281. public void getEntryDefectImproveQuery(GetEntryDefectImproveVO getEntryDefectImproveVO, List<GetEntryDefectImproveDTO> getEntryDefectImproveDTO) {
  282. Iterator<GetEntryDefectImproveDTO> iterator = getEntryDefectImproveDTO.iterator();
  283. while (iterator.hasNext()) {
  284. boolean mark = true;
  285. GetEntryDefectImproveDTO kfc = iterator.next();
  286. if (StringUtils.isNotBlank(getEntryDefectImproveVO.getCasesName()) &&
  287. !kfc.getCasesName().contains(getEntryDefectImproveVO.getCasesName())) {
  288. iterator.remove();
  289. mark = false;
  290. }
  291. if (mark && StringUtils.isNotBlank(getEntryDefectImproveVO.getEntryName()) &&
  292. !kfc.getEntryName().contains(getEntryDefectImproveVO.getEntryName())) {
  293. iterator.remove();
  294. }
  295. }
  296. }
  297. /**
  298. * @Description:分页数据
  299. * @Param: [dataList, pageSize, currentPage]
  300. * @return: java.util.List<java.lang.String>
  301. * @Author: cy
  302. * @Date: 2021/12/2
  303. */
  304. public static <T> List<T> page(List<T> retRecords, int pageSize, int currentPage) {
  305. List<T> currentPageList = new ArrayList<>();
  306. if (retRecords != null && retRecords.size() > 0) {
  307. int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
  308. for (int i = 0; i < pageSize && i < retRecords.size() - currIdx; i++) {
  309. T data = retRecords.get(currIdx + i);
  310. currentPageList.add(data);
  311. }
  312. }
  313. return currentPageList;
  314. }
  315. /**
  316. * 内存数据排序 使用JoSQL
  317. *
  318. * @param list
  319. * @param orderByString a asc,b desc
  320. * @return
  321. */
  322. public static <T> List<T> sortList(List<T> list, String orderByString) {
  323. String josql = " select * from " + list.get(0).getClass().getName() + " order by " + orderByString;
  324. Query query = new Query();
  325. try {
  326. query.parse(josql);
  327. QueryResults results = query.execute(list);
  328. list = results.getResults();
  329. } catch (QueryParseException e) {
  330. e.printStackTrace();
  331. } catch (QueryExecutionException e) {
  332. e.printStackTrace();
  333. }
  334. return list;
  335. }
  336. public static Map getEntryTotalMap(List<QcResultDetailInfo> qcResultDetailInfos, Map<String, Long> totalMap) {
  337. Set<String> totalSet = new HashSet<String>();
  338. for (QcResultDetailInfo qcResultDetailInfo : qcResultDetailInfos) {
  339. //质控下获取科室下总缺陷
  340. String casesEntryIds = qcResultDetailInfo.getCasesEntryIds();
  341. totalSet = getSetEntry(casesEntryIds, totalSet);
  342. }
  343. totalMap = getSetEntryCount(totalMap, totalSet);
  344. return totalMap;
  345. }
  346. public static Map getEntryImproveleMap(QcResultDetailInfo qcResultDetailInfo, Map<String, Long> improveMap) {
  347. Set<String> improveleSet = new HashSet<String>();
  348. String casesEntryIds = qcResultDetailInfo.getCasesEntryIds();
  349. improveleSet = getSetEntry(casesEntryIds, improveleSet);
  350. improveMap = getSetEntryCount(improveMap, improveleSet);
  351. return improveMap;
  352. }
  353. public static Set getSetEntry(String casesEntryIds, Set set) {
  354. if (StringUtils.isNotBlank(casesEntryIds) && !"0".equals(casesEntryIds)) {
  355. if (casesEntryIds.contains("、")) {
  356. String[] split = casesEntryIds.split("、");
  357. for (String id : split) {
  358. set.add(id);
  359. }
  360. } else {
  361. set.add(casesEntryIds);
  362. }
  363. }
  364. return set;
  365. }
  366. public static Map getSetEntryCount(Map<String, Long> map, Set<String> sets) {
  367. for (String set : sets) {
  368. if (map.containsKey(set)) {
  369. long count = map.get(set) + 1l;
  370. map.put(set, count);
  371. } else {
  372. map.put(set, 1L);
  373. }
  374. }
  375. return map;
  376. }
  377. public void getEntryDefectImproveByExport(HttpServletResponse response, GetEntryDefectImproveVO
  378. getEntryDefectImproveVO) {
  379. getEntryDefectImproveVO.setExportType(1L);
  380. getEntryDefectImproveVO.setCurrent(1L);
  381. getEntryDefectImproveVO.setSize(Long.MAX_VALUE);
  382. getEntryDefectImproveVO.setSearchCount(false);
  383. IPage<GetEntryDefectImproveDTO> page = getEntryDefectImprove(getEntryDefectImproveVO);
  384. String fileName = "条目缺陷改善统计.xls";
  385. ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", GetEntryDefectImproveDTO.class, fileName, response, 12.8f);
  386. }
  387. public IPage<BehospitalInfoDTO> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO
  388. getEntryDefectImproveInnerVO) {
  389. int current = (int) getEntryDefectImproveInnerVO.getCurrent();
  390. int size = (int) getEntryDefectImproveInnerVO.getSize();
  391. IPage<BehospitalInfoDTO> page = new Page<>();
  392. List<BehospitalInfoDTO> behospitalInfoDTOS = new ArrayList<>();
  393. entryDefectInnerSet(getEntryDefectImproveInnerVO);
  394. // List<GetEntryInfoDTO> entryInfo = medClickInfoService.getBaseMapper().getEntryInfo();
  395. List<EntryDefectImproveInner> records = medClickInfoService.getBaseMapper().getEntryDefectImproveInner(getEntryDefectImproveInnerVO);
  396. if (ListUtil.isNotEmpty(records) && records.size() == 1) {
  397. EntryDefectImproveInner entryDefectImproveInner = records.get(0);
  398. List<BehospitalCodeDetail> behospitalCodeDetails = entryDefectImproveInner.getBehospitalCodeInfos();
  399. for (BehospitalCodeDetail behospitalCodeDetail : behospitalCodeDetails) {
  400. List<QcResultDetailInfo> qcResultDetailInfos = behospitalCodeDetail.getQcResultDetailInfos();
  401. Set<String> totalSet = new HashSet<String>();
  402. Set<String> improveleSet = new HashSet<String>();
  403. for (QcResultDetailInfo qcResultDetailInfo : qcResultDetailInfos) {
  404. String casesEntryIds = qcResultDetailInfo.getCasesEntryIds();
  405. totalSet = getSetEntry(casesEntryIds, totalSet);
  406. }
  407. QcResultDetailInfo qcResultDetailInfo = qcResultDetailInfos.get(qcResultDetailInfos.size() - 1);
  408. if (null != qcResultDetailInfo && StringUtils.isNotBlank(qcResultDetailInfo.getCasesEntryIds())) {
  409. improveleSet = getSetEntry(qcResultDetailInfo.getCasesEntryIds(), improveleSet);
  410. }
  411. if ("0".equals(getEntryDefectImproveInnerVO.getTypeMark()) && totalSet.contains(getEntryDefectImproveInnerVO.getEntryId())) {
  412. behospitalInfoDTOS = getBehospitalInfoDTO(entryDefectImproveInner, behospitalCodeDetail, behospitalInfoDTOS);
  413. }
  414. if ("1".equals(getEntryDefectImproveInnerVO.getTypeMark()) && totalSet.contains(getEntryDefectImproveInnerVO.getEntryId())
  415. && !improveleSet.contains(getEntryDefectImproveInnerVO.getEntryId())) {
  416. behospitalInfoDTOS = getBehospitalInfoDTO(entryDefectImproveInner, behospitalCodeDetail, behospitalInfoDTOS);
  417. }
  418. if ("2".equals(getEntryDefectImproveInnerVO.getTypeMark()) && totalSet.contains(getEntryDefectImproveInnerVO.getEntryId())
  419. && improveleSet.contains(getEntryDefectImproveInnerVO.getEntryId())) {
  420. behospitalInfoDTOS = getBehospitalInfoDTO(entryDefectImproveInner, behospitalCodeDetail, behospitalInfoDTOS);
  421. }
  422. }
  423. }
  424. //导出操作
  425. if (getEntryDefectImproveInnerVO.getExportType() == 1L) {
  426. size = behospitalInfoDTOS.size();
  427. }
  428. page.setSize(size);
  429. page.setTotal(behospitalInfoDTOS.size());
  430. page.setCurrent(current);
  431. //分页操作
  432. List<BehospitalInfoDTO> behospitalInfoDTOList = page(behospitalInfoDTOS, size, current);
  433. if (ListUtil.isNotEmpty(behospitalInfoDTOList)) {
  434. //排序操作
  435. behospitalInfoDTOList = sortList(behospitalInfoDTOList, getEntryDefectImproveInnerVO.getAsc() != null ? getEntryDefectImproveInnerVO.getAsc() : getEntryDefectImproveInnerVO.getDesc() + " desc");
  436. }
  437. page.setRecords(behospitalInfoDTOList);
  438. return page;
  439. }
  440. /**
  441. * @Description: 数据封装
  442. * @Param: [entryDefectImproveInner, behospitalCodeDetail, qcResultDetailInfo, behospitalInfoDTOS]
  443. * @return: java.util.List<com.diagbot.dto.BehospitalInfoDTO>
  444. * @Author: cy
  445. * @Date: 2021/12/3
  446. */
  447. public List<BehospitalInfoDTO> getBehospitalInfoDTO(EntryDefectImproveInner entryDefectImproveInner, BehospitalCodeDetail behospitalCodeDetail,
  448. List<BehospitalInfoDTO> behospitalInfoDTOS) {
  449. BehospitalInfoDTO behospitalInfoDTO = new BehospitalInfoDTO();
  450. behospitalInfoDTO.setLevel(behospitalCodeDetail.getLevel());
  451. behospitalInfoDTO.setScoreRes(behospitalCodeDetail.getScoreRes());
  452. behospitalInfoDTO.setFileCode(behospitalCodeDetail.getFileCode());
  453. behospitalInfoDTO.setBehospitalCode(behospitalCodeDetail.getBehospitalCode());
  454. behospitalInfoDTO.setName(behospitalCodeDetail.getName());
  455. behospitalInfoDTO.setAge(behospitalCodeDetail.getAge());
  456. behospitalInfoDTO.setBehospitalDate(behospitalCodeDetail.getBehospitalDate());
  457. behospitalInfoDTO.setLeaveHospitalDate(behospitalCodeDetail.getLeaveHospitalDate());
  458. behospitalInfoDTO.setDoctorName(behospitalCodeDetail.getDoctorName());
  459. behospitalInfoDTO.setBehDeptName(entryDefectImproveInner.getBehDeptName());
  460. behospitalInfoDTO.setGradeTime(behospitalCodeDetail.getGradeTime());
  461. behospitalInfoDTOS.add(behospitalInfoDTO);
  462. return behospitalInfoDTOS;
  463. }
  464. public void getDefectImproveInnerByExport(HttpServletResponse response, GetEntryDefectImproveInnerVO
  465. getEntryDefectImproveInnerVO) {
  466. getEntryDefectImproveInnerVO.setSearchCount(false);
  467. getEntryDefectImproveInnerVO.setExportType(1L);
  468. String fileName = "条目缺陷改善统计病历列表.xls";
  469. IPage<BehospitalInfoDTO> page = this.getEntryDefectImproveInner(getEntryDefectImproveInnerVO);
  470. ExcelUtils.exportExcelUser(page.getRecords(), null, "sheet1", BehospitalInfoDTO.class, fileName, response);
  471. }
  472. /**
  473. * 增加全院记录
  474. *
  475. * @param records
  476. * @return
  477. */
  478. public GetQcClickDTO getGlobleTitle(List<GetQcClickDTO> records) {
  479. GetQcClickDTO item = new GetQcClickDTO();
  480. if (ListUtil.isEmpty(records)) {
  481. return null;
  482. }
  483. //缺陷总数
  484. Integer singleMode = records
  485. .stream()
  486. .map(GetQcClickDTO::getSingleModeNum)
  487. .reduce(0, Integer::sum);
  488. if (singleMode == null) {
  489. singleMode = 0;
  490. }
  491. Integer totalMode = records
  492. .stream()
  493. .map(GetQcClickDTO::getTotalModeNum)
  494. .reduce(0, Integer::sum);
  495. if (totalMode == null) {
  496. totalMode = 0;
  497. }
  498. item.setDeptName("全院");
  499. item.setSingleModeNum(singleMode);
  500. item.setTotalModeNum(totalMode);
  501. return item;
  502. }
  503. private void clickPageSet(GetQcClickVO getQcClickVO) {
  504. //入参验证
  505. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
  506. Date startDate = null;
  507. Date endDate = null;
  508. try {
  509. startDate = simpleDateFormat.parse(getQcClickVO.getStartDate());
  510. endDate = simpleDateFormat.parse(getQcClickVO.getEndDate());
  511. } catch (ParseException e) {
  512. e.printStackTrace();
  513. }
  514. if (DateUtil.after(startDate, endDate)) {
  515. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
  516. }
  517. getQcClickVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
  518. }
  519. private void clickInnerPageSet(GetQcClickInnerPageVO getQcClickInnerPageVO) {
  520. //入参验证
  521. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
  522. Date startDate = null;
  523. Date endDate = null;
  524. try {
  525. startDate = simpleDateFormat.parse(getQcClickInnerPageVO.getStartDate());
  526. endDate = simpleDateFormat.parse(getQcClickInnerPageVO.getEndDate());
  527. } catch (ParseException e) {
  528. e.printStackTrace();
  529. }
  530. if (DateUtil.after(startDate, endDate)) {
  531. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
  532. }
  533. getQcClickInnerPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
  534. }
  535. private void entryDefectSet(GetEntryDefectImproveVO getEntryDefectImproveVO) {
  536. getEntryDefectImproveVO.setCurrent(1L);
  537. getEntryDefectImproveVO.setSize(Long.MAX_VALUE);
  538. //入参验证
  539. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
  540. Date startDate = null;
  541. Date endDate = null;
  542. try {
  543. startDate = simpleDateFormat.parse(getEntryDefectImproveVO.getStartDate());
  544. endDate = simpleDateFormat.parse(getEntryDefectImproveVO.getEndDate());
  545. } catch (ParseException e) {
  546. e.printStackTrace();
  547. }
  548. if (DateUtil.after(startDate, endDate)) {
  549. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
  550. }
  551. getEntryDefectImproveVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
  552. }
  553. private void entryDefectInnerSet(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
  554. getEntryDefectImproveInnerVO.setCurrent(1L);
  555. getEntryDefectImproveInnerVO.setSize(Long.MAX_VALUE);
  556. //入参验证
  557. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
  558. Date startDate = null;
  559. Date endDate = null;
  560. try {
  561. startDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getStartDate());
  562. endDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getEndDate());
  563. } catch (ParseException e) {
  564. e.printStackTrace();
  565. }
  566. if (DateUtil.after(startDate, endDate)) {
  567. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
  568. }
  569. if (StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeStart())
  570. && StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeEnd())
  571. ) {
  572. Date chTimeStartDate = null;
  573. Date chTimeEndDate = null;
  574. try {
  575. chTimeStartDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
  576. chTimeEndDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
  577. } catch (ParseException e) {
  578. e.printStackTrace();
  579. }
  580. if (DateUtil.after(chTimeStartDate, chTimeEndDate)) {
  581. throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "病历核查开始时间必须小于结束时间!");
  582. }
  583. }
  584. getEntryDefectImproveInnerVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
  585. }
  586. }