|
@@ -1,19 +1,32 @@
|
|
|
package com.bizmatics.service.impl;
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.bizmatics.common.core.bean.CommonPage;
|
|
|
+import com.bizmatics.common.core.exception.BusinessException;
|
|
|
+import com.bizmatics.common.core.util.BeanMapperUtils;
|
|
|
+import com.bizmatics.common.core.util.FileUtils;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
+import com.bizmatics.common.spring.util.GlobalUtils;
|
|
|
import com.bizmatics.model.*;
|
|
|
import com.bizmatics.model.system.SysUser;
|
|
|
import com.bizmatics.model.vo.*;
|
|
|
import com.bizmatics.persistence.mapper.DevopsWorkOrderMapper;
|
|
|
import com.bizmatics.service.*;
|
|
|
import com.bizmatics.service.util.SecurityUtils;
|
|
|
+import com.bizmatics.service.vo.DeviceExportVO;
|
|
|
+import com.bizmatics.service.vo.ProcessingTimeExportVO;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -629,7 +642,6 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
|
|
|
@Override
|
|
|
public CommonPage<ProcessingTimeVo> workloadStatisticsLits(Integer siteId,String startTime,String endTime,Integer size , Integer current){
|
|
|
List<ProcessingTime> processingTimeList = baseMapper.workloadStatisticsLits(siteId, startTime, endTime);
|
|
|
-
|
|
|
LambdaQueryWrapper<PatrolInspectors> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(PatrolInspectors::getStatus, 1);
|
|
|
List<PatrolInspectors> patrolInspectorsList = patrolInspectorsService.list(queryWrapper);
|
|
@@ -697,4 +709,101 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
|
|
|
return new CommonPage<>(Active1, processingTimeVoList1.size(), size, current);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String workloadStatisticsExport(Integer siteId,String startTime,String endTime){
|
|
|
+ Workbook workbook = null;
|
|
|
+ File file = null;
|
|
|
+ try {
|
|
|
+ ExportParams params = new ExportParams(null, "工作量统计");
|
|
|
+ workbook = ExcelExportUtil.exportBigExcel(params, ProcessingTimeExportVO.class,
|
|
|
+ (o, i) -> {
|
|
|
+ List<ProcessingTime> processingTimeList = baseMapper.workloadStatisticsLits(siteId, startTime, endTime);
|
|
|
+ LambdaQueryWrapper<PatrolInspectors> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectors::getStatus, 1);
|
|
|
+ List<PatrolInspectors> patrolInspectorsList = patrolInspectorsService.list(queryWrapper);
|
|
|
+ List<ProcessingTimeVo> Active1 = new ArrayList<ProcessingTimeVo>(); // 存放页面需要展示的数据
|
|
|
+ List<ProcessingTimeVo> processingTimeVoList1 = new ArrayList<>();
|
|
|
+ if (patrolInspectorsList.size()>0){
|
|
|
+ for (int k = 0; k < patrolInspectorsList.size(); k++) {
|
|
|
+ ProcessingTimeVo processingTimeVo1 = new ProcessingTimeVo();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Integer orderQuantity = 0;
|
|
|
+ Integer completedQuantity = 0;
|
|
|
+ Integer incomplete = 0;
|
|
|
+ Integer responseTime = 0;
|
|
|
+ Integer processingTime = 0;
|
|
|
+ if (processingTimeList.size()>0){
|
|
|
+ for (Integer j = 0; j < processingTimeList.size(); j++) {
|
|
|
+ if (patrolInspectorsList.get(k).getId()==processingTimeList.get(j).getId()){
|
|
|
+ switch (processingTimeList.get(j).getWorkOrderStatus()) {
|
|
|
+ case 4:
|
|
|
+ orderQuantity += processingTimeList.get(j).getCount();
|
|
|
+ incomplete += processingTimeList.get(j).getCount();
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ incomplete += processingTimeList.get(j).getCount();
|
|
|
+ orderQuantity += processingTimeList.get(j).getCount();
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ orderQuantity += processingTimeList.get(j).getCount();
|
|
|
+ completedQuantity += processingTimeList.get(j).getCount();
|
|
|
+ processingTime=processingTimeList.get(j).getProcessingTime();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ processingTimeVo1.setId(patrolInspectorsList.get(k).getId());
|
|
|
+ processingTimeVo1.setInspectorsName(patrolInspectorsList.get(k).getInspectorsName());
|
|
|
+ processingTimeVo1.setOrderQuantity(orderQuantity);
|
|
|
+ processingTimeVo1.setCompletedQuantity(completedQuantity);
|
|
|
+ processingTimeVo1.setIncomplete(incomplete);
|
|
|
+ processingTimeVo1.setResponseTime(responseTime);
|
|
|
+ processingTimeVo1.setProcessingTime(processingTime);
|
|
|
+ processingTimeVo1.setTestimonials("");
|
|
|
+ }else {
|
|
|
+ processingTimeVo1.setId(patrolInspectorsList.get(k).getId());
|
|
|
+ processingTimeVo1.setInspectorsName(patrolInspectorsList.get(k).getInspectorsName());
|
|
|
+ processingTimeVo1.setOrderQuantity(orderQuantity);
|
|
|
+ processingTimeVo1.setCompletedQuantity(completedQuantity);
|
|
|
+ processingTimeVo1.setIncomplete(incomplete);
|
|
|
+ processingTimeVo1.setResponseTime(responseTime);
|
|
|
+ processingTimeVo1.setProcessingTime(processingTime);
|
|
|
+ processingTimeVo1.setTestimonials("");
|
|
|
+ }
|
|
|
+
|
|
|
+ processingTimeVoList1.add(processingTimeVo1);
|
|
|
+ }
|
|
|
+ int currIdx = (i > 1 ? (i -1) * 30: 0);
|
|
|
+ for (int j = 0; j < 30 && j < processingTimeVoList1.size() - currIdx; j++) { // 判断条件十分巧妙,防止List取值越界
|
|
|
+ ProcessingTimeVo active = processingTimeVoList1.get(currIdx + j);
|
|
|
+ Active1.add(active);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>(BeanMapperUtils.mapList(Active1, ProcessingTimeVo.class, ProcessingTimeExportVO.class));
|
|
|
+ }, null);
|
|
|
+ if (null != workbook) {
|
|
|
+ file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "工作量统计", System.currentTimeMillis() + ""));
|
|
|
+ FileUtils.createFile(file.getAbsolutePath());
|
|
|
+ FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
|
|
|
+ workbook.write(allListingFileOutputStream);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("表格数据为空");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导出文件失败", e);
|
|
|
+ throw new BusinessException("导出文件失败");
|
|
|
+ } finally {
|
|
|
+ if (workbook != null) {
|
|
|
+ try {
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("===export spec=== 关闭workbook失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return file.getName();
|
|
|
+ }
|
|
|
+
|
|
|
}
|