Merge branch 'version_performance_2.0' of http://gitlab.ldxinyong.com/enterpriseManagement/lz_management into version_performance_2.0

This commit is contained in:
杜建超 2020-11-09 16:46:11 +08:00
commit c287c4d7fa
17 changed files with 171 additions and 24 deletions

View File

@ -144,6 +144,19 @@ public class StringUtil extends StringUtils {
return result;
}
public static List<Long> splitToLongList(String source, String sep) {
List<Long> result = new ArrayList<Long>();
if (isBlank(source)) {
return result;
}
String[] tempResult = source.split(sep);
for (String item : tempResult) {
result.add(NumberUtil.objToLongDefault(item,0));
}
return result;
}
/**
* @param source 待处理字符串
* @return

View File

@ -408,7 +408,6 @@ public class ResultRecordController extends AbstractController {
BigDecimal weight = BigDecimal.ZERO;
for (ResultModel model:resultModels
) {
setCalculateValue(calculateModels, model);
ResultRecortModelDto resultRecortModelDto = new ResultRecortModelDto();
BeanUtils.copyProperties(model, resultRecortModelDto);
if(resultRecortModelDto.getWeight().compareTo(BigDecimal.ZERO) == 0){//不限权重的
@ -421,6 +420,7 @@ public class ResultRecordController extends AbstractController {
resultDetailService.selectDtosByRecordId(resultRecord.getId(), model.getType());
for (ResultDetailDto dto:detailDtos
) {
//下面设置计算公式
dto.setCalculate(setCalculateValue(calculateModels, dto)) ;
weight = weight.add(dto.getCheckWeight());
//获取评分详细
@ -460,7 +460,7 @@ public class ResultRecordController extends AbstractController {
dto.setScoreDtos(scoreDtos);
}
}
//下面设置计算公式
resultRecortModelDto.setDetailDtos(detailDtos);
resultRecortModelDtos.add(resultRecortModelDto);
@ -476,8 +476,10 @@ public class ResultRecordController extends AbstractController {
private String setCalculateValue(List<CalculateModel> calculateModels, Object model){
String mName = model.getClass().getName();//.replace("req", "dto");
String cal = "";
for (CalculateModel calculate:calculateModels
) {
//for (CalculateModel calculate:calculateModels
//) {
for(int i = 0; i < calculateModels.size(); i++){
CalculateModel calculate = calculateModels.get(i);
if(mName.contains("." + calculate.getTaboleBeanName())){//支持表名生成的req和dto
//获取值
try {
@ -487,8 +489,9 @@ public class ResultRecordController extends AbstractController {
if(obj != null){
calculate.setFieldValue(obj.toString());
}
if(calculate.getFieldValue() == null){
cal += calculate.getFieldBeanName();
//最后一个对象为自己或者获取的对象中的属性为null
if(calculate.getFieldValue() == null || i == calculateModels.size() - 1){
cal += ("{" + calculate.getFieldBeanName().substring(0, 1).toLowerCase() + calculate.getFieldBeanName().substring(1) + "}");
}else{
cal += calculate.getFieldValue();
}

View File

@ -210,7 +210,7 @@ public class StaffRoleController {
return staffRoleService.selectRoleInfoBy(roleModel);
}
// http://localhost:8080/lz_management/user/lzstaffrole/role/detail?id=4
// http://localhost:8080/lz_management/user/lzstaffrole/role/detail?id=28
// http://localhost:8080/lz_management/user/lzstaffrole/role/detail
@RequestMapping("/role/detail")
public R roleDetail(RoleModel roleModel) {

View File

@ -267,6 +267,13 @@ public class TestController {
R r = resultRecordService.initFlowRecord(resultRecordId);
}
// http://localhost:8080/lz_management/test/getAuth?userId=314
@RequestMapping("/test/getAuth")
public R getAuth(Long userId) throws Exception{
Map<String,Integer> map = staffRoleService.getRoleByUserId(userId);
return R.ok().put("data",map);
}
public static void main(String[] args) {
String a = "{\"313\":[17,20,13]}";

View File

@ -9,5 +9,6 @@ public class FlowDetailResp {
private Long flowRecordId;
private String departName;
private String avatar;
private int status ;
}

View File

@ -40,4 +40,6 @@ public interface RecordAuthMapper extends BaseMapper<RecordAuth> {
List<RecordAuth> selectAll();
List<AuthDto> selectAuthByRoleIds(@Param("roleIds") List<Long> roleIds);
List<AuthDto> selectAuthByIds(@Param("authIds") List<Long> authIds);
}

View File

@ -9,6 +9,8 @@ package com.lz.modules.flow.dao;
*/
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lz.modules.flow.entity.AuthDto;
import com.lz.modules.flow.entity.StaffMenu;
import com.lz.modules.flow.entity.StaffRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -50,4 +52,10 @@ public interface StaffRoleMapper extends BaseMapper<StaffRole> {
List<StaffRole> selectByRoleLevel(@Param("name") String name);
List<StaffRole> selectPageByRoleLevel(@Param("page") IPage page, @Param("name") String name);
StaffRole selectStaffRolesByStaffIdDepartmentLevel(@Param("staffId") Long staffId, @Param("departmentLevel") String departmentLevel);
List<StaffRole> selectAllByStaffId(@Param("staffId") Long staffId);
List<StaffMenu> selectAllMenus(@Param("userId") Long userId);
}

