Merge remote-tracking branch 'origin/dev_2nd_LCYH' into dev_2nd_LCYH

This commit is contained in:
wangzhijiang
2023-03-30 09:26:52 +08:00
18 changed files with 1084 additions and 308 deletions
@@ -28,6 +28,7 @@ import com.jero.modules.dummy.enums.DummyInventoryBaseFieldEnum;
import com.jero.modules.dummy.service.impl.DummyLogEOServiceImpl;
import com.jero.modules.dummy.util.DeepCopyListUtil;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.project.entity.ProjectCertificationInventoryEO;
import com.jero.modules.project.enums.ProjectInventoryFieldEnum;
import com.jero.modules.split.common.FileUnZip;
import com.jero.modules.system.entity.SysCategory;
@@ -513,9 +514,9 @@ public class AuthDummyInventoryInfoEOServiceImpl extends ServiceImpl<AuthDummyIn
if(CollectionUtils.isNotEmpty(baseList)){
String title = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())){
title = "类别,检验项目,配置项,WVTA ID,*编号,*责任领域,交付物类型";
title = "*类别,*检验项目,*配置项,*WVTA ID,*编号,*责任领域,*交付物类型";
}else{
title = "Category,Inspection Items,Configuration Item,WVTA ID,*Number,*Responsible Field,Deliverable Type";
title = "*Category,*Inspection Items,*Configuration Item,*WVTA ID,*Number,*Responsible Field,*Deliverable Type";
}
int pos = file.getOriginalFilename().lastIndexOf(".");
@@ -703,12 +704,12 @@ public class AuthDummyInventoryInfoEOServiceImpl extends ServiceImpl<AuthDummyIn
// //树形数据字典
// List<SysCategory> categoryList = sysCategoryService.list();
// //普通数据字典
// List<SysDictItem> dictItemList = sysDictItemServiceImpl.selectItemsAll();
// importDatas(datas, categoryList, dictItemList, zipEntryName,saveDirectory,authDummyInventoryInfoEO);
String cut = authDummyInventoryInfoEO.getCut();
importDisposeData(datas,cut);
List<SysCategory> categoryList = sysCategoryService.list();
//普通数据字典
List<SysDictItem> dictItemList = sysDictItemServiceImpl.selectItemsAll();
importDatas(datas, categoryList, dictItemList, zipEntryName,saveDirectory,authDummyInventoryInfoEO);
// String cut = authDummyInventoryInfoEO.getCut();
// importDisposeData(datas,cut);
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
}else{
@@ -720,6 +721,357 @@ public class AuthDummyInventoryInfoEOServiceImpl extends ServiceImpl<AuthDummyIn
}
}
private void importDatas(List<AuthDummyInventoryInfoEO> datas,
List<SysCategory> categoryList, List<SysDictItem> dictItemList,
String zipEntryName, File saveDirectory,
AuthDummyInventoryInfoEO authDummyInventoryInfoEOTemp) {
List<String> msgList = new ArrayList<>();
//模板数据验证
msgList = dataTemplateVerify(datas, dictItemList, zipEntryName, authDummyInventoryInfoEOTemp, categoryList);
if (msgList.size() > 0) {
//返回报错信息
String html = "";
for (String s : msgList) {
html += s + "</br>";
}
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException(html);
}else {
if (datas.size() != 0) {
this.saveBatch(datas);
}
}
}
private List<String> dataTemplateVerify(List<AuthDummyInventoryInfoEO> datas,
List<SysDictItem> dictItemList, String zipEntryName,
AuthDummyInventoryInfoEO authDummyInventoryInfoEOTemp,
List<SysCategory> categoryList) {
String dictId = sysCategoryMapper.getDictId("ren4_zheng4_-_jiao1_fu4_wu4_lei4_xing2");
List<SysCategory> collect = categoryList.stream().filter(e -> e.getSysDictId().equals(dictId)).collect(Collectors.toList());
List<String> treeNameList = new ArrayList<>();
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
treeNameList = collect.stream().map(SysCategory::getName).collect(Collectors.toList());
}else{
treeNameList = collect.stream().map(SysCategory::getEnName).collect(Collectors.toList());
}
int i = 2;
List<String> msgList = new ArrayList<>();
String value = "";
boolean flag = true;
//编号验证
verifySerialNumber(datas,authDummyInventoryInfoEOTemp);
for(AuthDummyInventoryInfoEO authDummyInventoryInfoEO :datas){
i++;
String errorMsg = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
errorMsg = "" + i + "行:";
}else{
errorMsg = i + " line";
}
//类别
String category = authDummyInventoryInfoEO.getCategory();
//检验项目
String inspectionItem = authDummyInventoryInfoEO.getInspectionItem();
//配置项
String configItem = authDummyInventoryInfoEO.getConfigItem();
//WVTA ID
String wvtaId = authDummyInventoryInfoEO.getWvtaId();
//标准编号
String serialNumber = authDummyInventoryInfoEO.getSerialNumber();
//责任领域
String dutyTerritory = authDummyInventoryInfoEO.getDutyTerritoryName();
//交付物类型
String deliverableType = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())){
deliverableType = authDummyInventoryInfoEO.getDeliverableTypeName();
}else {
deliverableType = authDummyInventoryInfoEO.getDeliverableTypeNameEn();
}
//编号必填
flag = must(authDummyInventoryInfoEO, errorMsg, msgList, serialNumber, "编号", "Number");
//WVTA ID
if(StringUtils.isNotBlank(wvtaId)){
if(wvtaId.length() > 100){
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "WVTA ID不能超过100个字符, ";
}else{
message = errorMsg + " The WVTA ID cannot contain more than 100 characters, ";
}
msgList.add(message);
}
} else {
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "WVTA ID不能为空, ";
}else{
message = errorMsg + " The WVTA ID cannot null, ";
}
msgList.add(message);
}
//类别
if(StringUtils.isNotBlank(category)){
if(category.length() > 100){
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "类别不能超过100个字符, ";
}else{
message = errorMsg + " The Category cannot contain more than 100 characters, ";
}
msgList.add(message);
}
}else {
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "类别不能为空, ";
}else{
message = errorMsg + " The Category cannot null, ";
}
msgList.add(message);
}
//检验项目
if(StringUtils.isNotBlank(inspectionItem)){
if(inspectionItem.length() > 100){
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "检验项目不能超过100个字符, ";
}else{
message = errorMsg + " The InspectionItem cannot contain more than 100 characters, ";
}
msgList.add(message);
}
}else {
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "检验项目不能为空, ";
}else{
message = errorMsg + " The InspectionItem cannot null, ";
}
msgList.add(message);
}
//配置项
if(StringUtils.isNotBlank(configItem)){
if(configItem.length() > 100){
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "配置项不能超过100个字符, ";
}else{
message = errorMsg + " The ConfigItem cannot contain more than 100 characters, ";
}
msgList.add(message);
}
}else {
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "配置项不能为空, ";
}else{
message = errorMsg + " The ConfigItem cannot null, ";
}
msgList.add(message);
}
//责任领域
if(StringUtils.isNotBlank(dutyTerritory)){
value = pullMore(dictItemList, authDummyInventoryInfoEO, errorMsg, dutyTerritory,msgList,"责任领域","Responsible Field","duty_territory");
if(StringUtils.isNotBlank(value)){
authDummyInventoryInfoEO.setDutyTerritory(value);
}
}else {
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "责任领域不能为空, ";
}else{
message = errorMsg + " The Responsible Field cannot null, ";
}
msgList.add(message);
}
//交付物类型
if(StringUtils.isNotEmpty(deliverableType)){
value = tree(categoryList,treeNameList, authDummyInventoryInfoEO, errorMsg, deliverableType,msgList,"交付物类型","Deliverable Type","deliverable_template");
if(StringUtils.isNotBlank(value)){
String treeId = getTreeId(categoryList, authDummyInventoryInfoEOTemp, treeNameList, value);
authDummyInventoryInfoEO.setDeliverableType(treeId);
}
}else{
String message = "";
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())){
message = errorMsg + "交付物类型不能为空, ";
}else{
message = errorMsg + " The Deliverable Type cannot null, ";
}
msgList.add(message);
}
}
return msgList;
}
private String getTreeId(List<SysCategory> categoryList, AuthDummyInventoryInfoEO authDummyInventoryInfoEOTemp,
List<String> treeNameList, String value) {
StringBuilder sb = new StringBuilder();
for (String valueTemp : value.split(",")) {
if (treeNameList.contains(valueTemp)) {
List<SysCategory> sysCategoryList = new ArrayList<>();
if (CutEnum.CN.getValue().equals(authDummyInventoryInfoEOTemp.getCut())) {
sysCategoryList = categoryList.stream().filter(e -> e.getName().equals(valueTemp)).collect(Collectors.toList());
} else {
sysCategoryList = categoryList.stream().filter(e -> e.getEnName().equals(valueTemp)).collect(Collectors.toList());
}
if (sysCategoryList.size() != 0) {
sb.append(sysCategoryList.get(0).getId() + ",");
}
}
}
if (StringUtils.isNotBlank(sb)) {
String substring = sb.substring(0, sb.length() - 1);
return substring;
}
return null;
}
private String tree(List<SysCategory> categoryList, List<String> nameList,
AuthDummyInventoryInfoEO authDummyInventoryInfoEO,
String errorMsg, String value, List<String> msgList,
String nameCn, String nameEn, String dictCode) {
if (StringUtils.isNotBlank(value)) {
StringBuilder sb = new StringBuilder();
for (String s : value.split(",")) {
if(!nameList.contains(s)){
sb.append(s+",");
}
}
if(StringUtils.isNotBlank(sb)){
String substring = sb.substring(0, sb.length() - 1);
if (CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())) {
errorMsg += nameCn + "中的" + substring + "与数据字典不匹配, ";
} else {
errorMsg += nameEn + " " + substring + " does not match the data dictionary, ";
}
msgList.add(errorMsg);
}else{
StringBuilder sbTemp = new StringBuilder();
for (String s : value.split(",")) {
List<SysCategory> collect = new ArrayList<>();
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())){
collect = categoryList.stream().filter(e -> s.equals(e.getName())).collect(Collectors.toList());
if(collect.size() != 0){
sbTemp.append(collect.get(0).getName()+",");
}
}else{
collect = categoryList.stream().filter(e -> s.equals(e.getEnName())).collect(Collectors.toList());
if(collect.size() != 0){
sbTemp.append(collect.get(0).getEnName()+",");
}
}
}
if(StringUtils.isNotBlank(sbTemp)){
String substring = sbTemp.substring(0, sbTemp.length() - 1);
return substring;
}
}
}
return null;
}
private String pullMore(List<SysDictItem> dictItemList, AuthDummyInventoryInfoEO authDummyInventoryInfoEO,
String errorMsg, String value, List<String> msgList, String nameCn,
String nameEn, String dictCode) {
List<String> valueList = new ArrayList<>();
if (StringUtils.isNotBlank(value)) {
List<String> list = Arrays.asList(value.split(","));
List<SysDictItem> sysDictItemList = new ArrayList<>();
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())){
sysDictItemList = dictItemList.stream().filter(e ->dictCode.equals(e.getDictCode()) && list.contains(e.getItemText())).collect(Collectors.toList());
}else{
sysDictItemList = dictItemList.stream().filter(e ->dictCode.equals(e.getDictCode()) && list.contains(e.getEnName())).collect(Collectors.toList());
}
if(list.size() == sysDictItemList.size()){
valueList = sysDictItemList.stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
}else{
//数据中有与数据字典不匹配的值
List<String> finalValueList = valueList;
List<String> diffList = list.stream().filter(e -> !finalValueList.contains(e)).collect(Collectors.toList());
if (CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())) {
errorMsg += nameCn + "中的" + StringUtils.join(diffList,",") + "与数据字典不匹配, ";
} else {
errorMsg += nameEn + " " + StringUtils.join(diffList,",") + " does not match the data dictionary, ";
}
msgList.add(errorMsg);
}
}
return StringUtils.join(valueList,",");
}
private boolean must(AuthDummyInventoryInfoEO authDummyInventoryInfoEO,
String errorMsg, List<String> msgList, String serialNumber,
String nameCn, String nameEn) {
int errorCount = 0;
if(StringUtils.isBlank(serialNumber)){
errorCount ++;
if(CutEnum.CN.getValue().equals(authDummyInventoryInfoEO.getCut())){
errorMsg += nameCn + "为必填项,不能为空, ";
}else{
errorMsg += nameEn + "This parameter is mandatory and cannot be empty, ";
}
msgList.add(errorMsg);
}
if(errorCount == 0){
return true;
}else{
return false;
}
}
private void verifySerialNumber(List<AuthDummyInventoryInfoEO> datas,
AuthDummyInventoryInfoEO authDummyInventoryInfoEOTemp) {
//1. 验证标准号在文档库中是否存在
List<String> serialNumberList = datas.stream().map(AuthDummyInventoryInfoEO::getSerialNumber).collect(Collectors.toList());
LambdaQueryWrapper<BussDocumentLibraryEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(BussDocumentLibraryEO::getSerialNumber,serialNumberList);
List<BussDocumentLibraryEO> bussDocumentLibraryEOList = iBussDocumentLibraryEOService.list(wrapper);
//文档库中可能存在重复的标准号
List<String> serialNumberListTemp = bussDocumentLibraryEOList.stream().map(BussDocumentLibraryEO::getSerialNumber).distinct().collect(Collectors.toList());
if(serialNumberList.size() != serialNumberListTemp.size()){
//存在文档库没有的数据
List<String> collect = bussDocumentLibraryEOList.stream().map(BussDocumentLibraryEO::getSerialNumber).collect(Collectors.toList());
List<String> serialNumbers = serialNumberList.stream().filter(e -> !collect.contains(e)).collect(Collectors.toList());
if(serialNumbers.size() > 0){
if(CutEnum.CN.getValue().equals(datas.get(0).getCut())){
throw new JeroBootException(StringUtils.join(serialNumbers,",")+"文档库中不存在,不能添加");
}else{
throw new JeroBootException(StringUtils.join(serialNumbers,",")+" does not exist in the document library and cannot be added");
}
}
}else{
for (AuthDummyInventoryInfoEO authDummyInventoryInfoEO : datas) {
List<BussDocumentLibraryEO> collect = bussDocumentLibraryEOList.stream()
.filter(e -> e.getSerialNumber().equals(authDummyInventoryInfoEO.getSerialNumber())).collect(Collectors.toList());
authDummyInventoryInfoEO.setBussDocumentLibraryId(collect.get(0).getId());
}
}
// //2. 验证标准号在法规清单中是否添加过
// LambdaQueryWrapper<ProjectCertificationInventoryEO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper.in(ProjectCertificationInventoryEO::getSerialNumber,serialNumberList).in(ProjectCertificationInventoryEO::getProjectLibraryId,projectCertificationInventoryEOTemp.getProjectLibraryId());
// List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = this.list(lambdaQueryWrapper);
// List<String> serialNumberTempList = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getSerialNumber).collect(Collectors.toList());
// if(projectCertificationInventoryEOList.size() > 0){
// if(CutEnum.CN.getValue().equals(datas.get(0).getCut())){
// throw new JeroBootException(StringUtils.join(serialNumberTempList,",")+"已存在,不能重复添加");
// }else{
// throw new JeroBootException(StringUtils.join(serialNumberTempList,",")+" already exists and cannot be added again");
// }
// }
}
@Override
public Result<?> batchAdd(JSONObject json) {
try {
@@ -763,21 +1115,21 @@ public class AuthDummyInventoryInfoEOServiceImpl extends ServiceImpl<AuthDummyIn
if (field == null) return null;
switch (field) {
case "类别": return "category";
case "检验项目": return "inspectionItem";
case "配置项": return "configItem";
case "WVTA ID": return "wvtaId";
case "*类别": return "category";
case "*检验项目": return "inspectionItem";
case "*配置项": return "configItem";
case "*WVTA ID": return "wvtaId";
case "*编号" : return "serialNumber";
case "*责任领域": return "dutyTerritoryName";
case "交付物类型" : return "deliverableTypeName";
case "*交付物类型" : return "deliverableTypeName";
case "Category" : return "Category";
case "Inspection Items" : return"inspectionItem";
case "Configuration Item" : return"configItem";
case "*Category" : return "Category";
case "*Inspection Items" : return"inspectionItem";
case "*Configuration Item" : return"configItem";
// case "WVTA ID" : return "wvtaId";
case "*Number" : return "serialNumber";
case "*Responsible Field" : return "dutyTerritoryName";
case "Deliverable Type" : return "deliverableTypeNameEn";
case "*Deliverable Type" : return "deliverableTypeNameEn";
default: return null;
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
@@ -13,6 +14,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import com.jero.common.system.base.controller.JeroController;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -22,164 +24,169 @@ import io.swagger.annotations.ApiOperation;
import com.jero.common.aspect.annotation.AutoLog;
/**
/**
* @Description: 车型备案-填写记录表
* @Author: jero-boot
* @Date: 2023-03-25
* @Date: 2023-03-25
* @Version: V1.0
*/
@Api(tags="车型备案-填写记录表")
@Api(tags = "车型备案-填写记录表")
@RestController
@RequestMapping("/ota/otaBaCxTxjl")
@Slf4j
public class OtaBaCxTxjlController extends JeroController<OtaBaCxTxjl, IOtaBaCxTxjlService> {
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
/**
* 分页列表查询
*
* @param otaBaCxTxjl
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "车型备案-填写记录表-分页列表查询")
@ApiOperation(value="车型备案-填写记录表-分页列表查询", notes="车型备案-填写记录表-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaCxTxjl otaBaCxTxjl,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaCxTxjl> queryWrapper = QueryGenerator.initQueryWrapper(otaBaCxTxjl, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
Page<OtaBaCxTxjl> page = new Page<OtaBaCxTxjl>(pageNo, pageSize);
IPage<OtaBaCxTxjl> pageList = otaBaCxTxjlService.page(page, queryWrapper);
return Result.OK(pageList);
}
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "车型备案-填写记录表-列表查询")
@ApiOperation(value="车型备案-填写记录表-列表查询", notes="车型备案-填写记录表-列表查询")
@GetMapping(value = "/list")
public Result<List<OtaBaCxTxjl>> queryList() {
* 分页列表查询
*
* @param otaBaCxTxjl
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "车型备案-填写记录表-分页列表查询")
@ApiOperation(value = "车型备案-填写记录表-分页列表查询", notes = "车型备案-填写记录表-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaCxTxjl otaBaCxTxjl,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<OtaBaCxTxjl> page = new Page<OtaBaCxTxjl>(pageNo, pageSize);
String otaId = req.getParameter("otaId");
if (StringUtils.isEmpty(otaId)) {
return Result.OK(page);
}
QueryWrapper<OtaBaCxTxjl> queryWrapper = QueryGenerator.initQueryWrapper(otaBaCxTxjl, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
IPage<OtaBaCxTxjl> pageList = otaBaCxTxjlService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "车型备案-填写记录表-列表查询")
@ApiOperation(value = "车型备案-填写记录表-列表查询", notes = "车型备案-填写记录表-列表查询")
@GetMapping(value = "/list")
public Result<List<OtaBaCxTxjl>> queryList() {
List<OtaBaCxTxjl> list = otaBaCxTxjlService.queryList();
return Result.OK(list);
}
/**
* 添加
*
* @param otaBaCxTxjl
* @return
*/
@AutoLog(value = "车型备案-填写记录表-添加")
@ApiOperation(value="车型备案-填写记录表-添加", notes="车型备案-填写记录表-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaCxTxjl otaBaCxTxjl) {
otaBaCxTxjlService.add(otaBaCxTxjl);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param otaBaCxTxjl
* @return
*/
@AutoLog(value = "车型备案-填写记录表-编辑")
@ApiOperation(value="车型备案-填写记录表-编辑", notes="车型备案-填写记录表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaCxTxjl otaBaCxTxjl) {
otaBaCxTxjlService.editById(otaBaCxTxjl);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-填写记录表-通过id删除")
@ApiOperation(value="车型备案-填写记录表-通过id删除", notes="车型备案-填写记录表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
otaBaCxTxjlService.deleteById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "车型备案-填写记录表-批量删除")
@ApiOperation(value="车型备案-填写记录表-批量删除", notes="车型备案-填写记录表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.otaBaCxTxjlService.deleteByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-填写记录表-通过id查询")
@ApiOperation(value="车型备案-填写记录表-通过id查询", notes="车型备案-填写记录表-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
OtaBaCxTxjl otaBaCxTxjl = otaBaCxTxjlService.queryById(id);
if(otaBaCxTxjl==null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxTxjl);
}
/**
* 通过otaId查询
*
* @param otaId
* @return
*/
@AutoLog(value = "车型备案-填写记录表-通过otaId查询")
@ApiOperation(value="车型备案-填写记录表-通过otaId查询", notes="车型备案-填写记录表-通过otaId查询")
@GetMapping(value = "/queryByOtaId")
public Result<?> queryByOtaId(@RequestParam(name="otaId",required=true) String otaId) {
List<OtaBaCxTxjl> otaBaCxTxjlList = otaBaCxTxjlService.queryByOtaId(otaId);
if(otaBaCxTxjlList==null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxTxjlList);
}
}
/**
* 导出excel
*
* @param request
* @param otaBaCxTxjl
*/
* 添加
*
* @param otaBaCxTxjl
* @return
*/
@AutoLog(value = "车型备案-填写记录表-添加")
@ApiOperation(value = "车型备案-填写记录表-添加", notes = "车型备案-填写记录表-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaCxTxjl otaBaCxTxjl) {
otaBaCxTxjlService.add(otaBaCxTxjl);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param otaBaCxTxjl
* @return
*/
@AutoLog(value = "车型备案-填写记录表-编辑")
@ApiOperation(value = "车型备案-填写记录表-编辑", notes = "车型备案-填写记录表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaCxTxjl otaBaCxTxjl) {
otaBaCxTxjlService.editById(otaBaCxTxjl);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-填写记录表-通过id删除")
@ApiOperation(value = "车型备案-填写记录表-通过id删除", notes = "车型备案-填写记录表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
otaBaCxTxjlService.deleteById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "车型备案-填写记录表-批量删除")
@ApiOperation(value = "车型备案-填写记录表-批量删除", notes = "车型备案-填写记录表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.otaBaCxTxjlService.deleteByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-填写记录表-通过id查询")
@ApiOperation(value = "车型备案-填写记录表-通过id查询", notes = "车型备案-填写记录表-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
OtaBaCxTxjl otaBaCxTxjl = otaBaCxTxjlService.queryById(id);
if (otaBaCxTxjl == null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxTxjl);
}
/**
* 通过otaId查询
*
* @param otaId
* @return
*/
@AutoLog(value = "车型备案-填写记录表-通过otaId查询")
@ApiOperation(value = "车型备案-填写记录表-通过otaId查询", notes = "车型备案-填写记录表-通过otaId查询")
@GetMapping(value = "/queryByOtaId")
public Result<?> queryByOtaId(@RequestParam(name = "otaId", required = true) String otaId) {
List<OtaBaCxTxjl> otaBaCxTxjlList = otaBaCxTxjlService.queryByOtaId(otaId);
if (otaBaCxTxjlList == null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxTxjlList);
}
/**
* 导出excel
*
* @param request
* @param otaBaCxTxjl
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, OtaBaCxTxjl otaBaCxTxjl) {
return super.exportXls(request, otaBaCxTxjl, OtaBaCxTxjl.class, "车型备案-填写记录表");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, OtaBaCxTxjl.class);
@@ -114,6 +114,7 @@ public class OtaBaSjGgnrfs implements Serializable {
/**告知用户方式(可多选)*/
@Excel(name = "告知用户方式(可多选)", width = 15)
@ApiModelProperty(value = "告知用户方式(可多选)")
@Dict(dicCode = "user_notification_mode")
private java.lang.String gzyhfs;
/**用户告知相关文件*/
@@ -0,0 +1,58 @@
package com.jero.modules.ota.entity;
import com.jero.modules.extRepo.entity.ERFTreeData;
import com.jero.modules.ota.service.impl.OtaBaSjSjmbclServiceImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Date;
public class VinObj {
String vin;
String cx;
String gglx;
Date scrq;
String scrqStr;
public String getVin() {
return vin;
}
public void setVin(String vin) {
this.vin = vin;
}
public String getCx() {
return cx;
}
public void setCx(String cx) {
this.cx = cx;
}
public String getGglx() {
return gglx;
}
public void setGglx(String gglx) {
this.gglx = gglx;
}
public Date getScrq() {
return scrq;
}
public void setScrq(Date scrq) {
this.scrq = scrq;
}
public String getScrqStr() {
return scrqStr;
}
public void setScrqStr(String scrqStr) {
this.scrqStr = scrqStr;
}
}
@@ -154,21 +154,21 @@ public enum OtaTitleEnum {
BABH("babh", "备案编号", "0"),
BAPC("bapc", "备案批次", "0"),
ZSL("zsl", "总数量", "0"),
SCRQKS("scrqks", "生产日期开始", "0"),
SCRQJS("scrqjs", "生产日期结束", "0"),
SCRQKS("scrqks", "生产日期开始", "3"),
SCRQJS("scrqjs", "生产日期结束", "3"),
VIN_LIST("vinList", "VIN码清单", "0"),
SJMD("sjmd", "升级目的", "uipgrade_purpose"),
SFBGCS("sfbgcs", "是否变更对应车型的《公告》技术参数", "0"),
JSXNBH("jsxnbh", "是否涉及性能变化", "0"),
FHGD("fhgd", "是否符合国家法律、行政法规、规章规定,以及道路机动车辆公告管理相关国家技术标准及安全技术条件等", "0"),
ZDJSXG("zdjsxg", "是否涉及汽车自动驾驶功能相关升级", "0"),
JRXXG("jrxxg", "兼容性评估相关", "0"),
SFBGCS("sfbgcs", "是否变更对应车型的《公告》技术参数", "2"),
JSXNBH("jsxnbh", "是否涉及性能变化", "2"),
FHGD("fhgd", "是否符合国家法律、行政法规、规章规定,以及道路机动车辆公告管理相关国家技术标准及安全技术条件等", "2"),
ZDJSXG("zdjsxg", "是否涉及汽车自动驾驶功能相关升级", "2"),
JRXXG("jrxxg", "兼容性评估相关", "2"),
ZXSJ("zxsj", "如何执行升级", "conditions_upgrades"),
AQJZ("aqjz", "升级失败或中断后,车辆采取的安全机制", "upgrade_failed"),
SFYXAQ("sfyxaq", "升级活动是否影响车辆安全", "0"),
YHQR("yhqr", "升级活动是否提供用户确认选项", "0"),
SFYXAQ("sfyxaq", "升级活动是否影响车辆安全", "2"),
YHQR("yhqr", "升级活动是否提供用户确认选项", "2"),
SJBCS("sjbcs", "升级包测试", "package_test"),
AQKKX("aqkkx", "已验证确认在线升级活动的安全性和可靠性", "0"),
AQKKX("aqkkx", "已验证确认在线升级活动的安全性和可靠性", "2"),
// BGFJ("bgfj", "提供变更或扩展后的《公告》批次及证明材料", "0"),
// CLFJ("clfj", "提供证明材料", "0"),
XTMC("xtmc", "系统名称", "0"),
@@ -193,14 +193,14 @@ public enum OtaTitleEnum {
SJKY("sjky", "升级执行期问,车辆是否可用", "0"),
SJBKYGN("sjbkygn", "升级执行期间不可用的车辆功能", "0"),
ZDXX("zdxx", "帮助车辆用户安全执行升级的任何指导信息", "0"),
SJSFCG("sjsfcg", "告知用户升级成功或失败", "0"),
GZBG("gzbg", "告知实施的变更", "0"),
GZSCNR("gzscnr", "告知了对用户手册的全部更新内容", "0"),
GZYHFS("gzyhfs", "告知用户方式(可多选)", "0"),
SJSFCG("sjsfcg", "告知用户升级成功或失败", "2"),
GZBG("gzbg", "告知实施的变更", "2"),
GZSCNR("gzscnr", "告知了对用户手册的全部更新内容", "2"),
GZYHFS("gzyhfs", "告知用户方式(可多选)", "user_notification_mode"),
// XGWJ("xgwj", "用户告知相关文件", "0"),
RWMC("rwmc", "任务名称", "0"),
SJFBSJ("sjfbsj", "升级发布时间", "0"),
SJJZSJ("sjjzsj", "升级计划截止时间", "0");
SJFBSJ("sjfbsj", "升级发布时间", "3"),
SJJZSJ("sjjzsj", "升级计划截止时间", "3");
String name;
String value;
@@ -2,60 +2,63 @@ package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaSjGnxtwh;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: 车型备案-功能系统维护
* @Author: jero-boot
* @Date: 2023-03-28
* @Date: 2023-03-28
* @Version: V1.0
*/
public interface IOtaBaSjGnxtwhService extends IService<OtaBaSjGnxtwh> {
/**
* 保存
*
* @param otaBaSjGnxtwh
* @return
*/
/**
* 保存
*
* @param otaBaSjGnxtwh
* @return
*/
void add(OtaBaSjGnxtwh otaBaSjGnxtwh);
/**
* 更新
*
* @param otaBaSjGnxtwh
* @return
*/
/**
* 更新
*
* @param otaBaSjGnxtwh
* @return
*/
void editById(OtaBaSjGnxtwh otaBaSjGnxtwh);
/**
* 通过id删除
*
* @param id
* @return
*/
/**
* 通过id删除
*
* @param id
* @return
*/
void deleteById(String id);
/**
* 批量删除
*
* @param ids
* @return
*/
/**
* 批量删除
*
* @param ids
* @return
*/
void deleteByIds(List<String> ids);
/**
* 通过id查询
*
* @param id
* @return
*/
/**
* 通过id查询
*
* @param id
* @return
*/
OtaBaSjGnxtwh queryById(String id);
String queryGnxtByKzq(String kzq);
/**
* 列表查询
*
* @return
*/
* 列表查询
*
* @return
*/
List<OtaBaSjGnxtwh> queryList();
}
@@ -4,26 +4,28 @@ import com.jero.modules.ota.entity.OtaBaSjGnxtwh;
import com.jero.modules.ota.mapper.OtaBaSjGnxtwhMapper;
import com.jero.modules.ota.service.IOtaBaSjGnxtwhService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Date;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 车型备案-功能系统维护
* @Author: jero-boot
* @Date: 2023-03-28
* @Date: 2023-03-28
* @Version: V1.0
*/
@Service
public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, OtaBaSjGnxtwh> implements IOtaBaSjGnxtwhService {
/**
* 保存
*
* @param otaBaSjGnxtwh
* @return
*/
@Override
/**
* 保存
*
* @param otaBaSjGnxtwh
* @return
*/
@Override
public void add(OtaBaSjGnxtwh otaBaSjGnxtwh) {
Date now = new Date();
otaBaSjGnxtwh.setCreateTime(now);
@@ -31,58 +33,74 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
save(otaBaSjGnxtwh);
}
/**
* 更新
*
* @param otaBaSjGnxtwh
* @return
*/
@Override
/**
* 更新
*
* @param otaBaSjGnxtwh
* @return
*/
@Override
public void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) {
Date now = new Date();
Date now = new Date();
otaBaSjGnxtwh.setUpdateTime(now);
saveOrUpdate(otaBaSjGnxtwh);
saveOrUpdate(otaBaSjGnxtwh);
}
/**
* 通过id删除
*
* @param id
* @return
*/
@Override
/**
* 通过id删除
*
* @param id
* @return
*/
@Override
public void deleteById(String id) {
removeById(id);
}
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
public void deleteByIds(List<String> ids) {
removeByIds(ids);
}
/**
* 通过id查询
*
* @param id
* @return
*/
@Override
/**
* 通过id查询
*
* @param id
* @return
*/
@Override
public OtaBaSjGnxtwh queryById(String id) {
return getById(id);
}
@Override
public String queryGnxtByKzq(String kzq) {
List<OtaBaSjGnxtwh> list = list();
for (OtaBaSjGnxtwh wh : list) {
String[] strs = wh.getDykzq().split(",");
for (String str : strs) {
if (str.equals(kzq)) {
return wh.getGnxt();
}
}
}
return null;
}
/**
* 列表查询
*
* @return
*/
@Override
* 列表查询
*
* @return
*/
@Override
public List<OtaBaSjGnxtwh> queryList() {
return list();
}
@@ -18,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -48,9 +49,6 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
@Autowired
private IOtaBaSjSjmbclService otaBaSjSjmbclService;
@Autowired
private IOtaBaCxAqcsService otaBaCxAqcsService;
@Autowired
private IOtaBaSjSjxtbhService otaBaSjSjxtbhService;
@@ -60,6 +58,9 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
@Autowired
private IOtaBaSjGgnrfsService otaBaSjGgnrfsService;
@Autowired
private IOtaBaSjSjyxpgService otaBaSjSjyxpgService;
/**
* 保存
@@ -170,7 +171,8 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
String otaId = mbcx.getOtaId();
if (StringUtils.isNotEmpty(otaId)) {
otaBaSjSjmbclService.parseFileList(fileList, otaId, cut);
otaBaCxAqcsService.parseFileList(fileList, otaId, cut);
otaBaSjSjmbcxService.parseFileList(fileList, otaId, cut);
otaBaSjSjyxpgService.parseFileList(fileList, otaId, cut);
otaBaSjSjxtbhService.parseFileList(fileList, otaId, cut);
otaBaSjSjfzbhService.parseFileList(fileList, otaId, cut);
otaBaSjGgnrfsService.parseFileList(fileList, otaId, cut);
@@ -181,6 +183,28 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
@Override
public void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception {
String cut = "cn";
File template = new File(templatePath + "在线升级活动备案.zip");
File exportFile = ImportFileUtil.copyZip(ImportFileUtil.createMfileByFile(template), cut, uploadPath);
File jbxxFile = ImportFileUtil.findFile(exportFile, "本次升级涉及的目标车辆.xlsx");
otaBaSjSjmbclService.exportData(jbxxFile, otaId, cut);
File sjmbcxFile = ImportFileUtil.findFile(exportFile, "升级目标车型.xlsx");
otaBaSjSjmbcxService.exportData(sjmbcxFile, otaId, cut);
File pgFile = ImportFileUtil.findFile(exportFile, "升级影响评估.docx");
otaBaSjSjyxpgService.exportData(pgFile, otaId, cut);
File sjSjxtbhFile = ImportFileUtil.findFile(exportFile, "本次升级的系统名称与变更参数.docx");
otaBaSjSjxtbhService.exportData(sjSjxtbhFile, otaId, cut);
File sjfzbhFile = ImportFileUtil.findFile(exportFile, "本次升级的驾驶辅助功能与参数变化.docx");
otaBaSjSjfzbhService.exportData(sjfzbhFile, otaId, cut);
String outPath = uploadPath + "/在线升级活动备案" + System.currentTimeMillis() + ".zip";
FileOutputStream fos1 = new FileOutputStream(outPath);
ImportFileUtil.toZip(exportFile.getCanonicalPath(), fos1, true);
ImportFileUtil.exportTemplate(response, outPath);
}
}
@@ -1,16 +1,21 @@
package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.ota.entity.*;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.entity.OtaBaSjSjmbcl;
import com.jero.modules.ota.entity.OtaBaSjSjmbcx;
import com.jero.modules.ota.entity.VinObj;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjSjmbclMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaSjListService;
import com.jero.modules.ota.service.IOtaBaSjLsjlService;
import com.jero.modules.ota.service.IOtaBaSjSjmbclService;
import com.jero.modules.ota.service.IOtaBaSjSjmbcxService;
import com.jero.modules.ota.utils.CSVUtil;
import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService;
@@ -23,17 +28,13 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.util.List;
import java.util.Date;
import java.util.UUID;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.util.*;
/**
* @Description: 升级备案-升级目标车辆
@@ -44,6 +45,8 @@ import javax.servlet.http.HttpServletResponse;
@Service
public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, OtaBaSjSjmbcl> implements IOtaBaSjSjmbclService {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
@Value(value = "${ota.templatePath}")
private String templatePath;
@@ -59,6 +62,10 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
@Autowired
private IOSSFileService ossFileService;
@Autowired
private IOtaBaSjSjmbcxService otaBaSjSjmbcxService;
/**
* 保存
*
@@ -183,14 +190,80 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
if (null == upFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjSjmbcl mbcl = parseFile(upFile, cut);
OtaBaSjSjmbcl mbcl = parseFile(upFile, otaId, cut);
mbcl.setOtaId(otaId);
add(mbcl);
return mbcl;
}
private OtaBaSjSjmbcl parseFile(File upFile, String cut) {
private OtaBaSjSjmbcl parseFile(File upFile, String otaId, String cut) throws Exception {
OtaBaSjSjmbcl mbcl = new OtaBaSjSjmbcl();
OtaBaSjSjmbcx mbcx = otaBaSjSjmbcxService.queryByOtaId(otaId, "");
if (ObjectUtils.isNotEmpty(mbcx) && StringUtils.isNotEmpty(mbcx.getCpxh())) {
String cx = mbcx.getCpxh();
Workbook wb = ImportFileUtil.readExcel(upFile);
Sheet s = wb.getSheetAt(0);
int rows = s.getPhysicalNumberOfRows();
List<VinObj> vinList = new ArrayList<>();
for (int i = 1; i < rows; i++) {
VinObj vinObj = new VinObj();
Row row = s.getRow(i);
Cell cell = row.getCell(0);
vinObj.setVin(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(1);
vinObj.setCx(ImportFileUtil.getCellValue(cell, wb));
if (!cx.equals(vinObj.getCx())) {
continue;
}
cell = row.getCell(2);
vinObj.setGglx(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(3);
vinObj.setScrq(cell.getDateCellValue());
vinObj.setScrqStr(sdf.format(vinObj.getScrq()));
vinList.add(vinObj);
}
mbcl.setOtaId(otaId);
if (ObjectUtils.isNotEmpty(vinList)) {
// 匿名比较器排序
Collections.sort(vinList, new Comparator<VinObj>() {
@Override
public int compare(VinObj p1, VinObj p2) {
return p1.getScrq().compareTo(p2.getScrq());
}
});
mbcl.setZsl(String.valueOf(vinList.size()));
mbcl.setScrqks(vinList.get(0).getScrq());
mbcl.setScrqjs(vinList.get(vinList.size() - 1).getScrq());
// 匿名比较器排序
Collections.sort(vinList, new Comparator<VinObj>() {
@Override
public int compare(VinObj p1, VinObj p2) {
return p1.getVin().compareTo(p2.getVin());
}
});
mbcl.setVinList(vinList.get(0).getVin() + "-" + vinList.get(vinList.size() - 1).getVin());
//生成VIN码文件
LinkedHashMap map = new LinkedHashMap();
map.put("1", "VIN");
List exportData = new ArrayList<Map>();
Map vrow = null;
for (int i = 0; i < vinList.size(); i++) {
vrow = new LinkedHashMap<String, String>();
vrow.put("1", vinList.get(i).getVin());
exportData.add(vrow);
}
String fileName = "VIN码.csv";
File file = CSVUtil.createCSVFile(exportData, map, uploadPath + System.currentTimeMillis(), fileName);
String filePath = uploadPath + "/" + file.getName();
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(file), "/ota", "", CutEnum.CN.getValue());
mbcl.setCsv(ossFile.getId());
}
}
return mbcl;
}
@@ -205,4 +278,5 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
public void exportData(File file, String otaId, String cut) throws Exception {
}
}
@@ -11,11 +11,12 @@ import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.enums.OtaTitleEnum;
import com.jero.modules.ota.mapper.OtaBaSjSjxtbhMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaSjGnxtwhService;
import com.jero.modules.ota.service.IOtaBaSjSjxtbhService;
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.util.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
@@ -52,6 +53,9 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
@Autowired
private IOSSFileService ossFileService;
@Autowired
private IOtaBaSjGnxtwhService otaBaSjGnxtwhService;
@Value(value = "${ota.templatePath}")
private String templatePath;
@@ -221,7 +225,8 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
oldList = new ArrayList<>();
}
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJXTMCBH, OtaTitleEnum.SJKZQMC.getName(), oldList, newList, sysDictService);
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJXTMCBH, OtaTitleEnum.XTMC.getName(), oldList, newList, sysDictService);
deleteByOtaId(otaId);
saveOrUpdateBatch(newList);
otaBaCxTxjlService.saveBatch(reList);
}
@@ -233,30 +238,38 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
Sheet s = wb.getSheetAt(0);
int rows = s.getPhysicalNumberOfRows();
for (int i = 4; i < rows; i++) {
Row row = s.getRow(i);
Cell cell = row.getCell(0);
OtaBaSjSjxtbh xtbh = new OtaBaSjSjxtbh();
cell = row.getCell(1);
xtbh.setOtaId(otaId);
Row row = s.getRow(i);
Cell cell = row.getCell(2);
String kzq = ImportFileUtil.getCellValue(cell, wb);
if (StringUtils.isNotEmpty(kzq)) {
xtbh.setSjkzqmc(kzq);
String gnxt = otaBaSjGnxtwhService.queryGnxtByKzq(kzq);
if (StringUtils.isNotEmpty(gnxt)) {
xtbh.setXtmc(gnxt);
}
}
cell = row.getCell(0);
xtbh.setSjqbgcs(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(2);
cell = row.getCell(1);
xtbh.setSjhbgcs(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(3);
xtbh.setSjkzqmc(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(4);
xtbh.setYjbb(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(5);
cell = row.getCell(4);
xtbh.setSjqrjbb(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(6);
cell = row.getCell(5);
xtbh.setSjhrjbb(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(7);
cell = row.getCell(6);
xtbh.setSjqczxt(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(8);
cell = row.getCell(7);
xtbh.setSjhczxt(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(9);
cell = row.getCell(8);
xtbh.setSjbyzsj(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(10);
cell = row.getCell(9);
xtbh.setSjbdx(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(11);
cell = row.getCell(10);
xtbh.setSfcfsj(ImportFileUtil.getCellValue(cell, wb));
xtbh.setCreateTime(now);
xtbh.setUpdateTime(now);
@@ -14,11 +14,17 @@ import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Date;
@@ -177,8 +183,24 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
return sjyxpg;
}
private OtaBaSjSjyxpg parseFile(File upFile, String cut) {
private OtaBaSjSjyxpg parseFile(File upFile, String cut) throws Exception {
OtaBaSjSjyxpg sjyxpg = new OtaBaSjSjyxpg();
InputStream is = new FileInputStream(upFile);
XWPFDocument doc = new XWPFDocument(is);
List<XWPFTable> tables = doc.getTables();
String sjmdStr = tables.get(1).getRow(0).getCell(2).getText();
if (StringUtils.isNotEmpty(sjmdStr)) {
StringBuilder sb = new StringBuilder();
String[] strs = sjmdStr.split("");
for (int i = 0; i < strs.length; i++) {
if (i >= strs.length - 1) {
sb.append(sysDictService.queryDictItemByValue("uipgrade_purpose", strs[i], cut));
} else {
sb.append(sysDictService.queryDictItemByValue("uipgrade_purpose", strs[i], cut)).append(",");
}
}
sjyxpg.setSjmd(sb.toString());
}
return sjyxpg;
}
@@ -186,7 +208,7 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
public OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("车型基本信息.xlsx")) {
if (f.getName().equals("升级影响评估.docx")) {
upFile = f;
}
}
@@ -0,0 +1,198 @@
package com.jero.modules.ota.utils;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
/**
* 文件操作
*/
public class CSVUtil {
/**
* 生成为CVS文件
*
* @param exportData 源数据List
* @param map csv文件的列表头map
* @param outPutPath 文件路径
* @param fileName 文件名称
* @return
*/
@SuppressWarnings("rawtypes")
public static File createCSVFile(List exportData, LinkedHashMap map,
String outPutPath, String fileName) {
File csvFile = null;
BufferedWriter csvFileOutputStream = null;
try {
// 定义文件名格式并创建
File file = new File(outPutPath);
if (!file.exists()) {
file.mkdir();
}
csvFile = new File(outPutPath + "/" + fileName);
System.out.println("csvFile" + csvFile);
// UTF-8使正确读取分隔符","
csvFileOutputStream = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream(csvFile), "UTF-8"), 1024);
System.out.println("csvFileOutputStream" + csvFileOutputStream);
// 写入文件头部
for (Iterator propertyIterator = map.entrySet().iterator();
propertyIterator.hasNext(); ) {
java.util.Map.Entry propertyEntry =
(java.util.Map.Entry) propertyIterator.next();
csvFileOutputStream.write(
"" + (String) propertyEntry.getValue() != null ?
(String) propertyEntry.getValue() : "" + "");
if (propertyIterator.hasNext()) {
csvFileOutputStream.write(",");
}
}
csvFileOutputStream.newLine();
// 写入文件内容
for (Iterator iterator = exportData.iterator(); iterator.hasNext(); ) {
Object row = (Object) iterator.next();
for (Iterator propertyIterator = map.entrySet().iterator();
propertyIterator.hasNext(); ) {
java.util.Map.Entry propertyEntry =
(java.util.Map.Entry) propertyIterator.next();
csvFileOutputStream.write((String) BeanUtils.getProperty(
row, (String) propertyEntry.getKey()));
if (propertyIterator.hasNext()) {
csvFileOutputStream.write(",");
}
}
if (iterator.hasNext()) {
csvFileOutputStream.newLine();
}
}
csvFileOutputStream.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
csvFileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return csvFile;
}
/**
* 下载文件
*
* @param response
* @param csvFilePath 文件路径
* @param fileName 文件名称
* @throws IOException
*/
public static void exportFile(HttpServletResponse response,
String csvFilePath, String fileName)
throws IOException {
response.setContentType("application/csv;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=" +
URLEncoder.encode(fileName, "UTF-8"));
InputStream in = null;
try {
in = new FileInputStream(csvFilePath);
int len = 0;
byte[] buffer = new byte[1024];
response.setCharacterEncoding("UTF-8");
OutputStream out = response.getOutputStream();
while ((len = in.read(buffer)) > 0) {
out.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});
out.write(buffer, 0, len);
}
} catch (FileNotFoundException e) {
System.out.println(e);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
/**
* 删除该目录filePath下的所有文件
*
* @param filePath 文件目录路径
*/
public static void deleteFiles(String filePath) {
File file = new File(filePath);
if (file.exists()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
files[i].delete();
}
}
}
}
/**
* 删除单个文件
*
* @param filePath 文件目录路径
* @param fileName 文件名称
*/
public static void deleteFile(String filePath, String fileName) {
File file = new File(filePath);
if (file.exists()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
if (files[i].getName().equals(fileName)) {
files[i].delete();
return;
}
}
}
}
}
/**
* 测试数据
*
* @param args
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static void main(String[] args) {
List exportData = new ArrayList<Map>();
Map row1 = new LinkedHashMap<String, String>();
row1.put("1", "11");
exportData.add(row1);
row1 = new LinkedHashMap<String, String>();
row1.put("1", "21");
exportData.add(row1);
LinkedHashMap map = new LinkedHashMap();
map.put("1", "第一列");
String path = "c:/export/";
String fileName = "文件导出";
File file = CSVUtil.createCSVFile(exportData, map, path, fileName);
String fileName2 = file.getName();
System.out.println("文件名称:" + fileName2);
}
}
@@ -10,6 +10,7 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@@ -20,12 +21,14 @@ import java.util.List;
* @param <T>
*/
public class ComparisonUtil<T> {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public ComparisonUtil() {
}
public List<OtaBaCxTxjl> comparisonRecord(String otaId, String newFj,String oldFjStr,OtaModuleEnum otaModuleEnum, String title, IOSSFileService ossFileService) {
public List<OtaBaCxTxjl> comparisonRecord(String otaId, String newFj, String oldFjStr, OtaModuleEnum otaModuleEnum, String title, IOSSFileService ossFileService) {
List<OtaBaCxTxjl> reList = new ArrayList<>();
String[] newFjList = {};
if (StringUtils.isNotEmpty(newFj)) {
@@ -57,6 +60,7 @@ public class ComparisonUtil<T> {
}
return reList;
}
public OtaBaCxTxjl addAttRecord(String otaId, OtaModuleEnum otaModuleEnum, String title, String attName) {
String content = title + "中添加了附件:'" + attName;
OtaBaCxTxjl jl = new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content);
@@ -226,6 +230,10 @@ public class ComparisonUtil<T> {
res = "";
}
}
} else if ("3".equals(ote.getType())) {
if (ObjectUtils.isNotEmpty(newVal)) {
res = sdf.format(newVal);
}
} else {
newVal = field.get(clazz);
if (ObjectUtils.isNotEmpty(newVal)) {
@@ -142,7 +142,7 @@ public class ProjectCertificationInventoryEOEn implements Serializable {
private java.lang.String deliverableTemplate;
/**交付物模板名称**/
@TableField(exist = false)
@Excel(name = "交付物模板", width = 20)
@Excel(name = "Deliverable Template", width = 40)
private String deliverableTemplateName;
/**交付结果*/
@@ -3175,7 +3175,7 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
if(StringUtils.isNotBlank(endTime)){
flag = dateVerify(projectCertificationInventoryEO, errorMsg, endTime,msgList,"截止时间","Due Date");
if(flag){
SimpleDateFormat sd = new SimpleDateFormat();
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = sd.parse(endTime);
@@ -3837,19 +3837,19 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
if(CutEnum.CN.getValue().equals(projectCertificationInventoryEO.getCut())){
title = "*类别,*检验项目,*配置项,*WVTA ID," +
"*标准编号,*责任领域,*工程接口人,*责任人," +
"*交付物类型,交付物模板,*截止日期";
"*交付物类型,交付物模板,*截止日期,报告编号,产品型号,生产企业名称";
}else {
title = "*Category,*Inspection Items,*Configuration Item,*WVTA ID," +
"*Standard No,*Responsible Field,*Eng. Interface,*Assignee," +
"*Deliverable Type,Deliverable Template,*Due Date";
"*Deliverable Type,Deliverable Template,*Due Date,Report No,Product Model,Name Of Manufacturer";
}
List<String> list = Arrays.asList(title.split(","));
int index = 0;
if(CutEnum.CN.getValue().equals(projectCertificationInventoryEO.getCut())){
index = list.indexOf("*截止日期") + 1;
index = list.indexOf("生产企业名称") + 1;
}else{
index = list.indexOf("*Due Date") + 1;
index = list.indexOf("Name Of Manufacturer") + 1;
}
//创建临时文件夹
@@ -3869,7 +3869,7 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
cellStyleTemp.setWrapText(true);//自动换行
CellRangeAddress region =
new CellRangeAddress(1, 1, 0, 10); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
new CellRangeAddress(1, 1, 0, 13); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
sheet.addMergedRegion(region);
String explain= "";
if(CutEnum.CN.getValue().equals(projectCertificationInventoryEO.getCut())){
@@ -300,7 +300,14 @@ export default {
},
handleaddCancel() {
this.visibleadd = false
this.formInline = {}
this.formInline = {
dataList:[
{
dykzq:'',
}
],
gnxt:''
}
},
onChangehistory(page, pageSize) {
this.pageNohistory = page
@@ -179,7 +179,7 @@
</template>
<script>
import { getAction, postAction, deleteAction } from '@/api/manage'
import { getAction, postAction, deleteAction ,downloadFile} from '@/api/manage'
import maintenance from './components/maintenance'
import gnxtwh from './components/gnxtwh'
import upgradecompletion from './components/upgradecompletion'
@@ -201,7 +201,8 @@ export default {
//url传参严格按照当前命名
url: {
list: '/lawsTechnologyEvaluation/lawsTechnologyEvaluationEO/page',
deleteBatch: '/ota/otaBaSjList/delete'
deleteBatch: '/ota/otaBaSjList/delete',
importZipUrl: '/ota/otaBaSjList/importData',//导入
},
visible: false,
@@ -435,22 +436,12 @@ export default {
},
// 导出
handleExport(row) {
let selectedRowKeys = JSON.parse(JSON.stringify(this.selectedRowKeys))
let text = ''
let text = '升级活动备案' + row.ggpc
let flag
if (this.activeTab == this.$t('ImplementationDate')) {
flag = 0
text = this.$t('ImplementationDate')
} else {
text = this.$t('vehicleInProductionDate')
flag = 1
}
let query = {
id: selectedRowKeys.join(','),
...this.searchParmes,
flag: flag
otaId: row.id
}
downloadFile(this.url.exportData, text + '.xls', query, this.Deselect)
downloadFile('/ota/otaBaSjList/exportData', text + '.zip', query, this.Deselect)
},
// 结束升级
endUpgrade(record,flag){
@@ -486,7 +477,7 @@ export default {
},
// 模板下载
handleModule(){
downloadFile('params/paramsInfo/exportTemplate', this.$t('parameterTemplateExportName') + '.xlsx', {})
downloadFile('ota/otaBaSjList/exportTemplate', '升级活动备案' + '.zip', {})
},
addModelList(record){
record.sjzt=1
@@ -162,7 +162,7 @@
<a-col :span="24">
<div class="plus">
<div class="title-text-add">
<span class="title-text-text" :title="$t('allupdatestotheusermanualareinformed')">{{$t('allupdatestotheusermanualareinformed')}}</span>
<span class="title-text-text" :title="$t('userinformstherelevantfile')">{{$t('userinformstherelevantfile')}}</span>
</div>
<a-form-model-item class="itemModel" prop="gzscnr">
<a-button type="primary" @click="clickButtonToUpload('xgwj')" v-model="formInline.xgwj">