Parcourir la source

日报可自动审核通过,增加博通容和

seyason il y a 2 ans
Parent
commit
4bdd017be9

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -1221,8 +1221,8 @@ public class ReportController {
             }
         }
         HttpRespMsg httpRespMsg = reportService.editReport(reportList, createDate.length > 0 ? createDate[0] : null, targetUserList, hourCost, user.getCompanyId());
-        //先给【上海绎维】使用
-        if (company.getId() == 862 || company.getId() == 10) {
+        //【上海绎维】、【火石演示】、【博通容合】使用
+        if (company.getId() == 862 || company.getId() == 10 || company.getId() == 3344) {
             //项目审核人是提交人的情况,直接审核
             List<String> reportIds = new ArrayList<>();
             for (int i = 0; i<id.length; i++) {

+ 13 - 11
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -2082,13 +2082,13 @@ public class WeiXinCorpController {
                     JSONArray jsonArray = json.getJSONObject("auth_info").getJSONArray("agent");
                     for (int i=0;i<jsonArray.size(); i++) {
                         JSONObject jsonObject = jsonArray.getJSONObject(i);
-                        if (jsonObject.getString("name").equals("工时管家")) {
-                            System.out.println(jsonObject);
+//                        if (jsonObject.getString("name").equals("工时管家")) {
+//                            System.out.println(jsonObject);
                             JSONObject privilege = jsonObject.getJSONObject("privilege");
                             allowUserList = privilege.getJSONArray("allow_user");
                             allowPartyList = privilege.getJSONArray("allow_party");
-                            break;
-                        }
+//                            break;
+//                        }
                     }
                 }
             } catch (Exception exception) {
@@ -2218,13 +2218,14 @@ public class WeiXinCorpController {
                     JSONArray jsonArray = json.getJSONObject("auth_info").getJSONArray("agent");
                     for (int i=0;i<jsonArray.size(); i++) {
                         JSONObject jsonObject = jsonArray.getJSONObject(i);
-                        if (jsonObject.getString("name").equals("工时管家")) {
-                            System.out.println(jsonObject);
+                        //用户可能会自定义应用名称,不一定是工时管家。
+//                        if (jsonObject.getString("name").equals("工时管家")) {
+//                            System.out.println(jsonObject);
                             JSONObject privilege = jsonObject.getJSONObject("privilege");
                             allowUserList = privilege.getJSONArray("allow_user");
                             allowPartyList = privilege.getJSONArray("allow_party");
-                            break;
-                        }
+//                            break;
+//                        }
                     }
                 }
             } catch (Exception exception) {
@@ -3293,7 +3294,7 @@ public class WeiXinCorpController {
             JSONArray jsonArray = json.getJSONObject("auth_info").getJSONArray("agent");
             for (int i=0;i<jsonArray.size(); i++) {
                 JSONObject jsonObject = jsonArray.getJSONObject(i);
-                if (jsonObject.getString("name").equals("工时管家")) {
+//                if (jsonObject.getString("name").equals("工时管家")) {
                     System.out.println(jsonObject);
                     Integer authMode = jsonObject.getInteger("auth_mode");
                     if (!wxCorpInfo.getAuthMode().equals(authMode)) {
@@ -3301,8 +3302,8 @@ public class WeiXinCorpController {
                         wxCorpInfoMapper.updateById(wxCorpInfo);
                     }
                     msg.data = jsonObject.toString();
-                    break;
-                }
+//                    break;
+//                }
             }
         }
         return msg;
@@ -3753,6 +3754,7 @@ public class WeiXinCorpController {
     @RequestMapping("/sendCardMsg")
     public HttpRespMsg sendCardMsg(String corpwxOpenId) {
         User user = userMapper.selectOne(new QueryWrapper<User>().eq("corpwx_userid", corpwxOpenId));
+        if (user == null) return new HttpRespMsg().fail("用户不存在");
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
         JSONObject data = new JSONObject();
         data.put("card_type", "news_notice");

+ 65 - 50
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -91,10 +91,13 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(userId);
         List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
+        boolean isAuditor = functionDeptList.size() > 0;
         boolean isNew = false;
         if (sheet.getId() == null) {
-            if(functionDeptList.size()>0){
+            if (isAuditor) {
                 sheet.setStatus(0);
+            } else {
+                sheet.setStatus(1);
             }
             isNew = true;
             //检查code不能重复
@@ -104,8 +107,18 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 msg.setError(MessageUtils.message("other.billNoExist"));
                 return msg;
             }
+        } else {
+            //如果是驳回状态,改成待审核,否则不变
+            if (sheet.getStatus() == 2) {
+                if (isAuditor) {
+                    sheet.setStatus(0);
+                } else {
+                    sheet.setStatus(1);
+                }
+            }
         }
-        sheet.setStatus(1);
+
+
         sheet.setDenyReason(null);
         sheet.setOperatorId(userId);//设置操作人id
         JSONArray array = JSONArray.parseArray(items);
@@ -113,55 +126,57 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         sheet.setCompanyId(user.getCompanyId());
         if (isNew) {
             expenseSheetMapper.insert(sheet);
-            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
-            if(wxCorpInfo!=null){
-                //获取具有费用报销审核权限的人员
-                SysFunction sysFunction = sysFunctionMapper.selectOne(new QueryWrapper<SysFunction>().eq("name", "费用审核"));
-                List<SysRoleFunction> sysRoleFunctions = sysRoleFunctionMapper.selectList(new QueryWrapper<SysRoleFunction>().eq("function_id", sysFunction.getId()));
-                List<Integer> roleIds = sysRoleFunctions.stream().map(sf -> sf.getRoleId()).distinct().collect(Collectors.toList());
-                List<Integer> targetRoleIds = sysRoleMapper.selectList(new QueryWrapper<SysRole>().eq("company_id", user.getCompanyId()).in("id", roleIds))
-                        .stream().map(sl -> sl.getId()).distinct().collect(Collectors.toList());
-                List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("role_id", targetRoleIds));
-                String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
-                User targetUser = userMapper.selectById(sheet.getOwnerId());
-                //推送到企业微信
-                JSONObject json=new JSONObject();
-                JSONArray dataJson=new JSONArray();
-                JSONObject jsonObj=new JSONObject();
-                jsonObj.put("key", "报销人");
-                jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
-                JSONObject jsonObj1=new JSONObject();
-                jsonObj1.put("key", "填报日期");
-                jsonObj1.put("value",sheet.getCreateDate());
-                JSONObject jsonObj2=new JSONObject();
-                jsonObj2.put("key", "票据类型");
-                jsonObj2.put("value",sheetTypes[sheet.getType()]);
-                JSONObject jsonObj3=new JSONObject();
-                jsonObj3.put("key", "金额");
-                jsonObj3.put("value",sheet.getTotalAmount());
-                JSONObject jsonObj4=new JSONObject();
-                jsonObj4.put("key", "备注");
-                jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
-                dataJson.add(jsonObj);
-                dataJson.add(jsonObj1);
-                dataJson.add(jsonObj2);
-                dataJson.add(jsonObj3);
-                dataJson.add(jsonObj4);
-                json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
-                json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
-                json.put("content_item",dataJson);
-                wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
-                List<Information> informationList=new ArrayList<>();
-                for (User item : targetUserList) {
-                    Information information=new Information();
-                    information.setUserId(item.getId());
-                    information.setTime(LocalDateTime.now());
-                    information.setMsg("费用报销待审核");
-                    information.setType(3);
-                    information.setContent(sheet.getCreateDate()+"");
-                    informationList.add(information);
+            if (!isAuditor) {
+                WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+                if(wxCorpInfo!=null){
+                    //获取具有费用报销审核权限的人员
+                    SysFunction sysFunction = sysFunctionMapper.selectOne(new QueryWrapper<SysFunction>().eq("name", "费用审核"));
+                    List<SysRoleFunction> sysRoleFunctions = sysRoleFunctionMapper.selectList(new QueryWrapper<SysRoleFunction>().eq("function_id", sysFunction.getId()));
+                    List<Integer> roleIds = sysRoleFunctions.stream().map(sf -> sf.getRoleId()).distinct().collect(Collectors.toList());
+                    List<Integer> targetRoleIds = sysRoleMapper.selectList(new QueryWrapper<SysRole>().eq("company_id", user.getCompanyId()).in("id", roleIds))
+                            .stream().map(sl -> sl.getId()).distinct().collect(Collectors.toList());
+                    List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("role_id", targetRoleIds));
+                    String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
+                    User targetUser = userMapper.selectById(sheet.getOwnerId());
+                    //推送到企业微信
+                    JSONObject json=new JSONObject();
+                    JSONArray dataJson=new JSONArray();
+                    JSONObject jsonObj=new JSONObject();
+                    jsonObj.put("key", "报销人");
+                    jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
+                    JSONObject jsonObj1=new JSONObject();
+                    jsonObj1.put("key", "填报日期");
+                    jsonObj1.put("value",sheet.getCreateDate());
+                    JSONObject jsonObj2=new JSONObject();
+                    jsonObj2.put("key", "票据类型");
+                    jsonObj2.put("value",sheetTypes[sheet.getType()]);
+                    JSONObject jsonObj3=new JSONObject();
+                    jsonObj3.put("key", "金额");
+                    jsonObj3.put("value",sheet.getTotalAmount());
+                    JSONObject jsonObj4=new JSONObject();
+                    jsonObj4.put("key", "备注");
+                    jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
+                    dataJson.add(jsonObj);
+                    dataJson.add(jsonObj1);
+                    dataJson.add(jsonObj2);
+                    dataJson.add(jsonObj3);
+                    dataJson.add(jsonObj4);
+                    json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
+                    json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
+                    json.put("content_item",dataJson);
+                    wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
+                    List<Information> informationList=new ArrayList<>();
+                    for (User item : targetUserList) {
+                        Information information=new Information();
+                        information.setUserId(item.getId());
+                        information.setTime(LocalDateTime.now());
+                        information.setMsg("费用报销待审核");
+                        information.setType(3);
+                        information.setContent(sheet.getCreateDate()+"");
+                        informationList.add(information);
+                    }
+                    informationService.saveBatch(informationList);
                 }
-                informationService.saveBatch(informationList);
             }
         } else {
             expenseSheetMapper.updateById(sheet);

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/HttpRespMsg.java

@@ -53,6 +53,10 @@ public class HttpRespMsg implements Serializable {
         msg = errorMsg;
     }
 
+    public HttpRespMsg fail(String errorMsg) {
+        setError(errorMsg);
+        return this;
+    }
 
     public String toJSONStr() {
         JSONObject json = new JSONObject();