zjh
2023-10-31 203250cd8eca569cc51499058c2a602d192c7e39
zjh 2023/10/31--1
3个文件已修改
171 ■■■■■ 已修改文件
ltkj-admin/src/main/java/com/ltkj/web/controller/service/TjSysAsyncServiceImpl.java 140 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjHomePageController.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjAsyncService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/service/TjSysAsyncServiceImpl.java
@@ -12,6 +12,7 @@
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.vodomain.AddNewReservationConfirm;
import com.ltkj.hosp.vodomain.PieChartVo;
import com.ltkj.hosp.vodomain.QjDomainVo;
import com.ltkj.mall.mallOrderUtils.TjConstants;
import com.ltkj.system.service.ISysUserService;
@@ -945,6 +946,145 @@
    }
    @Override
    @Async("async")
    public void getLineChart() {
        redisCache.setCacheObject("getLineChart",getLineCharts());
    }
    @Override
    @Async("async")
    public void getPieChart() {
        redisCache.setCacheObject("getPieChart",getPieCharts());
    }
    //首页饼状图登记人数接口
    private AjaxResult getPieCharts() {
        Map<String, Object> map = new HashMap<>();
        //获取体检登记数
        LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
        wq0.between(TjOrder::getCreateTime, DateUtil.lastMonth(), DateUtil.now());
        List<TjOrder> orderCountList = orderService.list(wq0);
        if (null != orderCountList && orderCountList.size() > 0) {
            List<PieChartVo> pieChartVoList = getTjorderCountMap(orderCountList);
            map.put("tjdj", pieChartVoList);
        } else {
            map.put("tjdj", 0);
        }
        //获取体检异常数
        LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
        wq1.between(TjOrder::getFinishTime, DateUtil.lastMonth(), DateUtil.now());
        wq1.eq(TjOrder::getCheckStatus, 1);
        List<TjOrder> orderAbnormalCountList = orderService.list(wq1);
        if (null != orderAbnormalCountList && orderAbnormalCountList.size() > 0) {
            List<PieChartVo> pieChartVoList = getTjorderAbnormalCountMap(orderAbnormalCountList);
            map.put("tjyc", pieChartVoList);
        } else {
            map.put("tjyc", 0);
        }
        return AjaxResult.success(map);
    }
    //首页折线图数据
    private AjaxResult getLineCharts() {
        List<Map<Object, Object>> line = orderService.getLine();
        Collections.reverse(line);
        return AjaxResult.success("折线图数据", line);
    }
    //获取体检登记数
    private List<PieChartVo> getTjorderCountMap(List<TjOrder> orderList) {
        int a = 0;
        int b = 0;
        int c = 0;
        int d = 0;
        int e = 0;
        Map<String, Object> map = null;
        for (TjOrder tjOrder : orderList) {
            map = new HashMap<>();
            TjCustomer customer = tjCustomerService.getById(tjOrder.getUserId());
            if (null != customer) {
                int age = DateUtil.ageOfNow(customer.getCusBrithday());
                if (age >= 0 && age <= 3) {
                    a += 1;
                } else if (age > 3 && age <= 16) {
                    b += 1;
                } else if (age > 16 && age <= 40) {
                    c += 1;
                } else if (age > 40 && age <= 60) {
                    d += 1;
                } else {
                    e += 1;
                }
            }
            map.put("0-3岁", a);
            map.put("3-16岁", b);
            map.put("16-40岁", c);
            map.put("40-60岁", d);
            map.put("60岁以上", e);
        }
        List<PieChartVo> pieChartVoList = new ArrayList<>();
        assert map != null;
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            PieChartVo pieChartVo = new PieChartVo();
            pieChartVo.setName(entry.getKey());
            pieChartVo.setCount((Integer) entry.getValue());
            pieChartVoList.add(pieChartVo);
        }
        return pieChartVoList;
    }
    //获取体检异常数
    private List<PieChartVo> getTjorderAbnormalCountMap(List<TjOrder> orderList) {
        int a = 0;
        int b = 0;
        int c = 0;
        int d = 0;
        int e = 0;
        Map<String, Object> map = null;
        for (TjOrder tjOrder : orderList) {
            map = new HashMap<>();
            LambdaQueryWrapper<TjOrderDetail> wq = new LambdaQueryWrapper<>();
            wq.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId());
            wq.eq(TjOrderDetail::getExceptionDesc, 1);
            List<TjOrderDetail> list = tjOrderDetailService.list(wq);
            if (null != list && list.size() > 0) {
                TjCustomer customer = tjCustomerService.getById(tjOrder.getUserId());
                if (null != customer) {
                    int age = DateUtil.ageOfNow(customer.getCusBrithday());
                    if (age >= 0 && age <= 3) {
                        a += 1;
                    } else if (age > 3 && age <= 16) {
                        b += 1;
                    } else if (age > 16 && age <= 40) {
                        c += 1;
                    } else if (age > 40 && age <= 60) {
                        d += 1;
                    } else {
                        e += 1;
                    }
                }
                map.put("0-3岁", a);
                map.put("3-16岁", b);
                map.put("16-40岁", c);
                map.put("40-60岁", d);
                map.put("60岁以上", e);
            }
        }
        List<PieChartVo> pieChartVoList = new ArrayList<>();
        assert map != null;
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            PieChartVo pieChartVo = new PieChartVo();
            pieChartVo.setName(entry.getKey());
            pieChartVo.setCount((Integer) entry.getValue());
            pieChartVoList.add(pieChartVo);
        }
        return pieChartVoList;
    }
    private List<DictSfxm> getDictSfxm() {
        List<DictSfxm> dictSfxms = dictSfxmService.getYjDictSfxmList();
        if (null != dictSfxms && dictSfxms.size() > 0) {
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjHomePageController.java
@@ -6,6 +6,7 @@
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.core.domain.entity.SysDept;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.common.utils.DateUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
@@ -42,6 +43,10 @@
    private ITjCustomerService customerService;
    @Resource
    private ITjProjectService projectService;
    @Resource
    private RedisCache redisCache;
    @Resource
    private TjAsyncService asyncService;
    @Resource
    private ISysDeptService deptService;
    @Resource
@@ -446,6 +451,14 @@
    @GetMapping("/getLineChart")
    @ApiOperation(value = "首页折线图数据")
    public AjaxResult getLineChart() {
        asyncService.getLineChart();
        if(redisCache.hasKey("getLineChart")){
            return redisCache.getCacheObject("getLineChart");
        }
        return getResult();
    }
    private AjaxResult getResult() {
        List<Map<Object, Object>> line = orderService.getLine();
        Collections.reverse(line);
        return AjaxResult.success("折线图数据", line);
@@ -454,6 +467,14 @@
    @GetMapping("/getPieChart")
    @ApiOperation(value = "首页饼状图登记人数接口")
    public AjaxResult getPieChart() {
        asyncService.getPieChart();
        if(redisCache.hasKey("getPieChart")){
            return redisCache.getCacheObject("getPieChart");
        }
        return getAjaxResult();
    }
    private AjaxResult getAjaxResult() {
        Map<String, Object> map = new HashMap<>();
        //获取体检登记数
@@ -477,6 +498,7 @@
        } else {
            map.put("tjyc", 0);
        }
        return AjaxResult.success(map);
    }
ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjAsyncService.java
@@ -86,4 +86,13 @@
    void getDictSfxms();
    void getOrderDetailByProParentId(String tjNumber,Map<String, Object> map,String proParentId);
    //首页折线图数据
    void getLineChart();
    //首页饼状图登记人数接口
    void getPieChart();
}