Ver código fonte

月度财务表添加工单筛选条件

yusm 1 mês atrás
pai
commit
cc0a3078d4

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceMonthlyWorktimeController.java

@@ -32,9 +32,9 @@ public class FinanceMonthlyWorktimeController {
     }
 
     @RequestMapping("/getByMonth")
-    public HttpRespMsg getByMonth(Integer companyId, String ymonth, @RequestParam(required = false, defaultValue = "0" ) Integer reGenerate,HttpServletRequest request) {
+    public HttpRespMsg getByMonth(Integer companyId, String ymonth, @RequestParam(required = false, defaultValue = "0" ) Integer reGenerate,Integer isItAWorkOrder, HttpServletRequest request) {
         try {
-            return financeMonthlyWorktimeService.getByMonth(companyId, ymonth,reGenerate, request);
+            return financeMonthlyWorktimeService.getByMonth(companyId, ymonth,reGenerate,isItAWorkOrder ,request);
         } catch (Exception e) {
             e.printStackTrace();
             HttpRespMsg msg = new HttpRespMsg();
@@ -44,8 +44,8 @@ public class FinanceMonthlyWorktimeController {
     }
 
     @RequestMapping("/exportByMonth")
-    public HttpRespMsg exportByMonth(Integer companyId, String ymonth, @RequestParam(required = false, defaultValue = "0" ) Integer reGenerate,HttpServletRequest request) throws Exception {
-       return financeMonthlyWorktimeService.exportByMonth(companyId, ymonth,reGenerate, request);
+    public HttpRespMsg exportByMonth(Integer companyId, String ymonth, @RequestParam(required = false, defaultValue = "0" ) Integer reGenerate,Integer isItAWorkOrder,HttpServletRequest request) throws Exception {
+       return financeMonthlyWorktimeService.exportByMonth(companyId, ymonth,reGenerate,isItAWorkOrder ,request);
     }
 
     @RequestMapping("/setTimesheetDate")

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

@@ -19,7 +19,7 @@ public interface FinanceMonthlyWorktimeService extends IService<FinanceMonthlyWo
 
     HttpRespMsg send(String fmwId, String timesheetDate, HttpServletRequest request);
 
-    HttpRespMsg getByMonth(Integer companyId, String ymonth, Integer reGenerate, HttpServletRequest request) throws Exception;
+    HttpRespMsg getByMonth(Integer companyId, String ymonth, Integer reGenerate, Integer isItAWorkOrder, HttpServletRequest request) throws Exception;
 
     HttpRespMsg setTimesheetDate(Integer id, String timesheetDate, HttpServletRequest request);
 
@@ -27,5 +27,5 @@ public interface FinanceMonthlyWorktimeService extends IService<FinanceMonthlyWo
 
     HttpRespMsg setStatusFinal(Integer id, HttpServletRequest request);
 
-    HttpRespMsg exportByMonth(Integer companyId, String ymonth, Integer reGenerate, HttpServletRequest request) throws Exception;
+    HttpRespMsg exportByMonth(Integer companyId, String ymonth, Integer reGenerate, Integer isItAWorkOrder, HttpServletRequest request) throws Exception;
 }

+ 20 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceMonthlyWorktimeServiceImpl.java

@@ -11,11 +11,13 @@ import com.management.platform.service.FinanceMonthlyWorktimeService;
 import com.management.platform.service.FmwDetailService;
 import com.management.platform.task.DataCollectTask;
 import com.management.platform.util.HttpRespMsg;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.http.*;
 import org.springframework.stereotype.Service;
@@ -41,6 +43,7 @@ import java.util.stream.Collectors;
  * @since 2025-04-16
  */
 @Service
+@Slf4j
 public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthlyWorktimeMapper, FinanceMonthlyWorktime> implements FinanceMonthlyWorktimeService {
     public static final String TIME_TYPE_COMPOSE = "组装工时(车间)";
     public static final String TIME_TYPE_REPAIR = "维修工时(车间)";
@@ -80,6 +83,9 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
     @Resource
     private ErpOrderInfoMapper erpOrderInfoMapper;
 
+    @Value(value = "${upload.path}")
+    private String uploadPath;
+
     @Override
     public HttpRespMsg send(String fmwId, String timesheetDate, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -150,7 +156,7 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public HttpRespMsg getByMonth(Integer companyId, String ymonth, Integer reGenerate, HttpServletRequest request) throws Exception {
+    public HttpRespMsg getByMonth(Integer companyId, String ymonth, Integer reGenerate, Integer isItAWorkOrder, HttpServletRequest request) throws Exception {
         //获取该月份的数据,如果没有自动生成
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         String token = request.getHeader("token");
@@ -338,7 +344,13 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
             }
         }
         //查询数据
-        List<FmwDetail> details = fmwDetailMapper.selectList(new QueryWrapper<FmwDetail>().eq("fmw_id", financeMonthlyWorktime.getId()));
+        QueryWrapper<FmwDetail> detailQueryWrapper = new QueryWrapper<FmwDetail>().eq("fmw_id", financeMonthlyWorktime.getId());
+        if (isItAWorkOrder!=null&&isItAWorkOrder==1){
+            detailQueryWrapper.isNotNull("extra_field4");//有工单号的数据
+        } else if (isItAWorkOrder != null && isItAWorkOrder == 2) {
+            detailQueryWrapper.isNull("extra_field4");//非工单则工单号为空的数据
+        }
+        List<FmwDetail> details = fmwDetailMapper.selectList(detailQueryWrapper);
         financeMonthlyWorktime.setDetailList(details);
         httpRespMsg.data = financeMonthlyWorktime;
         return httpRespMsg;
@@ -393,16 +405,13 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
 
     @Override
     @Transactional
-    public HttpRespMsg exportByMonth(Integer companyId, String ymonth, Integer reGenerate, HttpServletRequest request) throws Exception {
+    public HttpRespMsg exportByMonth(Integer companyId, String ymonth, Integer reGenerate, Integer isItAWorkOrder, HttpServletRequest request) throws Exception {
         //获取该月份的数据,如果没有自动生成
         HttpRespMsg httpRespMsg = new HttpRespMsg();
-        String token = request.getHeader("token");
-        User user = userMapper.selectById(token);
-        HttpRespMsg respMsg = getByMonth(companyId, ymonth, reGenerate, request);
+        HttpRespMsg respMsg = getByMonth(companyId, ymonth, reGenerate, isItAWorkOrder, request);
         FinanceMonthlyWorktime financeMonthlyWorktime = (FinanceMonthlyWorktime) respMsg.getData();
         List<FmwDetail> detailList = financeMonthlyWorktime.getDetailList();
 
-
         // 1. 创建工作簿和工作表
         Workbook workbook = new XSSFWorkbook();
         Sheet sheet = workbook.createSheet("工程工时表");
@@ -527,13 +536,14 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
             }
         }
 
+        long l = System.currentTimeMillis();
         // 6. 写入文件
-        try (FileOutputStream outputStream = new FileOutputStream("C:/upload/"+"工程工时表.xlsx")) {
+        try (FileOutputStream outputStream = new FileOutputStream(uploadPath+"月度财务工时表"+l+".xlsx")) {
             workbook.write(outputStream);
         }
         workbook.close();
-        System.out.println("Excel文件已生成!");
-
+        log.info("Excel文件已生成!");
+        httpRespMsg.data="/upload/"+"月度财务工时表"+l+".xlsx";
         return httpRespMsg;
     }