Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
liuchuan 2023-12-18 16:19:43 +08:00
commit b49dcb447d
40 changed files with 2494 additions and 108 deletions

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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<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("examineView")
public AjaxResult examineView(@RequestBody BackApplyInfo record) {
try {
List<BackApplyInfo> 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<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;
}
/**
* 退料审核列表
*
* @param record 查询条件
* @return AjaxResult对象
*/
@Log(title = "退料审核列表", businessType = BusinessType.QUERY)
@PostMapping("examineList")
public AjaxResult examineList(@RequestBody BackApplyInfo record) {
try {
List<BackApplyInfo> 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));
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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<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);
List<BackApplyInfo> examineList(BackApplyInfo record);
List<BackApplyInfo> examineView(BackApplyInfo record);
int audit(String id);
}

View File

@ -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);
}

View File

@ -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<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);
List<BackApplyInfo> examineList(BackApplyInfo record);
List<BackApplyInfo> examineView(BackApplyInfo record);
int audit(String id);
}

View File

@ -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);
}

View File

@ -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<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);
}
@Override
public List<BackApplyInfo> examineList(BackApplyInfo record) {
return backApplyMapper.examineList(record);
}
@Override
public List<BackApplyInfo> examineView(BackApplyInfo record) {
return backApplyMapper.examineView(record);
}
@Override
public int audit(String id) {
return backApplyMapper.audit(id);
}
}

View File

@ -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);
}
}

View File

@ -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<MaType> 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<MaType> 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));
}

View File

