开发OTA备案工具-导入导出
This commit is contained in:
+24
@@ -18,6 +18,7 @@ import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -184,4 +185,27 @@ public class OtaBaCxJsfzbacsController extends JeroController<OtaBaCxJsfzbacs, I
|
||||
return super.importExcel(request, response, OtaBaCxJsfzbacs.class);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "车型备案-驾驶辅助系统基础备案参数-模板下载")
|
||||
@GetMapping(value = "/exportTemplate")
|
||||
// @RequiresPermissions("otaBaCx:exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
this.otaBaCxJsfzbacsService.exportTemplate(response, request);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "车型备案-驾驶辅助系统基础备案参数-数据导入")
|
||||
@PostMapping(value = "/importData")
|
||||
// @RequiresPermissions("otaBaCx:importData")
|
||||
public Result<?> importData(@RequestParam(value = "file", required = false) MultipartFile file,
|
||||
@RequestParam(value = "cut", required = false) String cut,
|
||||
@RequestParam(value = "otaId", required = false) String otaId) throws Exception {
|
||||
try {
|
||||
this.otaBaCxJsfzbacsService.importData(file, otaId, cut);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -3,7 +3,10 @@ package com.jero.modules.ota.service;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.modules.ota.entity.OtaBaCxJsfzbacs;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -61,4 +64,8 @@ public interface IOtaBaCxJsfzbacsService extends IService<OtaBaCxJsfzbacs> {
|
||||
List<OtaBaCxJsfzbacs> queryList();
|
||||
|
||||
JSONObject queryByOtaId(String otaId, String otaIdT);
|
||||
|
||||
void exportTemplate(HttpServletResponse response, HttpServletRequest request);
|
||||
|
||||
void importData(MultipartFile file, String otaId, String cut) throws Exception;
|
||||
}
|
||||
|
||||
+12
-3
@@ -163,13 +163,22 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
|
||||
|
||||
@Override
|
||||
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) {
|
||||
ImportFileUtil.exportTemplate(response, templatePath + "车型基本信息.xlsx");
|
||||
ImportFileUtil.exportTemplate(response, templatePath + "车型基本信息.zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OtaBaCxJbxx importData(MultipartFile file, String otaId, String cut) throws Exception {
|
||||
File upLoadFile = ImportFileUtil.importFile(file, cut, uploadPath, "xlsx");
|
||||
OtaBaCxJbxx jbxx = parseFile(upLoadFile, cut);
|
||||
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
|
||||
File upFile = null;
|
||||
for (File f : upLoadFiles) {
|
||||
if (f.getName().equals("可在线升级的系统名称与参数.xlsx")) {
|
||||
upFile = f;
|
||||
}
|
||||
}
|
||||
if (null == upFile) {
|
||||
throw new JeroBootException("请上传正确的文件");
|
||||
}
|
||||
OtaBaCxJbxx jbxx = parseFile(upFile, cut);
|
||||
jbxx.setOtaId(otaId);
|
||||
return add(jbxx);
|
||||
}
|
||||
|
||||
+40
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.ota.entity.OtaBaCxJsfzbacs;
|
||||
import com.jero.modules.ota.entity.OtaBaCxSjmk;
|
||||
import com.jero.modules.ota.entity.OtaBaCxTxjl;
|
||||
@@ -14,11 +15,17 @@ import com.jero.modules.ota.service.IOtaBaCxJsfzbacsService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxSjmkService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
|
||||
import com.jero.modules.ota.utils.ComparisonUtil;
|
||||
import com.jero.modules.ota.utils.ImportFileUtil;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
@@ -31,6 +38,12 @@ import java.util.*;
|
||||
@Service
|
||||
public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMapper, OtaBaCxJsfzbacs> implements IOtaBaCxJsfzbacsService {
|
||||
|
||||
@Value(value = "${ota.templatePath}")
|
||||
private String templatePath;
|
||||
|
||||
@Value(value = "${ota.uploadPath}")
|
||||
private String uploadPath;
|
||||
|
||||
@Autowired
|
||||
private IOtaBaCxTxjlService otaBaCxTxjlService;
|
||||
|
||||
@@ -221,5 +234,32 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
|
||||
return this.getOne(queryWrapper, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) {
|
||||
ImportFileUtil.exportTemplate(response, templatePath + "驾驶辅助系统基础备案参数.zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importData(MultipartFile file, String otaId, String cut) throws Exception {
|
||||
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
|
||||
File upFile = null;
|
||||
for (File f : upLoadFiles) {
|
||||
if (f.getName().equals("驾驶辅助系统基础备案参数.xlsx")) {
|
||||
upFile = f;
|
||||
}
|
||||
}
|
||||
if (null == upFile) {
|
||||
throw new JeroBootException("请上传正确的文件");
|
||||
}
|
||||
JSONObject json = parseFile(upFile, otaId, cut);
|
||||
}
|
||||
|
||||
private JSONObject parseFile(File upFile, String otaId, String cut) {
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("otaId",otaId);
|
||||
|
||||
|
||||
|
||||
return jsonObj;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user