开发OTA备案工具-车辆升级

This commit is contained in:
高嵩
2023-03-29 00:37:49 +08:00
parent 5843bd2a1e
commit 2e59c45189
14 changed files with 977 additions and 557 deletions
@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -171,7 +172,6 @@ public class OtaBaSjListController extends JeroController<OtaBaSjList, IOtaBaSjL
/** /**
* 备案维护 * 备案维护
*
*/ */
@AutoLog(value = "升级备案-备案维护") @AutoLog(value = "升级备案-备案维护")
@ApiOperation(value = "升级备案-备案维护", notes = "升级备案-备案维护") @ApiOperation(value = "升级备案-备案维护", notes = "升级备案-备案维护")
@@ -185,4 +185,37 @@ public class OtaBaSjListController extends JeroController<OtaBaSjList, IOtaBaSjL
return Result.OK("备案维护成功!"); return Result.OK("备案维护成功!");
} }
@ApiOperation(value = "升级备案-模板下载")
@GetMapping(value = "/exportTemplate")
// @RequiresPermissions("otaBaCx:exportTemplate")
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
this.otaBaSjListService.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) throws Exception {
try {
this.otaBaSjListService.importData(file, cut);
} catch (Exception e) {
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK("导入成功");
}
@ApiOperation(value = "升级备案-数据导出")
@GetMapping(value = "/exportData")
// @RequiresPermissions("otaBaCx:exportTemplate")
public void exportData(@RequestParam(value = "otaId", required = false) String otaId, HttpServletResponse response, HttpServletRequest request) {
try {
this.otaBaSjListService.exportData(otaId, response, request);
} catch (Exception e) {
e.printStackTrace();
}
}
} }
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.ota.entity.OtaBaCxJbxx; import com.jero.modules.ota.entity.OtaBaCxJbxx;
@@ -17,6 +18,7 @@ import com.jero.common.system.base.controller.JeroController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -180,4 +182,29 @@ public class OtaBaSjSjmbclController extends JeroController<OtaBaSjSjmbcl, IOtaB
return super.importExcel(request, response, OtaBaSjSjmbcl.class); return super.importExcel(request, response, OtaBaSjSjmbcl.class);
} }
@ApiOperation(value = "升级备案-升级目标车辆-模板下载")
@GetMapping(value = "/exportTemplate")
// @RequiresPermissions("otaBaCx:exportTemplate")
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
this.otaBaSjSjmbclService.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 {
OtaBaSjSjmbcl res;
try {
String[] params = otaId.split("\\?");
otaId = params[0].equals("null") ? "" : params[0];
cut = params[1].replace("cut=", "");
res = this.otaBaSjSjmbclService.importData(file, otaId, cut);
} catch (Exception e) {
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK(res);
}
} }
@@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaSjSjmbcl; import com.jero.modules.ota.entity.OtaBaSjSjmbcl;
import com.jero.modules.ota.entity.OtaBaSjSjmbcx; import com.jero.modules.ota.entity.OtaBaSjSjmbcx;
import com.jero.modules.ota.service.IOtaBaSjSjmbcxService; import com.jero.modules.ota.service.IOtaBaSjSjmbcxService;
@@ -17,6 +18,7 @@ import com.jero.common.system.base.controller.JeroController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -180,4 +182,31 @@ public class OtaBaSjSjmbcxController extends JeroController<OtaBaSjSjmbcx, IOtaB
return super.importExcel(request, response, OtaBaSjSjmbcx.class); return super.importExcel(request, response, OtaBaSjSjmbcx.class);
} }
@ApiOperation(value = "升级备案-升级目标车型-模板下载")
@GetMapping(value = "/exportTemplate")
// @RequiresPermissions("otaBaCx:exportTemplate")
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
this.otaBaSjSjmbcxService.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 {
OtaBaSjSjmbcx res;
try {
String[] params = otaId.split("\\?");
otaId = params[0].equals("null") ? "" : params[0];
cut = params[1].replace("cut=", "");
res = this.otaBaSjSjmbcxService.importData(file, otaId, cut);
} catch (Exception e) {
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK(res);
}
} }
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.ota.entity.OtaBaCxAqcs; import com.jero.modules.ota.entity.OtaBaCxAqcs;
@@ -17,6 +18,7 @@ import com.jero.common.system.base.controller.JeroController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -186,4 +188,30 @@ public class OtaBaSjSjyxpgController extends JeroController<OtaBaSjSjyxpg, IOtaB
return super.importExcel(request, response, OtaBaSjSjyxpg.class); return super.importExcel(request, response, OtaBaSjSjyxpg.class);
} }
@ApiOperation(value = "车型备案-安全措施-模板下载")
@GetMapping(value = "/exportTemplate")
// @RequiresPermissions("otaBaCx:exportTemplate")
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
this.otaBaSjSjyxpgService.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 {
OtaBaSjSjyxpg res;
try {
String[] params = otaId.split("\\?");
otaId = params[0].equals("null") ? "" : params[0];
cut = params[1].replace("cut=", "");
res = this.otaBaSjSjyxpgService.importData(file, params[0], cut);
} catch (Exception e) {
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK(res);
}
} }
@@ -37,7 +37,7 @@ public interface IOtaBaSjJssjyyService extends IService<OtaBaSjJssjyy> {
*/ */
void deleteById(String id); void deleteById(String id);
void deleteByOtaId(String otaId) void deleteByOtaId(String otaId);
/** /**
* 批量删除 * 批量删除
@@ -2,7 +2,10 @@ package com.jero.modules.ota.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.ota.entity.OtaBaSjList; import com.jero.modules.ota.entity.OtaBaSjList;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@@ -62,7 +65,12 @@ public interface IOtaBaSjListService extends IService<OtaBaSjList> {
/** /**
* 备案维护 * 备案维护
*
*/ */
void batchRecord(String ids, String bazt, String batjsj, String bz, String cut); void batchRecord(String ids, String bazt, String batjsj, String bz, String cut);
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
void importData(MultipartFile file, String cut) throws Exception;
void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception;
} }
@@ -1,7 +1,13 @@
package com.jero.modules.ota.service; package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaSjSjmbcl; import com.jero.modules.ota.entity.OtaBaSjSjmbcl;
import com.baomidou.mybatisplus.extension.service.IService; 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.io.File;
import java.util.List; import java.util.List;
/** /**
@@ -60,4 +66,12 @@ public interface IOtaBaSjSjmbclService extends IService<OtaBaSjSjmbcl> {
List<OtaBaSjSjmbcl> queryList(); List<OtaBaSjSjmbcl> queryList();
OtaBaSjSjmbcl queryByOtaId(String otaId, String otaIdT); OtaBaSjSjmbcl queryByOtaId(String otaId, String otaIdT);
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
OtaBaSjSjmbcl parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
} }
@@ -1,7 +1,13 @@
package com.jero.modules.ota.service; package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaSjSjmbcx; import com.jero.modules.ota.entity.OtaBaSjSjmbcx;
import com.baomidou.mybatisplus.extension.service.IService; 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.io.File;
import java.util.List; import java.util.List;
/** /**
@@ -60,4 +66,13 @@ public interface IOtaBaSjSjmbcxService extends IService<OtaBaSjSjmbcx> {
List<OtaBaSjSjmbcx> queryList(); List<OtaBaSjSjmbcx> queryList();
OtaBaSjSjmbcx queryByOtaId(String otaId, String otaIdT); OtaBaSjSjmbcx queryByOtaId(String otaId, String otaIdT);
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
OtaBaSjSjmbcx importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaSjSjmbcx parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
} }
@@ -1,7 +1,13 @@
package com.jero.modules.ota.service; package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaSjSjmbcx;
import com.jero.modules.ota.entity.OtaBaSjSjyxpg; import com.jero.modules.ota.entity.OtaBaSjSjyxpg;
import com.baomidou.mybatisplus.extension.service.IService; 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.io.File;
import java.util.List; import java.util.List;
/** /**
@@ -60,4 +66,12 @@ public interface IOtaBaSjSjyxpgService extends IService<OtaBaSjSjyxpg> {
List<OtaBaSjSjyxpg> queryList(); List<OtaBaSjSjyxpg> queryList();
OtaBaSjSjyxpg queryByOtaId(String otaId, String otaIdT); OtaBaSjSjyxpg queryByOtaId(String otaId, String otaIdT);
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
OtaBaSjSjyxpg importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
} }
@@ -216,7 +216,12 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
jbxx.setCplb(ImportFileUtil.getCellValue(cell, wb)); jbxx.setCplb(ImportFileUtil.getCellValue(cell, wb));
row = s.getRow(4); row = s.getRow(4);
cell = row.getCell(1); cell = row.getCell(1);
String ggpc = ImportFileUtil.getCellValue(cell, wb);
if (StringUtils.isEmpty(cpbh)) {
throw new JeroBootException("公告批次不能为空");
}
jbxx.setGgpc(ImportFileUtil.getCellValue(cell, wb)); jbxx.setGgpc(ImportFileUtil.getCellValue(cell, wb));
row = s.getRow(5); row = s.getRow(5);
cell = row.getCell(1); cell = row.getCell(1);
jbxx.setCpsb(ImportFileUtil.getCellValue(cell, wb)); jbxx.setCpsb(ImportFileUtil.getCellValue(cell, wb));
@@ -2,15 +2,22 @@ package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.exception.JeroBootException; import com.jero.common.exception.JeroBootException;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaSjList; import com.jero.modules.ota.entity.OtaBaSjList;
import com.jero.modules.ota.entity.OtaBaSjLsjl; import com.jero.modules.ota.entity.OtaBaSjLsjl;
import com.jero.modules.ota.entity.OtaBaSjSjmbcx;
import com.jero.modules.ota.mapper.OtaBaSjListMapper; import com.jero.modules.ota.mapper.OtaBaSjListMapper;
import com.jero.modules.ota.service.IOtaBaSjListService; import com.jero.modules.ota.service.*;
import com.jero.modules.ota.service.IOtaBaSjLsjlService; import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.util.StringUtils; import com.jero.modules.system.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; 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.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -24,11 +31,25 @@ import java.util.List;
@Service @Service
public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBaSjList> implements IOtaBaSjListService { public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBaSjList> implements IOtaBaSjListService {
@Value(value = "${ota.templatePath}")
private String templatePath;
@Value(value = "${ota.uploadPath}")
private String uploadPath;
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@Autowired @Autowired
private IOtaBaSjLsjlService otaBaSjLsjlService; private IOtaBaSjLsjlService otaBaSjLsjlService;
@Autowired
private IOtaBaSjSjmbcxService otaBaSjSjmbcxService;
@Autowired
private IOtaBaSjSjmbclService otaBaSjSjmbclService;
@Autowired
private IOtaBaCxAqcsService otaBaCxAqcsService;
/** /**
@@ -127,4 +148,30 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
throw new JeroBootException(ex.getMessage()); throw new JeroBootException(ex.getMessage());
} }
} }
@Override
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
ImportFileUtil.exportTemplate(response, templatePath + "在线升级活动备案.zip");
}
@Override
public void importData(MultipartFile file, String cut) throws Exception {
List<File> fileList = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjmbcx mbcx = otaBaSjSjmbcxService.parseFileList(fileList, "", cut);
String otaId = mbcx.getOtaId();
if (StringUtils.isNotEmpty(otaId)) {
otaBaSjSjmbclService.parseFileList(fileList, otaId, cut);
otaBaCxAqcsService.parseFileList(fileList, otaId, cut);
} else {
throw new JeroBootException("导入失败");
}
}
@Override
public void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception {
}
} }
@@ -1,6 +1,7 @@
package com.jero.modules.ota.service.impl; package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.ota.entity.*; import com.jero.modules.ota.entity.*;
import com.jero.modules.ota.enums.OtaModuleEnum; import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjSjmbclMapper; import com.jero.modules.ota.mapper.OtaBaSjSjmbclMapper;
@@ -9,17 +10,28 @@ import com.jero.modules.ota.service.IOtaBaSjListService;
import com.jero.modules.ota.service.IOtaBaSjLsjlService; import com.jero.modules.ota.service.IOtaBaSjLsjlService;
import com.jero.modules.ota.service.IOtaBaSjSjmbclService; import com.jero.modules.ota.service.IOtaBaSjSjmbclService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* @Description: 升级备案-升级目标车辆 * @Description: 升级备案-升级目标车辆
@@ -30,6 +42,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service @Service
public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, OtaBaSjSjmbcl> implements IOtaBaSjSjmbclService { public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, OtaBaSjSjmbcl> implements IOtaBaSjSjmbclService {
@Value(value = "${ota.templatePath}")
private String templatePath;
@Value(value = "${ota.uploadPath}")
private String uploadPath;
@Autowired @Autowired
private ISysDictService sysDictService; private ISysDictService sysDictService;
@@ -59,7 +76,7 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
if (ObjectUtils.isEmpty(otaBaSjSjmbclOld)) { if (ObjectUtils.isEmpty(otaBaSjSjmbclOld)) {
otaBaSjSjmbclOld = new OtaBaSjSjmbcl(); otaBaSjSjmbclOld = new OtaBaSjSjmbcl();
} }
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaSjSjmbcl.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaSjSjmbclOld, otaBaSjSjmbcl, sysDictService); List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaSjSjmbcl.getOtaId(), OtaModuleEnum.SJ_SJMBCL, otaBaSjSjmbclOld, otaBaSjSjmbcl, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
} }
@@ -138,4 +155,43 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
queryWrapper.eq(OtaBaSjSjmbcl::getOtaId, otaId); queryWrapper.eq(OtaBaSjSjmbcl::getOtaId, otaId);
return this.getOne(queryWrapper, false); return this.getOne(queryWrapper, false);
} }
@Override
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
ImportFileUtil.exportTemplate(response, templatePath + "本次升级涉及的目标车辆.zip");
}
@Override
public OtaBaSjSjmbcl parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("本次升级涉及的目标车辆.xlsx")) {
upFile = f;
}
}
if (null == upFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjSjmbcl mbcl = parseFile(upFile, cut);
mbcl.setOtaId(otaId);
add(mbcl);
return mbcl;
}
private OtaBaSjSjmbcl parseFile(File upFile, String cut) {
OtaBaSjSjmbcl mbcl = new OtaBaSjSjmbcl();
return mbcl;
}
@Override
public OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjmbcl mbcl = parseFileList(upLoadFiles, otaId, cut);
return mbcl;
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
}
} }
@@ -1,24 +1,37 @@
package com.jero.modules.ota.service.impl; package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.ota.entity.*; import com.jero.modules.ota.entity.*;
import com.jero.modules.ota.enums.OtaModuleEnum; import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjSjmbcxMapper; import com.jero.modules.ota.mapper.OtaBaSjSjmbcxMapper;
import com.jero.modules.ota.service.IOtaBaCxJbxxService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaSjListService; import com.jero.modules.ota.service.IOtaBaSjListService;
import com.jero.modules.ota.service.IOtaBaSjSjmbcxService; import com.jero.modules.ota.service.IOtaBaSjSjmbcxService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* @Description: 升级备案-升级目标车型 * @Description: 升级备案-升级目标车型
@@ -38,6 +51,16 @@ public class OtaBaSjSjmbcxServiceImpl extends ServiceImpl<OtaBaSjSjmbcxMapper, O
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private IOtaBaCxJbxxService otaBaCxJbxxService;
@Value(value = "${ota.templatePath}")
private String templatePath;
@Value(value = "${ota.uploadPath}")
private String uploadPath;
/** /**
* 保存 * 保存
* *
@@ -147,4 +170,72 @@ public class OtaBaSjSjmbcxServiceImpl extends ServiceImpl<OtaBaSjSjmbcxMapper, O
queryWrapper.eq(OtaBaSjSjmbcx::getOtaId, otaId); queryWrapper.eq(OtaBaSjSjmbcx::getOtaId, otaId);
return this.getOne(queryWrapper, false); return this.getOne(queryWrapper, false);
} }
@Override
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
ImportFileUtil.exportTemplate(response, templatePath + "升级目标车型.zip");
}
@Override
public OtaBaSjSjmbcx importData(MultipartFile file, String otaId, String cut) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjmbcx mbcx = parseFileList(upLoadFiles, otaId, cut);
return mbcx;
}
@Override
public OtaBaSjSjmbcx parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("车型基本信息.xlsx")) {
upFile = f;
}
}
if (null == upFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjSjmbcx mbcx = parseFile(upFile, cut);
mbcx.setOtaId(otaId);
add(mbcx);
return mbcx;
}
private OtaBaSjSjmbcx parseFile(File upFile, String cut) throws Exception {
OtaBaSjSjmbcx mbcx = new OtaBaSjSjmbcx();
Workbook wb = ImportFileUtil.readExcel(upFile);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(1);
Cell cell = row.getCell(2);
mbcx.setBabh(ImportFileUtil.getCellValue(cell, wb));
row = s.getRow(2);
cell = row.getCell(2);
mbcx.setQymc(ImportFileUtil.getCellValue(cell, wb));
row = s.getRow(3);
cell = row.getCell(2);
String pc = ImportFileUtil.getCellValue(cell, wb);
if (StringUtils.isEmpty(pc)) {
throw new JeroBootException("车型及功能备案《公告》批次不能为空");
}
//查找车型备案的同批次数据
LambdaQueryWrapper<OtaBaCxJbxx> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OtaBaCxJbxx::getGgpc, pc);
OtaBaCxJbxx jbxx = otaBaCxJbxxService.getOne(queryWrapper, false);
if (ObjectUtils.isEmpty(jbxx)) {
throw new JeroBootException("车型及功能备案《公告》批次:" + jbxx + " 无法找到车型备案数据");
}
mbcx.setBapc(pc);
mbcx.setCpsb(jbxx.getCpsb());
mbcx.setCpmc(jbxx.getCpmc());
mbcx.setCpxh(jbxx.getCpxh());
mbcx.setDllx1(jbxx.getDllx1());
mbcx.setDllx2(jbxx.getDllx2());
return mbcx;
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
}
} }
@@ -2,22 +2,30 @@ package com.jero.modules.ota.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.ota.entity.*; import com.jero.modules.ota.entity.*;
import com.jero.modules.ota.enums.OtaModuleEnum; import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjSjyxpgMapper; import com.jero.modules.ota.mapper.OtaBaSjSjyxpgMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaSjSjyxpgService; import com.jero.modules.ota.service.IOtaBaSjSjyxpgService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* @Description: 升级备案-升级影响评估 * @Description: 升级备案-升级影响评估
@@ -35,6 +43,12 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Value(value = "${ota.templatePath}")
private String templatePath;
@Value(value = "${ota.uploadPath}")
private String uploadPath;
/** /**
* 保存 * 保存
* *
@@ -135,4 +149,43 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
queryWrapper.eq(OtaBaSjSjyxpg::getOtaId, otaId); queryWrapper.eq(OtaBaSjSjyxpg::getOtaId, otaId);
return this.getOne(queryWrapper, false); return this.getOne(queryWrapper, false);
} }
@Override
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
ImportFileUtil.exportTemplate(response, templatePath + "升级影响评估.zip");
}
@Override
public OtaBaSjSjyxpg importData(MultipartFile file, String otaId, String cut) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjyxpg sjyxpg = parseFileList(upLoadFiles, otaId, cut);
return sjyxpg;
}
private OtaBaSjSjyxpg parseFile(File upFile, String cut) {
OtaBaSjSjyxpg sjyxpg = new OtaBaSjSjyxpg();
return sjyxpg;
}
@Override
public OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("车型基本信息.xlsx")) {
upFile = f;
}
}
if (null == upFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjSjyxpg sjyxpg = parseFile(upFile, cut);
sjyxpg.setOtaId(otaId);
add(sjyxpg);
return sjyxpg;
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
}
} }