소스 검색

未填报人员催填

yurk 2 년 전
부모
커밋
eca5fd807d

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java

@@ -170,7 +170,7 @@ public class UserController {
     }
 
     @RequestMapping("/pushFillReport")
-    public HttpRespMsg pushFillReport(String ids, String date) {return userService.pushFillReport(ids, request, date); }
+    public HttpRespMsg pushFillReport(String ids, String date,Integer code) {return userService.pushFillReport(ids, request, date,code); }
 
     @RequestMapping("/exportMembList")
     public HttpRespMsg exportMembList(boolean isFill, String ids, String date) {return userService.exportMembList(isFill, ids, request, date); }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java

@@ -51,7 +51,7 @@ public interface UserService extends IService<User> {
 
     HttpRespMsg sendVcode(String mobile);
 
-    HttpRespMsg pushFillReport(String ids, HttpServletRequest request, String date);
+    HttpRespMsg pushFillReport(String ids, HttpServletRequest request, String date,Integer code);
 
     HttpRespMsg exportMembList(boolean isFill, String ids, HttpServletRequest request, String date);
 

+ 49 - 13
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -38,7 +38,6 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.*;
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
@@ -124,6 +123,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     private UserCertService userCertService;
     @Resource
     private TaskGroupMapper taskGroupMapper;
+    @Resource
+    private WxCorpInfoMapper wxCorpInfoMapper;
+    @Resource
+    private CompanyDingdingService companyDingdingService;
+    @Resource
+    private WxCorpInfoService wxCorpInfoService;
     //登录网页端
     @Override
     public HttpRespMsg loginAdmin(String username, String password) {
@@ -1278,26 +1283,57 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     }
 
     @Override
-    public HttpRespMsg pushFillReport(String ids, HttpServletRequest request, String date) {
+    public HttpRespMsg pushFillReport(String ids, HttpServletRequest request, String date,Integer code) {
         List<String> strings = ListUtil.convertLongIdsArrayToList(ids);
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
         List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
         List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", strings));
         HttpRespMsg msg = new HttpRespMsg();
-        for (User u : userList) {
-            if (!StringUtils.isEmpty(u.getWxOpenid())) {
-                Optional<Department> first = deptList.stream().filter(d -> d.getDepartmentId().equals(u.getDepartmentId())).findFirst();
-                if (first.isPresent()) {
-                    u.setDepartmentName(first.get().getDepartmentName());
+        List<WxCorpInfo> cpList = wxCorpInfoMapper.selectList(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        //企业微信消息推送
+            userList.forEach(u->{
+                if(code==0){
+                        if (u.getCorpwxUserid() != null) {
+                            //推送到企业微信
+                            String corpUid = (String) u.getCorpwxUserid();
+                            JSONObject json=new JSONObject();
+                            JSONArray dataJson=new JSONArray();
+                            JSONObject jsonObj=new JSONObject();
+                            jsonObj.put("key", "提示");
+                            jsonObj.put("value", "您"+(StringUtils.isEmpty(date)?"":date)+"的工时报告还未填写");
+                            dataJson.add(jsonObj);
+                            json.put("template_id","tty9TkCAAAYoevY-40ciWD5lDncDfR5w");
+                            json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://mobworktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=0#wechat_redirect");
+                            json.put("content_item",dataJson);
+                            if (cpList.size() > 0) {
+                                wxCorpInfoService.sendWXCorpTemplateMsg(cpList.get(0), corpUid, json);
+                            }
+                        }
                 }
-                boolean result = push(u, date);
-                if (!result) {
-                    System.out.println("!!!!!!!!!!!==================");
-                    msg.setError("推送失败,请检查日志");
+                //钉钉消息推送  可优化批量发送消息
+                else if(code==1){
+                    Integer companyId = u.getCompanyId();
+                    Long agentId = companyDingdingService.getOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId)).getAgentId();;
+                    String dingUid = (String) u.getDingdingUserid();
+                    String alertMsg = "您"+(StringUtils.isEmpty(date)?"":date)+"的工时报告还未填写";
+                    companyDingdingService.sendFillReportAlertMsg(companyId, agentId, alertMsg, dingUid);
                 }
-            }
-        }
+                //微信公众号消息推送
+                else if(code==2){
+                        if (!StringUtils.isEmpty(u.getWxOpenid())) {
+                            Optional<Department> first = deptList.stream().filter(d -> d.getDepartmentId().equals(u.getDepartmentId())).findFirst();
+                            if (first.isPresent()) {
+                                u.setDepartmentName(first.get().getDepartmentName());
+                            }
+                            boolean result = push(u, date);
+                            if (!result) {
+                                System.out.println("!!!!!!!!!!!==================");
+                                msg.setError("推送失败,请检查日志");
+                            }
+                        }
+                }
+            });
         return msg;
     }