|
@@ -6,10 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.injector.methods.SelectById;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
-import com.management.platform.service.CompanyDingdingService;
|
|
|
-import com.management.platform.service.DingDingService;
|
|
|
-import com.management.platform.service.ThirdPartyInterfaceService;
|
|
|
-import com.management.platform.service.WxCorpInfoService;
|
|
|
+import com.management.platform.service.*;
|
|
|
+import com.management.platform.util.DockWithMLD;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.RedisUtil;
|
|
|
import com.management.platform.util.WorkDayCalculateUtils;
|
|
|
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
|
@@ -32,11 +31,9 @@ import org.springframework.web.client.RestTemplate;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.LocalTime;
|
|
|
-import java.time.Period;
|
|
|
+import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAccessor;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -107,6 +104,12 @@ public class TimingTask {
|
|
|
private ThirdPartyInterfaceMapper thirdPartyInterfaceMapper;
|
|
|
@Resource
|
|
|
private ThirdPartyInterfaceService thirdPartyInterfaceService;
|
|
|
+ @Resource
|
|
|
+ private UserFvTimeService userFvTimeService;
|
|
|
+ @Resource
|
|
|
+ private LeaveSheetService leaveSheetService;
|
|
|
+ @Resource
|
|
|
+ private BusinessTripService businessTripService;
|
|
|
|
|
|
private static final List<Integer> VALID_TOKEN_CHARS = new ArrayList<>();
|
|
|
static {
|
|
@@ -186,6 +189,104 @@ public class TimingTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //每天2:11 同步钉钉用户前2天到未来30天时间段的打卡,请假,出差数据
|
|
|
+ @Scheduled(cron = "0 30 2 ? * *")
|
|
|
+ private void synFanWeiWorkData() {
|
|
|
+ if (isDev) return;
|
|
|
+ List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_fanwei", 1));
|
|
|
+ List<Integer> compIds = timeTypeList.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
|
|
|
+ if(compIds.size()<0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DockWithMLD dockWithMLD=new DockWithMLD();
|
|
|
+ JSONObject jsonObject=new JSONObject();
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
+ LocalDateTime yesterday = LocalDateTime.now().minusDays(2);
|
|
|
+ String startDate = dtf.format(yesterday);
|
|
|
+ String endDate = dtf.format(yesterday.plusDays(32));
|
|
|
+ jsonObject.put("startDate",startDate);
|
|
|
+ jsonObject.put("endDate",endDate);
|
|
|
+ String jsonString = jsonObject.toJSONString();
|
|
|
+ List<UserFvTime> userFvTimeList=new ArrayList<>();
|
|
|
+ List<LeaveSheet> leaveSheetList=new ArrayList<>();
|
|
|
+ List<BusinessTrip> businessTripList=new ArrayList<>();
|
|
|
+ //Todo: 获取打卡数据
|
|
|
+ HttpRespMsg workDataMsg = dockWithMLD.getResult("http://10.1.10.41:20170/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;
|
|
|
+ }
|
|
|
+ if(compIds.contains(user.getCompanyId())){
|
|
|
+ userFvTime.setWorkDate((LocalDate) map.get("workDate"));
|
|
|
+ LocalTime startTime = LocalTime.parse(String.valueOf(map.get("startTime")), dtf2);
|
|
|
+ LocalTime endTime = LocalTime.parse(String.valueOf(map.get("startTime")), dtf2);
|
|
|
+ Duration between = Duration.between(startTime, endTime);
|
|
|
+ userFvTime.setStartTime((String) map.get("startTime"));
|
|
|
+ userFvTime.setEndTime((String) map.get("endTime"));
|
|
|
+ userFvTime.setCompanyId(user.getCompanyId());
|
|
|
+ userFvTime.setUserId(user.getId());
|
|
|
+ userFvTime.setWorkHours((float) between.toHours());
|
|
|
+ userFvTimeList.add(userFvTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userFvTimeService.saveBatch(userFvTimeList);
|
|
|
+ //Todo: 获取请假数据
|
|
|
+ HttpRespMsg leaveRecordMsg = dockWithMLD.getResult("http://10.1.10.41:20170/api/cube/restful/interface/getModeDataPageList/getLeaveRecord", jsonString);
|
|
|
+ List<Map<String,Object>> leaveRecordList= (List<Map<String, Object>>) leaveRecordMsg.data;
|
|
|
+ for (Map<String, Object> map : leaveRecordList) {
|
|
|
+ User user = userMapper.selectOne(new QueryWrapper<User>().eq("job_number", map.get("userId")));
|
|
|
+ if(user==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(compIds.contains(user.getCompanyId())){
|
|
|
+ LeaveSheet leaveSheet=new LeaveSheet();
|
|
|
+ leaveSheet.setCompanyId(user.getCompanyId());
|
|
|
+ leaveSheet.setStatus(0);
|
|
|
+ leaveSheet.setOwnerId(user.getId());
|
|
|
+ leaveSheet.setOwnerName(user.getName());
|
|
|
+ leaveSheet.setStartDate(LocalDate.parse(String.valueOf(map.get("startDate")),dtf));
|
|
|
+ leaveSheet.setEndDate(LocalDate.parse(String.valueOf(map.get("endDate")),dtf));
|
|
|
+ leaveSheet.setTimeType(Integer.parseInt(String.valueOf(map.get("timeType"))));
|
|
|
+ leaveSheet.setTimeDays((Float) map.get("timeDays"));
|
|
|
+ leaveSheet.setTimeHours((Float) map.get("timeHours"));
|
|
|
+ leaveSheet.setLeaveType(Integer.parseInt(String.valueOf(map.get("leaveType"))));
|
|
|
+ leaveSheet.setProcinstId(String.valueOf(map.get("procinstId")));
|
|
|
+ leaveSheet.setGmtFinished(String.valueOf(map.get("gmtFinished")));
|
|
|
+ leaveSheetList.add(leaveSheet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ leaveSheetService.saveBatch(leaveSheetList);
|
|
|
+ //Todo: 获取出差数据
|
|
|
+ HttpRespMsg travelRecordMsg = dockWithMLD.getResult("http://10.1.10.41:20170/api/cube/restful/interface/getModeDataPageList/getTravelRecord", jsonString);
|
|
|
+ List<Map<String,Object>> travelRecordList= (List<Map<String, Object>>) travelRecordMsg.data;
|
|
|
+ for (Map<String, Object> map : travelRecordList) {
|
|
|
+ User user = userMapper.selectOne(new QueryWrapper<User>().eq("job_number", map.get("userId")));
|
|
|
+ if(user==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(compIds.contains(user.getCompanyId())){
|
|
|
+ BusinessTrip businessTrip=new BusinessTrip();
|
|
|
+ businessTrip.setCompanyId(user.getCompanyId());
|
|
|
+ businessTrip.setStartDate(LocalDate.parse(String.valueOf(map.get("startDate")),dtf));
|
|
|
+ businessTrip.setEndDate(LocalDate.parse(String.valueOf(map.get("endDate")),dtf));
|
|
|
+ businessTrip.setWay(Integer.valueOf(String.valueOf(map.get("way"))));
|
|
|
+ businessTrip.setCityFrom((String) map.get("cityFrom"));
|
|
|
+ businessTrip.setCityTo((String) map.get("cityTo"));
|
|
|
+ businessTrip.setGoBack(Integer.valueOf(String.valueOf(map.get("goBack"))));
|
|
|
+ businessTrip.setDayCount(Integer.valueOf(String.valueOf(map.get("dayCount"))));
|
|
|
+ businessTrip.setProcinstId((String) map.get("procinstId"));
|
|
|
+ businessTrip.setGmtFinished((String)map.get("gmtFinished"));
|
|
|
+ businessTripList.add(businessTrip);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ businessTripService.saveBatch(businessTripList);
|
|
|
+ }
|
|
|
+
|
|
|
//每天1:00 同步昨天的微信请假信息
|
|
|
@Scheduled(cron = "0 0 1 ? * *")
|
|
|
private void synWxLeave() throws Exception {
|
|
@@ -314,6 +415,7 @@ public class TimingTask {
|
|
|
@Scheduled(fixedRate = 1800 * 1000)
|
|
|
public void pushToken(){
|
|
|
if(isDev) return;
|
|
|
+ if(isPrivateDeploy)return;
|
|
|
int passwordLength = 30;
|
|
|
LocalDateTime localDateTime=LocalDateTime.now();
|
|
|
List<ThirdPartyInterface> thirdPartyInterfaceList = thirdPartyInterfaceMapper.selectList(null);
|