Explorar el Código

正北需求,车间导出日报工位改成员工工位

seyason hace 1 día
padre
commit
74f057e8b0

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -14,6 +14,7 @@ import com.management.platform.service.ProjectService;
 import com.management.platform.util.DockWithMLD;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
+import com.management.platform.util.SysConstant;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddressList;
@@ -319,7 +320,7 @@ public class ProjectController {
         String token = request.getHeader("token");
         User user = userMapper.selectById(token);
         //苏州正北定制工时表
-        if (user.getCompanyId() == 8138 || user.getCompanyId() == 7703 || user.getCompanyId() == 7) {
+        if (SysConstant.ZhengBeiCompIds.contains(user.getCompanyId()) || user.getCompanyId() == 7) {
             return projectService.exportZhengBeiTimeReport(date, request);
         }
         return projectService.exportTimeByProjectAndEmployee(date, request);

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -1499,7 +1499,7 @@ public class ReportController {
         }
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         //对于正北(苏州和广州)需校验项目开始结束日期
-        if (company.getId() == 8138 || company.getId() == 7703) {
+        if (SysConstant.ZhengBeiCompIds.contains(company.getId())) {
             for (Report report : reportList) {
                 Optional<Project> first = projectList.stream().filter(p -> p.getId().equals(report.getProjectId())).findFirst();
                 if (first.isPresent()) {
@@ -1589,7 +1589,7 @@ public class ReportController {
                 }
 
                 //HardCode:对于正北两家公司,校验填报工时不得少于考勤时长。(代填的不校验)
-                if ((company.getId() == 8138 || company.getId() == 7703) && (report.getFillUserid() == null || creatorId.equals(report.getFillUserid()))) {
+                if ((SysConstant.ZhengBeiCompIds.contains(company.getId())) && (report.getFillUserid() == null || creatorId.equals(report.getFillUserid()))) {
                     if (company.getId() == 8138) {
                         //苏州正北, 用钉钉
                         List<UserDingdingTime> userDingdingTimes = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("user_id", creatorId).eq("work_date", cDate));

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

@@ -843,6 +843,7 @@ public class UserCorpwxTimeController {
             l.setWorkHours(l.getWorkHours());
             l.setWeekDay(l.getCreateDate().getDayOfWeek().getValue());
             l.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(l.getWeekDay()));
+            System.out.println("导入人员:"+l.getName()+",日期:"+l.getCreateDate()+",上下班:"+l.getStartTime()+"-"+l.getEndTime()+",工作时长:"+l.getWorkHours()+",工号:");
         });
         if (msg.code.equals("error")) {
             return msg;

+ 30 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ExcelParserService.java

@@ -9,6 +9,7 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
@@ -26,6 +27,7 @@ public class ExcelParserService {
             // 获取表头行
             Row headerRow = sheet.getRow(0);
             // 从第二行开始解析数据(假设第一行是表头)
+            boolean isHandlingNightWork = false;
             for (int i = 2; i <= sheet.getLastRowNum(); i++) {
                 Row row = sheet.getRow(i);
                 if (row == null) continue;
@@ -51,14 +53,26 @@ public class ExcelParserService {
 
                     // 解析时间记录
                     String timeRecord = getCellValue(timeCell);
+                    System.out.println("dateStr="+dateStr+", TImeRecord:"+timeRecord);
                     if (timeRecord == null || timeRecord.isEmpty() || "-".equals(timeRecord)) {
                         continue;
                     }
 
                     // 分割时间记录(可能有多个打卡时间)
                     String[] times = timeRecord.split("\n");
+                    if (isHandlingNightWork) {
+                        // 如果是处理夜班工作,忽略12:00前的打卡
+                        times = java.util.Arrays.stream(times)
+                                .filter(t -> t.compareTo("12:00") >= 0)
+                                .toArray(String[]::new);
+                        isHandlingNightWork = false;
+                    }
 
                     if (times.length == 1) {
+                        if (times[0].length() > "00:00".length()) {
+                            //去掉后面的秒
+                            times[0] = times[0].substring(0, "00:00".length());
+                        }
                         //当前只有一次打卡,可能是晚班,要获取次日最晚打卡作为下班打卡。
                         if (times[0].compareTo("18:00") > 0) {
                             String sTime = times[0];
@@ -70,14 +84,17 @@ public class ExcelParserService {
                                 String nextDayTimeStr = getCellValue(nextDayTime);
                                 if (!StringUtils.isEmpty(nextDayTimeStr) && !"-".equals(nextDayTimeStr)) {
                                     String[] nextDayTimes = nextDayTimeStr.split("\n");
-                                    if (nextDayTimes[nextDayTimes.length -1].compareTo("12:00") < 0) {
+                                    //取次日12点前的最晚打卡
+                                    nextDayTimes = java.util.Arrays.stream(nextDayTimes)
+                                            .filter(t -> t.compareTo("12:00") < 0)
+                                            .toArray(String[]::new);
+                                    if (nextDayTimes.length > 0) {
                                         //次日上午打卡结束
                                         String nextDayEndTime = "次日"+nextDayTimes[nextDayTimes.length -1];
                                         times = new String[2];
                                         times[0] = sTime;
                                         times[1] = nextDayEndTime;
-                                        //跳过下一个日期
-                                        col++;
+                                        isHandlingNightWork = true;
                                     }
                                 }
                             }
@@ -131,7 +148,10 @@ public class ExcelParserService {
                 return cell.getStringCellValue().trim();
             case NUMERIC:
                 if (DateUtil.isCellDateFormatted(cell)) {
-                    return cell.getDateCellValue().toString();
+                    java.util.Date date = cell.getDateCellValue();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
+                    System.out.println("这是datecell:"+cell.getDateCellValue().toString());
+                    return simpleDateFormat.format(date);
                 } else {
                     return String.valueOf(cell.getNumericCellValue());
                 }
@@ -145,8 +165,8 @@ public class ExcelParserService {
     }
 
     public static void main(String[] args) {
-        String startTime = "08:29";
-        String endTime = "18:07";
+        String startTime = "20:06";
+        String endTime = "次日08:35";
         double workHours = calculateZhengBeiWorkHours(startTime, endTime);
 
         System.out.println("工作时长:" + workHours + "小时");
@@ -185,6 +205,10 @@ public class ExcelParserService {
         if (startHour <= 17 && endHour >= 18) {
             hours -= 0.5;
         }
+        //夜班减去休息1.5小时
+        if (startHour >= 20 || endHour >= 30) {
+            hours -= 1.5;
+        }
         double minPart = hours - (int)hours;
 
         if (minPart > 0 && minPart < 0.5) {

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

@@ -395,12 +395,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             Integer companyId = targetUser.getCompanyId();
             CompanyDingding dingding = null;
             WxCorpInfo wxCorpInfo = null;
-            if (companyId == 8138) {
-                //苏州正北,钉钉平台
-                dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
-            } else if (companyId == 7703) {
+            if (companyId == 7703) {
                 //广东正北连接,企业微信
                 wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
+            } else {
+                dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
             }
 
             // 查找该时间段内公司的所有日报数据

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

@@ -8846,7 +8846,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             List<Stages> stagesList = integerList.size() > 0?stagesMapper.selectList(new QueryWrapper<Stages>().in("project_id", integerList)) : new ArrayList<>();
             //获取当前项目的子项目列表,任务分组,任务列表,项目相关维度列表
             reports.forEach(r->{
-                if (!(companyId == 8138 || companyId == 7703)) {
+                if (!SysConstant.ZhengBeiCompIds.contains(companyId)) {
                     r.setContent(null);
                 }
                 allProjectList.stream().filter(pItem->pItem.getId().equals(r.getProjectId())).findFirst().ifPresent(p->r.setProjectName(p.getProjectName()));

+ 8 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/SysConstant.java

@@ -0,0 +1,8 @@
+package com.management.platform.util;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class SysConstant {
+    public static final List<Integer> ZhengBeiCompIds = Arrays.asList(new Integer[]{7703, 8138, 8261});
+}

+ 1 - 1
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/mapper/ReportMapper.xml

@@ -580,8 +580,8 @@
         date_format(r.create_date,'%Y-%m-%d') as createDate,date_format(r.create_time,'%Y-%m-%d %T') as reportTime,(CASE WHEN p.plan_type=0 THEN pp.unit_price ELSE p.money_of_job END) as unitPrice,r.cost  from report r
         left join plan p on p.id=r.plan_id
         left join plan_extra_info pei on r.id=pei.report_id
-        left join department d on d.department_id=p.station_id
         left join user u on r.creator_id=u.id
+        left join department d on d.department_id=u.department_id
         left join prod_procedure pp on pp.id=r.prod_procedure_id
         left join user uu on uu.id=r.checker_id
         where r.company_id=#{companyId}

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/dailyReportReview.vue

@@ -251,7 +251,7 @@
                       <span v-for="(item, index) in scope.row.data" style="margin-right:10px;" ><template v-if="index==0 || (index>0 && (scope.row.data[index-1].content != item.content))"><b>{{item.project}}</b>{{ ':'+item.content }}</template></span>
                   </template>
               </el-table-column>
-              <el-table-column label="代填人" v-if="user.companyId == 8138 || user.companyId == 7703" width="120">
+              <el-table-column label="代填人" v-if="user.companyId == 8138 || user.companyId == 7703 || user.companyId == 8261" width="120">
                   <template slot-scope="scope">
                       <div>
                           <span v-if="user.userNameNeedTranslate == '1'">