Browse Source

用户创建的修改

5 years ago
parent
commit
ac4e74aa56

+ 3 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/MouldVO.java

@@ -23,4 +23,7 @@ public class MouldVO extends Mould {
     private String hillNumber;
     private String ownerCompanyName;
     private String companyName;
+    private String produceCompany;
+    private String token;
+    private Integer managerId;
 }

+ 83 - 14
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldServiceImpl.java

@@ -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;

+ 22 - 8
cloud-model/src/main/resources/mapper/MouldMapper.xml

@@ -57,8 +57,10 @@
         <result column="equipment_id" property="equipmentId"/>
         <result column="belong_project_grade" property="belongProjectGrade"/>
         <result column="produce_company_id" property="produceCompanyId"/>
+        <result column="produceCompany" property="produceCompany"/>
         <result column="run_times" property="runTimes" />
         <result column="projectName" property="projectName"/>
+        <result column="managerId" property="managerId" />
         <result column="mangerName" property="mangerName"/>
         <result column="equipmentNo" property="equipmentNo"/>
         <result column="endTime" property="endTime"/>
@@ -73,9 +75,9 @@
 
     <select id="selectListByCondition" resultMap="BaseResultMapVO">
         select
-        tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,
-        tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,
-        tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,
+        tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbm.creator_id creator_id,
+        tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,
+        tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,
         tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times
         from
         tb_mould tbm
@@ -90,6 +92,10 @@
         tb_company tbc
         on
         tbc.id = tbm.company_id
+        left join
+        tb_company tbco
+        on
+        tbco.id = tbm.produce_company_id
         <where>
             <if test="userVO.parentId != 0">
                 tbm.company_id = #{userVO.companyId}
@@ -107,9 +113,9 @@
     </select>
     <select id="selectListByConditionByProject" resultMap="BaseResultMapVO">
         select
-        tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,
-        tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,
-        tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,
+        tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbp.manager_id managerId,
+        tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,
+        tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,
         tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times
         from
         tb_mould tbm
@@ -125,6 +131,10 @@
         tb_company tbc
         on
         tbc.id = tbm.company_id
+        left join
+        tb_company tbco
+        on
+        tbco.id = tbm.produce_company_id
         <where>
             <if test="userVO.searchType == 0 and userVO.keyName != '' and userVO.keyName != null">
                 AND tbm.model_no like concat('%',#{userVO.keyName},'%')
@@ -142,8 +152,8 @@
 
     <select id="getDetailById" resultMap="BaseResultMapVO">
     select
-        tbm.id id,tbm.model_no model_no, tbm.model_name,tbm.initial_modulus initial_modulus,
-        tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,
+        tbm.id id,tbm.model_no model_no, tbm.model_name,tbm.initial_modulus initial_modulus,tbp.manager_id managerId,
+        tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbco.company_name produceCompany,tbm.creator_id creator_id,
         tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbm.rfid rfid,tbm.oc_cycle oc_cycle,
         tbmp.equipment_no equipmentNo,tbmp.hill_number hillNumber,tbm.setting_life setting_life,tbm.run_times run_times
         from
@@ -155,6 +165,10 @@
         left join
         tb_project  tbp
         on tbp.id = tbm.project_id
+        left join
+        tb_company tbco
+        on
+        tbco.id = tbm.produce_company_id
         where
         tbm.id = #{mouldVO.id}
     </select>