|
@@ -3,6 +3,8 @@ package com.hssx.cloudmodel.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
import com.hssx.cloudmodel.constant.Constant;
|
|
import com.hssx.cloudmodel.constant.Constant;
|
|
import com.hssx.cloudmodel.entity.*;
|
|
import com.hssx.cloudmodel.entity.*;
|
|
import com.hssx.cloudmodel.entity.vo.MouldEquipmentVO;
|
|
import com.hssx.cloudmodel.entity.vo.MouldEquipmentVO;
|
|
@@ -18,6 +20,7 @@ import com.hssx.cloudmodel.util.ListUtil;
|
|
import com.hssx.cloudmodel.util.WechatTemplateMessage;
|
|
import com.hssx.cloudmodel.util.WechatTemplateMessage;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
@@ -62,7 +65,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
MouldFileMapper mouldFileMapper;
|
|
MouldFileMapper mouldFileMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg addAndUpdateMould(Mould mould, User user,Integer dynamicId) {
|
|
|
|
|
|
+ public HttpRespMsg addAndUpdateMould(Mould mould, User user, Integer dynamicId) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
if (mould.getId() != null) {
|
|
if (mould.getId() != null) {
|
|
//修改
|
|
//修改
|
|
@@ -84,7 +87,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
//更新模具操作
|
|
//更新模具操作
|
|
//取出之前模具的信息
|
|
//取出之前模具的信息
|
|
Mould model = mouldMapper.selectById(mould.getPreUpdateId());
|
|
Mould model = mouldMapper.selectById(mould.getPreUpdateId());
|
|
- if(null != dynamicId){
|
|
|
|
|
|
+ if (null != dynamicId) {
|
|
//更新模具更新的动态为已更新
|
|
//更新模具更新的动态为已更新
|
|
MouldFile mf = new MouldFile();
|
|
MouldFile mf = new MouldFile();
|
|
mf.setId(dynamicId);
|
|
mf.setId(dynamicId);
|
|
@@ -146,61 +149,62 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
public HttpRespMsg getMoildDetail(MouldVO mouldVO) {
|
|
public HttpRespMsg getMoildDetail(MouldVO mouldVO) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
- User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", mouldVO.getToken()));
|
|
|
|
|
|
+ User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", mouldVO.getToken()));
|
|
|
|
+ UserVO userVO = new UserVO();
|
|
|
|
+ BeanUtils.copyProperties(user, userVO);
|
|
List<Integer> set = new ArrayList<>();
|
|
List<Integer> set = new ArrayList<>();
|
|
- List<Mould> moulds = new ArrayList<>();
|
|
|
|
- if (currentUser.getId() != null) {
|
|
|
|
|
|
+ List<MouldVO> moulds = new ArrayList<>();
|
|
|
|
+ if (userVO.getId() != null) {
|
|
//资产方管理员,获取他公司下的所有模具
|
|
//资产方管理员,获取他公司下的所有模具
|
|
- if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
|
|
|
+ if (Constant.SYS_PARENT_ID == userVO.getParentId()) {
|
|
//超级管理员,获取平台所有模具
|
|
//超级管理员,获取平台所有模具
|
|
- moulds = mouldMapper.selectList(new QueryWrapper<Mould>());
|
|
|
|
- } else if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
|
|
+ moulds = mouldMapper.selectListByCondition(userVO);
|
|
|
|
+ } else if (Constant.SYS_ID == userVO.getParentId()) {
|
|
|
|
|
|
- if(Constant.ASSETS_COMPANY == currentUser.getSubordinateType()){
|
|
|
|
|
|
+ if (Constant.ASSETS_COMPANY == userVO.getSubordinateType()) {
|
|
//资产方管理员
|
|
//资产方管理员
|
|
- moulds = mouldMapper.selectList(new QueryWrapper<Mould>().eq("company_id",currentUser.getCompanyId()));
|
|
|
|
- }else if(Constant.PRODUCER_COMPANY == currentUser.getSubordinateType()){
|
|
|
|
- set = customCompanyMapper.selectList(new QueryWrapper<CustomCompany>().eq("company_id", currentUser.getCompanyId())).stream().map(CustomCompany::getProjectId).collect(Collectors.toList());
|
|
|
|
|
|
+ moulds = mouldMapper.selectListByCondition(userVO);
|
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == userVO.getSubordinateType()) {
|
|
|
|
+ set = customCompanyMapper.selectList(new QueryWrapper<CustomCompany>().eq("company_id", userVO.getCompanyId())).stream().map(CustomCompany::getProjectId).collect(Collectors.toList());
|
|
set.add(-1);
|
|
set.add(-1);
|
|
- moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id",set));
|
|
|
|
|
|
+ moulds = mouldMapper.selectListByConditionByProject(userVO, set);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//普通用户或者项目经理
|
|
//普通用户或者项目经理
|
|
//充当项目经理参与的项目
|
|
//充当项目经理参与的项目
|
|
- QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
- qw.eq("manager_id", currentUser.getId());
|
|
|
|
- List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
- if (projects.size() > 0) {
|
|
|
|
- for (Project project : projects) {
|
|
|
|
- set.add(project.getId());
|
|
|
|
- }
|
|
|
|
|
|
+ QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("manager_id", userVO.getId());
|
|
|
|
+ List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
+ if (projects.size() > 0) {
|
|
|
|
+ for (Project project : projects) {
|
|
|
|
+ set.add(project.getId());
|
|
}
|
|
}
|
|
|
|
+ }
|
|
// //充当普通人员参与的项目
|
|
// //充当普通人员参与的项目
|
|
- List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", currentUser.getId()));
|
|
|
|
- if (projectUsers.size() > 0) {
|
|
|
|
- for (ProjectUser projectUser : projectUsers) {
|
|
|
|
- set.add(projectUser.getProjectId());
|
|
|
|
- }
|
|
|
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", userVO.getId()));
|
|
|
|
+ if (projectUsers.size() > 0) {
|
|
|
|
+ for (ProjectUser projectUser : projectUsers) {
|
|
|
|
+ set.add(projectUser.getProjectId());
|
|
}
|
|
}
|
|
|
|
+ }
|
|
// //充当审批人员参与的项目
|
|
// //充当审批人员参与的项目
|
|
- List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId()));
|
|
|
|
- if (projectss.size() > 0) {
|
|
|
|
- for (ProjectApprove projectUser : projectss) {
|
|
|
|
- set.add(projectUser.getProjectId());
|
|
|
|
- }
|
|
|
|
|
|
+ List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", userVO.getId()));
|
|
|
|
+ if (projectss.size() > 0) {
|
|
|
|
+ for (ProjectApprove projectUser : projectss) {
|
|
|
|
+ set.add(projectUser.getProjectId());
|
|
}
|
|
}
|
|
|
|
+ }
|
|
set.add(-1);
|
|
set.add(-1);
|
|
- moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id",set));
|
|
|
|
|
|
+ moulds = mouldMapper.selectListByConditionByProject(userVO, set);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
msg.setError("用户不存在,或者未登录!");
|
|
msg.setError("用户不存在,或者未登录!");
|
|
- return msg;
|
|
|
|
}
|
|
}
|
|
- List<Integer> mIds = moulds.stream().map(Mould::getId).collect(Collectors.toList());
|
|
|
|
- if(!mIds.contains(mouldVO.getId())){
|
|
|
|
|
|
+ List<Integer> mIds = moulds.stream().map(MouldVO::getId).collect(Collectors.toList());
|
|
|
|
+ if (!mIds.contains(mouldVO.getId())) {
|
|
msg.setError("你没有查看该模具的权限!");
|
|
msg.setError("你没有查看该模具的权限!");
|
|
return msg;
|
|
return msg;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
MouldVO mould = mouldMapper.getDetailById(mouldVO);
|
|
MouldVO mould = mouldMapper.getDetailById(mouldVO);
|
|
map.put("vo", mould);
|
|
map.put("vo", mould);
|
|
ProjectVO vo = projectMapper.getProjectById(mould.getProjectId());
|
|
ProjectVO vo = projectMapper.getProjectById(mould.getProjectId());
|
|
@@ -212,29 +216,29 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
} else {
|
|
} else {
|
|
List<CustomCompany> list = customCompanyMapper.selectList(new QueryWrapper<CustomCompany>().eq("project_id", mould.getProjectId()));
|
|
List<CustomCompany> list = customCompanyMapper.selectList(new QueryWrapper<CustomCompany>().eq("project_id", mould.getProjectId()));
|
|
map.put("customCompany", list);
|
|
map.put("customCompany", list);
|
|
- if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
|
|
|
+ if (Constant.SYS_PARENT_ID == userVO.getParentId()) {
|
|
//当前人超级管理员 ,对项目只可以浏览
|
|
//当前人超级管理员 ,对项目只可以浏览
|
|
map.put("update", 0);
|
|
map.put("update", 0);
|
|
map.put("download", 0);
|
|
map.put("download", 0);
|
|
map.put("view", 1);
|
|
map.put("view", 1);
|
|
map.put("approve", 0);
|
|
map.put("approve", 0);
|
|
- } else if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
|
|
+ } else if (Constant.SYS_ID == userVO.getParentId()) {
|
|
//当前为系统管理员
|
|
//当前为系统管理员
|
|
- if (Constant.ASSETS_COMPANY == currentUser.getSubordinateType()) {
|
|
|
|
|
|
+ if (Constant.ASSETS_COMPANY == userVO.getSubordinateType()) {
|
|
map.put("update", 1);
|
|
map.put("update", 1);
|
|
map.put("download", 1);
|
|
map.put("download", 1);
|
|
map.put("view", 1);
|
|
map.put("view", 1);
|
|
map.put("approve", 0);
|
|
map.put("approve", 0);
|
|
- } else if (Constant.PRODUCER_COMPANY == currentUser.getSubordinateType()) {
|
|
|
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == userVO.getSubordinateType()) {
|
|
map.put("update", 0);
|
|
map.put("update", 0);
|
|
map.put("download", 1);
|
|
map.put("download", 1);
|
|
map.put("view", 1);
|
|
map.put("view", 1);
|
|
map.put("approve", 0);
|
|
map.put("approve", 0);
|
|
}
|
|
}
|
|
- } else if (vo.getManagerId() == currentUser.getId()) {
|
|
|
|
|
|
+ } else if (vo.getManagerId() == userVO.getId()) {
|
|
//当前人是该项目的项目经理
|
|
//当前人是该项目的项目经理
|
|
Integer approve = 0;
|
|
Integer approve = 0;
|
|
- if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0) {
|
|
|
|
|
|
+ if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", userVO.getId())) > 0) {
|
|
//查看当前项目经理是否为审批人
|
|
//查看当前项目经理是否为审批人
|
|
approve = 1;
|
|
approve = 1;
|
|
}
|
|
}
|
|
@@ -242,7 +246,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
map.put("download", 1);
|
|
map.put("download", 1);
|
|
map.put("view", 1);
|
|
map.put("view", 1);
|
|
map.put("approve", approve);
|
|
map.put("approve", approve);
|
|
- } else if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0) {
|
|
|
|
|
|
+ } else if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", userVO.getId())) > 0) {
|
|
//是否为审批人
|
|
//是否为审批人
|
|
map.put("update", 0);
|
|
map.put("update", 0);
|
|
map.put("download", 1);
|
|
map.put("download", 1);
|
|
@@ -254,7 +258,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
Integer download = 0;
|
|
Integer download = 0;
|
|
Integer view = 0;
|
|
Integer view = 0;
|
|
Integer approve = 0;
|
|
Integer approve = 0;
|
|
- List<Power> powers = powerMapper.selectList(new QueryWrapper<Power>().eq("project_id", mould.getProjectId()).eq("user_id", currentUser.getId()));
|
|
|
|
|
|
+ List<Power> powers = powerMapper.selectList(new QueryWrapper<Power>().eq("project_id", mould.getProjectId()).eq("user_id", userVO.getId()));
|
|
if (powers.size() > 0) {
|
|
if (powers.size() > 0) {
|
|
for (Power power : powers) {
|
|
for (Power power : powers) {
|
|
if (power.getPowerType() == 0) {
|
|
if (power.getPowerType() == 0) {
|