陈昶聿
7 小时以前 4f1618f0df5c8ac19970f3bf0efa218b770cfb61
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -1,6 +1,8 @@
package com.ruoyi.web.controller.smartor;
import com.github.pagehelper.ISelect;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ruoyi.common.annotation.AddOrgId;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
@@ -13,6 +15,7 @@
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.PreachFormEnum;
import com.ruoyi.common.enums.SendStateEnum;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DtoConversionUtils;
@@ -20,6 +23,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import com.ruoyi.quartz.service.ICollectHISService;
import com.ruoyi.quartz.task.RyTask;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserDeptService;
@@ -81,6 +85,9 @@
    @Autowired
    private RyTask ryTask;
    @Autowired
    private ICollectHISService collectHISService;
    @Value("${spring.profiles.active}")
    private String active;
@@ -226,6 +233,10 @@
            for (ServiceSubtaskExport serviceSubtaskExport : serviceSubtaskExports) {
                String pf = PreachFormEnum.getDescByCode(serviceSubtaskExport.getPreachform());
                serviceSubtaskExport.setPreachform(pf);
                if(serviceSubtaskExport.getSendstate() != null) {
                    String stName = SendStateEnum.getDescByCode("" + serviceSubtaskExport.getSendstate());
                    serviceSubtaskExport.setStName(stName);
                }
                //计算出院天数
                if (!Objects.isNull(serviceSubtaskExport.getEndtime())) {
@@ -397,6 +408,7 @@
        ivrTaskVO.setCreateBy(user.getNickName());
        ivrTaskVO.setUpdateBy(user.getNickName());
        ivrTaskVO.setOrgid(user.getOrgid());
        ivrTaskVO.setCampusid(user.getCampusid());
        return success(serviceSubtaskService.insertOrUpdateTask(ivrTaskVO));
    }
@@ -408,12 +420,21 @@
        return toAjax(serviceSubtaskService.updateServiceSubtask(serviceSubtask));
    }
    @ApiOperation("修改子任务模板")
    @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
    @PostMapping("/updateTemplate")
    public AjaxResult updateTemplate(@RequestBody ServiceSubtaskTemplateVO serviceSubtaskTemplateVO) {
        serviceSubtaskTemplateVO.setUpdateBy(getLoginUser().getUser().getNickName());
        return toAjax(serviceSubtaskService.updateTemplate(serviceSubtaskTemplateVO));
    }
    @ApiOperation("新增子任务")
    @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
    @PostMapping("/addSubTask")
    public AjaxResult addSubTask(@RequestBody ServiceSubtask serviceSubtask) {
        SysUser user = getLoginUser().getUser();
        if (ObjectUtils.isNotEmpty(user)) serviceSubtask.setOrgid(user.getOrgid());
        if (ObjectUtils.isNotEmpty(user)) serviceSubtask.setCampusid(user.getCampusid());
        return toAjax(serviceSubtaskService.insertServiceSubtask(serviceSubtask));
    }
@@ -423,6 +444,7 @@
    public AjaxResult addSubTaskAgain(@RequestBody ServiceSubtask serviceSubtask) {
        SysUser user = getLoginUser().getUser();
        if (ObjectUtils.isNotEmpty(user)) serviceSubtask.setOrgid(user.getOrgid());
        if (ObjectUtils.isNotEmpty(user)) serviceSubtask.setCampusid(user.getCampusid());
        return success(serviceSubtaskService.addSubTaskAgain(serviceSubtask));
    }
