|
|
|
|
@ -7,6 +7,7 @@ import com.alibaba.excel.metadata.data.ImageData; |
|
|
|
|
import com.alibaba.excel.metadata.data.WriteCellData; |
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import io.undertow.util.FileUtils; |
|
|
|
|
import jakarta.servlet.ServletOutputStream; |
|
|
|
|
@ -572,6 +573,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
//数据获取
|
|
|
|
|
String templateFileName = "WorkOrderServiceSheet.xlsx"; |
|
|
|
|
InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFileName); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
double total = workOrder.getTotalPrice(); |
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
|
List<WorkOrderRepairMaterial> workOrderRepairMaterialList = workOrderRepairMaterialService.list(Wrappers.lambdaQuery(WorkOrderRepairMaterial.class).eq(WorkOrderRepairMaterial::getOrderId, workOrder.getId())); |
|
|
|
|
@ -587,10 +589,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workOrderFillData.setPrice(price); |
|
|
|
|
workOrderFillDataList.add(workOrderFillData); |
|
|
|
|
} |
|
|
|
|
ImageExcelData imageExcelData = new ImageExcelData(); |
|
|
|
|
imageExcelData.setUrl(new URL(workOrder.getSignatureUrl())); |
|
|
|
|
// ImageExcelData imageExcelData = new ImageExcelData();
|
|
|
|
|
// imageExcelData.setUrl(new URL(workOrder.getSignatureUrl()));
|
|
|
|
|
//获取签字图片
|
|
|
|
|
URL url = new URL(workOrder.getSignatureUrl()); |
|
|
|
|
Optional<String> signatureUrl = Optional.ofNullable(workOrder.getSignatureUrl()); |
|
|
|
|
if (signatureUrl.isPresent() && StringUtils.isNotBlank(signatureUrl.get())) { |
|
|
|
|
URL url = new URL(signatureUrl.get()); |
|
|
|
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); |
|
|
|
|
httpURLConnection.setRequestMethod("GET"); |
|
|
|
|
httpURLConnection.setDoInput(true); |
|
|
|
|
@ -608,8 +612,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
Double width = Double.valueOf(image.getWidth()); |
|
|
|
|
Double height = Double.valueOf(image.getHeight()); |
|
|
|
|
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(imageBytes, width, height, 0.6, 1.9); |
|
|
|
|
map.put("image", voidWriteCellData); |
|
|
|
|
} |
|
|
|
|
User repairPerson = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getRepairPerson())); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
User customer = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getInformant())); |
|
|
|
|
map.put("customerName", customer.getRealName()); |
|
|
|
|
map.put("informant", customer.getRealName()); |
|
|
|
|
@ -621,28 +626,38 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
map.put("processMethod", workOrder.getProcessMethod()); |
|
|
|
|
map.put("repairPerson", repairPerson.getRealName()); |
|
|
|
|
map.put("repairPersonPhone", repairPerson.getPhone()); |
|
|
|
|
map.put("laborCost", workOrder.getLaborCost()); |
|
|
|
|
//转换日期格式
|
|
|
|
|
Date finishTime = workOrder.getFinishTime(); |
|
|
|
|
Optional<Date> finishTime = Optional.ofNullable(workOrder.getFinishTime()); |
|
|
|
|
if (finishTime.isPresent()) { |
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
|
|
|
|
map.put("finishTime", simpleDateFormat.format(finishTime)); |
|
|
|
|
map.put("image", voidWriteCellData); |
|
|
|
|
Device device = deviceService.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getId, workOrder.getDeviceId())); |
|
|
|
|
Optional<Integer> isWarran = Optional.ofNullable(device.getIsWarran()); |
|
|
|
|
if (isWarran.isPresent()) { |
|
|
|
|
if (isWarran.get() == 1) { |
|
|
|
|
map.put("in", "--"); |
|
|
|
|
map.put("out", total); |
|
|
|
|
map.put("sel2", "√"); |
|
|
|
|
} else { |
|
|
|
|
map.put("in", total); |
|
|
|
|
map.put("finishTime", simpleDateFormat.format(finishTime.get())); |
|
|
|
|
} |
|
|
|
|
Optional<Device> device = Optional.ofNullable(deviceService.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getId, workOrder.getDeviceId()))); |
|
|
|
|
if (device.isPresent()) { |
|
|
|
|
Optional<Long> limsId = Optional.ofNullable(device.get().getLimsId()); |
|
|
|
|
if (limsId.isPresent()) { |
|
|
|
|
map.put("in", total + workOrder.getLaborCost()); |
|
|
|
|
map.put("out", "--"); |
|
|
|
|
map.put("sel1", "√"); |
|
|
|
|
map.put("sel2", null); |
|
|
|
|
map.put("inTravel", workOrder.getTravelExpense()); |
|
|
|
|
map.put("outTravel", "--"); |
|
|
|
|
} else { |
|
|
|
|
map.put("in", "--"); |
|
|
|
|
map.put("out", total + workOrder.getLaborCost()); |
|
|
|
|
map.put("sel2", "√"); |
|
|
|
|
map.put("sel1", null); |
|
|
|
|
map.put("outTravel", workOrder.getTravelExpense()); |
|
|
|
|
map.put("inTravel", "--"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
map.put("in", "--"); |
|
|
|
|
map.put("out", "--"); |
|
|
|
|
map.put("out", total + workOrder.getLaborCost()); |
|
|
|
|
map.put("sel2", "√"); |
|
|
|
|
map.put("sel1", null); |
|
|
|
|
map.put("outTravel", workOrder.getTravelExpense()); |
|
|
|
|
map.put("inTravel", "--"); |
|
|
|
|
} |
|
|
|
|
Optional<Integer> status = Optional.ofNullable(workOrder.getStatus()); |
|
|
|
|
if (status.isPresent()) { |
|
|
|
|
@ -673,6 +688,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
//数据获取
|
|
|
|
|
String templateFileName = "WorkOrderServiceSheet.xlsx"; |
|
|
|
|
InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFileName); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
double total = workOrder.getTotalPrice(); |
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
|
List<WorkOrderRepairMaterial> workOrderRepairMaterialList = workOrderRepairMaterialService.list(Wrappers.lambdaQuery(WorkOrderRepairMaterial.class).eq(WorkOrderRepairMaterial::getOrderId, workOrder.getId())); |
|
|
|
|
@ -688,10 +704,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workOrderFillData.setPrice(price); |
|
|
|
|
workOrderFillDataList.add(workOrderFillData); |
|
|
|
|
} |
|
|
|
|
ImageExcelData imageExcelData = new ImageExcelData(); |
|
|
|
|
imageExcelData.setUrl(new URL(workOrder.getSignatureUrl())); |
|
|
|
|
// ImageExcelData imageExcelData = new ImageExcelData();
|
|
|
|
|
// imageExcelData.setUrl(new URL(workOrder.getSignatureUrl()));
|
|
|
|
|
//获取签字图片
|
|
|
|
|
URL url = new URL(workOrder.getSignatureUrl()); |
|
|
|
|
Optional<String> signatureUrl = Optional.ofNullable(workOrder.getSignatureUrl()); |
|
|
|
|
if (signatureUrl.isPresent() && StringUtils.isNotBlank(signatureUrl.get())) { |
|
|
|
|
URL url = new URL(signatureUrl.get()); |
|
|
|
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); |
|
|
|
|
httpURLConnection.setRequestMethod("GET"); |
|
|
|
|
httpURLConnection.setDoInput(true); |
|
|
|
|
@ -709,8 +727,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
Double width = Double.valueOf(image.getWidth()); |
|
|
|
|
Double height = Double.valueOf(image.getHeight()); |
|
|
|
|
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(imageBytes, width, height, 0.6, 1.9); |
|
|
|
|
map.put("image", voidWriteCellData); |
|
|
|
|
} |
|
|
|
|
User repairPerson = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getRepairPerson())); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
User customer = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getInformant())); |
|
|
|
|
map.put("customerName", customer.getRealName()); |
|
|
|
|
map.put("informant", customer.getRealName()); |
|
|
|
|
@ -722,28 +741,35 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
map.put("processMethod", workOrder.getProcessMethod()); |
|
|
|
|
map.put("repairPerson", repairPerson.getRealName()); |
|
|
|
|
map.put("repairPersonPhone", repairPerson.getPhone()); |
|
|
|
|
map.put("laborCost", workOrder.getLaborCost()); |
|
|
|
|
//转换日期格式
|
|
|
|
|
Date finishTime = workOrder.getFinishTime(); |
|
|
|
|
Optional<Date> finishTime = Optional.ofNullable(workOrder.getFinishTime()); |
|
|
|
|
if (finishTime.isPresent()) { |
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
|
|
|
|
map.put("finishTime", simpleDateFormat.format(finishTime)); |
|
|
|
|
map.put("image", voidWriteCellData); |
|
|
|
|
Device device = deviceService.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getId, workOrder.getDeviceId())); |
|
|
|
|
Optional<Integer> isWarran = Optional.ofNullable(device.getIsWarran()); |
|
|
|
|
if (isWarran.isPresent()) { |
|
|
|
|
if (isWarran.get() == 1) { |
|
|
|
|
map.put("in", "--"); |
|
|
|
|
map.put("ou", total); |
|
|
|
|
map.put("sel2", "√"); |
|
|
|
|
} else { |
|
|
|
|
map.put("in", total); |
|
|
|
|
map.put("finishTime", simpleDateFormat.format(finishTime.get())); |
|
|
|
|
} |
|
|
|
|
Optional<Device> device = Optional.ofNullable(deviceService.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getId, workOrder.getDeviceId()))); |
|
|
|
|
if (device.isPresent()) { |
|
|
|
|
Optional<Long> limsId = Optional.ofNullable(device.get().getLimsId()); |
|
|
|
|
if (limsId.isPresent()) { |
|
|
|
|
map.put("in", total + workOrder.getLaborCost()); |
|
|
|
|
map.put("out", "--"); |
|
|
|
|
map.put("sel1", "√"); |
|
|
|
|
map.put("sel2", null); |
|
|
|
|
map.put("inTravel", workOrder.getTravelExpense()); |
|
|
|
|
} else { |
|
|
|
|
map.put("in", "--"); |
|
|
|
|
map.put("out", total + workOrder.getLaborCost()); |
|
|
|
|
map.put("sel2", "√"); |
|
|
|
|
map.put("sel1", null); |
|
|
|
|
map.put("outTravel", workOrder.getTravelExpense()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
map.put("in", "--"); |
|
|
|
|
map.put("out", "--"); |
|
|
|
|
map.put("out", total + workOrder.getLaborCost()); |
|
|
|
|
map.put("sel2", "√"); |
|
|
|
|
map.put("sel1", null); |
|
|
|
|
map.put("outTravel", workOrder.getTravelExpense()); |
|
|
|
|
} |
|
|
|
|
Optional<Integer> status = Optional.ofNullable(workOrder.getStatus()); |
|
|
|
|
if (status.isPresent()) { |
|
|
|
|
|