diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/CompanyController.java b/src/main/java/com/dreamchaser/depository_manage/controller/CompanyController.java index fed060c5..092b2834 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/CompanyController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/CompanyController.java @@ -7,10 +7,7 @@ import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.exception.MyException; import com.dreamchaser.depository_manage.pojo.*; import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool; -import com.dreamchaser.depository_manage.service.CompanyService; -import com.dreamchaser.depository_manage.service.ConstructionUnitService; -import com.dreamchaser.depository_manage.service.DepositoryService; -import com.dreamchaser.depository_manage.service.RoleService; +import com.dreamchaser.depository_manage.service.*; import com.dreamchaser.depository_manage.utils.*; import org.apache.http.protocol.HTTP; import org.springframework.beans.factory.annotation.Autowired; @@ -28,16 +25,22 @@ import java.util.Map; public class CompanyController { @Autowired - CompanyService companyService; + private CompanyService companyService; @Autowired - RoleService roleService; + private RoleService roleService; @Autowired - DepositoryService depositoryService; + private DepositoryService depositoryService; @Autowired - ConstructionUnitService constructionUnitService; + private ConstructionUnitService constructionUnitService; + + @Autowired + private PostService postService; + + @Autowired + private UserService userService; @@ -86,8 +89,8 @@ public class CompanyController { } Integer total = ObjectFormatUtil.toInteger(data.get("total")); List administrationPList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - Administration administration = JSONObject.toJavaObject((JSONObject) list.get(i), Administration.class); + for (Object o : list) { + Administration administration = JSONObject.toJavaObject((JSONObject) o, Administration.class); AdministrationP administrationP = new AdministrationP(administration); administrationPList.add(administrationP); } @@ -109,7 +112,7 @@ public class CompanyController { userKey = (String) request.getSession().getAttribute("userKey"); } Map administration = PublicConfig.findAdministration(userKey,token); - List administrationPList = (List) administration.get("administrationPList"); + List administrationPList = ObjectFormatUtil.objToList(administration.get("administrationPList"),AdministrationP.class); return new RestResponse(administrationPList); } @@ -387,7 +390,7 @@ public class CompanyController { Long postId = ObjectFormatUtil.toLong(map.get("postId")); userParam.put("position", postId); List userByPortList = PublicConfig.FindUserByMap(userParam, userKey,token); - Post postById = PublicConfig.findPostById(postId, userKey,token); + Post postById = postService.findPostById(postId); List roleAndDepositoryByCondition = new ArrayList<>(); if (userByPortList.size() != 0) { Map param = new HashMap<>(); diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java index e12d56e1..e718d21e 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -59,6 +59,9 @@ public class DepositoryRecordController { @Autowired private MaterialTypeService materialTypeService; + @Autowired + private UserService userService; + @GetMapping("/myApply") public RestResponse findDepositoryInAndOutRecordPByCondition(@RequestParam Map map, HttpServletRequest request) { @@ -465,7 +468,7 @@ public class DepositoryRecordController { // 如果是个人 // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(uid, finalUserKey, finalToken); + UserByPort userByPort = userService.findUserByIdForNoPack(uid); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -482,7 +485,7 @@ public class DepositoryRecordController { // 定义用于获取当前岗位下的人的参数map Map paramForGetUserByPost = new HashMap<>(); paramForGetUserByPost.put("position", uid); - List userByPortList = PublicConfig.FindUserByMap(paramForGetUserByPost, null, null); + List userByPortList = userService.findUserByConditionForNoPack(paramForGetUserByPost); for (UserByPort userByPort : userByPortList) { int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -526,7 +529,7 @@ public class DepositoryRecordController { // 如果是个人 // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(uid, finalUserKey, finalToken); + UserByPort userByPort = userService.findUserByIdForNoPack(uid); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -543,7 +546,7 @@ public class DepositoryRecordController { // 定义用于获取当前岗位下的人的参数map Map paramForGetUserByPost = new HashMap<>(); paramForGetUserByPost.put("position", uid); - List userByPortList = PublicConfig.FindUserByMap(paramForGetUserByPost, finalUserKey, finalToken); + List userByPortList = userService.findUserByConditionForNoPack(paramForGetUserByPost); for (UserByPort userByPort : userByPortList) { int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -598,14 +601,14 @@ public class DepositoryRecordController { map.put("applicantId", userToken.getId()); map.put("createUid", userToken.getId()); // 获取当前部门负责人 - List departmentHeadByUsers = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(), userkey, usertoken); + List departmentHeadByUsers = userService.getDepartmentHeaderByIdForNoPack(userToken.getMaindeparment()); StringBuilder departmentHeadId = new StringBuilder(); for (UserByPort departmentHeadByUser : departmentHeadByUsers) { departmentHeadId.append(departmentHeadByUser.getId()).append(","); } // departmentHeadId = new StringBuilder("78").append(","); map.put("departmenthead", departmentHeadId.toString()); - List params = (List) map.get("params"); + List params = ObjectFormatUtil.objToList(map.get("params"), Integer.class); Integer integer = 0; if (map.containsKey("flagForAgency")) { @@ -743,7 +746,7 @@ public class DepositoryRecordController { Object userId = map.get("userId"); if (userId != null) { - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(userId), userkey, usertoken); + UserByPort userByPort = userService.findUserByIdForNoPack(ObjectFormatUtil.toLong(userId)); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype <= 10) { @@ -751,7 +754,7 @@ public class DepositoryRecordController { map.put("depositoryManager", userToken.getId()); } } else { - List departmentHeadByUsers = PublicConfig.findDepartmentHeadByUser(ObjectFormatUtil.toLong(map.get("adminorgId")), userkey, usertoken); + List departmentHeadByUsers = userService.getDepartmentHeaderByIdForNoPack(ObjectFormatUtil.toLong(map.get("adminorgId"))); StringBuilder departmentHeadId = new StringBuilder(); for (UserByPort departmentHeadByUser : departmentHeadByUsers) { departmentHeadId.append(departmentHeadByUser.getId()).append(","); @@ -759,7 +762,7 @@ public class DepositoryRecordController { map.put("departmenthead", userToken.getId()); map.put("depositoryManager", departmentHeadId.toString()); } - List params = (List) map.get("params"); + List params = ObjectFormatUtil.objToList(map.get("params"), Integer.class); Integer integer = 0; if (map.containsKey("constructionUnitId")) { String constructionUnitId = map.get("constructionUnitId").toString(); @@ -963,7 +966,7 @@ public class DepositoryRecordController { ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(applicationOutMinById.getParentId()); // 获取申请人 - UserByPort userByPort = PublicConfig.FindUserById(applicationOutRecordPById.getApplicantId(), userKey, token); + UserByPort userByPort = userService.findUserByIdForNoPack(applicationOutRecordPById.getApplicantId()); // 创建展示对象 SimpleApplicationOutMinRecordP simpleApplicationOutMinRecordP = new SimpleApplicationOutMinRecordP(applicationOutMinById); // 设置展示时的数量为申请数-已出库数 @@ -994,7 +997,7 @@ public class DepositoryRecordController { if (checkId != null) { // 如果该订单已经处理 // 获取处理人 - UserByPort checker = PublicConfig.FindUserById(checkId, userKey, token); + UserByPort checker = userService.findUserByIdForNoPack(checkId); simpleApplicationOutMinRecordP.setCheckerName(checker.getName()); simpleApplicationOutMinRecordP.setPcode(placeByDid.getCode()); // 当已经完成出库时设置数量为出库数 @@ -1065,6 +1068,7 @@ public class DepositoryRecordController { list = depositoryRecordService.findApplicationOutRecordPByUser(userByPort, map, userKey, token); countBy = depositoryRecordService.findApplicationOutRecordPCountByUser(userByPort, map); } + Map userByPortMap = new HashMap<>(); for (ApplicationOutRecordP outRecordP : list) { // 根据主订单获取所有子订单 List applicationOutMinByParentId = depositoryRecordService.findApplicationOutMinByParentId(outRecordP.getId()); @@ -1139,7 +1143,14 @@ public class DepositoryRecordController { if ("".equals(value)) { continue; } - UserByPort departmenthead = PublicConfig.FindUserById(ObjectFormatUtil.toLong(value), userKey, token); + UserByPort departmenthead = null; + Long departmentheadId = ObjectFormatUtil.toLong(value); + if (userByPortMap.containsKey(departmentheadId)) { + departmenthead = userByPortMap.get(departmentheadId); + } else { + departmenthead = userService.findUserById(departmentheadId); + userByPortMap.put(departmentheadId, departmenthead); + } // 获取用户的用工关系 int emptype = departmenthead.getEmptype(); if (emptype > 10) { @@ -1296,7 +1307,7 @@ public class DepositoryRecordController { String header = request.getHeader("user-agent"); String crypt = Md5.crypt(header); UserByPort userToken = AuthenticationTokenPool.getUserToken(usertoken); - List departmentHeadByUsers = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(), userkey, usertoken); + List departmentHeadByUsers = userService.getDepartmentHeaderByIdForNoPack(userToken.getMaindeparment()); StringBuilder departmentHeadId = new StringBuilder(); for (UserByPort departmentHeadByUser : departmentHeadByUsers) { departmentHeadId.append(departmentHeadByUser.getId()).append(","); @@ -1492,7 +1503,7 @@ public class DepositoryRecordController { String[] managersSplit = managers.toString().split(","); for (String manager : managersSplit) { if (!"".equals(manager)) { - UserByPort userByPort = PublicConfig.FindUserById(Long.parseLong(manager), userKey, token); + UserByPort userByPort = userService.findUserById(Long.parseLong(manager)); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -1507,7 +1518,7 @@ public class DepositoryRecordController { } else { // 如果已完成出库 - UserByPort userByPort = PublicConfig.FindUserById(checkId, userKey, token); + UserByPort userByPort = userService.findUserById(checkId); if (!managerList.contains(userByPort)) { managerList.add(userByPort); } @@ -1538,7 +1549,7 @@ public class DepositoryRecordController { String[] split = balancePoster.split(","); for (String s : split) { if (!"".equals(s)) { - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(s), userKey, token); + UserByPort userByPort = userService.findUserById(ObjectFormatUtil.toLong(s)); String name = userByPort.getMaindeparmentname() + "-" + userByPort.getName(); balancePosterIconPhoto.put(name, userByPort.getIconphoto()); balancePosterName.append(name).append(","); @@ -1567,7 +1578,7 @@ public class DepositoryRecordController { continue; } Long managerid = ObjectFormatUtil.toLong(s); - UserByPort user = PublicConfig.FindUserById(managerid, userKey, token); + UserByPort user = userService.findUserById(managerid); String name = user.getMaindeparmentname() + "-" + user.getName(); depositoryManagerIconPhoto.put(name, user.getIconphoto()); depositoryManagerNames.append(name); @@ -1767,7 +1778,7 @@ public class DepositoryRecordController { // 如果是针对人 // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(uid, finalUserkey, finalUsertoken); + UserByPort userByPort = userService.findUserByIdForNoPack(uid); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -1785,7 +1796,7 @@ public class DepositoryRecordController { // 定义用于获取当前岗位下的人的参数map Map paramForGetUserByPost = new HashMap<>(); paramForGetUserByPost.put("position", uid); - List userByPortList = PublicConfig.FindUserByMap(paramForGetUserByPost, finalUserkey, finalUsertoken); + List userByPortList = userService.findUserByConditionForNoPack(paramForGetUserByPost); for (UserByPort userByPort : userByPortList) { int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -1832,7 +1843,7 @@ public class DepositoryRecordController { // 如果是对人 // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(uid, finalUserkey, finalUsertoken); + UserByPort userByPort = userService.findUserByIdForNoPack(uid); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -1849,7 +1860,7 @@ public class DepositoryRecordController { // 定义用于获取当前岗位下的人的参数map Map paramForGetUserByPost = new HashMap<>(); paramForGetUserByPost.put("position", uid); - List userByPortList = PublicConfig.FindUserByMap(paramForGetUserByPost, finalUserkey, finalUsertoken); + List userByPortList = userService.findUserByConditionForNoPack(paramForGetUserByPost); for (UserByPort userByPort : userByPortList) { int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -1878,7 +1889,7 @@ public class DepositoryRecordController { } else if ("out".equals(type)) { // 获取部门负责人 - List departmentHeadByUsers = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(), userkey, usertoken); + List departmentHeadByUsers = userService.getDepartmentHeaderByIdForNoPack(userToken.getMaindeparment()); StringBuilder departmentHeadId = new StringBuilder(); for (UserByPort departmentHeadByUser : departmentHeadByUsers) { departmentHeadId.append(departmentHeadByUser.getId()).append(","); @@ -2069,7 +2080,7 @@ public class DepositoryRecordController { Long uid = mt.getUid(); if (classes == 1) { // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(uid, finalUserkey, finalUsertoken); + UserByPort userByPort = userService.findUserByIdForNoPack(uid); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -2084,7 +2095,7 @@ public class DepositoryRecordController { // 定义用于获取当前岗位下的人的参数map Map paramForGetUserByPost = new HashMap<>(); paramForGetUserByPost.put("position", uid); - List userByPortList = PublicConfig.FindUserByMap(paramForGetUserByPost, finalUserkey, finalUsertoken); + List userByPortList = userService.findUserByConditionForNoPack(paramForGetUserByPost); for (UserByPort userByPort : userByPortList) { int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -2128,7 +2139,7 @@ public class DepositoryRecordController { Long uid = mt.getUserId(); if (classes == 1) { // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(uid, finalUserkey, finalUsertoken); + UserByPort userByPort = userService.findUserByIdForNoPack(uid); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -2143,7 +2154,7 @@ public class DepositoryRecordController { // 定义用于获取当前岗位下的人的参数map Map paramForGetUserByPost = new HashMap<>(); paramForGetUserByPost.put("position", uid); - List userByPortList = PublicConfig.FindUserByMap(paramForGetUserByPost, finalUserkey, finalUsertoken); + List userByPortList = userService.findUserByConditionForNoPack(paramForGetUserByPost); for (UserByPort userByPort : userByPortList) { int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -2179,7 +2190,7 @@ public class DepositoryRecordController { } // 获取部门负责人 - List departmentHeadByUsers = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(), userkey, usertoken); + List departmentHeadByUsers = userService.getDepartmentHeaderByIdForNoPack(userToken.getMaindeparment()); StringBuilder departmentHeadId = new StringBuilder(); for (UserByPort departmentHeadByUser : departmentHeadByUsers) { departmentHeadId.append(departmentHeadByUser.getId()).append(","); diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java index c2a72909..7961896d 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java @@ -72,6 +72,15 @@ public class PageController { @Autowired private BusinessTypeService businessTypeService; + @Autowired + private UserService userService; + + @Autowired + private AdministrativeService administrativeService; + + @Autowired + private PostService postService; + /** * 初始化路由跳转 * @@ -321,7 +330,7 @@ public class PageController { ModelAndView mv = new ModelAndView(); mv.setViewName("pages/warehouse/depository_add"); Map administration = PublicConfig.findAdministration(userKey, token); - List administrationPList = ObjectFormatUtil.objToList(administration.get("administrationPList"),AdministrationP.class); + List administrationPList = ObjectFormatUtil.objToList(administration.get("administrationPList"), AdministrationP.class); mv.addObject("administrationPList", administrationPList); return mv; } @@ -1084,10 +1093,13 @@ public class PageController { token = (String) request.getSession().getAttribute("userToken"); userKey = (String) request.getSession().getAttribute("userKey"); } - UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/user/table-user"); - List administrationPList = PublicConfig.findAllCompany(userKey, token); + Map map = new HashMap<>(); + map.put("superior", "313"); + map.put("level", 3); + List administrationPList = administrativeService.findAdministrationPListByCondition(map); +// List administrationPList = PublicConfig.findAllCompany(userKey, token); mv.addObject("administrationPList", administrationPList); return mv; } @@ -1586,7 +1598,7 @@ public class PageController { UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/user/user-add"); - UserByPort userByPort = PublicConfig.FindUserById(userId, userKey, token); + UserByPort userByPort = userService.findUserByIdForNoPack(userId); UserByPortP userByPortP = new UserByPortP(userByPort); mv.addObject("userByPort", userByPortP); mv.addObject("classes", classes); @@ -1612,7 +1624,7 @@ public class PageController { UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/user/user-addForIn"); - UserByPort userByPort = PublicConfig.FindUserById(userId, userKey, token); + UserByPort userByPort = userService.findUserByIdForNoPack(userId); UserByPortP userByPortP = new UserByPortP(userByPort); mv.addObject("userByPort", userByPortP); mv.addObject("classes", classes); @@ -1641,7 +1653,7 @@ public class PageController { RoleAndDepository roleAndDepositoryById = roleService.findRoleAndDepositoryById(id); UserByPortP userByPortP = null; if (roleAndDepositoryById != null) { - UserByPort userByPort = PublicConfig.FindUserById(roleAndDepositoryById.getUserId(), userKey, token); + UserByPort userByPort = userService.findUserByIdForNoPack(roleAndDepositoryById.getUserId()); userByPortP = new UserByPortP(userByPort); userByPortP.setDepositoryName(roleAndDepositoryById.getDepositoryName()); } @@ -1672,7 +1684,7 @@ public class PageController { RoleAndMaterialType roleAndMaterialTypeById = roleService.findRoleAndMaterialTypeById(id); UserByPortP userByPortP = null; if (roleAndMaterialTypeById != null) { - UserByPort userByPort = PublicConfig.FindUserById(roleAndMaterialTypeById.getUid(), userKey, token); + UserByPort userByPort = userService.findUserByIdForNoPack(roleAndMaterialTypeById.getUid()); userByPortP = new UserByPortP(userByPort); userByPortP.setMaterialTypeName(roleAndMaterialTypeById.getTname()); } @@ -1704,8 +1716,8 @@ public class PageController { mv.setViewName("pages/post/postRole_edit"); Map userParam = new HashMap<>(); userParam.put("position", id); - List userByPortList = PublicConfig.FindUserByMap(userParam, userKey, token); - Post postById = PublicConfig.findPostById(id, userKey, token); + List userByPortList = userService.findUserByConditionForNoPack(userParam); + Post postById = postService.findPostById(id); PostP pp = new PostP(postById); Map param = new HashMap<>(); param.put("depositoryId", depositoryId); @@ -1738,9 +1750,7 @@ public class PageController { ModelAndView mv = new ModelAndView(); mv.setViewName("pages/user/user-edit"); mv.addObject("depositories", depositoryService.findDepositoryAll()); - Map map = new HashMap<>(); - map.put("number", id.toString()); - UserByPort userByPort = PublicConfig.FindUserByMap(map, userKey, token).get(0); + UserByPort userByPort = userService.findUserByNumber(id.toString()); mv.addObject("user", userByPort); return mv; } @@ -1771,7 +1781,10 @@ public class PageController { mv.addObject("record", depositoryRecordById); Long cid = depositoryRecordById.getCid(); List postList = PublicConfig.findCompanyBySuperior(cid.toString(), userKey, token); - List administrationPList = PublicConfig.findAllCompany(userKey, token); + Map map = new HashMap<>(); + map.put("superior", "313"); + map.put("level", 3); + List administrationPList = administrativeService.findAdministrationPListByCondition(map); // 部门列表 mv.addObject("postList", postList); // 公司列表 @@ -2079,7 +2092,6 @@ public class PageController { ApplicationOutRecordP recordP = depositoryRecordService.findApplicationOutRecordPById(id); // 获取当前出库仓库是否为开放仓库 - int flagForOpenDepository = recordP.getFlagForOpenDepository(); mv.addObject("depositoryManagerText", "负责人"); // 获取所有子订单 @@ -2097,6 +2109,7 @@ public class PageController { StringBuilder sumUnit = new StringBuilder(); List depositoryIdList = new ArrayList<>(); List placeIdList = new ArrayList<>(); + Map userByPortMap = new HashMap<>(); for (ApplicationOutRecordMinP applicationOutRecordMin : applicationOutRecordMinByParent) { // 获取子订单信息 // 获取出库物料信息 @@ -2139,7 +2152,7 @@ public class PageController { } } // 申请人 - UserByPort applicantUser = PublicConfig.FindUserById(recordP.getApplicantId(), userKey, token); + UserByPort applicantUser = userService.findUserById(recordP.getApplicantId()); // 部门负责人 // 获取部门负责人人员 @@ -2150,7 +2163,14 @@ public class PageController { String[] split = departmenthead.split(","); for (String s : split) { if (!"".equals(s)) { - UserByPort departmentUser = PublicConfig.FindUserById(ObjectFormatUtil.toLong(s), userKey, token); + Long departmentId = ObjectFormatUtil.toLong(s); + UserByPort departmentUser = null; + if (userByPortMap.containsKey(departmentId)) { + departmentUser = userByPortMap.get(departmentId); + } else { + departmentUser = userService.findUserById(departmentId); + userByPortMap.put(departmentId, departmentUser); + } String name = departmentUser.getMaindeparmentname() + "-" + departmentUser.getName(); departmentHeadIconPhoto.put(name, departmentUser.getIconphoto()); departmentHeadName.append("name").append(","); @@ -2235,13 +2255,21 @@ public class PageController { placeCode = placeById.getCode(); } Integer flagForGroup = applicationInRecordPById.getFlagForGroup(); + Map userByPortMap = new HashMap<>(); if (Integer.compare(applicationInRecordPById.getAirapproverPass(), 4) != 0) { String[] airapproverId = applicationInRecordPById.getAirapproverId().split(","); StringBuilder airapproverName = new StringBuilder(); for (String approverId : airapproverId ) { if (!"".equals(approverId)) { - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(approverId), userKey, token); + UserByPort userByPort = null; + Long applicantId = applicationInRecordPById.getApplicantId(); + if (userByPortMap.containsKey(applicantId)) { + userByPort = userByPortMap.get(applicantId); + } else { + userByPort = userService.findUserById(applicantId); + userByPortMap.put(applicantId, userByPort); + } airapproverName.append(userByPort.getName()).append(","); } } @@ -2250,7 +2278,14 @@ public class PageController { if (Integer.compare(flagForGroup, 2) != 0) { // 如果不是组合 - UserByPort userByPort = PublicConfig.FindUserById(applicationInRecordPById.getApplicantId(), userKey, token); + UserByPort userByPort = null; + Long applicantId = applicationInRecordPById.getApplicantId(); + if (userByPortMap.containsKey(applicantId)) { + userByPort = userByPortMap.get(applicantId); + } else { + userByPort = userService.findUserById(applicantId); + userByPortMap.put(applicantId, userByPort); + } applicationInRecordPById.setApplicantName(userByPort.getMaindeparmentname() + "_" + userByPort.getName()); applicationInRecordPById.setApplicantTime(DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(applicationInRecordPById.getApplicantTime()))); if (applicationInRecordPById.getPrice() != null) { @@ -2294,7 +2329,6 @@ public class PageController { token = (String) request.getSession().getAttribute("userToken"); userKey = (String) request.getSession().getAttribute("userKey"); } - UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/application/form-step-look_in_review"); if (id != null) { @@ -2314,13 +2348,23 @@ public class PageController { placeCode = placeById.getCode(); } Integer flagForGroup = applicationInRecordPById.getFlagForGroup(); + + Map userByPortMap = new HashMap<>(); + if (Integer.compare(applicationInRecordPById.getAirapproverPass(), 4) != 0) { String[] airapproverId = applicationInRecordPById.getAirapproverId().split(","); StringBuilder airapproverName = new StringBuilder(); for (String approverId : airapproverId ) { if (!"".equals(approverId)) { - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(approverId), userKey, token); + UserByPort userByPort = null; + Long applicantId = ObjectFormatUtil.toLong(approverId); + if (userByPortMap.containsKey(applicantId)) { + userByPort = userByPortMap.get(applicantId); + } else { + userByPort = userService.findUserById(applicantId); + userByPortMap.put(applicantId, userByPort); + } airapproverName.append(userByPort.getName()).append(","); } } @@ -2330,7 +2374,14 @@ public class PageController { mv.addObject("placeCode", placeCode); if (Integer.compare(flagForGroup, 2) != 0) { // 如果不是组合 - UserByPort userByPort = PublicConfig.FindUserById(applicationInRecordPById.getApplicantId(), userKey, token); + UserByPort userByPort = null; + Long applicantId = applicationInRecordPById.getApplicantId(); + if (userByPortMap.containsKey(applicantId)) { + userByPort = userByPortMap.get(applicantId); + } else { + userByPort = userService.findUserById(applicantId); + userByPortMap.put(applicantId, userByPort); + } applicationInRecordPById.setApplicantName(userByPort.getMaindeparmentname() + "_" + userByPort.getName()); applicationInRecordPById.setApplicantTime(DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(applicationInRecordPById.getApplicantTime()))); if (applicationInRecordPById.getPrice() != null) { @@ -2388,8 +2439,7 @@ public class PageController { // 获取处理人 Long checkId = recordMinP.getCheckId(); if (checkId != null) { - UserByPort userByPort = PublicConfig.FindUserById(checkId, userKey, token); - + UserByPort userByPort = userService.findUserByIdForNoPack(checkId); // 设置处理人姓名 recordMinP.setCheckerName(userByPort.getName()); // 获取出库库位 @@ -2508,6 +2558,7 @@ public class PageController { double sumPrice = 0.0; // 出库仓库id列表 List depositoryIdList = new ArrayList<>(); + Map userByPortMap = new HashMap<>(); for (ApplicationOutRecordMinP recordMinP : applicationOutRecordMinByParent) { // 获取子订单信息 @@ -2577,7 +2628,13 @@ public class PageController { if (outDisPoserIdList.size() > 0) { for (Long outDispositorId : outDisPoserIdList ) { - UserByPort disposer = PublicConfig.FindUserById(outDispositorId, userKey, token); + UserByPort disposer = null; + if (userByPortMap.containsKey(outDispositorId)) { + disposer = userByPortMap.get(outDispositorId); + } else { + disposer = userService.findUserById(outDispositorId); + userByPortMap.put(outDispositorId,disposer); + } outDisposer.append(disposer.getName()).append(","); } } @@ -2595,8 +2652,13 @@ public class PageController { // 申请人Id Long applicantId = applicationOutRecordPById.getApplicantId(); // 获取申请人信息 - UserByPort userByPort = PublicConfig.FindUserById(applicantId, userKey, token); - + UserByPort userByPort = null; + if (userByPortMap.containsKey(applicantId)) { + userByPort = userByPortMap.get(applicantId); + } else { + userByPort = userService.findUserById(applicantId); + userByPortMap.put(applicantId,userByPort); + } // 部门负责人 String departmentHead = applicationOutRecordPById.getDepartmenthead(); String[] split = departmentHead.split(","); @@ -2611,7 +2673,14 @@ public class PageController { if ("".equals(value)) { continue; } - UserByPort departmenthead = PublicConfig.FindUserById(ObjectFormatUtil.toLong(value), userKey, token); + UserByPort departmenthead = null; + Long departmentheadId = ObjectFormatUtil.toLong(value); + if (userByPortMap.containsKey(departmentheadId)) { + departmenthead = userByPortMap.get(departmentheadId); + } else { + departmenthead = userService.findUserById(departmentheadId); + userByPortMap.put(departmentheadId,userByPort); + } String name = departmenthead.getMaindeparmentname() + "-" + departmenthead.getName(); departmentHeadUserIcon.put(name, departmenthead.getIconphoto()); departmentHeadName.append(name).append(","); @@ -2625,7 +2694,7 @@ public class PageController { Long adminorgId = applicationOutRecordPById.getAdminorgId(); Long constructionUnitId = applicationOutRecordPById.getConstructionUnitId(); if (adminorgId != null) { - Administration company = PublicConfig.getCompany(adminorgId, userKey, token); + Administration company = administrativeService.findAdministrationById(adminorgId); applicationOutRecordPById.setAdminorgName(company.getName()); mv.addObject("adisplay", "table-row"); } else { @@ -2757,7 +2826,7 @@ public class PageController { stp.setCreateTime(DateUtil.TimeStampToDateTime(stockTaking.getCreateTime())); // 获取申请人 - UserByPort userByPort = PublicConfig.FindUserById(stockTaking.getOriginator(), userKey, token); + UserByPort userByPort = userService.findUserByIdForNoPack(stockTaking.getOriginator()); // 设置盘点发起人姓名 stp.setOriginatorName(userByPort.getName()); @@ -2768,7 +2837,7 @@ public class PageController { if ("".equals(s)) { continue; } - UserByPort manager = PublicConfig.findUserByPortByNumber(s); + UserByPort manager = userService.findUserByNumberForNoPack(s); int emptype = manager.getEmptype(); if (emptype > 10) { continue; @@ -2839,7 +2908,7 @@ public class PageController { // 获取申请人 - UserByPort userByPort = PublicConfig.FindUserById(stockTaking.getOriginator(), userKey, token); + UserByPort userByPort = userService.findUserById(stockTaking.getOriginator()); // 设置盘点发起人姓名 stp.setOriginatorName(userByPort.getName()); @@ -2850,7 +2919,7 @@ public class PageController { if ("".equals(s)) { continue; } - UserByPort manager = PublicConfig.findUserByPortByNumber(s); + UserByPort manager = userService.findUserByNumberForNoPack(s); int emptype = manager.getEmptype(); if (emptype > 10) { continue; @@ -2886,7 +2955,7 @@ public class PageController { userKey = (String) request.getSession().getAttribute("userKey"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); - Administration company = PublicConfig.getCompany(userToken.getMaindeparment(), userKey, token); + Administration company = administrativeService.findAdministrationById(userToken.getMaindeparment()); userToken.setMaindeparmentname(company.getName()); mv.addObject("userInfo", userToken); return mv; @@ -2945,7 +3014,10 @@ public class PageController { UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/company/company-out_back"); - List administrationPList = PublicConfig.findAllCompany(userKey, token); + Map map = new HashMap<>(); + map.put("superior", "313"); + map.put("level", 3); + List administrationPList = administrativeService.findAdministrationPListByCondition(map); mv.addObject("administrationPList", administrationPList); mv.addObject("level", 3); mv.addObject("parentId", "313"); @@ -2982,25 +3054,11 @@ public class PageController { token = (String) request.getSession().getAttribute("userToken"); userKey = (String) request.getSession().getAttribute("userKey"); } - String url = PublicConfig.external_url + "/org/getgovcont"; - Map map = new HashMap<>(); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/company/company_edit"); if (id != null) { - map.put("id", id); - map.put("idstr", id.toString()); - String jsonString = JSONObject.toJSONString(map); - JSONObject paramObject = JSONObject.parseObject(jsonString); - String post = null; - try { - post = HttpUtils.send(url, paramObject, HTTP.UTF_8, userKey, token); - } catch (IOException e) { - e.printStackTrace(); - } - JSONObject jsonObject = JSONObject.parseObject(post); - JSONObject data = (JSONObject) jsonObject.get("data"); - Administration administration = JSONObject.toJavaObject(data, Administration.class); - String SuperiorName = PublicConfig.getCompany(administration.getSuperior(), userKey, token).getName(); + Administration administration = administrativeService.findAdministrationById(id); + String SuperiorName = administrativeService.findAdministrationById(administration.getSuperior()).getName(); mv.addObject("record", administration); mv.addObject("SuperiorName", SuperiorName); } else { @@ -3026,7 +3084,6 @@ public class PageController { token = (String) request.getSession().getAttribute("userToken"); userKey = (String) request.getSession().getAttribute("userKey"); } - UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); if (parentId != null) { mv.addObject("parentId", parentId); @@ -3059,7 +3116,6 @@ public class PageController { token = (String) request.getSession().getAttribute("userToken"); userKey = (String) request.getSession().getAttribute("userKey"); } - UserByPort userToken = AuthenticationTokenPool.getUserToken(token); String url = PublicConfig.external_url + "/org/positionlist"; ModelAndView mv = new ModelAndView(); mv.addObject("parentId", organization); @@ -3113,7 +3169,7 @@ public class PageController { ModelAndView mv = new ModelAndView(); mv.setViewName("pages/post/post-view"); if (id != null) { - Post object = PublicConfig.findPostById(id, userKey, token); + Post object = postService.findPostById(id); mv.addObject("record", object); } else { throw new MyException("缺少必要参数!"); @@ -3182,7 +3238,7 @@ public class PageController { UserByPort userToken = AuthenticationTokenPool.getUserToken(token); ModelAndView mv = new ModelAndView(); mv.setViewName("pages/post/postRole_add"); - Post postById = PublicConfig.findPostById(id, userKey, token); + Post postById = postService.findPostById(id); mv.addObject("post", postById); mv.addObject("classes", classes); return mv; @@ -3419,7 +3475,7 @@ public class PageController { StringBuilder departmentHeadName = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder(); - List departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(), userKey, token); + List departmentHeadByUser = userService.getDepartmentHeaderByIdForNoPack(userToken.getMaindeparment()); for (UserByPort departmentHead : departmentHeadByUser ) { departmentHeadName.append(departmentHead.getName()).append(","); @@ -3862,7 +3918,7 @@ public class PageController { Long minRecordId = ObjectFormatUtil.toLong(s.split(":")[1].trim()); ApplicationOutRecordMinP applicationOutMinById = depositoryRecordService.findApplicationOutMinById(minRecordId); ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(applicationOutMinById.getParentId()); - UserByPort userByPort = PublicConfig.FindUserById(applicationOutRecordPById.getApplicantId(), userKey, token); + UserByPort userByPort = userService.findUserById(applicationOutRecordPById.getApplicantId()); applicationOutRecordPById.setApplicantName(userByPort.getMaindeparmentname() + "_" + userByPort.getName()); SimpleTaskP simpleTaskP = new SimpleTaskP(applicationOutRecordPById, applicationOutMinById); list.add(simpleTaskP); @@ -3937,7 +3993,8 @@ public class PageController { /** * 用于跳转到折线或柱状图 - * @param type 要查看的出入库 + * + * @param type 要查看的出入库 * @param echartType 图表类型 * @return */ @@ -3952,6 +4009,7 @@ public class PageController { /** * 用于跳转到折线或柱状图 + * * @param type 要查看的出入库 * @return */ diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/QyWxOperationController.java b/src/main/java/com/dreamchaser/depository_manage/controller/QyWxOperationController.java index c7b5c3f2..cbe32a30 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/QyWxOperationController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/QyWxOperationController.java @@ -14,10 +14,7 @@ import com.dreamchaser.depository_manage.pojo.callBackXml.callBackXml_button_tem import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool; import com.dreamchaser.depository_manage.security.pool.HandlesOtherFunctionalThreadPool; import com.dreamchaser.depository_manage.security.pool.RedisPool; -import com.dreamchaser.depository_manage.service.CallBackLogService; -import com.dreamchaser.depository_manage.service.DepositoryRecordService; -import com.dreamchaser.depository_manage.service.DepositoryService; -import com.dreamchaser.depository_manage.service.StockTakingService; +import com.dreamchaser.depository_manage.service.*; import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; import com.dreamchaser.depository_manage.utils.Md5; import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; @@ -47,27 +44,30 @@ public class QyWxOperationController { @Autowired - CallBackLogService callBackLogService; + private CallBackLogService callBackLogService; @Autowired - QyWxOperationService qyWxOperationService; + private QyWxOperationService qyWxOperationService; @Autowired - DepositoryRecordService depositoryRecordService; + private DepositoryRecordService depositoryRecordService; @Autowired - DepositoryService depositoryService; + private DepositoryService depositoryService; @Autowired - StockTakingService stockTakingService; + private StockTakingService stockTakingService; @Autowired - RedisPool redisPool; + private RedisPool redisPool; + + @Autowired + private UserService userService; /** * 用于接收企业微信的回调,get方式 diff --git a/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.java b/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.java index 32fc985a..4abb663b 100644 --- a/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.java @@ -27,5 +27,19 @@ public interface AdministrativeMapper { List findAdministrationsAll(); + /** + * 根据条件获取行政组织 + * @param map 待查询条件 + * @return + */ List findAdministrationPByCondition(Map map); + + /** + * 根据条件获取行政组织数 + * @param map 待查询条件 + * @return + */ + Integer findAdministrationPCountByCondition(Map map); + + } diff --git a/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.xml b/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.xml index d808c5c8..681ab190 100644 --- a/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.xml @@ -15,7 +15,7 @@ - + @@ -29,7 +29,7 @@ - id,number,name,superior,type,level,state,typename + id,numbe,name,superior,level,state,typename + + + diff --git a/src/main/java/com/dreamchaser/depository_manage/pojo/AdministrationP.java b/src/main/java/com/dreamchaser/depository_manage/pojo/AdministrationP.java index 14492fea..26071130 100644 --- a/src/main/java/com/dreamchaser/depository_manage/pojo/AdministrationP.java +++ b/src/main/java/com/dreamchaser/depository_manage/pojo/AdministrationP.java @@ -49,7 +49,7 @@ public class AdministrationP implements Serializable { /** * 上级 */ - private Integer superior; + private Long superior; public AdministrationP(Administration administration) { this.id = administration.getId(); @@ -60,4 +60,7 @@ public class AdministrationP implements Serializable { this.level = administration.getLevel(); this.state = administration.getState(); } + + public AdministrationP() { + } } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/AdministrativeService.java b/src/main/java/com/dreamchaser/depository_manage/service/AdministrativeService.java index 51edc9d9..db9b16d9 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/AdministrativeService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/AdministrativeService.java @@ -2,8 +2,10 @@ package com.dreamchaser.depository_manage.service; import com.dreamchaser.depository_manage.entity.Administration; import com.dreamchaser.depository_manage.entity.UserByPort; +import com.dreamchaser.depository_manage.pojo.AdministrationP; import java.util.List; +import java.util.Map; public interface AdministrativeService { @@ -26,14 +28,23 @@ public interface AdministrativeService { * @param userByPort 待获取用户 * @return */ - public Administration getDepartmentByUser(UserByPort userByPort); + Administration getDepartmentByUser(UserByPort userByPort); /** - * 获取当前用户所处的部门id(高科)_ - * @param departmentId 待获取部门id + * 根据条件获取行政组织 + * @param map 待查询条件 * @return */ - public Administration getDepartmentForHXGK(Long departmentId); + List findAdministrationPListByCondition(Map map); + + + /** + * 根据条件获取行政组织数 + * @param map 待查询条件 + * @return + */ + Integer findAdministrationPCountByCondition(Map map); + } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/PostService.java b/src/main/java/com/dreamchaser/depository_manage/service/PostService.java new file mode 100644 index 00000000..92d8adac --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/service/PostService.java @@ -0,0 +1,12 @@ +package com.dreamchaser.depository_manage.service; + +import com.dreamchaser.depository_manage.entity.Post; + +public interface PostService { + /** + * 根据岗位id获取岗位信息 + * @param postId + * @return + */ + Post findPostById(Long postId); +} diff --git a/src/main/java/com/dreamchaser/depository_manage/service/UserService.java b/src/main/java/com/dreamchaser/depository_manage/service/UserService.java index 78a77342..66a0e28c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/UserService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/UserService.java @@ -12,12 +12,20 @@ import java.util.Map; public interface UserService { /** - * 通过id获取用户信息 + * 通过id获取用户信息(包装) * @param id 待获取用户id * @return */ UserByPort findUserById(Long id); + + /** + * 通过id获取用户信息(未包装) + * @param id 待获取用户id + * @return + */ + UserByPort findUserByIdForNoPack(Long id); + /** * 通过工号获取用户信息 * @param number 待获取用户工号 @@ -25,9 +33,16 @@ public interface UserService { */ UserByPort findUserByNumber(String number); + /** + * 通过工号获取用户信息 + * @param number 待获取用户工号 + * @return + */ + UserByPort findUserByNumberForNoPack(String number); + /** - * 获取当前部门的部门负责人 + * 获取当前部门的部门负责人(包装) * * @param administration 待获取部门 * @return @@ -35,12 +50,28 @@ public interface UserService { List getDepartmentHeaderById(Administration administration); /** - * 根据条件查询用户信息 + * 获取当前部门的部门负责人(未包装) + * + * @param administrationId 待获取部门id + * @return + */ + List getDepartmentHeaderByIdForNoPack(Long administrationId); + + + /** + * 根据条件查询用户信息(包装) * @param map 待查询条件 * @return */ List findUserByCondition(Map map); + /** + * 根据条件查询用户信息(未包装) + * @param map 待查询条件 + * @return + */ + List findUserByConditionForNoPack(Map map); + /** * 根据条件查询用户数量 diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/AdministrativeServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/AdministrativeServiceImpl.java index e39f731b..eb0c4ded 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/AdministrativeServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/AdministrativeServiceImpl.java @@ -3,11 +3,13 @@ package com.dreamchaser.depository_manage.service.impl; import com.dreamchaser.depository_manage.entity.Administration; import com.dreamchaser.depository_manage.entity.UserByPort; import com.dreamchaser.depository_manage.hrNew_mapper.AdministrativeMapper; +import com.dreamchaser.depository_manage.pojo.AdministrationP; import com.dreamchaser.depository_manage.service.AdministrativeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service @@ -35,6 +37,24 @@ public class AdministrativeServiceImpl implements AdministrativeService { return administrativeMapper.findAdministrationsAll(); } + /** + * 根据条件获取行政组织 + * @param map 待查询条件 + * @return + */ + public List findAdministrationPListByCondition(Map map){ + return administrativeMapper.findAdministrationPByCondition(map); + } + + /** + * 根据条件获取行政组织数 + * @param map 待查询条件 + * @return + */ + public Integer findAdministrationPCountByCondition(Map map){ + return administrativeMapper.findAdministrationPCountByCondition(map); + } + /** * 获取当前用户所处部门 diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java index 7006b36a..79fe9e79 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java @@ -8,6 +8,8 @@ import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.entity.MaterialAndPlace; import com.dreamchaser.depository_manage.exception.MyException; import com.dreamchaser.depository_manage.depository_mapper.*; +import com.dreamchaser.depository_manage.hrNew_mapper.AdministrativeMapper; +import com.dreamchaser.depository_manage.hrNew_mapper.UserMapper; import com.dreamchaser.depository_manage.pojo.*; import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details; import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver; @@ -15,6 +17,7 @@ import com.dreamchaser.depository_manage.pojo.callBackXml.callBackXml_button_tem import com.dreamchaser.depository_manage.security.pool.HandlesOtherFunctionalThreadPool; import com.dreamchaser.depository_manage.security.pool.RedisPool; import com.dreamchaser.depository_manage.security.pool.SendQyWxMessageThreadPool; +import com.dreamchaser.depository_manage.service.AdministrativeService; import com.dreamchaser.depository_manage.service.DepositoryRecordService; import com.dreamchaser.depository_manage.service.RoleService; import com.dreamchaser.depository_manage.service.SplitUnitService; @@ -73,6 +76,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { @Autowired private GroupMapper groupMapper; + @Autowired + private UserMapper userMapper; + + @Autowired + private AdministrativeService administrativeService; + /** * 提交申请,插入一条仓库调度记录 @@ -203,7 +212,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (materialByCondition.size() > 0) { // 如果当前存在 Inventory mt = materialByCondition.get(0); map.put("mid", mt.getMid()); - mt.setQuantity((long)(mt.getQuantity() + (quantity * 100))); + mt.setQuantity((long) (mt.getQuantity() + (quantity * 100))); mt.setProducedDate(producedDate); materialMapper.updateInventory(mt); newMid = mt.getId(); @@ -1917,7 +1926,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 强行完成出库 // 获取当前出库人员 - UserByPort userByPort = PublicConfig.FindUserById(outRecordMin.getCheckId(), userKey, token); + UserByPort userByPort = userMapper.findUserById(outRecordMin.getCheckId()); outRecord.setPass(1); updateApplicationMinOutInfo(id, outRecordMin, outRecord, (double) (quantity), userByPort, placeById.getId(), userAgent, userKey, token); @@ -1936,7 +1945,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { for (RoleAndMaterialType mt : materialTypeIdForIn ) { // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(mt.getUid(), userKey, token); + UserByPort userByPort = userMapper.findUserById(mt.getUid()); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -1954,7 +1963,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { for (RoleAndDepository mt : materialTypeIdForIn ) { // 获取管理员数据 - UserByPort userByPort = PublicConfig.FindUserById(mt.getUserId(), userKey, token); + UserByPort userByPort = userMapper.findUserById(mt.getUserId()); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -2300,7 +2309,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 获取主订单单号 StringBuilder code = new StringBuilder(record.getCode()); // 获取申请用户信息 - UserByPort applicantUser = PublicConfig.FindUserById(record.getApplicantId(), userKey, token); + UserByPort applicantUser = userMapper.findUserById(record.getApplicantId()); // 获取申请用户行政组织 Administration company = PublicConfig.getCompany(applicantUser.getMaindeparment(), userKey, token); // 获取部门名称简写 @@ -2363,7 +2372,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { continue; } Long uid = ObjectFormatUtil.toLong(s); - UserByPort depositoryManager = PublicConfig.FindUserById(uid, userKey, token); + UserByPort depositoryManager = userMapper.findUserById(uid); // 获取用户的用工关系 int emptype = depositoryManager.getEmptype(); if (emptype > 10) { @@ -2559,7 +2568,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 将没有插入的用户进行插入 for (Long integer : userIdByMtId) { // 获取仓库管理员信息 - UserByPort manager = PublicConfig.FindUserById(integer, userKey, token); + UserByPort manager = userMapper.findUserById(integer); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -2644,7 +2653,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 修改redis中用户的数据 updateRedisDataForUserManager(integer, minRecordKey); // 获取仓库管理员信息 - UserByPort manager = PublicConfig.FindUserById(integer, userKey, token); + UserByPort manager = userMapper.findUserById(integer); // 获取用户的用工关系 int emptype = manager.getEmptype(); if (emptype > 10) { @@ -3183,7 +3192,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List minByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(record.getId()); // 获取申请用户 - UserByPort applicantUser = PublicConfig.FindUserById(record.getApplicantId(), userKey, token); + UserByPort applicantUser = userMapper.findUserById(record.getApplicantId()); // 用于标志该仓库是否为前置仓下的仓库 boolean flagForHasOtherDepository = true; //默认是前置仓下的仓库 // 获取当前出库是否为开放出库 @@ -3334,7 +3343,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if ("".equals(depositorymanager)) { continue; } - UserByPort depositoryManage = PublicConfig.FindUserById(ObjectFormatUtil.toLong(depositorymanager), userKey, token); + UserByPort depositoryManage = userMapper.findUserById(ObjectFormatUtil.toLong(depositorymanager)); // 获取用户的用工关系 int emptype = depositoryManage.getEmptype(); if (emptype > 10) { @@ -3393,7 +3402,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if ("".equals(s)) { continue; } - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(s), userKey, token); + UserByPort userByPort = userMapper.findUserById(ObjectFormatUtil.toLong(s)); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -3454,7 +3463,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if ("".equals(depositorymanager)) { continue; } - UserByPort depositoryManage = PublicConfig.FindUserById(ObjectFormatUtil.toLong(depositorymanager), userKey, token); + UserByPort depositoryManage = userMapper.findUserById(ObjectFormatUtil.toLong(depositorymanager)); // 获取用户的用工关系 int emptype = depositoryManage.getEmptype(); if (emptype > 10) { @@ -3513,7 +3522,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if ("".equals(s)) { continue; } - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(s), userKey, token); + UserByPort userByPort = userMapper.findUserById(ObjectFormatUtil.toLong(s)); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -3655,7 +3664,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { for (Long integer : userIdByDid) { // 获取仓库管理员信息 - UserByPort manager = PublicConfig.FindUserById(integer, userKey, token); + UserByPort manager = userMapper.findUserById(integer); // 获取用户的用工关系 int emptype = manager.getEmptype(); if (emptype > 10) { @@ -3694,7 +3703,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List minIdList = new ArrayList<>(); Object o = minIdByMaterialType.get("depository" + depositoryId); if (o != null) { - minIdList = ObjectFormatUtil.objToList(o,Long.class); + minIdList = ObjectFormatUtil.objToList(o, Long.class); } // 将当前子订单添加到该仓库下的子订单列表中 minIdList.add(applicationOutRecordMin.getId()); @@ -3744,7 +3753,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 修改redis中用户的数据 updateRedisDataForUserManager(integer, minRecordKey); // 获取仓库管理员信息 - UserByPort manager = PublicConfig.FindUserById(integer, userKey, token); + UserByPort manager = userMapper.findUserById(integer); // 获取用户的用工关系 int emptype = manager.getEmptype(); if (emptype > 10) { @@ -3782,7 +3791,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if ("".equals(s)) { continue; } - UserByPort userByPort = PublicConfig.FindUserById(ObjectFormatUtil.toLong(s), userKey, token); + UserByPort userByPort = userMapper.findUserById(ObjectFormatUtil.toLong(s)); // 获取用户的用工关系 int emptype = userByPort.getEmptype(); if (emptype > 10) { @@ -3829,7 +3838,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { SendQyWxMessageThreadPool.execute(() -> { // 获取responseCode(key为申请人number) //获取部门负责人信息 - UserByPort departHead = PublicConfig.FindUserById(ObjectFormatUtil.toLong(record.getDepartmenthead()), userKey, token); + UserByPort departHead = userMapper.findUserById(ObjectFormatUtil.toLong(record.getDepartmenthead())); // 获取用户的用工关系 int emptype = departHead.getEmptype(); if (emptype <= 10) { @@ -4024,7 +4033,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if ("".equals(s)) { continue; } - UserByPort userById = PublicConfig.FindUserById(ObjectFormatUtil.toLong(s), null, null); + UserByPort userById = userMapper.findUserById(ObjectFormatUtil.toLong(s)); // 获取用户的用工关系 int emptype = userById.getEmptype(); if (emptype > 10) { @@ -4122,7 +4131,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List minIdList = new ArrayList<>(); Object o = minIdByMaterialType.get("materialType" + materialTypeId); if (o != null) { - minIdList =ObjectFormatUtil.objToList(o,Long.class); + minIdList = ObjectFormatUtil.objToList(o, Long.class); } // 将当前子订单添加到该仓库下的子订单列表中 minIdList.add(applicationOutRecordMin.getId()); @@ -4170,7 +4179,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { for (Long integer : userIdByDid) { // 获取仓库管理员信息 - UserByPort manager = PublicConfig.FindUserById(integer, userKey, token); + UserByPort manager = userMapper.findUserById(integer); // 获取用户的用工关系 int emptype = manager.getEmptype(); if (emptype > 10) { @@ -4208,7 +4217,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List minIdList = new ArrayList<>(); Object o = minIdByMaterialType.get("depository" + depositoryId); if (o != null) { - minIdList = ObjectFormatUtil.objToList(o,Long.class); + minIdList = ObjectFormatUtil.objToList(o, Long.class); } // 将当前子订单添加到该仓库下的子订单列表中 minIdList.add(applicationOutRecordMin.getId()); @@ -4258,7 +4267,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 修改redis中用户的数据 updateRedisDataForUserManager(integer, minRecordKey); // 获取仓库管理员信息 - UserByPort manager = PublicConfig.FindUserById(integer, userKey, token); + UserByPort manager = userMapper.findUserById(integer); // 获取用户的用工关系 int emptype = manager.getEmptype(); if (emptype > 10) { @@ -4771,8 +4780,18 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List list = depositoryRecordMapper.findApplicationInRecordPByCondition(map); List result = new ArrayList<>(); + Map userByPortMap = new HashMap<>(); for (ApplicationInRecord applicationInRecord : list) { - UserByPort userByPortById = PublicConfig.FindUserById(applicationInRecord.getApplicantId(), userKey, token); + Long applicantId = applicationInRecord.getApplicantId(); + UserByPort userByPortById = null; + if (userByPortMap.containsKey(applicantId)) { + userByPortById = userByPortMap.get(applicantId); + } else { + userByPortById = userMapper.findUserById(applicantId); + Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); + userByPortById.setMaindeparmentname(departmentByUser.getName()); + userByPortMap.put(applicantId, userByPortById); + } String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(applicationInRecord.getApplicantTime())); applicationInRecord.setApplicantName(userByPortById.getName()); applicationInRecord.setApplicantTime(time); @@ -4826,8 +4845,18 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { map.put("applicantId", userByPort.getId()); List list = depositoryRecordMapper.findApplicationInRecordPByUser(map); List result = new ArrayList<>(); + Map userByPortMap = new HashMap<>(); for (ApplicationInRecord applicationInRecord : list) { - UserByPort userByPortById = PublicConfig.FindUserById(applicationInRecord.getApplicantId(), userKey, token); + Long applicantId = applicationInRecord.getApplicantId(); + UserByPort userByPortById = null; + if (userByPortMap.containsKey(applicantId)) { + userByPortById = userByPortMap.get(applicantId); + } else { + userByPortById = userMapper.findUserById(applicantId); + Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); + userByPortById.setMaindeparmentname(departmentByUser.getName()); + userByPortMap.put(applicantId, userByPortById); + } String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(applicationInRecord.getApplicantTime())); applicationInRecord.setApplicantName(userByPortById.getName()); applicationInRecord.setApplicantTime(time); @@ -4902,8 +4931,18 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List list = depositoryRecordMapper.findApplicationOutRecordPByUser(map); List result = new ArrayList<>(); + Map userByPortMap = new HashMap<>(); for (ApplicationOutRecord record : list) { - UserByPort userByPortById = PublicConfig.FindUserById(record.getApplicantId(), userKey, token); + Long applicantId = record.getApplicantId(); + UserByPort userByPortById = null; + if (userByPortMap.containsKey(applicantId)) { + userByPortById = userByPortMap.get(applicantId); + } else { + userByPortById = userMapper.findUserById(applicantId); + Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); + userByPortById.setMaindeparmentname(departmentByUser.getName()); + userByPortMap.put(applicantId, userByPortById); + } String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(record.getApplicantTime())); record.setApplicantName(userByPortById.getName()); record.setApplicantTime(time); @@ -4978,11 +5017,21 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } List list = depositoryRecordMapper.findApplicationOutRecordPByCondition(map); List result = new ArrayList<>(); + Map userByPortMap = new HashMap<>(); for (ApplicationOutRecord recordP : list) { if (recordP.getQuantity() == null || 0 == recordP.getQuantity()) { continue; } - UserByPort userByPortById = PublicConfig.FindUserById(recordP.getApplicantId(), userKey, token); + Long applicantId = recordP.getApplicantId(); + UserByPort userByPortById = null; + if (userByPortMap.containsKey(applicantId)) { + userByPortById = userByPortMap.get(applicantId); + } else { + userByPortById = userMapper.findUserById(applicantId); + Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); + userByPortById.setMaindeparmentname(departmentByUser.getName()); + userByPortMap.put(applicantId, userByPortById); + } String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(recordP.getApplicantTime())); recordP.setApplicantName(userByPortById.getName()); recordP.setApplicantTime(time); @@ -5626,7 +5675,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List result = new ArrayList<>(list.size()); for (SimpleApplicationOutRecord record : list) { SimpleApplicationOutOrInRecordP d = new SimpleApplicationOutOrInRecordP(record); - UserByPort userByPort = PublicConfig.FindUserById(record.getApplicantId(), userKey, token); + UserByPort userByPort = userMapper.findUserById(record.getApplicantId()); d.setApplyRemark(d.getApplyRemark() == null ? "" : d.getApplyRemark()); d.setApplicantName(userByPort.getMaindeparmentname() + "_" + userByPort.getName()); @@ -5639,7 +5688,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List result = new ArrayList<>(list.size()); for (SimpleApplicationInRecord record : list) { SimpleApplicationOutOrInRecordP d = new SimpleApplicationOutOrInRecordP(record); - UserByPort userByPort = PublicConfig.FindUserById(record.getApplicantId(), userKey, token); + UserByPort userByPort = userMapper.findUserById(record.getApplicantId()); d.setApplyRemark(d.getApplyRemark() == null ? "" : d.getApplyRemark()); d.setApplicantName(userByPort.getMaindeparmentname() + "_" + userByPort.getName()); result.add(d); @@ -5647,37 +5696,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { return result; } - /** - * 对查出来的记录进行包装,包装成前端需要的数据 - * - * @param list DepositoryRecord集合 - * @return 包装好的集合 - */ - private List pack(List list, String userKey, String token) { - List result = new ArrayList<>(list.size()); - for (DepositoryRecord record : list) { - result.add(singlePack(record, userKey, token)); - } - return result; - } - - private DepositoryRecordP singlePack(DepositoryRecord record, String userKey, String token) { - DepositoryRecordP d = new DepositoryRecordP(record); - UserByPort getApplicantUser = PublicConfig.FindUserById(record.getApplicantId(), userKey, token); - d.setApplicantName(getApplicantUser.getName()); - d.setDepositoryName(depositoryMapper.findDepositoryNameById(record.getDepositoryId())); - if (record.getReviewerId() != null) { - UserByPort reviewerUser = PublicConfig.FindUserById(record.getReviewerId(), userKey, token); - d.setReviewerName(reviewerUser.getName()); - } - if (record.getCheckerId() != null) { - UserByPort checkerUser = PublicConfig.FindUserById(record.getCheckerId(), userKey, token); - d.setCheckerName(checkerUser.getName()); - } - return d; - } - - /** * 生成单号 * @@ -6203,7 +6221,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (materialTypeList.size() <= 0) { double sum = 0.0; try { - Object call = new getSunBurstDataForInventoryByDepository( materialType, depositoryId).call(); + Object call = new getSunBurstDataForInventoryByDepository(materialType, depositoryId).call(); sum = ObjectFormatUtil.sum(sum, ObjectFormatUtil.toDouble(ObjectFormatUtil.objToMap(call, String.class, Object.class).get("value"))); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/PostServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/PostServiceImpl.java new file mode 100644 index 00000000..2a91d507 --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/PostServiceImpl.java @@ -0,0 +1,25 @@ +package com.dreamchaser.depository_manage.service.impl; + +import com.dreamchaser.depository_manage.entity.Post; +import com.dreamchaser.depository_manage.hrNew_mapper.PostMapper; +import com.dreamchaser.depository_manage.service.PostService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PostServiceImpl implements PostService { + @Autowired + private PostMapper postMapper; + + + /** + * 根据岗位id获取岗位信息 + * @param postId + * @return + */ + public Post findPostById(Long postId){ + return postMapper.findPostById(postId); + } + + +} diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java index d4498161..d11d5a71 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java @@ -26,8 +26,7 @@ public class UserServiceImpl implements UserService { /** - * 通过id获取用户信息 - * + * 通过id获取用户信息(包装) * @param id 待获取用户id * @return */ @@ -37,7 +36,17 @@ public class UserServiceImpl implements UserService { } /** - * 通过工号获取用户信息 + * 通过id获取用户信息(未包装) + * @param id 待获取用户id + * @return + */ + @Override + public UserByPort findUserByIdForNoPack(Long id) { + return userMapper.findUserById(id); + } + + /** + * 通过工号获取用户信息(包装) * * @param number 待获取用户工号 * @return @@ -47,6 +56,16 @@ public class UserServiceImpl implements UserService { return packForOne(userMapper.findUserByNumber(number)); } + /** + * 通过工号获取用户信息(未包装) + * + * @param number 待获取用户工号 + * @return + */ + public UserByPort findUserByNumberForNoPack(String number) { + return userMapper.findUserByNumber(number); + } + /** * 获取当前部门的部门负责人 @@ -71,6 +90,30 @@ public class UserServiceImpl implements UserService { return packForMoreOne(userByPortList); } + /** + * 获取当前部门的部门负责人(未包装) + * + * @param administrationId 待获取部门id + * @return + */ + @Override + public List getDepartmentHeaderByIdForNoPack(Long administrationId) { + // 用于存储结果集 + List userByPortList = new ArrayList<>(); + // 查询数据库中当前部门的负责人 + List departmentHeaders = userMapper.findDepartmentHeaders(administrationId); + for (UserByPort departmentHeader : departmentHeaders) { + // 获取当前人员的雇佣关系 + Integer emptype = departmentHeader.getEmptype(); + if (emptype > 10) { + // 如果是离职状态,则不加入 + continue; + } + userByPortList.add(departmentHeader); + } + return userByPortList; + } + /** * 根据条件查询用户信息 * @param map 待查询条件 @@ -81,6 +124,16 @@ public class UserServiceImpl implements UserService { return packForMoreOne(userMapper.findUserByCondition(map)); } + /** + * 根据条件查询用户信息(未包装) + * @param map 待查询条件 + * @return + */ + @Override + public List findUserByConditionForNoPack(Map map) { + return userMapper.findUserByCondition(map); + } + /** * 根据条件查询用户数量 * @param map 待查询条件 diff --git a/src/main/java/com/dreamchaser/depository_manage/utils/EncryptionAlgorithmUtil.java b/src/main/java/com/dreamchaser/depository_manage/utils/EncryptionAlgorithmUtil.java index f0c381cb..04bb8cff 100644 --- a/src/main/java/com/dreamchaser/depository_manage/utils/EncryptionAlgorithmUtil.java +++ b/src/main/java/com/dreamchaser/depository_manage/utils/EncryptionAlgorithmUtil.java @@ -45,6 +45,8 @@ public class EncryptionAlgorithmUtil { return DigestUtils.md5Hex(two); } + + /** * 用于获取当前用户的key与token * @param userByPort 待获取用户