Commit c41d2718 authored by wangqiang's avatar wangqiang

ExtPlanController:业务代码迁入(2.x版本->4.1版本)--暂时还未编译通过

parent 91afe366
package com.yonde.dcs.plan.common.constants;
/**
* @author xfchai
* @ClassName Constants.java
* @Description 通用常量信息
* @createTime 2021/09/02 11:30:00
*/
public class Constants {
/**
* 主内容
*/
public static final String MASTER_FILE = "MASTER_FILE";
/**
* 附件
*/
public static final String ATTACH_FILE = "ATTACH_FILE";
/**
* PDF附件
*/
public static final String PDF_FILE = "DOC_PDF_FILE";
/**
* minio桶名称
*/
public static final String BUCKET_NAME = "pdm";
/**
* 产品代号申请单(根据书签名替换为文字和图片)-附件类型
* docx的类型为:application/vnd.openxmlformats-officedocument.wordprocessingml.document
* doc的类型为:application/msword
*/
public static final String CONTENT_TYPE_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
public static final String CONTENT_TYPE_DOC = "application/msword";
/**
* AD数据导入(pdf数据)-附件类型
*/
public static final String CONTENT_TYPE_PDF = "application/pdf";
/**
* 上传图纸的ContentType
*/
public static final String CONTENT_TYPE_DWG = "application/x-dwg";
/**
* 导出excel
*/
public static final String EXCEL_TYPE = "application/vnd.ms-excel;charset=utf-8";
/**
* 下载压缩包
*/
public static final String DOWNLOAD_TYPE = "application/x-msdownload";
/**
* zip类型
*/
public static final String DOWNLOAD_ZIP_TYPE = "application/x-download";
/**
* 计划模板名称
*/
public static final String TEMPLATE_NAME = "PlanTemplate.xlsx";
/**
* 生成的 word名字和路径
*/
public static final String FILE_PATH = "resource/template/templateDoc.doc";
/**
* 合并后生成的 word名字和路径
*/
public static final String MERGER_FILE_PATH = "resource/template/mergeDoc.doc";
/**
* 合并后生成的 word名称
*/
public static final String MERGER_FILE_NAME = "mergeDoc.doc";
/**
* 合并后生成pdf名称
*/
public static final String MERGER_PDF_FILE_NAME = "mergeDoc.pdf";
/**
* 合并前存放文档目录
*/
public static final String MERGER_SOURCE = "source";
/**
* 合并生成后存放文档目录
*/
public static final String MERGER_TARGET = "target";
/**
* 签名文件存放目录
*/
public static final String MERGER_SIGN = "sign";
/**
* 合并后生成的 word-绝对路径
*/
public static final String MERGER_FILE_ABSOLUTE_PATH = "D:\\InetService\\resource\\template\\words\\";
/**
* 模板的路径
*/
public static final String MTEMPLATE_ABSOLUTE_PATH = "D:\\InetService\\resource\\template\\";
/**
* 生成多个合并前的模板路径
*/
public static final String BEFORE_MERGER_PATH = "resource/template/words/";
/**
* 生成多个合并前的模板路径
*/
public static final String JD_BEFORE_MERGER_PATH = "D:/InetService/resource/template/words/";
/**
* 模板路径
*/
public static final String TEMPLATE_PATH = "resource/template/";
/**
* 生成的 word名字和路径
*/
public static final String TEMPLATE_DOC = "templateDoc.doc";
/**
* 生成的pdf名字和路径
*/
public static final String PDF_FILE_PATH = "resource/template/templatePdf.pdf";
/**
* 待审阅
*/
public static final String PENDING_REVIEW = "pendingReview";
/**
* 修改中
*/
public static final String REVISING = "revising";
/**
* 提资待审阅
*/
public static final String RAIS_PEND_REVIEW = "raisPendReview";
/**
* 审阅中
*/
public static final String REVIEWING = "Reviewing";
/**
* 提资中
*/
public static final String CAPITAL_RAISING = "capitalRaising";
/**
* 已发放
*/
public static final String RELEASED = "released";
/**
* 驳回
*/
public static final String REJECT = "reject";
/**
* 已发布
*/
public static final String PBULISHED = "published";
/**
* 已过时
*/
public static final String OBSOLETE = "obsolete";
/**
* 打开
*/
public static final String OPENED = "Opened";
/**
* 未打开
*/
public static final String NOT_OPEN = "NotOpen";
/**
* 关闭
*/
public static final String CLOSE = "Close";
/**
* 已完成
*/
public static final String COMPLETED = "completed";
/**
* 未完成
*/
public static final String UNFINISHED = "unfinished";
/**
* 上下文-项目
*/
public static final String CONTEXT_PROJECT = "DxContextProject";
/**
* 上下文-公共库
*/
public static final String CONTEXT_LIBRARY = "DxContextLibrary";
/**
* 技术文件
*/
public static final String TECHNICAL_FILE = "TechnicalFile";
/**
* 质保程序文件
*/
public static final String QAP_DOC = "QAPDoc";
/**
* 设计图纸
*/
public static final String DESIGN_DRAWINGS = "DesignDrawings";
/**
* 设计图纸-原理图
*/
public static final String PRINCIPLE_DRAWINGS = "PrincipleDrawing";
/**
* 设计图纸-总装部件图
*/
public static final String ASSEMBLY_PARTS_DRAWINGS = "AssemblyPartsDiagram";
/**
* 设计图纸-布置图
*/
public static final String LAYOUT_DRAWINGS = "LayoutDrawings";
/**
* 设计图纸-零件图
*/
public static final String PART_DRAWINGS = "PartDrawing";
/**
* 更改单
*/
public static final String CHANGE_ORDER = "ChangeOrder";
/**
* 设计图册
*/
public static final String DESIGN_ATLAS = "DesignAtlas";
/**
* 安装图册
*/
public static final String INSTALL_ATLAS = "InstallAtlas";
/***
* 工艺文件
*/
public static final String CRAFT_DOC = "craftDoc";
/**
* 评审会资料
*/
public static final String METTING_MATERIALS = "MeetingMaterials";
/**
* 内部接口
*/
public static final String INTERNAL_INTERFACE = "InternalInterface";
/**
* 技术联系单
*/
public static final String CONTACTLIST = "ContactList";
/**
* 工作联系单
*/
public static final String WORK_CONTACTLIST = "WorkContactList";
/**
* 设计变更
*/
public static final String DESIGN_CHANGE = "DesignChange";
/**
* 过时文件
*/
public static final String OUTDATED_NOTIFY = "OutdatedDocNotify";
/**
* 设计文件需求申请表
*/
public static final String DESIGN_APPLICATION = "DesignDocApplicat";
/**
* 设计输入资料表
*/
public static final String DESIGN_ENTER = "DesignEnter";
/**
* 不符合项处理单
*/
public static final String NCR = "NCR";
/**
* 设计澄清单
*/
public static final String DEN = "DEN";
/**
* 上下文启用状态
*/
public static final String CONTEXT_ENABLE = "context-enable";
/**
* 上下文作废状态
*/
public static final String CONTEXT_CANCEL = "context-cancel";
/**
* 上下文停用状态
*/
public static final String CONTEXT_DISABLE = "context-disable";
/**
* 批量下载文件路径
*/
public static final String DOWLOAD_FILE_PATH = "D:\\bathDocFile";
/**
* 将bathDocFile目录下的所有文件目录打包到d:/bathDocFile.zip
*/
public static final String BATH_FILE_PATH = "D:/bathDocFile";
/**
* 未开启
*/
public static final String PLAN_STATE_UNOPENED = "unopened";
/**
* 全局状态
*/
public static final String GLOBAL_STATE = "globalState";
/**
* 内部接口流程一
*/
public static final String INTERFACE_WF_ONE = "InterFaceWF";
/**
* 内部接口流程二
*/
public static final String INTERFACE_WF_TWO = "InterfaceWFTwo";
/**
* 分发类型
*/
public static final String DistributeType_Paper = "discussionPaper";
/**
* 联系单分发类型
*/
public static final String DistributeType_Doc = "techContractDoc";
/**
* 名称
*/
public static final String BoTitle = "补充提资数据";
/**
* 补充设计输入资料
*/
public static final String BZSJSR = "接收设计输入单";
/**
* 项目代号字典type
*/
public static final String PROJECT_CODE = "ProjectCode";
/**
* 设计阶段字典type
*/
public static final String DESIGN_STAGE = "DesignStage";
/**
* 技术联系单类别字典type
*/
public static final String CATEGORY = "ContactListCategory";
/**
* 处理建议
*/
public static final String NCR_SUGGEST = "NCRSuggest";
/**
* NCR供方(字典换为外单位)
*/
public static final String NCR_SUPPLIER = "ExternalParties";
/**
* 密级字典
*/
public static final String SECRET_CODE = "SecretCode";
/**
* 载体类型字典
*/
public static final String CARRIER_TYPE = "CarrierType";
/**
* 修订说明字典
*/
public static final String REVISION_NOTE = "RevisionNote";
/**
* NCR分级
*/
public static final String NCR_GRADE_CLASSIFY = "GradeClassify";
/**
* 状态
*/
public static final String OBJ_STATUS = "ObjStatus";
/**
* (currentState)
* 状态 待澄清
*/
public static final String TO_CLARIFIED = "toClarified";
/**
* 状态 已澄清
*/
public static final String CLARIFIED = "clarified";
/**
* 状态 待更改
*/
public static final String TO_CHANGED = "toChanged";
/**
* 已更改
*/
public static final String CHANGED = "changed";
/**
* 已答复
*/
public static final String ANSWERED = "answered";
/**
* 技术联系单的内容附件
*/
public static final String CONTACT_CONTENT_ATTACH = "CONTACT_CONTENT_ATTACH";
/**
* 内部接口内容附件
*/
public static final String APP_CONTENT_ATTCH = "APP_CONTENT_ATTCH";
/**
* 内部技术联系单
*/
public static final String INTER_CONTACT = "InterContactList";
/**
* 外部技术联系单
*/
public static final String EXT_CONTACT = "ExtContactList";
}
package com.yonde.dcs.plan.common.utils;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
/**
* @author xfchai
* @ClassName ExcelUtils.java
* @Description 操作excel工具类
* @createTime 2021/09/06 09:38:00
*/
@Slf4j
public class ExcelUtils {
/**
* 通过名称读取Excel
*
* @param uploadFile
* @param sheetName
* @return
*/
public static ExcelReader excelUtil(MultipartFile uploadFile, String sheetName) {
try {
ExcelReader reader = ExcelUtil.getReader(uploadFile.getInputStream(), sheetName);
return reader;
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
/**
* 通过sheetIndex读取Excel
*
* @param uploadFile
* @param sheetIndex
* @return
*/
public static ExcelReader excelReader(MultipartFile uploadFile, int sheetIndex) {
try {
ExcelReader reader = ExcelUtil.getReader(uploadFile.getInputStream(), sheetIndex);
return reader;
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
}
package com.yonde.dcs.plan.common.utils;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import com.inet.pdm.constants.Constants;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.valut.handler.ContentHolder;
import com.yonde.dex.valut.vo.ObjFileLinkVO;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.io.MemoryUsageSetting;
import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author xfchai
* @ClassName MultipartFileToFile.java
* @Description MultipartFile转fie
* @createTime 2021/02/04 10:50:00
*/
@Slf4j
public class FileUtils {
/**
* MultipartFile转fie
*
* @param multipartFile
* @return
* @throws IOException
*/
public static File multipartFileToFile(MultipartFile multipartFile) throws IOException {
File file = null;
if (multipartFile.isEmpty()) {
file = null;
} else {
InputStream inputStream = multipartFile.getInputStream();
file = new File(multipartFile.getOriginalFilename());
inputStreamToFile(inputStream, file);
inputStream.close();
}
return file;
}
public static void inputStreamToFile(InputStream inputStream, File file) {
try {
OutputStream outputStream = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
inputStream.close();
} catch (Exception e) {
log.error(e.getMessage());
}
}
/**
* 删除本地的临时文件(单个文件)
*
* @param file
* @return
*/
public static boolean deleteFile(File file) {
boolean flag = false;
if (file.isFile() && file.exists()) {
flag = file.delete();
}
return flag;
}
/**
* 删除目录以及目录下的文件
*
* @param sPath :目录路径
* @return :是否删除成功
*/
public static boolean deleteDirectory(String sPath) {
if (!sPath.endsWith(File.separator)) {
sPath = sPath + File.separator;
}
File dirFile = new File(sPath);
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
File[] files = dirFile.listFiles();
if (files != null) {
for (File ff : files) {
if (ff.isFile()) {
flag = deleteFile(ff);
if (!flag) {
break;
}
} else {
flag = deleteDirectory(ff.getAbsolutePath());
if (!flag) {
break;
}
}
}
}
if (!flag) {
return false;
}
//删除当前目录
return dirFile.delete();
}
/**
* 删除目录下的文件
*
* @param sPath
* @return
*/
public static boolean deleteFilesInDirectory(String sPath) {
if (!sPath.endsWith(File.separator)) {
sPath = sPath + File.separator;
}
File dirFile = new File(sPath);
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
File[] files = dirFile.listFiles();
if (files != null) {
for (File ff : files) {
if (ff.isFile()) {
flag = deleteFile(ff);
if (!flag) {
break;
}
}
}
}
if (!flag) {
return false;
}
return true;
}
/**
* 根据路径删除指定目录和文件
*
* @param file
* @return
*/
public static boolean deleteFolder(File file) {
if (!file.exists()) {
return false;
} else {
if (file.isFile()) {
return deleteFile(file);
} else {
return deleteDirectory(file.getPath());
}
}
}
/**
* 图片转换为字节数组
*
* @param in
* @return
*/
public static byte[] imageToByte(InputStream in) {
try {
byte[] data = null;
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while ((rc = in.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
data = swapStream.toByteArray();
return data;
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
/**
* 将file转换为inputStream
*
* @param file
* @return
* @throws FileNotFoundException
*/
public static InputStream fileToInputStream(File file) throws FileNotFoundException {
return new FileInputStream(file);
}
/**
* 获取多个DWG文件
*
* @param dir
* @param fileList
* @return
*/
public static List<String> getAllFiles(File dir, List<String> fileList) {
File[] fs = dir.listFiles();
for (File f : fs) {
//否则就是文件
if (f.getName().endsWith("dwg")) {
fileList.add(f.getAbsolutePath());
}
}
return fileList;
}
/**
* base64转换为文件,放入文件目录
*
* @param base64
* @param name
*/
public static void base64ToFile(String base64, String name) {
File file = null;
//创建文件目录
String filePath = Constants.DOWLOAD_FILE_PATH;
File dir = new File(filePath);
if (!dir.exists() && !dir.isDirectory()) {
dir.mkdirs();
}
BufferedOutputStream bos = null;
FileOutputStream fos = null;
try {
byte[] bytes = Base64.getDecoder().decode(base64);
file = new File(filePath + "\\" + name);
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(bytes);
} catch (Exception e) {
log.error(e.getMessage());
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
log.error(e.getMessage());
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
log.error(e.getMessage());
}
}
}
}
/**
* 按时间戳生成word名称
*
* @return
*/
public static String generateWordFile(String beforeMergePath) {
//创建 StringBuffer 通过构造函数添加 文件路径
StringBuffer wordName = new StringBuffer(beforeMergePath);
//获得当前时间戳
Date currentTime = new Date();
//设置时间解析与格式化的形式
//注意:yyyyMMddHHmmss里面不能有 - : . 等
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
//通过append方法将字符串添加到 StringBuffer 对象中
wordName.append(formatter.format(currentTime));
//生成随机数(随机数范围:1000到10000)
int num = (int) (Math.random() * (10000 - 1000) + 1000);
//通过append()方法将字符串添加到 StringBuffer 对象中
wordName.append(num);
wordName.append(".docx");
return wordName.toString();
}
/**
* 合并word
*
* @param filePath Constants.MERGER_FILE_ABSOLUTE_PATH
*/
public static void mergeFile(String filePath, String savePath) {
//获取文件夹的所有文件--绝对路径
List<String> fileList = new ArrayList<>();
File[] files = FileUtil.ls(filePath);
if (files.length == 0 || files == null) {
log.error("文件夹下无文件,文件夹:{}" + filePath);
return;
}
List<File> collect = Arrays.stream(files).filter(item -> item.getAbsolutePath().endsWith(".docx")).sorted(Comparator.comparing(File::getAbsolutePath)).collect(Collectors.toList());
if (collect.size() == 0 || collect == null) {
return;
}
collect.stream().forEach(file -> {
fileList.add(file.getAbsolutePath());
});
if (fileList.size() == 0 || fileList == null) {
return;
}
//打开word、启动word
ActiveXComponent app = new ActiveXComponent("Word.Application");
try {
// 设置word不可见
app.setProperty("Visible", new Variant(false));
//获得documents对象
Object docs = app.getProperty("Documents").toDispatch();
//打开第一个文件
Object doc = Dispatch
.invoke(
(Dispatch) docs,
"Open",
Dispatch.Method,
new Object[]{(String) fileList.get(0),
new Variant(false), new Variant(true)},
new int[3]).toDispatch();
//追加文件
for (int i = 1; i < fileList.size(); i++) {
Dispatch.invoke(app.getProperty("Selection").toDispatch(),
"insertFile", Dispatch.Method, new Object[]{
(String) fileList.get(i), "",
new Variant(false), new Variant(false),
new Variant(false)}, new int[3]);
}
//保存新的word文件
Dispatch.invoke((Dispatch) doc, "SaveAs", Dispatch.Method,
new Object[]{savePath, new Variant(1)}, new int[3]);
Variant f = new Variant(false);
Dispatch.call((Dispatch) doc, "Close", f);
} catch (Exception e) {
log.error("合并word文件出错.原因:" + e.getMessage());
} finally {
app.invoke("Quit", new Variant[]{});
}
}
/**
* 合并pdf
*
* @param filePath
*/
public static void mergePdfFile(String filePath, String savePath) {
try {
//获取文件夹的所有文件--绝对路径
List<String> fileList = new ArrayList<>();
File[] files = FileUtil.ls(filePath);
if (files.length == 0 || files == null) {
log.error("文件夹下无文件,文件夹:{}" + filePath);
return;
}
List<File> collect = Arrays.stream(files).filter(item -> item.getAbsolutePath().endsWith(".pdf")).sorted(Comparator.comparing(File::getAbsolutePath)).collect(Collectors.toList());
if (collect.size() == 0 || collect == null) {
return;
}
collect.stream().forEach(file -> {
fileList.add(file.getAbsolutePath());
});
if (fileList.size() == 0 || fileList == null) {
return;
}
PDFMergerUtility mergePdf = new PDFMergerUtility();
List<InputStream> sourcesList = new ArrayList<InputStream>();
for (int i = 0; i < collect.size(); i++) {
File file = collect.get(i);
/*InputStream is = new FileInputStream(file);
//把文件添加到List中
sourcesList.add(is);*/
mergePdf.addSource(file);
}
//PDF 合并
//mergePdf.addSources(sourcesList);
mergePdf.setDestinationFileName(savePath);
mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
} catch (Exception e) {
log.error("合并pdf文件出错.原因:" + e.getMessage());
}
}
/**
* 下载文件流
*
* @param response
* @param inputData
* @throws IOException
*/
public static void downloadFile(HttpServletResponse response, InputStream inputData, DxDocumentVO doc) throws IOException {
//放到缓冲流里面
BufferedInputStream bins = new BufferedInputStream(inputData);
//获取文件输出IO流
OutputStream outs = response.getOutputStream();
BufferedOutputStream bouts = new BufferedOutputStream(outs);
response.setContentType(Constants.DOWNLOAD_ZIP_TYPE);
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(doc.getNumber() + "-" + doc.getName(), "UTF-8") + ".zip");
int bytesRead = 0;
byte[] buffer = new byte[8192];
//开始向网络传输文件流
while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
bouts.write(buffer, 0, bytesRead);
}
//调用flush()方法
bouts.flush();
inputData.close();
bins.close();
outs.close();
bouts.close();
}
/**
* 导出通用文件
*
* @param response
* @param fileInputStream
* @throws IOException
*/
public static void exportFile(HttpServletResponse response, FileInputStream fileInputStream, String exportType, String name) throws IOException {
//放到缓冲流里面
BufferedInputStream bins = new BufferedInputStream(fileInputStream);
//获取文件输出IO流
OutputStream outs = response.getOutputStream();
BufferedOutputStream bouts = new BufferedOutputStream(outs);
response.setContentType(exportType);
response.setCharacterEncoding("UTF-8");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-disposition", "attachment;filename=" + name);
int bytesRead = 0;
byte[] buffer = new byte[8192];
//开始向网络传输文件流
while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
bouts.write(buffer, 0, bytesRead);
}
//调用flush()方法
bouts.flush();
fileInputStream.close();
bins.close();
outs.close();
bouts.close();
}
/**
* 删除方法
*
* @param holder
* @param contentType
* @param <T>
*/
public static <T extends IdVO & ContentHolder> void removeFile(T holder, String contentType) {
if (!CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVos = (List) ((ContentHolder) holder).getObjFileLinks().stream().filter((m) -> {
return contentType.equalsIgnoreCase(m.getContentType());
}).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fileLinkVos)) {
Iterator var3 = fileLinkVos.iterator();
while (var3.hasNext()) {
ObjFileLinkVO linkVo = (ObjFileLinkVO) var3.next();
//判断是否重复
linkVo.setOperator(OperatorType.REMOVE);
}
}
}
}
/**
* 保存到本地临时文件夹
*
* @param inputStream
* @return
*/
@SneakyThrows
public static String saveToLocal(InputStream inputStream, String filePath) {
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(filePath);
IoUtil.copy(inputStream, outputStream);
} finally {
IoUtil.close(inputStream);
IoUtil.close(outputStream);
}
return filePath;
}
}
package com.yonde.dcs.plan.common.utils;
import lombok.extern.slf4j.Slf4j;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
/**
* @program: service
* @description: 外部资源配置类
* @author: dang wei
* @create: 2021-01-04 11:29
*/
@Slf4j
public class ResourceHelper {
/**
* 获取外部资源配置
* @return
*/
public static Properties getResource(){
Properties prop = new Properties();
try{
prop.load(new FileInputStream("resource/esignConfig.properties"));
}catch (FileNotFoundException e){
log.error("找不到配置资源文件:" + e.getMessage());
}catch (IOException e){
log.error("读取外部配置资源文件报错:" + e.getMessage());
}
return prop;
}
}
package com.yonde.dcs.plan.common.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author xfchai
* @ClassName ExtPlanEntity.java
* @Description 计划导入实体
* @createTime 2021/09/09 10:59:00
*/
@Data
public class PlanExcelVO implements Serializable {
/**
* 操作
*/
private String operate;
/**
* 计划名称
*/
private String name;
/**
* 计划编号
*/
private String number;
/**
* 父级计划编号
*/
private String superPlanCode;
/**
* 业务计划类型
*/
private String businessPlanType;
/**
* 反馈类型
*/
private String feedbackType;
/**
* 是否产生计划任务
*/
private String hasPlanTasks;
/**
* 合同编号
*/
private String contractNo;
/**
* 计划执行人
*/
private String planExecutor;
/**
* 工期
*/
private String constructPeriod;
/**
* 开始时间
*/
private Date startTime;
/**
* 完成时间
*/
private Date completeTime;
/**
* 文件分类
*/
private String fileType;
/**
* 文件名称
*/
private String fileName;
/**
* 文件编号
*/
private String fileNumber;
/**
* 文件代号
*/
private String fileCode;
/**
* 项目代号
*/
private String projectCode;
/**
* 管理信息系统编码
*/
private String systemCode;
/**
* 审核者
*/
private String review;
/**
* 批准者
*/
private String approver;
/**
* 审定者
*/
private String verifier;
/**
* 状态
*/
// private String state;
/**
* 阶段状态
*/
private String phaseState;
/**
* 计划级别
*/
private String planLevel;
/**
* 密级
*/
private String secretCode;
}
......@@ -3,6 +3,8 @@ package com.yonde.dcs.plan.core.controller;
import org.springframework.stereotype.Controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import java.io.IOException;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -13,7 +15,10 @@ import com.yonde.dcs.plan.core.service.ExtPlanService;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dcs.plan.core.controller.shadow.ExtPlanControllerShadow;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;
/**
* @description: ExtPlan-Controller
......@@ -27,6 +32,30 @@ import org.springframework.stereotype.Controller;
@Controller(ExtPlanController.BEAN_NAME)
public class ExtPlanController<V extends ExtPlanVO, S extends ExtPlanService<V>> extends ExtPlanControllerShadow<V, S> {
@Autowired
private ExtPlanService extPlanService;
@ApiOperation("下载计划模板")
@GetMapping(value = "/downloadTemplate")
public void downloadTemplate(HttpServletResponse response, @RequestParam(value = "name", required = false) String name) throws IOException {
extPlanService.downloadTemplate(response, name);
}
/**
* 新增计划
*
* @param uploadFile
* @return
* @throws IOException
*/
@ApiOperation("新增计划")
@PostMapping(value = "/insertPlan/{projectId}")
public ApiResult insertPlan(@RequestParam("file") MultipartFile uploadFile,
@PathVariable("projectId") Long projectId) throws IOException {
ApiResult apiResult = extPlanService.insertPlan(uploadFile, projectId);
return apiResult;
}
}
......
......@@ -2,8 +2,12 @@ package com.yonde.dcs.plan.core.service;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import com.yonde.dcs.plan.core.service.shadow.ExtPlanServiceShadow;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.user.common.vo.DxOrganizationVO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
......@@ -22,4 +26,21 @@ public interface ExtPlanService<V extends ExtPlanVO> extends ExtPlanServiceShado
*/
List<DxOrganizationVO> searchOrgNameByUserId(Long userId, String code);
/**
* 导出计划
*
* @param response
* @param name
*/
void downloadTemplate(HttpServletResponse response, String name) throws IOException;
/**
* 新增计划
*
* @param uploadFile
*/
ApiResult insertPlan(MultipartFile uploadFile, Long projectId);
}
package com.yonde.dcs.plan.core.service.impl;
import cn.hutool.poi.excel.ExcelReader;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.utils.ExcelUtils;
import com.yonde.dcs.plan.common.utils.FileUtils;
import com.yonde.dcs.plan.common.utils.ResourceHelper;
import com.yonde.dcs.plan.common.vo.PlanExcelVO;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.dao.service.util.DxPageUtils;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import com.yonde.dex.user.common.vo.DxOrganizationVO;
import dm.jdbc.util.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import io.swagger.annotations.ApiOperation;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.service.ExtPlanService;
import com.yonde.dcs.plan.core.repository.ExtPlanRepository;
import com.yonde.dcs.plan.entity.po.ExtPlan;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
* @description: ExtPlan-ServiceImpl
......@@ -35,6 +62,8 @@ public class ExtPlanServiceImpl<V extends ExtPlanVO> implements ExtPlanService<V
@Autowired
ExtPlanRepository<ExtPlan> extPlanRepository;
@Autowired
private DictDataFeignService dictDataService;
/**
* 通过userId获取组织名
......@@ -67,6 +96,493 @@ public class ExtPlanServiceImpl<V extends ExtPlanVO> implements ExtPlanService<V
return null;
}
/**
* 导出计划模板
*
* @param response
* @param name
*/
@Override
public void downloadTemplate(HttpServletResponse response, String name) throws IOException {
FileInputStream fileInputStream = null;
//获取外部资源配置
Properties prop = ResourceHelper.getResource();
//下载模板文件路径
String planTemplatePath = prop.getProperty("PlanTemplate");
fileInputStream = new FileInputStream(planTemplatePath);
// String fileName = new String("TEMPLATE(内部).xlsx".getBytes(), "ISO8859-1");
String fileName = URLEncoder.encode("TEMPLATE(内部).xlsx", "UTF-8");
FileUtils.exportFile(response, fileInputStream, Constants.EXCEL_TYPE, fileName);
// FileUtils.exportFile(response, fileInputStream, Constants.EXCEL_TYPE, "TEMPLATE(内部).xlsx");
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApiResult insertPlan(MultipartFile uploadFile, Long projectId) {
ApiResult apiResult = null;
// 上传文件名格式不正确
if (uploadFile.getName().lastIndexOf(".") != -1 && !".xlsx".equals(uploadFile.getName().substring(uploadFile.getName().lastIndexOf(".")))) {
throw new DxBusinessException("-1", "请上传excel文件!");
}
ExcelReader readerPlan = ExcelUtils.excelReader(uploadFile, 0);
//读取excel中所有数据(判断操作属性:新增、更改、删除)
if (!ObjectUtils.isEmpty(readerPlan)) {
//设置计划值
this.settingPlan(readerPlan);
List<PlanExcelVO> list = readerPlan.readAll(PlanExcelVO.class);
apiResult = this.importPlan(list, projectId);
}
return apiResult;
}
/**
* 导入计划(系统校验计划编号、计划名称、工期、计划开始时间、计划完成时间等必填项)
*
* @param
*/
public ApiResult importPlan(List<PlanExcelVO> list, Long projectId) {
List<PlanExcelVO> addPlans = new ArrayList<>();
List<PlanExcelVO> updatePlans = new ArrayList<>();
List<PlanExcelVO> removePlans = new ArrayList<>();
ApiResult apiResult = new ApiResult();
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
PlanExcelVO excelVO = list.get(i);
if (!StringUtils.isEmpty(excelVO.getOperate())) {
switch (excelVO.getOperate()) {
case "新增":
//先校验
stringBuffer = this.checkPlan(excelVO, i, stringBuffer, projectId);
//校验交付文件类的编号是否重复
stringBuffer = this.checkFileNumber(excelVO, i, stringBuffer);
addPlans.add(excelVO);
break;
case "更改":
//先校验
stringBuffer = this.checkPlan(excelVO, i, stringBuffer, projectId);
//校验未开启状态允许修改所有创建属性
stringBuffer = this.checkUpdatePlan(excelVO, i, stringBuffer);
updatePlans.add(excelVO);
break;
case "删除":
stringBuffer = this.checkPlanNumber(excelVO, i, stringBuffer);
removePlans.add(excelVO);
break;
default:
stringBuffer.append(String.format("第%s行,请填写正确的操作标识", i + 1) + "</br>");
}
}
}
if ((!StringUtils.isEmpty(stringBuffer) && stringBuffer.length() > 0)) {
apiResult.setCode("500");
apiResult.setMessage(stringBuffer.toString());
return apiResult;
} else {
if (!CollectionUtils.isEmpty(addPlans)) {
//增加计划数据
this.savePlans(addPlans, projectId);
}
if (!CollectionUtils.isEmpty(updatePlans)) {
//更改计划数据
this.updatePlans(updatePlans);
}
if (!CollectionUtils.isEmpty(removePlans)) {
//删除计划数据
this.deletePlans(removePlans);
}
apiResult.setMessage("导入成功");
apiResult.setCode("0");
return apiResult;
}
}
public void savePlans(List<PlanExcelVO> addPlans, Long projectId) {
//新增导入成功后,创建计划对象,状态置为:未开启
addPlans.stream().forEach(x -> {
//过滤掉已存在的编码计划
//查询编码是否存在
ExtPlanVO extPlanVOByNumber = this.searchByNumber(x.getNumber());
if (ObjectUtils.isEmpty(extPlanVOByNumber)) {
ExtPlanVO extPlanVO = this.copyPlan(x, OperatorType.ADD);
//工期=完成时间-开始时间
// int dayDiffer = DateUtils.getDayDiffer(extPlanVO.getStartTime(), extPlanVO.getCompleteTime());
// extPlanVO.setConstructPeriod(String.valueOf(dayDiffer) + "天");
extPlanVO.setState(Constants.PLAN_STATE_UNOPENED);
//todo wq:setDxContextId暂时注释,在2.0中DxContextId 属性在DxObjectVo类中,但在4.1中未找到
//extPlanVO.setDxContextId(projectId);
this.saveRecursion(extPlanVO);
}
});
}
/**
* 设置计划值
*/
private void settingPlan(ExcelReader reader) {
reader.addHeaderAlias("操作", "operate");
reader.addHeaderAlias("计划编号", "number");
reader.addHeaderAlias("计划级别", "planLevel");
reader.addHeaderAlias("计划名称", "name");
reader.addHeaderAlias("阶段状态", "phaseState");
reader.addHeaderAlias("业务计划类型", "businessPlanType");
reader.addHeaderAlias("反馈类型", "feedbackType");
reader.addHeaderAlias("是否产生计划任务", "hasPlanTasks");
reader.addHeaderAlias("合同编号", "contractNo");
reader.addHeaderAlias("计划执行人", "planExecutor");
reader.addHeaderAlias("父级计划编号", "superPlanCode");
reader.addHeaderAlias("工期", "constructPeriod");
reader.addHeaderAlias("开始时间", "startTime");
reader.addHeaderAlias("完成时间", "completeTime");
//文件分类
reader.addHeaderAlias("文件分类", "fileType");
reader.addHeaderAlias("文件名称", "fileName");
reader.addHeaderAlias("文件编号", "fileNumber");
reader.addHeaderAlias("文件代号", "fileCode");
reader.addHeaderAlias("项目代号", "projectCode");
reader.addHeaderAlias("管理信息系统编码", "systemCode");
reader.addHeaderAlias("审核者", "review");
reader.addHeaderAlias("批准者", "approver");
reader.addHeaderAlias("审定者", "verifier");
reader.addHeaderAlias("密级", "secretCode");
}
/**
* 统校验计划编号、计划名称、工期、计划开始时间、计划完成时间等必填项
*
* @param excelVO
*/
private StringBuffer checkPlan(PlanExcelVO excelVO, int i, StringBuffer buffer, long projectId) {
//校验
this.checkPlanNumber(excelVO, i, buffer);
if (StringUtils.isEmpty(excelVO.getName())) {
buffer.append(String.format("第%s行的计划名称为空", i + 1) + "</br>");
}
if (StringUtils.isEmpty(excelVO.getStartTime())) {
buffer.append(String.format("第%s行,请填写正确的计划开始时间的日期格式", i + 1) + "</br>");
}
if (StringUtils.isEmpty(excelVO.getCompleteTime())) {
buffer.append(String.format("第%s行,请填写正确的计划完成时间的日期格式", i + 1) + "</br>");
}
// if (StringUtils.isEmpty(excelVO.getConstructPeriod())) {
// buffer.append(String.format("第%s行的计划计划工期为空", i + 1) + "</br>");
// }
if ("交付文件类".equals(excelVO.getFeedbackType())) {
//交付文件类属于技术文件,校验阶段属性不能为空
String fileType = excelVO.getFileType();
if (!StringUtils.isEmpty(fileType)) {
String[] split = fileType.split("/");
String s = split[0];
if ("技术文件".equals(s) && StringUtils.isEmpty(excelVO.getPhaseState())) {
buffer.append(String.format("第%s行的计划交付文件类的阶段为空", i + 1) + "</br>");
}
} else {
buffer.append(String.format("第%s行的文件分类为空", i + 1) + "</br>");
}
//判断字典值
String projectCode = excelVO.getProjectCode();
String dictKey = this.searchDictDataByDictCode(Constants.PROJECT_CODE, projectCode);
if (StringUtils.isEmpty(dictKey)) {
buffer.append(String.format("第%s行的交付文件类的项目代号不存在!", i + 1) + "</br>");
}
}
// 密级校验
String secretCode = excelVO.getSecretCode();
String secretCodeKey = this.searchDictDataByDictCode(Constants.SECRET_CODE, secretCode);
if (StringUtils.isEmpty(secretCodeKey)) {
buffer.append(String.format("第%s行密级格式不正确!", i + 1) + "</br>");
}
return buffer;
}
/**
* 校验计划编号
*
* @param excelVO
*/
private StringBuffer checkPlanNumber(PlanExcelVO excelVO, int i, StringBuffer buffer) {
if (StringUtils.isEmpty(excelVO.getNumber())) {
buffer.append(String.format("第%s行的计划编号为空", i + 1) + "</br>");
}
return buffer;
}
/**
* 查询字典
*
* @param dictCode
* @param dictKey
* @return
*/
public String searchDictDataByDictCode(String dictCode, String dictKey) {
if (!StringUtils.isEmpty(dictKey)) {
//字典type 项目代号 ProjectCode
//todo wq:暂时返回null
//List<DictDataVO> dictDatasByDictCode = dictDataService.getDictDatasByDictCode(dictCode);
List<DictDataVO> dictDatasByDictCode = null;
if (CollectionUtils.isEmpty(dictDatasByDictCode)) {
return "";
} else {
for (DictDataVO dictDataVO : dictDatasByDictCode) {
if (dictKey.equals(dictDataVO.getDictKey())) {
return dictDataVO.getDictValue();
}
}
return "";
}
}
return "";
}
/**
* 一般技术文件
* 修改计划
*
* @param updatePlans
* @return
*/
public void updatePlans(List<PlanExcelVO> updatePlans) {
List<ExtPlanVO> checkInList = new ArrayList<>();
updatePlans.stream().forEach(x -> {
//通过number查询计划
ExtPlanVO extPlanVO = this.searchByNumber(x.getNumber());
if (!ObjectUtils.isEmpty(extPlanVO)) {
checkInList.add(doCheckOut(extPlanVO, x));
}
});
this.batchCheckIn(checkInList);
}
/**
* 通过number查询计划
*
* @param number
*/
private ExtPlanVO searchByNumber(String number) {
//通过number查询id
SearchQueryCondition query = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("sourcePlanDocLink").openProp(SearchQueryCondition.builder().name("target").build()).build())
.searchItems(SearchItems.builder().item(
new SearchItem("number", SearchItem.Operator.EQ, number, null))
.item(new SearchItem("latest", SearchItem.Operator.EQ, true, null))
.operator(SearchItems.BooleanOperator.AND).build()).build();
DxPageImpl<V> recursion = this.findRecursion(query);
if (CollectionUtils.isEmpty(recursion.getContent())) {
return null;
}
return DxPageUtils.getFirst(recursion);
}
// @Transactional
public ExtPlanVO doCheckOut(ExtPlanVO extPlanVO, PlanExcelVO planExcelVO) {
//检出后保存
ExtPlanVO checkout = this.checkOutAndEditByOriginalId(extPlanVO.getId());
//设置Excel的值
BeanUtils.copyProperties(planExcelVO, checkout);
checkout.setOperator(OperatorType.MODIFY);
ExtPlanVO planVO = this.saveRecursion(checkout);
return planVO;
}
/**
* 校验交付文件类的编号是否重复
*
* @param excelVO
* @param i
* @param stringBuffer
* @return
*/
private StringBuffer checkFileNumber(PlanExcelVO excelVO, int i, StringBuffer stringBuffer) {
if ("交付文件类".equals(excelVO.getFeedbackType())) {
//fileNumber可能会已存在,校验编号重复问题
DxDocumentVO searchDocByNumber = this.searchDocByNumber(excelVO.getFileNumber());
if (!ObjectUtils.isEmpty(searchDocByNumber)) {
stringBuffer.append(String.format("文档的文件编号%s已存在,请检查计划文件编号!", excelVO.getFileNumber()));
}
}
return stringBuffer;
}
/**
* 通过number查询文档
*
* @param number
*/
private DxDocumentVO searchDocByNumber(String number) {
//通过number查询id
SearchQueryCondition query = SearchQueryCondition.builder()
.searchItems(SearchItems.builder().item(
new SearchItem("number", SearchItem.Operator.EQ, number, null))
.operator(SearchItems.BooleanOperator.AND).build()).build();
//todo wq:在4.1中未找到 DocumentService,暂时返回null
//DxPageImpl<DxDocumentVO> recursion = documentService.findRecursion(query);
DxPageImpl<DxDocumentVO> recursion = null;
if (org.springframework.util.CollectionUtils.isEmpty(recursion.getContent())) {
return null;
}
return DxPageUtils.getFirst(recursion);
}
/**
* 校验未开启状态允许修改所有创建属性
*
* @param excelVO
* @param i
* @param stringBuffer
* @return
*/
private StringBuffer checkUpdatePlan(PlanExcelVO excelVO, int i, StringBuffer stringBuffer) {
ExtPlanVO extPlanVO = this.searchByNumber(excelVO.getNumber());
if (!ObjectUtils.isEmpty(extPlanVO)) {
switch (extPlanVO.getState()) {
//未完成
case Constants.UNFINISHED:
if ("交付文件类".equals(extPlanVO.getFeedbackType()) && !CollectionUtils.isEmpty(extPlanVO.getSourcePlanDocLink())) {
for (PlanDocLinkVO planDocLink : extPlanVO.getSourcePlanDocLink()) {
if (!ObjectUtils.isEmpty(planDocLink.getTarget())) {
if (!extPlanVO.getNumber().equals(excelVO.getNumber())) {
stringBuffer.append(String.format("第%s行的计划编号不允许修改", i + 1) + "</br>");
}
if (!extPlanVO.getName().equals(excelVO.getName())) {
stringBuffer.append(String.format("第%s行的计划名称不允许修改", i + 1) + "</br>");
}
int compare = extPlanVO.getStartTime().compareTo(excelVO.getStartTime());
if (compare != 0) {
stringBuffer.append(String.format("第%s行的计划开始时间不允许修改", i + 1) + "</br>");
}
if (!extPlanVO.getFeedbackType().equals(excelVO.getFeedbackType())) {
stringBuffer.append(String.format("第%s行的计划反馈类型不允许修改", i + 1) + "</br>");
}
if (!extPlanVO.getPlanExecutor().equals(excelVO.getPlanExecutor())) {
stringBuffer.append(String.format("第%s行的计划执行人不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getFileType(), excelVO.getFileType())) {
stringBuffer.append(String.format("第%s行的计划交付文件类型不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getFileName(), excelVO.getFileName())) {
stringBuffer.append(String.format("第%s行的计划交付文件名称不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getFileNumber(), excelVO.getFileNumber())) {
stringBuffer.append(String.format("第%s行的计划交付文件编号不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getPhaseState(), excelVO.getPhaseState())) {
stringBuffer.append(String.format("第%s行的计划阶段状态不允许修改", i + 1) + "</br>");
}
DxDocumentVO doc = planDocLink.getTarget();
if (Constants.REVIEWING.equals(doc.getState())) {
if (!StringUtil.equals(extPlanVO.getBusinessPlanType(), excelVO.getBusinessPlanType())) {
stringBuffer.append(String.format("第%s行的计划业务计划类型不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getContractNo(), excelVO.getContractNo())) {
stringBuffer.append(String.format("第%s行的计划合同编号不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getSuperPlanCode(), excelVO.getSuperPlanCode())) {
stringBuffer.append(String.format("第%s行的计划父级计划编号不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getFileCode(), excelVO.getFileCode())) {
stringBuffer.append(String.format("第%s行的计划文件代号不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getProjectCode(), excelVO.getProjectCode())) {
stringBuffer.append(String.format("第%s行的计划项目代号不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getSystemCode(), excelVO.getSystemCode())) {
stringBuffer.append(String.format("第%s行的计划管理信息系统编码不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getReview(), excelVO.getReview())) {
stringBuffer.append(String.format("第%s行的计划审核者不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getApprover(), excelVO.getApprover())) {
stringBuffer.append(String.format("第%s行的计划批准者不允许修改", i + 1) + "</br>");
}
if (!StringUtil.equals(extPlanVO.getVerifier(), excelVO.getVerifier())) {
stringBuffer.append(String.format("第%s行的计划审定者不允许修改", i + 1) + "</br>");
}
}
}
}
}
break;
//已完成
case Constants.COMPLETED:
stringBuffer.append(String.format("第%s行的计划已完成,不允许修改", i + 1) + "</br>");
break;
}
}
return stringBuffer;
}
/**
* 删除计划
*
* @param removePlans
* @return
*/
public void deletePlans(List<PlanExcelVO> removePlans) {
List<Long> list = new ArrayList<>();
removePlans.stream().forEach(x -> {
String number = x.getNumber();
ExtPlanVO extPlanVO = this.searchByNumber(number);
if (!ObjectUtils.isEmpty(extPlanVO)) {
list.add(extPlanVO.getId());
}
});
if (!CollectionUtils.isEmpty(list)) {
list.stream().forEach(x -> {
DeleteWrap deleteWrap = new DeleteWrap();
deleteWrap.setDeleteId(x);
deleteWrap.setDeleteType(DeleteWrap.DeleteType.MASTER_ITERATION);
//删除
this.deleteObjByType(deleteWrap);
});
} else {
throw new DxBusinessException("-1", "删除的计划不存在!");
}
}
/**
* @param planExcelVO
* @return
*/
private ExtPlanVO copyPlan(PlanExcelVO planExcelVO, OperatorType operatorType) {
ExtPlanVO extPlanVO = new ExtPlanVO();
BeanUtils.copyProperties(planExcelVO, extPlanVO);
extPlanVO.setName(planExcelVO.getName());
extPlanVO.setNumber(planExcelVO.getNumber());
extPlanVO.setOperator(operatorType);
// 密级
extPlanVO.setSecretCode(planExcelVO.getSecretCode());
// 反馈类型
String feedbackType = extPlanVO.getFeedbackType();
switch (feedbackType) {
case "交付文件类":
extPlanVO.setSubTypeName("DeliveryFileClass");
break;
case "计划反馈类":
extPlanVO.setSubTypeName("PlanFeedback");
break;
case "无反馈类":
extPlanVO.setSubTypeName("NoFeedback");
break;
default:
extPlanVO.setSubTypeName("ExtPlan");
break;
}
return extPlanVO;
}
public void batchCheckIn(List<ExtPlanVO> planList) {
this.checkin((V) planList);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment