From f0b4d0e6bc47a18f4e10ca4c007dcaa01c9c9647 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期二, 16 五月 2023 15:10:35 +0800 Subject: [PATCH] BUG修改 --- management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java | 117 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 96 insertions(+), 21 deletions(-) diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java index 55f20e3..bf1f4eb 100644 --- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java +++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java @@ -7,12 +7,14 @@ import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.modular.system.controller.resp.TBranchOfficeResp; import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; +import com.stylefeng.guns.modular.system.enums.StatusEnum; import com.stylefeng.guns.modular.system.model.*; -import com.stylefeng.guns.modular.system.service.ITRegionService; -import com.stylefeng.guns.modular.system.service.ITSystemConfigService; +import com.stylefeng.guns.modular.system.service.*; +import com.stylefeng.guns.modular.system.util.RedisUtil; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -21,8 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired; import com.stylefeng.guns.core.log.LogObjectHolder; import org.springframework.web.bind.annotation.RequestParam; -import com.stylefeng.guns.modular.system.service.ITBranchOfficeService; +import java.util.Date; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -46,12 +48,19 @@ @Autowired private ITRegionService tRegionService; + @Autowired + private ITDriverService tDriverService; + @Autowired + private ITDriverWorkService tDriverWorkService; + @Autowired + private RedisUtil redisUtil; /** * 跳转到首页 */ @RequestMapping("") - public String index() { + public String index(Model model) { + model.addAttribute("userType", Objects.requireNonNull(ShiroKit.getUser()).getRoleType()); return PREFIX + "tBranchOffice.html"; } @@ -115,22 +124,13 @@ * 跳转区域页面新增 */ @RequestMapping("/areaPageAdd") - public String areaPageAdd(Model model) { - List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); - model.addAttribute("provinceList",tRegions); - return PREFIX + "tBranchOfficeAreaAdd.html"; - } - - /** - * 跳转区域页面编辑 - */ - @RequestMapping("/areaPageUpdate") - public String areaPageUpdate(String area,String areaId,Model model) { + public String areaPageAdd(String area,String areaId,Model model) { + String[] split1 = areaId.split("/"); List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); model.addAttribute("provinceList",tRegions); List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); // 查询市 - List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", provinceIds)); + List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); model.addAttribute("cityList",tRegions1); // 查询区 @@ -148,7 +148,6 @@ model.addAttribute("districtName",""); } - String[] split1 = areaId.split("/"); model.addAttribute("provinceId",split1[0]); model.addAttribute("cityId",split1[1]); if(split1.length>2) { @@ -156,7 +155,55 @@ }else { model.addAttribute("districtId", ""); } + }else { + model.addAttribute("provinceName",""); + model.addAttribute("cityName","split[1]"); + model.addAttribute("districtName",""); + + model.addAttribute("provinceId",""); + model.addAttribute("cityId","split1[1]"); + model.addAttribute("districtId", ""); } + return PREFIX + "tBranchOfficeAreaAdd.html"; + } + + /** + * 跳转区域页面编辑 + */ + @RequestMapping("/areaPageUpdate") + public String areaPageUpdate(String area,String areaId,Model model) { + + String[] split = area.split("/"); + model.addAttribute("provinceName",split[0]); + model.addAttribute("cityName",split[1]); + if(split.length>2){ + model.addAttribute("districtName",split[2]); + }else { + model.addAttribute("districtName",""); + } + + String[] split1 = areaId.split("/"); + String provinceId = split1[0]; + model.addAttribute("provinceId",split1[0]); + model.addAttribute("cityId",split1[1]); + if(split1.length>2) { + model.addAttribute("districtId", split1[2]); + }else { + model.addAttribute("districtId", ""); + } + + List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); + model.addAttribute("provinceList",tRegions); +// List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); + // 查询市 + List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", provinceId)); + model.addAttribute("cityList",tRegions1); + + // 查询区 + List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); + List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); + model.addAttribute("districtList",tRegions2); + return PREFIX + "tBranchOfficeAreaUpdate.html"; } @@ -167,6 +214,9 @@ @ResponseBody public Object list(String branchOfficeName,String principal,String principalPhone,Integer operatingBusiness ,Integer status) { List<TBranchOfficeResp> tBranchOfficeRespList = tBranchOfficeService.getPageList(branchOfficeName,principal,principalPhone,operatingBusiness,status); + for (TBranchOfficeResp tBranchOfficeResp : tBranchOfficeRespList) { + tBranchOfficeResp.setUserType(Objects.requireNonNull(ShiroKit.getUser()).getRoleType()); + } // 分公司查询优惠券,订单,司机等信息 tBranchOfficeService.queryOtherInfo(tBranchOfficeRespList); return tBranchOfficeRespList; @@ -177,6 +227,10 @@ @ResponseBody public Object areaCity(Integer parentId,Model model) { List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId)); + /*if(CollectionUtils.isEmpty(tRegions) && StringUtils.hasLength(parentName)){ + TRegion parent = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("name", parentName)); + tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId)); + }*/ model.addAttribute("list",tRegions); return tRegions; } @@ -188,7 +242,7 @@ @ResponseBody public Object start(Integer id) { TBranchOffice tBranchOffice = tBranchOfficeService.selectById(id); - tBranchOffice.setStatus(1); + tBranchOffice.setStatus(StatusEnum.NORMAL.getCode()); tBranchOfficeService.updateById(tBranchOffice); return SUCCESS_TIP; } @@ -200,8 +254,25 @@ @ResponseBody public Object updateStatus(Integer id) { TBranchOffice tBranchOffice = tBranchOfficeService.selectById(id); - tBranchOffice.setStatus(2); + tBranchOffice.setStatus(StatusEnum.FREEZE.getCode()); tBranchOfficeService.updateById(tBranchOffice); + List<TDriver> list = tDriverService.selectList(new EntityWrapper<TDriver>() + .eq("branchOfficeId", tBranchOffice.getId())); + for (TDriver tDriver : list) { + String value = redisUtil.getValue("DRIVER_" + tDriver.getPhone()); + redisUtil.remove(value); + redisUtil.remove("DRIVER_" + tDriver.getPhone()); + TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() + .eq("driverId", tDriver.getId()) + .eq("status", 1) + .orderBy("workTime", false) + .last("LIMIT 1")); + if(Objects.nonNull(tDriverWork)){ + tDriverWork.setStatus(2); + tDriverWork.setOffWorkTime(new Date()); + tDriverWorkService.updateById(tDriverWork); + } + } return SUCCESS_TIP; } @@ -229,7 +300,8 @@ if(Objects.nonNull(o)){ return o; } - tBranchOffice.setStatus(1); + tBranchOffice.setPrincipal(tBranchOffice.getPrincipal().replace(" ","")); + tBranchOffice.setStatus(StatusEnum.NORMAL.getCode()); tBranchOfficeService.insert(tBranchOffice); return SUCCESS_TIP; @@ -241,7 +313,9 @@ @RequestMapping(value = "/delete") @ResponseBody public Object delete(@RequestParam Integer tBranchOfficeId) { - tBranchOfficeService.deleteById(tBranchOfficeId); + TBranchOffice tBranchOffice = tBranchOfficeService.selectById(tBranchOfficeId); + tBranchOffice.setStatus(StatusEnum.DELETE.getCode()); + tBranchOfficeService.updateById(tBranchOffice); return SUCCESS_TIP; } @@ -262,6 +336,7 @@ if(Objects.nonNull(o)){ return o; } + tBranchOffice.setPrincipal(tBranchOffice.getPrincipal().replace(" ","")); tBranchOfficeService.updateById(tBranchOffice); return SUCCESS_TIP; } -- Gitblit v1.7.1