Ver código fonte

工时填报时长问题

zhouyy 3 meses atrás
pai
commit
614228310f

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

@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -76,9 +77,9 @@ public class LeaveSheetController {
      * @return
      */
     @RequestMapping("/add")
-    public HttpRespMsg add(LeaveSheet sheet) {
+    public HttpRespMsg add(LeaveSheet sheet, @RequestParam(value = "files",required = false) MultipartFile[] files) {
         String userId = request.getHeader("Token");
-        return leaveSheetService.add(sheet, userId);
+        return leaveSheetService.add(sheet, userId,files);
 
     }
 

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

@@ -1278,6 +1278,7 @@ public class ReportController {
                     httpRespMsg.setError(MessageUtils.message("profession.workDurationError"));
                     return httpRespMsg;
                 } else if (report.getOvertimeHours() > report.getWorkingTime()) {
+
                     HttpRespMsg httpRespMsg = new HttpRespMsg();
                     DecimalFormat decimalFormat = new DecimalFormat("0.0");
                     decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
@@ -2116,6 +2117,8 @@ public class ReportController {
             JSONArray array = JSONArray.parseArray(str);
             try {
                 double totalHours = 0;
+                long totalSeconds = 0l;
+                double totalHoursTmp = 0;
                 for (int t=0;t<array.size(); t++) {
                     JSONObject jsonObject = array.getJSONObject(t);
                     WorktimeItem item = JSONObject.toJavaObject(jsonObject, WorktimeItem.class);
@@ -2133,14 +2136,15 @@ public class ReportController {
                     if (excludeTime > 0) {
                         time -= excludeTime;
                     }
-
+                    totalSeconds+=time;
                     int minutes = (int)time/1000/60;
                     double hours = minutes*1.0f/60;
                     item.setTime(hours);
                     jsonObject.put("time", hours);
                     totalHours += hours;
                 }
-                report.setWorkingTime(totalHours);
+                totalHoursTmp = ((int)totalSeconds/1000/60)*1.0f/60;
+                report.setWorkingTime(totalHoursTmp);
                 report.setCost(hourCost.multiply(new BigDecimal(totalHours)));
                 report.setContent(array.toJSONString());
             } catch (ParseException e) {

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

@@ -3,6 +3,7 @@ package com.management.platform.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.LeaveSheet;
 import com.management.platform.util.HttpRespMsg;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
@@ -17,7 +18,7 @@ import java.util.List;
  */
 public interface LeaveSheetService extends IService<LeaveSheet> {
 
-    HttpRespMsg add(LeaveSheet sheet, String userId);
+    HttpRespMsg add(LeaveSheet sheet, String userId, MultipartFile[] files);
 
     HttpRespMsg delete(Integer id);
 

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

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -80,8 +81,25 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
     @Value(value = "${upload.path}")
     private String path;
 
+    public void checkFile(MultipartFile file){
+        if(file.isEmpty()){
+            throw new RuntimeException("文件大小不能为0");
+        }
+        if(org.apache.commons.lang3.StringUtils.isBlank(file.getOriginalFilename())){
+            throw new RuntimeException("文件名不能为空");
+        }
+//        if(file.getOriginalFilename().){
+//
+//        }
+    }
+
     @Override
-    public HttpRespMsg add(LeaveSheet sheet, String userId) {
+    public HttpRespMsg add(LeaveSheet sheet, String userId, MultipartFile[] files) {
+//        if(null != files && files.length > 0){
+//            for (MultipartFile file : files) {
+//
+//            }
+//        }
         HttpRespMsg msg = new HttpRespMsg();
         boolean isNew = false;
         if (sheet.getId() == null) {