@ -46,7 +46,7 @@ public interface ITypeService {
* @param typeId 机具类型管理ma_type主键
* @return 结果
*/
public int deleteMaTypeByTypeId(Long typeId);
public int deleteMaTypeByTypeId(Long typeId) throws Exception;
/**
* 构建前端所需要树结构

View File

@ -22,12 +22,7 @@ public class MaMachineServiceImpl implements MaMachineService {
@Override
public List<MaMachine> getMaMachine(MaMachine maMachine) {
List<MaMachine> maMachineList = maMachineMapper.getMaMachine(maMachine);
for (MaMachine machine : maMachineList) {
// 添加查询物品种类,设备类型,规格型号
getType(machine);
}
return maMachineList;
return maMachineMapper.getMaMachine(maMachine);
}
/**

View File

@ -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<MaType> listByParentId = maTypeMapper.getListByParentId(typeId, "");
if (listByParentId.size() > 0) {
throw new Exception("子级类型不为空!!!");
}
return maTypeMapper.deleteTypeById(typeId);
}

View File

@ -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++) {

View File

@ -0,0 +1,461 @@
<?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>
<update id="audit">
UPDATE tm_task SET task_status = 38 WHERE task_id = #{id}
</update>
<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>
<select id="examineList" 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,
SUM(DISTINCT bad.pre_num) AS num,
bai.direct_audit_remark as directAuditRemark
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}
and bad.type_id is not null
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
</select>
<select id="examineView" 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>

View File

@ -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

View File

@ -37,11 +37,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getMaMachine" parameterType="com.bonus.sgzb.base.api.domain.MaMachine" resultMap="MaMachineResult">
select ma_id, type_id, ma_code, pre_code, ma_status, qr_code, buy_price, ma_vender, out_fac_time, out_fac_code,
assets_code, check_man, this_check_time, next_check_time, gps_code, rfid_code, erp_code, transfer_code,
in_out_num, buy_task, own_house ,company_id
from ma_machine
select m.ma_id, m.type_id, m.ma_code, m.pre_code, m.ma_status, dic.name maStatusName, m.qr_code, m.buy_price, m.ma_vender, m.out_fac_time, m.out_fac_code,
m.assets_code, m.check_man, m.this_check_time, m.next_check_time, m.gps_code, m.rfid_code, m.erp_code, m.transfer_code,
m.in_out_num, m.buy_task, m.own_house ,m.company_id ,mt.type_name specificationType,mt1.type_name deviceType, mt2.type_name itemType
from ma_machine m
left join (select id,p_id,name from sys_dic where p_id in (select id from sys_dic where value = 'ma_status')) dic on m.ma_status = dic.id
left join ma_type mt on m.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
<where>
<if test="maId != null and maId != ''">
AND ma_id = #{maId}
@ -49,70 +52,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="typeId != null and typeId != ''">
AND type_id = #{typeId}
</if>
<if test="maCode != null and maCode != ''">
AND ma_code = #{maCode}
</if>
<if test="preCode != null and preCode != ''">
AND pre_code = #{preCode}
</if>
<if test="maStatus != null and maStatus != ''">
and ma_status = #{maStatus}
</if>
<if test="qrCode != null and qrCode != ''">
and qr_code = #{qrCode}
</if>
<if test="buyPrice != null and buyPrice != ''">
and buy_price = #{buyPrice}
</if>
<if test="maVender != null and maVender != ''">
and ma_vender = #{maVender}
</if>
<if test="outFacTime != null and outFacTime != ''">
and out_fac_time = #{outFacTime}
</if>
<if test="outFacCode != null and outFacCode != ''">
and out_fac_code = #{outFacCode}
</if>
<if test="assetsCode != null and assetsCode != ''">
and assets_code = #{assetsCode}
</if>
<if test="checkMan != null and checkMan != ''">
and update_time = #{updateTime}
</if>
<if test="remark != null and remark != ''">
and check_man = #{remark}
</if>
<if test="thisCheckTime != null and thisCheckTime != ''">
and this_check_time = #{thisCheckTime}
</if>
<if test="nextCheckTime != null and nextCheckTime != ''">
and next_check_time = #{nextCheckTime}
</if>
<if test="gpsCode != null and gpsCode != ''">
and gps_code = #{gpsCode}
</if>
<if test="rfidCode != null and rfidCode != ''">
and rfid_code = #{rfidCode}
</if>
<if test="erpCode != null and erpCode != ''">
and erp_code = #{erpCode}
</if>
<if test="transferCode != null and transferCode != ''">
and transfer_code = #{transferCode}
</if>
<if test="inOutNum != null and inOutNum != ''">
and in_out_num = #{inOutNum}
</if>
<if test="buyTask != null and buyTask != ''">
and buy_task = #{buyTask}
</if>
<if test="ownHouse != null and ownHouse != ''">
and own_house = #{ownHouse}
</if>
<if test="companyId != null and companyId != ''">
and company_id = #{companyId}
</if>
</where>
</select>
@ -276,7 +215,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectMaMachineByMaId" parameterType="Long" resultMap="MaMachineResult">
<include refid="selectMaMachine"/>
select m.ma_id, m.type_id, m.ma_code, m.pre_code, m.ma_status, m.qr_code, m.buy_price, m.ma_vender, m.out_fac_time, m.out_fac_code,
m.assets_code, m.check_man, m.this_check_time, m.next_check_time, m.gps_code, m.rfid_code, m.erp_code, m.transfer_code,
m.in_out_num, m.buy_task, m.own_house ,m.company_id ,mt.type_name specificationType,mt1.type_name deviceType, mt2.type_name itemType
from ma_machine m
left join ma_type mt on m.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
where ma_id = #{maId}
</select>
</mapper>

View File

@ -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
<where>
level != 4 and m.status = '0'
</where>
where level != 4 and m.status = '0' and del_flag = '0'
</select>
<select id="getMaTypeSelect" resultType="com.bonus.sgzb.base.api.domain.MaType">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
@ -318,7 +316,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
left join ma_type_keeper mtk on mtf.type_id = mtk.type_id
left join sys_user su on mtk.user_id = su.user_id
where m.parent_id = #{typeId} and m.status = '0'
where m.parent_id = #{typeId} and m.status = '0' and m.del_flag = '0'
<if test="typeName != null and typeName !=''">
AND type_name like concat('%',#{typeName},'%')
</if>

View File

@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMaSupplierInfoList" parameterType="com.bonus.sgzb.base.domain.MaSupplierInfo" resultMap="MaSupplierInfoResult">
<include refid="selectMaSupplierInfoVo"/>
<where>
<if test="supplier != null and supplier != ''"> and supplier = #{supplier}</if>
<if test="supplier != null and supplier != ''"> and supplier like concat('%',#{supplier},'%') </if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="legalPerson != null and legalPerson != ''"> and legal_person = #{legalPerson}</if>
<if test="primaryContact != null and primaryContact != ''"> and primary_contact = #{primaryContact}</if>

View File

@ -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<ReturnOfMaterialsInfo> list = returnOfMaterialsInfoService.getReturnOfMaterialsInfoAll(bean);
return getDataTable(list);
}
}

View File

@ -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;
}

View File

@ -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<ReturnOfMaterialsInfo> getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean);
}

View File

@ -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<ReturnOfMaterialsInfo> getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean);
}

View File

@ -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;
}

View File

@ -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<ReturnOfMaterialsInfo> getReturnOfMaterialsInfoAll(ReturnOfMaterialsInfo bean) {
return returnOfMaterialsInfoMapper.getReturnOfMaterialsInfoAll(bean);
}
}

View File

@ -0,0 +1,29 @@
<?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.material.mapper.ReturnOfMaterialsInfoMapper">
<select id="getReturnOfMaterialsInfoAll" resultType="com.bonus.sgzb.material.domain.ReturnOfMaterialsInfo">
SELECT
tt.`code` ,bui.unit_name as unitName ,bpl.lot_name as lotName,
mt3.type_name as typeName,mt2.type_name as kindName,mt.type_name as modelName,
iad.input_num as inputNum,mm.ma_code as maCode,
tt.create_time as returnTime,
iad.create_time as submitStorageTime,
iad.create_by as submitToStoragePersonnel,iad.remark as remark
FROM input_apply_details iad
LEFT JOIN tm_task tt ON iad.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta on tta.task_id = tt.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui on bui.unit_id = bai.unit_id
LEFT JOIN ma_type mt on mt.type_id = iad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
LEFT JOIN ma_machine mm ON mm.ma_id = iad.ma_id
WHERE tt.task_status = '38' and mt.`level` = '4' and input_type ='2'
</select>
</mapper>

View File

@ -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>

View File

@ -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;
}
}

View File

@ -28,6 +28,7 @@ import com.bonus.sgzb.system.service.ISysDeptService;
*
* @author ruoyi
*/
/** 机构管理 */
@RestController
@RequestMapping("/dept")
public class SysDeptController extends BaseController

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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') &gt;= 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') &lt;= 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>

View File

@ -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>

View File

@ -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>