|
|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import jakarta.servlet.ServletOutputStream; |
|
|
|
import jakarta.servlet.ServletOutputStream; |
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.modules.business.mapper.MaintenanceTaskDetailMapper; |
|
|
|
import org.springblade.modules.business.mapper.MaintenanceTaskDetailMapper; |
|
|
|
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceOutputData; |
|
|
|
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceOutputData; |
|
|
|
@ -18,18 +19,20 @@ import org.springblade.modules.business.service.IMaintenanceTaskDetailService; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLConnection; |
|
|
|
import java.net.URLConnection; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.zip.ZipEntry; |
|
|
|
|
|
|
|
import java.util.zip.ZipOutputStream; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 巡检任务详情 服务实现类 |
|
|
|
* 巡检任务详情 服务实现类 |
|
|
|
@ -52,8 +55,8 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
String templateFile = "./src/main/resources/excel/MaintenanceTaskReport.xlsx"; |
|
|
|
String templateFile = "./src/main/resources/excel/MaintenanceTaskReport.xlsx"; |
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("taskName", task.getTaskName()); |
|
|
|
map.put("taskName", task.getDeptName()); |
|
|
|
map.put("address", task.getAddress()); |
|
|
|
map.put("address", task.getDeptName()); |
|
|
|
map.put("taskContent", task.getTaskContent()); |
|
|
|
map.put("taskContent", task.getTaskContent()); |
|
|
|
map.put("serviceManName", task.getServicemanName()); |
|
|
|
map.put("serviceManName", task.getServicemanName()); |
|
|
|
List<MaintenanceTaskDetail> maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); |
|
|
|
List<MaintenanceTaskDetail> maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); |
|
|
|
@ -67,10 +70,20 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
maintenanceOutputData.setDeptName(maintenanceTaskDetail.getDeptName()); |
|
|
|
maintenanceOutputData.setDeptName(maintenanceTaskDetail.getDeptName()); |
|
|
|
maintenanceOutputData.setMajorName(maintenanceTaskDetail.getMajorName()); |
|
|
|
maintenanceOutputData.setMajorName(maintenanceTaskDetail.getMajorName()); |
|
|
|
maintenanceOutputData.setCheckContent(maintenanceTaskDetail.getCheckContent()); |
|
|
|
maintenanceOutputData.setCheckContent(maintenanceTaskDetail.getCheckContent()); |
|
|
|
maintenanceOutputData.setStatus(maintenanceTaskDetail.getStatus()); |
|
|
|
Optional<Integer> status = Optional.ofNullable(maintenanceTaskDetail.getStatus()); |
|
|
|
|
|
|
|
if (status.isPresent()) { |
|
|
|
|
|
|
|
if (status.get() == 1) { |
|
|
|
|
|
|
|
maintenanceOutputData.setStatus("异常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (status.get() == 0) { |
|
|
|
|
|
|
|
maintenanceOutputData.setStatus("正常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
maintenanceOutputData.setRemark(maintenanceTaskDetail.getRemark()); |
|
|
|
maintenanceOutputData.setRemark(maintenanceTaskDetail.getRemark()); |
|
|
|
|
|
|
|
maintenanceOutputData.setSignature(task.getSignUrl()); |
|
|
|
if (StringUtils.isNotBlank(maintenanceTaskDetail.getPicUrl())) { |
|
|
|
if (StringUtils.isNotBlank(maintenanceTaskDetail.getPicUrl())) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
//获取图片
|
|
|
|
URL url = new URL(maintenanceTaskDetail.getPicUrl()); |
|
|
|
URL url = new URL(maintenanceTaskDetail.getPicUrl()); |
|
|
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); |
|
|
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); |
|
|
|
httpURLConnection.setRequestMethod("GET"); |
|
|
|
httpURLConnection.setRequestMethod("GET"); |
|
|
|
@ -78,7 +91,7 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
InputStream inputStream = httpURLConnection.getInputStream(); |
|
|
|
InputStream inputStream = httpURLConnection.getInputStream(); |
|
|
|
BufferedImage image = ImageIO.read(inputStream); |
|
|
|
BufferedImage image = ImageIO.read(inputStream); |
|
|
|
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ImageIO.write(image, "jpg", arrayOutputStream); |
|
|
|
ImageIO.write(image, "png", arrayOutputStream); |
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
maintenanceOutputData.setImage1(bytes); |
|
|
|
maintenanceOutputData.setImage1(bytes); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
@ -87,37 +100,125 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
maintenanceOutputData.setImage1(null); |
|
|
|
maintenanceOutputData.setImage1(null); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(maintenanceTaskDetail.getSignUrl())) { |
|
|
|
// if (StringUtils.isNotBlank(maintenanceTaskDetail.getSignUrl())) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// URL url = new URL(maintenanceTaskDetail.getSignUrl());
|
|
|
|
|
|
|
|
// HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
|
|
|
// httpURLConnection.setRequestMethod("GET");
|
|
|
|
|
|
|
|
// httpURLConnection.setDoInput(true);
|
|
|
|
|
|
|
|
// InputStream inputStream = httpURLConnection.getInputStream();
|
|
|
|
|
|
|
|
// BufferedImage image = ImageIO.read(inputStream);
|
|
|
|
|
|
|
|
// ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
|
|
|
|
|
|
|
|
// ImageIO.write(image, "jpg", arrayOutputStream);
|
|
|
|
|
|
|
|
// byte[] bytes = arrayOutputStream.toByteArray();
|
|
|
|
|
|
|
|
// maintenanceOutputData.setImage2(bytes);
|
|
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// maintenanceOutputData.setImage2(null);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
maintenanceOutputDataList.add(maintenanceOutputData); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//将数据导出到Excel
|
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
|
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(templateFile).build()) { |
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); |
|
|
|
|
|
|
|
excelWriter.fill(map, writeSheet); |
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
|
|
outputStream.flush(); |
|
|
|
|
|
|
|
outputStream.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchMaintenanceOutputService(List<MaintenanceTask> taskList, HttpServletResponse response) throws IOException { |
|
|
|
|
|
|
|
for (MaintenanceTask task : taskList) { |
|
|
|
|
|
|
|
//数据获取
|
|
|
|
|
|
|
|
String templateFile = "./src/main/resources/excel/MaintenanceTaskReport.xlsx"; |
|
|
|
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("taskName", task.getDeptName()); |
|
|
|
|
|
|
|
map.put("address", task.getDeptName()); |
|
|
|
|
|
|
|
map.put("taskContent", task.getTaskContent()); |
|
|
|
|
|
|
|
map.put("serviceManName", task.getServicemanName()); |
|
|
|
|
|
|
|
List<MaintenanceTaskDetail> maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); |
|
|
|
|
|
|
|
List<MaintenanceOutputData> maintenanceOutputDataList = new ArrayList<>(); |
|
|
|
|
|
|
|
long no = 0; |
|
|
|
|
|
|
|
for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { |
|
|
|
|
|
|
|
no++; |
|
|
|
|
|
|
|
MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); |
|
|
|
|
|
|
|
maintenanceOutputData.setNo(no); |
|
|
|
|
|
|
|
maintenanceOutputData.setFloor(maintenanceTaskDetail.getFloorName()); |
|
|
|
|
|
|
|
maintenanceOutputData.setDeptName(maintenanceTaskDetail.getDeptName()); |
|
|
|
|
|
|
|
maintenanceOutputData.setMajorName(maintenanceTaskDetail.getMajorName()); |
|
|
|
|
|
|
|
maintenanceOutputData.setCheckContent(maintenanceTaskDetail.getCheckContent()); |
|
|
|
|
|
|
|
Optional<Integer> status = Optional.ofNullable(maintenanceTaskDetail.getStatus()); |
|
|
|
|
|
|
|
if (status.isPresent()) { |
|
|
|
|
|
|
|
if (status.get() == 1) { |
|
|
|
|
|
|
|
maintenanceOutputData.setStatus("异常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (status.get() == 0) { |
|
|
|
|
|
|
|
maintenanceOutputData.setStatus("正常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
maintenanceOutputData.setRemark(maintenanceTaskDetail.getRemark()); |
|
|
|
|
|
|
|
maintenanceOutputData.setSignature(task.getSignUrl()); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(maintenanceTaskDetail.getPicUrl())) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
URL url = new URL(maintenanceTaskDetail.getSignUrl()); |
|
|
|
//获取图片
|
|
|
|
|
|
|
|
URL url = new URL(maintenanceTaskDetail.getPicUrl()); |
|
|
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); |
|
|
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); |
|
|
|
httpURLConnection.setRequestMethod("GET"); |
|
|
|
httpURLConnection.setRequestMethod("GET"); |
|
|
|
httpURLConnection.setDoInput(true); |
|
|
|
httpURLConnection.setDoInput(true); |
|
|
|
InputStream inputStream = httpURLConnection.getInputStream(); |
|
|
|
InputStream inputStream = httpURLConnection.getInputStream(); |
|
|
|
BufferedImage image = ImageIO.read(inputStream); |
|
|
|
BufferedImage image = ImageIO.read(inputStream); |
|
|
|
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ImageIO.write(image, "jpg", arrayOutputStream); |
|
|
|
ImageIO.write(image, "png", arrayOutputStream); |
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
maintenanceOutputData.setImage2(bytes); |
|
|
|
maintenanceOutputData.setImage1(bytes); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
maintenanceOutputData.setImage1(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取签字照片
|
|
|
|
|
|
|
|
// if (StringUtils.isNotBlank(maintenanceTaskDetail.getSignUrl())) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// URL url = new URL(maintenanceTaskDetail.getSignUrl());
|
|
|
|
|
|
|
|
// HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
|
|
|
// httpURLConnection.setRequestMethod("GET");
|
|
|
|
|
|
|
|
// httpURLConnection.setDoInput(true);
|
|
|
|
|
|
|
|
// InputStream inputStream = httpURLConnection.getInputStream();
|
|
|
|
|
|
|
|
// BufferedImage image = ImageIO.read(inputStream);
|
|
|
|
|
|
|
|
// ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
|
|
|
|
|
|
|
|
// ImageIO.write(image, "jpg", arrayOutputStream);
|
|
|
|
|
|
|
|
// byte[] bytes = arrayOutputStream.toByteArray();
|
|
|
|
|
|
|
|
// maintenanceOutputData.setImage2(bytes);
|
|
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// maintenanceOutputData.setImage2(null);
|
|
|
|
|
|
|
|
// }
|
|
|
|
maintenanceOutputDataList.add(maintenanceOutputData); |
|
|
|
maintenanceOutputDataList.add(maintenanceOutputData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//将数据导出到Excel
|
|
|
|
//将数据导出到Excel
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); |
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(templateFile).build()) { |
|
|
|
String fileName = task.getTaskCode() + "巡检报告.xlsx"; |
|
|
|
|
|
|
|
zos.putNextEntry(new ZipEntry(fileName)); |
|
|
|
|
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(zos).withTemplate(templateFile).build()) { |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); |
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); |
|
|
|
excelWriter.fill(map, writeSheet); |
|
|
|
excelWriter.fill(map, writeSheet); |
|
|
|
excelWriter.finish(); |
|
|
|
excelWriter.finish(); |
|
|
|
outputStream.flush(); |
|
|
|
zos.flush(); |
|
|
|
outputStream.close(); |
|
|
|
zos.closeEntry(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|