|
@@ -11,11 +11,13 @@ import com.management.platform.service.FinanceMonthlyWorktimeService;
|
|
import com.management.platform.service.FmwDetailService;
|
|
import com.management.platform.service.FmwDetailService;
|
|
import com.management.platform.task.DataCollectTask;
|
|
import com.management.platform.task.DataCollectTask;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.http.*;
|
|
import org.springframework.http.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -41,6 +43,7 @@ import java.util.stream.Collectors;
|
|
* @since 2025-04-16
|
|
* @since 2025-04-16
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@Slf4j
|
|
public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthlyWorktimeMapper, FinanceMonthlyWorktime> implements FinanceMonthlyWorktimeService {
|
|
public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthlyWorktimeMapper, FinanceMonthlyWorktime> implements FinanceMonthlyWorktimeService {
|
|
public static final String TIME_TYPE_COMPOSE = "组装工时(车间)";
|
|
public static final String TIME_TYPE_COMPOSE = "组装工时(车间)";
|
|
public static final String TIME_TYPE_REPAIR = "维修工时(车间)";
|
|
public static final String TIME_TYPE_REPAIR = "维修工时(车间)";
|
|
@@ -80,6 +83,9 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
|
|
@Resource
|
|
@Resource
|
|
private ErpOrderInfoMapper erpOrderInfoMapper;
|
|
private ErpOrderInfoMapper erpOrderInfoMapper;
|
|
|
|
|
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
|
+ private String uploadPath;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg send(String fmwId, String timesheetDate, HttpServletRequest request) {
|
|
public HttpRespMsg send(String fmwId, String timesheetDate, HttpServletRequest request) {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
@@ -150,7 +156,7 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@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();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
String token = request.getHeader("token");
|
|
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);
|
|
financeMonthlyWorktime.setDetailList(details);
|
|
httpRespMsg.data = financeMonthlyWorktime;
|
|
httpRespMsg.data = financeMonthlyWorktime;
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
@@ -393,16 +405,13 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@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();
|
|
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();
|
|
FinanceMonthlyWorktime financeMonthlyWorktime = (FinanceMonthlyWorktime) respMsg.getData();
|
|
List<FmwDetail> detailList = financeMonthlyWorktime.getDetailList();
|
|
List<FmwDetail> detailList = financeMonthlyWorktime.getDetailList();
|
|
|
|
|
|
-
|
|
|
|
// 1. 创建工作簿和工作表
|
|
// 1. 创建工作簿和工作表
|
|
Workbook workbook = new XSSFWorkbook();
|
|
Workbook workbook = new XSSFWorkbook();
|
|
Sheet sheet = workbook.createSheet("工程工时表");
|
|
Sheet sheet = workbook.createSheet("工程工时表");
|
|
@@ -527,13 +536,14 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
// 6. 写入文件
|
|
// 6. 写入文件
|
|
- try (FileOutputStream outputStream = new FileOutputStream("C:/upload/"+"工程工时表.xlsx")) {
|
|
|
|
|
|
+ try (FileOutputStream outputStream = new FileOutputStream(uploadPath+"月度财务工时表"+l+".xlsx")) {
|
|
workbook.write(outputStream);
|
|
workbook.write(outputStream);
|
|
}
|
|
}
|
|
workbook.close();
|
|
workbook.close();
|
|
- System.out.println("Excel文件已生成!");
|
|
|
|
-
|
|
|
|
|
|
+ log.info("Excel文件已生成!");
|
|
|
|
+ httpRespMsg.data="/upload/"+"月度财务工时表"+l+".xlsx";
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|