|
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
@@ -72,6 +73,8 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
@Resource
|
|
|
private SysRoleMapper sysRoleMapper;
|
|
|
@Resource
|
|
|
+ private HttpServletRequest request;
|
|
|
+ @Resource
|
|
|
private SysModuleMapper sysModuleMapper;
|
|
|
@Resource
|
|
|
private LeaveQuotaNumService leaveQuotaNumService;
|
|
@@ -135,6 +138,8 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
@Value("${configEnv.isDev}")
|
|
|
private boolean isDev;//是否是本地开发环境
|
|
|
|
|
|
+ public static final HashMap<String, Long> syncLog = new HashMap();
|
|
|
+
|
|
|
@Override
|
|
|
public synchronized HttpRespMsg initSystem(String corpid) throws ApiException {
|
|
|
System.out.println("========接收到initSystem请求===corpid="+corpid);
|
|
@@ -351,6 +356,34 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
public String syncCorpMembs(String corpid) throws ApiException {
|
|
|
CompanyDingding dingding = companyDingdingMapper.selectById(corpid);
|
|
|
String accessToken = null;
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ //判断时间
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ if (syncLog.get(token) == null) {
|
|
|
+ syncLog.put(token, now);
|
|
|
+ syncLog.put(user.getCompanyId()+"_status", 1L);
|
|
|
+ } else {
|
|
|
+ if (now - syncLog.get(token) < 30*1000) {
|
|
|
+ //msg.setError("调用过于频繁,请稍后再试");
|
|
|
+ return MessageUtils.message("Company.callError");
|
|
|
+ } else {
|
|
|
+ //检查是否当前公司有同步的正在进行
|
|
|
+ if (syncLog.get(user.getCompanyId()+"_status") == null) {
|
|
|
+ //没有进行中的任务,更新最近同步的时间
|
|
|
+ syncLog.put(token, now);
|
|
|
+ syncLog.put(user.getCompanyId()+"_status", 1L);
|
|
|
+ } else {
|
|
|
+ if (now - syncLog.get(token) > 0.5*3600*1000) {
|
|
|
+ //更新最近同步的时间
|
|
|
+ syncLog.put(token, now);
|
|
|
+ } else {
|
|
|
+ //msg.setError("同步正在进行中,请稍后再试");
|
|
|
+ return MessageUtils.message("Company.synError");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (dingding == null) {
|
|
|
System.out.println("corpid不存在=="+corpid);
|
|
|
return "调用失败:corpid不存在==";
|
|
@@ -388,6 +421,7 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
System.out.println("syncCorpMembs 开始获取部门, accessToken="+accessToken);
|
|
|
//获取授权的部门
|
|
|
getAuthedDeptsAndUsers(dingding, accessToken);
|
|
|
+ syncLog.remove(user.getCompanyId()+"_status");
|
|
|
return "调用成功";
|
|
|
}
|
|
|
}
|