Pu Zhibing
3 天以前 5dacdee9b54c78372b68140e2b068d03a620eab9
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java
@@ -1,7 +1,5 @@
package com.stylefeng.guns.modular.system.controller.general;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
@@ -20,6 +18,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@@ -36,28 +35,28 @@
    @Autowired
    private ITDriverService tDriverService;
    @Autowired
    private ITOrderTaxiService tOrderTaxiService;
    @Autowired
    private ITCarService tCarService;
    @Autowired
    private ITTaxiCardService taxiCardService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    @Autowired
    private IUserService userService;
    @Autowired
    private ITCompanyService tCompanyService;
    @Autowired
    private ITCarBrandService carBrandService;
    @Autowired
    private ITCarModelService carModelService;
@@ -66,36 +65,37 @@
    @Autowired
    private ITOrderPrivateCarService itOrderPrivateCarService;
    @Autowired
    private ITOrderCrossCityService itOrderCrossCityService;
    @Autowired
    private ITOrderLogisticsService itOrderLogisticsService;
    @Autowired
    private IDriverOnlineService driverOnlineService;
    @Resource
    private ShiroExtUtil shiroExtUtil;
    @RequestMapping("/openNetCarInfo")
    public Object openNetCarInfo(Integer id, Model model){
    public Object openNetCarInfo(Integer id, Model model) {
        model.addAttribute("id", id);
        return "/netCarInfo.html";
    }
    @RequestMapping("/showDriverOnline")
    public String showDriverOnline(){
    public String showDriverOnline() {
        return "/driverOnline.html";
    }
    @ResponseBody
    @PostMapping("/getSumData")
    public Object getSumData(Integer companyId, Date addDate, Date start, Date end){
        Integer id = ShiroExtUtil.getUser().getId();
    public Object getSumData(Integer companyId, Date addDate, Date start, Date end) {
        Integer id = shiroExtUtil.getUser().getId();
        User user = userService.selectById(id);
        if(companyId == null && user.getRoleType() != 1){
        if (companyId == null && user.getRoleType() != 1) {
            companyId = user.getObjectId();
        }
        Map<String, Object> map = new HashMap<>();
@@ -104,7 +104,7 @@
        Calendar calendar2 = Calendar.getInstance();
        Calendar calendar3 = Calendar.getInstance();
        Calendar calendar4 = Calendar.getInstance();
        if(addDate == null){
        if (addDate == null) {
            calendar1.setTime(date);
            calendar2.setTime(date);
        }else{
@@ -130,45 +130,44 @@
        calendar4.set(Calendar.HOUR_OF_DAY, 23);
        calendar4.set(Calendar.MINUTE, 59);
        calendar4.set(Calendar.SECOND, 59);
        //【今日运行情况】
        Map<String, Object> map1 = new HashMap<>();
        Wrapper<TUser> ne = new EntityWrapper<TUser>().between("insertTime", calendar1.getTime(), calendar2.getTime()).ne("flag", 3);
        if(companyId != null){
        if (companyId != null) {
            ne.eq("companyId", companyId);
        }
        int i = tUserService.selectCount(ne);
        map1.put("passengerInfo", i);  //新增用户
        Wrapper<TDriver> ne1 = new EntityWrapper<TDriver>().ne("state", 1).eq("authState", 2).ne("flag", 3);
        if(companyId != null){
        if (companyId != null) {
            ne1.eq("companyId", companyId).or().eq("franchiseeId", companyId);
        }
        List<TDriver> tDrivers = tDriverService.selectList(ne1);
        int size = driverOnlineService.queryOnlineDriverCount(null, null);
        map1.put("netcardriver", size);  //在线司机
        int count = tDriverService.selectCount(new EntityWrapper<TDriver>().ne("state", 1).eq("authState", 2).ne("flag", 3));
        map1.put("netcardriver", count);  //在线司机
        Wrapper<TOrderTaxi> travelTime1 = new EntityWrapper<TOrderTaxi>().between("insertTime", calendar1.getTime(), calendar2.getTime());
        if(companyId != null){
        if (companyId != null) {
            travelTime1.eq("companyId", companyId);
        }
        int i1 = tOrderTaxiService.selectCount(travelTime1);
        map1.put("orderDetail2", i1);  //出租车订单
        Wrapper<TOrderPrivateCar> zcTodayTme = new EntityWrapper<TOrderPrivateCar>().between("insertTime", calendar1.getTime(), calendar2.getTime());
        if(companyId != null){
        if (companyId != null) {
            zcTodayTme.eq("companyId", companyId);
        }
        int zcTodayNum = itOrderPrivateCarService.selectCount(zcTodayTme);
        map1.put("orderDetail1", zcTodayNum);  //快车订单
        Wrapper<TOrderCrossCity> kcTodayTme = new EntityWrapper<TOrderCrossCity>().between("insertTime", calendar1.getTime(), calendar2.getTime());
        if(companyId != null){
        if (companyId != null) {
            kcTodayTme.eq("companyId", companyId);
        }
        int kcTodayNum = itOrderCrossCityService.selectCount(kcTodayTme);
        map1.put("orderDetail3", kcTodayNum);  //跨城订单
        Wrapper<TOrderLogistics> tcxTodayTme = new EntityWrapper<TOrderLogistics>().between("insertTime", calendar1.getTime(), calendar2.getTime());
        if(companyId != null){
            tcxTodayTme.eq("companyId", companyId);
@@ -217,7 +216,7 @@
        Double allIncomeMoney = tOrderTaxiService.getAllIncomeMoney(companyId, null, null);
        ///   购买打车卡产生的收益
        Double allCardMoney = taxiCardService.AllCardMoney(ShiroExtUtil.getUser().getObjectId());
        Double allCardMoney = taxiCardService.AllCardMoney(shiroExtUtil.getUser().getObjectId());
        if(allCardMoney==null){
            allCardMoney=0.0;
        }
@@ -384,23 +383,25 @@
    @ResponseBody
    @PostMapping("/getDriverPosition")
    public Object getDriverPosition(Integer companyId){
        Integer id = ShiroExtUtil.getUser().getId();
    public Object getDriverPosition(Integer companyId) {
        Integer id = shiroExtUtil.getUser().getId();
        User user = userService.selectById(id);
        if(companyId == null && user.getRoleType() != 1){
        if (companyId == null && user.getRoleType() != 1) {
            companyId = user.getObjectId();
        }
        Wrapper<TDriver> ne = new EntityWrapper<TDriver>().eq("authState", 2).eq("state", 2).ne("flag", 3);
        if(companyId != null){
        if (companyId != null) {
            ne.eq("companyId", companyId).or().eq("franchiseeId", companyId);
        }
        List<TDriver> tDrivers = tDriverService.selectList(ne);
        Map<String, Object> map = new HashMap<>();
        List<Object> list = new ArrayList<>();
        for(TDriver tDriver : tDrivers){
        System.out.println(tDrivers.toString());
        for (TDriver tDriver : tDrivers) {
            Map<String, Object> d = new HashMap<>();
            String value = (String)redisTemplate.opsForValue().get("DRIVER" + tDriver.getId());
            if(ToolUtil.isEmpty(value)){
            String value = (String) redisTemplate.opsForValue().get("DRIVER" + tDriver.getId());
            System.out.println(value);
            if (ToolUtil.isEmpty(value)) {
                continue;
            }
            d.put("driver", tDriver);
@@ -453,15 +454,15 @@
    @ResponseBody
    @PostMapping("/getCompanyInfoByUserId")
    public Object getCompanyInfoByUserId(){
        Integer id = ShiroExtUtil.getUser().getId();
    public Object getCompanyInfoByUserId() {
        Integer id = shiroExtUtil.getUser().getId();
        User user = userService.selectById(id);
        companys = new ArrayList<>();
        List<TCompany> ids = new ArrayList<>();
        TCompany tCompany = null;
        if(user.getRoleType() == 1 && user.getObjectId() == null){
        if (user.getRoleType() == 1 && user.getObjectId() == null) {
            tCompany = tCompanyService.selectById(1);
        }else{
        } else {
            tCompany = tCompanyService.selectById(user.getObjectId());
        }
        ids.add(tCompany);