From 7d914d51a902b3013a8ae27ee48239821d766e4d Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 16 三月 2023 18:23:51 +0800
Subject: [PATCH] 基础信息管理:公告
---
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java | 202 +++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 164 insertions(+), 38 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 d806fe0..a4b60b0 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
@@ -3,12 +3,17 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
+import com.stylefeng.guns.core.base.tips.SuccessTip;
import com.stylefeng.guns.core.shiro.ShiroKit;
-import com.stylefeng.guns.modular.system.model.TAppUser;
-import com.stylefeng.guns.modular.system.model.TSystemConfig;
-import com.stylefeng.guns.modular.system.model.User;
+import com.stylefeng.guns.modular.system.controller.resp.TBranchOfficeResp;
+import com.stylefeng.guns.modular.system.controller.resp.TDriverResp;
+import com.stylefeng.guns.modular.system.model.*;
+import com.stylefeng.guns.modular.system.service.ITRegionService;
import com.stylefeng.guns.modular.system.service.ITSystemConfigService;
+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;
@@ -17,10 +22,11 @@
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.model.TBranchOffice;
import com.stylefeng.guns.modular.system.service.ITBranchOfficeService;
+import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* 控制器
@@ -38,6 +44,9 @@
private ITBranchOfficeService tBranchOfficeService;
@Autowired
private ITSystemConfigService tSystemConfigService;
+
+ @Autowired
+ private ITRegionService tRegionService;
/**
* 跳转到首页
@@ -60,8 +69,32 @@
*/
@RequestMapping("/tBranchOffice_update/{tBranchOfficeId}")
public String tBranchOfficeUpdate(@PathVariable Integer tBranchOfficeId, Model model) {
+
TBranchOffice tBranchOffice = tBranchOfficeService.selectById(tBranchOfficeId);
- model.addAttribute("item",tBranchOffice);
+ TBranchOfficeResp tBranchOfficeResp = new TBranchOfficeResp();
+ BeanUtils.copyProperties(tBranchOffice,tBranchOfficeResp);
+
+ // 查询区域
+ TRegion city = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tBranchOffice.getCityCode())
+ .last("LIMIT 1"));
+ TRegion district = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tBranchOffice.getDistrictCode())
+ .last("LIMIT 1"));
+
+ if(StringUtils.hasLength(tBranchOffice.getDistrictName())){
+ tBranchOfficeResp.setArea(tBranchOffice.getProvinceName()+"/"+tBranchOffice.getCityName()+"/"+tBranchOffice.getDistrictName());
+ }else {
+ tBranchOfficeResp.setArea(tBranchOffice.getProvinceName()+"/"+tBranchOffice.getCityName());
+ }
+
+ if(Objects.nonNull(city)){
+ if(Objects.nonNull(district)){
+ tBranchOfficeResp.setAreaId(city.getParentId()+"/"+city.getId()+"/"+district.getId());
+ }else {
+ tBranchOfficeResp.setAreaId(city.getParentId()+"/"+city.getId());
+ }
+ }
+
+ model.addAttribute("item",tBranchOfficeResp);
LogObjectHolder.me().set(tBranchOffice);
return PREFIX + "tBranchOffice_edit.html";
}
@@ -80,44 +113,115 @@
}
/**
+ * 跳转区域页面新增
+ */
+ @RequestMapping("/areaPageAdd")
+ 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>().eq("parent_id", split1[0]));
+ 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);
+
+ if(StringUtils.hasLength(area) && StringUtils.hasLength(areaId)){
+ 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","");
+ }
+
+ model.addAttribute("provinceId",split1[0]);
+ model.addAttribute("cityId",split1[1]);
+ if(split1.length>2) {
+ model.addAttribute("districtId", split1[2]);
+ }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";
+ }
+
+ /**
* 获取列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String branchOfficeName,String principal,String principalPhone,Integer operatingBusiness ,Integer status) {
- EntityWrapper<TBranchOffice> wrapper = new EntityWrapper<>();
- // 分公司名称
- if(StringUtils.hasLength(branchOfficeName)){
- wrapper.like("branchOfficeName",branchOfficeName);
- }
- // 负责人
- if(StringUtils.hasLength(principal)){
- wrapper.like("principal",principal);
- }
- // 负责人电话
- if(StringUtils.hasLength(principalPhone)){
- wrapper.like("principalPhone",principalPhone);
- }
- // 经营业务
- if(Objects.nonNull(operatingBusiness)){
- wrapper.eq("operatingBusiness",operatingBusiness);
- }
- // 状态
- if(Objects.nonNull(status)){
- wrapper.eq("status",status);
- }
- // 判断代理商 分公司
- Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
- Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
- if(2 == roleType){
- // 分公司
- wrapper.eq("id",objectId);
- }
- if(3 == roleType){
- // 代理商
- wrapper.eq("agentId",objectId);
- }
- return tBranchOfficeService.selectList(wrapper);
+ List<TBranchOfficeResp> tBranchOfficeRespList = tBranchOfficeService.getPageList(branchOfficeName,principal,principalPhone,operatingBusiness,status);
+ // 分公司查询优惠券,订单,司机等信息
+ tBranchOfficeService.queryOtherInfo(tBranchOfficeRespList);
+ return tBranchOfficeRespList;
+ }
+
+ @ApiOperation(value = "市区查询",notes="市区查询")
+ @RequestMapping(value = "/areaCity")
+ @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;
}
/**
@@ -159,6 +263,17 @@
@RequestMapping(value = "/add")
@ResponseBody
public Object add(TBranchOffice tBranchOffice) {
+ int count = tBranchOfficeService.selectCount(new EntityWrapper<TBranchOffice>().eq("branchOfficeName", tBranchOffice.getBranchOfficeName()));
+ if(count>0){
+ return new SuccessTip(500,"该分公司名称已存在!");
+ }
+
+ Object o = tBranchOfficeService.addOrUpdate(tBranchOffice);
+ if(Objects.nonNull(o)){
+ return o;
+ }
+ tBranchOffice.setStatus(1);
+
tBranchOfficeService.insert(tBranchOffice);
return SUCCESS_TIP;
}
@@ -179,6 +294,17 @@
@RequestMapping(value = "/update")
@ResponseBody
public Object update(TBranchOffice tBranchOffice) {
+ TBranchOffice office = tBranchOfficeService.selectOne(new EntityWrapper<TBranchOffice>().eq("branchOfficeName", tBranchOffice.getBranchOfficeName())
+ .last("LIMIT 1"));
+ if(Objects.nonNull(office) && !tBranchOffice.getId().equals(office.getId())){
+ return new SuccessTip(500,"该分公司名称已存在!");
+ }
+// Object ocr = ocr("E:\\071bf986db0b00355c0ed190bbd3b16.png");
+// System.err.println(ocr);
+ Object o = tBranchOfficeService.addOrUpdate(tBranchOffice);
+ if(Objects.nonNull(o)){
+ return o;
+ }
tBranchOfficeService.updateById(tBranchOffice);
return SUCCESS_TIP;
}
--
Gitblit v1.7.1