Commit 45511f79 authored by nie'hong's avatar nie'hong

删除user中的level

parent bda2c538
......@@ -25,4 +25,6 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> {
int updateManagerIdISNullById(Integer id);
List<WorkDept> getDeptByManagerId(Integer userId);
}
......@@ -3,9 +3,11 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.WorkTypeManager;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
public interface WorkTypeManagerMapper extends BaseMapper<WorkTypeManager> {
public interface WorkTypeManagerMapper extends BaseMapper<WorkTypeManager> {
List<WorkTypeManager> getListByManagerId(Integer userId);
}
......@@ -76,4 +76,10 @@ ORDER BY c.id,d.id
</select>
<select id="getDeptByManagerId" resultType="cn.wisenergy.model.app.WorkDept">
select <include refid="cols_all"/>
from <include refid="table"/>
where manager_id = #{userId}
</select>
</mapper>
......@@ -106,7 +106,7 @@
AND statistics_start >= #{firstDayOfMonth}
</if>
GROUP BY type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id,project_name
<if test="centreId != null"> ORDER BY </if>
<if test="centreId != null"> ORDER BY p.dept_id</if>
</select>
......
......@@ -221,9 +221,15 @@
<foreach collection="statusArray" item="workStatus" open="(" close=")" separator=",">#{workStatus}
</foreach>
</if>
<if test="typeArray != null">
<if test="typeList != null">
AND `type` IN
<foreach collection="typeArray" item="type" open="(" close=")" separator=",">
<foreach collection="typeList" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
<if test="deptIdList != null">
AND `type` IN
<foreach collection="deptIdList" item="dept" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
......
......@@ -3,5 +3,9 @@
<mapper namespace="cn.wisenergy.mapper.WorkTypeManagerMapper">
<select id="getListByManagerId" resultType="cn.wisenergy.model.app.WorkTypeManager">
select id, name,dept_id,manager_id,type
from work_type_manager
where manager_id = #{userId}
</select>
</mapper>
\ No newline at end of file
......@@ -16,7 +16,6 @@
<result column="type" property="type" />
<result column="status" property="status" />
<result column="wx_id" property="wxId" />
<result column="level" property="level" />
<result column="create_time" property="createTime" />
<result column="modify_time" property="modifyTime" />
</resultMap>
......@@ -33,11 +32,11 @@
</sql>
<sql id="cols_exclude_id">
name, oa_user_id, login_name, phone, dept_id, email, role ,type,status,wx_id,level,create_time,modify_time
name, oa_user_id, login_name, phone, dept_id, email, role ,type,status,wx_id,create_time,modify_time
</sql>
<sql id="values">
#{name},#{oaUserId},#{loginName},#{phone},#{deptId},#{email},#{role},#{type},#{status},#{wxId},#{level},now(),now()
#{name},#{oaUserId},#{loginName},#{phone},#{deptId},#{email},#{role},#{type},#{status},#{wxId},now(),now()
</sql>
<sql id="updateCondition">
......@@ -52,7 +51,6 @@
<if test="type != null">type =#{type},</if>
<if test="status != null">status = #{status},</if>
<if test="wxId != null">wx_id =#{wxId},</if>
<if test="level != null">level = #{level},</if>
modify_time =now()
</sql>
......@@ -69,7 +67,6 @@
<if test="type != null">and type =#{type}</if>
<if test="status != null">and status = #{status}</if>
<if test="wxId != null">and wx_id =#{wxId},</if>
<if test="level != null">and level = #{level}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="modifyTime != null">and #{modifyTime} &gt;= modify_time</if>
</sql>
......
......@@ -62,9 +62,6 @@ public class WorkUser implements Serializable {
@ApiModelProperty(name = "wxId",value = "微信id")
private String wxId;
@ApiModelProperty(name = "level",value = "权限级别:普通用户:0,项目/商机级别:1,部门级别:2,中心级别:3,系统管理员:4")
private Integer level;
@ApiModelProperty(name = "createTime",value = "创建时间")
private Date createTime;
......
......@@ -10,8 +10,7 @@ public enum LevelEnum {
PROJECT_MANAGER( "项目/商机管理"),
TIMEEXPORT("工时导出"),
SYSTEMSETTINGS("系统设置"),
ACCOUNTMANAGEMENT("账号管理"),
ACCOUNTMANAGEMENT("账号管理")
;
......
......@@ -70,6 +70,9 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired
private WorkDeptMapper workDeptMapper;
@Autowired
private WorkTypeManagerMapper workTypeManagerMapper;
@Autowired
private WorkUserProjectMapper workUserProjectMapper;
......@@ -84,9 +87,10 @@ public class StatisticsServiceImpl implements StatisticsService {
if (param == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
//管理员用户
List<Integer> role = userRoleLevelUtils.getRole(param.getUserId());
if (!role.contains(ManagerEnum.IS_SYSTEM_MANAGER.getCode())) {
// 用户权限名
List<String> userAuthority = this.getUserAuthority(param.getUserId());
if (!userAuthority.contains(LevelEnum.TIMEEXPORT.getLevelName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
//默认时间为当月
......@@ -143,7 +147,7 @@ public class StatisticsServiceImpl implements StatisticsService {
public Map<String, Object> getMonthlyStatistics(Integer userId) {
log.info("WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param" + userId);
WorkUser user = workUserService.getById(userId);
List<Integer> role = userRoleLevelUtils.getRole(user.getId());
List<String> userAuthority = this.getUserAuthority(userId);
//本月第一天
Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
// 返回数据对象
......@@ -151,7 +155,7 @@ public class StatisticsServiceImpl implements StatisticsService {
//存放查询条件
Map<String, Object> map = new HashMap<>();
//用户是项目或部门级别,查询审批统计
if (role.contains(ManagerEnum.IS_PROJECT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode())) {
if (userAuthority.contains(LevelEnum.EXAMINE.getLevelName())) {
//以审批人、审核状态、开始时间查询本月审批数量
map.put("reviewerId", userId);
map.put("startDay", firstDayOfMonth);
......@@ -161,21 +165,19 @@ public class StatisticsServiceImpl implements StatisticsService {
map.put("status", WorkOrderStatus.TURN_DOWN.getCode());
Integer rejectAndNotResubmit = workTimeOrderMapper.getCountByCondition(map);
// 项目级别,获取所管理项目,
if (role.contains(ManagerEnum.IS_PROJECT_DIRECTOR.getCode())) {
// 查询用户负责项目
List<WorkProject> projects = workProjectService.getUserManageProjects(userId);
if (CollectionUtil.isNotEmpty(projects)) {
List<Integer> projectIds = projects.stream().map(WorkProject::getId).collect(Collectors.toList());
map.put("projectIds", projectIds);
}
}
// 部门级别
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode())) {
List<WorkTypeManager> workTypeManagers = workTypeManagerMapper.getListByManagerId(userId);
if (CollectionUtil.isNotEmpty(workTypeManagers)) {
List<Integer> type = workTypeManagers.stream().map(WorkTypeManager::getType).collect(Collectors.toList());
map.put("typeList", type);
map.put("deptId", user.getDeptId());
//填报项目类型编码
int[] workOrderTypeArray = {WorkOrderType.EXTERNAL_WORK.getCode(), WorkOrderType.INTERNAL_WORK.getCode(), WorkOrderType.OTHER_NOT_PROJECT_BUSINESS.getCode()};
map.put("typeArray", workOrderTypeArray);
}
//待审核包括:新提交和重新提交的
List<Integer> statusArray = new ArrayList<>();
statusArray.add(WorkOrderStatus.WAIT_AUDIT.getCode());
......@@ -195,7 +197,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 填报情况
// 本月应填报日期
List<Date> currentMonthWorkDays = this.currentMonthWorkDays(firstDayOfMonth);
List<Date> currentMonthWorkDays = this.currentMonthWorkDays(firstDayOfMonth,true);
// 本月已填报日期
List<Date> currentMonthFilledDays = this.currentMonthFilledDays(userId, firstDayOfMonth);
// 本月未填报日期
......@@ -265,9 +267,11 @@ public class StatisticsServiceImpl implements StatisticsService {
}
// 用户角色
List<Integer> role = userRoleLevelUtils.getRole(user.getId());
// 普通用户
if (role.contains(ManagerEnum.NOT_MANAGER.getCode())) {
List<Integer> role = UserRoleLevelUtils.getRole(userId);
// 用户权限
List<String> userAuthority = this.getUserAuthority(userId);
// 没有小程序工时汇总权限
if (!userAuthority.contains(LevelEnum.EXAMINE.getLevelName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
......@@ -293,7 +297,6 @@ public class StatisticsServiceImpl implements StatisticsService {
WorkDept workDept = workDeptMapper.getById(user.getDeptId());
map.put("centreId",workDept.getCentreId() );
}
// 查询项目和商机的工时统计
List<WorkTimeAndCostCollect> collect = workProjectTimeCostMapper.selectList(map);
// 获取查询出的类型
......@@ -313,26 +316,26 @@ public class StatisticsServiceImpl implements StatisticsService {
collect.add(workTimeAndCostCollect);
}
}
// 用户不为项目级别或不仅为项目级别
if (!role.contains(ManagerEnum.IS_PROJECT_DIRECTOR.getCode()) || role.size() != 1) {
// 部门和中心级别
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
// 清除查询条件
map.remove("projectIds");
map.remove("centreId");
types.clear();
// 查询条件排除项目和商机
// 查询类型排除项目和商机
for (WorkType workType : workTypes) {
if (!workType.getName().equals(workTypes.get(0).getName()) && !workType.getName().equals(workTypes.get(1).getName())) {
types.add(workType.getId());
}
}
map.put("types", types);
// 用户仅为部门管理,以部门主键作为查询条件之一,否则中心级别查询所有部门
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) && role.size() == 1) {
// 用户不为中心级别
if (!role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
map.put("deptId", user.getDeptId());
}
map.put("types", types);
List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map);
// 将查询结果封装在一起
......@@ -349,6 +352,7 @@ public class StatisticsServiceImpl implements StatisticsService {
collect.add(workTimeAndCostCollect1);
}
}
}
// 给类型赋值类型名称
for (WorkTimeAndCostCollect timeAndCostCollect : collect) {
......@@ -358,11 +362,11 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
}
for (WorkTimeAndCostCollect workTimeAndCostCollect : collect) {
// 类型总工时
for (WorkTimeAndCostCollect workTimeAndCostCollect1 : collect) {
// 类型的总工时
BigDecimal typeTotalTime = new BigDecimal("0.0000");
List<DeptProjectWorkTimeAndCost> deptProjectWorkTimeAndCosts = workTimeAndCostCollect.getDeptProjectWorkTimeAndCosts();
BigDecimal typeTotalTime = new BigDecimal("0.000");
List<DeptProjectWorkTimeAndCost> deptProjectWorkTimeAndCosts = workTimeAndCostCollect1.getDeptProjectWorkTimeAndCosts();
if (CollectionUtil.isNotEmpty(deptProjectWorkTimeAndCosts)) {
for (DeptProjectWorkTimeAndCost deptProjectWorkTimeAndCost : deptProjectWorkTimeAndCosts) {
List<ProjectWorkTimeAndCostStatistics> projectWorkTimeAndCostStatistics = deptProjectWorkTimeAndCost.getProjectWorkTimeAndCostStatistics();
......@@ -371,8 +375,9 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
}
workTimeAndCostCollect.setWorkTime(typeTotalTime);
workTimeAndCostCollect1.setWorkTime(typeTotalTime);
}
Collections.sort(collect);
return collect;
}
......@@ -380,10 +385,12 @@ public class StatisticsServiceImpl implements StatisticsService {
@Override
public HSSFWorkbook exportWorkTimeExcel(GetMonthlyCollectParam param) {
log.info("StatisticsServiceImpl[]exportWorkTimeExcel[]input.param{}" + param);
PageInfo dayWorkTimeOfMonth = getDayWorkTimeOfMonth(param);
PageInfo dayWorkTimeOfMonth = this.getDayWorkTimeOfMonth(param);
Date date = DateUtil.convertStrToDate(param.getYear() + "-" + param.getMonth(), "yyyy-MM");
// 传参的时间当月总天数
int dayCount = DateUtil.getMonthDaysArray(date).length;
// 当天
Date today = new Date();
// 需要导出的信息
List<StatisticsTableDto> list = dayWorkTimeOfMonth.getList();
// 创建工作簿
......@@ -404,7 +411,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 第一列列宽
sheet.setColumnWidth(1, EXCEL_WIDTH);
// 获取本月应上班日期集合
List<Date> dates = this.currentMonthWorkDays(date);
List<Date> dates = this.currentMonthWorkDays(date,false);
List<Integer> days = new ArrayList<>();
for (Date date1 : dates) {
days.add(DateUtil.getDay(date1));
......@@ -500,7 +507,8 @@ public class StatisticsServiceImpl implements StatisticsService {
public List<UserWorkTimeStatisticsByProject> getUserWorkTimeStatisticsReport(Integer userId, Integer deptId, String startDate, String endDate, Integer isConclusion) {
log.info("StatisticsServiceImpl[]getUserWorkTimeStatisticsReport[]" + userId + deptId + startDate + endDate + isConclusion);
List<Integer> role = userRoleLevelUtils.getRole(userId);
if (role.contains(ManagerEnum.NOT_MANAGER.getCode())) {
List<String> userAuthority = this.getUserAuthority(userId);
if (!userAuthority.contains(LevelEnum.EXAMINE.getLevelName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
// 不是中心级不能选择部门
......@@ -581,8 +589,10 @@ public class StatisticsServiceImpl implements StatisticsService {
@Override
public List<ProjectStatisticsByMonth> getProjectStatistics(Integer userId, Integer deptId, Integer year, Integer projectId) {
log.info("StatisticsServiceImpl[]getProjectStatistics[]input.param" + userId + deptId + year + projectId);
// 权限判断
// 获取角色
List<Integer> role = userRoleLevelUtils.getRole(userId);
// 获取权限
List<String> userAuthority = this.getUserAuthority(userId);
if (!role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
}
......@@ -637,14 +647,14 @@ public class StatisticsServiceImpl implements StatisticsService {
}
//获取一个月应上班日期,如果是当月,时间截至到当天
public List<Date> currentMonthWorkDays(Date date) {
public List<Date> currentMonthWorkDays(Date date, boolean toToday) {
log.info("StatisticsServiceImpl[]currentMonthWorkDays[]input.method");
// 时间为本月,起始时间为参数时间当月第一天,截至时间为当天。否则,截至时间为当月最后一天
Date startDate = DateUtil.getFirstDayOfMonth(date);
Date endDate = null;
// 当前时间
Date now = new Date();
if (DateUtil.getYear(date) == DateUtil.getYear(now) && DateUtil.getMonth(date) == DateUtil.getMonth(now)) {
if (DateUtil.getYear(date) == DateUtil.getYear(now) && DateUtil.getMonth(date) == DateUtil.getMonth(now) && toToday) {
endDate = DateUtil.getStartOfDay(now);
} else {
endDate = DateUtil.getLastDayOfMonth(date);
......@@ -743,4 +753,17 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
}
// 获取用户权限
public List<String> getUserAuthority(Integer userId) {
// 获取用户角色
List<Integer> role = UserRoleLevelUtils.getRole(userId);
// 获取角色对应权限id
List<Integer> list = UserRoleLevelUtils.getlevelIds(role);
// 获取权限对象
List<WorkLevel> workLevels = UserRoleLevelUtils.getlevelByIds(list);
// 获取权限名
List<String> collect = workLevels.stream().map(WorkLevel::getName).collect(Collectors.toList());
return collect;
}
}
......@@ -480,10 +480,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
isManager(reviewerId);
Integer level = workUserService.getById(reviewerId).getLevel();
if (level == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
int i = workTimeOrderMapper.updateStatusById(reviewerId, id, reason);
if (i == 0) {
......
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