|
@@ -0,0 +1,227 @@
|
|
|
|
+package com.diagbot.facade;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.diagbot.dto.HospItemDTO;
|
|
|
|
+import com.diagbot.dto.HospNameDTO;
|
|
|
|
+import com.diagbot.dto.OptDTO;
|
|
|
|
+import com.diagbot.dto.OptHospDTO;
|
|
|
|
+import com.diagbot.entity.OptInfo;
|
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
|
+import com.diagbot.service.impl.OptInfoServiceImpl;
|
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
|
+import com.diagbot.util.HttpUtils;
|
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
|
+import com.diagbot.vo.HospitalVO;
|
|
|
|
+import com.diagbot.vo.OptHospPageVO;
|
|
|
|
+import com.diagbot.vo.OptHospVO;
|
|
|
|
+import com.diagbot.vo.OptVO;
|
|
|
|
+import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+/**
|
|
|
|
+ * @author wangfeng
|
|
|
|
+ * @Description:
|
|
|
|
+ * @date 2020-03-20 16:20
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class OptInfoFacade extends OptInfoServiceImpl {
|
|
|
|
+ @Autowired
|
|
|
|
+ DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OptInfoFacade optInfoFacade;
|
|
|
|
+
|
|
|
|
+ public Boolean saveOptOnfo(HospitalVO hospitalVO, String optType) {
|
|
|
|
+ OptInfo optInfo = new OptInfo();
|
|
|
|
+ Date now = DateUtil.now();
|
|
|
|
+ optInfo.setGmtModified(now);
|
|
|
|
+ optInfo.setGmtCreate(now);
|
|
|
|
+ optInfo.setIp(HttpUtils.getIpAddress());
|
|
|
|
+ optInfo.setHospitalCode(StringUtil.isNotBlank(hospitalVO.getHospitalCode()) ? hospitalVO.getHospitalCode() : "朗通通用");
|
|
|
|
+ optInfo.setOptType(optType);
|
|
|
|
+ optInfo.setSysType(hospitalVO.getSysType());
|
|
|
|
+ Boolean res = this.save(optInfo);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public OptDTO getOptSum(OptVO optVO) {
|
|
|
|
+ //入参验证
|
|
|
|
+ if (null != optVO && null != optVO.getStartDate()) {
|
|
|
|
+ optVO.setStartDate(DateUtil.getFirstTimeOfDay(optVO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (null != optVO && null != optVO.getEndDate()) {
|
|
|
|
+ optVO.setEndDate(DateUtil.getLastTimeOfDay(optVO.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != optVO && null != optVO.getStartDate() && null != optVO.getEndDate()) {
|
|
|
|
+ if (DateUtil.after(optVO.getStartDate(), optVO.getEndDate())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间大于结束时间!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != optVO && null != optVO.getSysType()) {
|
|
|
|
+ optVO.setSysType(optVO.getSysType());
|
|
|
|
+ }
|
|
|
|
+ //获取统计数据
|
|
|
|
+ OptDTO optDTO = new OptDTO();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> invokeParams = new HashMap<>();
|
|
|
|
+ invokeParams.put("optVO", optVO);
|
|
|
|
+ optDTO
|
|
|
|
+ = dataBeanAggregateQueryFacade.get("getAllOptSum", invokeParams, OptDTO.class);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // optDTO.setPvdto(this.getPV(optVO));
|
|
|
|
+ // optDTO.setPvSum(this.getPVSum(optVO));
|
|
|
|
+ // optDTO.setUvdto(this.getUV(optVO));
|
|
|
|
+ // optDTO.setUvSum(this.getUVSum(optVO));
|
|
|
|
+ // optDTO.setZzdto(this.getZZ(optVO));
|
|
|
|
+ // optDTO.setZzSum(this.getZZSum(optVO));
|
|
|
|
+ return optDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public OptDTO getOptSumNoDays(OptVO optVO) {
|
|
|
|
+ //入参验证
|
|
|
|
+ if (null != optVO && null != optVO.getStartDate()) {
|
|
|
|
+ optVO.setStartDate(DateUtil.getFirstTimeOfDay(optVO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (null != optVO && null != optVO.getEndDate()) {
|
|
|
|
+ optVO.setEndDate(DateUtil.getLastTimeOfDay(optVO.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != optVO && null != optVO.getStartDate() && null != optVO.getEndDate()) {
|
|
|
|
+ if (DateUtil.after(optVO.getStartDate(), optVO.getEndDate())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间大于结束时间!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != optVO && null != optVO.getSysType()) {
|
|
|
|
+ optVO.setSysType(optVO.getSysType());
|
|
|
|
+ }
|
|
|
|
+ //获取统计数据
|
|
|
|
+ OptDTO optDTO = new OptDTO();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> invokeParams = new HashMap<>();
|
|
|
|
+ invokeParams.put("optVO", optVO);
|
|
|
|
+ optDTO
|
|
|
|
+ = dataBeanAggregateQueryFacade.get("getAllOptSumNoDays", invokeParams, OptDTO.class);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // optDTO.setPvdto(this.getPV(optVO));
|
|
|
|
+ // optDTO.setPvSum(this.getPVSum(optVO));
|
|
|
|
+ // optDTO.setUvdto(this.getUV(optVO));
|
|
|
|
+ // optDTO.setUvSum(this.getUVSum(optVO));
|
|
|
|
+ // optDTO.setZzdto(this.getZZ(optVO));
|
|
|
|
+ // optDTO.setZzSum(this.getZZSum(optVO));
|
|
|
|
+ return optDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public OptHospDTO getOptSumHosp(OptVO optVO) {
|
|
|
|
+ //入参验证
|
|
|
|
+ if (null != optVO && null != optVO.getStartDate()) {
|
|
|
|
+ optVO.setStartDate(DateUtil.getFirstTimeOfDay(optVO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (null != optVO && null != optVO.getEndDate()) {
|
|
|
|
+ optVO.setEndDate(DateUtil.getLastTimeOfDay(optVO.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != optVO && null != optVO.getStartDate() && null != optVO.getEndDate()) {
|
|
|
|
+ if (DateUtil.after(optVO.getStartDate(), optVO.getEndDate())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间大于结束时间!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != optVO && null != optVO.getSysType()) {
|
|
|
|
+ optVO.setSysType(optVO.getSysType());
|
|
|
|
+ }
|
|
|
|
+ //获取统计数据
|
|
|
|
+ OptHospDTO optHospDTO = new OptHospDTO();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> invokeParams = new HashMap<>();
|
|
|
|
+ invokeParams.put("optVO", optVO);
|
|
|
|
+ optHospDTO
|
|
|
|
+ = dataBeanAggregateQueryFacade.get("getAllOptSumHosp", invokeParams, OptHospDTO.class);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return optHospDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public List<HospItemDTO> getOptSumHospNoDays(OptHospVO optHospVO) {
|
|
|
|
+ //入参验证
|
|
|
|
+ if (null != optHospVO && null != optHospVO.getStartDate()) {
|
|
|
|
+ optHospVO.setStartDate(DateUtil.getFirstTimeOfDay(optHospVO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (null != optHospVO && null != optHospVO.getEndDate()) {
|
|
|
|
+ optHospVO.setEndDate(DateUtil.getLastTimeOfDay(optHospVO.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != optHospVO && null != optHospVO.getStartDate() && null != optHospVO.getEndDate()) {
|
|
|
|
+ if (DateUtil.after(optHospVO.getStartDate(), optHospVO.getEndDate())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间大于结束时间!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != optHospVO && null != optHospVO.getSysType()) {
|
|
|
|
+ optHospVO.setSysType(optHospVO.getSysType());
|
|
|
|
+ }
|
|
|
|
+ return this.getHospitalPUZ(optHospVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public IPage<HospItemDTO> getOptSumHospNoDaysPageFac(OptHospPageVO optHospPageVO) {
|
|
|
|
+ //入参验证
|
|
|
|
+ if (null != optHospPageVO && null != optHospPageVO.getStartDate()) {
|
|
|
|
+ optHospPageVO.setStartDate(DateUtil.getFirstTimeOfDay(optHospPageVO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (null != optHospPageVO && null != optHospPageVO.getEndDate()) {
|
|
|
|
+ optHospPageVO.setEndDate(DateUtil.getLastTimeOfDay(optHospPageVO.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != optHospPageVO && null != optHospPageVO.getStartDate() && null != optHospPageVO.getEndDate()) {
|
|
|
|
+ if (DateUtil.after(optHospPageVO.getStartDate(), optHospPageVO.getEndDate())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间大于结束时间!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != optHospPageVO && null != optHospPageVO.getSysType()) {
|
|
|
|
+ optHospPageVO.setSysType(optHospPageVO.getSysType());
|
|
|
|
+ }
|
|
|
|
+ return getPageHospitalPUZ(optHospPageVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public HospNameDTO getAllHospitalName(){
|
|
|
|
+ HospNameDTO hospNameDTO = new HospNameDTO();
|
|
|
|
+ List<String> hospitalList = optInfoFacade.getAllHospital();
|
|
|
|
+ if(ListUtil.isNotEmpty(hospitalList)){
|
|
|
|
+ hospNameDTO.setHospitalCode(hospitalList);
|
|
|
|
+ }
|
|
|
|
+ return hospNameDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public HospNameDTO getAllHospitalNameWithLtFrist(){
|
|
|
|
+ HospNameDTO hospNameDTO = new HospNameDTO();
|
|
|
|
+ List<String> hospitalList = optInfoFacade.getAllHospital();
|
|
|
|
+ if(ListUtil.isNotEmpty(hospitalList)){
|
|
|
|
+ List<String> hospitalListNew = new ArrayList<>();
|
|
|
|
+ List<String> hospitalListFilter = hospitalList.stream().filter(r -> !"朗通通用".equals(r)).collect(Collectors.toList());
|
|
|
|
+ hospitalListNew.add("朗通通用");
|
|
|
|
+ hospitalListNew.addAll(hospitalListFilter);
|
|
|
|
+ hospNameDTO.setHospitalCode(hospitalListNew);
|
|
|
|
+ }
|
|
|
|
+ return hospNameDTO;
|
|
|
|
+ }
|
|
|
|
+}
|