提交修改
This commit is contained in:
parent
394371d19e
commit
7b122dc5eb
@ -229,4 +229,20 @@ public class DateUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算 minute 分钟后的时间
|
||||
*
|
||||
* @param date
|
||||
* @param minute
|
||||
* @return
|
||||
*/
|
||||
public static Date addMinute(Date date, int minute) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MINUTE, minute);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,11 +3,14 @@ package com.lz.modules.app.controller;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.R;
|
||||
import com.lz.modules.app.dto.DepartmentsDto;
|
||||
import com.lz.modules.app.req.ResultRecordReq;
|
||||
import com.lz.modules.app.service.DepartmentsService;
|
||||
import com.lz.modules.sys.entity.app.ResultRecord;
|
||||
import com.lz.modules.sys.service.app.ResultRecordService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
@ -33,6 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class ResultRecordController {
|
||||
@Autowired
|
||||
private ResultRecordService lzResultRecordService;
|
||||
@Autowired
|
||||
private DepartmentsService departmentsService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@ -41,9 +46,17 @@ public class ResultRecordController {
|
||||
@RequiresPermissions("user:lzresultrecord:list")
|
||||
public R list(ResultRecordReq req){
|
||||
PageUtils page = lzResultRecordService.queryPage(req);
|
||||
return R.ok().put("page", page);
|
||||
List<DepartmentsDto> departmentList1 = departmentsService.selectByParentDepartmentId("0");
|
||||
return R.ok().put("page", page)
|
||||
.put("departmentList1",departmentList1);
|
||||
}
|
||||
|
||||
@RequestMapping("/departmentQuery")
|
||||
public R departmentQuery(ResultRecordReq req){
|
||||
List<DepartmentsDto> departmentList1 = departmentsService.selectByParentDepartmentId(req.getDepartmentId());
|
||||
return R.ok()
|
||||
.put("departmentList",departmentList1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
|
||||
@ -1,21 +1,19 @@
|
||||
package com.lz.modules.app.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.lz.modules.app.entity.StaffOccupationEntity;
|
||||
import com.lz.modules.app.service.StaffOccupationService;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.R;
|
||||
import com.lz.modules.app.dto.DepartmentsDto;
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import com.lz.modules.app.entity.StaffOccupationEntity;
|
||||
import com.lz.modules.app.service.DepartmentsService;
|
||||
import com.lz.modules.app.service.StaffOccupationService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -31,25 +29,27 @@ public class StaffOccupationController {
|
||||
@Autowired
|
||||
private StaffOccupationService staffOccupationService;
|
||||
|
||||
@Autowired
|
||||
private DepartmentsService departmentsService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("generator:staffoccupation:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = staffOccupationService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("generator:staffoccupation:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
StaffOccupationEntity staffOccupation = staffOccupationService.getById(id);
|
||||
public R info(@PathVariable("id") Long id) {
|
||||
StaffOccupationEntity staffOccupation = staffOccupationService.getById(id);
|
||||
|
||||
return R.ok().put("staffOccupation", staffOccupation);
|
||||
}
|
||||
@ -59,8 +59,8 @@ public class StaffOccupationController {
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("generator:staffoccupation:save")
|
||||
public R save(@RequestBody StaffOccupationEntity staffOccupation){
|
||||
staffOccupationService.save(staffOccupation);
|
||||
public R save(@RequestBody StaffOccupationEntity staffOccupation) {
|
||||
staffOccupationService.save(staffOccupation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@ -70,8 +70,8 @@ public class StaffOccupationController {
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("generator:staffoccupation:update")
|
||||
public R update(@RequestBody StaffOccupationEntity staffOccupation){
|
||||
staffOccupationService.updateById(staffOccupation);
|
||||
public R update(@RequestBody StaffOccupationEntity staffOccupation) {
|
||||
staffOccupationService.updateById(staffOccupation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@ -81,8 +81,8 @@ public class StaffOccupationController {
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("generator:staffoccupation:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
staffOccupationService.removeByIds(Arrays.asList(ids));
|
||||
public R delete(@RequestBody Long[] ids) {
|
||||
staffOccupationService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -29,4 +29,5 @@ public interface DepartmentsDao extends BaseMapper<DepartmentsEntity> {
|
||||
List<DepartmentsDto> getDepartmentsByparentId(@Param("parentId") String parentId);
|
||||
|
||||
|
||||
List<DepartmentsEntity> selectAll();
|
||||
}
|
||||
|
||||
@ -43,4 +43,5 @@ public interface DepartmentsStaffRelateDao extends BaseMapper<DepartmentsStaffRe
|
||||
|
||||
String getRelateByStaffIdAndDepartmentId(@Param("staffId") Long staffId, @Param("departmentId") String departmentId);
|
||||
|
||||
List<DepartmentsStaffRelateEntity> selectByDepartmentIds(@Param("departmentIds") List<String> departmentIds);
|
||||
}
|
||||
|
||||
@ -45,4 +45,5 @@ public interface StaffDao extends BaseMapper<StaffEntity> {
|
||||
|
||||
List<GraphicsStatisticalDto> getEducationData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
|
||||
List<StaffEntity> selectByName(@Param("name") String name);
|
||||
}
|
||||
|
||||
@ -36,10 +36,10 @@ public class DepartmentsDto implements Serializable {
|
||||
/**
|
||||
* ztree属性
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
@TableField(exist = false)
|
||||
private Boolean open;
|
||||
|
||||
@TableField(exist=false)
|
||||
@TableField(exist = false)
|
||||
private List<?> list;
|
||||
|
||||
}
|
||||
|
||||
24
src/main/java/com/lz/modules/app/dto/EmployeesDto.java
Normal file
24
src/main/java/com/lz/modules/app/dto/EmployeesDto.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.lz.modules.app.dto;
|
||||
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class EmployeesDto {
|
||||
|
||||
private Long expire ;
|
||||
|
||||
private Map<String, List<DepartmentsEntity>> cacheMap;
|
||||
|
||||
public EmployeesDto() {
|
||||
|
||||
}
|
||||
|
||||
public EmployeesDto(Long expire, Map<String, List<DepartmentsEntity>> cacheMap) {
|
||||
this.expire = expire;
|
||||
this.cacheMap = cacheMap;
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,27 @@ package com.lz.modules.app.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ResultRecordReq {
|
||||
private Integer page;
|
||||
private Integer limit;
|
||||
private String monthBeginDate;
|
||||
private String monthEndDate;
|
||||
//0.新建,1 提交审批中,2 拒绝
|
||||
private Integer status;
|
||||
private String departmentId;
|
||||
|
||||
private String department1;
|
||||
private String department2;
|
||||
private String department3;
|
||||
|
||||
private String name;
|
||||
private String remark;
|
||||
|
||||
private List<Long> departmentStaffIds;
|
||||
private List<Long> staffIds;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -26,5 +26,6 @@ public interface DepartmentsService extends IService<DepartmentsEntity> {
|
||||
|
||||
List<DepartmentsDto> getDepartmentTree();
|
||||
|
||||
List<DepartmentsDto> selectByParentDepartmentId(String deparentId);
|
||||
}
|
||||
|
||||
|
||||
@ -48,5 +48,7 @@ public interface StaffService extends IService<StaffEntity> {
|
||||
|
||||
|
||||
void enterDatabase(List<Map<String, String>> sheet12List, List<Map<String, String>> sheet3List, List<Map<String, String>> sheet4List);
|
||||
|
||||
List<StaffEntity> selectByName(String name);
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,11 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
|
||||
return departmentsParentsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentsDto> selectByParentDepartmentId(String deparentId) {
|
||||
return departmentsDao.getDepartmentsByparentId(deparentId+"");
|
||||
}
|
||||
|
||||
private List<DepartmentsDto> getDepartmentTreeList(List<DepartmentsDto> departmentList) {
|
||||
List<DepartmentsDto> DepartmentsList = Lists.newArrayList();
|
||||
for (DepartmentsDto departmentsDto : departmentList) {
|
||||
|
||||
@ -270,6 +270,11 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StaffEntity> selectByName(String name) {
|
||||
return staffDao.selectByName(name);
|
||||
}
|
||||
|
||||
private void createDepartmentInfo(StaffEntity staffEntity, String departmentName) {
|
||||
DepartmentsEntity departmentsEntity = departmentsService.getOne(new QueryWrapper<DepartmentsEntity>().eq("department_name", departmentName));
|
||||
if (departmentsEntity != null) {
|
||||
|
||||
@ -1,21 +1,30 @@
|
||||
package com.lz.modules.sys.service.app.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.lz.common.utils.DateUtils;
|
||||
import com.lz.common.utils.ISelect;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.StringUtil;
|
||||
import com.lz.modules.app.dao.DepartmentsDao;
|
||||
import com.lz.modules.app.dao.DepartmentsStaffRelateDao;
|
||||
import com.lz.modules.app.dto.EmployeesDto;
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
|
||||
import com.lz.modules.app.entity.StaffEntity;
|
||||
import com.lz.modules.app.req.ResultRecordReq;
|
||||
import com.lz.modules.app.resp.ResultRecordResp;
|
||||
import com.lz.modules.app.service.StaffService;
|
||||
import com.lz.modules.sys.dao.app.ResultRecordMapper;
|
||||
import com.lz.modules.sys.entity.app.ResultRecord;
|
||||
import com.lz.modules.sys.service.app.ResultRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -27,6 +36,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, ResultRecord> implements ResultRecordService {
|
||||
|
||||
|
||||
@ -34,6 +44,20 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
|
||||
private ResultRecordMapper resultRecordMapper;
|
||||
|
||||
|
||||
private static EmployeesDto employeesDto;
|
||||
|
||||
@Autowired
|
||||
private DepartmentsDao departmentsDao;
|
||||
|
||||
@Autowired
|
||||
private DepartmentsStaffRelateDao departmentsStaffRelateDao;
|
||||
|
||||
@Autowired
|
||||
private StaffService staffService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResultRecord selectResultRecordById(Long id) {
|
||||
return resultRecordMapper.selectResultRecordById(id);
|
||||
@ -66,12 +90,68 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(ResultRecordReq params) {
|
||||
List<Long> departmentStaffIds = new ArrayList<>();
|
||||
List<Long> staffIds = new ArrayList<>();
|
||||
List<String> departmentIds = new ArrayList<>();
|
||||
if (StringUtil.isNotBlank(params.getDepartment1())
|
||||
|| StringUtil.isNotBlank(params.getDepartment2())
|
||||
|| StringUtil.isNotBlank(params.getDepartment3())) {
|
||||
Map<String,List<DepartmentsEntity>> departmentMap = null;
|
||||
if(employeesDto == null || employeesDto.getExpire() < new Date().getTime()){
|
||||
List<DepartmentsEntity> tDepartments = departmentsDao.selectAll();
|
||||
departmentMap = new HashMap<>();
|
||||
for(DepartmentsEntity department : tDepartments) {
|
||||
List<DepartmentsEntity> list = new ArrayList<>();
|
||||
for(DepartmentsEntity child : tDepartments) {
|
||||
if(child.getDepartmentId().equals(department.getDepartmentParentId())){
|
||||
list.add(child);
|
||||
}
|
||||
}
|
||||
departmentMap.put(department.getDepartmentId(), list);
|
||||
}
|
||||
Date expire = DateUtils.addMinute(new Date(),30);
|
||||
EmployeesDto newDto = new EmployeesDto(expire.getTime(),departmentMap);
|
||||
employeesDto = newDto;
|
||||
log.info("使用新数据");
|
||||
}else{
|
||||
log.info("使用缓存");
|
||||
departmentMap = employeesDto.getCacheMap();
|
||||
}
|
||||
if (StringUtil.isNotBlank(params.getDepartment3())) {
|
||||
getChildIds(departmentIds, params.getDepartment3(), departmentMap);
|
||||
} else if (StringUtil.isNotBlank(params.getDepartment2())) {
|
||||
getChildIds(departmentIds, params.getDepartment2(), departmentMap);
|
||||
} else if (StringUtil.isNotBlank(params.getDepartment1())) {
|
||||
getChildIds(departmentIds, params.getDepartment1(), departmentMap);
|
||||
}
|
||||
}
|
||||
if (departmentIds != null && departmentIds.size() > 0) {
|
||||
List<DepartmentsStaffRelateEntity > departmentsStaffRelateEntities = departmentsStaffRelateDao.selectByDepartmentIds(departmentIds);
|
||||
if(CollectionUtils.isNotEmpty(departmentsStaffRelateEntities)){
|
||||
for(DepartmentsStaffRelateEntity departmentsStaffRelateEntity:departmentsStaffRelateEntities){
|
||||
departmentStaffIds.add(departmentsStaffRelateEntity.getStaffId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtil.isNotBlank(params.getName())){
|
||||
List<StaffEntity> staffEntities = staffService.selectByName(params.getName());
|
||||
if(CollectionUtils.isNotEmpty(staffEntities)){
|
||||
for(StaffEntity staffEntity:staffEntities){
|
||||
staffIds.add(staffEntity.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
params.setDepartmentStaffIds(departmentStaffIds);
|
||||
params.setStaffIds(staffIds);
|
||||
PageUtils pageUtils = PageUtils.startPage(params.getPage(), params.getLimit() ).doSelect(new ISelect() {
|
||||
@Override
|
||||
public List doSelect(IPage page) {
|
||||
return resultRecordMapper.selectByCondition(page, params);
|
||||
}
|
||||
});
|
||||
|
||||
List<ResultRecord> resultRecords = pageUtils.getList();
|
||||
List<ResultRecordResp> list = new ArrayList<>();
|
||||
for (ResultRecord resultRecord : resultRecords) {
|
||||
@ -88,4 +168,16 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
|
||||
|
||||
}
|
||||
|
||||
public void getChildIds(List<String> childDepartIds ,String parentId,Map<String,List<DepartmentsEntity>> departmentMap ){
|
||||
childDepartIds.add(parentId);
|
||||
List<DepartmentsEntity > tDepartments = departmentMap.get(parentId);
|
||||
if(CollectionUtils.isNotEmpty(tDepartments)){
|
||||
for(DepartmentsEntity tDepartment:tDepartments){
|
||||
getChildIds(childDepartIds,tDepartment.getDepartmentId(),departmentMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -70,4 +70,11 @@
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<select id="selectAll" resultType="com.lz.modules.app.entity.DepartmentsEntity">
|
||||
select * from lz_departments where is_delete=0
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -33,8 +33,17 @@
|
||||
select department_id from lz_departments_staff_relate where is_delete=0 and staff_id = #{staffId} and department_id=#{departmentId}
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateByStaffId">
|
||||
update lz_departments_staff_relate set is_delete=0 and update_time=now(), department_id=#{departmentId} where is_delete=0 and staff_id = #{staffId}
|
||||
</update>
|
||||
|
||||
<select id="selectByDepartmentIds" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
|
||||
select * from lz_departments_staff_relate where department_id in
|
||||
<foreach collection="departmentIds" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -269,4 +269,9 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectByName" resultType="com.lz.modules.app.entity.StaffEntity">
|
||||
select * from lz_staff where is_delete=0 AND name LIKE CONCAT('%',#{name},'%')
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user