Przeglądaj źródła

项目计划 提醒认为项目组成员

user5 4 lat temu
rodzic
commit
1aca47df15

+ 7 - 0
src/main/java/com/jeeplus/modules/sys/dao/OfficeDao.java

@@ -80,4 +80,11 @@ public interface OfficeDao extends TreeDao<Office> {
 
     //根据id获取微信id
 	public Integer findWechatId(String officeId);
+
+	/**
+	 * 根据信息查询项目组内成员父节点信息
+	 * @param office
+	 * @return
+	 */
+	List<Office> findByParentIdsByProjectId(Office office);
 }

+ 9 - 0
src/main/java/com/jeeplus/modules/sys/entity/Office.java

@@ -51,6 +51,7 @@ public class Office extends TreeEntity<Office> {
 	private String topCompany;//上级分公司
     private String branchNo; //分公司编号
 	private String isSon;
+	private String projectId;   //项目id
 	//企业微信端
 	private String wxOfficeId;//微信部门id
 
@@ -357,4 +358,12 @@ public class Office extends TreeEntity<Office> {
 	public void setIsSon(String isSon) {
 		this.isSon = isSon;
 	}
+
+	public String getProjectId() {
+		return projectId;
+	}
+
+	public void setProjectId(String projectId) {
+		this.projectId = projectId;
+	}
 }

+ 10 - 0
src/main/java/com/jeeplus/modules/sys/service/OfficeService.java

@@ -127,6 +127,16 @@ public class OfficeService extends TreeService<OfficeDao, Office> {
 		List<Office> offices = dao.findByParentIdsLike(office);
 		return offices;
 	}
+
+	@Transactional(readOnly = true)
+	public List<Office> findByParentIdsByProjectId(Office office){
+		office.setId(office.getParentIds());
+		office.setParentIds(office.getParentIds()+"%");
+		Office company = UserUtils.getSelectCompany();
+		office.setIsSon(company.getIsSon());
+		List<Office> offices = dao.findByParentIdsByProjectId(office);
+		return offices;
+	}
 	@Transactional(readOnly = true)
 	public List<Office> findByParentId(Office office){
 		office.setId(office.getParent().getId());

+ 43 - 0
src/main/java/com/jeeplus/modules/sys/web/OfficeController.java

@@ -505,6 +505,49 @@ public class OfficeController extends BaseController {
         }
         return mapList;
     }
+
+    /**
+     * 获取机构JSON数据。
+     *
+     * @param extId    排除的ID
+     * @param type     类型(1:公司;2:部门/小组/其它:3:用户)
+     * @param grade    显示级别
+     * @param projectId    项目id
+     * @param response
+     * @return
+     */
+    @RequiresPermissions("user")
+    @ResponseBody
+    @RequestMapping(value = "treeDataByPlan")
+    public List<Map<String, Object>> treeDataByPlan(@RequestParam(required = false) String extId, @RequestParam(required = false) String type,
+                                                 @RequestParam(required = false) Long grade, @RequestParam(required = false) Boolean isAll, String projectId, HttpServletResponse response) {
+        List<Map<String, Object>> mapList = Lists.newArrayList();
+        Office office = new Office();
+        office.setParentIds(UserUtils.getSelectCompany().getId());
+        office.setProjectId(projectId);
+        List<Office> list = officeService.findByParentIdsByProjectId(office);
+        for (int i = 0; i < list.size(); i++) {
+            Office e = list.get(i);
+            if ((StringUtils.isBlank(extId) || (extId != null && !extId.equals(e.getId()) && e.getParentIds().indexOf("," + extId + ",") == -1))
+                    && (type == null || (type != null && (type.equals("1") ? type.equals(e.getType()) : true)))
+                    && (grade == null || (grade != null && Integer.parseInt(e.getGrade()) <= grade.intValue()))
+                    && Global.YES.equals(e.getUseable())) {
+                Map<String, Object> map = Maps.newHashMap();
+                map.put("id", e.getId());
+                map.put("projectId", projectId);
+                map.put("pId", e.getParentId());
+                map.put("pIds", e.getParentIds());
+                map.put("name", e.getTopCompany());
+                if (type != null && "3".equals(type)) {
+                    map.put("isParent", true);
+                }
+                mapList.add(map);
+            }
+        }
+        return mapList;
+    }
+
+
     /**
      * 获取机构JSON数据。
      *

+ 39 - 15
src/main/java/com/jeeplus/modules/sys/web/UserController.java

@@ -16,6 +16,7 @@ import com.jeeplus.common.utils.*;
 import com.jeeplus.common.utils.excel.ExportExcel;
 import com.jeeplus.common.utils.excel.ImportExcel;
 import com.jeeplus.common.web.BaseController;
+import com.jeeplus.modules.projectrecord.dao.WorkProjectUserDao;
 import com.jeeplus.modules.sys.dao.UserDao;
 import com.jeeplus.modules.sys.entity.Office;
 import com.jeeplus.modules.sys.entity.Role;
@@ -39,6 +40,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.apache.shiro.subject.PrincipalCollection;
 import org.apache.shiro.subject.SimplePrincipalCollection;
 import org.apache.shiro.subject.Subject;
+import org.jcodings.util.Hash;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -58,10 +60,7 @@ import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 用户Controller
@@ -87,6 +86,8 @@ public class UserController extends BaseController {
     private SysImportInfoService sysImportInfoService;
     @Autowired
     private WorkStaffBasicInfoService workStaffBasicInfoService;
+    @Autowired
+    private WorkProjectUserDao workProjectUserDao;
 
     @ModelAttribute
     public User get(@RequestParam(required=false) String id) {
@@ -914,18 +915,41 @@ public class UserController extends BaseController {
     @RequiresPermissions("user")
     @ResponseBody
     @RequestMapping(value = "treeData")
-    public List<Map<String, Object>> treeData(@RequestParam(required=false) String officeId, HttpServletResponse response) {
+    public List<Map<String, Object>> treeData(@RequestParam(required=false) String projectId,@RequestParam(required=false) String officeId, HttpServletResponse response) {
         List<Map<String, Object>> mapList = Lists.newArrayList();
-        List<User> list = systemService.findUserByOfficeId(officeId);
-        for (int i=0; i<list.size(); i++){
-            User e = list.get(i);
-            Map<String, Object> map = Maps.newHashMap();
-            map.put("id", "u_"+e.getId());
-            map.put("pId", officeId);
-            String name = StringUtils.replace(e.getName(), " ", "");
-            name = StringEscapeUtils.unescapeHtml4(name);
-            map.put("name", name);
-            mapList.add(map);
+        if(StringUtils.isBlank(projectId)){
+            List<User> list = systemService.findUserByOfficeId(officeId);
+            for (int i=0; i<list.size(); i++){
+                User e = list.get(i);
+                Map<String, Object> map = Maps.newHashMap();
+                map.put("id", "u_"+e.getId());
+                map.put("pId", officeId);
+                String name = StringUtils.replace(e.getName(), " ", "");
+                name = StringEscapeUtils.unescapeHtml4(name);
+                map.put("name", name);
+                mapList.add(map);
+            }
+        }else{
+            List<User> list = systemService.findUserByOfficeId(officeId);
+            //查询项目组成员信息
+            List<User> members = workProjectUserDao.isDelFalg(projectId, "");
+            Set<String> setUser = new HashSet();
+            for (User user: members) {
+                setUser.add(user.getId());
+            }
+            List<String> userIdList = new ArrayList<>(setUser);
+            for (int i=0; i<list.size(); i++){
+                User e = list.get(i);
+                if(userIdList.contains(e.getId())){
+                    Map<String, Object> map = Maps.newHashMap();
+                    map.put("id", "u_"+e.getId());
+                    map.put("pId", officeId);
+                    String name = StringUtils.replace(e.getName(), " ", "");
+                    name = StringEscapeUtils.unescapeHtml4(name);
+                    map.put("name", name);
+                    mapList.add(map);
+                }
+            }
         }
         return mapList;
     }

+ 12 - 0
src/main/resources/mappings/modules/sys/OfficeDao.xml

@@ -359,6 +359,18 @@
 		 OR a.id = #{id})
 		ORDER BY a.code
 	</select>
+	<select id="findByParentIdsByProjectId" resultType="Office">
+		SELECT
+		<include refid="officeColumns"/>
+		FROM sys_office a
+		<include refid="officeJoins"/>
+		WHERE a.del_flag = #{DEL_FLAG_NORMAL} AND a.useable = '1'
+		AND a.id in (#{id},
+		(select u.office_id from work_project_user a, sys_user u where a.user_id = u.id and a.project_id = #{projectId}
+		and a.is_master = 1)
+		)
+		ORDER BY a.code
+	</select>
 
 	<select id="findByParent" resultType="Office">
 		SELECT

+ 1 - 1
src/main/webapp/webpage/modules/projectrecord/plan/projectPlanForm.jsp

@@ -241,7 +241,7 @@
 
                                     <td>
                                         <sys:treeselecttPlanUser id="projectPlanList{{idx}}_remindName" name="remindName" value="${projectRecords.leaderIds}" labelName="projectPlanList[{{idx}}].remindName" labelValue="{{row.remindName}}"
-                                         title="用户" url="/sys/office/treeDataAll?type=3" checked="true" cssClass="form-control required layui-input" allowClear="true" notAllowSelectParent="true"/>
+                                         title="用户" url="/sys/office/treeDataByPlan?type=3&projectId=${projectRecords.id}" checked="true" cssClass="form-control required layui-input" allowClear="true" notAllowSelectParent="true"/>
                                     </td>
 
                                     <td>

+ 1 - 1
src/main/webapp/webpage/modules/sys/tagTreeselect.jsp

@@ -8,7 +8,7 @@
 	<script type="text/javascript">
 		var key, lastValue = "", nodeList = [], type = getQueryString("type", "${url}");
 		var tree, setting = {view:{selectedMulti:false,dblClickExpand:false},check:{enable:"${checked}",nocheckInherit:true},
-				async:{enable:(type==3),url:"${ctx}/sys/user/treeData",autoParam:["id=officeId"]},
+				async:{enable:(type==3),url:"${ctx}/sys/user/treeData",autoParam:["id=officeId","projectId=projectId"]},
 				data:{simpleData:{enable:true}},callback:{<%--
 					beforeClick: function(treeId, treeNode){
 						if("${checked}" == "true"){