wjli
2023-05-11 a067fdbf6b1374a1402096c722257575916eab99
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java
@@ -5,12 +5,15 @@
import cn.exrick.xboot.core.common.utils.ResultUtil;
import cn.exrick.xboot.core.common.vo.PageVo;
import cn.exrick.xboot.core.common.vo.Result;
import cn.exrick.xboot.core.entity.User;
import cn.exrick.xboot.core.service.UserService;
import cn.exrick.xboot.your.entity.*;
import cn.exrick.xboot.your.service.*;
import cn.exrick.xboot.your.util.HaiKangPost;
import cn.exrick.xboot.your.vo.AlarmVo;
import cn.exrick.xboot.your.vo.PreviewURLsVo;
import cn.exrick.xboot.your.vo.TalkURLsVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -20,9 +23,11 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -64,6 +69,15 @@
    @Autowired
    private ICustomerService iCustomerService;
    @Autowired
    private IOrderTask2Service iOrderTask2Service;
    @Autowired
    private UserService userService;
    @Autowired
    private IDuoZhengService iDuoZhengService;
    @RequestMapping(value = "/getIndex1", method = RequestMethod.GET)
    @ApiOperation(value = "获取首页数据")
@@ -286,25 +300,90 @@
    @ApiOperation(value = "获取配送分析详情")
    public Result<Object> getYiHuDuoZheng() {
        List<Customer> list = iCustomerService.getYiHuDuoZheng();
//        List<Customer> list = iCustomerService.getYiHuDuoZheng();
//        Map<String,Object> map = new HashMap<>();
//        map.put("name","一户多证");
//        List<Object> childrens = new ArrayList<>();
//        for(Customer c:list){
//            Map<String,Object> map2 = new HashMap<>();
//            map2.put("name",c.getName());
//
//            List<Object> names = new ArrayList<>();
//            Map<String,Object> map3 = new HashMap<>();
//            map3.put("name",c.getCode());
//            names.add(map3);
//
//            map2.put("children",names);
//
//            childrens.add(map2);
//        }
//        map.put("children",childrens);
        List<String> list = iDuoZhengService.getNames();
        Map<String,Object> map = new HashMap<>();
        map.put("name","一户多证");
        List<Object> childrens = new ArrayList<>();
        for(Customer c:list){
        for(String c:list){
            Map<String,Object> map2 = new HashMap<>();
            map2.put("name",c.getName());
            map2.put("name",c);
            List<Object> names = new ArrayList<>();
            Map<String,Object> map3 = new HashMap<>();
            map3.put("name",c.getCode());
            names.add(map3);
            QueryWrapper<DuoZheng> wp = new QueryWrapper<>();
            wp.eq("name",c);
            List<DuoZheng> list1 = iDuoZhengService.list(wp);
            for(DuoZheng dz:list1){
                Map<String,Object> map3 = new HashMap<>();
                map3.put("name",dz.getCustomerName());
                names.add(map3);
            }
            map2.put("children",names);
            childrens.add(map2);
        }
        map.put("children",childrens);
        return new ResultUtil<Object>().setData(map);
    }
    @RequestMapping(value = "/test", method = RequestMethod.GET)
    @ApiOperation(value = "测试接口,没用")
    public String test(){
        List<OrderTask> list = iOrderTaskService.list();
        List<OrderTask2> list2 = new ArrayList<>();
        for(OrderTask orderTask:list){
            OrderTask2 orderTask2 = new OrderTask2();
            BeanUtil.copyProperties(orderTask,orderTask2);
            if(StrUtil.isNotEmpty(orderTask.getUserId())){
                orderTask2.setUserName(getUser(orderTask.getUserId()));
            }
            if(StrUtil.isNotEmpty(orderTask.getCustomerId())){
                orderTask2.setCustomerName(getCustomer(orderTask.getCustomerId()));
            }
            list2.add(orderTask2);
        }
        iOrderTask2Service.saveBatch(list2);
        return list.size()+"ok";
    }
    private String getUser(String id){
        User user = userService.get(id);
        if(user!=null){
            return user.getNickname();
        }else{
            return null;
        }
    }
    private String getCustomer(String id){
        Customer customer = iCustomerService.getById(id);
        if(customer!=null){
            return customer.getName();
        }else{
            return null;
        }
    }
}