技术监督计划导入
This commit is contained in:
@@ -400,41 +400,44 @@ public class ExcelUtil {
|
|||||||
* @param pullDowns
|
* @param pullDowns
|
||||||
*/
|
*/
|
||||||
private static void setTopLevel(Workbook workbook, List<PullDown> pullDowns) {
|
private static void setTopLevel(Workbook workbook, List<PullDown> pullDowns) {
|
||||||
int num = 0;
|
if(CollUtil.isNotEmpty(pullDowns)){
|
||||||
for (PullDown pullDown : pullDowns) {
|
int num = 0;
|
||||||
if (!pullDown.getIsText()) {
|
for (PullDown pullDown : pullDowns) {
|
||||||
int sum = pullDown.getStrings().stream().mapToInt(String::length).sum();
|
if (!pullDown.getIsText()) {
|
||||||
if (sum == 0) {
|
int sum = pullDown.getStrings().stream().mapToInt(String::length).sum();
|
||||||
continue;
|
if (sum == 0) {
|
||||||
}
|
continue;
|
||||||
if (sum > 255) {
|
}
|
||||||
// 创建隐藏sheet
|
if (sum > 255) {
|
||||||
String hiddenSheetName = "hiddenSheetA";
|
// 创建隐藏sheet
|
||||||
if (num == 0) {
|
String hiddenSheetName = "hiddenSheetA";
|
||||||
workbook.createSheet(hiddenSheetName);
|
if (num == 0) {
|
||||||
}
|
workbook.createSheet(hiddenSheetName);
|
||||||
//false展示隐藏sheet ,true不展示隐藏sheet
|
}
|
||||||
workbook.setSheetHidden(workbook.getSheetIndex(workbook.getSheet(hiddenSheetName)), true);
|
//false展示隐藏sheet ,true不展示隐藏sheet
|
||||||
Sheet sheet = workbook.getSheet(hiddenSheetName);
|
workbook.setSheetHidden(workbook.getSheetIndex(workbook.getSheet(hiddenSheetName)), false);
|
||||||
if (num == 0) {
|
Sheet sheet = workbook.getSheet(hiddenSheetName);
|
||||||
//sheet.getLastRowNum无法区分 有一行和没有 所以这里先建一行
|
if (num == 0) {
|
||||||
sheet.createRow(0);
|
//sheet.getLastRowNum无法区分 有一行和没有 所以这里先建一行
|
||||||
}
|
sheet.createRow(0);
|
||||||
Row row; //创建数据行
|
}
|
||||||
sheet.setColumnWidth(num, 4000); //设置每列的列宽
|
Row row; //创建数据行
|
||||||
for (int j = 0; j < pullDown.getStrings().size(); j++) {
|
sheet.setColumnWidth(num, 4000); //设置每列的列宽
|
||||||
if (sheet.getLastRowNum() < j) {
|
for (int j = 0; j < pullDown.getStrings().size(); j++) {
|
||||||
row = sheet.createRow(j); //创建数据行
|
if (sheet.getLastRowNum() < j) {
|
||||||
} else {
|
row = sheet.createRow(j); //创建数据行
|
||||||
row = sheet.getRow(j);
|
} else {
|
||||||
}
|
row = sheet.getRow(j);
|
||||||
//设置对应单元格的值
|
}
|
||||||
row.createCell(num).setCellValue(pullDown.getStrings().get(j));
|
//设置对应单元格的值
|
||||||
}
|
row.createCell(num).setCellValue(pullDown.getStrings().get(j));
|
||||||
num++;
|
}
|
||||||
}
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ public enum SupervisionResponseEnum {
|
|||||||
NO_USER_REPORT_UPDATE("A00550","常态化干扰源用户管理信息更新失败,不存在该条信息"),
|
NO_USER_REPORT_UPDATE("A00550","常态化干扰源用户管理信息更新失败,不存在该条信息"),
|
||||||
NO_DEPT_POWER("A00550","不能操作非自己部门创建的任务"),
|
NO_DEPT_POWER("A00550","不能操作非自己部门创建的任务"),
|
||||||
IMPORT_DEV_ERROR("A00550","导入终端检测失败"),
|
IMPORT_DEV_ERROR("A00550","导入终端检测失败"),
|
||||||
|
IMPORT_PLAN_ERROR("A00550","导入技术监督计划失败"),
|
||||||
IMPORT_DEV_DATA_ERROR("A00550","终端数据为空"),
|
IMPORT_DEV_DATA_ERROR("A00550","终端数据为空"),
|
||||||
|
IMPORT_PLAN_DATA_ERROR("A00550","技术监督计划数据为空"),
|
||||||
DELETE_TO_BE_SUBMITTED("A00550","流程删除失败,只有待提交信息可删除!"),
|
DELETE_TO_BE_SUBMITTED("A00550","流程删除失败,只有待提交信息可删除!"),
|
||||||
EXISTENCE_OR_NOT("A00550","信息查询为空,请检查信息是否存在!"),
|
EXISTENCE_OR_NOT("A00550","信息查询为空,请检查信息是否存在!"),
|
||||||
NAME_EXISTS("A00550","名称重复"),
|
NAME_EXISTS("A00550","名称重复"),
|
||||||
|
|||||||
@@ -15,13 +15,17 @@ import com.njcn.supervision.service.survey.ISurveyPlanService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,5 +112,25 @@ public class SurveyPlanController extends BaseController {
|
|||||||
Boolean b = surveyPlanService.deleteSurveyPlan(supervisionId);
|
Boolean b = surveyPlanService.deleteSurveyPlan(supervisionId);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping(value = "/downloadPlanTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||||
|
@ApiOperation("下载技术监督计划模板")
|
||||||
|
public void downloadPlanTemplate() {
|
||||||
|
surveyPlanService.downloadPlanTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/importPlanData", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||||
|
@ApiOperation("批量导入技术监督计划")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||||
|
public HttpResult<String> importPlanData(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
||||||
|
String methodDescribe = getMethodDescribe("importDevData");
|
||||||
|
surveyPlanService.importPlanData(file, response);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import com.njcn.bpm.service.IBpmService;
|
|||||||
import com.njcn.supervision.pojo.param.survey.SurveyPlanParam;
|
import com.njcn.supervision.pojo.param.survey.SurveyPlanParam;
|
||||||
import com.njcn.supervision.pojo.po.survey.SurveyPlan;
|
import com.njcn.supervision.pojo.po.survey.SurveyPlan;
|
||||||
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
|
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,4 +32,8 @@ public interface ISurveyPlanService extends IBpmService<SurveyPlan> {
|
|||||||
SurveyPlanVO getVOById(String id);
|
SurveyPlanVO getVOById(String id);
|
||||||
|
|
||||||
Boolean deleteSurveyPlan(List<String> supervisionId);
|
Boolean deleteSurveyPlan(List<String> supervisionId);
|
||||||
|
|
||||||
|
void downloadPlanTemplate();
|
||||||
|
|
||||||
|
void importPlanData(MultipartFile file, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package com.njcn.supervision.service.survey.impl;
|
package com.njcn.supervision.service.survey.impl;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.text.StrPool;
|
import cn.hutool.core.text.StrPool;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@@ -20,13 +26,24 @@ import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
|||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.enums.common.DealStateEnum;
|
import com.njcn.common.pojo.enums.common.DealStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||||
|
import com.njcn.device.biz.pojo.dto.SubGetBase;
|
||||||
|
import com.njcn.device.biz.pojo.param.SubstationParam;
|
||||||
|
import com.njcn.device.pms.pojo.excel.PowerGenerationUserExcel;
|
||||||
|
import com.njcn.device.pms.utils.PubUtil;
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
|
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
|
||||||
|
import com.njcn.poi.excel.ExcelUtil;
|
||||||
|
import com.njcn.poi.excel.PullDown;
|
||||||
|
import com.njcn.poi.util.PoiUtil;
|
||||||
import com.njcn.supervision.enums.FlowStatusEnum;
|
import com.njcn.supervision.enums.FlowStatusEnum;
|
||||||
import com.njcn.supervision.enums.SupervisionKeyEnum;
|
import com.njcn.supervision.enums.SupervisionKeyEnum;
|
||||||
import com.njcn.supervision.enums.SupervisionResponseEnum;
|
import com.njcn.supervision.enums.SupervisionResponseEnum;
|
||||||
import com.njcn.supervision.mapper.survey.SurveyPlanMapper;
|
import com.njcn.supervision.mapper.survey.SurveyPlanMapper;
|
||||||
|
import com.njcn.supervision.pojo.dto.SupervisionDevMainReportExcel;
|
||||||
|
import com.njcn.supervision.pojo.dto.SupervisionPlanExcel;
|
||||||
import com.njcn.supervision.pojo.param.survey.SurveyPlanParam;
|
import com.njcn.supervision.pojo.param.survey.SurveyPlanParam;
|
||||||
|
import com.njcn.supervision.pojo.po.device.SupervisionDevMainReportPO;
|
||||||
import com.njcn.supervision.pojo.po.survey.SurveyPlan;
|
import com.njcn.supervision.pojo.po.survey.SurveyPlan;
|
||||||
import com.njcn.supervision.pojo.po.survey.SurveyTest;
|
import com.njcn.supervision.pojo.po.survey.SurveyTest;
|
||||||
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
|
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
|
||||||
@@ -35,18 +52,23 @@ import com.njcn.supervision.service.survey.ISurveyPlanService;
|
|||||||
import com.njcn.supervision.service.survey.ISurveyTestService;
|
import com.njcn.supervision.service.survey.ISurveyTestService;
|
||||||
import com.njcn.supervision.utils.InstanceUtil;
|
import com.njcn.supervision.utils.InstanceUtil;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.user.api.DeptFeignClient;
|
import com.njcn.user.api.DeptFeignClient;
|
||||||
|
import com.njcn.user.pojo.dto.DeptDTO;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -62,19 +84,16 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BpmProcessFeignClient bpmProcessFeignClient;
|
private BpmProcessFeignClient bpmProcessFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DeptFeignClient deptFeignClient;
|
private DeptFeignClient deptFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LineFeignClient lineFeignClient;
|
private LineFeignClient lineFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISurveyTestService surveyTestService;
|
private ISurveyTestService surveyTestService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DicDataFeignClient dicDataFeignClient;
|
private DicDataFeignClient dicDataFeignClient;
|
||||||
|
@Resource
|
||||||
|
private CommTerminalGeneralClient commterminalGeneralClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SurveyPlanVO> surveyPlanPage(SurveyPlanParam.SurveyPlanQueryParam surveyPlanQueryParam) {
|
public Page<SurveyPlanVO> surveyPlanPage(SurveyPlanParam.SurveyPlanQueryParam surveyPlanQueryParam) {
|
||||||
@@ -348,4 +367,202 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
|
|||||||
return this.update(new LambdaUpdateWrapper<SurveyPlan>().set(SurveyPlan::getState, DataStateEnum.DELETED.getCode())
|
return this.update(new LambdaUpdateWrapper<SurveyPlan>().set(SurveyPlan::getState, DataStateEnum.DELETED.getCode())
|
||||||
.in(SurveyPlan::getId, supervisionId));
|
.in(SurveyPlan::getId, supervisionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadPlanTemplate() {
|
||||||
|
ExportParams exportParams = new ExportParams("技术监督计划模板数据模板(带*字段均是必填,请严格按照模板标准填入数据)", "技术监督计划信息");
|
||||||
|
//所属供电公司
|
||||||
|
List<DeptDTO> depts = deptFeignClient.getDepSonDetailByDeptId("0d52f9f6e43ec0ee83013cd32da93f66").getData();
|
||||||
|
List<DictData> supType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData();
|
||||||
|
SubstationParam substationParam = new SubstationParam();
|
||||||
|
substationParam.setOrgIds(depts.stream().map(DeptDTO::getId).distinct().collect(Collectors.toList()));
|
||||||
|
List<SubGetBase> data = commterminalGeneralClient.tagOrIdGetSub(substationParam).getData();
|
||||||
|
|
||||||
|
List<PullDown> pullDowns = new ArrayList<>();
|
||||||
|
|
||||||
|
PullDown pullDown;
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(0);
|
||||||
|
pullDown.setLastCol(0);
|
||||||
|
pullDown.setStrings(depts.stream().map(DeptDTO::getName).distinct().collect(Collectors.toList()));
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(1);
|
||||||
|
pullDown.setLastCol(1);
|
||||||
|
pullDown.setIsText(true);
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(2);
|
||||||
|
pullDown.setLastCol(2);
|
||||||
|
pullDown.setStrings(supType.stream().map(DictData::getName).distinct().collect(Collectors.toList()));
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(3);
|
||||||
|
pullDown.setLastCol(3);
|
||||||
|
pullDown.setIsText(true);
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(4);
|
||||||
|
pullDown.setLastCol(4);
|
||||||
|
pullDown.setIsText(true);
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(5);
|
||||||
|
pullDown.setLastCol(5);
|
||||||
|
pullDown.setIsText(true);
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(6);
|
||||||
|
pullDown.setLastCol(6);
|
||||||
|
pullDown.setStrings(Stream.of("是", "否").collect(Collectors.toList()));
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(7);
|
||||||
|
pullDown.setLastCol(7);
|
||||||
|
pullDown.setStrings(data.stream().map(SubGetBase::getName).distinct().collect(Collectors.toList()));
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(8);
|
||||||
|
pullDown.setLastCol(8);
|
||||||
|
pullDown.setStrings(data.stream().map(SubGetBase::getName).distinct().collect(Collectors.toList()));
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
|
||||||
|
pullDown = new PullDown();
|
||||||
|
pullDown.setFirstCol(9);
|
||||||
|
pullDown.setLastCol(9);
|
||||||
|
pullDown.setStrings(data.stream().map(SubGetBase::getName).distinct().collect(Collectors.toList()));
|
||||||
|
pullDowns.add(pullDown);
|
||||||
|
ExcelUtil.exportExcelPullDown(exportParams, "技术监督计划模板.xlsx", pullDowns, SupervisionPlanExcel.class, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importPlanData(MultipartFile file, HttpServletResponse response) {
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
//表头
|
||||||
|
params.setHeadRows(1);
|
||||||
|
//标题
|
||||||
|
params.setTitleRows(1);
|
||||||
|
params.setNeedVerify(true);
|
||||||
|
params.setStartSheetIndex(0);
|
||||||
|
params.setSheetNum(1);
|
||||||
|
List<SupervisionPlanExcel> planExcels;
|
||||||
|
try {
|
||||||
|
planExcels = ExcelImportUtil.importExcel(file.getInputStream(), SupervisionPlanExcel.class, params);
|
||||||
|
|
||||||
|
//如果存在非法数据,将不合格的数据导出
|
||||||
|
// if (CollectionUtil.isEmpty(objectExcelImportResult.getList())) {
|
||||||
|
// throw new BusinessException(SupervisionResponseEnum.IMPORT_PLAN_DATA_ERROR);
|
||||||
|
// }
|
||||||
|
if (planExcels.size() > 1) {
|
||||||
|
throw new BusinessException(SupervisionResponseEnum.IMPORT_PLAN_DATA_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SupervisionPlanExcel.ExcelMsg> planMsgList = new ArrayList<>();
|
||||||
|
//各地市
|
||||||
|
List<DeptDTO> deptS = deptFeignClient.getDepSonDetailByDeptId(RequestUtil.getDeptIndex()).getData();
|
||||||
|
List<DictData> supType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData();
|
||||||
|
|
||||||
|
SubstationParam substationParam = new SubstationParam();
|
||||||
|
substationParam.setOrgIds(deptS.stream().map(DeptDTO::getId).distinct().collect(Collectors.toList()));
|
||||||
|
List<SubGetBase> data = commterminalGeneralClient.tagOrIdGetSub(substationParam).getData();
|
||||||
|
List<SurveyPlan> info = new ArrayList<>();
|
||||||
|
SurveyPlan po;
|
||||||
|
if (CollectionUtil.isNotEmpty(planExcels)) {
|
||||||
|
for (SupervisionPlanExcel planExcel : planExcels) {
|
||||||
|
po = new SurveyPlan();
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
if (StrUtil.isEmpty(planExcel.getDeptId())) {
|
||||||
|
msg.append("计划负责单位不能为空!");
|
||||||
|
} else {
|
||||||
|
List<String> DeptIds = deptS.stream().filter(x -> x.getName().equals(planExcel.getDeptId())).map(DeptDTO::getId).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(DeptIds)) {
|
||||||
|
msg.append("计划负责单位不存在!");
|
||||||
|
} else {
|
||||||
|
po.setDeptId(DeptIds.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<SubGetBase> subList = new ArrayList<>();
|
||||||
|
List<String> list = Arrays.asList(planExcel.getSubstation(), planExcel.getSubstation2(), planExcel.getSubstation3());
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
msg.append("关联电站不能为空!");
|
||||||
|
} else {
|
||||||
|
if ("1".equals(planExcel.getCustomSubstationFlag())) {
|
||||||
|
subList.addAll(data.stream().filter(x -> list.contains(x.getName())).collect(Collectors.toList()));
|
||||||
|
if (CollUtil.isEmpty(subList)) {
|
||||||
|
msg.append("关联电站不存在!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(planExcel.getSupvType())) {
|
||||||
|
msg.append("监督类型不能为空!");
|
||||||
|
} else {
|
||||||
|
String dicById = PubUtil.getDicById(planExcel.getSupvType(), supType);
|
||||||
|
if (StrUtil.isEmpty(dicById)) {
|
||||||
|
msg.append("监督类型不存在!");
|
||||||
|
} else {
|
||||||
|
po.setSupvType(dicById);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(planExcel.getSupvObjectName())) {
|
||||||
|
msg.append("监督对象名称不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DateTime startTime = DateUtil.parseDate(planExcel.getPlanStartTime());
|
||||||
|
DateTime endTime = DateUtil.parseDate(planExcel.getPlanEndTime());
|
||||||
|
po.setSupvObjectName(planExcel.getSupvObjectName());
|
||||||
|
po.setPlanStartTime(startTime.toLocalDateTime().toLocalDate());
|
||||||
|
po.setPlanEndTime(endTime.toLocalDateTime().toLocalDate());
|
||||||
|
if ("1".equals(planExcel.getCustomSubstationFlag())) {
|
||||||
|
List<String> subIds = subList.stream().map(SubGetBase::getId).collect(Collectors.toList());
|
||||||
|
po.setSubstation(String.join(",", subIds));
|
||||||
|
} else {
|
||||||
|
po.setSubstation(planExcel.getSubstation());
|
||||||
|
}
|
||||||
|
po.setCustomSubstationFlag(Integer.valueOf(planExcel.getCustomSubstationFlag()));
|
||||||
|
po.setSubstation(subList.get(0).getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
msg.append("计划时间格式有误!");
|
||||||
|
}
|
||||||
|
String string = msg.toString();
|
||||||
|
if (StrUtil.isNotBlank(string)) {
|
||||||
|
SupervisionPlanExcel.ExcelMsg excelMsg = new SupervisionPlanExcel.ExcelMsg();
|
||||||
|
BeanUtils.copyProperties(planExcel, excelMsg);
|
||||||
|
excelMsg.setMsg(string);
|
||||||
|
planMsgList.add(excelMsg);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
po.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||||
|
po.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
info.add(po);
|
||||||
|
// this.saveOrUpdate(po);
|
||||||
|
// SurveyPlan surveyPlan = this.baseMapper.selectById(po.getId());
|
||||||
|
// Map<String, Object> processInstanceVariables = new HashMap<>(16);
|
||||||
|
// BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||||
|
// bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.SURVEY_PLAN.getKey());
|
||||||
|
// bpmProcessInstanceCreateReqDTO.setBusinessKey(surveyPlan.getId());
|
||||||
|
// bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<>(16));
|
||||||
|
// bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables);
|
||||||
|
// String processInstanceId = bpmProcessFeignClient.createProcessInstance(surveyPlan.getCreateBy(), bpmProcessInstanceCreateReqDTO).getData();
|
||||||
|
// // 将工作流的编号,更新到流程单中
|
||||||
|
// surveyPlan.setProcessInstanceId(processInstanceId);
|
||||||
|
// this.baseMapper.updateById(surveyPlan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断有没有错误信息
|
||||||
|
if (CollectionUtil.isNotEmpty(planMsgList)) {
|
||||||
|
ExcelUtil.exportExcel("失败列表.xlsx", SupervisionDevMainReportExcel.ExcelMsg.class, planMsgList);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BusinessException(SupervisionResponseEnum.IMPORT_PLAN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user