|
@@ -1,871 +0,0 @@
|
|
|
-package com.management.platform.task;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.management.platform.controller.ReportController;
|
|
|
-import com.management.platform.entity.*;
|
|
|
-import com.management.platform.entity.vo.TisTimeVO;
|
|
|
-import com.management.platform.mapper.*;
|
|
|
-import com.management.platform.service.*;
|
|
|
-import com.management.platform.util.MessageUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.core.ParameterizedTypeReference;
|
|
|
-import org.springframework.http.*;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-@EnableScheduling
|
|
|
-@Component
|
|
|
-public class DataCollectTask {
|
|
|
-
|
|
|
- @Value("${configEnv.isDev}")
|
|
|
- public boolean isDev;
|
|
|
- //是否是私有化部署
|
|
|
- @Value("${configEnv.isPrivateDeploy}")
|
|
|
- boolean isPrivateDeploy;
|
|
|
- @Resource
|
|
|
- private UserFvTimeMapper userFvTimeMapper;
|
|
|
- @Resource
|
|
|
- private BusinessTripMapper businessTripMapper;
|
|
|
- @Resource
|
|
|
- private LeaveSheetMapper leaveSheetMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private ErpOrderInfoMapper erpOrderInfoMapper;
|
|
|
- @Resource
|
|
|
- private ErpOrderInfoService erpOrderInfoService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private ProjectMapper projectMapper;
|
|
|
- @Resource
|
|
|
- private UserSalaryService userSalaryService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private ProjectCategoryMapper projectCategoryMapper;
|
|
|
-
|
|
|
- public static final String PREFIX_URL = "http://58.210.104.138:10020";
|
|
|
-
|
|
|
- private static final int specialCompanyId = 7536;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private UserMapper userMapper;
|
|
|
- @Resource
|
|
|
- private BustripProjectMapper bustripProjectMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private ReportMapper reportMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private FmwDetailMapper fmwDetailMapper;
|
|
|
- @Resource
|
|
|
- private FinanceMonthlyWorktimeMapper financeMonthlyWorktimeMapper;
|
|
|
- @Resource
|
|
|
- private CompanyMapper companyMapper;
|
|
|
- @Autowired
|
|
|
- private LeaveSheetService leaveSheetService;
|
|
|
-
|
|
|
-
|
|
|
-// private static HikariDataSource sqlServerDataSource;
|
|
|
-//
|
|
|
-// static {
|
|
|
-// HikariConfig sqlServerConfig = new HikariConfig();
|
|
|
-// sqlServerConfig.setJdbcUrl("jdbc:sqlserver://172.168.10.84:1433;databaseName=UFDATA_001_2023;encrypt=true;trustServerCertificate=true");
|
|
|
-// sqlServerConfig.setUsername("zhangyuhua");
|
|
|
-// sqlServerConfig.setPassword("ZC12zyh18");
|
|
|
-// sqlServerConfig.setMaximumPoolSize(5);
|
|
|
-// sqlServerDataSource = new HikariDataSource(sqlServerConfig);
|
|
|
-// }
|
|
|
-
|
|
|
- @Scheduled(cron = "0 30 0 28-31 * ?")
|
|
|
- @Async
|
|
|
- public void caDayTisTask(){
|
|
|
- if(isDev){return;}
|
|
|
- if(isPrivateDeploy) return;
|
|
|
- LocalDate nowDate = LocalDate.now();
|
|
|
- int today = nowDate.getMonthValue();
|
|
|
- int lastDay = Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
- if(today != lastDay){
|
|
|
- return ;
|
|
|
- }
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String insertUrl = PREFIX_URL+"/dataCollect/insertCisData";
|
|
|
- String checkUrl = PREFIX_URL+"/dataCollect/checkCisData";
|
|
|
-// SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- SimpleDateFormat sdfYm = new SimpleDateFormat("yyyy-MM");
|
|
|
- Date date = new Date();
|
|
|
- String dateYm = sdfYm.format(date);
|
|
|
-
|
|
|
- List<FinanceMonthlyWorktime> financeMonthlyWorktimes = financeMonthlyWorktimeMapper.selectList(new LambdaQueryWrapper<FinanceMonthlyWorktime>()
|
|
|
- .eq(FinanceMonthlyWorktime::getCompanyId, specialCompanyId)
|
|
|
- .eq(FinanceMonthlyWorktime::getYmonth, dateYm)
|
|
|
- .eq(FinanceMonthlyWorktime::getStatus, 1)
|
|
|
- );
|
|
|
- if(!CollectionUtils.isEmpty(financeMonthlyWorktimes)){
|
|
|
- List<TisTimeVO> toSendList = new ArrayList<>();
|
|
|
- for (FinanceMonthlyWorktime financeMonthlyWorktime : financeMonthlyWorktimes) {
|
|
|
- String ymd = financeMonthlyWorktime.getTimesheetDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
- List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByFmwId(financeMonthlyWorktime.getId());
|
|
|
- if(!CollectionUtils.isEmpty(timeVOList)){
|
|
|
- timeVOList.forEach(t->t.setDateStr(ymd));
|
|
|
- toSendList.addAll(timeVOList);
|
|
|
- }
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toSendList)){
|
|
|
- //校验cppid
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("toSendList", toSendList);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<TisTimeVO>> checkResponse = restTemplate.exchange(checkUrl, HttpMethod.POST, requestEntity
|
|
|
- ,new ParameterizedTypeReference<List<TisTimeVO>>(){});
|
|
|
- if (checkResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<TisTimeVO> resList = checkResponse.getBody();
|
|
|
- List<TisTimeVO> tmpCheck = resList.stream().filter(t -> null != t.getCoId()).collect(Collectors.toList());
|
|
|
- if(tmpCheck.size() == resList.size()){
|
|
|
- //执行插入操作
|
|
|
- HttpHeaders insertHeaders = new HttpHeaders();
|
|
|
- insertHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> insertBody = new HashMap<>();
|
|
|
- insertBody.put("tisList", resList);
|
|
|
- HttpEntity<Object> insertEntity = new HttpEntity<>(insertBody, insertHeaders);
|
|
|
- ResponseEntity<String> tisResponse = restTemplate.exchange(insertUrl, HttpMethod.POST, insertEntity, String.class);
|
|
|
- if (tisResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- System.out.println("插入成功");
|
|
|
- }else{
|
|
|
- System.out.println("插入失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-// List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByDateYm(specialCompanyId,dateStr);
|
|
|
-// List<TisTimeVO> timeVOList = reportMapper.getTisTimeByDate(specialCompanyId,dateStr);
|
|
|
-
|
|
|
-// for (TisTimeVO tisTimeVO : timeVOList) {
|
|
|
-// String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
|
|
|
-// try (Connection connection = sqlServerDataSource.getConnection()) {
|
|
|
-// PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
|
|
|
-// queryStmt.setString(1,tisTimeVO.getOrderId());
|
|
|
-// queryStmt.setInt(2,tisTimeVO.getLine());
|
|
|
-// ResultSet queryRs = queryStmt.executeQuery();
|
|
|
-// if (queryRs.next()) {
|
|
|
-// tisTimeVO.setCoId(queryRs.getString("iRealCOID"));
|
|
|
-//
|
|
|
-// }
|
|
|
-// } catch (SQLException e) {
|
|
|
-// System.err.println("数据库操作错误: " + e.getMessage());
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// for (TisTimeVO tisTimeVO : timeVOList) {
|
|
|
-// String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
|
|
|
-// try (Connection connection = sqlServerDataSource.getConnection()) {
|
|
|
-// PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
|
|
|
-// queryStmt.setString(1,tisTimeVO.getOrderId());
|
|
|
-// queryStmt.setInt(2,tisTimeVO.getLine());
|
|
|
-// ResultSet queryRs = queryStmt.executeQuery();
|
|
|
-// if (queryRs.next()) {
|
|
|
-// String iRealCOID = queryRs.getString("iRealCOID");
|
|
|
-// String sqlInsert = "insert into CA_DayTiS(cPPID,iRealWkt,dDate) values(?,?,?)";
|
|
|
-// PreparedStatement insertStmt = connection.prepareStatement(sqlInsert);
|
|
|
-// insertStmt.setString(1,iRealCOID);
|
|
|
-// insertStmt.setBigDecimal(2,tisTimeVO.getWorkTime());
|
|
|
-// insertStmt.setString(3,dateStr);
|
|
|
-// int i = insertStmt.executeUpdate();
|
|
|
-// if(i>0){
|
|
|
-// System.out.println("执行成功");
|
|
|
-// }else{
|
|
|
-// System.out.println(iRealCOID+"执行失败");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } catch (SQLException e) {
|
|
|
-// System.err.println("数据库操作错误: " + e.getMessage());
|
|
|
-// }
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
-// @Scheduled(cron = "0 0 11 * * ?")
|
|
|
- @Async
|
|
|
- public void sqlServerTask() {
|
|
|
- if(isDev){return;}
|
|
|
- if(isPrivateDeploy) return;
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerDataSum";
|
|
|
- String listUrl = PREFIX_URL+"/dataCollect/getSqlServerDataList";
|
|
|
-
|
|
|
- try {
|
|
|
- ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
- sumUrl,
|
|
|
- HttpMethod.GET,
|
|
|
- null,
|
|
|
- String.class
|
|
|
- );
|
|
|
- Integer totalNum = 0;
|
|
|
- if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
- } else {
|
|
|
- System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
- }
|
|
|
- System.out.println("总数量为==== "+totalNum);
|
|
|
- if(totalNum > 0){
|
|
|
- int pageSize = 1000;
|
|
|
- int offset = 0;
|
|
|
- List<ErpOrderInfo> toAddList = new ArrayList<>();
|
|
|
- List<ErpOrderInfo> toUpdateList = new ArrayList<>();
|
|
|
- while (offset < totalNum) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("pageNo", offset);
|
|
|
- requestBody.put("pageSize", pageSize);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<ErpOrderInfo>> listResponse = restTemplate.exchange(
|
|
|
- listUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- new ParameterizedTypeReference<List<ErpOrderInfo>>(){}
|
|
|
- );
|
|
|
- if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- //dataList中是进行中的工单
|
|
|
- List<ErpOrderInfo> dataList = listResponse.getBody();
|
|
|
- List<ErpOrderInfo> erpOrderInfos = erpOrderInfoMapper.selectList(new LambdaQueryWrapper<ErpOrderInfo>());
|
|
|
- List<ErpOrderInfo> closeInfoList = new ArrayList<>();
|
|
|
- List<String> collect = dataList.stream().map(ErpOrderInfo::getMoDId).collect(Collectors.toList());
|
|
|
- if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
- for (ErpOrderInfo item : dataList) {
|
|
|
- Optional<ErpOrderInfo> first = erpOrderInfos.stream().filter(t -> t.getMoDId().equals(item.getMoDId())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- item.setId(first.get().getId());
|
|
|
- toUpdateList.add(item);
|
|
|
- } else {
|
|
|
- toAddList.add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
- erpOrderInfoMapper.batchInsert(toAddList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
- erpOrderInfoService.updateBatchById(toUpdateList);
|
|
|
- }
|
|
|
- toUpdateList.clear();
|
|
|
- toAddList.clear();
|
|
|
- erpOrderInfos.stream().filter(t -> !collect.contains(t.getMoDId())).forEach(t -> closeInfoList.add(new ErpOrderInfo().setId(t.getId()).setStatus(4)));
|
|
|
- if(!CollectionUtils.isEmpty(closeInfoList)){
|
|
|
- erpOrderInfoService.updateBatchById(closeInfoList);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //全部关闭
|
|
|
- erpOrderInfoMapper.update(new ErpOrderInfo().setStatus(4), new QueryWrapper<ErpOrderInfo>());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- offset += pageSize;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("请求发生异常: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Scheduled(cron = "0 30 1 * * ?")
|
|
|
-//@Scheduled(cron = "0 42 16 * * ?")
|
|
|
- public void workDayTask(){
|
|
|
- if(isDev){return;}
|
|
|
- if(isPrivateDeploy) return;
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String sumUrl = PREFIX_URL+"/dataCollect/getWorkDayDataSum";
|
|
|
- String listUrl = PREFIX_URL+"/dataCollect/getWorkDayDataList";
|
|
|
-
|
|
|
- try {
|
|
|
- ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
- sumUrl,
|
|
|
- HttpMethod.GET,
|
|
|
- null,
|
|
|
- String.class
|
|
|
- );
|
|
|
- Integer totalNum = 0;
|
|
|
- if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
- } else {
|
|
|
- System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
- }
|
|
|
- if(totalNum > 0){
|
|
|
- int pageSize = 1000;
|
|
|
- int offset = 0;
|
|
|
- List<UserFvTime> toAddList = new ArrayList<>();
|
|
|
- List<UserFvTime> toUpdateList = new ArrayList<>();
|
|
|
- List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, specialCompanyId));
|
|
|
- Map<String, User> userMap = users.stream().filter(t -> StringUtils.isNotBlank(t.getJobNumber()))
|
|
|
- .collect(Collectors.toMap(User::getJobNumber, t -> t));
|
|
|
- while (offset < totalNum) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("pageNo", offset);
|
|
|
- requestBody.put("pageSize", pageSize);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<UserFvTime>> listResponse = restTemplate.exchange(
|
|
|
- listUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- new ParameterizedTypeReference<List<UserFvTime>>(){}
|
|
|
- );
|
|
|
- if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<UserFvTime> dataList = listResponse.getBody();
|
|
|
- if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
- for (UserFvTime userFvTime : dataList) {
|
|
|
- if(StringUtils.isBlank(userFvTime.getProcinstId())){
|
|
|
- System.out.println(userFvTime);
|
|
|
- }
|
|
|
- User tmp = userMap.get(userFvTime.getUserId());
|
|
|
- if(null == tmp){
|
|
|
- System.out.println("缺失id=== "+userFvTime.getUserId()+",缺失名字=== "+userFvTime.getName());
|
|
|
- }
|
|
|
- userFvTime.setUserId(null==tmp?null:tmp.getId());
|
|
|
- }
|
|
|
- List<UserFvTime> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getUserId())).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(realDataList)){
|
|
|
- List<String> collect = realDataList.stream().map(UserFvTime::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
- List<UserFvTime> existList = userFvTimeMapper.selectList(new LambdaQueryWrapper<UserFvTime>().in(UserFvTime::getProcinstId, collect).eq(UserFvTime::getCompanyId, specialCompanyId));
|
|
|
- for (UserFvTime tmp : realDataList) {
|
|
|
- Optional<UserFvTime> first = existList.stream().filter(t -> t.getProcinstId().equals(tmp.getProcinstId())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- tmp.setId(first.get().getId());
|
|
|
- toUpdateList.add(tmp);
|
|
|
- } else {
|
|
|
- toAddList.add(tmp);
|
|
|
- }
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
- userFvTimeMapper.batchInsertCollect(toAddList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
- for (UserFvTime tmp : toUpdateList) {
|
|
|
- userFvTimeMapper.updateById(tmp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- toUpdateList.clear();
|
|
|
- toAddList.clear();
|
|
|
- offset += pageSize;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("请求发生异常: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Scheduled(cron = "0 0 2 * * ?")
|
|
|
-//@Scheduled(cron = "30 35 15 * * ?")
|
|
|
- @Async
|
|
|
- public void leaveSheetTask(){
|
|
|
- if(isDev){return;}
|
|
|
- if(isPrivateDeploy) return;
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String sumUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataSum";
|
|
|
- String listUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataList";
|
|
|
-
|
|
|
- try {
|
|
|
- ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
- sumUrl,
|
|
|
- HttpMethod.GET,
|
|
|
- null,
|
|
|
- String.class
|
|
|
- );
|
|
|
- Integer totalNum = 0;
|
|
|
- if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
- } else {
|
|
|
- System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
- }
|
|
|
- if(totalNum > 0){
|
|
|
- int pageSize = 1000;
|
|
|
- int offset = 0;
|
|
|
- List<LeaveSheet> toAddList = new ArrayList<>();
|
|
|
- List<LeaveSheet> toUpdateList = new ArrayList<>();
|
|
|
- List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, specialCompanyId));
|
|
|
- Map<String, User> userMap = users.stream().filter(t -> StringUtils.isNotBlank(t.getJobNumber()))
|
|
|
- .collect(Collectors.toMap(User::getJobNumber, t -> t));
|
|
|
- while (offset < totalNum) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("pageNo", offset);
|
|
|
- requestBody.put("pageSize", pageSize);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<LeaveSheet>> listResponse = restTemplate.exchange(
|
|
|
- listUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- new ParameterizedTypeReference<List<LeaveSheet>>(){}
|
|
|
- );
|
|
|
- if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<LeaveSheet> dataList = listResponse.getBody();
|
|
|
- if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
- for (LeaveSheet leaveSheet : dataList) {
|
|
|
- User ownerTmp = userMap.get(leaveSheet.getOwnerId());
|
|
|
- User opTmp = userMap.get(leaveSheet.getOperatorId());
|
|
|
- leaveSheet.setOwnerId(null==ownerTmp?null:ownerTmp.getId());
|
|
|
- leaveSheet.setOperatorId(null==opTmp?null:opTmp.getId());
|
|
|
- if(null != ownerTmp && null != opTmp){
|
|
|
- leaveSheet.setOperatorId(ownerTmp.getId());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- List<LeaveSheet> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getOwnerId())).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(realDataList)){
|
|
|
- List<String> collect = realDataList.stream().map(LeaveSheet::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
- List<LeaveSheet> existLeaveSheetList = leaveSheetMapper.selectList(new LambdaQueryWrapper<LeaveSheet>().in(LeaveSheet::getProcinstId, collect).eq(LeaveSheet::getCompanyId, specialCompanyId));
|
|
|
-// List<String> existIds = existLeaveSheetList.stream().map(LeaveSheet::getProcinstId).collect(Collectors.toList());
|
|
|
-// List<String> existIds = leaveSheetMapper.getExistIds(collect,specialCompanyId);
|
|
|
- for (LeaveSheet tmp : realDataList) {
|
|
|
- Optional<LeaveSheet> first = existLeaveSheetList.stream().filter(t -> t.getProcinstId().equals(tmp.getProcinstId())).findFirst();
|
|
|
- if (first.isPresent()) {
|
|
|
- tmp.setId(first.get().getId());
|
|
|
- toUpdateList.add(tmp);
|
|
|
- } else {
|
|
|
- toAddList.add(tmp);
|
|
|
- }
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
- leaveSheetMapper.batchInsert(toAddList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
- leaveSheetService.updateBatchById(toUpdateList);
|
|
|
- }
|
|
|
- //自动生成审核通过的请假工时日报
|
|
|
- for (LeaveSheet tmp : realDataList) {
|
|
|
- //获取某人每天请假的时长合计
|
|
|
- String ownerId = tmp.getOwnerId();
|
|
|
- User owner = userMapper.selectById(ownerId);
|
|
|
- //停用的用户不生成日报
|
|
|
- if (owner.getIsActive() == 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- Project project = projectMapper.selectOne(new QueryWrapper<Project>().eq("project_code", "HH-QJ-0000001").eq("company_id", specialCompanyId));
|
|
|
- TaskGroup leaveGroup = taskGroupMapper.selectOne(new LambdaQueryWrapper<TaskGroup>().eq(TaskGroup::getProjectId, project.getId()).eq(TaskGroup::getName, "请假工时"));
|
|
|
- for (LocalDate date = tmp.getStartDate(); date.compareTo(tmp.getEndDate()) <= 0; date = date.plusDays(1)) {
|
|
|
- //先计算每一天的请假工时数合计
|
|
|
- List<LeaveSheet> leaveSheetList = leaveSheetMapper.selectList(new LambdaQueryWrapper<LeaveSheet>()
|
|
|
- .eq(LeaveSheet::getOwnerId, ownerId)
|
|
|
- .eq(LeaveSheet::getCompanyId, specialCompanyId)
|
|
|
- .le(LeaveSheet::getStartDate, date).ge(LeaveSheet::getEndDate, date));
|
|
|
- if (!CollectionUtils.isEmpty(leaveSheetList)) {
|
|
|
- double leaveHours = leaveSheetList.stream().mapToDouble(LeaveSheet::getTimeHours).sum();
|
|
|
- if (leaveHours > 0) {
|
|
|
- //跨天请假的
|
|
|
- if (leaveHours > 8.0) {
|
|
|
- leaveHours = 8.0;
|
|
|
- }
|
|
|
- //检查当天是否已经生成了请假工时的日报
|
|
|
- List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("company_id", specialCompanyId).eq("project_id", project.getId()).eq("create_date", date).eq("creator_id", ownerId));
|
|
|
- //取第一条
|
|
|
- Report oneReport = reportList.size() > 0?reportList.get(0):new Report();
|
|
|
- if (oneReport.getId() != null) {
|
|
|
- if (!oneReport.getWorkingTime().equals(leaveHours)) {
|
|
|
- //更新时长
|
|
|
- reportMapper.updateById(new Report().setId(oneReport.getId()).setWorkingTime(leaveHours));
|
|
|
- }
|
|
|
- } else {
|
|
|
- //生成请假工时的日报
|
|
|
- Report report = new Report();
|
|
|
- report.setProjectId(project.getId());
|
|
|
- report.setGroupId(leaveGroup.getId());
|
|
|
- report.setReportTimeType(1);
|
|
|
- report.setMultiWorktime(0);
|
|
|
- report.setContent("请假");
|
|
|
- report.setState(1);//自动生成的审核通过
|
|
|
- report.setCompanyId(specialCompanyId);
|
|
|
- report.setStage("-");
|
|
|
- report.setCreateDate(date);
|
|
|
- report.setCreatorId(ownerId);
|
|
|
- report.setDeptId(owner.getDepartmentId());
|
|
|
- report.setProjectAuditState(0);
|
|
|
- report.setWorkingTime(leaveHours);
|
|
|
-
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
- DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- BigDecimal hourCost = null;
|
|
|
- if (owner.getCostApplyDate() != null) {
|
|
|
- //检查有效期
|
|
|
- if (owner.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
|
|
|
- //取上一个历史成本
|
|
|
- List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", owner.getId()).orderByDesc("indate").last("limit 2"));
|
|
|
- if (list.size() > 1) {
|
|
|
- hourCost = list.get(1).getCost();
|
|
|
- } else {
|
|
|
- //没有记录,又没有达到预设的起效时间,则默认为0
|
|
|
- hourCost = new BigDecimal(0);
|
|
|
- }
|
|
|
- } else {
|
|
|
- hourCost = owner.getCost();
|
|
|
- }
|
|
|
- } else {
|
|
|
- hourCost = owner.getCost();
|
|
|
- }
|
|
|
- if (hourCost == null) {
|
|
|
- hourCost = new BigDecimal(0);
|
|
|
- }
|
|
|
- //计算工时和成本
|
|
|
- report.setCost(hourCost.multiply(new BigDecimal(leaveHours)));
|
|
|
- reportMapper.insert(report);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- toUpdateList.clear();
|
|
|
- toAddList.clear();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- offset += pageSize;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("请求发生异常: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Scheduled(cron = "0 30 3 * * ?")
|
|
|
-//@Scheduled(cron = "0 12 16 * * ?")
|
|
|
- @Async
|
|
|
- public void sqlServerProjectTask() {
|
|
|
- if(isDev){return;}
|
|
|
- if(isPrivateDeploy) return;
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataSum";
|
|
|
- String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataList";
|
|
|
- Company company = companyMapper.selectById(specialCompanyId);
|
|
|
- try {
|
|
|
- ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
- sumUrl,
|
|
|
- HttpMethod.GET,
|
|
|
- null,
|
|
|
- String.class
|
|
|
- );
|
|
|
- Integer totalNum = 0;
|
|
|
- if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
- } else {
|
|
|
- System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
- }
|
|
|
- if(totalNum > 0){
|
|
|
- int pageSize = 1000;
|
|
|
- int offset = 0;
|
|
|
- List<Project> toAddList = new ArrayList<>();
|
|
|
- List<Project> toUpdateList = new ArrayList<>();
|
|
|
- while (offset < totalNum) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("pageNo", offset);
|
|
|
- requestBody.put("pageSize", pageSize);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<Project>> listResponse = restTemplate.exchange(
|
|
|
- listUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- new ParameterizedTypeReference<List<Project>>(){}
|
|
|
- );
|
|
|
- if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<Project> dataList = listResponse.getBody();
|
|
|
- if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
- List<String> collect = dataList.stream().map(Project::getProjectCode).distinct().collect(Collectors.toList());
|
|
|
- List<String> existIds = projectMapper.getExistIds(collect,specialCompanyId);
|
|
|
- if(!CollectionUtils.isEmpty(existIds)){
|
|
|
- toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProjectCode())).collect(Collectors.toList()));
|
|
|
- toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProjectCode())).collect(Collectors.toList()));
|
|
|
- }else{
|
|
|
- toAddList.addAll(dataList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
- for (Project project : toAddList) {
|
|
|
- //以项目编码前五为作为分类名称
|
|
|
- String categoryName = project.getProjectCode().substring(0,5);
|
|
|
- project.setCategoryName(categoryName);
|
|
|
- ProjectCategory category = projectCategoryMapper.selectOne(new LambdaQueryWrapper<ProjectCategory>()
|
|
|
- .eq(ProjectCategory::getCompanyId, specialCompanyId)
|
|
|
- .eq(ProjectCategory::getName, project.getCategoryName())
|
|
|
- .last(" limit 1 ")
|
|
|
- );
|
|
|
- int categoryId;
|
|
|
- if(null != category){
|
|
|
- categoryId = category.getId();
|
|
|
- }else{
|
|
|
- ProjectCategory tmp = new ProjectCategory();
|
|
|
- tmp.setName(project.getCategoryName());
|
|
|
- tmp.setCompanyId(specialCompanyId);
|
|
|
- projectCategoryMapper.insert(tmp);
|
|
|
- categoryId = tmp.getId();
|
|
|
- }
|
|
|
- if(0!= categoryId){
|
|
|
- project.setCategory(categoryId);
|
|
|
- projectMapper.insert(project);
|
|
|
- if (company.getPackageProject() == 1) {
|
|
|
- initGroup(specialCompanyId,project.getId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-// projectMapper.batchInsert(toAddList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
- for (Project orderInfo : toUpdateList) {
|
|
|
- projectMapper.updateById(orderInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- toUpdateList.clear();
|
|
|
- toAddList.clear();
|
|
|
- }
|
|
|
- }
|
|
|
- offset += pageSize;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("请求发生异常: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Resource
|
|
|
- private GroupTemplateMapper groupTemplateMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private GroupTmpstagesMapper groupTmpstagesMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private StagesService stagesService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private GtemplateTaskMapper gtemplateTaskMapper;
|
|
|
- @Resource
|
|
|
- private TaskGroupMapper taskGroupMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private TaskService taskService;
|
|
|
-
|
|
|
- public void initGroup(Integer companyId, Integer projectId) {
|
|
|
- User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
|
|
|
- .eq(User::getRoleName, "超级管理员")
|
|
|
- .last(" limit 1")
|
|
|
- );
|
|
|
- List<GroupTemplate> groupTemplates = groupTemplateMapper.selectList(new QueryWrapper<GroupTemplate>()
|
|
|
- .eq("company_id", companyId).eq("cre_with_pro", true));
|
|
|
- if (groupTemplates.size()==0){
|
|
|
- //创建默认分组
|
|
|
- TaskGroup group = new TaskGroup();
|
|
|
- group.setProjectId(projectId);
|
|
|
- //group.setName("项目阶段");
|
|
|
- group.setName(MessageUtils.message("entry.projectStage"));
|
|
|
- taskGroupMapper.insert(group);
|
|
|
- }else{
|
|
|
- for (GroupTemplate groupTemplate : groupTemplates) {
|
|
|
- TaskGroup group = new TaskGroup();
|
|
|
- group.setProjectId(projectId);
|
|
|
- group.setName(groupTemplate.getName());
|
|
|
- taskGroupMapper.insert(group);
|
|
|
- //从模板创建任务列表
|
|
|
- List<GroupTmpstages> stages = groupTmpstagesMapper.selectList(new QueryWrapper<GroupTmpstages>().eq("template_id", groupTemplate.getId()));
|
|
|
- List<Stages> batchList = new ArrayList<>();
|
|
|
- stages.forEach(s->{
|
|
|
- Stages stageItem = new Stages();
|
|
|
- stageItem.setGroupId(group.getId());
|
|
|
- stageItem.setStagesName(s.getStagesName());
|
|
|
- stageItem.setSequence(s.getSequence());
|
|
|
- stageItem.setProjectId(projectId);
|
|
|
- batchList.add(stageItem);
|
|
|
- });
|
|
|
- stagesService.saveBatch(batchList);
|
|
|
- //阶段的任务,里程碑,风险
|
|
|
- List<GtemplateTask> gtemplateTaskList = gtemplateTaskMapper.selectList(
|
|
|
- new QueryWrapper<GtemplateTask>().eq("gtemplate_id", groupTemplate.getId())
|
|
|
- .orderByAsc("seq"));
|
|
|
- if (gtemplateTaskList.size() > 0) {
|
|
|
- List<Task> taskList = new ArrayList<>();
|
|
|
- gtemplateTaskList.forEach(gt->{
|
|
|
- Task task = gt.toTask();
|
|
|
- task.setProjectId(projectId);
|
|
|
- task.setGroupId(group.getId());
|
|
|
- String sName = stages.stream().filter(s->s.getId().equals(gt.getTstagesId())).findFirst().get().getStagesName();
|
|
|
- Integer realStageId = batchList.stream().filter(bat->bat.getStagesName().equals(sName)).findFirst().get().getId();
|
|
|
- task.setStagesId(realStageId);
|
|
|
- task.setCreaterId(user.getId());
|
|
|
- task.setCreaterName(user.getName());
|
|
|
- task.setCreatorColor(user.getColor());
|
|
|
- taskList.add(task);
|
|
|
- });
|
|
|
- taskService.saveBatch(taskList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Scheduled(cron = "0 0 3 * * ?")
|
|
|
-//@Scheduled(cron = "0 57 9 * * ?")
|
|
|
- @Async
|
|
|
- public void businessTripTask(){
|
|
|
- if(isDev){return;}
|
|
|
- if(isPrivateDeploy) return;
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String sumUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataSum";
|
|
|
- String listUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataList";
|
|
|
-
|
|
|
- try {
|
|
|
- ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
- sumUrl,
|
|
|
- HttpMethod.GET,
|
|
|
- null,
|
|
|
- String.class
|
|
|
- );
|
|
|
- Integer totalNum = 0;
|
|
|
- if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
- } else {
|
|
|
- System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
- }
|
|
|
- System.out.println("出差数据:"+totalNum);
|
|
|
- if(totalNum > 0){
|
|
|
- int pageSize = 1000;
|
|
|
- int offset = 0;
|
|
|
- List<BusinessTrip> toAddList = new ArrayList<>();
|
|
|
- List<BusinessTrip> toUpdateList = new ArrayList<>();
|
|
|
- List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, specialCompanyId));
|
|
|
- Map<String, User> userMap = users.stream().filter(t -> StringUtils.isNotBlank(t.getJobNumber()))
|
|
|
- .collect(Collectors.toMap(User::getJobNumber, t -> t));
|
|
|
- List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>().eq(Project::getCompanyId, specialCompanyId));
|
|
|
- Map<String, Project> projectCodeMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode, t -> t));
|
|
|
- while (offset < totalNum) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("pageNo", offset);
|
|
|
- requestBody.put("pageSize", pageSize);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<BusinessTrip>> listResponse = restTemplate.exchange(
|
|
|
- listUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- new ParameterizedTypeReference<List<BusinessTrip>>(){}
|
|
|
- );
|
|
|
- if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<BusinessTrip> dataList = listResponse.getBody();
|
|
|
- if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
- for (BusinessTrip businessTrip : dataList) {
|
|
|
- User ownerTmp = userMap.get(businessTrip.getOwnerId());
|
|
|
- businessTrip.setOwnerId(null==ownerTmp?null:ownerTmp.getId());
|
|
|
- }
|
|
|
- List<BusinessTrip> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getOwnerId())).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(realDataList)){
|
|
|
- List<String> collect = realDataList.stream().map(BusinessTrip::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
- List<BusinessTrip> existBTripList = businessTripMapper.selectList(new QueryWrapper<BusinessTrip>().in("procinst_id", collect));
|
|
|
- for (BusinessTrip businessTrip : realDataList) {
|
|
|
- if (existBTripList.stream().anyMatch(t -> t.getProcinstId().equals(businessTrip.getProcinstId()))) {
|
|
|
- businessTrip.setId(existBTripList.stream().filter(t -> t.getProcinstId().equals(businessTrip.getProcinstId())).findFirst().get().getId());
|
|
|
- toUpdateList.add(businessTrip);
|
|
|
- } else {
|
|
|
- toAddList.add(businessTrip);
|
|
|
- }
|
|
|
- }
|
|
|
-// if(existBTripList.size() > 0){
|
|
|
-// toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
-// toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
-// }else{
|
|
|
-// toAddList.addAll(realDataList);
|
|
|
-// }
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
-// businessTripMapper.batchInsert(toAddList);
|
|
|
- for (BusinessTrip businessTrip : toAddList) {
|
|
|
- businessTripMapper.insert(businessTrip);
|
|
|
- if (!StringUtils.isEmpty(businessTrip.getCCcxmNo())) {
|
|
|
- String[] split = businessTrip.getCCcxmNo().split(",");
|
|
|
- for (String s : split) {
|
|
|
- Project project = projectCodeMap.get(s);
|
|
|
- if (project != null) {
|
|
|
- BustripProject bustripProject = new BustripProject();
|
|
|
- bustripProject.setBustripId(businessTrip.getId());
|
|
|
- bustripProject.setProjectId(project.getId());
|
|
|
- bustripProject.setStartDate(businessTrip.getStartDate());
|
|
|
- bustripProject.setEndDate(businessTrip.getEndDate());
|
|
|
- bustripProjectMapper.insert(bustripProject);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
- for (BusinessTrip tmp : toUpdateList) {
|
|
|
- businessTripMapper.updateById(tmp);
|
|
|
- //检查出差项目
|
|
|
- if (!StringUtils.isEmpty(tmp.getCCcxmNo())) {
|
|
|
- String[] split = tmp.getCCcxmNo().split(",");
|
|
|
- for (String s : split) {
|
|
|
- Project project = projectCodeMap.get(s);
|
|
|
- if (project != null) {
|
|
|
- //查找是否已经存在
|
|
|
- BustripProject existBustripProject = bustripProjectMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<BustripProject>().eq(BustripProject::getBustripId, tmp.getId()).eq(BustripProject::getProjectId, project.getId()).between(BustripProject::getStartDate, tmp.getStartDate(), tmp.getEndDate()));
|
|
|
- if (existBustripProject == null) {
|
|
|
- BustripProject bustripProject = new BustripProject();
|
|
|
- bustripProject.setBustripId(tmp.getId());
|
|
|
- bustripProject.setProjectId(project.getId());
|
|
|
- bustripProject.setStartDate(tmp.getStartDate());
|
|
|
- bustripProject.setEndDate(tmp.getEndDate());
|
|
|
- bustripProjectMapper.insert(bustripProject);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- toUpdateList.clear();
|
|
|
- toAddList.clear();
|
|
|
- } else {
|
|
|
- System.out.println("出差数据为空");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- offset += pageSize;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("请求发生异常: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|