Commit 920123fe authored by cq990612's avatar cq990612

优化代码结构

parent 80be1447
......@@ -73,7 +73,7 @@ public enum BASE_RESP_CODE_ENUM {
ORDINARY_MEMBERS_ARE_MANAGEMENT("653", "普通成员不能有管理角色"),
REPEAT_WITH_OLDTIME("654", "日期与其他节假日或工作日冲突"),
BUDGET_CANNOT_BELESSTHAN_ZERO("655", "预算不能小于0"),
ITEMOADUPLICATE("656", "OA编号重复"),
ITEMOADUPLICATE("656", "编号重复"),
NO_AUTHORITY("657", "暂无该权限"),
THEPERIOD_CANNOT_BELESS_THANONEDAY("658", "设置的期限不能小于1天"),
DUPLICATE_HOLIDAY_NAME("659", "节假日名称重复"),
......@@ -81,7 +81,9 @@ public enum BASE_RESP_CODE_ENUM {
CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人"),
ROLE_CANNOTBE_EMPTY("662", "设置的角色不能为空"),
NOADMIN_ISTRATIVE_RIGHTS("663", "设置的负责人没有管理权限"),
NON_PROJECT_OPPORTUNITYNUMBERNAME_ISEMPTY("664","非项目,无商机属性")
NON_PROJECT_OPPORTUNITYNUMBERNAME_ISEMPTY("664", "非项目,无商机属性"),
THEPROJECT_HASBEEN_CLOSED("665", "该项目/商机已经结束,请重新选择填报"),
THISTYPEOF_WORKINGHOURS_HASENDE("666", "该工时类型已经结束,请选择其他类型"),
;
......
......@@ -2,6 +2,7 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.WorkType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -15,7 +16,7 @@ public interface WorkTypeMapper extends BaseMapper<WorkType> {
List<Integer> getIdByReviewer(Integer reviewer);
List<WorkType> getByIsDelete(Integer isDelete);
List<WorkType> getByIsStatus(Integer status);
int updateIsDeleteById(Integer id, Integer isDelete);
int updateIsStatusById(@Param("id") Integer id, @Param("status") Integer status);
}
<?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="cn.wisenergy.mapper.WorkTypeMapper">
<update id="updateIsDeleteById">
<update id="updateIsStatusById">
update work_type
<set>
<if test="null != isDelete">
is_delete = #{isDelete},
<if test="null != status">
status = #{status},
</if>
</set>
<where>
......@@ -18,7 +18,7 @@
<select id="getAll" resultType="cn.wisenergy.model.app.WorkType">
SELECT id,name,reviewer,is_delete
SELECT id,`name`,reviewer,status
FROM work_type
</select>
......@@ -27,12 +27,12 @@
FROM work_type
WHERE reviewer = #{reviewer}
</select>
<select id="getByIsDelete" resultType="cn.wisenergy.model.app.WorkType">
SELECT id,name,reviewer,is_delete
<select id="getByIsStatus" resultType="cn.wisenergy.model.app.WorkType">
SELECT id,name,reviewer,status
FROM work_type
<where>
<if test="null != isDelete">
is_delete = #{isDelete}
<if test="null != status">
status = #{status}
</if>
</where>
......
......@@ -31,8 +31,8 @@ public class WorkType implements Serializable, Comparable{
@ApiModelProperty(name = "reviewer",value = "检查者:1:该项目负责人 2:系统自动 3:部门或中心负责人")
private Integer reviewer;
@ApiModelProperty(name = "isDelete",value = "0:正常 1:删除")
private Integer isDelete;
@ApiModelProperty(name = "status",value = "0:禁用 1:正常")
private Integer status;
@Override
......
......@@ -16,7 +16,7 @@ public interface WorkTypeService {
Boolean addAndModifyWorkType(WorkType workType);
Boolean deleteTypeById(Integer id);
Boolean modifyStatusById(Integer id,Integer status);
List<WorkType> getByIsDelete(Integer isSort,Integer isDelete);
List<WorkType> getByIsStatus(Integer isSort,Integer status);
}
......@@ -214,11 +214,15 @@ public class WorkProjectServiceImpl implements WorkProjectService {
}
Integer rank = null;
Integer projectLevel = null;
for (WorkLevel level : workLevels) {
if (LevelEnum.PROJECT_MANAGER.getLevelName().equals(level.getName())) {
if (null == rank) {
rank = level.getRank();
}
if (LevelRankEnum.PROJECT_LEVEL.getRank().equals(level.getRank())) {
projectLevel = 1;
}
if (null != rank && rank < level.getRank()) {
rank = level.getRank();
}
......@@ -232,7 +236,9 @@ public class WorkProjectServiceImpl implements WorkProjectService {
int pageSize = gmpv.getPageSize() == null ? 10 : gmpv.getPageSize();
Integer isConclusion = gmpv.getIsConclusion();
List<ManagerProjectsDto> managerProjectsDto;
if (null == projectLevel) {
gmpv.setUserId(null);
}
// 中心级
if (rank.equals(LevelRankEnum.CENTRAL_LEVEL.getRank())) {
List<Integer> deptIds = new ArrayList<>();
......
......@@ -21,17 +21,16 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.util.*;
import static java.util.Collections.*;
import static java.util.Collections.sort;
/**
* <p>
......@@ -212,17 +211,19 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
List<WorkTimeOrder> addList = new ArrayList<>();
List<Integer> typeIds = workTypeService.getIdByReviewer(1);
List<WorkType> workTypes = workTypeService.getAll(null);
// 验证填报类型项目是否已经结项
orderIsEnd(workTimeOrders, workTypes);
for (WorkTimeOrderDto dto : workTimeOrders) {
// 3.判断工单是否合法
isEmpty(dto);
// 获取用户名和类型名
Integer type = dto.getType();
/*Integer type = dto.getType();
dto.setUserName(workUserService.getById(dto.getUserId()).getName());
dto.setTypeName(getTypeName(type, workTypes));
if (!CollectionUtils.isEmpty(typeIds)) {
if (typeIds.contains(type)) {
dto.setProjectName(workProjectService.getById(dto.getProjectId()).getProjectName());
if (typeIds.contains(type)) {dto.setProjectName(workProjectService.getById(dto.getProjectId()).getProjectName());
dto.setManagerName(workUserService.getById(workProjectService.getById(dto.getProjectId()).getManagerId()).getName());
}
if (!typeIds.contains(type)) {
......@@ -232,7 +233,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
}
}
}*/
// 设置状态
if (null == dto.getStatus() || 0 == dto.getStatus()) {
dto.setStatus(COMPLETED);
......@@ -263,11 +264,10 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
addList.add(workTimeOrder);
}
WorkCollect workCollect = workCollectService.getByUserIdAndWorkDay(workTimeOrders.get(0).getUserId(), workTimeOrders.get(0).getWorkDay());
for (WorkTimeOrder dto : addList) {
WorkCollect byUserIdAndWorkDay = workCollectService.getByUserIdAndWorkDay(dto.getUserId(), dto.getWorkDay());
if (null != byUserIdAndWorkDay && null != byUserIdAndWorkDay.getRejectTime()) {
Date rejectTime1 = byUserIdAndWorkDay.getRejectTime();
if (null != workCollect && null != workCollect.getRejectTime()) {
Date rejectTime1 = workCollect.getRejectTime();
dto.setStatus(RE_SUBMIT);
Date rejectTime = DateUtil.convertStrToDate(DateUtil.convertDateToStr(rejectTime1, "yyyy-MM-dd"), "yyyy-MM-dd");
if (DateUtil.isThanDay(rejectTime, date, submitTime)) {
......@@ -294,7 +294,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
// 更新collect表
int status = statusYes(workTimeOrders.get(0).getUserId(), workTimeOrders.get(0).getWorkDay());
WorkCollect workCollect = workCollectService.getByUserIdAndWorkDay(workTimeOrders.get(0).getUserId(), workTimeOrders.get(0).getWorkDay());
if (null == workCollect) {
workCollect = new WorkCollect();
......@@ -314,6 +313,32 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
private void orderIsEnd(List<WorkTimeOrderDto> workTimeOrders,List<WorkType> workTypes) {
if (!CollectionUtils.isEmpty(workTimeOrders) || !CollectionUtils.isEmpty(workTypes)) {
List<WorkProject> projectsByIds = workProjectMapper.getProjectsByIds(null, 0);
if (!CollectionUtils.isEmpty(projectsByIds)) {
for (WorkTimeOrderDto workTimeOrder : workTimeOrders) {
if (workTimeOrder.getType().equals(1) || workTimeOrder.getType().equals(2)) {
for (WorkProject projectsById : projectsByIds) {
if (projectsById.getId().equals(workTimeOrder.getProjectId())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THEPROJECT_HASBEEN_CLOSED);
}
}
}else{
for (WorkType workType : workTypes) {
if (workType.getStatus().equals(0)) {
if (workType.getId().equals(workTimeOrder.getType())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THISTYPEOF_WORKINGHOURS_HASENDE);
}
}
}
}
}
}
}
}
// 判断填写工时单是否重复
private void isRepeat(List<WorkTimeOrderDto> list) {
if (CollectionUtils.isEmpty(list)) {
......@@ -550,7 +575,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
ProjectsDto projectsDto = new ProjectsDto();
WorkUser user = workUserService.getById(userId);
// 逻辑删后的东西
List<WorkType> workTypeList = workTypeService.getByIsDelete(1, 0);
List<WorkType> workTypeList = workTypeService.getByIsStatus(1, 1);
projectsDto.setWorkTypeList(workTypeList);
// 1.获取可填报的类型
List<WorkType> workTypes = workTypeService.getAll(1);
......@@ -568,7 +593,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
return projectsDto;
}
public List<ProjectManagerDto> getProjectManagerDto(WorkUser user,List<WorkType> workTypes) {
public List<ProjectManagerDto> getProjectManagerDto(WorkUser user, List<WorkType> workTypes) {
List<UserRoleLevelDto> roleUserLevel = UserRoleLevelUtils.getRoleUserLevel(user.getId());
if (CollectionUtils.isEmpty(roleUserLevel)) {
return null;
......@@ -578,6 +603,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
if (LevelEnum.EXAMINE.getLevelName().equals(userRoleLevelDto.getLevelName())) {
List<ProjectManagerDto> projectManagerDtos = new ArrayList<>();
List<ProjectDto> projectDtos = workProjectService.getByManagerId(user.getId(), 1);
if (LevelRankEnum.PROJECT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
if (!CollectionUtils.isEmpty(projectDtos)) {
QueryWrapper<WorkTimeOrder> wrapper = new QueryWrapper<>();
List<Integer> projectIds = new ArrayList<>();
......@@ -601,6 +627,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
projectManagerDtos.add(projectManagerDto);
}
}
}
if (LevelRankEnum.DEPARTMENT_LEVEL.getRank().equals(userRoleLevelDto.getRank()) || LevelRankEnum.CENTRAL_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
List<WorkType> workTypeServiceAll = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTypeServiceAll)) {
......@@ -639,7 +667,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
}
return null;
}
}
// 获取可以填报的数据
private List<ProjectInfoDto> getProjectInfoDto(Integer userId) {
......@@ -659,7 +687,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
List<WorkProject> projects = workProjectService.getNameByIds(projectIds, 1);
ProjectInfoDto projectInfoDto;
List<WorkType> workTypes = workTypeService.getByIsDelete(1, 0);
List<WorkType> workTypes = workTypeService.getByIsStatus(1, 1);
if (!CollectionUtils.isEmpty(workTypes)) {
for (WorkType value : workTypes) {
projectInfoDto = new ProjectInfoDto().setType(value.getId()).setTypeName(value.getName()).setDeptManagerName(deptManagerName);
......@@ -751,16 +779,10 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_TIME_OVER_NOW_DAY);
}
if (1 == dto.getType() || 2 == dto.getType()) {
/* QueryWrapper<WorkProject> wrapper = new QueryWrapper<>();
wrapper.eq("id", dto.getProjectId());
wrapper.eq("type", dto.getType());
List<WorkProject> workProjects = workProjectMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(workProjects)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ItemType_Does_NotMatch);
}*/
if (null == dto.getProjectId()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_JOIN_EVERY_PROJECT_PLASE_JION);
}
}
List<WorkType> workTypes = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTypes)) {
......
......@@ -78,19 +78,19 @@ public class WorkTypeServiceImpl implements WorkTypeService {
@Transactional
@Override
public Boolean deleteTypeById(Integer id) {
log.info("WorkTypeServiceImpl[]deleteTypeById[]input.param.id:{}" + id);
if (null == id) {
public Boolean modifyStatusById(Integer id,Integer status) {
log.info("WorkTypeServiceImpl[]modifyStatusById[]input.param.id:{},status:{}" + id,status);
if (null == id || null == status) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
int i = workTypeMapper.updateIsDeleteById(id, 0);
int i = workTypeMapper.updateIsStatusById(id, status);
return i>0;
}
@Override
public List<WorkType> getByIsDelete(Integer isSort,Integer isDelete) {
log.info("WorkTypeServiceImpl[]getByIsDelete[]");
List<WorkType> workTypes = workTypeMapper.getByIsDelete(isDelete);
public List<WorkType> getByIsStatus(Integer isSort,Integer status) {
log.info("WorkTypeServiceImpl[]getByIsStatus[]");
List<WorkType> workTypes = workTypeMapper.getByIsStatus(status);
if (CollectionUtils.isEmpty(workTypes)) {
return null;
}
......
......@@ -129,12 +129,15 @@ public class SystemController extends BaseController {
return getResult(aBoolean);
}
@ApiOperation(value = "删除工时类型", notes = "删除工时类型", httpMethod = "DELETE")
@ApiImplicitParam(name = "id",value = "类型id",dataType ="int", required = true)
@DeleteMapping("/modifyWorkType")
public Result<Boolean> deleteTypeById(Integer id) {
log.info("SystemController[]modifyRole[]input.param.id:{}" + id);
Boolean aBoolean = workTypeService.deleteTypeById(id);
@ApiOperation(value = "修改工时类型状态", notes = "修改工时类型状态", httpMethod = "PUT")
@ApiImplicitParams({
@ApiImplicitParam(name = "id",value = "类型id",dataType ="int", required = true),
@ApiImplicitParam(name = "status",value = "状态:0无效 1正常",dataType ="int", required = true)
})
@PutMapping("/modifyStatus")
public Result<Boolean> modifyStatusById(Integer id,Integer status) {
log.info("SystemController[]modifyStatusById[]input.param.id:{},status:{}" + id,status);
Boolean aBoolean = workTypeService.modifyStatusById(id,status);
return getResult(aBoolean);
}
......
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