移动退料申请,后台部分系统管理
This commit is contained in:
parent
d73fe10073
commit
e9cfbe9f29
|
|
@ -101,4 +101,10 @@ public class TmTask implements Serializable {
|
|||
@ApiModelProperty(value="领料任务详情集合")
|
||||
private List<LeaseApplyDetails> leaseApplyDetails;
|
||||
|
||||
private Integer agreementId;
|
||||
private Integer backPerson;
|
||||
private String phone;
|
||||
private String directAuditBy;
|
||||
private String directAuditTime;
|
||||
private String directAuditRemark;
|
||||
}
|
||||
|
|
@ -55,6 +55,9 @@ public class SysDept extends BaseEntity
|
|||
/** 子部门 */
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
/** 备注信息 */
|
||||
private String remark;
|
||||
|
||||
public Long getDeptId()
|
||||
{
|
||||
return deptId;
|
||||
|
|
@ -198,6 +201,7 @@ public class SysDept extends BaseEntity
|
|||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ public class SysRole extends BaseEntity
|
|||
|
||||
/** 角色菜单权限 */
|
||||
private Set<String> permissions;
|
||||
/** 数据所属组织 */
|
||||
private String deptName;
|
||||
|
||||
public SysRole()
|
||||
{
|
||||
|
|
@ -219,6 +221,14 @@ public class SysRole extends BaseEntity
|
|||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
@ -236,6 +246,7 @@ public class SysRole extends BaseEntity
|
|||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("deptName", getDeptName())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,239 @@
|
|||
package com.bonus.sgzb.app.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.sgzb.app.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.BmAgreementInfo;
|
||||
import com.bonus.sgzb.app.service.BackApplyService;
|
||||
import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
|
||||
import com.bonus.sgzb.app.service.LeaseApplyInfoService;
|
||||
import com.bonus.sgzb.app.service.TmTaskService;
|
||||
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.base.api.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.base.api.domain.TmTask;
|
||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.log.annotation.Log;
|
||||
import com.bonus.sgzb.common.log.enums.BusinessType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退料申请
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/back_apply")
|
||||
public class BackApplyController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private BackApplyService backApplyService; // 任务表Service
|
||||
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private TmTaskService tmTaskService; // 任务表Service
|
||||
|
||||
@Resource
|
||||
private LeaseApplyInfoService leaseApplyInfoService; // 领料申请表Service
|
||||
|
||||
@Resource
|
||||
private LeaseApplyDetailsService leaseApplyDetailsService; // 领料申请明细表Service
|
||||
|
||||
/**
|
||||
* 退料申请列表
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "退料申请列表", businessType = BusinessType.QUERY)
|
||||
@PostMapping("getbackList")
|
||||
public AjaxResult getbackList(@RequestBody BackApplyInfo record) {
|
||||
try {
|
||||
List<BackApplyInfo> list =backApplyService.getbackList(record);
|
||||
return success(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物料列表
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "获取退料物料列表", businessType = BusinessType.QUERY)
|
||||
@PostMapping("materialList")
|
||||
public AjaxResult materialList(@RequestBody BackApplyInfo record) {
|
||||
try {
|
||||
List<BackApplyInfo> list =backApplyService.materialList(record);
|
||||
return success(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情查看
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "退料详情查看", businessType = BusinessType.QUERY)
|
||||
@GetMapping("view")
|
||||
public AjaxResult view(@RequestBody BackApplyInfo record) {
|
||||
try {
|
||||
List<BackApplyInfo> list =backApplyService.view(record);
|
||||
return success(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "退料删除", businessType = BusinessType.QUERY)
|
||||
@GetMapping("del")
|
||||
public AjaxResult del(@RequestBody BackApplyInfo record) {
|
||||
try {
|
||||
int re =backApplyService.del(record);
|
||||
if (re>0){
|
||||
return AjaxResult.success("删除成功");
|
||||
}else {
|
||||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退料单位列表
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "退料申请-退料单位", businessType = BusinessType.QUERY)
|
||||
@GetMapping("getbackUnit")
|
||||
public AjaxResult getbackUnit(@RequestBody BmAgreementInfo record) {
|
||||
try {
|
||||
List<BmAgreementInfo> list =backApplyService.getbackUnit(record);
|
||||
return success(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退料工程列表
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "退料申请-退料工程", businessType = BusinessType.QUERY)
|
||||
@GetMapping("getbackPro")
|
||||
public AjaxResult getbackPro(@RequestBody BmAgreementInfo record) {
|
||||
try {
|
||||
List<BmAgreementInfo> list =backApplyService.getbackPro(record);
|
||||
return success(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建退料任务单
|
||||
*
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "退料申请-新增", businessType = BusinessType.INSERT)
|
||||
@PostMapping("addBackTask")
|
||||
public AjaxResult addBackTask(@RequestBody TmTask task) {
|
||||
if (StringUtils.isNull(task)) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
try {
|
||||
String code = purchaseCodeRule();
|
||||
// 创建任务(tm_task)
|
||||
task.setCode(code);
|
||||
boolean addTaskResult = backApplyService.insertTask(task) > 0;
|
||||
if (addTaskResult){
|
||||
//任务协议表(tm_task_agreement)
|
||||
Boolean addTaskAgreementRes = backApplyService.insertTaskAgreement(task)>0;
|
||||
if (addTaskAgreementRes){
|
||||
//退料任务表(back_apply_info)
|
||||
Boolean addBackApply=backApplyService.insertBackApply(task)>0;
|
||||
if (addBackApply){
|
||||
return AjaxResult.success("任务创建成功,已完成");
|
||||
}else {
|
||||
return AjaxResult.error("退料任务创建失败");
|
||||
}
|
||||
}else {
|
||||
return AjaxResult.error("创建任务协议失败");
|
||||
}
|
||||
}else {
|
||||
return AjaxResult.error("创建任务失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交物料型号及数量
|
||||
*
|
||||
* @param record 查询条件
|
||||
* @return AjaxResult对象
|
||||
*/
|
||||
@Log(title = "提交物料型号及数量", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("upload")
|
||||
public AjaxResult upload(@RequestBody BackApplyInfo record) {
|
||||
try {
|
||||
if (!StringUtils.isEmpty(record.getTypeId()) && !StringUtils.isEmpty(record.getNum())){
|
||||
String[] typeId = record.getTypeId().split(",");
|
||||
String[] num = record.getNum().split(",");
|
||||
for (int i=0;i< typeId.length;i++){
|
||||
String typeIdStr=typeId[i];
|
||||
String numStr=num[i];
|
||||
record.setTypeId(typeIdStr);
|
||||
record.setNum(numStr);
|
||||
int re =backApplyService.upload(record);
|
||||
if (re<1){
|
||||
return AjaxResult.error("提交失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("提交成功");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 退料编号生成规则
|
||||
private String purchaseCodeRule() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
int taskNum = tmTaskService.selectTaskNumByMonth(nowDate,36) + 1;
|
||||
String code="";
|
||||
if (taskNum>9 && taskNum<100){
|
||||
code = "T" + format + "-00" + taskNum;
|
||||
}else if (taskNum>99 && taskNum<1000){
|
||||
code = "T" + format + "-0" + taskNum;
|
||||
}else {
|
||||
code = "T" + format + "-000" + taskNum;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.bonus.sgzb.app.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 退料
|
||||
*/
|
||||
@Data
|
||||
public class BackApplyInfo {
|
||||
/**
|
||||
* 退料id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 退料人
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
private String lotName;
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
private String unitName;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private String planStartTime;
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 退料审核状态
|
||||
*/
|
||||
private String taskStatus;
|
||||
/**
|
||||
* 规格id
|
||||
*/
|
||||
private String typeId;
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
private String typeName;
|
||||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
private String typeCode;
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private String companyId;
|
||||
/**
|
||||
* 在用数量
|
||||
*/
|
||||
private String num;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String maCode;
|
||||
/**
|
||||
* 协议id
|
||||
*/
|
||||
private String agreementId;
|
||||
/**
|
||||
* 人员
|
||||
*/
|
||||
private String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
private String updateTime;
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -112,5 +112,54 @@ public class BmAgreementInfo implements Serializable {
|
|||
@ApiModelProperty(value = "数据所属组织")
|
||||
private Integer companyId;
|
||||
|
||||
/**
|
||||
* 人员id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
private String unitName;
|
||||
/**
|
||||
* 工程id
|
||||
*/
|
||||
private Integer lotId;
|
||||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
private String lotName;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUnitName() {
|
||||
return unitName;
|
||||
}
|
||||
|
||||
public void setUnitName(String unitName) {
|
||||
this.unitName = unitName;
|
||||
}
|
||||
|
||||
public Integer getLotId() {
|
||||
return lotId;
|
||||
}
|
||||
|
||||
public void setLotId(Integer lotId) {
|
||||
this.lotId = lotId;
|
||||
}
|
||||
|
||||
public String getLotName() {
|
||||
return lotName;
|
||||
}
|
||||
|
||||
public void setLotName(String lotName) {
|
||||
this.lotName = lotName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.bonus.sgzb.app.mapper;
|
||||
|
||||
import com.bonus.sgzb.app.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.BmAgreementInfo;
|
||||
import com.bonus.sgzb.base.api.domain.TmTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface BackApplyMapper {
|
||||
/**
|
||||
* 查询退料单位列表
|
||||
*/
|
||||
List<BmAgreementInfo> getbackUnit(BmAgreementInfo record);
|
||||
|
||||
/**
|
||||
* 查询退料工程列表
|
||||
*/
|
||||
List<BmAgreementInfo> getbackPro(BmAgreementInfo record);
|
||||
|
||||
int insertTask(TmTask task);
|
||||
|
||||
List<BackApplyInfo> getbackList(BackApplyInfo record);
|
||||
|
||||
int insertTaskAgreement(TmTask task);
|
||||
|
||||
int insertBackApply(TmTask task);
|
||||
|
||||
List<BackApplyInfo> materialList(BackApplyInfo record);
|
||||
|
||||
int upload(BackApplyInfo record);
|
||||
|
||||
List<BackApplyInfo> view(BackApplyInfo record);
|
||||
|
||||
int del(BackApplyInfo record);
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@ package com.bonus.sgzb.app.mapper;
|
|||
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.base.api.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.base.api.domain.TmTask;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -59,4 +62,6 @@ public interface TmTaskMapper {
|
|||
int updateBatchSelective(List<TmTask> list);
|
||||
|
||||
int batchInsert(@Param("list") List<TmTask> list);
|
||||
|
||||
int selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType);
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.bonus.sgzb.app.service;
|
||||
|
||||
import com.bonus.sgzb.app.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.BmAgreementInfo;
|
||||
import com.bonus.sgzb.base.api.domain.TmTask;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BackApplyService {
|
||||
|
||||
/**
|
||||
* 查询退料单位列表
|
||||
*/
|
||||
List<BmAgreementInfo> getbackUnit(BmAgreementInfo record);
|
||||
|
||||
/**
|
||||
* 查询退料工程列表
|
||||
*/
|
||||
List<BmAgreementInfo> getbackPro(BmAgreementInfo record);
|
||||
|
||||
/**
|
||||
* 创建任务单
|
||||
*/
|
||||
int insertTask(TmTask task);
|
||||
|
||||
/**
|
||||
* 退料申请列表
|
||||
*/
|
||||
List<BackApplyInfo> getbackList(BackApplyInfo record);
|
||||
|
||||
int insertTaskAgreement(TmTask task);
|
||||
|
||||
int insertBackApply(TmTask task);
|
||||
|
||||
List<BackApplyInfo> materialList(BackApplyInfo record);
|
||||
|
||||
int upload(BackApplyInfo record);
|
||||
|
||||
List<BackApplyInfo> view(BackApplyInfo record);
|
||||
|
||||
int del(BackApplyInfo record);
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package com.bonus.sgzb.app.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.bonus.sgzb.base.api.domain.TmTask;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -42,4 +45,5 @@ public interface TmTaskService{
|
|||
|
||||
int batchInsert(List<TmTask> list);
|
||||
|
||||
int selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
package com.bonus.sgzb.app.service.impl;
|
||||
|
||||
import com.bonus.sgzb.app.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.BmAgreementInfo;
|
||||
import com.bonus.sgzb.app.mapper.BackApplyMapper;
|
||||
import com.bonus.sgzb.app.mapper.TmTaskMapper;
|
||||
import com.bonus.sgzb.app.service.BackApplyService;
|
||||
import com.bonus.sgzb.app.service.TmTaskService;
|
||||
import com.bonus.sgzb.base.api.domain.TmTask;
|
||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class BackApplyServiceImpl implements BackApplyService {
|
||||
|
||||
@Resource
|
||||
private BackApplyMapper backApplyMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<BmAgreementInfo> getbackUnit(BmAgreementInfo record) {
|
||||
return backApplyMapper.getbackUnit(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BmAgreementInfo> getbackPro(BmAgreementInfo record) {
|
||||
return backApplyMapper.getbackPro(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertTask(TmTask task) {
|
||||
return backApplyMapper.insertTask(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BackApplyInfo> getbackList(BackApplyInfo record) {
|
||||
return backApplyMapper.getbackList(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertTaskAgreement(TmTask task) {
|
||||
return backApplyMapper.insertTaskAgreement(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBackApply(TmTask task) {
|
||||
return backApplyMapper.insertBackApply(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BackApplyInfo> materialList(BackApplyInfo record) {
|
||||
return backApplyMapper.materialList(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int upload(BackApplyInfo record) {
|
||||
return backApplyMapper.upload(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BackApplyInfo> view(BackApplyInfo record) {
|
||||
return backApplyMapper.view(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int del(BackApplyInfo record) {
|
||||
return backApplyMapper.del(record);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
/**
|
||||
* Description:
|
||||
|
|
@ -152,4 +153,9 @@ public class TmTaskServiceImpl implements TmTaskService{
|
|||
return tmTaskMapper.batchInsert(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectTaskNumByMonth(Date date, Integer taskType) {
|
||||
return tmTaskMapper.selectTaskNumByMonth(date,taskType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,409 @@
|
|||
<?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.bonus.sgzb.app.mapper.BackApplyMapper">
|
||||
<resultMap id="BaseResultMap" type="com.bonus.sgzb.app.domain.BmAgreementInfo">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table bm_agreement_info-->
|
||||
<id column="agreement_id" jdbcType="INTEGER" property="agreementId" />
|
||||
<result column="agreement_code" jdbcType="VARCHAR" property="agreementCode" />
|
||||
<result column="sign_time" jdbcType="VARCHAR" property="signTime" />
|
||||
<result column="unit_id" jdbcType="INTEGER" property="unitId" />
|
||||
<result column="project_id" jdbcType="INTEGER" property="projectId" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
<result column="lease_day" jdbcType="INTEGER" property="leaseDay" />
|
||||
<result column="plan_start_time" jdbcType="TIMESTAMP" property="planStartTime" />
|
||||
<result column="contract_code" jdbcType="VARCHAR" property="contractCode" />
|
||||
<result column="auth_person" jdbcType="VARCHAR" property="authPerson" />
|
||||
<result column="phone" jdbcType="VARCHAR" property="phone" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="company_id" jdbcType="INTEGER" property="companyId" />
|
||||
<result column="unit_id" jdbcType="INTEGER" property="unitId" />
|
||||
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
|
||||
<result column="lot_id" jdbcType="INTEGER" property="lotId" />
|
||||
<result column="lot_name" jdbcType="VARCHAR" property="lotName" />
|
||||
|
||||
</resultMap>
|
||||
<insert id="insertTask" keyColumn="task_id" keyProperty="taskId" parameterType="com.bonus.sgzb.base.api.domain.TmTask" useGeneratedKeys="true">
|
||||
insert into tm_task
|
||||
(
|
||||
<if test="taskType != null">
|
||||
task_type,
|
||||
</if>
|
||||
<if test="taskStatus != null">
|
||||
task_status,
|
||||
</if>
|
||||
<if test="code != null and code != ''">
|
||||
code,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="taskType != null">
|
||||
#{taskType},
|
||||
</if>
|
||||
<if test="taskStatus != null">
|
||||
#{taskStatus},
|
||||
</if>
|
||||
<if test="code != null and code != ''">
|
||||
#{code},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertTaskAgreement">
|
||||
insert into tm_task_agreement
|
||||
(
|
||||
<if test="taskId != null">
|
||||
task_id,
|
||||
</if>
|
||||
<if test="agreementId != null">
|
||||
agreement_id,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="taskId != null">
|
||||
#{taskId},
|
||||
</if>
|
||||
<if test="agreementId != null">
|
||||
#{agreementId},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertBackApply">
|
||||
insert into back_apply_info
|
||||
(
|
||||
<if test="code != null">
|
||||
code,
|
||||
</if>
|
||||
<if test="taskId != null">
|
||||
task_id,
|
||||
</if>
|
||||
<if test="backPerson != null and backPerson != ''">
|
||||
back_person,
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
phone,
|
||||
</if>
|
||||
<if test="directAuditBy != null">
|
||||
direct_audit_by,
|
||||
</if>
|
||||
<if test="directAuditTime != null and directAuditTime != ''">
|
||||
direct_audit_time,
|
||||
</if>
|
||||
<if test="directAuditRemark != null">
|
||||
direct_audit_remark,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="code != null">
|
||||
#{code},
|
||||
</if>
|
||||
<if test="taskId != null">
|
||||
#{taskId},
|
||||
</if>
|
||||
<if test="backPerson != null and backPerson != ''">
|
||||
#{backPerson},
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
#{phone},
|
||||
</if>
|
||||
<if test="directAuditBy != null">
|
||||
#{directAuditBy},
|
||||
</if>
|
||||
<if test="directAuditTime != null and directAuditTime != ''">
|
||||
#{directAuditTime},
|
||||
</if>
|
||||
<if test="directAuditRemark != null">
|
||||
#{directAuditRemark},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="upload">
|
||||
insert into back_apply_details
|
||||
(
|
||||
<if test="id != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
type_id,
|
||||
</if>
|
||||
<if test="num != null">
|
||||
pre_num,
|
||||
</if>
|
||||
status,
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
update_by,
|
||||
</if>
|
||||
update_time,
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
)
|
||||
values (
|
||||
<if test="id != null">
|
||||
#{id},
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
#{typeId},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
#{num},
|
||||
</if>
|
||||
'0',
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
NOW(),
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
<delete id="del">
|
||||
DELETE FROM back_apply_info WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getbackUnit" resultType="com.bonus.sgzb.app.domain.BmAgreementInfo">
|
||||
SELECT bui.unit_id,
|
||||
bui.unit_name,
|
||||
bai.agreement_id,
|
||||
bai.agreement_code,
|
||||
bpl.lot_id,
|
||||
bpl.lot_name
|
||||
FROM bm_unit_info bui
|
||||
LEFT JOIN bm_unit_person bup on bup.unit_id = bui.unit_id
|
||||
LEFT JOIN bm_agreement_info bai on bai.unit_id=bui.unit_id
|
||||
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bai.project_id
|
||||
WHERE bup.user_id = #{userId}
|
||||
and bui.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="getbackPro" resultType="com.bonus.sgzb.app.domain.BmAgreementInfo">
|
||||
SELECT
|
||||
bpl.lot_id,
|
||||
bpl.lot_name
|
||||
FROM
|
||||
bm_unit_info bui
|
||||
LEFT JOIN bm_agreement_info bai ON bai.unit_id = bui.unit_id
|
||||
LEFT JOIN bm_project_lot bpl on bai.project_id=bpl.lot_id
|
||||
WHERE
|
||||
bui.unit_id=#{unitId}
|
||||
and bui.del_flag='0'
|
||||
</select>
|
||||
<select id="getbackList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
|
||||
SELECT
|
||||
bai.id,
|
||||
us.user_name as userName,
|
||||
bai.phone,
|
||||
bpl.lot_name as lotName,
|
||||
bui.unit_name as unitName,
|
||||
bagi.plan_start_time as planStartTime,
|
||||
tt.task_status as taskStatus,
|
||||
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
|
||||
GROUP_CONCAT(CONCAT_WS('/', IFNULL(mt3.type_name, ''))) AS typeName
|
||||
FROM
|
||||
back_apply_info bai
|
||||
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
|
||||
LEFT JOIN tm_task tt on tt.task_id=bai.task_id
|
||||
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
|
||||
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id
|
||||
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bagi.project_id
|
||||
LEFT JOIN bm_unit_info bui on bui.unit_id=bagi.unit_id
|
||||
LEFT JOIN sys_user us on us.user_id=bai.create_by
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id=mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id=mt3.parent_id
|
||||
WHERE
|
||||
bai.company_id=#{companyId}
|
||||
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
|
||||
</select>
|
||||
|
||||
<select id="materialList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
|
||||
SELECT
|
||||
subquery1.type_id as typeId,
|
||||
subquery1.typeName typeCode,
|
||||
subquery1.typeNames as typeName,
|
||||
subquery1.out_num - COALESCE(subquery2.pre_num, 0) AS num,
|
||||
subquery1.ma_code as maCode
|
||||
FROM
|
||||
(
|
||||
-- 第一个查询作为子查询
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt.type_name as typeName,
|
||||
CONCAT_WS('/', IFNULL(mt3.type_name, '')) AS typeNames,
|
||||
lod.out_num,
|
||||
mm.ma_code
|
||||
FROM
|
||||
tm_task_agreement tta
|
||||
LEFT JOIN lease_apply_info lai on lai.task_id=tta.task_id
|
||||
LEFT JOIN lease_out_details lod on lod.parent_id=lai.id
|
||||
LEFT JOIN ma_type mt on mt.type_id=lod.type_id
|
||||
LEFT JOIN tm_task tt on tt.task_id=tta.task_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id=lod.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id=mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id=mt3.parent_id
|
||||
LEFT JOIN ma_machine mm on mm.ma_id=lod.ma_id
|
||||
WHERE
|
||||
tta.agreement_id=#{agreementId}
|
||||
and tt.task_type='29'
|
||||
and tt.task_status='35'
|
||||
) AS subquery1
|
||||
LEFT JOIN
|
||||
(
|
||||
-- 第二个查询作为子查询
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt.type_name,
|
||||
CONCAT_WS('/', IFNULL(mt3.type_name, '')) AS typeNames,
|
||||
bad.pre_num
|
||||
FROM
|
||||
tm_task tt
|
||||
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
|
||||
LEFT JOIN back_apply_info bai on bai.task_id=tta.task_id
|
||||
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
|
||||
LEFT JOIN ma_type mt on mt.type_id=bad.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id=mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id=mt3.parent_id
|
||||
WHERE
|
||||
tta.agreement_id=#{agreementId}
|
||||
and tt.task_type='36'
|
||||
and tt.task_status='40'
|
||||
) AS subquery2
|
||||
ON subquery1.type_id = subquery2.type_id
|
||||
</select>
|
||||
|
||||
<select id="view" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
|
||||
SELECT
|
||||
mt.type_name typeCode,
|
||||
CONCAT_WS('/', IFNULL(mt3.type_name, '')) AS typeName,
|
||||
bad.pre_num as num,
|
||||
mm.ma_code as maCode
|
||||
FROM
|
||||
back_apply_details bad
|
||||
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
|
||||
LEFT JOIN ma_type mt on mt.type_id=bad.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id=mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id=mt3.parent_id
|
||||
LEFT JOIN ma_machine mm on mm.type_id=bad.type_id
|
||||
WHERE
|
||||
bai.id=#{id}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -27,6 +27,9 @@
|
|||
from tm_task
|
||||
where task_id = #{taskId,jdbcType=BIGINT}
|
||||
</select>
|
||||
<select id="selectTaskNumByMonth" resultType="java.lang.Integer">
|
||||
select count(*) from tm_task where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m') and task_type = #{taskType}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from tm_task
|
||||
|
|
|
|||
|
|
@ -135,7 +135,14 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService
|
|||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
int taskNum = taskMapper.selectTaskNumByMonth(nowDate,23) + 1;
|
||||
String code = "XG" + format + "-000" + taskNum;
|
||||
String code="";
|
||||
if (taskNum>9 && taskNum<100){
|
||||
code = "XG" + format + "-00" + taskNum;
|
||||
}else if (taskNum>99 && taskNum<1000){
|
||||
code = "XG" + format + "-0" + taskNum;
|
||||
}else {
|
||||
code = "XG" + format + "-000" + taskNum;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<select id="selectTaskNumByMonth" resultType="java.lang.Integer">
|
||||
select count(*) from tm_task where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m') and task_type = #{date}
|
||||
select count(*) from tm_task where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m') and task_type = #{taskType}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
package com.bonus.sgzb.system.controller;
|
||||
|
||||
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.sgzb.common.log.annotation.Log;
|
||||
import com.bonus.sgzb.common.log.enums.BusinessType;
|
||||
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||
import com.bonus.sgzb.system.api.domain.SysDept;
|
||||
import com.bonus.sgzb.system.api.domain.SysRole;
|
||||
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||
import com.bonus.sgzb.system.domain.SysMenu;
|
||||
import com.bonus.sgzb.system.domain.SysUserRole;
|
||||
import com.bonus.sgzb.system.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class SysAuthController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysAuthService authService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private ISysMenuService menuService;
|
||||
|
||||
@RequiresPermissions("system:role:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRole role)
|
||||
{
|
||||
startPage();
|
||||
List<SysRole> list = authService.selectRoleList(role);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@RequiresPermissions("system:menu:list")
|
||||
@GetMapping("/lists")
|
||||
public AjaxResult list(SysMenu menu)
|
||||
{
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||
return success(menus);
|
||||
}
|
||||
|
||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:role:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysRole role)
|
||||
{
|
||||
List<SysRole> list = authService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
util.exportExcel(response, list, "角色数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色编号获取详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:role:query")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public AjaxResult getInfo(@PathVariable Long roleId)
|
||||
{
|
||||
authService.checkRoleDataScope(roleId);
|
||||
return success(authService.selectRoleById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:add")
|
||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
if (!authService.checkRoleNameUnique(role))
|
||||
{
|
||||
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (!authService.checkRoleKeyUnique(role))
|
||||
{
|
||||
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(authService.insertRole(role));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
authService.checkRoleAllowed(role);
|
||||
authService.checkRoleDataScope(role.getRoleId());
|
||||
if (!authService.checkRoleNameUnique(role))
|
||||
{
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (!authService.checkRoleKeyUnique(role))
|
||||
{
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(authService.updateRole(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据权限
|
||||
*/
|
||||
@RequiresPermissions("system:auth:edit")
|
||||
@Log(title = "权限管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/dataScope")
|
||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||
{
|
||||
authService.checkRoleAllowed(role);
|
||||
authService.checkRoleDataScope(role.getRoleId());
|
||||
return toAjax(authService.authDataScope(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||
{
|
||||
authService.checkRoleAllowed(role);
|
||||
authService.checkRoleDataScope(role.getRoleId());
|
||||
role.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(authService.updateRoleStatus(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:remove")
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] roleIds)
|
||||
{
|
||||
return toAjax(authService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色选择框列表
|
||||
*/
|
||||
@RequiresPermissions("system:role:query")
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
return success(authService.selectRoleAll());
|
||||
}
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@RequiresPermissions("system:role:list")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public TableDataInfo allocatedList(SysUser user)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectAllocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@RequiresPermissions("system:role:list")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public TableDataInfo unallocatedList(SysUser user)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUnallocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户
|
||||
*/
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
|
||||
{
|
||||
return toAjax(authService.deleteAuthUser(userRole));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户
|
||||
*/
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
|
||||
{
|
||||
return toAjax(authService.deleteAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*/
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
||||
{
|
||||
authService.checkRoleDataScope(roleId);
|
||||
return toAjax(authService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色部门树列表
|
||||
*/
|
||||
@RequiresPermissions("system:role:query")
|
||||
@GetMapping(value = "/deptTree/{roleId}")
|
||||
public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ import com.bonus.sgzb.system.service.ISysDeptService;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
/** 机构管理 */
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
public class SysDeptController extends BaseController
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.sgzb.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.sgzb.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
|
@ -22,10 +24,9 @@ import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
|||
import com.bonus.sgzb.system.domain.SysMenu;
|
||||
import com.bonus.sgzb.system.service.ISysMenuService;
|
||||
|
||||
|
||||
/**
|
||||
* 菜单信息
|
||||
*
|
||||
* @author ruoyi
|
||||
* 资源管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/menu")
|
||||
|
|
@ -41,7 +42,7 @@ public class SysMenuController extends BaseController
|
|||
@GetMapping("/list")
|
||||
public AjaxResult list(SysMenu menu)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||
return success(menus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
package com.bonus.sgzb.system.mapper;
|
||||
|
||||
import com.bonus.sgzb.system.api.domain.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限管理
|
||||
*/
|
||||
public interface SysAuthMapper
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public List<SysRole> selectRoleList(SysRole role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRoleAll();
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
public List<Long> selectRoleListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public SysRole selectRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRolesByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param roleName 角色名称
|
||||
* @return 角色信息
|
||||
*/
|
||||
public SysRole checkRoleNameUnique(String roleName);
|
||||
|
||||
/**
|
||||
* 校验角色权限是否唯一
|
||||
*
|
||||
* @param roleKey 角色权限
|
||||
* @return 角色信息
|
||||
*/
|
||||
public SysRole checkRoleKeyUnique(String roleKey);
|
||||
|
||||
/**
|
||||
* 修改角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRole(SysRole role);
|
||||
|
||||
/**
|
||||
* 新增角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRole(SysRole role);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色信息
|
||||
*
|
||||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleByIds(Long[] roleIds);
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
package com.bonus.sgzb.system.service;
|
||||
|
||||
import com.bonus.sgzb.system.api.domain.SysRole;
|
||||
import com.bonus.sgzb.system.domain.SysUserRole;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 权限管理
|
||||
*/
|
||||
public interface ISysAuthService
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public List<SysRole> selectRoleList(SysRole role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRolesByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Set<String> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRoleAll();
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
public List<Long> selectRoleListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public SysRole selectRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkRoleNameUnique(SysRole role);
|
||||
|
||||
/**
|
||||
* 校验角色权限是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkRoleKeyUnique(SysRole role);
|
||||
|
||||
/**
|
||||
* 校验角色是否允许操作
|
||||
*
|
||||
* @param role 角色信息
|
||||
*/
|
||||
public void checkRoleAllowed(SysRole role);
|
||||
|
||||
/**
|
||||
* 校验角色是否有数据权限
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
public void checkRoleDataScope(Long roleId);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserRoleByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 新增保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRole(SysRole role);
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRole(SysRole role);
|
||||
|
||||
/**
|
||||
* 修改角色状态
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRoleStatus(SysRole role);
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int authDataScope(SysRole role);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色信息
|
||||
*
|
||||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleByIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 取消授权用户角色
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAuthUser(SysUserRole userRole);
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要取消授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
/**
|
||||
* 批量选择授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要删除的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds);
|
||||
}
|
||||
|
|
@ -0,0 +1,417 @@
|
|||
package com.bonus.sgzb.system.service.impl;
|
||||
|
||||
import com.bonus.sgzb.common.core.constant.UserConstants;
|
||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||
import com.bonus.sgzb.common.core.utils.SpringUtils;
|
||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||
import com.bonus.sgzb.common.datascope.annotation.DataScope;
|
||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||
import com.bonus.sgzb.system.api.domain.SysRole;
|
||||
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||
import com.bonus.sgzb.system.domain.SysRoleDept;
|
||||
import com.bonus.sgzb.system.domain.SysRoleMenu;
|
||||
import com.bonus.sgzb.system.domain.SysUserRole;
|
||||
import com.bonus.sgzb.system.mapper.*;
|
||||
import com.bonus.sgzb.system.service.ISysAuthService;
|
||||
import com.bonus.sgzb.system.service.ISysRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限管理
|
||||
*/
|
||||
@Service
|
||||
public class SysAuthServiceImpl implements ISysAuthService
|
||||
{
|
||||
@Autowired
|
||||
private SysAuthMapper authMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMenuMapper roleMenuMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleDeptMapper roleDeptMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysRole> selectRoleList(SysRole role)
|
||||
{
|
||||
return authMapper.selectRoleList(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRolesByUserId(Long userId)
|
||||
{
|
||||
List<SysRole> userRoles = authMapper.selectRolePermissionByUserId(userId);
|
||||
List<SysRole> roles = selectRoleAll();
|
||||
for (SysRole role : roles)
|
||||
{
|
||||
for (SysRole userRole : userRoles)
|
||||
{
|
||||
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
|
||||
{
|
||||
role.setFlag(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(Long userId)
|
||||
{
|
||||
List<SysRole> perms = authMapper.selectRolePermissionByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (SysRole perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotNull(perm))
|
||||
{
|
||||
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRoleAll()
|
||||
{
|
||||
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectRoleListByUserId(Long userId)
|
||||
{
|
||||
return authMapper.selectRoleListByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysRole selectRoleById(Long roleId)
|
||||
{
|
||||
return authMapper.selectRoleById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkRoleNameUnique(SysRole role)
|
||||
{
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
SysRole info = authMapper.checkRoleNameUnique(role.getRoleName());
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色权限是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkRoleKeyUnique(SysRole role)
|
||||
{
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
SysRole info = authMapper.checkRoleKeyUnique(role.getRoleKey());
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色是否允许操作
|
||||
*
|
||||
* @param role 角色信息
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleAllowed(SysRole role)
|
||||
{
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
|
||||
{
|
||||
throw new ServiceException("不允许操作超级管理员角色");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色是否有数据权限
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(Long roleId)
|
||||
{
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
||||
{
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
if (StringUtils.isEmpty(roles))
|
||||
{
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int countUserRoleByRoleId(Long roleId)
|
||||
{
|
||||
return userRoleMapper.countUserRoleByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertRole(SysRole role)
|
||||
{
|
||||
// 新增角色信息
|
||||
authMapper.insertRole(role);
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateRole(SysRole role)
|
||||
{
|
||||
// 修改角色信息
|
||||
authMapper.updateRole(role);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色状态
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRoleStatus(SysRole role)
|
||||
{
|
||||
return authMapper.updateRole(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int authDataScope(SysRole role)
|
||||
{
|
||||
// // 修改角色信息
|
||||
// authMapper.updateRole(role);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
|
||||
// 新增角色和部门信息(数据权限)
|
||||
return insertRoleDept(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色菜单信息
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleMenu(SysRole role)
|
||||
{
|
||||
int rows = 1;
|
||||
// 新增用户与角色管理
|
||||
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
|
||||
for (Long menuId : role.getMenuIds())
|
||||
{
|
||||
SysRoleMenu rm = new SysRoleMenu();
|
||||
rm.setRoleId(role.getRoleId());
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
rows = roleMenuMapper.batchRoleMenu(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色部门信息(数据权限)
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleDept(SysRole role)
|
||||
{
|
||||
int rows = 1;
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
|
||||
for (Long deptId : role.getDeptIds())
|
||||
{
|
||||
SysRoleDept rd = new SysRoleDept();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
rows = roleDeptMapper.batchRoleDept(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleById(Long roleId)
|
||||
{
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDeptByRoleId(roleId);
|
||||
return authMapper.deleteRoleById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色信息
|
||||
*
|
||||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleByIds(Long[] roleIds)
|
||||
{
|
||||
for (Long roleId : roleIds)
|
||||
{
|
||||
checkRoleAllowed(new SysRole(roleId));
|
||||
checkRoleDataScope(roleId);
|
||||
SysRole role = selectRoleById(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0)
|
||||
{
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenu(roleIds);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDept(roleIds);
|
||||
return authMapper.deleteRoleByIds(roleIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户角色
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUser(SysUserRole userRole)
|
||||
{
|
||||
return userRoleMapper.deleteUserRoleInfo(userRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要取消授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds)
|
||||
{
|
||||
return userRoleMapper.deleteUserRoleInfos(roleId, userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds)
|
||||
{
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
for (Long userId : userIds)
|
||||
{
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
return userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
<?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.bonus.sgzb.system.mapper.SysAuthMapper">
|
||||
|
||||
<resultMap type="com.bonus.sgzb.system.api.domain.SysRole" id="SysRoleResult">
|
||||
<id property="roleId" column="role_id" />
|
||||
<result property="roleName" column="role_name" />
|
||||
<result property="roleKey" column="role_key" />
|
||||
<result property="roleSort" column="role_sort" />
|
||||
<result property="dataScope" column="data_scope" />
|
||||
<result property="menuCheckStrictly" column="menu_check_strictly" />
|
||||
<result property="deptCheckStrictly" column="dept_check_strictly" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||
r.status
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleList" parameterType="com.bonus.sgzb.system.api.domain.SysRole" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.del_flag = '0'
|
||||
<if test="roleId != null and roleId != 0">
|
||||
AND r.role_id = #{roleId}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
AND r.role_name like concat('%', #{roleName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
<if test="roleKey != null and roleKey != ''">
|
||||
AND r.role_key like concat('%', #{roleKey}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
GROUP BY r.role_id
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleAll" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
|
||||
select r.role_id
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and u.user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.role_name=#{roleName} and r.del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertRole" parameterType="com.bonus.sgzb.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
insert into sys_role(
|
||||
<if test="roleId != null and roleId != 0">role_id,</if>
|
||||
<if test="roleName != null and roleName != ''">role_name,</if>
|
||||
<if test="roleKey != null and roleKey != ''">role_key,</if>
|
||||
<if test="roleSort != null">role_sort,</if>
|
||||
<if test="dataScope != null and dataScope != ''">data_scope,</if>
|
||||
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
|
||||
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="roleId != null and roleId != 0">#{roleId},</if>
|
||||
<if test="roleName != null and roleName != ''">#{roleName},</if>
|
||||
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
|
||||
<if test="roleSort != null">#{roleSort},</if>
|
||||
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
|
||||
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
|
||||
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateRole" parameterType="com.bonus.sgzb.system.api.domain.SysRole">
|
||||
update sys_role
|
||||
<set>
|
||||
<if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
|
||||
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
|
||||
<if test="roleSort != null">role_sort = #{roleSort},</if>
|
||||
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
|
||||
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
|
||||
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where role_id = #{roleId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteRoleById" parameterType="Long">
|
||||
update sys_role set del_flag = '2' where role_id = #{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRoleByIds" parameterType="Long">
|
||||
update sys_role set del_flag = '2' where role_id in
|
||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -20,10 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeptVo">
|
||||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
|
||||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,
|
||||
d.remark
|
||||
from sys_dept d
|
||||
</sql>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||
r.status, r.del_flag, r.create_time, r.remark
|
||||
r.status, r.del_flag, r.create_time, r.remark ,IFNULL(CONCAT_WS('/', d3.dept_name, d2.dept_name, d1.dept_name), 'Unknown') AS dept_name
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
LEFT JOIN sys_dept d1 ON d1.dept_id = r.company_id
|
||||
LEFT JOIN sys_dept d2 ON d2.dept_id = d1.parent_id
|
||||
LEFT JOIN sys_dept d3 ON d3.dept_id = d2.parent_id
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleList" parameterType="com.bonus.sgzb.system.api.domain.SysRole" resultMap="SysRoleResult">
|
||||
|
|
@ -53,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
GROUP BY r.role_id
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue