diff --git a/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java b/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java index 98a6abb1..72abaa56 100644 --- a/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java +++ b/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java @@ -23,6 +23,8 @@ import java.util.Map; @Data public class PortConfig { // 部署数据库 depository NhE47edekBHxhjYk + + // 接口地址 public static String external_url = "http://172.20.2.87:39168"; // public static String external_url = "http://127.0.0.1:39168"; @@ -56,16 +58,16 @@ public class PortConfig { list = new JSONArray(); } List userPostList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - Post userPost = JSONObject.toJavaObject((JSONObject) list.get(i), Post.class); + for (Object o : list) { + Post userPost = JSONObject.toJavaObject((JSONObject) o, Post.class); userPostList.add(userPost); } List userByPortList = new ArrayList<>(); - for (int i = 0; i < userPostList.size(); i++) { - Map param = new HashMap<>(); - Post userPost = userPostList.get(i); - param.put("position",userPost.getId()); - List userByPorts = LinkInterfaceUtil.FindUserByMap(param,userToken); + for (Post value : userPostList) { + Map param = new HashMap<>(); + Post userPost = value; + param.put("position", userPost.getId()); + List userByPorts = LinkInterfaceUtil.FindUserByMap(param, userToken); userByPortList.addAll(userByPorts); } return userByPortList; diff --git a/src/main/java/com/dreamchaser/depository_manage/config/QyWxConfig.java b/src/main/java/com/dreamchaser/depository_manage/config/QyWxConfig.java index be00eed2..9de42ff6 100644 --- a/src/main/java/com/dreamchaser/depository_manage/config/QyWxConfig.java +++ b/src/main/java/com/dreamchaser/depository_manage/config/QyWxConfig.java @@ -35,7 +35,7 @@ public class QyWxConfig { public static String code = ""; //userCode public static String sendMessage_url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN"; - public static RedisTemplate redisTemplate; + public static RedisTemplate redisTemplate; // 用于回调配置的token public static String sToken = "sM4MFE44fAKdtqvq81HYygqmrdUn"; @@ -62,20 +62,13 @@ public class QyWxConfig { // 用于jsapi的url public static String jsApiUrl = "https://jy.hxgk.group/"; - @Autowired - public void setRedisTemplate(RedisTemplate redisTemplate){ - QyWxConfig.redisTemplate = redisTemplate; - } - - // 用于获取企业微信对应token - public static String GetQYWXToken(String UserAgent){ + public static String GetQYWXToken(String UserAgent) { // 获取redis中当前用户的user-agent - String token_redis = redisTemplate.opsForValue().get("wms_access_token_"+UserAgent); - if(token_redis != null){ + String token_redis = redisTemplate.opsForValue().get("wms_access_token_" + UserAgent); + if (token_redis != null) { return token_redis; - } - else { + } else { String url = String.format(" https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s", QyWxConfig.corpid, QyWxConfig.secret); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); @@ -92,21 +85,21 @@ public class QyWxConfig { Set keys = redisTemplate.keys("wms_access_token_*"); // 获取遍历器 Iterator iterator = keys.iterator(); - while (iterator.hasNext()){ // 如果有下个,则进行遍历 + while (iterator.hasNext()) { // 如果有下个,则进行遍历 // 获取当前key String next = iterator.next(); // 当前key对应的token String next_access_token = redisTemplate.opsForValue().get(next); - if(accessToken.equals(next_access_token)){ + if (accessToken.equals(next_access_token)) { // 如果当前token相等 // 获取当前的过期时间 - expires_in = redisTemplate.opsForValue().getOperations().getExpire(next,TimeUnit.SECONDS); + expires_in = redisTemplate.opsForValue().getOperations().getExpire(next, TimeUnit.SECONDS); } } - redisTemplate.opsForValue().set("wms_access_token_"+UserAgent,accessToken); - redisTemplate.expire("wms_access_token_"+UserAgent,expires_in, TimeUnit.SECONDS); + redisTemplate.opsForValue().set("wms_access_token_" + UserAgent, accessToken); + redisTemplate.expire("wms_access_token_" + UserAgent, expires_in, TimeUnit.SECONDS); return accessToken; } else { @@ -116,10 +109,9 @@ public class QyWxConfig { } } - // 根据获取到的用户code以及token获取用户id - public static JSONObject GetQYWXUserId(String UserAgent){ - String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=%s&code=%s",QyWxConfig.GetQYWXToken(UserAgent),QyWxConfig.code); + public static JSONObject GetQYWXUserId(String UserAgent) { + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=%s&code=%s", QyWxConfig.GetQYWXToken(UserAgent), QyWxConfig.code); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); return jsonObject; @@ -127,51 +119,51 @@ public class QyWxConfig { } // 用于拼接发送链接 - public static String getQYWXCodeUrl(){ + public static String getQYWXCodeUrl() { String encode = null; try { encode = URLEncoder.encode(QyWxConfig.callBackUrl, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - String url = String.format("https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&agentid=%s#wechat_redirect",QyWxConfig.corpid,encode,QyWxConfig.secret); + String url = String.format("https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&agentid=%s#wechat_redirect", QyWxConfig.corpid, encode, QyWxConfig.secret); return url; } // 获取企业的jsapi_ticket - public static JSONObject getQyWxJsApiTicketForEnterprise(String UserAgent){ + public static JSONObject getQyWxJsApiTicketForEnterprise(String UserAgent) { // 如果token不为"",则使用token,否则获取新token String tempToken = GetQYWXToken(UserAgent); - String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=%s",tempToken); + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=%s", tempToken); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); return jsonObject; } // 获取应用的jsapi_ticket - public static JSONObject getQyWxJsApiTicketForApp(String UserAgent){ + public static JSONObject getQyWxJsApiTicketForApp(String UserAgent) { // 如果token不为"",则使用token,否则获取新token String tempToken = GetQYWXToken(UserAgent); - String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/ticket/get?access_token=%s&type=agent_config",tempToken); + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/ticket/get?access_token=%s&type=agent_config", tempToken); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); return jsonObject; } // 获取企业微信中仓储中心负责人标签的成员的userId - public static List getQyWxLabelUserList(String UserAgent){ + public static List getQyWxLabelUserList(String UserAgent) { // 获取当前token String tempToken = GetQYWXToken(UserAgent); - String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=%s",tempToken); + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=%s", tempToken); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); Integer errcode = jsonObject.getInteger("errcode"); List userIdList = new ArrayList<>(); - if(Integer.compare(0,errcode) == 0){ + if (Integer.compare(0, errcode) == 0) { JSONArray taglist = jsonObject.getJSONArray("taglist"); for (Object o : taglist) { qywxLabel qywxLabel = JSONObject.toJavaObject((JSON) o, qywxLabel.class); - if(qywxLabel.getTagname().contains("仓储中心负责人")){ + if (qywxLabel.getTagname().contains("仓储中心负责人")) { List qyWxLabelUserList = getQyWxLabelUserList(tempToken, qywxLabel.getTagid().toString()); for (qywxLabelUser qywxLabelUser : qyWxLabelUserList) { userIdList.add(qywxLabelUser.getUserid()); @@ -179,58 +171,88 @@ public class QyWxConfig { break; } } - }else{ - throw new MyException("获取标签列表失败"); + } else { + throw new MyException("获取标签列表失败"); } return userIdList; } /** * 获取当前标签成员 + * * @param tempToken * @param TAGID * @return */ - public static List getQyWxLabelUserList(String tempToken,String TAGID){ - String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/tag/get?access_token=%s&tagid=%s",tempToken,TAGID); + public static List getQyWxLabelUserList(String tempToken, String TAGID) { + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/tag/get?access_token=%s&tagid=%s", tempToken, TAGID); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); Integer errcode = jsonObject.getInteger("errcode"); List userList = new ArrayList<>(); - if(Integer.compare(errcode,0) == 0){ + if (Integer.compare(errcode, 0) == 0) { JSONArray userlist = jsonObject.getJSONArray("userlist"); for (Object o : userlist) { qywxLabelUser qywxLabelUser = JSONObject.toJavaObject((JSON) o, qywxLabelUser.class); userList.add(qywxLabelUser); } - }else{ - throw new MyException("获取标签成员失败"); + } else { + throw new MyException("获取标签成员失败"); } return userList; } - /** * 用于获取当前企业微信部门详情 + * * @param UserAgent * @param id * @return */ - public static qywxDepartment getQyWxDepartment(String UserAgent,Integer id){ + public static qywxDepartment getQyWxDepartment(String UserAgent, Integer id) { String tempToken = GetQYWXToken(UserAgent); - String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=%s&id=%s",tempToken,id); + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=%s&id=%s", tempToken, id); String get = HttpUtils.doGet(url); JSONObject jsonObject = JSONObject.parseObject(get); Integer errcode = jsonObject.getInteger("errcode"); - if(Integer.compare(errcode,0) == 0){ + if (Integer.compare(errcode, 0) == 0) { qywxDepartment qywxDepartment = JSONObject.toJavaObject(jsonObject.getJSONObject("department"), qywxDepartment.class); return qywxDepartment; - }else{ - throw new MyException("获取部门信息失败"); + } else { + throw new MyException("获取部门信息失败"); } } + /** + * 用于获取企业微信部门列表 + * + * @param UserAgent + * @return + */ + public static List getQyWxDepartmentList(String UserAgent, Integer id) { + String tempToken = GetQYWXToken(UserAgent); + String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=%s&id=%s", tempToken, id); + String get = HttpUtils.doGet(url); + JSONObject jsonObject = JSONObject.parseObject(get); + Integer errcode = jsonObject.getInteger("errcode"); + if (Integer.compare(errcode, 0) == 0) { + List qywxDepartmentList = new ArrayList<>(); + JSONArray department = jsonObject.getJSONArray("department"); + for (int i = 0; i < department.size(); i++) { + qywxDepartment qywxDepartment = JSONObject.toJavaObject(department.getJSONObject(i), qywxDepartment.class); + qywxDepartmentList.add(qywxDepartment); + } + return qywxDepartmentList; + } else { + throw new MyException("获取部门列表失败"); + } + } + + @Autowired + public void setRedisTemplate(RedisTemplate redisTemplate) { + QyWxConfig.redisTemplate = redisTemplate; + } } diff --git a/src/main/java/com/dreamchaser/depository_manage/config/QyWx_template_card/TextCardContent.java b/src/main/java/com/dreamchaser/depository_manage/config/QyWx_template_card/TextCardContent.java new file mode 100644 index 00000000..ff29aa2c --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/config/QyWx_template_card/TextCardContent.java @@ -0,0 +1,18 @@ +package com.dreamchaser.depository_manage.config.QyWx_template_card; + +import lombok.Data; + +/** + * 文本卡片信息中的消息类 + */ +@Data +public class TextCardContent { + // 标题,不超过128个字节,超过会自动截断(支持id转译) + private String title; + // 描述,不超过512个字节,超过会自动截断(支持id转译) + private String description; + // 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https) + private String url; + //按钮文字。 默认为“详情”, 不超过4个文字,超过自动截断。 + private String btntxt; +} diff --git a/src/main/java/com/dreamchaser/depository_manage/config/QyWx_template_card/TextTemplateCard.java b/src/main/java/com/dreamchaser/depository_manage/config/QyWx_template_card/TextTemplateCard.java new file mode 100644 index 00000000..449cea9a --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/config/QyWx_template_card/TextTemplateCard.java @@ -0,0 +1,8 @@ +package com.dreamchaser.depository_manage.config.QyWx_template_card; + +import lombok.Data; + +@Data +public class TextTemplateCard extends BaseMessage { + private TextCardContent textcard; +} 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 e150e753..c1298513 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/CompanyController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/CompanyController.java @@ -39,156 +39,160 @@ public class CompanyController { /** * 查询组织架构 - * @param map 查询条件 + * + * @param map 查询条件 * @param request 请求体 * @return */ @PostMapping("/allCompanyByParent") - public RestResponse findCompanyByNoParent(@RequestParam Mapmap, HttpServletRequest request){ + public RestResponse findCompanyByNoParent(@RequestParam Map map, HttpServletRequest request) { UserByPort userToken = (UserByPort) request.getAttribute("userToken"); - String url = PortConfig.external_url +"/org/govlist"; + String url = PortConfig.external_url + "/org/govlist"; Object page = map.get("page"); Object pagesize = map.get("pagesize"); String superior = (String) map.get("superior"); Integer level = ObjectFormatUtil.toInteger(map.get("level")); - if("".equals(superior)){ + if ("".equals(superior)) { superior = "313"; } - map.put("page",ObjectFormatUtil.toInteger(page)); - map.put("pagesize",ObjectFormatUtil.toInteger(pagesize)); - map.put("superior",superior); - map.put("level",level); - map.put("state",1); + map.put("page", ObjectFormatUtil.toInteger(page)); + map.put("pagesize", ObjectFormatUtil.toInteger(pagesize)); + map.put("superior", superior); + map.put("level", level); + map.put("state", 1); String jsonString = JSONObject.toJSONString(map); JSONObject paramObject = JSONObject.parseObject(jsonString); String post = null; try { - post = HttpUtils.send(url,paramObject, HTTP.UTF_8,userToken); + post = HttpUtils.send(url, paramObject, HTTP.UTF_8, userToken); } catch (IOException e) { e.printStackTrace(); } JSONObject jsonObject = JSONObject.parseObject(post); JSONObject data = (JSONObject) jsonObject.get("data"); JSONArray list = (JSONArray) data.get("list"); - if(list == null){ + if (list == null) { list = new JSONArray(); } 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); + Administration administration = JSONObject.toJavaObject((JSONObject) list.get(i), Administration.class); AdministrationP administrationP = new AdministrationP(administration); administrationPList.add(administrationP); } - return new RestResponse(administrationPList,total,200); + return new RestResponse(administrationPList, total, 200); } /** * 根据条件查询公司 + * * @param map 查询条件 * @return 返回结果 */ @PostMapping("/companyByCondition") - public RestResponse findcompanyByCondition(@RequestParam Map map,HttpServletRequest request){ - UserByPort userByPort = (UserByPort)request.getAttribute("userToken"); + public RestResponse findcompanyByCondition(@RequestParam Map map, HttpServletRequest request) { + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); String url = PortConfig.external_url + "/org/govlist"; - if(map.containsKey("state")){ + if (map.containsKey("state")) { Object state = map.get("state"); - map.put("state",ObjectFormatUtil.toInteger(state)); + map.put("state", ObjectFormatUtil.toInteger(state)); } Object page = map.get("page"); Object pagesize = map.get("pagesize"); - map.put("page",ObjectFormatUtil.toInteger(page)); - map.put("pagesize",ObjectFormatUtil.toInteger(pagesize)); + map.put("page", ObjectFormatUtil.toInteger(page)); + map.put("pagesize", ObjectFormatUtil.toInteger(pagesize)); String jsonString = JSONObject.toJSONString(map); JSONObject paramObject = JSONObject.parseObject(jsonString); String post = null; try { - post = HttpUtils.send(url,paramObject, HTTP.UTF_8,userByPort); + post = HttpUtils.send(url, paramObject, HTTP.UTF_8, userByPort); } catch (IOException e) { e.printStackTrace(); } JSONObject jsonObject = JSONObject.parseObject(post); JSONObject data = (JSONObject) jsonObject.get("data"); JSONArray list = (JSONArray) data.get("list"); - if(list == null){ + if (list == null) { list = new JSONArray(); } 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); + Administration administration = JSONObject.toJavaObject((JSONObject) list.get(i), Administration.class); AdministrationP administrationP = new AdministrationP(administration); administrationPList.add(administrationP); } - return new RestResponse(list,total,200); + return new RestResponse(list, total, 200); } /** * 根据条件查询岗位 + * * @param map 查询条件 * @return */ @PostMapping("/allPostByOrganization") - public RestResponse allPostByParent(@RequestParam Map map,HttpServletRequest request) { - UserByPort userByPort = (UserByPort)request.getAttribute("userToken"); + public RestResponse allPostByParent(@RequestParam Map map, HttpServletRequest request) { + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); String url = PortConfig.external_url + "/org/positionlist"; Object page = map.get("page"); Object pagesize = map.get("pagesize"); - map.put("page",ObjectFormatUtil.toInteger(page)); - map.put("pagesize",ObjectFormatUtil.toInteger(pagesize)); + map.put("page", ObjectFormatUtil.toInteger(page)); + map.put("pagesize", ObjectFormatUtil.toInteger(pagesize)); String jsonString = JSONObject.toJSONString(map); JSONObject paramObject = JSONObject.parseObject(jsonString); String post = null; try { - post = HttpUtils.send(url,paramObject, HTTP.UTF_8,userByPort); + post = HttpUtils.send(url, paramObject, HTTP.UTF_8, userByPort); } catch (IOException e) { e.printStackTrace(); } JSONObject jsonObject = JSONObject.parseObject(post); JSONObject data = (JSONObject) jsonObject.get("data"); JSONArray list = (JSONArray) data.get("list"); - if(list == null){ + if (list == null) { list = new JSONArray(); } Integer total = ObjectFormatUtil.toInteger(data.get("total")); List postList = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { - Post object = JSONObject.toJavaObject((JSONObject)list.get(i), Post.class); + Post object = JSONObject.toJavaObject((JSONObject) list.get(i), Post.class); PostP postP = new PostP(object); List depositoryAndRole = roleService.findDepositoryAndRole(postP.getId()); - if(depositoryAndRole != null) { + if (depositoryAndRole != null) { StringBuilder Depository = new StringBuilder(); for (int j = 0; j < depositoryAndRole.size(); j++) { String depositoryName = depositoryAndRole.get(i).getDepositoryName(); - if(depositoryName == null){ + if (depositoryName == null) { depositoryName = ""; } Depository.append(depositoryName + " "); } postP.setDepositoryName(Depository.toString()); - }else{ + } else { postP.setDepositoryName(""); } postList.add(postP); } - return new RestResponse(postList,total,200); + return new RestResponse(postList, total, 200); } /** * 给岗位设置权限 + * * @param map 条件 * @return 设置结果 */ @PostMapping("/post_role") - public RestResponse addUser(@RequestBody Map map,HttpServletRequest request) { + public RestResponse addUser(@RequestBody Map map, HttpServletRequest request) { UserByPort userToken = (UserByPort) request.getAttribute("userToken"); - Map userParam = new HashMap<>(); - userParam.put("position",ObjectFormatUtil.toInteger(map.get("userid"))); - List userByPortList = LinkInterfaceUtil.FindUserByMap(userParam,userToken); + Map userParam = new HashMap<>(); + userParam.put("position", ObjectFormatUtil.toInteger(map.get("userid"))); + List userByPortList = LinkInterfaceUtil.FindUserByMap(userParam, userToken); Integer success = 0; - if(map.containsKey("depositoryId")) { + if (map.containsKey("depositoryId")) { for (int i = 0; i < userByPortList.size(); i++) { Map param = new HashMap<>(); param.put("userId", userByPortList.get(i).getId()); @@ -206,7 +210,7 @@ public class CompanyController { success += roleService.addUserOrPostRoleAndDepository(insert); } } - }else{ + } else { List depositoryAll = depositoryService.findDepositoryAll(); for (int i = 0; i < depositoryAll.size(); i++) { for (int j = 0; j < userByPortList.size(); j++) { @@ -221,50 +225,53 @@ public class CompanyController { Map insert = new HashMap<>(); insert.put("classes", 2); insert.put("authority", 0); - insert.put("depositoryId",depositoryAll.get(i).getId()); + insert.put("depositoryId", depositoryAll.get(i).getId()); insert.put("userid", userByPortList.get(j).getId()); success += roleService.addUserOrPostRoleAndDepository(insert); } } } } - return CrudUtil.postHandle(success,success); + return CrudUtil.postHandle(success, success); } /** * 修改岗位的权限 + * * @param map 修改条件 * @return */ @PostMapping("/postRole_edit") public RestResponse editPostRole(@RequestBody Map map) { - Map userParam = new HashMap<>(); + Map userParam = new HashMap<>(); Integer oldDepository = ObjectFormatUtil.toInteger(map.get("oldDepository")); Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); - userParam.put("position",ObjectFormatUtil.toInteger(map.get("userid"))); - Map param = new HashMap<>(); - param.put("depositoryId",oldDepository); - param.put("classes",2); + userParam.put("position", ObjectFormatUtil.toInteger(map.get("userid"))); + Map param = new HashMap<>(); + param.put("depositoryId", oldDepository); + param.put("classes", 2); List roleAndDepositoryByCondition = roleService.findRoleAndDepositoryByCondition(param); Integer success = 0; for (int i = 0; i < roleAndDepositoryByCondition.size(); i++) { RoleAndDepository roleAndDepository = roleAndDepositoryByCondition.get(i); - Map update = new HashMap<>(); - update.put("roleId",roleAndDepository.getId()); - update.put("depositoryId",depositoryId); - update.put("classes",2); + Map update = new HashMap<>(); + update.put("roleId", roleAndDepository.getId()); + update.put("depositoryId", depositoryId); + update.put("classes", 2); success += roleService.UpdateRoleAndDepositoryById(update); } - return CrudUtil.postHandle(success,roleAndDepositoryByCondition.size()); + return CrudUtil.postHandle(success, roleAndDepositoryByCondition.size()); } + /** * 根据主键删除权限类型 + * * @param map 删除条件 * @return */ @PostMapping("/postRole_del") - public RestResponse deleteRoleAndDepository(@RequestBody Map map){ - if(map.containsKey("depositoryId")) { + public RestResponse deleteRoleAndDepository(@RequestBody Map map) { + if (map.containsKey("depositoryId")) { Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); Map param = new HashMap<>(); param.put("depositoryId", depositoryId); @@ -275,9 +282,9 @@ public class CompanyController { success += roleService.deleteRoleAndDepositoryById(roleAndDepositoryByCondition.get(i).getId()); } return CrudUtil.postHandle(success, roleAndDepositoryByCondition.size()); - }else if(map.containsKey("depositoryIds")){ + } else if (map.containsKey("depositoryIds")) { Integer num = 0; - List depositoryIds =(List) map.get("depositoryIds"); + List depositoryIds = (List) map.get("depositoryIds"); Integer success = 0; Integer total = 0; for (int i = 0; i < depositoryIds.size(); i++) { @@ -292,29 +299,29 @@ public class CompanyController { } } return CrudUtil.postHandle(success, total); - } - else{ + } else { throw new MyException("所需请求参数缺失!"); } } /** * 查询岗位对应的权限 + * * @param postId 要查询的岗位id * @return */ @GetMapping("/findPostRole") - public RestResponse findPostRole(@RequestParam("postId") Integer postId,HttpServletRequest request){ + public RestResponse findPostRole(@RequestParam("postId") Integer postId, HttpServletRequest request) { UserByPort userToken = (UserByPort) request.getAttribute("userToken"); - Map userParam = new HashMap<>(); - userParam.put("position",postId); - List userByPortList = LinkInterfaceUtil.FindUserByMap(userParam,userToken); - Post postById = LinkInterfaceUtil.findPostById(postId,userToken); + Map userParam = new HashMap<>(); + userParam.put("position", postId); + List userByPortList = LinkInterfaceUtil.FindUserByMap(userParam, userToken); + Post postById = LinkInterfaceUtil.findPostById(postId, userToken); List roleAndDepositoryByCondition = new ArrayList<>(); - if(userByPortList.size() != 0){ - Map param = new HashMap<>(); - param.put("classes",2); - param.put("userId",userByPortList.get(0).getId()); + if (userByPortList.size() != 0) { + Map param = new HashMap<>(); + param.put("classes", 2); + param.put("userId", userByPortList.get(0).getId()); roleAndDepositoryByCondition = roleService.findRoleAndDepositoryByCondition(param); } List postPS = new ArrayList<>(); @@ -330,6 +337,7 @@ public class CompanyController { /** * 用于进行选择负责人 + * * @param request * @return */ @@ -340,4 +348,20 @@ public class CompanyController { list = companyService.InitTreeMenus(userToken); return new RestResponse(list); } + + + /** + * 用于获取企业微信通讯录下的结构 + * + * @param request + * @return + */ + @GetMapping("/departmentTreeMenus") + public RestResponse departmentTreeMenus(HttpServletRequest request) { + List list = new ArrayList<>(); + UserByPort userToken = (UserByPort) request.getAttribute("userToken"); + list = companyService.InitTreeMenus(userToken); + return new RestResponse(list); + } + } diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java index 4d6954cd..40ba5aad 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -1486,7 +1486,8 @@ public class MaterialController { // 用于添加条形码与物料编码的对应关系 @PostMapping("/addBarCodeByMaterial") public RestResponse addBarCodeByMaterial(@RequestBody Map map, HttpServletRequest request) { - return CrudUtil.postHandle(materialService.addBarCodeByMaterial(map), 1); + Integer integer = materialService.addBarCodeByMaterial(map); + return CrudUtil.postHandle(integer, 1); } // 删除条形码与物料编码的对应关系 diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/NoticeController.java b/src/main/java/com/dreamchaser/depository_manage/controller/NoticeController.java index 2875e8fa..6cfeddbe 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/NoticeController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/NoticeController.java @@ -1,27 +1,86 @@ package com.dreamchaser.depository_manage.controller; +import com.alibaba.fastjson.JSONObject; +import com.dreamchaser.depository_manage.config.PortConfig; +import com.dreamchaser.depository_manage.config.QyWxConfig; +import com.dreamchaser.depository_manage.entity.UserByPort; +import com.dreamchaser.depository_manage.entity.qywxDepartment; +import com.dreamchaser.depository_manage.pojo.NoticeP; import com.dreamchaser.depository_manage.pojo.RestResponse; import com.dreamchaser.depository_manage.service.NoticeService; +import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; import com.dreamchaser.depository_manage.utils.CrudUtil; +import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; +import com.dreamchaser.depository_manage.utils.Md5; +import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import java.util.List; import java.util.Map; /** * @author Dreamchaser */ @RestController +@RequestMapping("/notice") public class NoticeController { + + + @Autowired + NoticeService noticeService; + @Autowired - private NoticeService noticeService; + QyWxOperationService qyWxOperationService; + @PostMapping("/notice") - public RestResponse addNotice(@RequestBody Map map){ - return CrudUtil.postHandle(noticeService.addNotice(map),1); + public RestResponse addNotice(@RequestBody Map map, HttpServletRequest request){ + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); + map.put("userId",userByPort.getId()); + map.put("state",1); + // 获取插入结果 + Integer integer = noticeService.addNotice(map); + if(Integer.compare(integer,1) == 0){ + // 如果成功插入 + + String header = request.getHeader("user-agent"); + String crypt = Md5.crypt(header); + + // 开启线程推送应用消息 + /*new Thread(new Runnable() { + @Override + public void run() { + qyWxOperationService.sendNoticeForAllUser(ObjectFormatUtil.toInteger(map.get("id")),crypt); + } + }).start();*/ + + } + return CrudUtil.postHandle(integer,1); } - @GetMapping("/notices") - public RestResponse findNotices(@RequestParam Map map){ - return new RestResponse(noticeService.findNoticeByCondition(map)); + @GetMapping("/findAllNotices") + public RestResponse findNotices(@RequestParam Map map,HttpServletRequest request){ + UserByPort userToken = (UserByPort) request.getAttribute("userToken"); + String header = request.getHeader("user-agent"); + String crypt = Md5.crypt(header); + + // 获取当前用户部门对应在企业微信下的部门 + JSONObject userPortByQyWx = PortConfig.getUserPortByQyWx(userToken.getMaindeparment()); + String portName = userPortByQyWx.getString("name"); + Integer portByQyWxInteger = userPortByQyWx.getInteger("wechatorganizationid"); + + qywxDepartment qyWxDepartment = QyWxConfig.getQyWxDepartment(crypt, userToken.getMaindeparment()); + List noticeByCondition = noticeService.findNoticeByCondition(map); + return new RestResponse(noticeByCondition); + } + + @PostMapping("/notice_del") + public RestResponse DelNotice(@RequestBody Map map,HttpServletRequest request){ + return null; } + + + + } 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 35696a2b..68bf3438 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java @@ -797,9 +797,17 @@ public class PageController { @GetMapping("/notice_edit") public String notice_edit() { - return "pages/other/notice-edit"; + return "pages/notice/notice-edit"; } + @GetMapping("/notice_add") + public String notice_add() { + return "pages/notice/notice-add"; + } + + @GetMapping("/notice_out") + public String notice_out() {return "pages/notice/notice-out";} + @GetMapping("/chart_in") public ModelAndView chart_in() { ModelAndView mv = new ModelAndView(); @@ -2378,4 +2386,25 @@ public class PageController { } + /** + * 用于查看当前公告信息 + * @param id 待查看公告id + * @return + */ + @GetMapping("/noticeView") + public ModelAndView noticeView(Integer id){ + ModelAndView mv = new ModelAndView(); + mv.setViewName("pages/notice/notice-view"); + NoticeP noticeById = noticeService.findNoticeById(id); + mv.addObject("record",noticeById); + return mv; + } + + + @GetMapping("/selectDepartment") + public String selectDepartment(){ + return "pages/notice/selectDepartment"; + } + + } diff --git a/src/main/java/com/dreamchaser/depository_manage/entity/Notice.java b/src/main/java/com/dreamchaser/depository_manage/entity/Notice.java index 79d9544b..92727c6d 100644 --- a/src/main/java/com/dreamchaser/depository_manage/entity/Notice.java +++ b/src/main/java/com/dreamchaser/depository_manage/entity/Notice.java @@ -1,5 +1,7 @@ package com.dreamchaser.depository_manage.entity; +import lombok.Data; + import java.util.Date; /** @@ -8,6 +10,7 @@ import java.util.Date; * @author bianj * @version 1.0.0 2021-06-14 */ +@Data public class Notice implements java.io.Serializable { /** 版本号 */ private static final long serialVersionUID = -2744388334561767209L; @@ -23,94 +26,17 @@ public class Notice implements java.io.Serializable { private String content; /** 发布时间 */ - private String time; - - - /** - * 获取公告主键 - * - * @return 公告主键 - */ - public Integer getId() { - return this.id; - } - - /** - * 设置公告主键 - * - * @param id - * 公告主键 - */ - public void setId(Integer id) { - this.id = id; - } - - /** - * 获取公告标题 - * - * @return 公告标题 - */ - public String getTitle() { - return this.title; - } - - /** - * 设置公告标题 - * - * @param title - * 公告标题 - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * 获取公告内容 - * - * @return 公告内容 - */ - public String getContent() { - return this.content; - } - - /** - * 设置公告内容 - * - * @param content - * 公告内容 - */ - public void setContent(String content) { - this.content = content; - } + private Long time; /** - * 获取发布时间 - * - * @return 发布时间 + * 发布人员 */ - public String getTime() { - return this.time; - } + private Integer userId; /** - * 设置发布时间 - * - * @param time - * 发布时间 + * 公告状态 */ - public void setTime(String time) { - this.time = time; - } + private Integer state; - /* This code was generated by TableGo tools, mark 2 end. */ - @Override - public String toString() { - return "Notice{" + - "id=" + id + - ", title='" + title + '\'' + - ", content='" + content + '\'' + - ", time='" + time + '\'' + - '}'; - } } \ No newline at end of file diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml index f222086e..287d9a6e 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml @@ -86,7 +86,7 @@ - + @@ -136,7 +136,7 @@ id,mid,depositoryId,mname,quantity,price,mtid,mstate,tname,dname,version,amounts ,unit ,texture,mcode,depositoryCode,producedDate,shelfLife,productionPlace,brand,remark,numberOfTemporary - + mp.id,mp.inid,mp.mid,mp.quantity,mp.expendnum,mp.inventory,mp.producedDate,mp.barCode,mp.qrCode @@ -802,7 +802,7 @@ - insert into qrcodeandmaterial(id,mcode,barCode,1) + insert into qrcodeandmaterial(id,mcode,barCode,flag) values (#{id}, @@ -888,7 +888,7 @@ where id = #{id} - + UPDATE material @@ -1009,12 +1009,12 @@ - + DELETE FROM material WHERE id = #{id} - + - n.id, n.title, n.content, n.time + n.id, n.title, n.content, n.time,n.state,n.userId @@ -35,8 +37,17 @@ AND n.content LIKE CONCAT('%', #{content}, '%') - - AND n.time = #{time} + + AND n.time >= #{startDate} + + + AND n.time <= #{endDate} + + + and n.userId = #{userId} + + + and n.state = #{state} order by n.time DESC @@ -44,6 +55,12 @@ + + - + INSERT INTO notice ( - title, content, time + title, content, time,userId,state ) VALUES ( #{title}, #{content}, - #{time} + #{time}, + #{userId}, + #{state} ) + + INSERT INTO notice ( - id, title, content, time + id, title, content, time,userId,state ) VALUES ( #{item.id}, #{item.title}, #{item.content}, - #{item.time} + #{item.time}, + #{item.userId}, + #{item.state}, ) - + + - UPDATE notice + update notice - + title = #{title}, content = #{content}, - - time = #{time} + + time = #{time}, + + + state = #{state} - WHERE id = #{id} + where id = #{id} @@ -111,6 +138,9 @@ time = #{item.time} + + state = #{item.state} + WHERE id = #{item.id} diff --git a/src/main/java/com/dreamchaser/depository_manage/pojo/NoticeP.java b/src/main/java/com/dreamchaser/depository_manage/pojo/NoticeP.java new file mode 100644 index 00000000..4a4aaa49 --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/pojo/NoticeP.java @@ -0,0 +1,45 @@ +package com.dreamchaser.depository_manage.pojo; + +import com.dreamchaser.depository_manage.entity.Notice; +import com.dreamchaser.depository_manage.utils.DateUtil; +import lombok.Data; + +@Data +public class NoticeP { + /** 公告主键 */ + private Integer id; + + /** 公告标题 */ + private String title; + + /** 公告内容 */ + private String content; + + /** 发布时间 */ + private String time; + + /** + * 发布人员 + */ + private Integer userId; + + /** + * 公告状态 + */ + private Integer state; + + /** + * 发布人员名称 + */ + private String userName; + + + public NoticeP(Notice notice) { + this.id = notice.getId(); + this.time = DateUtil.TimeStampToDateTime(notice.getTime()); + this.title = notice.getTitle(); + this.content = notice.getContent(); + this.userId = notice.getUserId(); + this.state = notice.getState(); + } +} diff --git a/src/main/java/com/dreamchaser/depository_manage/service/CompanyService.java b/src/main/java/com/dreamchaser/depository_manage/service/CompanyService.java index 8a933485..d0559d2b 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/CompanyService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/CompanyService.java @@ -1,6 +1,7 @@ package com.dreamchaser.depository_manage.service; import com.dreamchaser.depository_manage.entity.Company; +import com.dreamchaser.depository_manage.entity.User; import com.dreamchaser.depository_manage.entity.UserByPort; import java.util.List; @@ -93,4 +94,10 @@ public interface CompanyService { * @return */ List InitTreeMenus(UserByPort userToken); + + + /** + * 用于构造企业微信行政组织结构 + */ + List BuildQyWxAdministrationTreeMenus(UserByPort userByPort); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/NoticeService.java b/src/main/java/com/dreamchaser/depository_manage/service/NoticeService.java index 189b656e..96692b80 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/NoticeService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/NoticeService.java @@ -1,6 +1,7 @@ package com.dreamchaser.depository_manage.service; import com.dreamchaser.depository_manage.entity.Notice; +import com.dreamchaser.depository_manage.pojo.NoticeP; import java.util.List; import java.util.Map; @@ -21,5 +22,14 @@ public interface NoticeService { * @param map 参数map * @return 符合条件的公告列表 */ - List findNoticeByCondition(Map map); + List findNoticeByCondition(Map map); + + /** + * 根据主键id获取公告信息 + * @param id 待查询id + * @return + */ + NoticeP findNoticeById(Integer id); + + } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/CompanyServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/CompanyServiceImpl.java index 36f1b020..1e94dad6 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/CompanyServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/CompanyServiceImpl.java @@ -185,6 +185,17 @@ public class CompanyServiceImpl implements CompanyService { return list; } + + + /** + * 用于构造企业微信行政组织结构 + */ + @Override + public List BuildQyWxAdministrationTreeMenus(UserByPort userByPort) { + + return null; + } + /** * 用于构造人员树 */ diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/NoticeServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/NoticeServiceImpl.java index 9d72c84d..2bee03fb 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/NoticeServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/NoticeServiceImpl.java @@ -1,17 +1,18 @@ package com.dreamchaser.depository_manage.service.impl; import com.dreamchaser.depository_manage.entity.Notice; +import com.dreamchaser.depository_manage.entity.UserByPort; import com.dreamchaser.depository_manage.mapper.NoticeMapper; +import com.dreamchaser.depository_manage.pojo.NoticeP; import com.dreamchaser.depository_manage.service.NoticeService; import com.dreamchaser.depository_manage.utils.DateUtil; +import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; +import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author Dreamchaser @@ -20,20 +21,75 @@ import java.util.Map; public class NoticeServiceImpl implements NoticeService { @Autowired NoticeMapper noticeMapper; + + + /** + * 增加一条公告信息 + * + * @param map 参数map + * @return 受影响的行数 + */ @Override public Integer addNotice(Map map) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Calendar instance = Calendar.getInstance(); - map.put("time",DateUtil.DateTimeToTimeStamp(simpleDateFormat.format(instance.getTime()))); + // 设置当前时间 + map.put("time", System.currentTimeMillis()); return noticeMapper.addNotice(map); } + /** + * 根据条件查询符合条件的公告信息 + * + * @param map 参数map + * @return 符合条件的公告列表 + */ @Override - public List findNoticeByCondition(Map map) { + public List findNoticeByCondition(Map map) { + + Integer size = 10,page=1; + if (map.containsKey("size")){ + size= ObjectFormatUtil.toInteger(map.get("size")); + map.put("size", size); + } + if (map.containsKey("page")){ + page=ObjectFormatUtil.toInteger(map.get("page")); + map.put("begin",(page-1)*size); + } + + if (map.containsKey("startDate")) { + + String startDate = (String) map.get("startDate"); + map.put("startDate", DateUtil.DateTimeByMonthToTimeStamp(startDate)); + } + if (map.containsKey("endDate")) { + String endDate = (String) map.get("endDate"); + map.put("endDate", DateUtil.DateTimeByMonthToTimeStamp(endDate)); + + } List notice = noticeMapper.findNoticeByCondition(map); - for (int i = 0; i < notice.size(); i++) { - notice.get(i).setTime(DateUtil.TimeStampToDateTime(Long.parseLong(notice.get(i).getTime()))); + List result = new ArrayList<>(); + for (Notice value : notice) { + UserByPort user = LinkInterfaceUtil.FindUserById(value.getUserId(), null); + NoticeP np = new NoticeP(value); + np.setUserName(user.getName()); + result.add(np); } - return notice; + return result; + } + + + /** + * 根据主键id获取公告信息 + * + * @param id 待查询id + * @return + */ + @Override + public NoticeP findNoticeById(Integer id) { + Notice noticeById = noticeMapper.findNoticeById(id); + NoticeP noticeP = new NoticeP(noticeById); + // 获取发起人 + UserByPort user = LinkInterfaceUtil.FindUserById(noticeById.getUserId(), null); + noticeP.setUserName(user.getName()); + return noticeP; } } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java index 02215859..79874895 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java @@ -11,6 +11,7 @@ import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.mapper.*; import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP; import com.dreamchaser.depository_manage.pojo.StockTakingChildP; +import com.dreamchaser.depository_manage.service.NoticeService; import com.dreamchaser.depository_manage.utils.DateUtil; import com.dreamchaser.depository_manage.utils.HttpUtils; import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; @@ -51,6 +52,10 @@ public class QyWxOperationService { MaterialTypeMapper materialTypeMapper; + @Autowired + NoticeMapper noticeMapper; + + /** * 用于向企业微信发送出库消息 * @@ -2526,6 +2531,60 @@ public class QyWxOperationService { } + /** + * 用于向企业中所有用户发送公告信息 + * @param nid 公告id + * @param userAgent md5加密后user-agent + * @return + */ + public JSONObject sendNoticeForAllUser(Integer nid,String userAgent){ + // 获取当前要发生的公告信息 + Notice noticeById = noticeMapper.findNoticeById(nid); + TextTemplateCard textTemplateCard = new TextTemplateCard(); + + // 设置消息接收者为所有人 + textTemplateCard.setTouser("@all"); + + // 设置消息类型,此时固定为:textcard + textTemplateCard.setMsgtype("textcard"); + // 设置企业应用的id + textTemplateCard.setAgentid(QyWxConfig.AgentId); + + // 定义卡片内容 + TextCardContent textCardContent = new TextCardContent(); + // 设置标题 + textCardContent.setTitle(noticeById.getTitle()); + String noticeContent = "
"+DateUtil.TimeStampToDateTime(noticeById.getTime())+ + "
"+noticeById.getContent()+"
"+ + LinkInterfaceUtil.FindUserById(noticeById.getUserId(),null).getName()+"
"; + // 设置内容 + textCardContent.setDescription(noticeContent); + // 设置点击后跳转的链接 + textCardContent.setUrl("https://jy.hxgk.group/noticeView?id="+noticeById.getId()); + // 设置跳转按钮文本 + textCardContent.setBtntxt("详情"); + + // 设置内容 + textTemplateCard.setTextcard(textCardContent); + + String jsonString = JSONObject.toJSONString(textTemplateCard); + jsonString = String.format(jsonString); + // 3.获取请求的url + // 获取access_token:根据企业id和应用密钥获取access_token,并拼接请求url + String accessToken = QyWxConfig.GetQYWXToken(userAgent); + String url = QyWxConfig.sendMessage_url.replace("ACCESS_TOKEN", accessToken); + + // 4.调用接口,发送消息 + String s1 = HttpUtils.doPost(url, jsonString); + + // 将返回结果转为json对象 + JSONObject jsonObject = JSON.parseObject(s1); + + // 返回 + return jsonObject; + } + + /** * 用于当在系统内进行审批后向其他所有用户发送消息 * diff --git a/src/main/resources/static/css/public.css b/src/main/resources/static/css/public.css index cfdec7cf..cf039630 100644 --- a/src/main/resources/static/css/public.css +++ b/src/main/resources/static/css/public.css @@ -25,7 +25,7 @@ body { } .layuimini-form > .layui-form-item > .layui-form-label { - width: 120px !important; + width: 120px ; } .layuimini-form > .layui-form-item > .layui-input-block { diff --git a/src/main/resources/templates/pages/materialBarCode/materialBarCode_out.html b/src/main/resources/templates/pages/materialBarCode/materialBarCode_out.html index ef9b0e2e..8489c934 100644 --- a/src/main/resources/templates/pages/materialBarCode/materialBarCode_out.html +++ b/src/main/resources/templates/pages/materialBarCode/materialBarCode_out.html @@ -110,22 +110,25 @@ var req = {}; req.mid = mid; req.barCodeList = barCode; - $.ajax({ - url: "/material/addBarCodeByMaterial", - type: "post", - data: JSON.stringify(req), - dataType: "json", - contentType: "application/json;charset=utf-8", - success: function (d) { - table.reload('currentTableId', { - url: '/material/findMaterialBarCode', - page: { - curr: 1 - }, - where: {"mid": mid} - }); - } - }) + if(barCode.length > 0){ + $.ajax({ + url: "/material/addBarCodeByMaterial", + type: "post", + data: JSON.stringify(req), + dataType: "json", + contentType: "application/json;charset=utf-8", + success: function (d) { + table.reload('currentTableId', { + url: '/material/findMaterialBarCode', + page: { + curr: 1 + }, + where: {"mid": mid} + }); + } + }) + } + }; diff --git a/src/main/resources/templates/pages/notice/notice-add.html b/src/main/resources/templates/pages/notice/notice-add.html new file mode 100644 index 00000000..144df827 --- /dev/null +++ b/src/main/resources/templates/pages/notice/notice-add.html @@ -0,0 +1,126 @@ + + + + + layui + + + + + + + + + + + +
+
+
+ 公告发布 +
+
+
+
+ +
+
+
+ + +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/pages/other/notice-edit.html b/src/main/resources/templates/pages/notice/notice-edit.html similarity index 92% rename from src/main/resources/templates/pages/other/notice-edit.html rename to src/main/resources/templates/pages/notice/notice-edit.html index eb6bbcac..276c7422 100644 --- a/src/main/resources/templates/pages/other/notice-edit.html +++ b/src/main/resources/templates/pages/notice/notice-edit.html @@ -11,12 +11,13 @@ -
+
+
公告发布
-
+
@@ -39,6 +40,7 @@
+
@@ -59,7 +61,7 @@ //监听提交 form.on('submit(noticeBtn)', function (data) { $.ajax({ - url: "/notice", + url: "/notice/notice", data: JSON.stringify(data.field), type: "post", dataType: 'json', @@ -72,7 +74,7 @@ icon: 6,//成功的表情 time: 1000 //1秒关闭(如果不配置,默认是3秒) },function(){ - window.location="/notice_edit" + window.location="/notice_add" }); } } diff --git a/src/main/resources/templates/pages/notice/notice-out.html b/src/main/resources/templates/pages/notice/notice-out.html new file mode 100644 index 00000000..b6e7be5d --- /dev/null +++ b/src/main/resources/templates/pages/notice/notice-out.html @@ -0,0 +1,586 @@ + + + + + layui + + + + + + + +
+
+
+ 搜索信息 +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
-
+
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ + + + + + + +
+ + + +
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/pages/notice/notice-view.html b/src/main/resources/templates/pages/notice/notice-view.html new file mode 100644 index 00000000..08178ca5 --- /dev/null +++ b/src/main/resources/templates/pages/notice/notice-view.html @@ -0,0 +1,72 @@ + + + + + layui + + + + + + + + +
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/pages/notice/selectDepartment.html b/src/main/resources/templates/pages/notice/selectDepartment.html new file mode 100644 index 00000000..177ddb4d --- /dev/null +++ b/src/main/resources/templates/pages/notice/selectDepartment.html @@ -0,0 +1,55 @@ + + + + + Title + + +
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/pages/other/welcome.html b/src/main/resources/templates/pages/other/welcome.html index 63ec8ba0..2419e168 100644 --- a/src/main/resources/templates/pages/other/welcome.html +++ b/src/main/resources/templates/pages/other/welcome.html @@ -10,28 +10,142 @@ @@ -54,7 +168,7 @@
仓库数量
-

4

+

4

当前仓库总记录数
@@ -68,7 +182,7 @@
库存金额统计
-

12032

+

12032

当前库存总数
@@ -114,49 +228,57 @@
- + 我的申请 @@ -176,6 +298,7 @@
系统公告
+
修改选项卡样式
2019-07-11 23:06
@@ -203,7 +326,7 @@