|
|
|
|
@ -3,19 +3,31 @@ package org.springblade.modules.business.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
import com.alibaba.excel.metadata.data.WriteCellData; |
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
|
|
import com.alibaba.excel.write.metadata.fill.FillWrapper; |
|
|
|
|
import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import jakarta.servlet.ServletOutputStream; |
|
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils; |
|
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.modules.business.excel.CustomMergeStrategy; |
|
|
|
|
import org.springblade.modules.business.excel.TemplateExcelUtils; |
|
|
|
|
import org.springblade.modules.business.mapper.MaintenanceTaskDetailMapper; |
|
|
|
|
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceOutputData; |
|
|
|
|
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTask; |
|
|
|
|
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTaskDetail; |
|
|
|
|
import org.springblade.modules.business.pojo.entity.MaintenanceTaskDetailGoods; |
|
|
|
|
import org.springblade.modules.business.pojo.entity.maintenance.*; |
|
|
|
|
import org.springblade.modules.business.service.IMaintenanceApplyGoodsService; |
|
|
|
|
import org.springblade.modules.business.service.IMaintenanceTaskDetailService; |
|
|
|
|
import org.springblade.modules.system.pojo.entity.User; |
|
|
|
|
import org.springblade.modules.system.service.IUserService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
@ -31,6 +43,7 @@ import java.net.URL; |
|
|
|
|
import java.net.URLConnection; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.zip.ZipEntry; |
|
|
|
|
import java.util.zip.ZipOutputStream; |
|
|
|
|
|
|
|
|
|
@ -43,6 +56,11 @@ import java.util.zip.ZipOutputStream; |
|
|
|
|
@Service |
|
|
|
|
public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<MaintenanceTaskDetailMapper, MaintenanceTaskDetail> implements IMaintenanceTaskDetailService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IUserService userService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IMaintenanceApplyGoodsService maintenanceApplyGoodsService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<MaintenanceTaskDetail> findListByDeviceId(Long deviceId) { |
|
|
|
|
@ -55,14 +73,35 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
|
String templateFile = "MaintenanceTaskReport.xlsx"; |
|
|
|
|
InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFile); |
|
|
|
|
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()); |
|
|
|
|
Map<String, Object> map0 = new HashMap<>(); |
|
|
|
|
map0.put("taskName", task.getDeptName()); |
|
|
|
|
String period = baseMapper.findPeriod(); |
|
|
|
|
map0.put("period",period + "度报告"); |
|
|
|
|
map0.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日")); |
|
|
|
|
map0.put("taskCode", task.getTaskCode()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("taskName", task.getDeptName()); |
|
|
|
|
map1.put("address", task.getDeptName()); |
|
|
|
|
map1.put("taskContent", task.getTaskContent()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map2 = new HashMap<>(); |
|
|
|
|
map2.put("taskName", task.getDeptName()); |
|
|
|
|
map2.put("address", task.getDeptName()); |
|
|
|
|
map2.put("inspectionConclusion", task.getInspectionConclusion()); |
|
|
|
|
map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); |
|
|
|
|
//获取客户联系人、联系电话
|
|
|
|
|
Map<String,String> cusMap = baseMapper.getDeptContact(task.getDeptId()); |
|
|
|
|
if(CollectionUtils.isNotEmpty(cusMap)){ |
|
|
|
|
map2.put("contact",cusMap.get("name")); //联系人
|
|
|
|
|
map2.put("phone",cusMap.get("phone")); //联系方式
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<MaintenanceTaskDetail> maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); |
|
|
|
|
List<MaintenanceOutputData> maintenanceOutputDataList = new ArrayList<>(); |
|
|
|
|
List<MaintenanceOutputData> maintenanceOutputDataList1 = new ArrayList<>(); |
|
|
|
|
long no = 0; |
|
|
|
|
long no1 = 0; |
|
|
|
|
for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { |
|
|
|
|
no++; |
|
|
|
|
MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); |
|
|
|
|
@ -101,33 +140,55 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
|
} 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); |
|
|
|
|
if(maintenanceTaskDetail.getStatus() == 1){ |
|
|
|
|
no1++; |
|
|
|
|
MaintenanceOutputData maintenanceOutputData1 = BeanUtil.copyProperties(maintenanceOutputData,MaintenanceOutputData.class); |
|
|
|
|
maintenanceOutputData1.setNo(no1); |
|
|
|
|
maintenanceOutputDataList1.add(maintenanceOutputData1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取签字图片
|
|
|
|
|
if (StringUtils.isNotBlank(task.getSignatureUrl())) { |
|
|
|
|
try { |
|
|
|
|
//获取图片
|
|
|
|
|
URL url = new URL(task.getSignatureUrl()); |
|
|
|
|
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, "png", arrayOutputStream); |
|
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
|
Double width = Double.valueOf(image.getWidth()); |
|
|
|
|
Double height = Double.valueOf(image.getHeight()); |
|
|
|
|
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); |
|
|
|
|
map2.put("image", voidWriteCellData); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
map2.put("image",null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//将数据导出到Excel
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(fileInputStream).build()) { |
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); |
|
|
|
|
excelWriter.fill(map, writeSheet); |
|
|
|
|
WriteSheet writeSheet0 = EasyExcel.writerSheet(0).build(); |
|
|
|
|
excelWriter.fill(map0, writeSheet0); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); |
|
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet1); |
|
|
|
|
excelWriter.fill(map1, writeSheet1); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet2 = EasyExcel.writerSheet(2).build(); |
|
|
|
|
excelWriter.fill(maintenanceOutputDataList1, fillConfig, writeSheet2); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet3 = EasyExcel.writerSheet(3).build(); |
|
|
|
|
excelWriter.fill(map2, writeSheet3); |
|
|
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
outputStream.flush(); |
|
|
|
|
outputStream.close(); |
|
|
|
|
@ -141,14 +202,36 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
|
String templateFile = "MaintenanceTaskReport.xlsx"; |
|
|
|
|
InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFile); |
|
|
|
|
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()); |
|
|
|
|
Map<String, Object> map0 = new HashMap<>(); |
|
|
|
|
map0.put("taskName", task.getDeptName()); |
|
|
|
|
String period = baseMapper.findPeriod(); |
|
|
|
|
map0.put("period",period + "度报告"); |
|
|
|
|
map0.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日")); |
|
|
|
|
map0.put("taskCode", task.getTaskCode()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("taskName", task.getDeptName()); |
|
|
|
|
map1.put("address", task.getDeptName()); |
|
|
|
|
map1.put("taskContent", task.getTaskContent()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map2 = new HashMap<>(); |
|
|
|
|
map2.put("taskName", task.getDeptName()); |
|
|
|
|
map2.put("address", task.getDeptName()); |
|
|
|
|
map2.put("inspectionConclusion", task.getInspectionConclusion()); |
|
|
|
|
map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); |
|
|
|
|
|
|
|
|
|
//获取客户联系人、联系电话
|
|
|
|
|
Map<String,String> cusMap = baseMapper.getDeptContact(task.getDeptId()); |
|
|
|
|
if(CollectionUtils.isNotEmpty(cusMap)){ |
|
|
|
|
map2.put("contact",cusMap.get("name")); //联系人
|
|
|
|
|
map2.put("phone",cusMap.get("phone")); //联系方式
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<MaintenanceTaskDetail> maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); |
|
|
|
|
List<MaintenanceOutputData> maintenanceOutputDataList = new ArrayList<>(); |
|
|
|
|
List<MaintenanceOutputData> maintenanceOutputDataList1 = new ArrayList<>(); |
|
|
|
|
long no = 0; |
|
|
|
|
long no1 = 0; |
|
|
|
|
for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { |
|
|
|
|
no++; |
|
|
|
|
MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); |
|
|
|
|
@ -187,40 +270,191 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc |
|
|
|
|
} 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); |
|
|
|
|
if(maintenanceTaskDetail.getStatus() == 1){ |
|
|
|
|
no1++; |
|
|
|
|
MaintenanceOutputData maintenanceOutputData1 = BeanUtil.copyProperties(maintenanceOutputData,MaintenanceOutputData.class); |
|
|
|
|
maintenanceOutputData1.setNo(no1); |
|
|
|
|
maintenanceOutputDataList1.add(maintenanceOutputData1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//获取签字图片
|
|
|
|
|
if (StringUtils.isNotBlank(task.getSignatureUrl())) { |
|
|
|
|
try { |
|
|
|
|
//获取图片
|
|
|
|
|
URL url = new URL(task.getSignatureUrl()); |
|
|
|
|
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, "png", arrayOutputStream); |
|
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
|
Double width = Double.valueOf(image.getWidth()); |
|
|
|
|
Double height = Double.valueOf(image.getHeight()); |
|
|
|
|
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); |
|
|
|
|
map2.put("image", voidWriteCellData); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
map2.put("image",null); |
|
|
|
|
} |
|
|
|
|
//将数据导出到Excel
|
|
|
|
|
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); |
|
|
|
|
String fileName = task.getTaskCode() + "巡检报告.xlsx"; |
|
|
|
|
zos.putNextEntry(new ZipEntry(fileName)); |
|
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(zos).withTemplate(fileInputStream).build()) { |
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); |
|
|
|
|
excelWriter.fill(map, writeSheet); |
|
|
|
|
WriteSheet writeSheet0 = EasyExcel.writerSheet(0).build(); |
|
|
|
|
excelWriter.fill(map0, writeSheet0); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); |
|
|
|
|
excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet1); |
|
|
|
|
excelWriter.fill(map1, writeSheet1); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet2 = EasyExcel.writerSheet(2).build(); |
|
|
|
|
excelWriter.fill(maintenanceOutputDataList1, fillConfig, writeSheet2); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet3 = EasyExcel.writerSheet(3).build(); |
|
|
|
|
excelWriter.fill(map2, writeSheet3); |
|
|
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
zos.flush(); |
|
|
|
|
zos.closeEntry(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void repairOutputService(MaintenanceTask task, HttpServletResponse response) throws IOException { |
|
|
|
|
//数据获取
|
|
|
|
|
String templateFile = "RepairService.xlsx"; |
|
|
|
|
InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFile); |
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
|
Map<String, Object> map0 = new HashMap<>(); |
|
|
|
|
map0.put("taskName", task.getDeptName()); //客户名称
|
|
|
|
|
map0.put("address", task.getDeptName()); //地址
|
|
|
|
|
//获取客户联系人、联系电话
|
|
|
|
|
Map<String,String> cusMap = baseMapper.getDeptContact(task.getDeptId()); |
|
|
|
|
if(CollectionUtils.isNotEmpty(cusMap)){ |
|
|
|
|
map0.put("contact",cusMap.get("name")); //联系人
|
|
|
|
|
map0.put("phone",cusMap.get("phone")); //联系方式
|
|
|
|
|
} |
|
|
|
|
map0.put("servicemanName", task.getServicemanName()); //维修工程师
|
|
|
|
|
map0.put("inspectionConclusion", task.getInspectionConclusion()); //维修结论
|
|
|
|
|
if(task.getServicemanId() != null){ |
|
|
|
|
User serviceman = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, task.getServicemanId())); |
|
|
|
|
map0.put("servicemanPhone", serviceman.getPhone()); //维修工程师联系方式
|
|
|
|
|
} |
|
|
|
|
map0.put("faultDescribe",task.getFaultDescribe()); //故障现象
|
|
|
|
|
map0.put("faultCause",task.getFaultCause()); //故障原因
|
|
|
|
|
map0.put("travelExpense",task.getTravelExpense()==null?0:task.getTravelExpense()); //维修差旅费
|
|
|
|
|
map0.put("processingResult",task.getProcessingResult()); //处理结果
|
|
|
|
|
map0.put("finishTime",task.getFinishTime() != null ? DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日") : ""); //维修结束时间
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("taskName", task.getDeptName()); |
|
|
|
|
map1.put("address", task.getDeptName()); |
|
|
|
|
if(CollectionUtils.isNotEmpty(cusMap)){ |
|
|
|
|
map1.put("contact",cusMap.get("name")); //联系人
|
|
|
|
|
map1.put("phone",cusMap.get("phone")); //联系方式
|
|
|
|
|
} |
|
|
|
|
map1.put("inspectionConclusion", task.getInspectionConclusion()); |
|
|
|
|
map1.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); //客户签字时间
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<RepairGoodsOutputData> repairGoodsList = new ArrayList<>(); |
|
|
|
|
List<RepairGoodsOutputData> unRepairGoodsList = new ArrayList<>(); |
|
|
|
|
long no = 0; |
|
|
|
|
long no1 = 0; |
|
|
|
|
double total = 0.0; |
|
|
|
|
double total1 = 0.0; |
|
|
|
|
List<MaintenanceTaskDetail> taskDetailList = this.list(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId,task.getId()).eq(BaseEntity::getIsDeleted,0)); |
|
|
|
|
if(CollectionUtils.isNotEmpty(taskDetailList)){ |
|
|
|
|
Map<Integer,List<MaintenanceTaskDetail>> taskDetailMap = taskDetailList.stream().collect(Collectors.groupingBy(MaintenanceTaskDetail::getIsRepair)); |
|
|
|
|
for (Map.Entry<Integer, List<MaintenanceTaskDetail>> entry : taskDetailMap.entrySet()) { |
|
|
|
|
if(entry.getKey() == 1){ |
|
|
|
|
for(MaintenanceTaskDetail detail : entry.getValue()){ |
|
|
|
|
List<MaintenanceTaskDetailGoods> list = maintenanceApplyGoodsService.list(Wrappers.lambdaQuery(MaintenanceTaskDetailGoods.class).eq(MaintenanceTaskDetailGoods::getParentId,detail.getId()).eq(BaseEntity::getIsDeleted,0)); |
|
|
|
|
if(CollectionUtils.isNotEmpty(list)){ |
|
|
|
|
for(MaintenanceTaskDetailGoods goods : list){ |
|
|
|
|
no++; |
|
|
|
|
RepairGoodsOutputData repairGoodsOutputData = new RepairGoodsOutputData(); |
|
|
|
|
repairGoodsOutputData.setNo(no); |
|
|
|
|
repairGoodsOutputData.setGoodsName(goods.getGoodsName()); |
|
|
|
|
repairGoodsOutputData.setNumber(goods.getNumber()); |
|
|
|
|
repairGoodsOutputData.setPrice(goods.getPrice()); |
|
|
|
|
repairGoodsOutputData.setTotalPrice(goods.getNumber() * goods.getPrice()); |
|
|
|
|
repairGoodsList.add(repairGoodsOutputData); |
|
|
|
|
total+=goods.getNumber() * goods.getPrice(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
for(MaintenanceTaskDetail detail : entry.getValue()){ |
|
|
|
|
List<MaintenanceTaskDetailGoods> list = maintenanceApplyGoodsService.list(Wrappers.lambdaQuery(MaintenanceTaskDetailGoods.class).eq(MaintenanceTaskDetailGoods::getParentId,detail.getId()).eq(BaseEntity::getIsDeleted,0)); |
|
|
|
|
if(CollectionUtils.isNotEmpty(list)){ |
|
|
|
|
for(MaintenanceTaskDetailGoods goods : list){ |
|
|
|
|
no1++; |
|
|
|
|
RepairGoodsOutputData unRepairGoodsOutputData = new RepairGoodsOutputData(); |
|
|
|
|
unRepairGoodsOutputData.setNo(no1); |
|
|
|
|
unRepairGoodsOutputData.setGoodsName(goods.getGoodsName()); |
|
|
|
|
unRepairGoodsOutputData.setNumber(goods.getNumber()); |
|
|
|
|
unRepairGoodsOutputData.setPrice(goods.getPrice()); |
|
|
|
|
unRepairGoodsOutputData.setTotalPrice(goods.getNumber() * goods.getPrice()); |
|
|
|
|
unRepairGoodsList.add(unRepairGoodsOutputData); |
|
|
|
|
total1+=goods.getNumber() * goods.getPrice(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
map0.put("total",total); //维修材料费用
|
|
|
|
|
map0.put("repairTotal", (task.getTravelExpense() == null ? 0.0 : task.getTravelExpense()) + total); //维修费总计
|
|
|
|
|
map0.put("total1",total1); //未维修项目材料费用
|
|
|
|
|
|
|
|
|
|
//获取签字图片
|
|
|
|
|
if (StringUtils.isNotBlank(task.getSignatureUrl())) { |
|
|
|
|
try { |
|
|
|
|
//获取图片
|
|
|
|
|
URL url = new URL(task.getSignatureUrl()); |
|
|
|
|
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, "png", arrayOutputStream); |
|
|
|
|
byte[] bytes = arrayOutputStream.toByteArray(); |
|
|
|
|
Double width = Double.valueOf(image.getWidth()); |
|
|
|
|
Double height = Double.valueOf(image.getHeight()); |
|
|
|
|
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); |
|
|
|
|
map0.put("image", voidWriteCellData); |
|
|
|
|
map1.put("image", voidWriteCellData); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
map0.put("image",null); |
|
|
|
|
map1.put("image",null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//将数据导出到Excel
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(fileInputStream).build()) { |
|
|
|
|
WriteSheet writeSheet0 = EasyExcel.writerSheet(0).registerWriteHandler(new CustomMergeStrategy()).build(); |
|
|
|
|
excelWriter.fill(map0, writeSheet0); |
|
|
|
|
excelWriter.fill(new FillWrapper("data1", repairGoodsList),fillConfig, writeSheet0); |
|
|
|
|
excelWriter.fill(new FillWrapper("data2", unRepairGoodsList),fillConfig, writeSheet0); |
|
|
|
|
|
|
|
|
|
WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); |
|
|
|
|
excelWriter.fill(map1, writeSheet1); |
|
|
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
outputStream.flush(); |
|
|
|
|
outputStream.close(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|