浏览代码

模具添加

5 年之前
父节点
当前提交
955f542d0b

+ 22 - 3
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldController.java

@@ -2,8 +2,11 @@ package com.hssx.cloudmodel.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.hssx.cloudmodel.entity.Company;
 import com.hssx.cloudmodel.entity.Mould;
 import com.hssx.cloudmodel.entity.User;
+import com.hssx.cloudmodel.mapper.CompanyMapper;
+import com.hssx.cloudmodel.service.CompanyService;
 import com.hssx.cloudmodel.service.MouldService;
 import com.hssx.cloudmodel.service.UserService;
 import com.hssx.cloudmodel.util.HttpRespMsg;
@@ -24,12 +27,14 @@ public class MouldController {
     private MouldService mouldService;
     @Autowired
     private UserService userService;
+    @Autowired
+    private CompanyService companyService;
     /**
      * 添加/修改模具设备
-     * 添加参数:equipmentId 设备id, modelNo 模具编号
-     * 修改参数:id 模具id, modelName 模具名称,settingLife 使用年限, initialModulus 初始模次 equipmentId 设备id,
+     * 添加参数:equipmentId 设备id, modelNo 模具编号 ,belongCompanyId 所属公司id,modelName 模具名称
+     * 修改参数:id 模具id, settingLife 使用年限, initialModulus 初始模次 equipmentId 设备id,
      * produceCompanyId 生产方公司id,ocCycle 每模平均周期,rfid rfid码,area 工厂地址,factoryId 工厂id,factoryName 工厂名称
-     * belongCompanyId 所属公司id ,equipmentName 设备名称
+     * equipmentName 设备名称
      * @return
      */
     @ApiOperation("添加/修改模具")
@@ -43,5 +48,19 @@ public class MouldController {
         msg = mouldService.addAndUpdateMould(mould,user);
         return msg;
     }
+    /**
+     * 创建模具获取的(资产方)公司列表
+     * @return
+     */
+    @ApiOperation("创建模具获取的公司列表")
+    @RequestMapping("/getcompanys")
+    @ResponseBody
+    public HttpRespMsg getcompanys() {
+        HttpRespMsg msg = new HttpRespMsg();
+        QueryWrapper<Company> qw = new QueryWrapper<>();
+        qw.eq("company_type",0);
+        msg.data  = companyService.list(qw);
+        return msg;
+    }
 }
 

+ 15 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/controller/ProjectController.java

@@ -33,7 +33,7 @@ public class ProjectController{
      * 参数:projectName 项目名 ,customerCompanyIds 客户方公司ids "1,2,3",customerCompanyNames 客户方公司名字“1,2,3”
      * managerId 项目经理id 非必传
      * 修改时/添加时分配项目: id 项目id ,userIds 参与项目的用户id 如:“1,2,3”(多个或者一个)()
-     * managerId 项目经理id 非必传
+     * managerId 项目经理id 非必传,  modelIds 模具ids 如 :"1,2,3"
      * flag 0-添加,1-修改
      *
      * @return
@@ -51,6 +51,20 @@ public class ProjectController{
         return msg;
     }
 
+    /**
+     * 获取该公司下的模具列表
+     * parentId 当前人parentId
+     * @return
+     */
+    @ApiOperation("获取该公司下的模具列表")
+    @RequestMapping("/add")
+    @ResponseBody
+    public HttpRespMsg addAndUpdateProject(User user) {
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = projectService.getModelListByCompanyId(user);
+        return msg;
+    }
+
     /**
      * 根据公司id获取公司下的人员
      * 参数:companyIds 公司ids ,id当前操作人的id

+ 2 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/ProjectService.java

@@ -28,4 +28,6 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getProjectDetail(Project project);
 
     HttpRespMsg getUserListByCompanyIds(String companyIds,Integer adminId);
+
+    HttpRespMsg getModelListByCompanyId(User user);
 }

+ 36 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/ProjectServiceImpl.java

@@ -42,6 +42,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     CompanyMapper companyMapper;
     @Autowired
     CustomCompanyMapper customCompanyMapper;
+    @Autowired
+    MouldMapper mouldMapper;
 
     @Override
     public HttpRespMsg addAndUpdateProject(Project project, Integer flag, User user,String userIds,
@@ -93,6 +95,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 projectUserMapper.delete(qwPro);
                 //再次重新分配
                 this.handOutProject(project, userIds);
+                //模具的分配
+                if(modelIds != null && !"".equals(modelIds)){
+                    List<Integer> modelList = ListUtil.convertIntegerIdsArrayToList(modelIds);
+                    int index = 1;
+                    if(modelList.size()>0){
+                        for (Integer id : modelList) {
+                            Mould mould = new Mould();
+                            mould.setId(id);
+                            mould.setProjectId(project.getId());
+                            mould.setBelongProjectGrade(index/modelList.size()+"");
+                            mouldMapper.updateById(mould);
+                        }
+                    }
+                }
             }
         }else{
             msg.setError("当前角色涉及权限问题,请重新登录");
@@ -185,4 +201,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         }
         return msg;
     }
+
+    @Override
+    public HttpRespMsg getModelListByCompanyId(User user) {
+        HttpRespMsg msg = new HttpRespMsg();
+        QueryWrapper<Mould> qw = new QueryWrapper<>();
+        if(Constant.SYS_ID == user.getParentId()){
+            //此时是admin
+            User admin = userMapper.selectOne(new QueryWrapper<User>().eq("id", user.getId()));
+            qw.eq("company_id",admin.getCompanyId());
+        }else if(Constant.SYS_PARENT_ID == user.getParentId()){
+            //系统管理员
+//            qw.eq("company_type",Constant.ASSETS_COMPANY);
+        }else{
+            //此时是项目经理
+            User admin = userMapper.selectOne(new QueryWrapper<User>().eq("id", user.getParentId()));
+            qw.eq("company_id",admin.getCompanyId());
+        }
+        msg.data =  mouldMapper.selectList(qw);
+        return msg;
+    }
 }