Commit 7476d50b authored by mx's avatar mx

员工管理

parent bb01f6dd
package org.rcisoft.sys.sysuser.controller;
/*固定导入*/
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.rcisoft.sys.sysuser.entity.SysDept;
import org.rcisoft.sys.sysuser.service.SysDeptService;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.rcisoft.core.result.CyResult;
import org.rcisoft.core.util.CyResultGenUtil;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.model.CyGridModel;
import org.rcisoft.core.exception.CyServiceException;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
/**
* Created by cy on 2022年11月18日 上午9:03:23.
*/
@RestController
@RequestMapping("/sysDept")
public class SysDeptController extends CyPaginationController<SysDept> {
@Autowired
private SysDeptService sysDeptServiceImpl;
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:add')")
@CyOpeLogAnno(title = "system-部门表管理-新增部门表", businessType = CyLogTypeEnum.INSERT)
@ApiOperation(value="添加部门表", notes="添加部门表")
@PostMapping(value = "/add")
public CyResult add(@Valid SysDept sysDept, BindingResult bindingResult) {
CyPersistModel data = sysDeptServiceImpl.persist(sysDept);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
sysDept);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:delete')")
@CyOpeLogAnno(title = "system-部门表管理-删除部门表", businessType = CyLogTypeEnum.DELETE)
@ApiOperation(value="逻辑删除部门表", notes="逻辑删除部门表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@DeleteMapping("/deleteLogical/{businessId:\\w+}")
public CyResult deleteLogical(@PathVariable int businessId,SysDept sysDept) {
sysDept.setBusinessId(businessId);
CyPersistModel data = sysDeptServiceImpl.removeLogical(sysDept);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:delete')")
@CyOpeLogAnno(title = "system-部门表管理-删除部门表", businessType = CyLogTypeEnum.DELETE)
@ApiOperation(value="删除部门表", notes="删除部门表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@DeleteMapping("/delete/{businessId:\\w+}")
public CyResult delete(@PathVariable int businessId,SysDept sysDept) {
sysDept.setBusinessId(businessId);
CyPersistModel data = sysDeptServiceImpl.remove(sysDept);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:update')")
@CyOpeLogAnno(title = "system-部门表管理-修改部门表", businessType = CyLogTypeEnum.UPDATE)
@ApiOperation(value="修改部门表", notes="修改部门表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PutMapping("/update/{businessId:\\w+}")
public CyResult update(@PathVariable int businessId, @Valid SysDept sysDept, BindingResult bindingResult) {
sysDept.setBusinessId(businessId);
CyPersistModel data = sysDeptServiceImpl.merge(sysDept);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
sysDept);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:query')")
@CyOpeLogAnno(title = "system-部门表管理-查询部门表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value="查询单一部门表", notes="查询单一部门表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@GetMapping("/detail/{businessId:\\w+}")
public CyResult detail(@PathVariable int businessId) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
sysDeptServiceImpl.findById(businessId));
}
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:list')")
@CyOpeLogAnno(title = "system-部门表管理-查询部门表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value="查询部门表集合", notes="查询部门表集合")
@GetMapping(value = "/querySysDepts")
public CyResult querySysDepts(SysDept sysDept) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
sysDeptServiceImpl.findAll(sysDept));
}
//@PreAuthorize("@cyPerm.hasPerm('sys:dept:list')")
@CyOpeLogAnno(title = "system-部门表管理-查询部门表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value="分页查询部门表集合", notes="分页查询部门表集合")
@GetMapping(value = "/querySysDeptByPagination")
public CyGridModel listByPagination(SysDept sysDept) {
sysDeptServiceImpl.findAllByPagination(getPaginationUtility(), sysDept);
return getGridModelResponse();
}
@CyOpeLogAnno(title = "system-部门表管理-查询部门表", businessType = CyLogTypeEnum.EXPORT)
@ApiOperation(value = "导出部门表信息", notes = "导出部门表信息")
@GetMapping(value = "/export")
public CyResult outSysDept(HttpServletResponse response,SysDept sysDept,@PathVariable @RequestParam(defaultValue = "0") String excelId) {
String excelName="";
switch(excelId){
case "0": excelName="部门表信息.xls";break;
case "1": excelName="部门表信息.xlsx";break;
case "2": excelName="部门表信息.csv";break;
}
List<SysDept> sysDeptList = sysDeptServiceImpl.export(sysDept);
CyEpExcelUtil.exportExcel(sysDeptList, "部门表信息", "部门表信息", SysDept.class, excelName, response);
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
sysDeptList);
}
}
......@@ -33,5 +33,8 @@ public interface SysDictDataRepositorys extends CyBaseMapper<SysDictData> {
//根据职位id查询职位字典
List<SysDictData> queryDataByPosition(String position);
//根据班次id查询班次字典
List<SysDictData> queryDataByNltBz(String nltBz);
}
......@@ -2,9 +2,12 @@ package org.rcisoft.sys.sysuser.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.rcisoft.core.entity.CyIdIncreEntity;
import org.springframework.data.annotation.Transient;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
......@@ -18,6 +21,21 @@ import java.util.List;
@TableName("sys_dept")
public class SysDept extends CyIdIncreEntity<SysDept> {
//排序
@Transient
private String px;
/**
* 开始时间
*/
@Transient
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private String beginTime;
//结束时间
@Transient
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private String endTime;
/**
* @desc 父部门id
......
......@@ -22,9 +22,13 @@ import java.util.List;
@TableName("sys_user")
public class SysUser extends CyIdIncreEntity<SysUser> {
//班次中文名
@Transient
private String dictLabelBynltBz;
//职位中文名
@Transient
private String dictLabel;
private String dictLabelByPosition;
//部门名称
@Transient
......
package org.rcisoft.sys.sysuser.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.aop.CyPageUtilAsp;
import org.rcisoft.core.model.CyPageInfo;
import org.rcisoft.sys.sysuser.entity.SysDept;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by cy on 2022年11月18日 上午9:03:23.
*/
@Service
public interface SysDeptService {
/**
* 保存 部门表
* @param sysDept
* @return
*/
CyPersistModel persist(SysDept sysDept);
/**
* 删除 部门表
* @param sysDept
* @return
*/
CyPersistModel remove(SysDept sysDept);
/**
* 逻辑删除 部门表
* @param sysDept
* @return
*/
CyPersistModel removeLogical(SysDept sysDept);
/**
* 修改 部门表
* @param sysDept
* @return
*/
CyPersistModel merge(SysDept sysDept);
/**
* 根据id查询 部门表
* @param id
* @return
*/
SysDept findById(int id);
/**
* 分页查询 部门表
* @param sysDept
* @return
*/
IPage<SysDept> findAllByPagination(CyPageInfo<SysDept> paginationUtility,
SysDept sysDept);
/**
* 查询list 部门表
* @param sysDept
* @return
*/
List<SysDept> findAll(SysDept sysDept);
/**
* 导出部门表
* @return
*/
List<SysDept> export(SysDept sysDept);
}
package org.rcisoft.sys.sysuser.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.aop.CyPageUtilAsp;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.rcisoft.core.service.CyBaseService;
import org.rcisoft.sys.sysuser.dao.SysDeptRepositorys;
import org.rcisoft.sys.sysuser.entity.SysDept;
import org.rcisoft.sys.sysuser.service.SysDeptService;
import org.rcisoft.sys.wbac.dept.dao.SysDeptRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.rcisoft.core.model.CyPageInfo;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
/**
* Created by cy on 2022年11月18日 上午9:03:23.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class SysDeptServiceImpl extends ServiceImpl<SysDeptRepositorys, SysDept> implements SysDeptService {
/**
* 保存 部门表
* @param sysDept
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel persist(SysDept sysDept){
//增加操作
int line = baseMapper.insert(sysDept);
log.debug(CyUserUtil.getAuthenUsername()+"新增了ID为"+
sysDept.getBusinessId()+"的部门表信息");
return new CyPersistModel(line);
}
/**
* 删除 部门表
* @param sysDept
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel remove(SysDept sysDept){
int line = baseMapper.realDelete(sysDept);
log.debug(CyUserUtil.getAuthenUsername()+"删除了ID为"+
sysDept.getBusinessId()+"的部门表信息");
return new CyPersistModel(line);
}
/**
* 逻辑删除 部门表
* @param sysDept
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel removeLogical(SysDept sysDept){
sysDept.setDeleted();
int line = baseMapper.deleteById(sysDept);
log.debug(CyUserUtil.getAuthenUsername()+"逻辑删除了ID为"+
sysDept.getBusinessId()+"的部门表信息");
return new CyPersistModel(line);
}
/**
* 修改 部门表
* @param sysDept
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel merge(SysDept sysDept){
int line = baseMapper.updateById(sysDept);
log.debug(CyUserUtil.getAuthenUsername()+"修改了ID为"+ sysDept.getBusinessId()+"的部门表信息");
return new CyPersistModel(line);
}
/**
* 根据id查询 部门表
* @param id
* @return
*/
@Override
public SysDept findById(int id){
return baseMapper.selectById(id);
}
/**
* 分页查询 部门表
* @param sysDept
* @return
*/
@Override
public IPage<SysDept> findAllByPagination(CyPageInfo<SysDept> paginationUtility,
SysDept sysDept){
return baseMapper.querySysDeptsPaged(paginationUtility,sysDept);
}
/**
* 查询list 部门表
* @param sysDept
* @return
*/
@Override
public List<SysDept> findAll(SysDept sysDept){
return baseMapper.querySysDepts(sysDept);
}
/**
* 导出部门表
* @return
*/
@Override
public List<SysDept> export(SysDept sysDept) {
List<SysDept> sysDeptList = baseMapper.querySysDepts(sysDept);
return sysDeptList;
}
}
......@@ -120,7 +120,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
@Override
public IPage<SysUser> findAllByPagination(CyPageInfo<SysUser> paginationUtility, SysUser sysUser) {
IPage<SysUser> sysUserIPage = baseMapper.querySysUsersPaged(paginationUtility, sysUser);
for (int i = 0; i < sysUserIPage.getSize(); i++) {
for (int i = 0; i < sysUserIPage.getRecords().size(); i++) {
BigInteger deptId = sysUserIPage.getRecords().get(i).getDeptId();
//根据部门id查询部门表
List<SysDept> sysDepts = sysDeptRepositorys.queryDeptById(deptId);
......@@ -129,13 +129,23 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
String deptName = sysDepts.get(0).getDeptName();
sysUserIPage.getRecords().get(i).setDeptName(deptName);
}
//查询职位id
String position = sysUserIPage.getRecords().get(i).getPosition();
List<SysDictData> sysDictData = sysDictDataRepositorys.queryDataByPosition(position);
if (sysDictData.size() != 0) {
//查询职位中文名
String dictLabel = sysDictData.get(0).getDictLabel();
sysUserIPage.getRecords().get(i).setDictLabel(dictLabel);
sysUserIPage.getRecords().get(i).setDictLabelByPosition(dictLabel);
}
//查询班次id
String nltBz = sysUserIPage.getRecords().get(i).getNltBz();
List<SysDictData> sysDictData1 = sysDictDataRepositorys.queryDataByNltBz(nltBz);
if (sysDictData1.size() != 0) {
//查询班次中文名
String dictLabel = sysDictData1.get(0).getDictLabel();
sysUserIPage.getRecords().get(i).setDictLabelBynltBz(dictLabel);
}
}
......
......@@ -34,14 +34,28 @@
</select>
<select id="querySysDeptsPaged" resultMap="BaseResultMap">
select * from sys_dept
where 1=1
<if test="entity.delFlag !=null and entity.delFlag != '' ">
and del_flag = #{entity.delFlag}
</if>
select distinct *
from sys_dept
where
del_flag = 0
<if test="entity.flag !=null and entity.flag != '' ">
and flag = #{entity.flag}
</if>
<if test="entity.businessId !=null and entity.businessId != '' ">
and parent_id = #{entity.businessId}
</if>
<if test="entity.beginTime != null and entity.beginTime !='' "><!-- 开始时间检索 -->
and date_format(create_date,'%Y-%m-%d') &gt;= date_format(#{entity.beginTime},'%Y-%m-%d')
</if>
<if test="entity.endTime != null and entity.endTime !='' "><!-- 结束时间检索 -->
and date_format(create_date,'%Y-%m-%d') &lt;= date_format(#{entity.endTime},'%Y-%m-%d')
</if>
<if test="entity.px == 1 "><!-- 排序-->
ORDER BY create_date
</if>
<if test="entity.px == 2 "><!-- 排序-->
ORDER BY dept_name
</if>
</select>
<select id="queryDept" resultMap="BaseResultMap">
......
......@@ -58,4 +58,12 @@
and del_flag = 0
and dict_value = #{position}
</select>
<select id="queryDataByNltBz" resultMap="BaseResultMap">
SELECT *
FROM sys_dict_data
WHERE dict_type = "shift"
and del_flag = 0
and dict_value = #{nltBz}
</select>
</mapper>
\ No newline at end of file
......@@ -40,24 +40,54 @@
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<select id="querySysUsers" resultMap="BaseResultMap">
select * from sys_user
where 1=1
<if test="entity.delFlag !=null and entity.delFlag != '' ">
and del_flag = #{entity.delFlag}
select distinct business_id,NAME,sex,phone,face_address,address,dept_id, position,nlt_bz,flag,user_type
from sys_user
where
del_flag = 0
<if test="entity.userType !=null and entity.userType != '' ">
and user_type = #{entity.userType}
</if>
<if test="entity.phone !=null and entity.phone != '' ">
and phone = #{entity.phone}
<if test="entity.position !=null and entity.position != '' ">
and position in
<foreach collection="array" item="position" index="index" open="(" close=")" separator=",">
#{entity.position}
</foreach>
</if>
<if test="entity.flag !=null and entity.flag != '' ">
and flag = #{entity.flag}
</if>
<if test="entity.deptId !=null and entity.deptId != '' ">
and deptId in
<foreach collection="array" item="deptId" index="index" open="(" close=")" separator=",">
#{entity.deptId}
</foreach>
</if>
<if test="entity.phone !=null and entity.phone != '' ">
and phone = #{entity.phone}
</if>
<if test="entity.beginTime != null and entity.beginTime !='' "><!-- 开始时间检索 -->
and date_format(create_date,'%Y-%m-%d') &gt;= date_format(#{entity.beginTime},'%Y-%m-%d')
</if>
<if test="entity.endTime != null and entity.endTime !='' "><!-- 结束时间检索 -->
and date_format(create_date,'%Y-%m-%d') &lt;= date_format(#{entity.endTime},'%Y-%m-%d')
</if>
<if test="entity.px == 1 "><!-- 排序-->
ORDER BY create_date
</if>
<if test="entity.px == 2 "><!-- 排序-->
ORDER BY position
</if>
<if test="entity.px == 3 "><!-- 排序-->
ORDER BY name
</if>
</select>
<select id="querySysUsersPaged" resultMap="BaseResultMap">
select distinct business_id,NAME,sex,phone,face_address,address,dept_id, position,nlt_bz,flag
select distinct business_id,NAME,sex,phone,face_address,address,dept_id, position,nlt_bz,flag,user_type
from sys_user
where
del_flag = 0
and user_type = 0
<if test="entity.position !=null and entity.position != '' ">
and position in
<foreach collection="array" item="position" index="index" open="(" close=")" separator=",">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment