|
@@ -29,6 +29,7 @@ import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
@@ -55,10 +56,12 @@ public class TimingTask {
|
|
|
//是否是开发环境
|
|
|
@Value("${configEnv.isDev}")
|
|
|
boolean isDev;
|
|
|
+ @Value("${privateDeployURL.pcUrl}")
|
|
|
+ private String pcUrl;
|
|
|
//是否是私有化部署
|
|
|
@Value("${configEnv.isPrivateDeploy}")
|
|
|
boolean isPrivateDeploy;
|
|
|
-
|
|
|
+ private final static Executor executor = Executors.newFixedThreadPool(3);//启用多线程
|
|
|
|
|
|
@Value("${wx.template_report_fill}")
|
|
|
public String TEMPLATE_REPORT_FILL;
|
|
@@ -68,6 +71,8 @@ public class TimingTask {
|
|
|
public String appId;
|
|
|
@Value("${wx.app_secret}")
|
|
|
public String appSecret;
|
|
|
+ @Value("${corpId}")
|
|
|
+ public String corpId;
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
@Autowired
|
|
@@ -85,6 +90,8 @@ public class TimingTask {
|
|
|
@Resource
|
|
|
private ReportMapper reportMapper;
|
|
|
@Resource
|
|
|
+ private TimeAutoExcludeMapper timeAutoExcludeMapper;
|
|
|
+ @Resource
|
|
|
private WxCorpInfoService wxCorpInfoService;
|
|
|
@Resource
|
|
|
private WxCorpInfoMapper wxCorpInfoMapper;
|
|
@@ -195,19 +202,66 @@ public class TimingTask {
|
|
|
}
|
|
|
|
|
|
//每个月五号推送日报信息
|
|
|
- @Scheduled(cron = "0 0 2 2 * ?")
|
|
|
+ @Scheduled(cron = "0 0 1 5 * ?")
|
|
|
private void pushReportListByToken(){
|
|
|
if(isDev) return;
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
LocalDate now=LocalDate.now().minusMonths(1);
|
|
|
+ DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
now.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
LocalDate start=now.with(TemporalAdjusters.firstDayOfMonth());
|
|
|
LocalDate end=now.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("push_report_data", 1));
|
|
|
+ for (TimeType timeType : timeTypeList) {
|
|
|
+ List<ReportLog> reportLogList = reportLogMapper.selectList(new QueryWrapper<ReportLog>().eq("company_id", timeType.getCompanyId()).ge("operate_date",start.atTime(LocalTime.now())).orderByAsc("operate_date"));
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", timeType.getCompanyId()));
|
|
|
+ List<HashMap<String, Object>> allReportByDate = reportMapper.getAllReportByDate(start.format(df),timeType.getCompanyId(), null, end.format(df), null, 1, null);
|
|
|
+ final CountDownLatch latch=new CountDownLatch(allReportByDate.size());
|
|
|
+ for (HashMap<String, Object> map : allReportByDate) {
|
|
|
+ java.sql.Date sqlCreateDate= (java.sql.Date) map.get("createDate");
|
|
|
+ java.sql.Timestamp sqlProjectAuditTime= (Timestamp) map.get("projectAuditTime");
|
|
|
+ java.sql.Timestamp sqlTime= (Timestamp) map.get("time");
|
|
|
+ if(sqlCreateDate!=null){
|
|
|
+ LocalDate createDate = sqlCreateDate.toLocalDate();
|
|
|
+ map.put("createDate",df.format(createDate));
|
|
|
+ }
|
|
|
+ if(sqlProjectAuditTime!=null){
|
|
|
+ LocalDateTime projectAuditTime = sqlProjectAuditTime.toLocalDateTime();
|
|
|
+ map.put("projectAuditTime",projectAuditTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ }
|
|
|
+ if(sqlTime!=null){
|
|
|
+ LocalDateTime time = sqlTime.toLocalDateTime();
|
|
|
+ map.put("time",time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ }
|
|
|
+ executor.execute(new Runnable(){
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ List<ReportLog> item=new ArrayList<>();
|
|
|
+ Integer reportId = (Integer) map.get("id");
|
|
|
+ for (ReportLog reportLog : reportLogList) {
|
|
|
+ List<String> list = Arrays.asList(reportLog.getReportIds().split(","));
|
|
|
+ reportLog.setCreatorName(!userList.stream().filter(
|
|
|
+ ul->ul.getId().equals(reportLog.getCreatorId())).findFirst().isPresent()?"":userList.stream().filter(
|
|
|
+ ul->ul.getId().equals(reportLog.getCreatorId())).findFirst().get().getName());
|
|
|
+ reportLog.setOperateName(!userList.stream().filter(
|
|
|
+ ul->ul.getId().equals(reportLog.getOperatorId())).findFirst().isPresent()?"":userList.stream().filter(
|
|
|
+ ul->ul.getId().equals(reportLog.getOperatorId())).findFirst().get().getName());
|
|
|
+ if(list.contains(String.valueOf(reportId))&&!reportLog.getMsg().contains("提交")){
|
|
|
+ item.add(reportLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("checkLog",item);
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ msg.data=allReportByDate;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
//每天2:11 同步钉钉用户前2天到未来30天时间段的打卡,请假,出差数据
|
|
|
- @Scheduled(cron = "0 48 17 ? * *")
|
|
|
+ @Scheduled(cron = "0 53 15 ? * *")
|
|
|
private void synFanWeiWorkData() {
|
|
|
/*if (isDev) return;*/
|
|
|
List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_fanwei", 1));
|
|
@@ -235,24 +289,50 @@ public class TimingTask {
|
|
|
//Todo: 获取打卡数据
|
|
|
HttpRespMsg workDataMsg = dockWithMLD.getResult("http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getWorkData", jsonString);
|
|
|
List<Map<String,Object>> workDataList= (List<Map<String, Object>>) workDataMsg.data;
|
|
|
- for (Map<String, Object> map : workDataList) {
|
|
|
- UserFvTime userFvTime=new UserFvTime();
|
|
|
- User user = userMapper.selectOne(new QueryWrapper<User>().eq("job_number", map.get("userId")));
|
|
|
- if(user==null){
|
|
|
- continue;
|
|
|
+ List<String> userIds = workDataList.stream().map(map -> String.valueOf(map.get("userId"))).collect(Collectors.toList());
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("job_number", userIds));
|
|
|
+ for (User user : userList) {
|
|
|
+ System.out.println("需要同步的用户列表-----"+userList);
|
|
|
+ LocalTime startTime=null;
|
|
|
+ LocalTime endTime=null;
|
|
|
+ LocalDate workDate=null;
|
|
|
+ for (Map<String, Object> map : workDataList) {
|
|
|
+ if (map.get("userId").equals(user.getJobNumber())) {
|
|
|
+ if(String.valueOf(map.get("signtype")).equals("签到")){
|
|
|
+ startTime=LocalTime.parse(String.valueOf(map.get("signtime")), dtf2);
|
|
|
+ workDate= LocalDate.parse(String.valueOf(map.get("workDate")), dtf);
|
|
|
+ }
|
|
|
+ if(String.valueOf(map.get("signtype")).equals("签退")){
|
|
|
+ endTime=LocalTime.parse(String.valueOf(map.get("signtime")), dtf2);
|
|
|
+ workDate=LocalDate.parse(String.valueOf(map.get("workDate")),dtf);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ UserFvTime userFvTime=new UserFvTime();
|
|
|
+ //获取休息设置
|
|
|
+ TimeAutoExclude timeAutoExclude = timeAutoExcludeMapper.selectOne(new QueryWrapper<TimeAutoExclude>().eq("company_id", user.getCompanyId()));
|
|
|
+ System.out.println("泛微同步人员打卡数据----"+user.getName());
|
|
|
if(compIds.contains(user.getCompanyId())){
|
|
|
- userFvTime.setWorkDate(LocalDate.parse(String.valueOf(map.get("workDate")),dtf));
|
|
|
- LocalTime startTime = LocalTime.parse(String.valueOf(map.get("startTime")), dtf2);
|
|
|
- LocalTime endTime = LocalTime.parse(String.valueOf(map.get("endTime")), dtf2);
|
|
|
- LocalDateTime time1= LocalDate.now().atTime(startTime);
|
|
|
- LocalDateTime time2 = LocalDate.now().atTime(endTime);
|
|
|
- Duration between = Duration.between(time1, time2);
|
|
|
- userFvTime.setStartTime((String) map.get("startTime"));
|
|
|
- userFvTime.setEndTime((String) map.get("endTime"));
|
|
|
+ if(startTime==null||endTime==null){
|
|
|
+ System.out.println("缺少上班或者下班打卡时间----"+user.getName());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ userFvTime.setWorkDate(workDate);
|
|
|
+ Duration between = Duration.between(startTime, endTime);
|
|
|
+ userFvTime.setStartTime(startTime.format(dtf2));
|
|
|
+ userFvTime.setEndTime(endTime.format(dtf2));
|
|
|
userFvTime.setCompanyId(user.getCompanyId());
|
|
|
userFvTime.setUserId(user.getId());
|
|
|
- userFvTime.setWorkHours((float)between.toHours());
|
|
|
+ long workHours = between.toHours();
|
|
|
+ long restHours;
|
|
|
+ if(startTime.isBefore(LocalTime.parse(timeAutoExclude.getStartTime(),dtf2))
|
|
|
+ &&endTime.isAfter(LocalTime.parse(timeAutoExclude.getEndTime(),dtf2))){
|
|
|
+ Duration bt = Duration.between(LocalTime.parse(timeAutoExclude.getStartTime(),dtf2), LocalTime.parse(timeAutoExclude.getEndTime(),dtf2));
|
|
|
+ restHours=bt.toHours();
|
|
|
+ }else {
|
|
|
+ restHours=0;
|
|
|
+ }
|
|
|
+ userFvTime.setWorkHours(BigDecimal.valueOf(workHours).subtract(BigDecimal.valueOf(restHours)).floatValue());
|
|
|
Optional<UserFvTime> first = oldUserFvTimeList.stream().filter(ol -> ol.getWorkDate().isEqual(userFvTime.getWorkDate()) && ol.getUserId().equals(userFvTime.getUserId())).findFirst();
|
|
|
if(first.isPresent()){
|
|
|
userFvTime.setId(first.get().getId());
|
|
@@ -271,6 +351,7 @@ public class TimingTask {
|
|
|
if(user==null){
|
|
|
continue;
|
|
|
}
|
|
|
+ System.out.println("泛微同步人员请假数据----"+user.getName());
|
|
|
if(compIds.contains(user.getCompanyId())){
|
|
|
LeaveSheet leaveSheet=new LeaveSheet();
|
|
|
leaveSheet.setCompanyId(user.getCompanyId());
|
|
@@ -278,7 +359,7 @@ public class TimingTask {
|
|
|
leaveSheet.setOwnerId(user.getId());
|
|
|
leaveSheet.setOwnerName(user.getName());
|
|
|
leaveSheet.setStartDate(LocalDate.parse(String.valueOf(map.get("startDate")),dtf1));
|
|
|
- leaveSheet.setEndDate(LocalDate.parse(String.valueOf(map.get("endtDate")),dtf1));
|
|
|
+ leaveSheet.setEndDate(LocalDate.parse(String.valueOf(map.get("endDate")),dtf1));
|
|
|
Integer timeType=null;
|
|
|
switch (String.valueOf(map.get("timeType"))){
|
|
|
case "小时":timeType=1;
|
|
@@ -336,6 +417,7 @@ public class TimingTask {
|
|
|
if(user==null){
|
|
|
continue;
|
|
|
}
|
|
|
+ System.out.println("泛微同步人员出差数据----"+user.getName());
|
|
|
if(compIds.contains(user.getCompanyId())){
|
|
|
BusinessTrip businessTrip=new BusinessTrip();
|
|
|
businessTrip.setCompanyId(user.getCompanyId());
|
|
@@ -702,7 +784,7 @@ public class TimingTask {
|
|
|
jsonObj.put("value", StringUtils.isEmpty(t.getAlertMsg())?"":t.getAlertMsg());
|
|
|
dataJson.add(jsonObj);
|
|
|
if(isPrivateDeploy){
|
|
|
- json.put("content",StringUtils.isEmpty(t.getAlertMsg())?"":t.getAlertMsg()+"\\n<a href=\\\"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=0#wechat_redirect\\\">去填写</a>");
|
|
|
+ json.put("content",StringUtils.isEmpty(t.getAlertMsg())?"":t.getAlertMsg()+"\\n<a href=\\\"https://open.weixin.qq.com/connect/oauth2/authorize?appid="+corpId+"&redirect_uri=http://"+pcUrl+"/api/corpInsideWXAuth&response_type=code&scope=snsapi_base&state=0#wechat_redirect\\\">去填写</a>");
|
|
|
}else {
|
|
|
json.put("template_id","tty9TkCAAAYoevY-40ciWD5lDncDfR5w");
|
|
|
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=0#wechat_redirect");
|