123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736 |
- package com.bootdo.datas.service.impl;
- import com.alibaba.fastjson.JSONArray;
- import com.bootdo.common.config.BootdoConfig;
- import com.bootdo.common.utils.*;
- import com.bootdo.datas.domain.ExpertOpinionDO;
- import com.bootdo.datas.dao.GyDataDao;
- import com.bootdo.datas.dao.GyUnitDao;
- import com.bootdo.datas.domain.*;
- import com.bootdo.datas.dto.ExamineLogDTO;
- import com.bootdo.datas.dto.GyDataImportDTO;
- import com.bootdo.datas.service.ExamineLogService;
- import com.bootdo.datas.service.GyDataService;
- import com.bootdo.datas.service.UnitService;
- import com.bootdo.datas.tools.ExcelUtils;
- import com.bootdo.datas.tools.gm.FileCryptTool;
- import com.bootdo.system.domain.RoleDO;
- import com.bootdo.system.domain.UserDO;
- import com.bootdo.system.service.RoleService;
- import com.google.common.collect.Lists;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.Row;
- import org.apache.poi.xssf.usermodel.XSSFSheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.CollectionUtils;
- import org.springframework.util.ObjectUtils;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletResponse;
- import java.io.*;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service
- @Transactional
- public class GyDataServiceImpl implements GyDataService {
- @Autowired
- private BootdoConfig bootdoConfig;
- @Autowired
- private GyUnitDao gyUnitDao;
- @Autowired
- private GyDataDao gyDataDao;
- @Value("${managerValue}")
- public String managerValue;
- @Value("${deployType:#{null}}")
- public String deployType;
- @Value("${sysProvince:#{null}}")
- public String sysProvince;
- @Value("${sysCity:#{null}}")
- public String sysCity;
- @Autowired
- private UnitService unitService;
- @Autowired
- private ExamineLogService examineLogService;
- @Autowired
- private RoleService roleService;
- private static Logger log = LoggerFactory.getLogger(GyDataServiceImpl.class);
- @Override
- public List<GyDataImportDTO> list(Map<String, Object> map) {
- UserDO currUser = ShiroUtils.getUser();
- log.info("currUser:" + currUser.toString());
- if (!managerValue.contains(currUser.getDeptId().toString())) {
- String province = currUser.getProvince();
- if(StringUtils.isEmpty(province)){
- province = sysProvince;
- }
- map.put("unitProvince", province);
- String city = currUser.getCity();
- if(StringUtils.isEmpty(city)){
- city = sysCity;
- }
- map.put("unitCity", city);
- if(!ObjectUtils.isEmpty(city)){
- map.put("auditStage", "1");
- } else {
- map.put("auditStage", "2");
- }
- }
- return gyDataDao.list(map);
- }
- @Override
- public int countTotal(Map<String, Object> map) {
- UserDO currUser = ShiroUtils.getUser();
- log.info("currUser:" + currUser.toString());
- if (!managerValue.contains(currUser.getDeptId().toString())) {
- String province = currUser.getProvince();
- if(StringUtils.isEmpty(province)){
- province = sysProvince;
- }
- map.put("unitProvince", province);
- String city = currUser.getCity();
- if(StringUtils.isEmpty(city)){
- city = sysCity;
- }
- map.put("unitCity", city);
- if(!ObjectUtils.isEmpty(city)){
- map.put("auditStage", "1");
- } else {
- map.put("auditStage", "2");
- }
- }
- return gyDataDao.countTotal(map);
- }
- /**
- * @param file
- * @Description: 文件解密
- * @Author: wangp
- * @Date: 2022/3/9 15:07
- * @Return: boolean
- */
- @Override
- public String dec(MultipartFile file) {
- String decFile = "";
- FileInputStream srcStream = null;
- try {
- String fileName = file.getOriginalFilename();
- // 生成临时文件
- String fileNames = FileUtil.renameToUUID(fileName);
- String temFile = bootdoConfig.getUploadPath() + fileNames;
- MultipartFileToFile(file, temFile);
- // FileUtil.uploadFile(file.getBytes(), bootdoConfig.getUploadPath(), fileName);
- // 解密文件路径
- decFile = bootdoConfig.getUploadPath() + fileName;
- log.info("temFile:" + temFile + ",decFile:" + decFile);
- srcStream = new FileInputStream(temFile);
- log.info("srcStream:" + srcStream.toString());
- log.info("EncPrival:" + bootdoConfig.getEncPrival());
- FileCryptTool.decryptFile(bootdoConfig.getEncPrival(), temFile, decFile);
- // 清除数据
- srcStream.close();
- FileUtil.deleteFile(temFile);// 临时文件
- } catch (Exception e) {
- log.error("文件解密异常", e);
- return "";
- }
- return decFile;
- }
- /**
- * @description: 密文导入
- * @param:
- * @return: int
- * @author xhl
- * @date: 2022/9/7 14:28
- */
- @Override
- public String cipherTextImport(String decFlg,int type) {
- File file = new File(decFlg);
- String result = null;
- InputStream is = null;
- try {
- is = new FileInputStream(file);
- result = imp(is,type);
- // 清除临时数据
- FileUtil.deleteFile(decFlg);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- // xssfWorkbook.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return result;
- }
- }
- /**
- * @description: 明文导入
- * @param: file
- * @return: java.lang.String
- * @author xhl
- * @date: 2022/9/7 14:23
- */
- @Override
- public String plainTextImport(MultipartFile file,int type) {
- String result = null;
- InputStream is = null;
- try {
- is = file.getInputStream();
- result = imp(is,type);
- } catch (BDException e) {
- e.printStackTrace();
- throw e;
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- is.close();
- // xssfWorkbook.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return result;
- }
- private String imp(InputStream is,int type) throws Exception {
- int otherProvince = 0;
- int otherCity = 0;
- int auditPass = 0;
- int unitNoAudit = 0;
- XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is);
- XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
- // 企业信息
- List<GyUnitDO> gyUnitList = new ArrayList();
- // 数据目录
- List<GyDataDO> dataList = new ArrayList();
- // 用户信息
- UserDO currUser = ShiroUtils.getUser();
- log.info("currUser:" + currUser.toString());
- if(null == currUser){
- throw new BDException("当前用户没登录");
- }
- String userProvince = null;
- String userCity= null;
- if (managerValue.contains(currUser.getDeptId().toString())) {
- userProvince = sysProvince;
- userCity = sysCity;
- } else {
- userProvince = currUser.getProvince();
- if(StringUtils.isEmpty(userProvince)){
- userProvince = sysProvince;
- }
- userCity = currUser.getCity();
- if(StringUtils.isEmpty(userCity)){
- userCity = sysCity;
- }
- }
- //判断是哪种格式的
- Row firstRow = xssfSheet.getRow(0);
- Cell firstRowCell = firstRow.getCell(0);
- int beginDataRowIndex = 0;
- if("序号".equals(firstRowCell.getStringCellValue())){
- beginDataRowIndex = 1;
- } else {
- beginDataRowIndex = 4;
- }
- if(xssfSheet.getLastRowNum() < beginDataRowIndex){ //getLastRowNum返回最后一行的索引,即 比行总数小1
- throw new BDException("excel文件无数据");
- }
- // 遍历
- for (int i = beginDataRowIndex; i <= xssfSheet.getLastRowNum(); i++) {
- log.info("userProvince: {}, i: {}", userProvince, i);
- Row row = xssfSheet.getRow(i);
- if (row.getCell(1) == null) {
- break;
- }
- if(row.getLastCellNum()<52){ //getLastCellNum返回的是最后一列的列数,即 等于总列数
- throw new BDException("excel文件列数不正确");
- }
- //所属省份
- String dataProvince = row.getCell(18).getStringCellValue();
- String dataCity = row.getCell(19).getStringCellValue();
- // 当非管理员导入的数据为非本省的数据的时候 跳过当前数据 并记录
- if (StringUtils.isEmpty(dataProvince) || (!StringUtils.isEmpty(userProvince)) && !dataProvince.equals(userProvince)) {
- log.info("当前用户省份: {}, 当前数据省份: {}, 数据名称: {}", userProvince, dataProvince, row.getCell(1).getStringCellValue());
- otherProvince++;
- continue;
- }
- if (StringUtils.isEmpty(dataCity) || (!StringUtils.isEmpty(userCity)) && !dataCity.equals(userCity)) {
- log.info("当前用户地市: {}, 当前数据地市: {}, 数据名称: {}", userCity, dataCity, row.getCell(1).getStringCellValue());
- otherCity++;
- continue;
- }
- GyUnitDO tmpGyUnitDO = gyUnitDao.getGyUnitByCreditCode(row.getCell(17).getStringCellValue());
- if (ObjectUtils.isEmpty(tmpGyUnitDO) || !"1".equals(tmpGyUnitDO.getAuditStatus())) {
- unitNoAudit++;
- continue;
- }
- // 企业单位
- GyUnitDO gyUnitDO = new GyUnitDO();
- // 数据信息
- GyDataDO gyDataDO = new GyDataDO();
- //无数据导出
- if ("/".equals(row.getCell(1).getStringCellValue()) && row.getCell(16).getStringCellValue() !=null && !"/".equals(row.getCell(16).getStringCellValue())) {
- gyUnitDO.setReporterUnit(row.getCell(16).getStringCellValue());// 数据处理者名称
- gyUnitDO.setCreditCode(row.getCell(17).getStringCellValue());// 统一社会信用代码(机构代码 )
- gyUnitDO.setUnitProvince(dataProvince);//所在地区(省)
- gyUnitDO.setUnitCity(row.getCell(19).getStringCellValue());//所在地区(市)
- gyUnitDO.setUnitCharacter(row.getCell(20).getStringCellValue());//数据处理者性质
- gyUnitDO.setIndustryTypeOne(row.getCell(21).getStringCellValue());//所属行业
- gyUnitDO.setIndustryTypeTwo(row.getCell(22).getStringCellValue());//主营业务范围
- gyUnitDO.setDataSecurityMan(row.getCell(23).getStringCellValue());//数据安全负责人姓名
- gyUnitDO.setDataSecurityOffice(row.getCell(24).getStringCellValue());//数据安全负责人职务
- gyUnitDO.setDataSecurityWay(row.getCell(25).getStringCellValue());//数据安全负责人联系方式
- int count = gyUnitDao.getGyUnit(gyUnitDO);
- if (count == 0) {
- try {
- gyUnitDO.setCreateTime(new Date());
- gyUnitDO.setStatus("0");
- gyUnitDao.save(gyUnitDO);
- } catch (Exception e) {
- log.error("error enterprise-only : {}", e.getMessage());
- }
- }
- break;
- }
- gyDataDO.setDataName(row.getCell(1).getStringCellValue());//数据名称
- gyDataDO.setDataTypeBase(row.getCell(2).getStringCellValue());//数据分类分级规范
- gyDataDO.setDataTypeOne(row.getCell(3).getStringCellValue());//数据一级类别
- gyDataDO.setDataTypeTwo(row.getCell(4).getStringCellValue());//数据二级类别
- gyDataDO.setDataTypeThree(row.getCell(5)==null?null:row.getCell(5).getStringCellValue());//数据三级类别
- gyDataDO.setDataTypeFour(row.getCell(6)==null?null:row.getCell(6).getStringCellValue());//数据四级类别
- gyDataDO.setDataLevel(row.getCell(7).getStringCellValue());//数据级别
- gyDataDO.setDataCarrier(row.getCell(8).getStringCellValue());//数据载体
- gyDataDO.setDataSource(row.getCell(9).getStringCellValue());//数据来源
- gyDataDO.setDataNumGb(row.getCell(10).getNumericCellValue());//数据数量(非电子数据)
- gyDataDO.setDataNum((int) row.getCell(11).getNumericCellValue());//数据数量(电子数据)
- gyDataDO.setDataScope(row.getCell(12).getStringCellValue());//覆盖类型
- gyDataDO.setDataProportion(row.getCell(13).getStringCellValue());//覆盖占比
- gyDataDO.setDataPrecision(row.getCell(14).getStringCellValue());//数据精度
- gyDataDO.setDataPrecisionDes(row.getCell(15).getStringCellValue());//数据精度描述
- gyUnitDO.setReporterUnit(row.getCell(16).getStringCellValue());// 数据处理者名称
- gyUnitDO.setCreditCode(row.getCell(17).getStringCellValue());// 统一社会信用代码(机构代码 )
- gyUnitDO.setUnitProvince(dataProvince);//所在地区(省)
- gyUnitDO.setUnitCity(row.getCell(19).getStringCellValue());//所在地区(市)
- gyUnitDO.setUnitCharacter(row.getCell(20).getStringCellValue());//数据处理者性质
- gyUnitDO.setIndustryTypeOne(row.getCell(21).getStringCellValue());//所属行业
- gyUnitDO.setIndustryTypeTwo(row.getCell(22).getStringCellValue());//主营业务范围
- gyUnitDO.setDataSecurityMan(row.getCell(23).getStringCellValue());//数据安全负责人姓名
- gyUnitDO.setDataSecurityOffice(row.getCell(24).getStringCellValue());//数据安全负责人职务
- gyUnitDO.setDataSecurityWay(row.getCell(25).getStringCellValue());//数据安全负责人联系方式
- gyUnitList.add(gyUnitDO);
- gyDataDO.setDataHandleType(row.getCell(26).getStringCellValue());//数据处理方式
- gyDataDO.setDataResult(row.getCell(27).getStringCellValue());//数据目的
- gyDataDO.setIsAlgorithmHandle(row.getCell(28).getStringCellValue());//是否涉及算法处理
- gyDataDO.setIsCross(row.getCell(29).getStringCellValue());//是否出境
- gyDataDO.setCrossAcceptName(row.getCell(30).getStringCellValue());//跨境接收方名称
- gyDataDO.setDataCrossType(row.getCell(31).getStringCellValue());//出境方式
- gyDataDO.setIsSecurityAss(row.getCell(32).getStringCellValue());//是否安全评估
- gyDataDO.setAssessResult(row.getCell(33).getStringCellValue());//评估结果
- gyDataDO.setIsCrossMain(row.getCell(34).getStringCellValue());//是否对外共享
- gyDataDO.setCrossmainAcceptName(row.getCell(35).getStringCellValue());//数据对外共享接收方
- gyDataDO.setDataCrossmainType(row.getCell(36).getStringCellValue());//数据对外共享方式
- gyDataDO.setIsForeignData(row.getCell(37).getStringCellValue());//是否为涉外数据
- gyDataDO.setIsCrossmainFlow(row.getCell(38).getStringCellValue());//是否涉及跨主体流动
- gyDataDO.setInfoSystemName(row.getCell(39).getStringCellValue());//信息系统名称
- gyDataDO.setInfoSystemIpAddress(row.getCell(40).getStringCellValue());//信息系统ip地址
- gyDataDO.setInfoSystemDomainName(row.getCell(41).getStringCellValue());//信息系统域名
- gyDataDO.setInfoSystemType(row.getCell(42).getStringCellValue());//信息系统类型
- gyDataDO.setSecurityCognizance(row.getCell(43).getStringCellValue());//网络安全等级保护认定情况
- gyDataDO.setComSecurityCognizance(row.getCell(44).getStringCellValue());//通信网络安全防护定级备案情况
- gyDataDO.setIsKetSystem(row.getCell(45).getStringCellValue());//是否为关键信息基础设施
- gyDataDO.setIsKeydataAss(row.getCell(46).getStringCellValue());//是否开展重要数据安全风险评估
- gyDataDO.setAssessOrg(row.getCell(47).getStringCellValue());//评估机构
- gyDataDO.setAssessBase(row.getCell(48).getStringCellValue());//评估依据的规范
- gyDataDO.setAssessTime(row.getCell(49).getStringCellValue());//评估时间
- gyDataDO.setDataAssessResult(row.getCell(50).getStringCellValue());//重要数据安全风险评估结论
- gyDataDO.setDataDesc(row.getCell(51).getStringCellValue());//备注
- gyDataDO.setGyUnitId(gyUnitDO.getCreditCode());//关联填报企业
- if (type == 1) { //导入列表导入
- gyDataDO.setSendVerify("0");// 送审状态 0:未送审 1:已送审
- gyDataDO.setDataStatus("0"); // 状态 0:待审核 1:删除 2:已上报 3:通过审核 4:驳回
- gyDataDO.setDeleteStatus("0"); // 状态 0:正常 1:删除
- if("1".equals(deployType)){ //市级单独部署
- gyDataDO.setAuditStage("1");
- } else if("2".equals(deployType)){ //省级单独部署
- gyDataDO.setAuditStage("2");
- } else if("3".equals(deployType)){ //省市一体部署
- gyDataDO.setAuditStage("1");
- }
- } else if(type == 2){ //数据目录导入
- gyDataDO.setSendVerify("1");// 送审状态 0:未送审 1:已送审
- gyDataDO.setDataStatus("3"); // 状态 0:待审核 1:删除 2:已上报 3:通过审核 4:驳回
- gyDataDO.setDeleteStatus("0"); // 状态 0:正常 1:删除
- if("1".equals(deployType)){ //市级单独部署
- throw new BDException("不支持该操作,请到“报送到省级”列表操作");
- } else if("2".equals(deployType)){ //省级单独部署
- gyDataDO.setAuditStage("2");
- } else if("3".equals(deployType)){ //省市一体部署
- if(StringUtils.isNotEmpty(currUser.getCity())){ //市级人员操作
- throw new BDException("市级人员无权操作");
- } else {
- gyDataDO.setAuditStage("2");
- }
- }
- } else { //上报到省级导入
- gyDataDO.setSendVerify("1");// 送审状态 0:未送审 1:已送审
- gyDataDO.setDataStatus("3"); // 状态 0:待审核 1:删除 2:已上报 3:通过审核 4:驳回
- gyDataDO.setDeleteStatus("0"); // 状态 0:正常 1:删除
- if("1".equals(deployType)){ //市级单独部署
- gyDataDO.setAuditStage("1");
- } else if("2".equals(deployType)){ //省级单独部署
- throw new BDException("不支持该操作,请到“数据目录”列表操作");
- } else if("3".equals(deployType)){ //省市一体部署
- if(StringUtils.isNotEmpty(currUser.getCity())){ //市级人员操作
- gyDataDO.setAuditStage("1");
- } else {
- if (managerValue.contains(currUser.getDeptId().toString())) { //机构是管理员
- gyDataDO.setAuditStage("1");
- } else { //一般省级人员
- throw new BDException("省级人员无权操作");
- }
- }
- }
- }
- gyDataDO.setUploadTime(new Date());
- gyDataDO.setUpdateTime(gyDataDO.getUploadTime());
- log.info("dataDO:" + gyDataDO.toString());
- Map<String, Object> params = new HashMap<>();
- params.put("dataName", gyDataDO.getDataName());// 数据名称
- params.put("gyUnitId", gyDataDO.getGyUnitId());// 单位
- //判断数据是否已经上传过
- List<GyDataImportDTO> listInfo = gyDataDao.listId(params);
- if (listInfo !=null && listInfo.size()>0) {
- GyDataImportDTO gyDataImportDTO = listInfo.get(0);
- if("3".equals(gyDataImportDTO.getDataStatus())){ //审核通过数据不导入
- log.info("审核通过数据id:" + gyDataImportDTO.getId());
- auditPass++;
- continue;
- } else{
- // 删除数据
- log.info("删除数据id:" + gyDataImportDTO.getId());
- gyDataDao.remove(gyDataImportDTO.getId());
- }
- }
- dataList.add(gyDataDO);
- }
- // 企业单位批量导入
- log.info("unitList size:" + gyUnitList.size());
- if (gyUnitList != null && gyUnitList.size() > 0) {
- for (GyUnitDO gyUnitDO : gyUnitList) {
- log.info("unitList size:" + gyUnitList.size());
- int count = gyUnitDao.getGyUnit(gyUnitDO);
- if (count == 0) {
- try {
- gyUnitDO.setCreateTime(new Date());
- gyUnitDO.setStatus("0");
- gyUnitDO.setAuditStatus("0");
- gyUnitDao.save(gyUnitDO);
- } catch (Exception e) {
- log.error("error enterprise-only : {}", e.getMessage());
- }
- }
- }
- }
- // 数据批量导入
- if (dataList != null && dataList.size() > 0) {
- gyDataDao.batchSave(dataList);
- }
- String result = null;
- if ((otherProvince + otherCity + auditPass + unitNoAudit) > 0) {
- StringBuilder sb = new StringBuilder();
- if (otherProvince > 0) {
- sb.append(otherProvince).append("条非本省数据(已忽略导入)! <br/>");
- }
- if (otherCity > 0) {
- sb.append(otherCity).append("条非本市数据(已忽略导入)! <br/>");
- }
- if (auditPass > 0) {
- sb.append(auditPass).append("条已经审核通过数据(已忽略导入)! <br/>");
- }
- if (unitNoAudit > 0) {
- sb.append(unitNoAudit).append("条所属企业未注册或还没通过审核(已忽略导入)! <br/>");
- }
- result = sb.toString();
- }
- return result;
- }
- @Override
- public GyDataImportDTO get(Long id) {
- return gyDataDao.get(id);
- }
- @Override
- public GyDataExcelDO getDataExcel(Long id) {
- return gyDataDao.getDataExcel(id);
- }
- @Override
- public GbDataExcelDO getGbDataExcel(Long id) {
- return gyDataDao.getGbDataExcel(id);
- }
- @Override
- public void updateStatus(GyDataImportDTO data) {
- int effect = gyDataDao.updateStatus(data);
- if ("2".equalsIgnoreCase(data.getDataStatus()) && effect > 0) {
- GyDataImportDTO gyDataImportDTO = get(data.getId());
- RoleDO roleDO = roleService.get(gyDataImportDTO.getRoleId());
- if (roleDO != null) {
- ExamineLogDTO dto = new ExamineLogDTO();
- dto.setUniqueKey(String.valueOf(data.getId()));
- dto.setDataType("DI_OPER");
- dto.setMessage("数据已送审至: " + roleDO.getRoleName());
- examineLogService.save(dto);
- }
- } else if ("3".equalsIgnoreCase(data.getDataStatus()) && effect > 0) {
- GyDataImportDTO gyDataImportDTO = get(data.getId());
- RoleDO roleDO = roleService.get(gyDataImportDTO.getRoleId());
- if (roleDO != null) {
- ExamineLogDTO dto = new ExamineLogDTO();
- dto.setUniqueKey(String.valueOf(data.getId()));
- dto.setDataType("DI_OPER");
- dto.setMessage("数据已被(" + roleDO.getRoleName() + ")审核通过");
- examineLogService.save(dto);
- }
- } else if ("4".equalsIgnoreCase(data.getDataStatus()) && effect > 0) {
- GyDataImportDTO gyDataImportDTO = get(data.getId());
- RoleDO roleDO = roleService.get(gyDataImportDTO.getRoleId());
- if (roleDO != null) {
- ExamineLogDTO dto = new ExamineLogDTO();
- dto.setUniqueKey(String.valueOf(data.getId()));
- dto.setDataType("DI_OPER");
- dto.setMessage("数据已被(" + roleDO.getRoleName() + ")审核驳回, 请核对");
- examineLogService.save(dto);
- }
- }
- }
- @Override
- public void addExpertOpinion(ExpertOpinionDO expertOpinionDO){
- GyDataImportDTO gyDataImportDTO = get(expertOpinionDO.getId());
- RoleDO roleDO = roleService.get(gyDataImportDTO.getRoleId());
- if (roleDO != null) {
- ExamineLogDTO dto = new ExamineLogDTO();
- dto.setUniqueKey(String.valueOf(expertOpinionDO.getId()));
- dto.setDataType("DI_OPER");
- dto.setMessage(roleDO.getRoleName() + "的专家意见为: " + expertOpinionDO.getOpinion());
- examineLogService.save(dto);
- }
- }
- @Override
- public void batchRemove(Long[] ids) {
- gyDataDao.batchRemove(ids);
- }
- @Override
- public List<GyDataImportDTO> listRecover(Map<String, Object> map) {
- UserDO currUser = ShiroUtils.getUser();
- log.info("currUser:" + currUser.toString());
- if (!managerValue.contains(currUser.getDeptId().toString())) {
- String province = currUser.getProvince();
- if(StringUtils.isEmpty(province)){
- province = sysProvince;
- }
- map.put("unitProvince", province);
- String city = currUser.getCity();
- if(StringUtils.isEmpty(city)){
- city = sysCity;
- }
- map.put("unitCity", city);
- if(!ObjectUtils.isEmpty(city)){
- map.put("auditStage", "1");
- } else {
- map.put("auditStage", "2");
- }
- }
- return gyDataDao.listRecover(map);
- }
- @Override
- public int countRecover(Map<String, Object> map) {
- UserDO currUser = ShiroUtils.getUser();
- log.info("currUser:" + currUser.toString());
- if (!managerValue.contains(currUser.getDeptId().toString())) {
- String province = currUser.getProvince();
- if(StringUtils.isEmpty(province)){
- province = sysProvince;
- }
- map.put("unitProvince", province);
- String city = currUser.getCity();
- if(StringUtils.isEmpty(city)){
- city = sysCity;
- }
- map.put("unitCity", city);
- if(!ObjectUtils.isEmpty(city)){
- map.put("auditStage", "1");
- } else {
- map.put("auditStage", "2");
- }
- }
- return gyDataDao.countRecover(map);
- }
- @Override
- public int recover(Long id) {
- GyDataImportDTO gyDataImportDTO = gyDataDao.getRecoverUnit(id);
- Map<String, Object> params = new HashMap<>();
- params.put("dataName", gyDataImportDTO.getDataName());// 数据名称
- params.put("gyUnitId", gyDataImportDTO.getGyUnitId());// 单位
- params.put("neqDataStatus", "4");
- List<GyDataImportDTO> listInfo = gyDataDao.list(params);
- if (listInfo !=null && listInfo.size()>0) {
- // 存在非驳回数据,不允许恢复
- return 0;
- }
- if ("1".equals(gyDataImportDTO.getStatus())) {
- unitService.updateUnitByCreditCode(gyDataImportDTO.getGyUnitId());
- }
- String auditStage =null;
- if("1".equals(deployType)){ //市级单独部署
- auditStage = "1";
- } else if("2".equals(deployType)){ //省级单独部署
- auditStage = "2";
- } else if("3".equals(deployType)){ //省市一体部署
- auditStage = "1";
- }
- return gyDataDao.recover(id, auditStage);
- }
- @Override
- public int batchPhysicalDeletion(Long id) {
- Long[] longArray = new Long[]{id};
- return gyDataDao.batchPhysicalDeletion(longArray);
- }
- @Override
- public void encryptExports(HttpServletResponse responses, String idValue) throws Exception {
- List<GyDataExcelDO> list = new ArrayList<>();
- JSONArray json = (JSONArray)JSONArray.parse(idValue);
- for (int i = 0; i < json.size(); i++) {
- String id = String.valueOf(json.get(i));
- log.info("批量导出 id:" + json.get(i));
- GyDataExcelDO data = new GyDataExcelDO();
- data = gyDataDao.getDataExcel(Long.parseLong(id));
- data.setNo(i + 1); //序号
- list.add(data);
- }
- log.info("list size:" + list.size());
- String decFile = bootdoConfig.getUploadPath() + "数据目录备案导出信息.xlsx";
- String encFile = bootdoConfig.getUploadPath() + "数据目录备案加密导出信息.xlsx";
- ExcelUtils.encryptExport(responses, EncryptExcelDO.class,list,bootdoConfig.getCrtPrival(),decFile,encFile);
- }
- /**
- * @Description: MultipartFile转file
- * @Author: wangp
- * @Date: 2022/2/25 9:15
- * @param multiFile
- * @param fileName
- * @Return: File
- */
- public static File MultipartFileToFile(MultipartFile multiFile, String fileName) {
- // 获取文件后缀
- String prefix = fileName.substring(fileName.lastIndexOf("."));
- log.info("fileName:" + fileName + ",prefix:" + prefix);
- // 若须要防止生成的临时文件重复,能够在文件名后添加随机码
- try {
- File file = new File(fileName);
- boolean res = file.createNewFile();
- if (!res) {
- log.info("创建失败!");
- } else {
- multiFile.transferTo(file);
- file.setExecutable(true);// 设置可执行权限
- file.setReadable(true);// 设置可读权限
- file.setWritable(true);// 设置可写权限
- }
- return file;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- public static void main(String[] args) {
- FileCryptTool.encryptFile("F:/dev-dys/sm2/sm2_client_enc_cert.crt", "F:/dev-dys/res/测试导入-河南.xlsx",
- "F:/dev-dys/res/enc-测试导入加密文件-河南.xlsx");
- FileCryptTool.encryptFile("F:/dev-dys/sm2/sm2_client_enc_cert.crt", "F:/dev-dys/res/测试导入-河北.xlsx",
- "F:/dev-dys/res/enc-测试导入加密文件-河北.xlsx");
- FileCryptTool.encryptFile("F:/dev-dys/sm2/sm2_client_enc_cert.crt", "F:/dev-dys/res/测试导入-四川.xlsx",
- "F:/dev-dys/res/enc-测试导入加密文件-四川.xlsx");
- }
- }
|