ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -44,8 +44,7 @@ import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; import java.util.*; import java.util.stream.Collectors; /** @@ -69,9 +68,10 @@ private final TCrmPositionService crmPositionService; private final TCrmSalespersonService crmSalespersonService; private final TCrmBranchLiftService crmBranchLiftService; private final TRegionService regionService; private final TokenService tokenService; @Autowired public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TCrmSalespersonService crmSalespersonService, TCrmBranchLiftService crmBranchLiftService, TokenService tokenService) { public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TCrmSalespersonService crmSalespersonService, TCrmBranchLiftService crmBranchLiftService, TRegionService regionService, TokenService tokenService) { this.crmBranchService = crmBranchService; this.crmBranchAreaService = crmBranchAreaService; this.crmBranchSalaryService = crmBranchSalaryService; @@ -80,6 +80,7 @@ this.crmPositionService = crmPositionService; this.crmSalespersonService = crmSalespersonService; this.crmBranchLiftService = crmBranchLiftService; this.regionService = regionService; this.tokenService = tokenService; } @@ -90,7 +91,9 @@ @PostMapping(value = "/pageList") public R<PageInfo<TCrmBranchVO>> pageList(@RequestBody TCrmBranchQuery query) { Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); Long userId = tokenService.getLoginUser().getUserId(); query.setRoleType(roleType); query.setUserId(userId); return R.ok(crmBranchService.pageList(query)); } @@ -115,11 +118,33 @@ /** * 获取crm分公司管理管理列表 */ @ApiOperation(value = "获取crm分公司省公司管理列表") @PostMapping(value = "/listProvince") public R<List<TCrmBranch>> listProvince() { @ApiOperation(value = "获取crm分公司省公司,地区经理管理列表") @GetMapping(value = "/listProvince") public R<List<TCrmBranch>> listProvince(@RequestParam Integer personType) { List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getPersonType, personType) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); return R.ok(crmBranches); } /** * 获取crm分公司管理管理列表 */ @ApiOperation(value = "获取crm分公司地区经理,城市经理管理列表") @GetMapping(value = "/listCity") public R<List<TCrmBranch>> listCity() { Long userId = tokenService.getLoginUser().getUserId(); TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, userId) .eq(TCrmBranch::getPersonType, 1) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); if(Objects.isNull(crmBranch)){ return R.ok(new ArrayList<>()); } List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId()) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); return R.ok(crmBranches); @@ -188,9 +213,16 @@ TCrmBranch crmBranch = crmBranchService.getById(id); TCrmBranchVO crmBranchVO = new TCrmBranchVO(); BeanUtils.copyProperties(crmBranch, crmBranchVO); // 查询区域 List<TCrmBranchArea> crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class).eq(TCrmBranchArea::getBranchId, id)); // 查询负责区域 List<TCrmBranchArea> crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getAreaType, 1) .eq(TCrmBranchArea::getBranchId, id)); crmBranchVO.setCrmBranchAreas(crmBranchAreas); // 查询管辖区域 List<TCrmBranchArea> jurisdictionBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getAreaType, 2) .eq(TCrmBranchArea::getBranchId, id)); crmBranchVO.setJurisdictionBranchAreas(jurisdictionBranchAreas); // 职位薪资 List<TCrmPosition> crmPositions = crmPositionService.list(); List<TCrmBranchSalary> crmBranchSalaries = crmBranchSalaryService.list(Wrappers.lambdaQuery(TCrmBranchSalary.class).eq(TCrmBranchSalary::getBranchId, id)); @@ -199,6 +231,48 @@ } crmBranchVO.setCrmBranchSalaries(crmBranchSalaries); return R.ok(crmBranchVO); } /** * 查看crm分公司管理详情 */ @ApiOperation(value = "查看crm分公司解绑详情") @GetMapping(value = "/getDetailUnbindById") public R<TCrmBranchLiftVO> getDetailUnbindById(@RequestParam String id) { TCrmBranchLift crmBranchLift = crmBranchLiftService.getById(id); if(Objects.isNull(crmBranchLift)){ return R.fail("未找到该解绑信息"); } TCrmBranchLiftVO crmBranchLiftVO = new TCrmBranchLiftVO(); BeanUtils.copyProperties(crmBranchLift, crmBranchLiftVO); TCrmBranch crmBranch = crmBranchService.getById(crmBranchLift.getBranchId()); TCrmBranchVO crmBranchVO = new TCrmBranchVO(); BeanUtils.copyProperties(crmBranch, crmBranchVO); // 查询负责区域 List<TCrmBranchArea> crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getAreaType, 1) .eq(TCrmBranchArea::getBranchId, crmBranchLift.getBranchId())); crmBranchVO.setCrmBranchAreas(crmBranchAreas); // 查询管辖区域 List<TCrmBranchArea> jurisdictionBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getAreaType, 2) .eq(TCrmBranchArea::getBranchId, crmBranchLift.getBranchId())); crmBranchVO.setJurisdictionBranchAreas(jurisdictionBranchAreas); // 职位薪资 List<TCrmPosition> crmPositions = crmPositionService.list(); List<TCrmBranchSalary> crmBranchSalaries = crmBranchSalaryService.list(Wrappers.lambdaQuery(TCrmBranchSalary.class).eq(TCrmBranchSalary::getBranchId, id)); for (TCrmBranchSalary crmBranchSalary : crmBranchSalaries) { crmPositions.stream().filter(crmPosition -> Objects.equals(crmPosition.getId(), crmBranchSalary.getPositionId())).findFirst().ifPresent(crmPosition -> crmBranchSalary.setPositionName(crmPosition.getPositionName())); } crmBranchVO.setCrmBranchSalaries(crmBranchSalaries); crmBranchLiftVO.setCrmBranchVO(crmBranchVO); return R.ok(crmBranchLiftVO); } /** @@ -386,7 +460,7 @@ } TCrmBranchLift crmBranchLift = new TCrmBranchLift(); crmBranchLift.setBranchId(crmBranch.getId()); crmBranchLift.setBranchId(dto.getBranchId()); crmBranchLift.setChargePhone(dto.getChargePhone()); crmBranchLift.setLiftReason(dto.getLiftReason()); crmBranchLiftService.save(crmBranchLift); @@ -438,5 +512,49 @@ return R.ok(); } /** * 通过分公司上级id查询负责区域 */ @ApiOperation(value = "crm分公司管理信息-通过分公司上级id查询负责区域",notes = "branchId:分公司id") @GetMapping(value = "/getAreaByParentId") public R<Set<TRegion>> getAreaByParentId(@RequestParam String branchId) { List<TCrmBranchArea> list = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getBranchId, branchId) .eq(TCrmBranchArea::getAreaType, 1)); if(CollectionUtils.isEmpty(list)){ return R.fail("未查询到负责区域"); } List<TRegion> regionList = regionService.list(); // 匹配到省份 Set<TRegion> regions = new HashSet<>(); for (TCrmBranchArea tCrmBranchArea : list) { List<TRegion> parent = regionList.stream().filter(a -> a.getCode().equals(tCrmBranchArea.getProvinceCode())).collect(Collectors.toList()); regions.add(parent.get(0)); } // 匹配市区和区县 for (TRegion region : regions) { List<String> cityCodes = list.stream().filter(a -> a.getProvinceCode().equals(region.getCode())) .map(TCrmBranchArea::getCityCode) .collect(Collectors.toList()); List<TRegion> tRegionList = regionList.stream().filter(a -> a.getParentId().equals(region.getId()) && cityCodes.contains(a.getCode())).collect(Collectors.toList()); for (TRegion child : tRegionList) { List<TRegion> children1 = regionList.stream().filter(a -> a.getParentId().equals(child.getId())).collect(Collectors.toList()); child.setChildren(children1); } region.setChildren(tRegionList); } return R.ok(regions); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmSupplierController.java
@@ -104,6 +104,9 @@ @GetMapping(value = "/getDetailById") public R<TCrmSupplierVO> getDetailById(@RequestParam String id) { TCrmSupplier crmSupplier = crmSupplierService.getById(id); if(Objects.isNull(crmSupplier)){ return R.fail("供应商不存在"); } TCrmSupplierVO crmSupplierVO = new TCrmSupplierVO(); BeanUtils.copyProperties(crmSupplier, crmSupplierVO); // 查询仓库 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysOtherConfigController.java
@@ -60,6 +60,7 @@ TSysOtherConfig sysConfig = sysOtherConfigService.getById(1); sysConfig.setVerifyValue(verifyValue); sysConfig.setVerifyUnit(verifyUnit); sysOtherConfigService.updateById(sysConfig); return R.ok(); } ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -4,11 +4,14 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.model.TCrmBranch; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.TCrmBranchService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -48,6 +51,8 @@ private TokenService tokenService; @Autowired private ISysRoleService roleService; @Autowired private TCrmBranchService crmBranchService; /** * 账号密码登录 @@ -72,6 +77,18 @@ return AjaxResult.error("该账号角色已被禁用!"); } SysUser user = loginUser.getUser(); Integer roleType = user.getRoleType(); if(roleType == 2){ // 查询分公司的类型 TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, loginUser.getUserId()) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); user.setPersonType(crmBranch.getPersonType()); loginUser.setUser(user); } List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); ajax.put("menus",menus); ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysNoticeController.java
@@ -9,9 +9,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; import java.util.List; @@ -51,5 +49,15 @@ return R.ok(list); } /** * 获取公告管理管理列表 */ @ApiOperation(value = "获取公告管理详情") @GetMapping(value = "/getDetailById") public R<TSysNotice> getDetailById(@RequestParam String id) { TSysNotice sysNotice = sysNoticeService.getById(id); return R.ok(sysNotice); } } ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
@@ -141,7 +141,9 @@ @ApiModelProperty(value = "供应商-诊所使用,判断账号属于哪个供应商和诊所") @TableField("object_id") private String objectId; @ApiModelProperty(value = "类型 1=省公司负责人 2=地区经理 3=城市经理") @TableField(exist = false) private Integer personType; public String getRoleName() { return roleName; } ruoyi-system/src/main/java/com/ruoyi/system/dto/UnbindDTO.java
@@ -10,6 +10,9 @@ @ApiModel(value = "解除绑定分公司DTO") public class UnbindDTO implements Serializable { @ApiModelProperty(value = "分公司id") private String branchId; @ApiModelProperty(value = "负责人电话") private String chargePhone; ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmBranchArea.java
@@ -63,4 +63,8 @@ @TableField("area_type") private Integer areaType; @ApiModelProperty(value = "类型 1=省公司负责人 2=地区经理 3=城市经理") @TableField("person_type") private Integer personType; } ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmBranchQuery.java
@@ -34,8 +34,12 @@ @ApiModelProperty(value = "分公司id,前端忽略") private List<String> branchIds; @ApiModelProperty(value = "分公司id,前端忽略") private List<String> branchIdList; @ApiModelProperty(value = "角色类型") @ApiModelProperty(value = "角色类型 前端忽略") private Integer roleType; @ApiModelProperty(value = "角色类型 前端忽略") private Long userId; } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java
@@ -81,6 +81,22 @@ List<String> branchIds = crmBranchAreas.stream().map(TCrmBranchArea::getBranchId).collect(Collectors.toList()); query.setBranchIds(branchIds); } if(query.getRoleType() == 2){ // 查询分公司账号 TCrmBranch crmBranch = this.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, query.getUserId()) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); List<TCrmBranch> crmBranches = this.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId())); if(CollectionUtils.isEmpty(crmBranches)){ return pageInfo; } List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()); query.setBranchIdList(branchIds); } List<TCrmBranchVO> list = this.baseMapper.pageList(query,pageInfo); if(CollectionUtils.isEmpty(list)){ return pageInfo; @@ -130,6 +146,7 @@ if(!CollectionUtils.isEmpty(branchAreaCityCodes)){ long count = crmBranchAreaService.count(Wrappers.lambdaQuery(TCrmBranchArea.class) .in(TCrmBranchArea::getCityCode, branchAreaCityCodes) .eq(TCrmBranchArea::getPersonType,dto.getPersonType()) .eq(TCrmBranchArea::getAreaType,1)); if(count > 0){ return R.fail("负责区域已存在"); @@ -157,17 +174,24 @@ } this.save(dto); // 添加区域 for (TCrmBranchArea branchArea : branchAreas) { branchArea.setBranchId(dto.getId()); branchArea.setAreaType(2); List<TCrmBranchArea> allAreas = new ArrayList<>(); if(dto.getPersonType() != 3){ for (TCrmBranchArea responsibleBranchArea : responsibleBranchAreas) { responsibleBranchArea.setBranchId(dto.getId()); responsibleBranchArea.setAreaType(1); responsibleBranchArea.setPersonType(dto.getPersonType()); } allAreas.addAll(responsibleBranchAreas); } for (TCrmBranchArea responsibleBranchArea : responsibleBranchAreas) { responsibleBranchArea.setBranchId(dto.getId()); responsibleBranchArea.setAreaType(1); if(dto.getPersonType() != 1){ // 添加区域 for (TCrmBranchArea branchArea : branchAreas) { branchArea.setBranchId(dto.getId()); branchArea.setAreaType(2); } allAreas.addAll(branchAreas); } branchAreas.addAll(responsibleBranchAreas); crmBranchAreaService.saveBatch(branchAreas); crmBranchAreaService.saveBatch(allAreas); // 添加职位薪资 List<TCrmBranchSalary> branchSalaries = dto.getBranchSalaries(); branchSalaries.forEach(t -> t.setBranchId(dto.getId())); @@ -225,6 +249,7 @@ long count = crmBranchAreaService.count(Wrappers.lambdaQuery(TCrmBranchArea.class) .in(TCrmBranchArea::getCityCode, branchAreaCityCodes) .eq(TCrmBranchArea::getAreaType,1) .eq(TCrmBranchArea::getPersonType,dto.getPersonType()) .ne(TCrmBranchArea::getBranchId, dto.getId())); if(count > 0){ return R.fail("负责区域已存在"); @@ -235,17 +260,24 @@ // 删除区域 crmBranchAreaService.remove(Wrappers.lambdaQuery(TCrmBranchArea.class).eq(TCrmBranchArea::getBranchId, dto.getId())); // 添加区域 // 添加区域 for (TCrmBranchArea branchArea : branchAreas) { branchArea.setBranchId(dto.getId()); branchArea.setAreaType(2); List<TCrmBranchArea> allAreas = new ArrayList<>(); if(dto.getPersonType() != 3){ for (TCrmBranchArea responsibleBranchArea : responsibleBranchAreas) { responsibleBranchArea.setBranchId(dto.getId()); responsibleBranchArea.setAreaType(1); responsibleBranchArea.setPersonType(dto.getPersonType()); } allAreas.addAll(responsibleBranchAreas); } for (TCrmBranchArea responsibleBranchArea : responsibleBranchAreas) { responsibleBranchArea.setBranchId(dto.getId()); responsibleBranchArea.setAreaType(1); if(dto.getPersonType() != 1){ // 添加区域 for (TCrmBranchArea branchArea : branchAreas) { branchArea.setBranchId(dto.getId()); branchArea.setAreaType(2); } allAreas.addAll(branchAreas); } branchAreas.addAll(responsibleBranchAreas); crmBranchAreaService.saveBatch(branchAreas); crmBranchAreaService.saveBatch(allAreas); // 删除职位薪资 crmBranchSalaryService.remove(Wrappers.lambdaQuery(TCrmBranchSalary.class).eq(TCrmBranchSalary::getBranchId, dto.getId())); // 添加职位薪资 ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmBranchLiftVO.java
@@ -24,4 +24,8 @@ @ApiModelProperty(value = "省公司id") private String provinceBranchId; @ApiModelProperty(value = "分公司信息") private TCrmBranchVO crmBranchVO; } ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmBranchVO.java
@@ -16,9 +16,12 @@ @ApiModelProperty(value = "省份") private String provinceName; @ApiModelProperty(value = "省市列表") @ApiModelProperty(value = "负责区域列表") private List<TCrmBranchArea> crmBranchAreas; @ApiModelProperty(value = "管辖区域列表") private List<TCrmBranchArea> jurisdictionBranchAreas; @ApiModelProperty(value = "职位薪资") private List<TCrmBranchSalary> crmBranchSalaries; ruoyi-system/src/main/resources/mapper/system/TCrmBranchAreaMapper.xml
@@ -13,11 +13,12 @@ <result column="district_name" property="districtName" /> <result column="district_code" property="districtCode" /> <result column="area_type" property="areaType" /> <result column="person_type" property="personType" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, branch_id, province_name, province_code, city_name, city_code,district_name, district_code, area_type id, branch_id, province_name, province_code, city_name, city_code,district_name, district_code, area_type,person_type </sql> </mapper> ruoyi-system/src/main/resources/mapper/system/TCrmBranchMapper.xml
@@ -56,6 +56,12 @@ #{item} </foreach> </if> <if test="query.branchIdList != null and query.branchIdList.size()>0"> and id in <foreach item="item" collection="query.branchIdList" separator="," open="(" close=")" index=""> #{item} </foreach> </if> <if test="query.roleType != null and query.roleType == 1"> and audit_status = 2 </if> @@ -108,15 +114,13 @@ <if test="query.phone != null and query.phone != ''"> and phone like concat('%',#{query.phone},'%') </if> <if test="query.status != null"> and status = #{query.status} </if> <if test="query.roleType != null and query.roleType == 1"> and audit_status in (1,3) <if test="query.auditStatus != null"> and audit_status = #{query.auditStatus} </if> <if test="query.branchId != null and query.branchId != ''"> and province_branch_id = #{query.branchId} </if> and audit_status in (1,3) AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ORDER BY create_time DESC @@ -134,8 +138,8 @@ <if test="query.phone != null and query.phone != ''"> and tcb.phone like concat('%',#{query.phone},'%') </if> <if test="query.status != null"> and tcbl.status = #{query.status} <if test="query.auditStatus != null"> and tcbl.status = #{query.auditStatus} </if> <if test="query.branchId != null and query.branchId != ''"> and tcb.province_branch_id = #{query.branchId} @@ -157,15 +161,13 @@ <if test="query.phone != null and query.phone != ''"> and phone like concat('%',#{query.phone},'%') </if> <if test="query.status != null"> and status = #{query.status} </if> <if test="query.roleType != null and query.roleType == 1"> and audit_status in (1,3) <if test="query.auditStatus != null"> and audit_status = #{query.auditStatus} </if> <if test="query.branchId != null and query.branchId != ''"> and province_branch_id = #{query.branchId} </if> and audit_status in (1,3) AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ORDER BY create_time DESC ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -346,7 +346,7 @@ t1.precautions, t1.interaction, t1.content,t1.content_state, t1.storage, t1.storage,t1.state_remark, t2.supplier_name from t_erp_goods t1 left join t_crm_supplier t2 on t1.supplier_clinic_id = t2.id and t1.goods_source =1 where t1.disabled = 0 and t1.goods_source =1