diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachine.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachine.java index 3a59e2e9..0e5b16dd 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachine.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachine.java @@ -47,6 +47,11 @@ public class MaMachine extends BaseEntity { */ @ApiModelProperty(value = "机具状态(数据字典)") private String maStatus; + /** + * 机具状态(数据字典) + */ + @ApiModelProperty(value = "机具状态(数据字典)名称") + private String maStatusName; /** * 二维码 */ @@ -354,4 +359,12 @@ public class MaMachine extends BaseEntity { public void setSpecificationType(String specificationType) { this.specificationType = specificationType; } + + public String getMaStatusName() { + return maStatusName; + } + + public void setMaStatusName(String maStatusName) { + this.maStatusName = maStatusName; + } } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/TmTask.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/TmTask.java index fbfa6959..b2ced482 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/TmTask.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/TmTask.java @@ -101,4 +101,10 @@ public class TmTask implements Serializable { @ApiModelProperty(value="领料任务详情集合") private List leaseApplyDetails; + private Integer agreementId; + private Integer backPerson; + private String phone; + private String directAuditBy; + private String directAuditTime; + private String directAuditRemark; } \ No newline at end of file diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java index 78383fc0..c85a14b7 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java @@ -55,6 +55,9 @@ public class SysDept extends BaseEntity /** 子部门 */ private List children = new ArrayList(); + /** 备注信息 */ + 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(); } } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysRole.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysRole.java index bb66a850..b27605a3 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysRole.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysRole.java @@ -63,6 +63,8 @@ public class SysRole extends BaseEntity /** 角色菜单权限 */ private Set 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(); } } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackApplyController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackApplyController.java new file mode 100644 index 00000000..8c7e2afe --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackApplyController.java @@ -0,0 +1,287 @@ +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.base.domain.WarehouseKeeper; +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 io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +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 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 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 list =backApplyService.view(record); + return success(list); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 退料审核明细 + * + * @param record 查询条件 + * @return AjaxResult对象 + */ + @Log(title = "退料审核明细", businessType = BusinessType.QUERY) + @GetMapping("examineView") + public AjaxResult examineView(@RequestBody BackApplyInfo record) { + try { + List list =backApplyService.examineView(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 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 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; + } + + + + /** + * 退料审核列表 + * + * @param record 查询条件 + * @return AjaxResult对象 + */ + @Log(title = "退料审核列表", businessType = BusinessType.QUERY) + @PostMapping("examineList") + public AjaxResult examineList(@RequestBody BackApplyInfo record) { + try { + List list =backApplyService.examineList(record); + return success(list); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + @ApiOperation("退料审核列表-审核") + @Log(title = "退料审核列表-审核", businessType = BusinessType.UPDATE) + @PostMapping("/audit") + public AjaxResult audit(String id) + { + return toAjax(backApplyService.audit(id)); + } + +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java new file mode 100644 index 00000000..87618774 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java @@ -0,0 +1,84 @@ +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; + /** + * 审核备注 + */ + private String directAuditRemark; +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BmAgreementInfo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BmAgreementInfo.java index 1a0cca29..8fd7b089 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BmAgreementInfo.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BmAgreementInfo.java @@ -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; + } } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackApplyMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackApplyMapper.java new file mode 100644 index 00000000..d9c0355c --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackApplyMapper.java @@ -0,0 +1,45 @@ +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 getbackUnit(BmAgreementInfo record); + + /** + * 查询退料工程列表 + */ + List getbackPro(BmAgreementInfo record); + + int insertTask(TmTask task); + + List getbackList(BackApplyInfo record); + + int insertTaskAgreement(TmTask task); + + int insertBackApply(TmTask task); + + List materialList(BackApplyInfo record); + + int upload(BackApplyInfo record); + + List view(BackApplyInfo record); + + int del(BackApplyInfo record); + + List examineList(BackApplyInfo record); + + List examineView(BackApplyInfo record); + + int audit(String id); +} \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java index bb32373d..77d91510 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java @@ -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 list); int batchInsert(@Param("list") List list); + + int selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/BackApplyService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/BackApplyService.java new file mode 100644 index 00000000..5cbf9735 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/BackApplyService.java @@ -0,0 +1,48 @@ +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 getbackUnit(BmAgreementInfo record); + + /** + * 查询退料工程列表 + */ + List getbackPro(BmAgreementInfo record); + + /** + * 创建任务单 + */ + int insertTask(TmTask task); + + /** + * 退料申请列表 + */ + List getbackList(BackApplyInfo record); + + int insertTaskAgreement(TmTask task); + + int insertBackApply(TmTask task); + + List materialList(BackApplyInfo record); + + int upload(BackApplyInfo record); + + List view(BackApplyInfo record); + + int del(BackApplyInfo record); + + List examineList(BackApplyInfo record); + + List examineView(BackApplyInfo record); + + int audit(String id); +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java index 4395c513..516b0b86 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/TmTaskService.java @@ -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 list); + int selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackApplyServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackApplyServiceImpl.java new file mode 100644 index 00000000..d9ed5357 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackApplyServiceImpl.java @@ -0,0 +1,89 @@ +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 getbackUnit(BmAgreementInfo record) { + return backApplyMapper.getbackUnit(record); + } + + @Override + public List getbackPro(BmAgreementInfo record) { + return backApplyMapper.getbackPro(record); + } + + @Override + public int insertTask(TmTask task) { + return backApplyMapper.insertTask(task); + } + + @Override + public List 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 materialList(BackApplyInfo record) { + return backApplyMapper.materialList(record); + } + + @Override + public int upload(BackApplyInfo record) { + return backApplyMapper.upload(record); + } + + @Override + public List view(BackApplyInfo record) { + return backApplyMapper.view(record); + } + + @Override + public int del(BackApplyInfo record) { + return backApplyMapper.del(record); + } + + @Override + public List examineList(BackApplyInfo record) { + return backApplyMapper.examineList(record); + } + + @Override + public List examineView(BackApplyInfo record) { + return backApplyMapper.examineView(record); + } + + @Override + public int audit(String id) { + return backApplyMapper.audit(id); + } + +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index 513f2384..f15ae2f2 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -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); + } + } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index 01dffced..542e5fb5 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -64,6 +64,20 @@ public class MaTypeController extends BaseController { return AjaxResult.success(maTypeList); } + /** + * 根据左列表类型id查询右表格 + * @param typeId + * @return + */ + + @ApiOperation(value = "工器具类型") + @GetMapping("/equipmentType") + public AjaxResult equipmentType(@RequestParam(required = false) Long typeId, + @RequestParam(required = false) String typeName){ + List listByMaType = iTypeService.getEquipmentType(typeId,typeName); + return success(listByMaType); + } + /** * 获取规格层级为3的设备列表 * @return 结果 @@ -161,6 +175,19 @@ public class MaTypeController extends BaseController { */ @ApiOperation(value = "根据左列表类型id查询右表格") @GetMapping("/getListByMaType") + public AjaxResult getListByMaType(@RequestParam(required = false) Long typeId, + @RequestParam(required = false) String typeName){ + List listByMaType = iTypeService.getListByParentId(typeId,typeName); + return success(listByMaType); + } + +/* *//** + * 根据左列表类型id查询右表格 + * @param typeId + * @return + *//* + @ApiOperation(value = "根据左列表类型id查询右表格") + @GetMapping("/getListByMaType") public TableDataInfo getListByMaType(@RequestParam(required = false) Long typeId, @RequestParam(required = false) String typeName, @RequestParam(required = false) Integer pageSize, @@ -172,12 +199,12 @@ public class MaTypeController extends BaseController { TableDataInfo rspData = new TableDataInfo(); rspData.setTotal(listByMaType.size()); rspData.setCode(HttpStatus.SUCCESS); - listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); +// listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); rspData.setRows(listByMaType); rspData.setMsg("查询成功"); return rspData; - } + }*/ /** * 获取机具类型管理ma_type详细信息 @@ -217,8 +244,7 @@ public class MaTypeController extends BaseController { @ApiOperation(value = "删除机具类型管理ma_type") @Log(title = "机具类型管理ma_type", businessType = BusinessType.DELETE) @DeleteMapping("/{typeId}") - public AjaxResult remove(@PathVariable Long typeId) - { + public AjaxResult remove(@PathVariable Long typeId) throws Exception { return toAjax(iTypeService.deleteMaTypeByTypeId(typeId)); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java index cf8403ee..6e662b89 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java @@ -46,7 +46,7 @@ public interface ITypeService { * @param typeId 机具类型管理ma_type主键 * @return 结果 */ - public int deleteMaTypeByTypeId(Long typeId); + public int deleteMaTypeByTypeId(Long typeId) throws Exception; /** * 构建前端所需要树结构 diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java index d1322b2d..b52d6306 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineServiceImpl.java @@ -22,12 +22,7 @@ public class MaMachineServiceImpl implements MaMachineService { @Override public List getMaMachine(MaMachine maMachine) { - List maMachineList = maMachineMapper.getMaMachine(maMachine); - for (MaMachine machine : maMachineList) { - // 添加查询物品种类,设备类型,规格型号 - getType(machine); - } - return maMachineList; + return maMachineMapper.getMaMachine(maMachine); } /** diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index b53362c9..f8348c2d 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -48,23 +48,31 @@ public class MaTypeServiceImpl implements ITypeService { @Override @Transactional public int insertMaType(MaType maType) { + Long parentId = maType.getParentId(); + MaType maType1 = maTypeMapper.selectMaTypeByTypeId(parentId); + String level = maType1.getLevel(); + maType.setLevel(String.valueOf(Integer.parseInt(level) + 1)); maType.setCreateTime(DateUtils.getNowDate()); int i = maTypeMapper.insertType(maType); Long typeId = maType.getTypeId(); // 图片路径保存 - MaTypeFile typeFile = new MaTypeFile(); - typeFile.setTypeId(typeId); - typeFile.setFileName(maType.getPhotoName()); - typeFile.setFileUrl(maType.getPhotoUrl()); - typeFile.setFileType(""); - typeFileMapper.insertMaTypeFile(typeFile); + if (StringUtils.isNotEmpty(maType.getPhotoName()) && StringUtils.isNotEmpty(maType.getPhotoUrl())) { + MaTypeFile typeFile = new MaTypeFile(); + typeFile.setTypeId(typeId); + typeFile.setFileName(maType.getPhotoName()); + typeFile.setFileUrl(maType.getPhotoUrl()); + typeFile.setFileType(""); + typeFileMapper.insertMaTypeFile(typeFile); + } // 文档路径保存 - MaTypeFile typeFile1 = new MaTypeFile(); - typeFile1.setTypeId(typeId); - typeFile1.setFileName(maType.getDocumentName()); - typeFile1.setFileUrl(maType.getDocumentUrl()); - typeFile1.setFileType(""); - typeFileMapper.insertMaTypeFile(typeFile1); + if (StringUtils.isNotEmpty(maType.getDocumentName()) && StringUtils.isNotEmpty(maType.getDocumentUrl())) { + MaTypeFile typeFile1 = new MaTypeFile(); + typeFile1.setTypeId(typeId); + typeFile1.setFileName(maType.getDocumentName()); + typeFile1.setFileUrl(maType.getDocumentUrl()); + typeFile1.setFileType(""); + typeFileMapper.insertMaTypeFile(typeFile1); + } // 库管员配置 MaTypeKeeper typeKeeper = new MaTypeKeeper(); typeKeeper.setUserId(maType.getKeeperUserId()); @@ -145,7 +153,11 @@ public class MaTypeServiceImpl implements ITypeService { * @return 结果 */ @Override - public int deleteMaTypeByTypeId(Long typeId) { + public int deleteMaTypeByTypeId(Long typeId) throws Exception { + List listByParentId = maTypeMapper.getListByParentId(typeId, ""); + if (listByParentId.size() > 0) { + throw new Exception("子级类型不为空!!!"); + } return maTypeMapper.deleteTypeById(typeId); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/largeScreen/util/CommonUtil.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/largeScreen/util/CommonUtil.java index 9b7b34d7..1d0162d5 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/largeScreen/util/CommonUtil.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/largeScreen/util/CommonUtil.java @@ -76,7 +76,6 @@ public class CommonUtil { valueList.add(0); return valueList; } - ; BigDecimal numberValue = new BigDecimal(new Double(0).toString()); BigDecimal countValue = new BigDecimal(new Double(0).toString()); for (int i = 0; i < list.size(); i++) { diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackApplyMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackApplyMapper.xml new file mode 100644 index 00000000..f067c8a7 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackApplyMapper.xml @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into tm_task + ( + + task_type, + + + task_status, + + + code, + + + create_by, + + + update_by, + + + update_time, + + + remark, + + + company_id, + + create_time + ) values ( + + #{taskType}, + + + #{taskStatus}, + + + #{code}, + + + #{createBy}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + insert into tm_task_agreement + ( + + task_id, + + + agreement_id, + + + create_by, + + + update_by, + + + update_time, + + + remark, + + + company_id, + + create_time + ) values ( + + #{taskId}, + + + #{agreementId}, + + + #{createBy}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + insert into back_apply_info + ( + + code, + + + task_id, + + + back_person, + + + phone, + + + direct_audit_by, + + + direct_audit_time, + + + direct_audit_remark, + + + create_by, + + + update_by, + + + update_time, + + + remark, + + + company_id, + + create_time + ) values ( + + #{code}, + + + #{taskId}, + + + #{backPerson}, + + + #{phone}, + + + #{directAuditBy}, + + + #{directAuditTime}, + + + #{directAuditRemark}, + + + #{createBy}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into back_apply_details + ( + + parent_id, + + + type_id, + + + pre_num, + + status, + + create_by, + + + update_by, + + update_time, + + remark, + + + company_id, + + create_time + ) + values ( + + #{id}, + + + #{typeId}, + + + #{num}, + + '0', + + #{createBy}, + + + #{createBy}, + + NOW(), + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + UPDATE tm_task SET task_status = 38 WHERE task_id = #{id} + + + DELETE FROM back_apply_info WHERE id = #{id} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml index 52f1207d..3d9fd5ed 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml @@ -27,6 +27,9 @@ from tm_task where task_id = #{taskId,jdbcType=BIGINT} + delete from tm_task diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml index 8372e64b..3d49ec35 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml @@ -37,11 +37,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -276,7 +215,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml index c60984a1..690526b4 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml @@ -289,9 +289,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time, m.remark, m.company_id from ma_type m - - level != 4 and m.status = '0' - + where level != 4 and m.status = '0' and del_flag = '0' - and supplier = #{supplier} + and supplier like concat('%',#{supplier},'%') and address = #{address} and legal_person = #{legalPerson} and primary_contact = #{primaryContact} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/ReturnOfMaterialsInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/ReturnOfMaterialsInfoController.java new file mode 100644 index 00000000..7bf076dd --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/ReturnOfMaterialsInfoController.java @@ -0,0 +1,37 @@ +package com.bonus.sgzb.material.controller; + +import com.bonus.sgzb.common.core.web.controller.BaseController; +import com.bonus.sgzb.common.core.web.page.TableDataInfo; +import com.bonus.sgzb.material.domain.ReturnOfMaterialsInfo; +import com.bonus.sgzb.material.service.ReturnOfMaterialsInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.bonus.sgzb.material.domain.AgreementInfo; +import java.util.List; + +/** + * @author lsun + */ +@Api(tags = " 退料入库") +@RestController +@RequestMapping("/returnOfMaterialsInfo") +public class ReturnOfMaterialsInfoController extends BaseController { + @Autowired + private ReturnOfMaterialsInfoService returnOfMaterialsInfoService; + + /** + * 获取协议管理列表 + */ + @ApiOperation(value = "获取协议管理列表") + @GetMapping("/getReturnOfMaterialsInfoAll") + public TableDataInfo getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean) + { + startPage(); + List list = returnOfMaterialsInfoService.getReturnOfMaterialsInfoAll(bean); + return getDataTable(list); + } +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReturnOfMaterialsInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReturnOfMaterialsInfo.java new file mode 100644 index 00000000..c33984b2 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReturnOfMaterialsInfo.java @@ -0,0 +1,64 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author lsun + * 退料入库 + */ +@Data +public class ReturnOfMaterialsInfo { + + + @ApiModelProperty(value = "id") + private Long id; + + /** 退料单号 */ + @ApiModelProperty(value = "退料单号") + private String code; + + /** 退料单位 */ + @ApiModelProperty(value = "退料单位") + private String unitName; + + /** 退料工程 */ + @ApiModelProperty(value = "退料工程") + private String lotName; + + + @ApiModelProperty(value = "机具id") + private Long kindId; + @ApiModelProperty(value = "机具名称") + private String kindName; + @ApiModelProperty(value = "类型id") + private Long typeId; + @ApiModelProperty(value = "类型ids") + private String typeIds; + @ApiModelProperty(value = "类型名称") + private String typeName; + @ApiModelProperty(value = "规格型号id") + private Long modelId; + @ApiModelProperty(value = "规格型号") + private String modelName; + + + @ApiModelProperty(value = "入库数量") + private String inputNum; + + @ApiModelProperty(value = "编号") + private String maCode; + + @ApiModelProperty(value = "退料时间") + private String returnTime; + + @ApiModelProperty(value = "提交入库时间") + private String submitStorageTime; + + @ApiModelProperty(value = "提交入库人员") + private String submitToStoragePersonnel; + + @ApiModelProperty(value = "备注") + private String remark; + +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReturnOfMaterialsInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReturnOfMaterialsInfoMapper.java new file mode 100644 index 00000000..7d941cab --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReturnOfMaterialsInfoMapper.java @@ -0,0 +1,17 @@ +package com.bonus.sgzb.material.mapper; + + +import com.bonus.sgzb.material.domain.ReturnOfMaterialsInfo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +/** + * @author lsun + */ +@Mapper +public interface ReturnOfMaterialsInfoMapper { + + List getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean); +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/ReturnOfMaterialsInfoService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/ReturnOfMaterialsInfoService.java new file mode 100644 index 00000000..6912da12 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/ReturnOfMaterialsInfoService.java @@ -0,0 +1,14 @@ +package com.bonus.sgzb.material.service; + + +import com.bonus.sgzb.material.domain.ReturnOfMaterialsInfo; + +import java.util.List; + +/** + * @author lsun + */ +public interface ReturnOfMaterialsInfoService { + + List getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean); +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckInfoServiceImpl.java index 1785868c..9e824bba 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckInfoServiceImpl.java @@ -134,7 +134,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; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ReturnOfMaterialsInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ReturnOfMaterialsInfoServiceImpl.java new file mode 100644 index 00000000..afe61f02 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ReturnOfMaterialsInfoServiceImpl.java @@ -0,0 +1,24 @@ +package com.bonus.sgzb.material.service.impl; + +import com.bonus.sgzb.material.domain.ReturnOfMaterialsInfo; +import com.bonus.sgzb.material.mapper.ReturnOfMaterialsInfoMapper; +import com.bonus.sgzb.material.service.ReturnOfMaterialsInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author lsun + */ +@Service +public class ReturnOfMaterialsInfoServiceImpl implements ReturnOfMaterialsInfoService { + + @Autowired + private ReturnOfMaterialsInfoMapper returnOfMaterialsInfoMapper; + + @Override + public List getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean) { + return returnOfMaterialsInfoMapper.getReturnOfMaterialsInfoAll(bean); + } +} diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ReturnOfMaterialsInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ReturnOfMaterialsInfoMapper.xml new file mode 100644 index 00000000..830f1d68 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ReturnOfMaterialsInfoMapper.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/TaskMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/TaskMapper.xml index 156bab49..ee2b64b7 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/TaskMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/TaskMapper.xml @@ -90,6 +90,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" \ No newline at end of file diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysAuthController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysAuthController.java new file mode 100644 index 00000000..f8648dcd --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysAuthController.java @@ -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 list = authService.selectRoleList(role); + return getDataTable(list); + } + + /** + * 获取菜单列表 + */ + @RequiresPermissions("system:menu:list") + @GetMapping("/lists") + public AjaxResult list(SysMenu menu) + { + Long userId = SecurityUtils.getLoginUser().getUserid(); + List 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 list = authService.selectRoleList(role); + ExcelUtil util = new ExcelUtil(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 list = userService.selectAllocatedList(user); + return getDataTable(list); + } + + /** + * 查询未分配用户角色列表 + */ + @RequiresPermissions("system:role:list") + @GetMapping("/authUser/unallocatedList") + public TableDataInfo unallocatedList(SysUser user) + { + startPage(); + List 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; + } +} diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java index dd32bee0..94936d7a 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java @@ -28,6 +28,7 @@ import com.bonus.sgzb.system.service.ISysDeptService; * * @author ruoyi */ +/** 机构管理 */ @RestController @RequestMapping("/dept") public class SysDeptController extends BaseController diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysMenuController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysMenuController.java index a0853c0c..02ef9061 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysMenuController.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysMenuController.java @@ -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 menus = menuService.selectMenuList(menu, userId); return success(menus); } diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysAuthMapper.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysAuthMapper.java new file mode 100644 index 00000000..d1ba13d0 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysAuthMapper.java @@ -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 selectRoleList(SysRole role); + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolePermissionByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + public List selectRoleListByUserId(Long userId); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public SysRole selectRoleById(Long roleId); + + /** + * 根据用户ID查询角色 + * + * @param userName 用户名 + * @return 角色列表 + */ + public List 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); +} diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysAuthService.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysAuthService.java new file mode 100644 index 00000000..bdb60089 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysAuthService.java @@ -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 selectRoleList(SysRole role); + + /** + * 根据用户ID查询角色列表 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolesByUserId(Long userId); + + /** + * 根据用户ID查询角色权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectRolePermissionByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + public List 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); +} diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysAuthServiceImpl.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysAuthServiceImpl.java new file mode 100644 index 00000000..afac878c --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysAuthServiceImpl.java @@ -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 selectRoleList(SysRole role) + { + return authMapper.selectRoleList(role); + } + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + @Override + public List selectRolesByUserId(Long userId) + { + List userRoles = authMapper.selectRolePermissionByUserId(userId); + List 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 selectRolePermissionByUserId(Long userId) + { + List perms = authMapper.selectRolePermissionByUserId(userId); + Set 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 selectRoleAll() + { + return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); + } + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + @Override + public List 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 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 list = new ArrayList(); + 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 list = new ArrayList(); + 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 list = new ArrayList(); + for (Long userId : userIds) + { + SysUserRole ur = new SysUserRole(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } + return userRoleMapper.batchUserRole(list); + } +} diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysAuthMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysAuthMapper.xml new file mode 100644 index 00000000..cd7c29c9 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysAuthMapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + + + + + + + + + insert into sys_role( + role_id, + role_name, + role_key, + role_sort, + data_scope, + menu_check_strictly, + dept_check_strictly, + status, + remark, + create_by, + create_time + )values( + #{roleId}, + #{roleName}, + #{roleKey}, + #{roleSort}, + #{dataScope}, + #{menuCheckStrictly}, + #{deptCheckStrictly}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + update sys_role + + role_name = #{roleName}, + role_key = #{roleKey}, + role_sort = #{roleSort}, + data_scope = #{dataScope}, + menu_check_strictly = #{menuCheckStrictly}, + dept_check_strictly = #{deptCheckStrictly}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where role_id = #{roleId} + + + + update sys_role set del_flag = '2' where role_id = #{roleId} + + + + update sys_role set del_flag = '2' where role_id in + + #{roleId} + + + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml index df64162c..aa210e79 100644 --- a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -20,10 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - 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 diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysRoleMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysRoleMapper.xml index 250cfa8e..eafbf884 100644 --- a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -19,15 +19,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + 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