Commit f0481eb9 by levphon

车型bug修复、工单图片优化

1 parent 297f45b2
......@@ -33,7 +33,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.List;
......@@ -65,14 +64,6 @@ public class WorkOrderController {
@ApiOperation(value = "工单照片导出")
@GetMapping(value = "/batchExportPics")
public void batchExportPics(HttpServletResponse response, WorkOrderSearch search) throws IOException {
String filename = new String(DateUtils.formatSerial(new Date()).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + ".zip";
response.reset();
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentType("application/octet-stream; charset=utf-8");
response.setCharacterEncoding("UTF-8");
if (CollectionUtils.isEmpty(search.getOrderIds())) {
throw new AdminException("参数为空");
}
......@@ -126,7 +117,6 @@ public class WorkOrderController {
* 编辑工单
*
* @param workOrderBO
*
* @return
*/
@SysLog(module = MODULE, value = "编辑工单", action = OperateType.EDIT)
......
......@@ -943,13 +943,17 @@ public class VehicleService {
Map<Integer, List<VehicleTypeModel>> typesMap = typesList.stream().collect(Collectors.groupingBy(VehicleTypeModel::getPid));
brandList.forEach(brand -> {
brand.setChilds(transCarTypeChild(subBrandMap.get(brand.getPid())));
subBrandList.forEach(subBrand -> {
subBrand.setChilds(transCarTypeChild(seriesMap.get(subBrand.getPid())));
seriesList.forEach(series -> {
series.setChilds(transCarTypeChild(typesMap.get(series.getPid())));
brand.setChilds(transCarTypeChild(subBrandMap.get(brand.getId())));
if (CollectionUtils.isNotEmpty(brand.getChilds())) {
brand.getChilds().forEach(subBrand -> {
subBrand.setChilds(transCarTypeChild(seriesMap.get(subBrand.getId())));
if (CollectionUtils.isNotEmpty(subBrand.getChilds())) {
subBrand.getChilds().forEach(series -> {
series.setChilds(transCarTypeChild(typesMap.get(series.getId())));
});
}
});
});
}
});
return brandList;
}
......@@ -964,7 +968,12 @@ public class VehicleService {
private List<CarInfoSelected> transCarTypeChild(List<VehicleTypeModel> modelList) {
List<CarInfoSelected> list = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(modelList)) {
modelList.forEach(vtm -> {
CarInfoSelected selected = new CarInfoSelected();
selected.setId(vtm.getId());
selected.setName(vtm.getName());
list.add(selected);
});
}
return list;
}
......
......@@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.DateUtils;
import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
......@@ -46,9 +47,12 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
......@@ -143,10 +147,11 @@ public class WorkOrderService {
List<WorkOrderVehicle> wvList = workOrderVehicleMapper.selectByOrderIds(search.getOrderIds());
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (WorkOrderVehicle wv : wvList) {
final ZipOutputStream out = new ZipOutputStream(baos);
for (WorkOrderVehicle wv : wvList) {
List<WorkOrderDocs> woDocs = docsMap.get(wv.getWorkOrderId());
String vinPath = wv.getVin() + File.separator;
......@@ -154,27 +159,32 @@ public class WorkOrderService {
ZipEntry vinDir = new ZipEntry(vinPath);
if (CollectionUtils.isNotEmpty(woDocs)) {
zos.putNextEntry(vinDir);
//车架号目录
out.putNextEntry(vinDir);
for (WorkOrderDocs doc : woDocs) {
byte[] bytes = HttpUtils.downloadBytes(doc.getPath());
String filename = doc.getName();
if (!filename.contains(".")) {
String suffix = doc.getPath().substring(doc.getPath().lastIndexOf("."));
filename = filename + suffix;
if (StringUtils.isNullOrEmpty(filename)) {
filename = doc.getPath().substring(doc.getPath().lastIndexOf("/"));
} else {
if (!filename.contains(".")) {
String suffix = doc.getPath().substring(doc.getPath().lastIndexOf("."));
filename = filename + suffix;
}
}
zos.putNextEntry(new ZipEntry(vinPath + filename));
zos.write(bytes, 0, bytes.length);
out.putNextEntry(new ZipEntry(vinPath + filename));
out.write(bytes, 0, bytes.length);
}
}
}
zos.flush();
zos.close();
out.close();
String filename = new String(DateUtils.formatSerial(new Date()).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + ".zip";
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
response.setHeader("Content-Type", "application/zip");
response.getOutputStream().write(baos.toByteArray());
response.flushBuffer();
baos.close();
}
public List<WorkOrderImport> batchImport(List<WorkOrderImport> importList) {
......@@ -580,7 +590,7 @@ public class WorkOrderService {
}
public WorkOrder getSingleWorkOrderInfoById(Long workOrderId) {
if (workOrderId==null) {
if (workOrderId == null) {
return null;
}
WorkOrder workOrder = workOrderMapper.selectById(workOrderId);
......
......@@ -16,6 +16,7 @@ public class FileConstants {
public static final String PDF_TYPE = "pdf";
public static final String PNG_TYPE = "png";
public static final String JPG_TYPE = "jpg";
public static final String ZIP_TYPE = "zip";
/**
* 文件服务器地址
......
......@@ -49,7 +49,7 @@ public class FileUploadUtil {
*/
public static FileUploadServerData uploadToFileSystem(String fileName, byte[] uploadData, String fileType) {
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("systemSign", "salesexcel");
form.add("filePath", "");
form.add("param1", fileName);
......@@ -67,7 +67,7 @@ public class FileUploadUtil {
*/
public static FileUploadServerData zipToFileSystem(List filePathList) {
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("systemSign", "salesexcelzip");
form.add("filePath", "");
form.add("param1", "");
......
......@@ -88,7 +88,7 @@
</select>
<select id="selectBrandByTenantIds" resultType="cn.com.glsx.admin.modules.model.VehicleTypeModel">
select brand_id id,brand_name name
select distinct brand_id id,brand_name name
from t_tenant_vehicle_type
where del_flag = 0
and enable_status = 1
......@@ -100,7 +100,7 @@
</select>
<select id="selectSubBrandByTenantIds" resultType="cn.com.glsx.admin.modules.model.VehicleTypeModel">
select sub_brand_id id,sub_brand_name name, brand_id pid
select distinct sub_brand_id id,sub_brand_name name, brand_id pid
from t_tenant_vehicle_type
where del_flag = 0
and enable_status = 1
......@@ -115,7 +115,7 @@
</select>
<select id="selectSeriesByTenantIds" resultType="cn.com.glsx.admin.modules.model.VehicleTypeModel">
select series_id id,series_name name, sub_brand_id pid
select distinct series_id id,series_name name, sub_brand_id pid
from t_tenant_vehicle_type
where del_flag = 0
and enable_status = 1
......@@ -130,7 +130,7 @@
</select>
<select id="selectTypesByTenantIds" resultType="cn.com.glsx.admin.modules.model.VehicleTypeModel">
select type_id id,type_name name, series_id pid
select distinct type_id id,type_name name, series_id pid
from t_tenant_vehicle_type
where del_flag = 0
and enable_status = 1
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!