浏览代码

修改项目添加和修改

5 年之前
父节点
当前提交
9765c7d5ad

+ 20 - 5
cloud-model/src/main/java/com/hssx/cloudmodel/controller/ProjectController.java

@@ -31,9 +31,10 @@ public class ProjectController{
 
     /**
      * 添加/修改项目
-     * 参数:projectName 项目名 ,customerCompany 客户方公司id customerCompanyName 客户方公司名称
-     * managerId 项目经理id
+     * 参数:projectName 项目名 ,customerCompanyIds 客户方公司ids "1,2,3",customerCompanyNames 客户方公司名字“1,2,3”
+     * managerId 项目经理id 非必传
      * 修改时/添加时分配项目: id 项目id ,userIds 参与项目的用户id 如:“1,2,3”(多个或者一个)()
+     * managerId 项目经理id 非必传
      * flag 0-添加,1-修改
      *
      * @return
@@ -41,13 +42,27 @@ public class ProjectController{
     @ApiOperation("添加/修改项目")
     @RequestMapping("/add")
     @ResponseBody
-    public HttpRespMsg addAndUpdateProject(Project project, HttpServletRequest request, Integer flag,
-                                           HttpServletResponse response, String token,@RequestParam(required = false) String userIds) {
+    public HttpRespMsg addAndUpdateProject(Project project, HttpServletRequest request, Integer flag,String customerCompanyIds,
+                                           String customerCompanyNames, String token,@RequestParam(required = false) String userIds) {
         HttpRespMsg msg = new HttpRespMsg();
         QueryWrapper<User> qw = new QueryWrapper<>();
         qw.eq("head_imgurl",token);
         User user = userService.getOne(qw);
-        msg = projectService.addAndUpdateProject(project, flag, user,userIds);
+        msg = projectService.addAndUpdateProject(project, flag, user,userIds,customerCompanyIds,customerCompanyNames);
+        return msg;
+    }
+
+    /**
+     * 根据公司id获取公司下的人员
+     * 参数:companyIds 公司ids
+     *
+     * @return
+     */
+    @ApiOperation("根据公司id获取公司下的人员")
+    @RequestMapping("/getUserListByCompanyIds")
+    @ResponseBody
+    public HttpRespMsg getUserListByCompanyIds(String companyIds){
+        HttpRespMsg msg = projectService.getUserListByCompanyIds(companyIds);
         return msg;
     }
 

+ 3 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/ProjectService.java

@@ -17,7 +17,7 @@ import com.hssx.cloudmodel.util.PageUtil;
  */
 public interface ProjectService extends IService<Project> {
 
-    HttpRespMsg addAndUpdateProject(Project project, Integer flag, User user,String userIds);
+    HttpRespMsg addAndUpdateProject(Project project, Integer flag, User user,String userIds,String customerCompanyIds,String customerCompanyNames);
 
     HttpRespMsg handOutProject(Project project, String userIds);
 
@@ -26,4 +26,6 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getUserByCompanyIdOrSubordinateType(User user);
 
     HttpRespMsg getProjectDetail(Project project);
+
+    HttpRespMsg getUserListByCompanyIds(String companyIds);
 }

+ 30 - 13
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/ProjectServiceImpl.java

@@ -3,15 +3,9 @@ package com.hssx.cloudmodel.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.hssx.cloudmodel.entity.Company;
-import com.hssx.cloudmodel.entity.Project;
-import com.hssx.cloudmodel.entity.ProjectUser;
-import com.hssx.cloudmodel.entity.User;
+import com.hssx.cloudmodel.entity.*;
 import com.hssx.cloudmodel.entity.vo.ProjectVO;
-import com.hssx.cloudmodel.mapper.CompanyMapper;
-import com.hssx.cloudmodel.mapper.ProjectMapper;
-import com.hssx.cloudmodel.mapper.ProjectUserMapper;
-import com.hssx.cloudmodel.mapper.UserMapper;
+import com.hssx.cloudmodel.mapper.*;
 import com.hssx.cloudmodel.service.ProjectService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.cloudmodel.util.HttpRespMsg;
@@ -24,6 +18,7 @@ import javax.jws.soap.SOAPBinding;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Spliterator;
 
 /**
  * <p>
@@ -44,9 +39,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     UserMapper userMapper;
     @Autowired
     CompanyMapper companyMapper;
+    @Autowired
+    CustomCompanyMapper customCompanyMapper;
 
     @Override
-    public HttpRespMsg addAndUpdateProject(Project project, Integer flag, User user,String userIds) {
+    public HttpRespMsg addAndUpdateProject(Project project, Integer flag, User user,String userIds,String customerCompanyIds,String customerCompanyNames) {
         HttpRespMsg msg = new HttpRespMsg();
         if(user != null){
             QueryWrapper<Project> qw = new QueryWrapper<>();
@@ -70,11 +67,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     project.setOwnerCompany(user.getCompanyId());
                     project.setOwnerCompanyName(company.getCompanyName());
                     project.setProjectNo("YMXM"+seq);
-                    project.setCreatorId(user.getId());
-                    project.setCreator(user.getUsername());
                     projectMapper.insert(project);
-                    //分配人员
-                    this.handOutProject(project, userIds);
+                    //添加生产方关联公司
+                    if(customerCompanyIds != null && !"".equals(customerCompanyIds) && customerCompanyNames != null && !"".equals(customerCompanyNames)){
+                        List<Integer> ides = ListUtil.convertIntegerIdsArrayToList(customerCompanyIds);
+                        String[] split = customerCompanyNames.split(",");
+                        int index = 0;
+                        for(String cusCompany:split){
+                            CustomCompany customCompany = new CustomCompany();
+                            customCompany.setCompanyId(ides.get(index));
+                            customCompany.setCompanyName(cusCompany);
+                            customCompany.setProjectId(project.getId());
+                            customCompanyMapper.insert(customCompany);
+                            index++;
+                        }
+                    }
                 }
             }else if(flag == 1){
                 projectMapper.updateById(project);
@@ -166,4 +173,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         msg.data = vo;
         return msg;
     }
+
+    @Override
+    public HttpRespMsg getUserListByCompanyIds(String companyIds) {
+        HttpRespMsg msg = new HttpRespMsg();
+        if(!"".equals(companyIds) && companyIds != null){
+            List<Integer> ids = ListUtil.convertIntegerIdsArrayToList("companyIds");
+            msg.data = userMapper.selectList(new QueryWrapper<User>().in("company_id",ids));
+        }
+        return msg;
+    }
 }

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("tb_user_company");
+        strategy.setInclude("tb_custom_company");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/util/ListUtil.java

@@ -27,6 +27,7 @@ public class ListUtil {
 		}
 		return ids;
 	}
+
 	/**
 	 * Long
 	 * @param idStr  1,2,3,4,5字符串
@@ -42,6 +43,21 @@ public class ListUtil {
 		}
 		return ids;
 	}
+	/**
+	 * Long
+	 * @param idStr  1,2,3,4,5字符串
+	 * @return
+	 */
+	public static List<Integer> convertIntegerIdsArrayToList(String idStr) {
+		String[] array = idStr.split(",");
+		List<Integer> ids = new ArrayList<Integer>();
+		for (String a : array) {
+			if (a != null && a.length() > 0) {
+				ids.add(Integer.valueOf(a));
+			}
+		}
+		return ids;
+	}
 
 	public static List<Integer> extractIdFromList(List object, String key) {
 		List<Integer> list = new ArrayList<Integer>();