@@ -526,6 +548,33 @@
        Integer offset = PageUtils.getOffset(serviceSubtaskCountReq.getPageNum(), serviceSubtaskCountReq.getPageSize());
        serviceSubtaskCountReq.setPageNum(offset);
        Integer statisticaltype = serviceSubtaskCountReq.getStatisticaltype();
        if(ObjectUtils.isNotEmpty(statisticaltype)){
            SysUser user = getLoginUser().getUser();
            if(statisticaltype==1){
                if(CollectionUtils.isEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())){
                    //全部病区
                    String hospInfo = user.getHospInfo();
                    Gson gson = new Gson();
                    // 3. 定义 List 类型(核心)
                    TypeToken<List<String>> typeToken = new TypeToken<List<String>>() {};
                    List<String> leavehospitaldistrictcodes = gson.fromJson(hospInfo, typeToken.getType());
                    serviceSubtaskCountReq.setLeavehospitaldistrictcodes(leavehospitaldistrictcodes);
                }
            }else if(statisticaltype==2){
                if(CollectionUtils.isEmpty(serviceSubtaskCountReq.getDeptcodes())){
                    //全部科室
                    String deptInfo = user.getDeptInfo();
                    Gson gson = new Gson();
                    // 3. 定义 List 类型(核心)
                    TypeToken<List<String>> typeToken = new TypeToken<List<String>>() {};
                    List<String> deptCodes = gson.fromJson(deptInfo, typeToken.getType());
                    serviceSubtaskCountReq.setDeptcodes(deptCodes);
                }
            }
        }
        String followUpCountStyle = configService.selectConfigByKey("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
        if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
            serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
@@ -536,6 +585,31 @@
        serviceSubtaskCountReq.setPageSize(null);
        List<ServiceSubtaskStatistic> sfStatistics = serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq);
        return getDataTable4(CollectionUtils.isEmpty(sfStatistics) ? sfStatistics.size() : 0, serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq));
    }
    /**
     * 获取专病随访统计比例
     */
    @ApiOperation("获取专病随访统计比例")
    @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
    @PostMapping("/getSpecialSfStatistics")
    public Map<String, Object> getSpecialSfStatistics(@RequestBody ServiceSubtaskCountReq serviceSubtaskCountReq) {
        if (CollectionUtils.isEmpty(serviceSubtaskCountReq.getServiceType())) {
            return error("服务类型不能为空");
        }
        Integer offset = PageUtils.getOffset(serviceSubtaskCountReq.getPageNum(), serviceSubtaskCountReq.getPageSize());
        serviceSubtaskCountReq.setPageNum(offset);
        String followUpCountStyle = configService.selectConfigByKey("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
        if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
            serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
        } else {
            serviceSubtaskCountReq.setFollowUpCountStyle("1");
        }
        serviceSubtaskCountReq.setPageNum(null);
        serviceSubtaskCountReq.setPageSize(null);
        List<ServiceSubtaskStatistic> sfStatistics = serviceSubtaskService.getSpecialSfStatistics(serviceSubtaskCountReq);
        return getDataTable4(CollectionUtils.isEmpty(sfStatistics) ? sfStatistics.size() : 0, serviceSubtaskService.getSpecialSfStatistics(serviceSubtaskCountReq));
    }
    /**
@@ -584,25 +658,6 @@
        return success(serviceStatistics);
    }
    /**
     * 随访异常统计导出
     */
    //@PreAuthorize("@ss.hasPermi('system:taskcall:export')")
    @Log(title = "随访统计导出", businessType = BusinessType.EXPORT)
    @PostMapping("/getSfStatisticsIsAbnormalExport")
    public void getSfStatisticsIsAbnormalExport(HttpServletResponse response, ServiceSubtaskCountReq serviceSubtaskCountReq) {
        List<ServiceSubtaskIsAbnormalStatistic> sfStatistics = serviceSubtaskService.getSfStatisticsIsAbnormalExport(serviceSubtaskCountReq);
        ExcelUtil<ServiceSubtaskIsAbnormalStatistic> util = new ExcelUtil<ServiceSubtaskIsAbnormalStatistic>(ServiceSubtaskIsAbnormalStatistic.class);
        String sheetName = "";
        String fileName = "";
        if (active.equals("ls") || active.equals("druid")) {
            fileName = sheetName = LocalDate.now().getMonthValue() + "月出院随访异常统计表";
            util.exportExcelWithFileName(response, sfStatistics, sheetName, fileName);
        } else {
            sheetName = "随访异常统计导出";
            util.exportExcel(response, sfStatistics, sheetName);
        }
    }
    /**
     * 获取随访统计比例
@@ -617,6 +672,63 @@
        return success(serviceSubtaskService.getSfStatisticsJoydetails(serviceSubtaskCountReq));
    }
    /**
     * 获取随访统计超链接
     * dischargeCountInfo
     * followUpNeededAllInfo - sendstate != 4 (1,2,3,5,6,7)
     * nonFollowUpInfo - sendstate = 4
     * needFollowUpInfo - visitCount = 1 && sendstate != 4
     * pendingFollowUpInfo - visitCount = 1 && sendstate = 2
     * followUpSuccessInfo - visitCount = 1 && sendstate = 6
     * followUpFailInfo - visitCount = 1 && (sendstate = 5 || sendstate = 7)
     * manualInfo - visitCount = 1 && currentPreachForm = "1"
     * voiceInfo - visitCount = 1 && currentPreachForm = "3"
     * smsInfo - visitCount = 1 && currentPreachForm = "4"
     * wechatInfo - visitCount = 1 && currentPreachForm = "5"
     * abnormalInfo - visitCount = 1 && excep = "1"
     * needFollowUpAgainInfo - visitCount > 1 && sendstate != 4
     * pendingFollowUpAgainInfo -  visitCount > 1 && sendstate = 2
     * followUpSuccessAgainInfo - visitCount > 1 && sendstate =6
     * followUpFailAgainInfo - visitCount > 1 && (sendstate = 5 || sendstate = 7)
     * manualAgainInfo - visitCount > 1 && currentPreachForm = "1"
     * voiceAgainInfo - visitCount > 1 && currentPreachForm = "3"
     * smsAgainInfo - visitCount > 1 && currentPreachForm = "4"
     * wechatAgainInfo -  visitCount > 1 && currentPreachForm = "5"
     * abnormalAgainInfo- visitCount > 1 && excep = "1"
     * taskSituation1Info - taskSituation = 1
     * taskSituation2Info - taskSituation = 2
     * taskSituation3Info - taskSituation = 3
     * taskSituation4Info - taskSituation = 4
     * taskSituation5Info - taskSituation = 5
     * taskSituation6Info - taskSituation = 7
     * filterCountList - taskSituation = 6 && sendstate = 4
     *
     */
    @ApiOperation("获取随访统计超链接")
    @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
    @PostMapping("/getSfStatisticsHyperlink")
    public AjaxResult getSfStatisticsHyperlink(@RequestBody ServiceSubtaskCountReq serviceSubtaskCountReq) {
        LoginUser loginUser = getLoginUser();
        String orgid = loginUser.getUser().getOrgid();
        String configKey = serviceSubtaskCountReq.getConfigKey();
        if (StringUtils.isNotEmpty(configKey)) {
            String configValue = configService.selectConfigByKey(configKey, orgid);
            serviceSubtaskCountReq.setConfigValue(configValue);
            if (StringUtils.isEmpty(configValue)) {
                String logInfo = "getSfStatisticsCount-参数 " + configKey + " 未配置, 请配置好后重试";
                log.error(logInfo);
                return error(logInfo);
            }
        }
        String followUpCountStyle = configService.selectConfigByKey("followUpCountStyle", orgid);
        if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
            serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
        } else {
            serviceSubtaskCountReq.setFollowUpCountStyle("1");
        }
        return success(serviceSubtaskService.getSfStatisticsHyperlink(serviceSubtaskCountReq));
    }
    /**
     * 延续护理统计
@@ -661,7 +773,8 @@
            log.error(logInfo);
            return error(logInfo);
        }
        return success(serviceSubtaskService.getSfStatisticsScript(serviceSubtaskCountReq));
        List<ServiceSubtaskStatistic> serviceSubtaskStatistics = serviceSubtaskService.getSfStatisticsScript(serviceSubtaskCountReq);
        return success(serviceSubtaskStatistics);
    }
    @ApiOperation("获取随访分类统计明细详情")
@@ -763,6 +876,16 @@
    @PostMapping("/test")
    public void test() {
        ryTask.longTaskSend();
        ryTask.dealOutHospInfo();
    }
    @PostMapping("/syncMedInhospForShiyi")
    public void syncMedInhospForShiyi(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
        collectHISService.syncMedInhosp(startTime, endTime);
    }
    @PostMapping("/syncMedOperForShiyi")
    public void syncMedOperForShiyi(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
        collectHISService.syncOper(startTime, endTime);
    }
}