View File

@ -42,7 +42,7 @@ public class StaffMenu implements java.io.Serializable {
private Long parentId;
//授权 id
@ApiModelProperty(value = "授权 id", name = "authIds")
private Long authIds;
private String authIds;
@TableField(exist=false)
private List<StaffMenu> childs;
/**
@ -139,14 +139,14 @@ public class StaffMenu implements java.io.Serializable {
* 授权 id
* @return
*/
public Long getAuthIds() {
public String getAuthIds() {
return authIds;
}
/**
* 授权 id
* @param authIds
*/
public void setAuthIds(Long authIds) {
public void setAuthIds(String authIds) {
this.authIds = authIds;
}

View File

@ -47,4 +47,6 @@ public interface RecordAuthService extends IService<RecordAuth> {
Long getRoleIdByStaffRoleInfo(String flowStaffIdRole,Long approvalStaffId);
Map<String, Integer> selectAuthByRoleIds(List<Long> roleIds);
Map<String, Integer> selectAuthByIds(List<Long> authIds);
}

View File

@ -61,4 +61,8 @@ public interface StaffRoleService extends IService<StaffRole> {
R roleAddOrUpdate(RoleModel roleModel);
R delete(RoleModel roleModel);
List<StaffRole> selectAllByStaffId(Long userId);
Map<String, Integer> getRoleByUserId(Long userId);
}

View File

@ -129,8 +129,20 @@ public class RecordAuthServiceImpl extends ServiceImpl<RecordAuthMapper, RecordA
return map;
}
@Override
public Map<String, Integer> selectAuthByIds(List<Long> authIds) {
Map<String,Integer> map = new HashMap<>();
List<AuthDto> list = recordAuthMapper.selectAuthByIds(authIds);
if(CollectionUtils.isNotEmpty(list)){
for(AuthDto authDto:list){
map.put(authDto.getIdentity(),authDto.getStatus());
}
}
return map;
}
public Auth getAuth(List<RecordAuth> auths) {
public Auth getAuth(List<RecordAuth> auths) {
Map<String, Integer> map = new HashMap<>();
if (CollectionUtils.isNotEmpty(auths)) {
for(RecordAuth recordAuth : auths){

View File

@ -32,6 +32,7 @@ import com.lz.modules.sys.entity.SysMenuEntity;
import com.lz.modules.sys.entity.SysRoleEntity;
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;
@ -90,13 +91,16 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService;
@Autowired
private StaffMenuService staffMenuService;
@Autowired
private StaffRoleDepartmentService staffRoleDepartmentService;
@Autowired
private RecordAuthService recordAuthService;
@Override
public StaffRole selectStaffRoleById(Long id) {
return staffRoleMapper.selectStaffRoleById(id);
@ -328,7 +332,7 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
List<String> deparmentNames = new ArrayList<>();
if (staffRole.getDepartmentId().equals(new Long(2))) {
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
for(StaffRoleDepartment staffRoleDepartment:staffRoleDepartments){
for (StaffRoleDepartment staffRoleDepartment : staffRoleDepartments) {
DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(staffRoleDepartment.getDepartmentId());
deparmentNames.add(departmentsEntity.getDepartmentName());
}
@ -360,8 +364,8 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
@Override
public R selectRoleDetail(RoleModel roleModel) {
StaffRole staffRole= staffRoleMapper.selectById(roleModel.getId());
if(staffRole == null ){
StaffRole staffRole = staffRoleMapper.selectById(roleModel.getId());
if (staffRole == null) {
staffRole = new StaffRole();
}
StaffRoleDetailInfo info = new StaffRoleDetailInfo();
@ -407,6 +411,10 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
return R.ok("更新成功");
}
} else if (roleModel.getStaffId() != null) { // 员工不为空
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevel(roleModel.getStaffId(), roleModel.getDepartmentLevel());
if (data != null) {
return R.error("该管理员己经存在");
}
staffRole = new StaffRole();
com.lz.modules.app.utils.BeanUtils.copyProperty(staffRole, roleModel);
staffRole.setStaffName(staffEntity.getName());
@ -454,6 +462,43 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
return R.ok();
}
@Override
public List<StaffRole> selectAllByStaffId(Long staffId) {
return staffRoleMapper.selectAllByStaffId(staffId);
}
@Override
public Map<String, Integer> getRoleByUserId(Long userId) {
Map<String ,Integer> map = new HashMap<>();
List<StaffRole> staffRoleList = staffRoleMapper.selectAllByStaffId(userId);
List<StaffMenu> staffMenus = new ArrayList<>();
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(userId);
if(new Integer(1).equals(departmentsStaffRelateEntity.getIsLeader())){
List<StaffMenu> staffMenuDepartmentList= staffMenuService.selectByParentId( RoleMenuEnums.DEPARTMENT_PM.getType());
if(CollectionUtils.isNotEmpty(staffMenuDepartmentList)){
staffMenus.addAll(staffMenuDepartmentList);
}
}
if(CollectionUtils.isNotEmpty(staffRoleList)){
List<StaffMenu> staffMenuList = staffRoleMapper.selectAllMenus(userId);
if(CollectionUtils.isNotEmpty(staffMenuList)){
staffMenus.addAll(staffMenuList);
}
}
if(CollectionUtils.isNotEmpty(staffMenus) && staffMenus.size() > 0 ){
List<Long> authIds = new ArrayList<>();
for(StaffMenu staffMenu:staffMenus){
List<Long> ids = StringUtil.splitToLongList(staffMenu.getAuthIds(),",");
authIds.addAll(ids);
}
if(authIds.size() > 0){
map = recordAuthService.selectAuthByIds(authIds);
}
}
return map;
}
public void insertPM(StaffRole staffRole, Long parentId, StaffEntity staffEntity) {
staffRole.setEvaluationGroupId(EvaluationGroupEnums.ALL.getType());//全部考评组
staffRole.setDepartmentId(DepartmentPMEnums.ALL.getType());//所有部门

View File

@ -18,6 +18,8 @@ import com.lz.modules.app.enums.SmsTypeEnum;
import com.lz.modules.app.service.CodeRecordService;
import com.lz.modules.app.service.SmsTemplateService;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.service.StaffRoleService;
import com.lz.modules.sys.entity.SysConfigEntity;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.form.SysLoginForm;
@ -41,9 +43,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.*;
/**
* 登录相关
@ -64,6 +64,9 @@ public class SysLoginController extends AbstractController {
private CodeRecordService codeRecordService;
@Resource
private SysConfigService sysConfigService;
@Autowired
private StaffRoleService staffRoleService;
@Resource
private DhgjSmsUtil dhgjSmsUtil;
@ -71,7 +74,7 @@ public class SysLoginController extends AbstractController {
private String environment;
@Autowired
private StaffService staffService ;
private StaffService staffService;
/**
* 验证码
@ -181,7 +184,7 @@ public class SysLoginController extends AbstractController {
SysUserEntity user = sysUserService.queryByUserName(form.getUserName());
if (user == null) {
StaffEntity staffEntity = staffService.selectByPhone(form.getUserName());
if(staffEntity != null){
if (staffEntity != null) {
user = new SysUserEntity();
user.setPassword(staffEntity.getPassword());
user.setMobile(staffEntity.getMobile());
@ -193,7 +196,7 @@ public class SysLoginController extends AbstractController {
user.setUsername(staffEntity.getMobile());
user.setRealName(staffEntity.getName());
user.setUserNo(staffEntity.getMobile());
}else{
} else {
return R.error("账号不存在!");
}
}
@ -218,11 +221,15 @@ public class SysLoginController extends AbstractController {
}
//生成token并保存到数据库
R r = sysUserTokenService.createToken(user);
return r;
Map<String,Integer> map = staffRoleService.getRoleByUserId(user.getUserId());
return r.put("data",map);
}
/**
* 退出
*/

View File

@ -1131,11 +1131,21 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
}
Map<String,Integer> auth = new HashMap<>();
auth.put("showScore",1);
auth.put("showResult",1);
auth.put("showScore",1);
List<FlowRecord> currentResultRecords = flowRecordService.selectFlowRecordByRecordIdStatus(recordDetailDto.getResultRecordId(),2);
log.info("当前用户登陆用户 id :" + recordDetailDto.getLoginUserId());
if(currentResultRecords !=null && currentResultRecords.size() > 0 ){
FlowRecord currentFlowRecord = currentResultRecords.get(0);
int flowProcess = currentFlowRecord.getFlowProcess();
if(flowProcess < 3 ){
auth.put("showResult",0);
}
if( flowProcess < 4 ){
auth.put("showScore",0);
}
FlowRecord currentResultRecord = null;
for(FlowRecord flowRecord:currentResultRecords){
if(flowRecord.getApprovalStaffId().equals(recordDetailDto.getLoginUserId())){
@ -1172,6 +1182,14 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
flowDetailResp.setCurrentStaffId(flowRecord.getApprovalStaffId());
flowDetailResp.setStaffName(flowRecord.getApprovalStaffName());
flowDetailResp.setFlowRecordId(flowRecord.getId());
int status = flowRecord.getStatus();
if (flowRecord.getStatus() == 3) {
status = 0;
}
if (flowRecord.getStatus() == 2) {
status = 0;
}
flowDetailResp.setStatus(status);
StaffEntity staffEntity = staffService.selectStaffById(flowRecord.getApprovalStaffId());
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(flowRecord.getApprovalStaffId());
flowDetailResp.setAvatar(staffEntity.getAvatar());

View File

@ -136,7 +136,7 @@
</select>
<select id="selectEvaluationGroupByName" resultType="EvaluationGroup" >
select * from lz_evaluation_group where name=#{name} and is_delete = 0 limit 1
select * from lz_evaluation_group where name=#{name} and is_delete = 0 and copy_id = 0 limit 1
</select>
<update id="deleteByCopyIds">

View File

@ -108,5 +108,14 @@
</select>
<select id="selectAuthByIds" resultType="com.lz.modules.flow.entity.AuthDto">
select * from (select identity ,status from lz_record_auth where id in
<foreach item="item" collection="authIds" open="(" separator="," close=")">
#{item}
</foreach>
order by status desc)a group by identity
</select>
</mapper>

View File

@ -155,5 +155,21 @@
</select>
<select id="selectStaffRolesByStaffIdDepartmentLevel" resultType="com.lz.modules.flow.entity.StaffRole">
select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel} and staff_id =#{staffId}
</select>
<select id="selectAllByStaffId" resultType="com.lz.modules.flow.entity.StaffRole">
select * from lz_staff_role where is_delete = 0 and staff_id =#{staffId}
</select>
<select id="selectAllMenus" resultType="com.lz.modules.flow.entity.StaffMenu">
select * from lz_staff_menu where id in (
select menu_id from lz_staff_role_menu where role_id in (
select id from lz_staff_role where staff_id = #{userId}))
</select>
</mapper>