1.部门绑定运营区
This commit is contained in:
parent
66d22c623d
commit
da26d6b2b1
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.system.service.IEtOperatingAreaService;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
@ -34,6 +36,10 @@ public class SysDeptController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService deptService;
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IEtOperatingAreaService etOperatingAreaService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
*/
|
*/
|
||||||
|
@ -64,8 +70,11 @@ public class SysDeptController extends BaseController
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long deptId)
|
public AjaxResult getInfo(@PathVariable Long deptId)
|
||||||
{
|
{
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return success(deptService.selectDeptById(deptId));
|
ajax.put(AjaxResult.DATA_TAG,deptService.selectDeptById(deptId));
|
||||||
|
ajax.put("areaIds", etOperatingAreaService.selectAreaListByDeptId(deptId));
|
||||||
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +87,7 @@ public class SysDeptController extends BaseController
|
||||||
{
|
{
|
||||||
if (!deptService.checkDeptNameUnique(dept))
|
if (!deptService.checkDeptNameUnique(dept))
|
||||||
{
|
{
|
||||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return error("新增运营商'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(getUsername());
|
dept.setCreateBy(getUsername());
|
||||||
return toAjax(deptService.insertDept(dept));
|
return toAjax(deptService.insertDept(dept));
|
||||||
|
@ -96,15 +105,15 @@ public class SysDeptController extends BaseController
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
if (!deptService.checkDeptNameUnique(dept))
|
if (!deptService.checkDeptNameUnique(dept))
|
||||||
{
|
{
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return error("修改运营商'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
else if (dept.getParentId().equals(deptId))
|
else if (dept.getParentId().equals(deptId))
|
||||||
{
|
{
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return error("修改运营商'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
}
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
||||||
{
|
{
|
||||||
return error("该部门包含未停用的子部门!");
|
return error("该运营商包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
dept.setUpdateBy(getUsername());
|
dept.setUpdateBy(getUsername());
|
||||||
return toAjax(deptService.updateDept(dept));
|
return toAjax(deptService.updateDept(dept));
|
||||||
|
|
|
@ -6,6 +6,8 @@ import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
@ -52,6 +54,17 @@ public class SysDept extends BaseEntity
|
||||||
/** 父部门名称 */
|
/** 父部门名称 */
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
|
/** 运营区id */
|
||||||
|
private Long[] areaIds;
|
||||||
|
|
||||||
|
public Long[] getAreaIds() {
|
||||||
|
return areaIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAreaIds(Long[] areaIds) {
|
||||||
|
this.areaIds = areaIds;
|
||||||
|
}
|
||||||
|
|
||||||
/** 子部门 */
|
/** 子部门 */
|
||||||
private List<SysDept> children = new ArrayList<SysDept>();
|
private List<SysDept> children = new ArrayList<SysDept>();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营商与运营区(部门)关联表 et_area_dept
|
||||||
|
*
|
||||||
|
* @author 邱贞招
|
||||||
|
* @date 2024-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@TableName(value = "et_area_dept")
|
||||||
|
public class EtAreaDept implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 区域id */
|
||||||
|
private Long areaId;
|
||||||
|
|
||||||
|
/** 收费规则id */
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
}
|
|
@ -144,7 +144,7 @@ public class EtFeeRule extends BaseEntity
|
||||||
|
|
||||||
/** 骑行价格说明*/
|
/** 骑行价格说明*/
|
||||||
@Excel(name = "骑行价格说明")
|
@Excel(name = "骑行价格说明")
|
||||||
private BigDecimal instructions;
|
private String instructions;
|
||||||
|
|
||||||
/** 是否缴纳过押金*/
|
/** 是否缴纳过押金*/
|
||||||
@Excel(name = "是否缴纳过押金")
|
@Excel(name = "是否缴纳过押金")
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.system.domain.EtAreaDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域与部门关联 数据层
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public interface EtAreaDeptMapper extends BaseMapper<EtAreaDept>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 通过用运营区ID删除区域与部门关联
|
||||||
|
*
|
||||||
|
* @param deptId 部门id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAreaDeptByDeptId(Long deptId);
|
||||||
|
}
|
|
@ -10,4 +10,11 @@ import com.ruoyi.system.domain.EtAreaRule;
|
||||||
*/
|
*/
|
||||||
public interface EtAreaRuleMapper extends BaseMapper<EtAreaRule>
|
public interface EtAreaRuleMapper extends BaseMapper<EtAreaRule>
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 通过用运营区ID删除区域与收费方式关联
|
||||||
|
*
|
||||||
|
* @param areaId 运营区id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAreaRuleByAreaId(Long areaId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,14 @@ public interface EtOperatingAreaMapper extends BaseMapper<EtOperatingArea>
|
||||||
* @return 运营区集合
|
* @return 运营区集合
|
||||||
*/
|
*/
|
||||||
public List<EtOperatingArea> selectEtOperatingAreaList(EtOperatingArea etOperatingArea);
|
public List<EtOperatingArea> selectEtOperatingAreaList(EtOperatingArea etOperatingArea);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门ID获取运营区选择框列表 运营商
|
||||||
|
*
|
||||||
|
* @param deptId 用户ID
|
||||||
|
* @return 选中运营区ID列表
|
||||||
|
*/
|
||||||
|
List<Long> selectAreaListByDeptId(Long deptId);
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * 新增运营区
|
// * 新增运营区
|
||||||
|
|
|
@ -87,4 +87,12 @@ public interface IEtOperatingAreaService extends IService<EtOperatingArea>
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
EtOperatingArea getAreaInfoByLocation(String longitude, String latitude);
|
EtOperatingArea getAreaInfoByLocation(String longitude, String latitude);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门ID获取运营区选择框列表
|
||||||
|
*
|
||||||
|
* @param deptId 用户ID
|
||||||
|
* @return 选中运营区ID列表
|
||||||
|
*/
|
||||||
|
public List<Long> selectAreaListByDeptId(Long deptId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int updateEtOperatingArea(EtOperatingArea etOperatingArea)
|
public int updateEtOperatingArea(EtOperatingArea etOperatingArea)
|
||||||
{
|
{
|
||||||
/** 将边界值转Geometry对象*/
|
/** 将边界值转Geometry对象*/
|
||||||
|
@ -137,7 +138,13 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
|
||||||
Geometry geometry = GeoUtils.toGeometry(boundaryStr);
|
Geometry geometry = GeoUtils.toGeometry(boundaryStr);
|
||||||
String wkt = GeoUtils.wkt(geometry);
|
String wkt = GeoUtils.wkt(geometry);
|
||||||
etOperatingArea.setBoundary(wkt);
|
etOperatingArea.setBoundary(wkt);
|
||||||
return dao.updateById(etOperatingArea);
|
etAreaRuleMapper.deleteAreaRuleByAreaId(etOperatingArea.getAreaId());
|
||||||
|
int i = dao.updateById(etOperatingArea);
|
||||||
|
Long[] ruleIds = etOperatingArea.getRuleIds();
|
||||||
|
for (Long ruleId:ruleIds){
|
||||||
|
etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build());
|
||||||
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,6 +258,16 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门ID获取运营区选择框列表
|
||||||
|
*
|
||||||
|
* @param deptId 用户ID
|
||||||
|
* @return 选中运营区ID列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Long> selectAreaListByDeptId(Long deptId) {
|
||||||
|
return dao.selectAreaListByDeptId(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.EtAreaDept;
|
||||||
|
import com.ruoyi.system.domain.EtAreaRule;
|
||||||
|
import com.ruoyi.system.mapper.EtAreaDeptMapper;
|
||||||
|
import com.ruoyi.system.service.IEtOperatingAreaService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
|
@ -20,6 +25,9 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理 服务实现
|
* 部门管理 服务实现
|
||||||
|
@ -35,6 +43,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleMapper roleMapper;
|
private SysRoleMapper roleMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EtAreaDeptMapper etAreaDeptMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
*
|
*
|
||||||
|
@ -209,6 +220,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int insertDept(SysDept dept)
|
public int insertDept(SysDept dept)
|
||||||
{
|
{
|
||||||
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
||||||
|
@ -218,7 +230,12 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
}
|
}
|
||||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||||
return deptMapper.insertDept(dept);
|
int i = deptMapper.insertDept(dept);
|
||||||
|
Long[] areaIds = dept.getAreaIds();
|
||||||
|
for (Long areaId:areaIds){
|
||||||
|
etAreaDeptMapper.insert(EtAreaDept.builder().areaId(areaId).deptId(dept.getDeptId()).build());
|
||||||
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,6 +245,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int updateDept(SysDept dept)
|
public int updateDept(SysDept dept)
|
||||||
{
|
{
|
||||||
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
||||||
|
@ -246,6 +264,11 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||||
updateParentDeptStatusNormal(dept);
|
updateParentDeptStatusNormal(dept);
|
||||||
}
|
}
|
||||||
|
etAreaDeptMapper.deleteAreaDeptByDeptId(dept.getDeptId());
|
||||||
|
Long[] areaIds = dept.getAreaIds();
|
||||||
|
for (Long areaId:areaIds){
|
||||||
|
etAreaDeptMapper.insert(EtAreaDept.builder().areaId(areaId).deptId(dept.getDeptId()).build());
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.system.mapper.EtAreaDeptMapper">
|
||||||
|
|
||||||
|
<delete id="deleteAreaDeptByDeptId">
|
||||||
|
delete from et_area_dept where dept_id=#{deptId}
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -4,4 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ruoyi.system.mapper.EtAreaRuleMapper">
|
<mapper namespace="com.ruoyi.system.mapper.EtAreaRuleMapper">
|
||||||
|
|
||||||
|
<delete id="deleteAreaRuleByAreaId">
|
||||||
|
delete from et_area_rule where area_id=#{areaId}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -61,4 +61,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where area_id = #{areaId}
|
where area_id = #{areaId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAreaListByDeptId" resultType="java.lang.Long" parameterType="Long">
|
||||||
|
select a.area_id
|
||||||
|
from et_operating_area a
|
||||||
|
left join et_area_dept ad on ad.area_id = a.area_id
|
||||||
|
left join sys_dept d on d.dept_id = ad.dept_id
|
||||||
|
where d.dept_id = #{deptId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -87,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertDept" parameterType="SysDept">
|
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
||||||
insert into sys_dept(
|
insert into sys_dept(
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user