|
@@ -38,7 +38,6 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.math.RoundingMode;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneOffset;
|
|
import java.time.ZoneOffset;
|
|
@@ -124,6 +123,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
private UserCertService userCertService;
|
|
private UserCertService userCertService;
|
|
@Resource
|
|
@Resource
|
|
private TaskGroupMapper taskGroupMapper;
|
|
private TaskGroupMapper taskGroupMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private CompanyDingdingService companyDingdingService;
|
|
|
|
+ @Resource
|
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
//登录网页端
|
|
//登录网页端
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg loginAdmin(String username, String password) {
|
|
public HttpRespMsg loginAdmin(String username, String password) {
|
|
@@ -1278,26 +1283,57 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@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);
|
|
List<String> strings = ListUtil.convertLongIdsArrayToList(ids);
|
|
String token = request.getHeader("TOKEN");
|
|
String token = request.getHeader("TOKEN");
|
|
User user = userMapper.selectById(token);
|
|
User user = userMapper.selectById(token);
|
|
List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", strings));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", strings));
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
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;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|