|
@@ -3,12 +3,12 @@ package com.hssx.cloudmodel.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.hssx.cloudmodel.entity.Mould;
|
|
|
-import com.hssx.cloudmodel.entity.MouldEquipment;
|
|
|
-import com.hssx.cloudmodel.entity.User;
|
|
|
+import com.hssx.cloudmodel.constant.Constant;
|
|
|
+import com.hssx.cloudmodel.entity.*;
|
|
|
import com.hssx.cloudmodel.entity.vo.MouldEquipmentVO;
|
|
|
import com.hssx.cloudmodel.entity.vo.MouldVO;
|
|
|
-import com.hssx.cloudmodel.mapper.MouldMapper;
|
|
|
+import com.hssx.cloudmodel.entity.vo.ProjectVO;
|
|
|
+import com.hssx.cloudmodel.mapper.*;
|
|
|
import com.hssx.cloudmodel.service.MouldService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.hssx.cloudmodel.util.HttpKit;
|
|
@@ -32,7 +32,7 @@ import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author 吴涛涛
|
|
@@ -43,23 +43,32 @@ import java.util.Map;
|
|
|
public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements MouldService {
|
|
|
@Resource
|
|
|
MouldMapper mouldMapper;
|
|
|
+ @Resource
|
|
|
+ UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ PowerMapper powerMapper;
|
|
|
+ @Resource
|
|
|
+ ProjectMapper projectMapper;
|
|
|
+ @Resource
|
|
|
+ ProjectApproveMapper projectApproveMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg addAndUpdateMould(Mould mould, User user) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
- if(mould.getId() != null){
|
|
|
+ if (mould.getId() != null) {
|
|
|
//修改
|
|
|
Mould m = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
|
|
|
- if((m != null && m.getId()==mould.getId()) || m == null){
|
|
|
+ if ((m != null && m.getId() == mould.getId()) || m == null) {
|
|
|
mouldMapper.updateById(mould);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//查询当前模具编号的模具是否存在
|
|
|
Integer count = mouldMapper.selectCount(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
|
|
|
- if(count>0){
|
|
|
+ if (count > 0) {
|
|
|
msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
mould.setCreatorId(user.getId());
|
|
|
mould.setCompanyId(user.getCompanyId());
|
|
|
mouldMapper.insert(mould);
|
|
@@ -71,16 +80,75 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
@Override
|
|
|
public HttpRespMsg getMoildDetail(MouldVO mouldVO) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
- msg.data = mouldMapper.getDetailById(mouldVO);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ MouldVO mould = mouldMapper.getDetailById(mouldVO);
|
|
|
+ map.put("vo",mould);
|
|
|
+ ProjectVO vo = projectMapper.getProjectById(mould.getProjectId());
|
|
|
+ User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", mouldVO.getToken()));
|
|
|
+ if (null == mould.getProjectId()) {
|
|
|
+ map.put("update", 0);
|
|
|
+ map.put("download", 0);
|
|
|
+ map.put("view", 0);
|
|
|
+ map.put("approve", 0);
|
|
|
+ } else {
|
|
|
+ if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
+ //当前人超级管理员 ,对项目只可以浏览
|
|
|
+ map.put("update", 0);
|
|
|
+ map.put("download", 0);
|
|
|
+ map.put("view", 1);
|
|
|
+ map.put("approve", 0);
|
|
|
+ } else if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
+ //当前为系统管理员
|
|
|
+ map.put("update", 1);
|
|
|
+ map.put("download", 1);
|
|
|
+ map.put("view", 1);
|
|
|
+ } else if (vo.getManagerId() == currentUser.getId()) {
|
|
|
+ //当前人是该项目的项目经理
|
|
|
+ Integer approve = 0;
|
|
|
+ if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0) {
|
|
|
+ //查看当前项目经理是否为审批人
|
|
|
+ approve = 1;
|
|
|
+ }
|
|
|
+ map.put("update", 1);
|
|
|
+ map.put("download", 1);
|
|
|
+ map.put("view", 1);
|
|
|
+ map.put("approve", approve);
|
|
|
+ } else {
|
|
|
+ //该项目的参与人
|
|
|
+ Integer update = 0;
|
|
|
+ Integer download = 0;
|
|
|
+ Integer view = 0;
|
|
|
+ Integer approve = 0;
|
|
|
+ List<Power> powers = powerMapper.selectList(new QueryWrapper<Power>().eq("project_id", mould.getProjectId()).eq("user_id", currentUser.getId()));
|
|
|
+ if (powers.size() > 0) {
|
|
|
+ for (Power power : powers) {
|
|
|
+ if (power.getPowerType() == 0) {
|
|
|
+ update = 1;
|
|
|
+ } else if (power.getPowerType() == 1) {
|
|
|
+ download = 1;
|
|
|
+ } else if (power.getPowerType() == 2) {
|
|
|
+ view = 1;
|
|
|
+ } else {
|
|
|
+ approve = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("update", update);
|
|
|
+ map.put("download", download);
|
|
|
+ map.put("view", view);
|
|
|
+ map.put("approve", approve);
|
|
|
+ }
|
|
|
+ }
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
//告警模板推送通用接口
|
|
|
+
|
|
|
/**
|
|
|
* templateId 模板id,touserOpenId 被推送者的openId,appId微信公众号的appId
|
|
|
* firstData 推送标题
|
|
|
*/
|
|
|
- public HttpRespMsg sendEmergencyTemplateMessage(String templateId, String touserOpenId, String appId,String secret, MouldEquipmentVO mouldEquipmentVO)throws Exception{
|
|
|
+ public HttpRespMsg sendEmergencyTemplateMessage(String templateId, String touserOpenId, String appId, String secret, MouldEquipmentVO mouldEquipmentVO) throws Exception {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
+ appId + "&secret=" + secret;
|
|
@@ -131,11 +199,12 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
return msg;
|
|
|
}
|
|
|
//保养
|
|
|
+
|
|
|
/**
|
|
|
* templateId 模板id,touserOpenId 被推送者的openId,appId微信公众号的appId
|
|
|
* firstData 推送标题
|
|
|
*/
|
|
|
- public HttpRespMsg sendMaintainTemplateMessage(String templateId, String touserOpenId, String appId,String secret, MouldEquipmentVO mouldEquipmentVO) throws Exception{
|
|
|
+ public HttpRespMsg sendMaintainTemplateMessage(String templateId, String touserOpenId, String appId, String secret, MouldEquipmentVO mouldEquipmentVO) throws Exception {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
+ appId + "&secret=" + secret;
|