ソースを参照

出差项目编号获取

QuYueTing 2 週間 前
コミット
d8fd9be416

+ 3 - 4
fhKeeper/formulahousekeeper/collectdata/src/main/java/com/management/collectdata/controller/DataCollectController.java

@@ -478,11 +478,10 @@ public class DataCollectController {
     @RequestMapping("/getBusinessTripDataList")
     public List<BusinessTrip> getBusinessTripDataList(@RequestBody PageBO pageBO) {
         String sqlQuery = "select id,emp_no,emp_name,reason,begin_date,end_date,c_departure_place_city " +
-                " ,c_destination_place_city,trip_day,c_ccxm_no " +
+                " ,c_destination_place_city,trip_day,c_ccxm_name " +
                 " from att_business_trip_order abto " +
                 " where abto.audit_status = 3 and abto.is_delete = 0 and abto.create_date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) order by id limit ?,? ";
 
-        SimpleDateFormat sdfAll = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
         List<BusinessTrip> resList = new ArrayList<>();
         try (Connection connection = mysqlDataSource.getConnection()) {
@@ -494,7 +493,7 @@ public class DataCollectController {
             try (ResultSet resultSet = queryStmt.executeQuery()) {
                 while (resultSet.next()) {
                     BusinessTrip businessTrip = new BusinessTrip();
-                    businessTrip.setCCcxmNo(resultSet.getString("c_ccxm_no"));
+                    businessTrip.setCCcxmNo(resultSet.getString("c_ccxm_name"));
                     businessTrip.setCompanyId(companyId);
                     businessTrip.setWay(4);
                     businessTrip.setOwnerId(resultSet.getString("emp_no"));
@@ -506,7 +505,7 @@ public class DataCollectController {
                     businessTrip.setCityFrom(resultSet.getString("c_departure_place_city"));
                     businessTrip.setCityTo(resultSet.getString("c_destination_place_city"));
                     businessTrip.setDayCount(null==resultSet.getBigDecimal("trip_day")?null:resultSet.getBigDecimal("trip_day").setScale(0,RoundingMode.HALF_UP).intValue());
-                    businessTrip.setIndate(LocalDateTime.now());
+//                    businessTrip.setIndate(LocalDateTime.now());
                     businessTrip.setProcinstId(resultSet.getString("id"));
 
                     resList.add(businessTrip);

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/BusinessTrip.java

@@ -127,8 +127,8 @@ public class BusinessTrip extends Model<BusinessTrip> {
      * 申请时间
      */
     @TableField("indate")
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime indate;
 
     /**

+ 5 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -5333,7 +5333,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             if (WorkDayCalculateUtils.isWorkDay(workDate)) {
                                 Map<String, Object> leaveMap = new HashMap<>();
                                 leaveMap.put("createDate", leaveDateStr);
-                                leaveMap.put("workingTime", MessageUtils.message("leave.leave")+leave.getTimeHours()+"h");
+                                if(leave.getTimeHours() >= timeType.getAllday()){
+                                    leaveMap.put("workingTime", MessageUtils.message("leave.leaveOfDay"));
+                                } else {
+                                    leaveMap.put("workingTime", MessageUtils.message("leave.leave")+leave.getTimeHours()+"h");
+                                }
                                 worktimeList.add(leaveMap);
                             }
                         }

+ 56 - 14
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/DataCollectTask.java

@@ -1,5 +1,6 @@
 package com.management.platform.task;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.*;
@@ -584,6 +585,9 @@ public class DataCollectTask {
                             }
                             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())
@@ -703,7 +707,7 @@ public class DataCollectTask {
     }
 
     @Scheduled(cron = "0 0 3 * * ?")
-//@Scheduled(cron = "0 20 17 * * ?")
+//@Scheduled(cron = "0 57 9 * * ?")
     @Async
     public void businessTripTask(){
         if(isDev){return;}
@@ -724,6 +728,7 @@ public class DataCollectTask {
             } else {
                 System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
             }
+            System.out.println("出差数据:"+totalNum);
             if(totalNum > 0){
                 int pageSize = 1000;
                 int offset = 0;
@@ -757,35 +762,72 @@ public class DataCollectTask {
                             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<String> existIds = businessTripMapper.getExistIds(collect,specialCompanyId);
-                                if(!CollectionUtils.isEmpty(existIds)){
-                                    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);
+                                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);
-                                        BustripProject bustripProject = new BustripProject();
-                                        bustripProject.setBustripId(businessTrip.getId());
-                                        Project project = projectCodeMap.get(businessTrip.getCCcxmNo());
-                                        bustripProject.setProjectId(null == project?null:project.getId());
-                                        bustripProject.setStartDate(businessTrip.getStartDate());
-                                        bustripProject.setEndDate(businessTrip.getEndDate());
-                                        bustripProjectMapper.insert(bustripProject);
+                                        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("出差数据为空");
                         }
 
                     }