瀏覽代碼

物奇增加刷新考勤功能

QuYueTing 1 月之前
父節點
當前提交
5220b74a38

+ 49 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserCorpwxTimeController.java

@@ -596,6 +596,55 @@ public class UserCorpwxTimeController {
         return msg;
     }
 
+    @RequestMapping("/refreshWeeklyCardTime")
+    public HttpRespMsg refreshWeeklyCardTime(String dateArray, String userId){
+        HttpRespMsg msg=new HttpRespMsg();
+        User user = null;
+        if (StringUtils.isEmpty(userId)) {
+            user = userMapper.selectById(request.getHeader("token"));
+        } else {
+            user = userMapper.selectById(userId);
+        }
+
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        JSONArray array = JSONArray.parseArray(dateArray);
+        List<String> dateList = new ArrayList<>();
+        for (int i=0;i<array.size(); i++) {
+            String date = array.getString(i);
+            dateList.add(date);
+            LocalDate localDate = LocalDate.parse(date, df);
+            //如果是今天,取日打卡记录接口,如果是过往其他日期,取考勤记录接口
+            if (localDate.isEqual(LocalDate.now())) {
+                LocalDateTime start = LocalDateTime.of(localDate, LocalTime.MIN);
+                LocalDateTime end = LocalDateTime.of(localDate, LocalTime.MAX).withSecond(0).withNano(0);
+                wxCorpInfoService.getUserPunchRecord(user.getCompanyId(),user.getId(),start,end,false);
+            } else if (localDate.isBefore(LocalDate.now())) {
+                LocalDateTime start = localDate.atTime(0,0,0);
+                LocalDateTime end = localDate.atTime(0,0,0);
+                wxCorpInfoService.getUserCheckInDayData(user.getCompanyId(),user.getId(),start, end, true);
+                List<UserCorpwxTime> changedCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                        .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+
+                if (changedCorpwxTimes.size() > 0) {
+                    UserCorpwxTime time = changedCorpwxTimes.get(0);
+                    //如果没有考勤,获取当日打卡记录
+                    boolean hasTimeRecord = time.getWorkHours() > 0 || time.getCardTime() >= 1.0 || time.getAskLeaveTime() > 0 || time.getOutdoorTime() > 0;
+                    if (!hasTimeRecord) {
+                        LocalDateTime start1 = LocalDateTime.of(localDate, LocalTime.MIN);
+                        LocalDateTime end1 = LocalDateTime.of(localDate, LocalTime.MAX).withSecond(0).withNano(0);
+                        wxCorpInfoService.getUserPunchRecord(user.getCompanyId(),user.getId(),start1,end1,false);
+                    }
+                }
+            }
+        }
+        if (dateList.size() > 0) {
+            List<UserCorpwxTime> changedCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                    .eq("corpwx_userid", user.getCorpwxUserid()).in("create_date", dateList));
+            msg.data=changedCorpwxTimes;
+        }
+        return msg;
+    }
+
     @RequestMapping("/importCardTime")
     public HttpRespMsg importCardTime(Integer companyId, MultipartFile multipartFile, HttpServletRequest request){
         HttpRespMsg msg=new HttpRespMsg();

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ContractBonusDetailServiceImpl.java

@@ -14,6 +14,7 @@ import com.management.platform.mapper.*;
 import com.management.platform.service.ContractBonusDetailService;
 import com.management.platform.service.ContractBonusSummaryService;
 import com.management.platform.service.WxCorpInfoService;
+import com.management.platform.util.DateTimeUtil;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
@@ -321,7 +322,8 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
             List<String> userIds = importDataList.stream().map(ImportBonusTemplateVO::getUserId).collect(Collectors.toList());
             BonusDataBO bonusDataBO = new BonusDataBO();
             bonusDataBO.setStartDate(startYM+"-01");
-            bonusDataBO.setEndDate(endYM+"-31");
+            //获取startYM的最后一天的日期, startYM为2025-05格式
+            bonusDataBO.setEndDate(DateTimeUtil.getLastDayOfYearMonth(endYM));
             bonusDataBO.setBonusType(bonusType);
             bonusDataBO.setUserIds(userIds);
             bonusDataBO.setCompanyId(user.getCompanyId());

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

@@ -6,10 +6,7 @@ import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.management.platform.util.ExcelUtil;
-import com.management.platform.util.HttpRespMsg;
-import com.management.platform.util.MessageUtils;
-import com.management.platform.util.UserNotFoundException;
+import com.management.platform.util.*;
 import org.apache.commons.io.FileUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Value;
@@ -118,7 +115,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
             List<User> updateUserList = new ArrayList<>();
 
             String startStr = yearMonth + "-01";
-            String endStr = yearMonth + "-31";
+            String endStr = DateTimeUtil.getLastDayOfYearMonth(yearMonth);;
             //由于第一行需要指明列对应的标题
             int rowNum = sheet.getLastRowNum();
             for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
@@ -303,7 +300,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
                 List<User> updateUserList = new ArrayList<>();
 
                 String startStr = yearMonth + "-01";
-                String endStr = yearMonth + "-31";
+                String endStr = DateTimeUtil.getLastDayOfYearMonth(yearMonth);;
                 //获取人员该月份填写的日报的总时长
                 List<Map<String, Object>> userTimeList = null;
                 if (financeImport.getRecoverMonthcost()==1 || financeImport.getRecoverReport()==1) {

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -9,6 +9,7 @@ import com.management.platform.entity.*;
 import com.management.platform.entity.excel.SpecialContractMonthSalary;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
+import com.management.platform.util.DateTimeUtil;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
@@ -116,7 +117,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
         List<Finance> financeList = financeMapper.selectListByDept(companyId, yearMonth,deptIds);
         TimeType timeType = timeTypeMapper.selectById(companyId);
         //当前月是否有项目日报数据
-        List<Map<String, Object>> userList = reportMapper.selectFillReportUserList(companyId, yearMonth+"-01", yearMonth+"-31");
+        List<Map<String, Object>> userList = reportMapper.selectFillReportUserList(companyId, yearMonth+"-01", DateTimeUtil.getLastDayOfYearMonth(yearMonth));
         if (timeType.getIsSecretSalary() == 1) {
             //秘薪处理
             financeList.forEach(finance->{
@@ -192,7 +193,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             //需要更新成本的人员数据
             List<User> updateUserList = new ArrayList<>();
             String startStr = yearMonth + "-01";
-            String endStr = yearMonth + "-31";
+            String endStr = DateTimeUtil.getLastDayOfYearMonth(yearMonth);
             //获取人员该月份填写的日报的总时长
             List<Map<String, Object>> userTimeList = null;
             if (syncUserCost || syncHistoryReport) {

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

@@ -10985,7 +10985,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             TimeType timeType = timeTypeMapper.selectById(companyId);
             if (timeType.getFixMonthcost() == 1) {
                 //每月固定月薪的方式计算,平摊到各个项目中
-                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null,deptIds);
+                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", DateTimeUtil.getLastDayOfYearMonth(endDate), null,deptIds);
                 //检查财务表中是否已经导入成本
                 List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
                 List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));

+ 15 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -55,6 +55,7 @@ import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.chrono.ChronoLocalDate;
 import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
 import java.time.format.DateTimeParseException;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalAdjusters;
@@ -7402,7 +7403,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             } else {
                 //按月
                 startDate = date + "-01";
-                endDate = date + "-31";
+                endDate = DateTimeUtil.getLastDayOfYearMonth(date);
             }
             //pageIndex从1开始
             Integer startIndex = (pageIndex -1) * pageSize;
@@ -9591,6 +9592,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 dateList = new ArrayList<>();
             }
             reportMap.put("dateList", dateList);
+            //查询考勤请假状态
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+            if (wxCorpInfo != null && dateList.size() > 0) {
+                List<UserCorpwxTime> userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", user.getCorpwxUserid()).in("create_date", dateList.stream().map(r -> (String) r.get("date")).collect(Collectors.toList())));
+                for (HashMap item : dateList) {
+                    String curDate = (String) item.get("date");
+                    UserCorpwxTime userCorpwxTime = userCorpwxTimeList.stream().filter(r -> r.getCreateDate().isEqual(LocalDate.parse(curDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")))).findFirst().orElse(null);
+                    if (userCorpwxTime != null) {
+                        item.put("time", userCorpwxTime);
+                    }
+                }
+            }
             reportMap.put("summary", summary);
             reportMap.put("weeklyAttachment", attachment);
         } else {
@@ -12188,7 +12201,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         Integer leaveProjectId = 80333;//请假项目,排除在外
         Integer publicProjectId = 77651;//公共项目
         String startDate = ymonth + "-01";
-        String endDate = ymonth + "-31";
+        String endDate = DateTimeUtil.getLastDayOfYearMonth(ymonth);
         QueryWrapper<Report> wrapper = new QueryWrapper<Report>().select("id, create_date, creator_id, project_id,dept_id, working_time, group_id, extra_field4").eq("company_id", companyId).ne("project_id", leaveProjectId)
                 .eq("state", 1).between("create_date", startDate, endDate);
         if (projectId != null) {

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/SimpleReportServiceImpl.java

@@ -8,6 +8,7 @@ import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.SimpleFinanceService;
 import com.management.platform.service.SimpleProjectimeService;
 import com.management.platform.service.SimpleReportService;
+import com.management.platform.util.DateTimeUtil;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
@@ -129,7 +130,7 @@ public class SimpleReportServiceImpl extends ServiceImpl<SimpleReportMapper, Sim
                 List<User> updateUserList = new ArrayList<>();
                 LocalDate now = LocalDate.now();
                 String startStr = yearMonth + "-01";
-                String endStr = yearMonth + "-31";
+                String endStr = DateTimeUtil.getLastDayOfYearMonth(yearMonth);;
                 //获取人员该月份填写的日报的总时长
                 List<Map<String, Object>> userTimeList = null;
 

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

@@ -380,7 +380,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             //需要更新成本的人员数据
             List<User> updateUserList = new ArrayList<>();
             String startStr = yearMonth + "-01";
-            String endStr = yearMonth + "-31";
+            String endStr = DateTimeUtil.getLastDayOfYearMonth(yearMonth);;
             BigDecimal monthTotalHours = timeType.getMonthDays().multiply(new BigDecimal(timeType.getAllday()));
             //由于第一行需要指明列对应的标题
             for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/DataCollectTask.java

@@ -47,6 +47,8 @@ public class DataCollectTask {
     private FinanceMonthlyWorktimeMapper financeMonthlyWorktimeMapper;
     @Autowired
     private UserFvTimeService userFvTimeService;
+    @Autowired
+    private ProjectService projectService;
 
     @Scheduled(cron = "30 10 8,12,20 * * ?")
 //    @Scheduled(cron = "30 08 21 * * ?")
@@ -94,7 +96,7 @@ public class DataCollectTask {
     public void sqlServerProjectTask() {
         if(isDev){return;}
         if(isPrivateDeploy) return;
-
+        projectService.syncHongHuData(HONGHU_COMP_ID);
 
     }
 

+ 8 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/DateTimeUtil.java

@@ -84,9 +84,16 @@ public class DateTimeUtil {
 
     public static void main(String[] args) {
         LocalDate localDate = LocalDate.now();
-        System.out.println(localDate);
+        System.out.println(getLastDayOfYearMonth("2025-08"));
         System.out.println(localDate.getDayOfWeek().getValue());
         localDate = localDate.with(DayOfWeek.SUNDAY);
         System.out.println(localDate);
     }
+
+    public static String getLastDayOfYearMonth(String yearMonth) {
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate localDate = LocalDate.parse(yearMonth + "-01", dateTimeFormatter);
+        LocalDate lastDay = localDate.withDayOfMonth(localDate.getMonth().length(localDate.isLeapYear()));
+        return dateTimeFormatter.format(lastDay);
+    }
 }

+ 20 - 3
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/weeklyCustomization.vue

@@ -4,6 +4,7 @@
             <el-button @click="getCurrentWeek(-7)" size="small">&lt;&lt;</el-button>
             <el-button @click="getCurrentWeek(0)" size="small">{{ $t('time.thisWeek') }}</el-button>
             <el-button @click="getCurrentWeek(7)" size="small">&gt;&gt;</el-button>
+            <el-button @click="refreshCardTime()" size="small" style="margin-left:20px;" v-if="user.roleName == '超级管理员'" :loading="isRefreshing">刷新考勤</el-button>
         </div>
         <div class="weekcen flexColumn" v-loading="submitLoading">
             <div class="flexColumnAuto flex1">
@@ -12,6 +13,7 @@
                         <template slot-scope="scope">
                             <span>{{ scope.row.dateTime }}</span>
                             (<span>{{ scope.row.weekDayTxt }}</span>)
+                            <span v-if="scope.row.time && scope.row.time.askLeaveTime > 0" style="color:green;">请假{{scope.row.time.askLeaveTime}}h</span>
                         </template>
                     </el-table-column>
                     <el-table-column :label="$t('other.project')" width="220">
@@ -130,6 +132,7 @@ export default {
     },
     data() {
         return {
+            isRefreshing: false,
             serverFileList:[],
             upLoading: false,
             fileList:[],
@@ -152,6 +155,20 @@ export default {
         this.getProjectList()
     },
     methods: {
+        async refreshCardTime() {
+            this.isRefreshing = true;
+            var dateArray = this.weekTableData.map(item=>item.dateTime);
+            console.log(dateArray);
+            let { data } = await this.getData('/user-corpwx-time/refreshWeeklyCardTime',  {dateArray: JSON.stringify(dateArray)})
+            this.isRefreshing = false;
+            for (var i=0;i<this.weekTableData.length; i++) {
+                for (var j=0;j<data.length; j++) {
+                    if (data[j].createDate == this.weekTableData[i].dateTime) {
+                        this.weekTableData[i].time = data[j]
+                    }
+                }
+            }
+        },
         handleRemove(file, fileList) {
             console.log(file, fileList);
             console.log('删除的文件名=='+file.name);
@@ -413,10 +430,10 @@ export default {
             console.log(data, '<===== 处理之后的')
             const { dateList, projectList, sumTimeList, cardTimeList } = data;
             const weekTableData = dateList.flatMap(date => {
-                const { weekDayTxt, date: dateTime, reportList, canFill } = date;
-                const reports = reportList.map(report => ({ ...report, weekDayTxt, dateTime, canFill,projectName:projectList.filter(p=>p.id == report.projectId)[0].projectName }));
+                const { weekDayTxt, date: dateTime, reportList, canFill, time } = date;
+                const reports = reportList.map(report => ({ ...report, weekDayTxt, dateTime,time, canFill,projectName:projectList.filter(p=>p.id == report.projectId)[0].projectName }));
 
-                return reports.length > 0 ? reports : [{ weekDayTxt, dateTime, canFill }];
+                return reports.length > 0 ? reports : [{ weekDayTxt, dateTime,time, canFill }];
             });
             let sumSet = new Set();
             weekTableData.forEach(obj => {