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

This commit is contained in:
wangzhijiang
2023-03-28 09:14:59 +08:00
27 changed files with 1511 additions and 607 deletions
@@ -215,7 +215,11 @@ public class OtaBaCxListController extends JeroController<OtaBaCxList, IOtaBaCxL
@GetMapping(value = "/exportData")
// @RequiresPermissions("otaBaCx:exportTemplate")
public void exportData(@RequestParam(value = "otaId", required = false) String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception {
this.otaBaCxListService.exportData(otaId, response, request);
try {
this.otaBaCxListService.exportData(otaId, response, request);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -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.OtaBaCxLsjl;
@@ -22,163 +23,164 @@ import io.swagger.annotations.ApiOperation;
import com.jero.common.aspect.annotation.AutoLog;
/**
/**
* @Description: 车型备案-历史记录
* @Author: jero-boot
* @Date: 2023-03-17
* @Date: 2023-03-17
* @Version: V1.0
*/
@Api(tags="车型备案-历史记录")
@Api(tags = "车型备案-历史记录")
@RestController
@RequestMapping("/ota/otaBaCxLsjl")
@Slf4j
public class OtaBaCxLsjlController extends JeroController<OtaBaCxLsjl, IOtaBaCxLsjlService> {
@Autowired
private IOtaBaCxLsjlService otaBaCxLsjlService;
/**
* 分页列表查询
*
* @param otaBaCxLsjl
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "车型备案-历史记录-分页列表查询")
@ApiOperation(value="车型备案-历史记录-分页列表查询", notes="车型备案-历史记录-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaCxLsjl otaBaCxLsjl,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaCxLsjl> queryWrapper = QueryGenerator.initQueryWrapper(otaBaCxLsjl, req.getParameterMap());
Page<OtaBaCxLsjl> page = new Page<OtaBaCxLsjl>(pageNo, pageSize);
IPage<OtaBaCxLsjl> pageList = otaBaCxLsjlService.page(page, queryWrapper);
return Result.OK(pageList);
}
@Autowired
private IOtaBaCxLsjlService otaBaCxLsjlService;
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "车型备案-历史记录-列表查询")
@ApiOperation(value="车型备案-历史记录-列表查询", notes="车型备案-历史记录-列表查询")
@GetMapping(value = "/list")
public Result<List<OtaBaCxLsjl>> queryList() {
List<OtaBaCxLsjl> list = otaBaCxLsjlService.queryList();
* 分页列表查询
*
* @param otaBaCxLsjl
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "车型备案-历史记录-分页列表查询")
@ApiOperation(value = "车型备案-历史记录-分页列表查询", notes = "车型备案-历史记录-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaCxLsjl otaBaCxLsjl,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaCxLsjl> queryWrapper = QueryGenerator.initQueryWrapper(otaBaCxLsjl, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
Page<OtaBaCxLsjl> page = new Page<OtaBaCxLsjl>(pageNo, pageSize);
IPage<OtaBaCxLsjl> pageList = otaBaCxLsjlService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "车型备案-历史记录-列表查询")
@ApiOperation(value = "车型备案-历史记录-列表查询", notes = "车型备案-历史记录-列表查询")
@GetMapping(value = "/list")
public Result<List<OtaBaCxLsjl>> queryList() {
List<OtaBaCxLsjl> list = otaBaCxLsjlService.list();
return Result.OK(list);
}
/**
* 添加
*
* @param otaBaCxLsjl
* @return
*/
@AutoLog(value = "车型备案-历史记录-添加")
@ApiOperation(value="车型备案-历史记录-添加", notes="车型备案-历史记录-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaCxLsjl otaBaCxLsjl) {
otaBaCxLsjlService.add(otaBaCxLsjl);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param otaBaCxLsjl
* @return
*/
@AutoLog(value = "车型备案-历史记录-编辑")
@ApiOperation(value="车型备案-历史记录-编辑", notes="车型备案-历史记录-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaCxLsjl otaBaCxLsjl) {
otaBaCxLsjlService.editById(otaBaCxLsjl);
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) {
otaBaCxLsjlService.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.otaBaCxLsjlService.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) {
OtaBaCxLsjl otaBaCxLsjl = otaBaCxLsjlService.queryById(id);
if(otaBaCxLsjl==null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxLsjl);
}
/**
* 通过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<OtaBaCxLsjl> otaBaCxLsjlList = otaBaCxLsjlService.queryByOtaId(otaId);
if(otaBaCxLsjlList==null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxLsjlList);
}
}
/**
* 导出excel
*
* @param request
* @param otaBaCxLsjl
*/
* 添加
*
* @param otaBaCxLsjl
* @return
*/
@AutoLog(value = "车型备案-历史记录-添加")
@ApiOperation(value = "车型备案-历史记录-添加", notes = "车型备案-历史记录-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaCxLsjl otaBaCxLsjl) {
otaBaCxLsjlService.add(otaBaCxLsjl);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param otaBaCxLsjl
* @return
*/
@AutoLog(value = "车型备案-历史记录-编辑")
@ApiOperation(value = "车型备案-历史记录-编辑", notes = "车型备案-历史记录-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaCxLsjl otaBaCxLsjl) {
otaBaCxLsjlService.editById(otaBaCxLsjl);
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) {
otaBaCxLsjlService.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.otaBaCxLsjlService.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) {
OtaBaCxLsjl otaBaCxLsjl = otaBaCxLsjlService.queryById(id);
if (otaBaCxLsjl == null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxLsjl);
}
/**
* 通过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<OtaBaCxLsjl> otaBaCxLsjlList = otaBaCxLsjlService.queryByOtaId(otaId);
if (otaBaCxLsjlList == null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaCxLsjlList);
}
/**
* 导出excel
*
* @param request
* @param otaBaCxLsjl
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, OtaBaCxLsjl otaBaCxLsjl) {
return super.exportXls(request, otaBaCxLsjl, OtaBaCxLsjl.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, OtaBaCxLsjl.class);
@@ -53,6 +53,7 @@ public class OtaBaCxTxjlController extends JeroController<OtaBaCxTxjl, IOtaBaCxT
@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);
@@ -54,6 +54,7 @@ public class OtaBaSjListController extends JeroController<OtaBaSjList, IOtaBaSjL
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaSjList> queryWrapper = QueryGenerator.initQueryWrapper(otaBaSjList, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
Page<OtaBaSjList> page = new Page<OtaBaSjList>(pageNo, pageSize);
IPage<OtaBaSjList> pageList = otaBaSjListService.page(page, queryWrapper);
return Result.OK(pageList);
@@ -53,6 +53,7 @@ public class OtaBaSjLsjlController extends JeroController<OtaBaSjLsjl, IOtaBaSjL
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaSjLsjl> queryWrapper = QueryGenerator.initQueryWrapper(otaBaSjLsjl, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
Page<OtaBaSjLsjl> page = new Page<OtaBaSjLsjl>(pageNo, pageSize);
IPage<OtaBaSjLsjl> pageList = otaBaSjLsjlService.page(page, queryWrapper);
return Result.OK(pageList);
@@ -71,4 +71,6 @@ public interface IOtaBaCxAqcsService extends IService<OtaBaCxAqcs> {
OtaBaCxAqcs importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaCxAqcs parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, File attFile, String otaId, String cut) throws Exception;
}
@@ -71,4 +71,6 @@ public interface IOtaBaCxJbxxService extends IService<OtaBaCxJbxx> {
OtaBaCxJbxx importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaCxJbxx parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -71,4 +71,6 @@ public interface IOtaBaCxJsfzbacsService extends IService<OtaBaCxJsfzbacs> {
void importData(MultipartFile file, String otaId, String cut) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -71,4 +71,6 @@ public interface IOtaBaCxKsjjsmccsService extends IService<OtaBaCxKsjjsmccs> {
void importData(MultipartFile file, String otaId, String cut) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, File attFile, String otaId, String cut) throws Exception;
}
@@ -71,4 +71,6 @@ public interface IOtaBaCxKsjxtmccsService extends IService<OtaBaCxKsjxtmccs> {
void importData(MultipartFile file, String otaId, String cut) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, File attFile, String otaId, String cut) throws Exception;
}
@@ -11,65 +11,65 @@ import java.util.List;
/**
* @Description: 车型及功能备案列表
* @Author: jero-boot
* @Date: 2023-03-17
* @Date: 2023-03-17
* @Version: V1.0
*/
public interface IOtaBaCxListService extends IService<OtaBaCxList> {
/**
* 保存
*
* @param otaBaCxList
* @return
*/
/**
* 保存
*
* @param otaBaCxList
* @return
*/
void add(OtaBaCxList otaBaCxList);
/**
* 更新
*
* @param otaBaCxList
* @return
*/
/**
* 更新
*
* @param otaBaCxList
* @return
*/
void editById(OtaBaCxList otaBaCxList);
/**
* 通过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
*/
OtaBaCxList queryById(String id);
/**
* 列表查询
*/
* 列表查询
*/
List<OtaBaCxList> queryList();
/**
* 备案维护
*/
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);
void importData(MultipartFile file, String cut) throws Exception;
void exportData(String otaId, HttpServletResponse response, HttpServletRequest request);
void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception;
}
@@ -72,4 +72,6 @@ public interface IOtaBaCxZxsjyqService extends IService<OtaBaCxZxsjyq> {
OtaBaCxZxsjyq importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaCxZxsjyq parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, File attFile,String otaId, String cut) throws Exception;
}
@@ -3,6 +3,7 @@ package com.jero.modules.ota.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.oss.CosBootUtil;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.ota.entity.*;
@@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Date;
@@ -86,7 +88,7 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
if (ObjectUtils.isEmpty(otaBaCxAqcsOld)) {
otaBaCxAqcsOld = new OtaBaCxAqcs();
}
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxAqcsOld.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaCxAqcsOld, otaBaCxAqcs, sysDictService);
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxAqcs.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaCxAqcsOld, otaBaCxAqcs, sysDictService);
otaBaCxTxjlService.saveBatch(reList);
}
}
@@ -233,4 +235,49 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
aqcs.setZmcl(obj.toString());
return aqcs;
}
@Override
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
OtaBaCxAqcs aqcs = getByOtaId(otaId);
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(2);
Cell cell = row.getCell(2);
cell.setCellValue(sysDictService.queryDictItemByValue("protection_mechanism", aqcs.getBhjz(), cut));
row = s.getRow(3);
cell = row.getCell(2);
cell.setCellValue(sysDictService.queryDictItemByValue("fail_safe_mechanism", aqcs.getFsxjz(), cut));
row = s.getRow(4);
cell = row.getCell(2);
cell.setCellValue(sysDictService.queryDictItemByValue("upgrade_failure", aqcs.getSjsbcs(), cut));
row = s.getRow(5);
cell = row.getCell(2);
cell.setCellValue(sysDictService.queryDictItemByValue("Information_security_mechanism", aqcs.getXxaqjz(), cut));
row = s.getRow(2);
cell = row.getCell(3);
StringBuilder sb = new StringBuilder();
String attStr = aqcs.getZmcl();
List<AttachmentEO> attList = JSONArray.parseArray(attStr, AttachmentEO.class);
if (ObjectUtils.isNotEmpty(attList)) {
for (AttachmentEO aeo : attList) {
List<OSSFile> ossFileList = ossFileService.getFileInfos(aeo.getId());
for (OSSFile ossFile : ossFileList) {
String filePath = ossFile.getUrl();
boolean b = CosBootUtil.doesObjectExist(filePath);
if (b) {
InputStream download = CosBootUtil.download(filePath);
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
sb.append(ossFile.getFileName()).append(",");
}
}
}
}
cell.setCellValue(sb.toString());
}
}
@@ -236,5 +236,48 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
return jbxx;
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
OtaBaCxJbxx jbxx = this.getByOtaId(otaId);
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(1);
Cell cell = row.getCell(1);
cell.setCellValue(jbxx.getQymc());
row = s.getRow(2);
cell = row.getCell(1);
cell.setCellValue(jbxx.getDjbh());
row = s.getRow(3);
cell = row.getCell(1);
cell.setCellValue(jbxx.getCplb());
row = s.getRow(4);
cell = row.getCell(1);
cell.setCellValue(jbxx.getGgpc());
row = s.getRow(5);
cell = row.getCell(1);
cell.setCellValue(jbxx.getCpsb());
row = s.getRow(6);
cell = row.getCell(1);
cell.setCellValue(jbxx.getCpmc());
row = s.getRow(7);
cell = row.getCell(1);
cell.setCellValue(jbxx.getCpxh());
row = s.getRow(8);
cell = row.getCell(1);
cell.setCellValue(jbxx.getDllx1());
row = s.getRow(9);
cell = row.getCell(1);
cell.setCellValue(jbxx.getDllx2());
row = s.getRow(10);
cell = row.getCell(1);
cell.setCellValue(sysDictService.queryDictItemByValue("communication_terminal", jbxx.getTxzd(), cut));
row = s.getRow(11);
cell = row.getCell(1);
cell.setCellValue(jbxx.getCdotasj());
wb.write(new FileOutputStream(file));
wb.close();
}
}
@@ -248,6 +248,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
parseFileList(upLoadFiles, otaId, cut);
}
@Override
public void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
File upFile = null;
@@ -326,7 +327,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
Row row = s.getRow(2);
Cell cell = row.getCell(2);
bass.setJsfzczjPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setJsfzczjPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(2);
cell = row.getCell(4);
bass.setJgldSl(ImportFileUtil.getCellValue(cell, wb));
@@ -342,7 +343,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(6);
cell = row.getCell(2);
bass.setHmbldPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setHmbldPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(6);
cell = row.getCell(4);
bass.setHmbldSl(ImportFileUtil.getCellValue(cell, wb));
@@ -359,7 +360,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(10);
cell = row.getCell(2);
bass.setCsbldPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setCsbldPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(10);
cell = row.getCell(4);
bass.setCsbldSl(ImportFileUtil.getCellValue(cell, wb));
@@ -376,7 +377,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(14);
cell = row.getCell(2);
bass.setSxthsPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setSxthsPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(14);
cell = row.getCell(4);
bass.setSxthsSl(ImportFileUtil.getCellValue(cell, wb));
@@ -392,7 +393,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(18);
cell = row.getCell(2);
bass.setSxtdsdPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setSxtdsdPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(18);
cell = row.getCell(4);
bass.setSxtdsdSl(ImportFileUtil.getCellValue(cell, wb));
@@ -408,7 +409,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(22);
cell = row.getCell(2);
bass.setJsyjkPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setJsyjkPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(22);
cell = row.getCell(4);
bass.setJsyjkSl(ImportFileUtil.getCellValue(cell, wb));
@@ -424,7 +425,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(26);
cell = row.getCell(2);
bass.setJsyhwPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setJsyhwPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(26);
cell = row.getCell(4);
bass.setJsyhwSl(ImportFileUtil.getCellValue(cell, wb));
@@ -440,7 +441,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(30);
cell = row.getCell(2);
bass.setCzwxdwPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setCzwxdwPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(30);
cell = row.getCell(4);
bass.setCzwxdwGgxh(ImportFileUtil.getCellValue(cell, wb));
@@ -450,7 +451,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(32);
cell = row.getCell(2);
bass.setGxdhPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setGxdhPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(32);
cell = row.getCell(4);
bass.setGxdhGgxh(ImportFileUtil.getCellValue(cell, wb));
@@ -460,7 +461,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(34);
cell = row.getCell(2);
bass.setLsjPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setLsjPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(34);
cell = row.getCell(4);
bass.setLsjGgxh(ImportFileUtil.getCellValue(cell, wb));
@@ -470,7 +471,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(36);
cell = row.getCell(2);
bass.setGjddtPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setGjddtPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(36);
cell = row.getCell(4);
bass.setGjddtGgxh(ImportFileUtil.getCellValue(cell, wb));
@@ -480,14 +481,14 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(38);
cell = row.getCell(2);
bass.setDzwlPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setDzwlPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(38);
cell = row.getCell(4);
bass.setDzwlDxxgcs(ImportFileUtil.getCellValue(cell, wb));
row = s.getRow(39);
cell = row.getCell(2);
bass.setCztxPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setCztxPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(39);
cell = row.getCell(4);
bass.setCztxXtmc(ImportFileUtil.getCellValue(cell, wb));
@@ -506,7 +507,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(44);
cell = row.getCell(2);
bass.setJsfzczjPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setJsfzczjPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(44);
cell = row.getCell(4);
bass.setJsfzczjMc(ImportFileUtil.getCellValue(cell, wb));
@@ -519,7 +520,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(47);
cell = row.getCell(2);
bass.setJsfzzsqPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setJsfzzsqPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(47);
cell = row.getCell(4);
bass.setJsfzzsqMc(ImportFileUtil.getCellValue(cell, wb));
@@ -532,7 +533,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(50);
cell = row.getCell(2);
bass.setFxptstsPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setFxptstsPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(50);
cell = row.getCell(4);
bass.setFxptstsMc(ImportFileUtil.getCellValue(cell, wb));
@@ -545,7 +546,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(53);
cell = row.getCell(2);
bass.setJsyzyltsPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setJsyzyltsPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(53);
cell = row.getCell(4);
bass.setJsyzyltsMc(ImportFileUtil.getCellValue(cell, wb));
@@ -558,7 +559,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(56);
cell = row.getCell(2);
bass.setDssadPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setDssadPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(56);
cell = row.getCell(4);
bass.setDssadGgxh(ImportFileUtil.getCellValue(cell, wb));
@@ -568,7 +569,7 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
row = s.getRow(58);
cell = row.getCell(2);
bass.setEdrPz(Integer.parseInt(ImportFileUtil.getCellValueYesOrNo(cell, wb)));
bass.setEdrPz(ImportFileUtil.getCellValueYesOrNoInt(cell, wb));
row = s.getRow(58);
cell = row.getCell(4);
bass.setEdrGgxh(ImportFileUtil.getCellValue(cell, wb));
@@ -577,4 +578,287 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
bass.setEdrScqy(ImportFileUtil.getCellValue(cell, wb));
return bass;
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
OtaBaCxJsfzbacs bass = getByOtaId(otaId);
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
bass.setOtaId(otaId);
Row row = s.getRow(2);
Cell cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getJsfzczjPz()));
row = s.getRow(2);
cell = row.getCell(4);
cell.setCellValue(bass.getJgldSl());
row = s.getRow(3);
cell = row.getCell(4);
cell.setCellValue(bass.getJgldBzwz());
row = s.getRow(4);
cell = row.getCell(4);
cell.setCellValue(bass.getJgldGgxh());
row = s.getRow(5);
cell = row.getCell(4);
cell.setCellValue(bass.getJgldScqy());
row = s.getRow(6);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getHmbldPz()));
row = s.getRow(6);
cell = row.getCell(4);
cell.setCellValue(bass.getHmbldSl());
row = s.getRow(7);
cell = row.getCell(4);
cell.setCellValue(bass.getHmbldBzwz());
row = s.getRow(8);
cell = row.getCell(4);
cell.setCellValue(bass.getHmbldGgxh());
row = s.getRow(9);
cell = row.getCell(4);
cell.setCellValue(bass.getHmbldScqy());
row = s.getRow(10);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getCsbldPz()));
row = s.getRow(10);
cell = row.getCell(4);
cell.setCellValue(bass.getCsbldSl());
row = s.getRow(11);
cell = row.getCell(4);
cell.setCellValue(bass.getCsbldBzwz());
row = s.getRow(12);
cell = row.getCell(4);
cell.setCellValue(bass.getCsbldGgxh());
row = s.getRow(13);
cell = row.getCell(4);
cell.setCellValue(bass.getCsbldScqy());
row = s.getRow(14);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getSxthsPz()));
row = s.getRow(14);
cell = row.getCell(4);
cell.setCellValue(bass.getSxthsSl());
row = s.getRow(15);
cell = row.getCell(4);
cell.setCellValue(bass.getSxthsBzwz());
row = s.getRow(16);
cell = row.getCell(4);
cell.setCellValue(bass.getSxthsGgxh());
row = s.getRow(17);
cell = row.getCell(4);
cell.setCellValue(bass.getSxthsScqy());
row = s.getRow(18);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getSxtdsdPz()));
row = s.getRow(18);
cell = row.getCell(4);
cell.setCellValue(bass.getSxtdsdSl());
row = s.getRow(19);
cell = row.getCell(4);
cell.setCellValue(bass.getSxtdsdBzwz());
row = s.getRow(20);
cell = row.getCell(4);
cell.setCellValue(bass.getSxtdsdGgxh());
row = s.getRow(21);
cell = row.getCell(4);
cell.setCellValue(bass.getSxtdsdScqy());
row = s.getRow(22);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getJsyjkPz()));
row = s.getRow(22);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyjkSl());
row = s.getRow(23);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyjkBzwz());
row = s.getRow(24);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyjkGgxh());
row = s.getRow(25);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyjkScqy());
row = s.getRow(26);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getJsyhwPz()));
row = s.getRow(26);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyhwSl());
row = s.getRow(27);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyhwBzwz());
row = s.getRow(28);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyhwGgxh());
row = s.getRow(29);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyhwScqy());
row = s.getRow(30);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getCzwxdwPz()));
row = s.getRow(30);
cell = row.getCell(4);
cell.setCellValue(bass.getCzwxdwGgxh());
row = s.getRow(31);
cell = row.getCell(4);
cell.setCellValue(bass.getCzwxdwScqy());
row = s.getRow(32);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getGxdhPz()));
row = s.getRow(32);
cell = row.getCell(4);
cell.setCellValue(bass.getGxdhGgxh());
row = s.getRow(33);
cell = row.getCell(4);
cell.setCellValue(bass.getGxdhScqy());
row = s.getRow(34);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getLsjPz()));
row = s.getRow(34);
cell = row.getCell(4);
cell.setCellValue(bass.getLsjGgxh());
row = s.getRow(35);
cell = row.getCell(4);
cell.setCellValue(bass.getLsjScqy());
row = s.getRow(36);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getGjddtPz()));
row = s.getRow(36);
cell = row.getCell(4);
cell.setCellValue(bass.getGjddtGgxh());
row = s.getRow(37);
cell = row.getCell(4);
cell.setCellValue(bass.getGjddtScqy());
row = s.getRow(38);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getDzwlPz()));
row = s.getRow(38);
cell = row.getCell(4);
cell.setCellValue(bass.getDzwlDxxgcs());
row = s.getRow(39);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getCztxPz()));
row = s.getRow(39);
cell = row.getCell(4);
cell.setCellValue(bass.getCztxXtmc());
row = s.getRow(40);
cell = row.getCell(4);
cell.setCellValue(bass.getCztxGgxh());
row = s.getRow(41);
cell = row.getCell(4);
cell.setCellValue(bass.getCztxScqy());
row = s.getRow(42);
cell = row.getCell(4);
cell.setCellValue(bass.getCztxBbh());
row = s.getRow(43);
cell = row.getCell(4);
cell.setCellValue(bass.getCztxKfqy());
row = s.getRow(44);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getJsfzczjPz()));
row = s.getRow(44);
cell = row.getCell(4);
cell.setCellValue(bass.getJsfzczjMc());
row = s.getRow(45);
cell = row.getCell(4);
cell.setCellValue(bass.getJsfzczjYjxh());
row = s.getRow(46);
cell = row.getCell(4);
cell.setCellValue(bass.getJsfzczjScqy());
row = s.getRow(47);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getJsfzzsqPz()));
row = s.getRow(47);
cell = row.getCell(4);
cell.setCellValue(bass.getJsfzzsqMc());
row = s.getRow(48);
cell = row.getCell(4);
cell.setCellValue(bass.getJsfzzsqYjxh());
row = s.getRow(49);
cell = row.getCell(4);
cell.setCellValue(bass.getJsfzzsqScqy());
row = s.getRow(50);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getFxptstsPz()));
row = s.getRow(50);
cell = row.getCell(4);
cell.setCellValue(bass.getFxptstsMc());
row = s.getRow(51);
cell = row.getCell(4);
cell.setCellValue(bass.getFxptstsYjxh());
row = s.getRow(52);
cell = row.getCell(4);
cell.setCellValue(bass.getFxptstsScqy());
row = s.getRow(53);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getJsyzyltsPz()));
row = s.getRow(53);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyzyltsMc());
row = s.getRow(54);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyzyltsYjxh());
row = s.getRow(55);
cell = row.getCell(4);
cell.setCellValue(bass.getJsyzyltsScqy());
row = s.getRow(56);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getDssadPz()));
row = s.getRow(56);
cell = row.getCell(4);
cell.setCellValue(bass.getDssadGgxh());
row = s.getRow(57);
cell = row.getCell(4);
cell.setCellValue(bass.getDssadScqy());
row = s.getRow(58);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(bass.getEdrPz()));
row = s.getRow(58);
cell = row.getCell(4);
cell.setCellValue(bass.getEdrGgxh());
row = s.getRow(59);
cell = row.getCell(4);
cell.setCellValue(bass.getEdrScqy());
List<OtaBaCxSjmk> sjmkList = OtaBaCxSjmkService.queryByOtaId(otaId);
int startRow = 63;
for (OtaBaCxSjmk sjmk : sjmkList) {
row = s.getRow(startRow);
cell = row.createCell(0);
cell.setCellValue(sjmk.getBjmc());
cell = row.createCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(sjmk.getPzqk()));
cell = row.createCell(2);
cell.setCellValue(sjmk.getKzqmc());
cell = row.createCell(3);
cell.setCellValue(sjmk.getYjggxh());
cell = row.createCell(4);
cell.setCellValue(sjmk.getYjscqy());
cell = row.createCell(5);
cell.setCellValue(sjmk.getRjbb());
cell = row.createCell(6);
cell.setCellValue(sjmk.getRjkfqy());
cell = row.createCell(7);
cell.setCellValue(sjmk.getBzwz());
startRow++;
}
}
}
@@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.oss.CosBootUtil;
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.enums.OtaModuleEnum;
import com.jero.modules.ota.enums.OtaTitleEnum;
@@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*;
@@ -60,6 +64,9 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
@Autowired
private ISysDictService sysDictService;
@Autowired
private IOSSFileService ossFileService;
/**
* 保存
*
@@ -229,7 +236,7 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
}
List<OtaBaCxKsjjsmccs> oldList = getByOtaId(otaId);
List<OtaBaCxKsjjsmccs> mccsList = parseFile(upFile, otaId, cut);
List<OtaBaCxKsjjsmccs> mccsList = parseFile(upFile, attFile, otaId, cut);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KZXSJDJSFZGNMCYCS, OtaTitleEnum.GNMC.getName(), oldList, mccsList, sysDictService);
deleteByOtaId(otaId);
@@ -238,7 +245,7 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
}
private List<OtaBaCxKsjjsmccs> parseFile(File upFile, String otaId, String cut) throws Exception {
private List<OtaBaCxKsjjsmccs> parseFile(File upFile, File attFile, String otaId, String cut) throws Exception {
Date now = new Date();
List<OtaBaCxKsjjsmccs> mccsList = new ArrayList<>();
Workbook wb = ImportFileUtil.readExcel(upFile);
@@ -253,7 +260,10 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
//列表数据数量,在证明材料处结束
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
if (ObjectUtils.isNotEmpty(otaBaCxList)) {
otaBaCxList.setZxsjjsfj(str);
cell = row.getCell(1);
str = ImportFileUtil.getCellValue(cell, wb);
String[] strs = str.split(",");
otaBaCxList.setZxsjjsfj(ImportFileUtil.uploadFiles(attFile, strs, ossFileService));
otaBaCxListService.editById(otaBaCxList);
}
break;
@@ -292,4 +302,68 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
}
return mccsList;
}
@Override
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
List<OtaBaCxKsjjsmccs> mccsList = this.getByOtaId(otaId);
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
int startRow = 3;
for (OtaBaCxKsjjsmccs mccs : mccsList) {
Row row = s.getRow(startRow);
Cell cell = row.createCell(0);
cell.setCellValue(mccs.getGnmc());
cell = row.createCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(mccs.getPzqk()));
cell = row.createCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(mccs.getSfksj()));
cell = row.createCell(3);
cell.setCellValue(mccs.getJszdhjb());
cell = row.createCell(4);
cell.setCellValue(mccs.getSjggcs());
cell = row.createCell(5);
cell.setCellValue(mccs.getGnms());
cell = row.createCell(6);
cell.setCellValue(mccs.getSytj());
cell = row.createCell(7);
cell.setCellValue(mccs.getKzqmc());
cell = row.createCell(8);
cell.setCellValue(mccs.getKzqscqy());
cell = row.createCell(9);
cell.setCellValue(mccs.getKzqxh());
cell = row.createCell(10);
cell.setCellValue(mccs.getYjbbxx());
cell = row.createCell(11);
cell.setCellValue(mccs.getRjkfqy());
cell = row.createCell(12);
cell.setCellValue(mccs.getCzxtbbh());
cell = row.createCell(13);
cell.setCellValue(mccs.getCsyzsj());
}
Row row = s.getRow(startRow);
Cell cell = row.createCell(0);
cell.setCellValue("证明材料");
cell = row.getCell(1);
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
if (ObjectUtils.isNotEmpty(otaBaCxList)) {
StringBuilder sb = new StringBuilder();
String fj = otaBaCxList.getZxsjjsfj();
if (StringUtils.isNotEmpty(fj)) {
String[] strs = fj.split(",");
for (String str : strs) {
List<OSSFile> ossFileList = ossFileService.getFileInfos(str);
for (OSSFile ossFile : ossFileList) {
String filePath = ossFile.getUrl();
boolean b = CosBootUtil.doesObjectExist(filePath);
if (b) {
InputStream download = CosBootUtil.download(filePath);
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
sb.append(ossFile.getFileName()).append(",");
}
}
}
cell.setCellValue(sb.toString());
}
}
}
}
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.oss.CosBootUtil;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.ota.entity.*;
@@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*;
@@ -254,6 +256,8 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
//列表数据数量,在证明材料处结束
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
if (ObjectUtils.isNotEmpty(otaBaCxList)) {
cell = row.getCell(1);
str = ImportFileUtil.getCellValue(cell, wb);
String[] strs = str.split(",");
otaBaCxList.setZxsjxtfj(ImportFileUtil.uploadFiles(attFile, strs, ossFileService));
otaBaCxListService.editById(otaBaCxList);
@@ -267,10 +271,10 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
cell = row.getCell(2);
mssc.setSjbgcs(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(3);
mssc.setTpt(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(4);
String[] strs = ImportFileUtil.getCellValue(cell, wb).split(",");
mssc.setKzqmc(ImportFileUtil.uploadFiles(attFile, strs, ossFileService));
mssc.setTpt(ImportFileUtil.uploadFiles(attFile, strs, ossFileService));
cell = row.getCell(4);
mssc.setKzqmc(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(5);
mssc.setAqwzxdj(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(6);
@@ -298,4 +302,93 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
}
return mccsList;
}
}
@Override
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
List<OtaBaCxKsjxtmccs> mccsList = this.getByOtaId(otaId);
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
int startRow = 3;
for (OtaBaCxKsjxtmccs mccs : mccsList) {
Row row = s.getRow(startRow);
Cell cell = row.createCell(0);
cell.setCellValue(mccs.getXtlb());
cell = row.createCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(mccs.getSfksj()));
cell = row.createCell(2);
cell.setCellValue(mccs.getSjbgcs());
cell = row.createCell(3);
StringBuilder sb = new StringBuilder();
String tptStr = mccs.getTpt();
if (StringUtils.isNotEmpty(tptStr)) {
String[] strs = tptStr.split(",");
for (String str : strs) {
List<OSSFile> ossFileList = ossFileService.getFileInfos(str);
for (OSSFile ossFile : ossFileList) {
String filePath = ossFile.getUrl();
boolean b = CosBootUtil.doesObjectExist(filePath);
if (b) {
InputStream download = CosBootUtil.download(filePath);
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
sb.append(ossFile.getFileName()).append(",");
}
}
}
cell.setCellValue(sb.toString());
}
cell = row.createCell(4);
cell.setCellValue(mccs.getKzqmc());
cell = row.createCell(5);
cell.setCellValue(mccs.getAqwzxdj());
cell = row.createCell(6);
cell.setCellValue(mccs.getKzqscqy());
cell = row.createCell(7);
cell.setCellValue(mccs.getKzqxh());
cell = row.createCell(8);
cell.setCellValue(mccs.getYjbbxx());
cell = row.createCell(9);
cell.setCellValue(mccs.getCsrjbbh());
cell = row.createCell(10);
cell.setCellValue(mccs.getCsrjbwzsj());
cell = row.createCell(11);
cell.setCellValue(mccs.getSjsfyx());
cell = row.createCell(12);
cell.setCellValue(mccs.getCzxtlx());
cell = row.createCell(13);
cell.setCellValue(mccs.getCzxtscqy());
cell = row.createCell(14);
cell.setCellValue(mccs.getCzxtbbh());
startRow++;
}
Row row = s.getRow(startRow);
Cell cell = row.createCell(0);
cell.setCellValue("证明材料");
cell = row.getCell(1);
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
if (ObjectUtils.isNotEmpty(otaBaCxList)) {
StringBuilder sb = new StringBuilder();
String fj = otaBaCxList.getZxsjxtfj();
if (StringUtils.isNotEmpty(fj)) {
String[] strs = fj.split(",");
for (String str : strs) {
List<OSSFile> ossFileList = ossFileService.getFileInfos(str);
for (OSSFile ossFile : ossFileList) {
String filePath = ossFile.getUrl();
boolean b = CosBootUtil.doesObjectExist(filePath);
if (b) {
InputStream download = CosBootUtil.download(filePath);
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
sb.append(ossFile.getFileName()).append(",");
}
}
}
cell.setCellValue(sb.toString());
}
}
}
}
@@ -10,6 +10,7 @@ import com.jero.modules.ota.mapper.OtaBaCxListMapper;
import com.jero.modules.ota.service.*;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.util.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,10 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -187,28 +185,37 @@ public class OtaBaCxListServiceImpl extends ServiceImpl<OtaBaCxListMapper, OtaBa
}
@Override
public void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) {
log.error("otaId" + otaId);
File template = new File("D://opt//ota//车型及功能备案.zip");
BufferedOutputStream os = null;
InputStream in = null;
try {
in = new FileInputStream(template);
response.setHeader("Content-disposition", "attachment;filename=" + template.getName());
response.setContentType("application/octet-stream;charset=UTF-8");
os = new BufferedOutputStream(response.getOutputStream());
int len;
while ((len = in.read()) != -1) {
os.write(len);
os.flush();
}
in.close();
os.close();
} catch (Exception e) {
throw new JeroBootException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(os);
}
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");
otaBaCxJbxxService.exportData(jbxxFile, otaId, cut);
File sjyqFile = ImportFileUtil.findFile(exportFile, "在线升级要求.xlsx");
File sjyqAttFile = ImportFileUtil.findFoder(exportFile, "在线升级要求");
otaBaCxZxsjyqService.exportData(sjyqFile, sjyqAttFile, otaId, cut);
File aqcsFile = ImportFileUtil.findFile(exportFile, "安全措施.xlsx");
File aqcsAttFile = ImportFileUtil.findFoder(exportFile, "安全措施");
otaBaCxAqcsService.exportData(aqcsFile, aqcsAttFile, otaId, cut);
File mccsFile = ImportFileUtil.findFile(exportFile, "可在线升级的系统名称与参数.xlsx");
File mccsAttFile = ImportFileUtil.findFoder(exportFile, "可在线升级的系统名称与参数");
otaBaCxKsjxtmccsService.exportData(mccsFile, mccsAttFile, otaId, cut);
File jsmccsFile = ImportFileUtil.findFile(exportFile, "可在线升级的驾驶辅助功能名称与参数.xlsx");
File jsmccsAttFile = ImportFileUtil.findFoder(exportFile, "可在线升级的驾驶辅助功能名称与参数");
otaBaCxKsjjsmccsService.exportData(jsmccsFile, jsmccsAttFile, otaId, cut);
File bacsFile = ImportFileUtil.findFile(exportFile, "驾驶辅助系统基础备案参数.xlsx");
otaBaCxJsfzbacsService.exportData(bacsFile, otaId, cut);
String outPath = uploadPath + "/车型及功能备案" + System.currentTimeMillis() + ".zip";
FileOutputStream fos1 = new FileOutputStream(outPath);
ImportFileUtil.toZip(exportFile.getCanonicalPath(), fos1, true);
ImportFileUtil.exportTemplate(response, outPath);
}
}
@@ -93,6 +93,7 @@ public class OtaBaCxLsjlServiceImpl extends ServiceImpl<OtaBaCxLsjlMapper, OtaBa
public List<OtaBaCxLsjl> queryByOtaId(String otaId) {
LambdaQueryWrapper<OtaBaCxLsjl> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OtaBaCxLsjl::getOtaId, otaId);
queryWrapper.orderByDesc(OtaBaCxLsjl::getCreateTime);
List<OtaBaCxLsjl> res = this.list(queryWrapper);
return res;
}
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
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.common.util.oss.CosBootUtil;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.ota.entity.AttachmentEO;
@@ -16,6 +17,8 @@ import com.jero.modules.ota.service.IOtaBaCxZxsjyqService;
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.collections4.ListUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
@@ -30,6 +33,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
@@ -250,4 +254,62 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
otaBaCxZxsjyq.setZmcl(obj.toString());
return otaBaCxZxsjyq;
}
@Override
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
OtaBaCxZxsjyq otaBaCxZxsjyq = this.getByOtaId(otaId);
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(2);
Cell cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getBhsjb()));
row = s.getRow(3);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getBhclbb()));
row = s.getRow(4);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getClgxnl()));
row = s.getRow(5);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getClsjtj()));
row = s.getRow(6);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getClsjdl()));
row = s.getRow(7);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjbhaq()));
row = s.getRow(8);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjantj()));
row = s.getRow(9);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjsbaq()));
row = s.getRow(10);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjgg()));
row = s.getRow(11);
cell = row.getCell(2);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjzt()));
row = s.getRow(2);
cell = row.getCell(3);
StringBuilder sb = new StringBuilder();
String attStr = otaBaCxZxsjyq.getZmcl();
List<AttachmentEO> attList = JSONArray.parseArray(attStr, AttachmentEO.class);
if (ObjectUtils.isNotEmpty(attList)) {
for (AttachmentEO aeo : attList) {
List<OSSFile> ossFileList = ossFileService.getFileInfos(aeo.getId());
for (OSSFile ossFile : ossFileList) {
String filePath = ossFile.getUrl();
boolean b = CosBootUtil.doesObjectExist(filePath);
if (b) {
InputStream download = CosBootUtil.download(filePath);
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
sb.append(ossFile.getFileName()).append(",");
}
}
}
}
cell.setCellValue(sb.toString());
}
}
@@ -70,7 +70,7 @@ public class ComparisonUtil<T> {
Object newVal = field.get(newObj);
String newStr = "";
if (ObjectUtils.isNotEmpty(newVal) && !field.getName().equals(tableField.getName())) {
newStr = newVal.toString();
newStr = parseDictText(ote, field, newObj, sysDictService);
content = tableField.get(newObj).toString() + "-" + title + "由'空'改为'" + newStr + "'";
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
}
@@ -86,6 +86,7 @@ public class ComparisonUtil<T> {
}
}
for (T oldObj : oldList) {
boolean flag = true;
if (ObjectUtils.isNotEmpty(oldObj)) {
Field idField = oldObj.getClass().getDeclaredField("id");
idField.setAccessible(true);
@@ -94,19 +95,22 @@ public class ComparisonUtil<T> {
if (ObjectUtils.isNotEmpty(newObj)) {
Object newId = idField.get(newObj);
if (ObjectUtils.isNotEmpty(newId) && oldId.equals(newId.toString())) {
flag = false;
break;
}
}
}
Field tableTitleField = oldObj.getClass().getDeclaredField(tableTitle);
tableTitleField.setAccessible(true);
Object tableTitleObj = tableTitleField.get(oldObj);
String tableTitleObjStr = "";
if (ObjectUtils.isNotEmpty(tableTitleObj)) {
tableTitleObjStr = tableTitleObj.toString();
if (flag) {
Field tableTitleField = oldObj.getClass().getDeclaredField(tableTitle);
tableTitleField.setAccessible(true);
Object tableTitleObj = tableTitleField.get(oldObj);
String tableTitleObjStr = "";
if (ObjectUtils.isNotEmpty(tableTitleObj)) {
tableTitleObjStr = tableTitleObj.toString();
}
String content = "删除了'" + tableTitleObjStr + "'";
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
}
String content = "删除了'" + tableTitleObjStr + "'";
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
}
}
} catch (IllegalAccessException | NoSuchFieldException e) {
@@ -136,7 +140,7 @@ public class ComparisonUtil<T> {
Object newVal = field.get(newClazz);
String newTitleStr = "";
if (ObjectUtils.isNotEmpty(newVal)) {
Field tableField = newVal.getClass().getDeclaredField(tableTitle);
Field tableField = newClazz.getClass().getDeclaredField(tableTitle);
tableField.setAccessible(true);
Object newTitleVal = tableField.get(newVal);
if (ObjectUtils.isNotEmpty(newTitleVal)) {
@@ -12,15 +12,22 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ImportFileUtil {
@@ -52,8 +59,7 @@ public class ImportFileUtil {
}
public static List<File> importZip(MultipartFile file, String cut, String uploadPath) throws Exception {
List<File> fileList = new ArrayList<>();
public static File copyZip(MultipartFile file, String cut, String uploadPath) throws Exception {
int pos = file.getOriginalFilename().lastIndexOf(".");
String str = file.getOriginalFilename().substring(pos + 1).toLowerCase();
String filenameorg = file.getOriginalFilename().substring(0, pos);
@@ -77,7 +83,12 @@ public class ImportFileUtil {
if (str.equals("zip")) {
zipEntryName = FileUnZip.unZipFiles(path + File.separator + file.getOriginalFilename(), path);
}
File fileNew = new File(path);
return new File(path);
}
public static List<File> importZip(MultipartFile file, String cut, String uploadPath) throws Exception {
List<File> fileList = new ArrayList<>();
File fileNew = ImportFileUtil.copyZip(file, cut, uploadPath);
for (File file1 : fileNew.listFiles()) {
if (file1.getName().contains(".xls") || file1.getName().contains(".xlsx") || file1.isDirectory()
|| file1.getName().contains(".docx") || file1.getName().contains(".doc")) {
@@ -112,7 +123,6 @@ public class ImportFileUtil {
}
public static Workbook readExcel(File file) {
Workbook wb = null;
if (file == null) {
return null;
}
@@ -121,9 +131,9 @@ public class ImportFileUtil {
try {
is = new FileInputStream(file);
if (".xls".equals(extString)) {
return wb = new HSSFWorkbook(is);
return new HSSFWorkbook(is);
} else if (".xlsx".equals(extString)) {
return wb = new XSSFWorkbook(is);
return new XSSFWorkbook(is);
}
is.close();
} catch (FileNotFoundException e) {
@@ -133,7 +143,7 @@ public class ImportFileUtil {
} finally {
IOUtils.closeQuietly(is);
}
return wb;
return null;
}
public static String getCellValue(Cell cell, Workbook workbook) throws Exception {
@@ -147,6 +157,15 @@ public class ImportFileUtil {
return "";
}
public static Integer getCellValueYesOrNoInt(Cell cell, Workbook workbook) throws Exception {
Integer res = null;
String str = getCellValueYesOrNo(cell, workbook);
if (StringUtils.isNotEmpty(str)) {
res = Integer.parseInt(str);
}
return res;
}
public static String getCellValueYesOrNo(Cell cell, Workbook workbook) throws Exception {
String res = "";
String str = getCellValue(cell, workbook);
@@ -160,6 +179,30 @@ public class ImportFileUtil {
return res;
}
public static String getCellValueYesOrNoInt(Integer val) throws Exception {
String res = "";
if (ObjectUtils.isNotEmpty(val)) {
if (val.equals(1)) {
res = "";
} else if (val.equals(2)) {
res = "";
}
}
return res;
}
public static String getCellValueYesOrNo(String str) throws Exception {
String res = "";
if (StringUtils.isNotEmpty(str)) {
if (str.equals("1")) {
res = "";
} else if (str.equals("2")) {
res = "";
}
}
return res;
}
public static String getCellValueDict(Cell cell, Workbook wb, String dictType, ISysDictService sysDictService, String cut) throws Exception {
String res = "";
String str = ImportFileUtil.getCellValue(cell, wb);
@@ -193,6 +236,34 @@ public class ImportFileUtil {
return null;
}
public static File findFoder(File file, String fileName) throws Exception {
// 获取此地址中的所有文件以及文件夹(File[] list)
File[] listFiles = file.listFiles();// 获取此地址中的所有文件以及文件夹(File[] list)
for (File file1 : listFiles) {// 遍历数组
// 判断当前的File对象是否为文件夹
if (file1.isDirectory()) {
String name = file1.getName();
if (name.equals(fileName)) {
return file1;
}
}
}
return null;
}
public static File findFile(List<File> file, String fileName) throws Exception {
for (File file1 : file) {// 遍历数组
// 判断当前的File对象是否为文件夹
if (!file1.isDirectory()) {
String name = file1.getName();
if (name.equals(fileName)) {
return file1;
}
}
}
return null;
}
public static MultipartFile createMfileByFile(File file) {
MultipartFile mFile = null;
try {
@@ -209,13 +280,15 @@ public class ImportFileUtil {
public static List<OSSFile> uploadFiles1(File attFile, String[] strs, IOSSFileService ossFileService) throws Exception {
List<OSSFile> res = new ArrayList<>();
for (int i = 0; i < strs.length; i++) {
File file = ImportFileUtil.findFile(attFile, strs[i]);
if (null == file) {
throw new JeroBootException("找不到文件:" + strs[i]);
}
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(file), "", null, null);
if (ObjectUtils.isNotEmpty(ossFile)) {
res.add(ossFile);
if (StringUtils.isNotEmpty(strs[i])) {
File file = ImportFileUtil.findFile(attFile, strs[i]);
if (null == file) {
throw new JeroBootException("找不到文件:" + strs[i]);
}
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(file), "", null, null);
if (ObjectUtils.isNotEmpty(ossFile)) {
res.add(ossFile);
}
}
}
return res;
@@ -224,20 +297,168 @@ public class ImportFileUtil {
public static String uploadFiles(File attFile, String[] strs, IOSSFileService ossFileService) throws Exception {
String res = "";
for (int i = 0; i < strs.length; i++) {
File file = ImportFileUtil.findFile(attFile, strs[i]);
if (null == file) {
throw new JeroBootException("找不到文件:" + strs[i]);
}
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(file), "", null, null);
if (ObjectUtils.isNotEmpty(ossFile)) {
if (i >= strs.length - 1) {
res += ossFile.getId();
} else {
res += ossFile.getId() + ",";
if (StringUtils.isNotEmpty(strs[i])) {
File file = ImportFileUtil.findFile(attFile, strs[i]);
if (null == file) {
throw new JeroBootException("找不到文件:" + strs[i]);
}
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(file), "", null, null);
if (ObjectUtils.isNotEmpty(ossFile)) {
if (i >= strs.length - 1) {
res += ossFile.getId();
} else {
res += ossFile.getId() + ",";
}
}
}
}
return res;
}
private static final int BUFFER_SIZE = 2 * 1024;
/**
* 压缩成ZIP 方法1
*
* @param srcDir 压缩文件夹路径
* @param out 压缩文件输出流
* @param KeepDirStructure 是否保留原来的目录结构,true:保留目录结构;
* false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)
* @throws RuntimeException 压缩失败会抛出运行时异常
*/
public static void toZip(String srcDir, OutputStream out, boolean KeepDirStructure)
throws RuntimeException {
long start = System.currentTimeMillis();
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(out);
File sourceFile = new File(srcDir);
compress(sourceFile, zos, sourceFile.getName(), KeepDirStructure);
long end = System.currentTimeMillis();
System.out.println("压缩完成,耗时:" + (end - start) + " ms");
} catch (Exception e) {
throw new RuntimeException("zip error from ZipUtils", e);
} finally {
if (zos != null) {
try {
zos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 压缩成ZIP 方法2
*
* @param srcFiles 需要压缩的文件列表
* @param out 压缩文件输出流
* @throws RuntimeException 压缩失败会抛出运行时异常
*/
public static void toZip(List<File> srcFiles, OutputStream out) throws RuntimeException {
long start = System.currentTimeMillis();
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(out);
for (File srcFile : srcFiles) {
byte[] buf = new byte[BUFFER_SIZE];
zos.putNextEntry(new ZipEntry(srcFile.getName()));
int len;
FileInputStream in = new FileInputStream(srcFile);
while ((len = in.read(buf)) != -1) {
zos.write(buf, 0, len);
}
zos.closeEntry();
in.close();
}
long end = System.currentTimeMillis();
System.out.println("压缩完成,耗时:" + (end - start) + " ms");
} catch (Exception e) {
throw new RuntimeException("zip error from ZipUtils", e);
} finally {
if (zos != null) {
try {
zos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 递归压缩方法
*
* @param sourceFile 源文件
* @param zos zip输出流
* @param name 压缩后的名称
* @param KeepDirStructure 是否保留原来的目录结构,true:保留目录结构;
* false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)
* @throws Exception
*/
private static void compress(File sourceFile, ZipOutputStream zos, String name,
boolean KeepDirStructure) throws Exception {
byte[] buf = new byte[BUFFER_SIZE];
if (sourceFile.isFile()) {
// 向zip输出流中添加一个zip实体,构造器中name为zip实体的文件的名字
zos.putNextEntry(new ZipEntry(name));
// copy文件到zip输出流中
int len;
FileInputStream in = new FileInputStream(sourceFile);
while ((len = in.read(buf)) != -1) {
zos.write(buf, 0, len);
}
// Complete the entry
zos.closeEntry();
in.close();
} else {
File[] listFiles = sourceFile.listFiles();
if (listFiles == null || listFiles.length == 0) {
// 需要保留原来的文件结构时,需要对空文件夹进行处理
if (KeepDirStructure) {
// 空文件夹的处理
zos.putNextEntry(new ZipEntry(name + "/"));
// 没有文件,不需要文件的copy
zos.closeEntry();
}
} else {
for (File file : listFiles) {
// 判断是否需要保留原来的文件结构
if (KeepDirStructure) {
// 注意:file.getName()前面需要带上父文件夹的名字加一斜杠,
// 不然最后压缩包中就不能保留原来的文件结构,即:所有文件都跑到压缩包根目录下了
compress(file, zos, name + "/" + file.getName(), KeepDirStructure);
} else {
compress(file, zos, file.getName(), KeepDirStructure);
}
}
}
}
}
/**
* 将InputStream写入本地文件
*
* @param input 输入流
* @throws IOException IOException
*/
public static void writeToLocal(String path, InputStream input)
throws IOException {
int index;
byte[] bytes = new byte[1024];
FileOutputStream downloadFile = new FileOutputStream(path);
while ((index = input.read(bytes)) != -1) {
downloadFile.write(bytes, 0, index);
downloadFile.flush();
}
input.close();
downloadFile.close();
}
}