QuYueTing 2 日 前
コミット
2803cfb291

+ 22 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DingDingServiceImpl.java

@@ -2277,7 +2277,7 @@ public class DingDingServiceImpl implements DingDingService {
         try {
             rsp = client.execute(req, accessToken);
             if (rsp.getErrcode() == 0) {
-                System.out.println(rsp.getBody());
+//                System.out.println("获取考勤数据="+rsp.getBody());
                 //正常
                 JSONArray array = JSONObject.parseObject(rsp.getBody()).getJSONArray("recordresult");
                 List<DdingCardTimeItem> list = new ArrayList<DdingCardTimeItem>();
@@ -2317,6 +2317,26 @@ public class DingDingServiceImpl implements DingDingService {
                         Optional<DdingCardTimeItem> find = oneDayTimes.stream().filter(p->"OnDuty".equals(p.getCheckType())).min(comparator);
                         if (find.isPresent()) {
                             onDutyEarleast = find.get();
+                        } else {
+                            //如果没有上班数据,尝试查找invalidRecordType=Other, sourceType=APPROVE
+                            for (int i=0;i<array.size(); i++) {
+                                JSONObject object = array.getJSONObject(i);
+                                if ("Other".equals(object.getString("invalidRecordType")) && "APPROVE".equals(object.getString("sourceType"))) {
+                                    onDutyEarleast = JSONObject.toJavaObject(object, DdingCardTimeItem.class);
+                                }
+                            }
+                            if (onDutyEarleast == null) {
+                                //再尝试获取最早的下班打卡,作为上班时间,但是要在13:30之前
+                                find = oneDayTimes.stream().filter(p->"OffDuty".equals(p.getCheckType())).min(comparator);
+                                if (find.isPresent()) {
+                                    DdingCardTimeItem time = find.get();
+                                    LocalDateTime sLt = LocalDateTime.ofEpochSecond(time.getUserCheckTime()/1000, 0, ZoneOffset.ofHours(8));
+                                    String checkTime = hmFormat.format(sLt);
+                                    if (checkTime.compareTo("13:30") < 0) {
+                                        onDutyEarleast = time;
+                                    }
+                                }
+                            }
                         }
                         Optional<DdingCardTimeItem> findOff = oneDayTimes.stream().filter(p->"OffDuty".equals(p.getCheckType())).max(comparator);
                         if (findOff.isPresent()) {
@@ -2347,6 +2367,7 @@ public class DingDingServiceImpl implements DingDingService {
                             check=oLt.toLocalDate();
                         }
                         timeItem.setCompanyId(dingding.getCompanyId());
+//                        System.out.println(timeItem.getWorkDate() +", timeItem ="+timeItem.getStartTime() + "--" + timeItem.getEndTime());
                         if (onDutyEarleast != null && offDutyLatest != null) {
                             //下班打卡时间在第二天的情况下设置为前一天的23:59
                             if(offDutyLatest.getUserCheckTime() < onDutyEarleast.getUserCheckTime()){
@@ -2376,7 +2397,6 @@ public class DingDingServiceImpl implements DingDingService {
                 }
                 //保存数据
                 if (cardRecordList.size() > 0) {
-                    System.out.println("插入数据size=="+cardRecordList.size());
                     userDingdingTimeService.saveOrUpdateBatch(cardRecordList);
                 }
             } else {

+ 7 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceImportServiceImpl.java

@@ -386,13 +386,6 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
                     if (first.isPresent()) {
                         finance.setUserId(first.get().getId());
                         BigDecimal total = new BigDecimal(0);
-                        if (salaryCell != null) {
-                            salaryCell.setCellType(CellType.STRING);
-                            String item = salaryCell.getStringCellValue();
-                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
-                            finance.setMonthCost(value);
-                            if (financeConfig.getMonthCostCalculate()==1) total = total.add(value);
-                        }
 
                         //按姓名做匹配
                         Optional<Finance> matchItem = oldFinanceList.stream().filter(o -> o.getName().equals(finance.getName())).findFirst();
@@ -467,6 +460,13 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
                             total = finance.getTotalCost();
                         } else {
                             //常规月薪导入
+                            if (salaryCell != null) {
+                                salaryCell.setCellType(CellType.STRING);
+                                String item = salaryCell.getStringCellValue();
+                                BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                                finance.setMonthCost(value);
+                                if (financeConfig.getMonthCostCalculate()==1) total = total.add(value);
+                            }
                             if (bonusCell != null) {
                                 bonusCell.setCellType(CellType.STRING);
                                 String bonusString = bonusCell.getStringCellValue();