feat: 发起年度制修订标准化发起 模板下载导入
This commit is contained in:
+24
-24
@@ -4,24 +4,22 @@ import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.aspect.annotation.Translation;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.modules.activiti.process.esAnnualInit.entity.ProcessEsAnnualInit;
|
||||
|
||||
import com.jero.modules.activiti.process.esAnnualInit.service.ProcessEsAnnualInitService;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jero.common.system.base.controller.JeroController.*;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
@@ -40,21 +38,23 @@ public class ESAnnualInitController {
|
||||
* 导入模板下载
|
||||
*/
|
||||
@GetMapping("/templateDownload")
|
||||
@ApiOperation(value = "企标年度制修订标准化发起流程-模板下载", notes = "企标年度制修订标准化发起流程-模板下载",
|
||||
produces = "application/octet-stream")
|
||||
@AutoLog(value = "企标年度制修订标准化发起流程-模板下载")
|
||||
public ModelAndView templateDownload() {
|
||||
// AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
String title = "标准化发起导入模板";
|
||||
mv.addObject(FILE_NAME, title);
|
||||
mv.addObject(CLASS, ProcessEsAnnualInit.class);
|
||||
ExportParams exportParams = new ExportParams(title, title);
|
||||
// 导出xlsx
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
mv.addObject(PARAMS, exportParams);
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, new ArrayList<T>());
|
||||
return mv;
|
||||
@ApiOperation(value = "企标年度制修订标准化发起流程-导入模板下载", notes = "企标年度制修订标准化发起流程-导入模板下载"
|
||||
,produces = "application/octet-stream")
|
||||
@AutoLog(value = "企标年度制修订标准化发起流程-导入模板下载")
|
||||
public void templateDownload(HttpServletResponse response) {
|
||||
try {
|
||||
ClassPathResource resource = new ClassPathResource("excelTemplate/es-annual-init.xlsx");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=es-annual-init.xlsx");
|
||||
|
||||
try (InputStream in = resource.getInputStream(); OutputStream out = response.getOutputStream()) {
|
||||
IOUtils.copy(in, out);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
// 记录错误或执行其他处理
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-14
@@ -93,7 +93,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 制修订类型
|
||||
*/
|
||||
@Excel(name = "制修订类型", width = 15, orderNum = "1")
|
||||
@Excel(name = "*制修订类型", width = 15, orderNum = "1")
|
||||
@Dict(dicCode = "esp_revision_type")
|
||||
@ApiModelProperty(value = "制修订类型")
|
||||
private String projectType;
|
||||
@@ -114,14 +114,13 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 原企标名称
|
||||
*/
|
||||
@Excel(name = "原企标名称", width = 15, orderNum = "4")
|
||||
@ApiModelProperty(value = "原企标名称")
|
||||
private String originEnStandardName;
|
||||
|
||||
/**
|
||||
* 新企标名称
|
||||
*/
|
||||
@Excel(name = "新企标名称", width = 15, orderNum = "5")
|
||||
@Excel(name = "*新企标名称", width = 15, orderNum = "3")
|
||||
@ApiModelProperty(value = "新企标名称")
|
||||
private String newEnStandardName;
|
||||
|
||||
@@ -134,6 +133,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 企标体系
|
||||
*/
|
||||
@Excel(name = "*标准体系", width = 25, orderNum = "5")
|
||||
@Dict(dictTable = "laws_tree_node", dicCode = "id", dicText = "node_name")
|
||||
@ApiModelProperty(value = "企标体系")
|
||||
private String enStandardSystem;
|
||||
@@ -141,19 +141,23 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 企业标准代号
|
||||
*/
|
||||
@Excel(name = "企业标准代号", width = 15, orderNum = "7")
|
||||
@Excel(name = "企业标准代号", width = 15, orderNum = "6")
|
||||
@ApiModelProperty(value = "企业标准代号")
|
||||
private String enStandardCode;
|
||||
|
||||
/**
|
||||
* 企业名称代号
|
||||
*/
|
||||
@Excel(name = "企业名称代号", width = 15, orderNum = "7")
|
||||
@Dict(dicCode = "enterprise_name_code")
|
||||
@ApiModelProperty(value = "企业名称代号")
|
||||
private String enNameCode;
|
||||
|
||||
/**
|
||||
* 标准类别代号
|
||||
*/
|
||||
@Excel(name = "标准类别代号", width = 15, orderNum = "8")
|
||||
@Dict(dicCode = "standard_category_code")
|
||||
@ApiModelProperty(value = "标准类别代号")
|
||||
private String standardCategoryCode;
|
||||
|
||||
@@ -166,19 +170,23 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 标准类型
|
||||
*/
|
||||
@Excel(name = "*标准类型", width = 15, orderNum = "13")
|
||||
@Dict(dicCode = "esp_standard_type")
|
||||
@ApiModelProperty(value = "标准类型")
|
||||
private String standardType;
|
||||
|
||||
/**
|
||||
* 企标等级分类
|
||||
*/
|
||||
@Excel(name = "*标准等级分类", width = 15, orderNum = "14")
|
||||
@Dict(dicCode = "standard_grade_classify")
|
||||
@ApiModelProperty(value = "企标等级分类")
|
||||
private String enStandardClassification;
|
||||
|
||||
/**
|
||||
* 草稿计划完成日期
|
||||
*/
|
||||
@Excel(name = "草稿计划完成日期", width = 20, orderNum = "13")
|
||||
@Excel(name = "草稿计划完成日期", width = 20, orderNum = "17")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "草稿计划完成日期")
|
||||
@@ -187,7 +195,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 征求意见稿计划完成日期
|
||||
*/
|
||||
@Excel(name = "征求意见稿计划完成日期", width = 24, orderNum = "14")
|
||||
@Excel(name = "征求意见稿计划完成日期", width = 24, orderNum = "18")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "征求意见稿计划完成日期")
|
||||
@@ -196,7 +204,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 计划报批日期
|
||||
*/
|
||||
@Excel(name = "计划报批日期", width = 15, orderNum = "15")
|
||||
@Excel(name = "计划报批日期", width = 15, orderNum = "19")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "计划报批日期")
|
||||
@@ -223,7 +231,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 主起草人
|
||||
*/
|
||||
@Excel(name = "主起草人", width = 15, orderNum = "9")
|
||||
@Excel(name = "*主起草人", width = 15, orderNum = "10")
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "username")
|
||||
@ApiModelProperty(value = "主起草人")
|
||||
private String mainDraftingUser;
|
||||
@@ -231,7 +239,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 主起草单位
|
||||
*/
|
||||
@Excel(name = "主起草单位", width = 15, orderNum = "10")
|
||||
@Excel(name = "*主起草单位", width = 15, orderNum = "11")
|
||||
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
|
||||
@ApiModelProperty(value = "主起草单位")
|
||||
private String mainDraftingUnit;
|
||||
@@ -239,12 +247,12 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 主起草单位责任人
|
||||
*/
|
||||
@Excel(name = "主起草单位责任人", width = 20, orderNum = "11")
|
||||
@Excel(name = "*起草单位责任人", width = 20, orderNum = "12")
|
||||
@Dict(dicCode = "id", dictTable = "sys_user", dicText = "username")
|
||||
@ApiModelProperty(value = "主起草单位责任人")
|
||||
private String mainDraftingUnitResponsiblePerson;
|
||||
|
||||
@Excel(name = "标准推进人", width = 15, orderNum = "12")
|
||||
@Excel(name = "*标准推进人", width = 15, orderNum = "16")
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "username")
|
||||
@ApiModelProperty(value = "标准推进人")
|
||||
private String standardPromoter;
|
||||
@@ -280,7 +288,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 授权部门
|
||||
*/
|
||||
@Excel(name = "授权部门", width = 15, orderNum = "6")
|
||||
@Excel(name = "*授权部门", width = 15, orderNum = "4")
|
||||
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
|
||||
@ApiModelProperty(value = "授权部门")
|
||||
private String authDept;
|
||||
@@ -288,7 +296,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 配合单位
|
||||
*/
|
||||
@Excel(name = "配合单位", width = 15, orderNum = "8")
|
||||
@Excel(name = "*配合单位", width = 15, orderNum = "9")
|
||||
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
|
||||
@ApiModelProperty(value = "配合单位")
|
||||
private String cooperationUnit;
|
||||
@@ -296,7 +304,7 @@ public class ProcessEsAnnualInit implements Serializable {
|
||||
/**
|
||||
* 联络人
|
||||
*/
|
||||
@Excel(name = "联络人", width = 15, orderNum = "17")
|
||||
@Excel(name = "*联络人", width = 15, orderNum = "15")
|
||||
@ApiModelProperty(value = "联络人")
|
||||
private String contactUser;
|
||||
|
||||
|
||||
+35
-25
@@ -71,12 +71,14 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
|
||||
}
|
||||
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(1);
|
||||
params.setTitleRows(0);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
|
||||
try {
|
||||
List<ProcessEsAnnualInit> list = ExcelImportUtil.importExcel(file.getInputStream(), ProcessEsAnnualInit.class, params);
|
||||
list.remove(0);
|
||||
list.remove(0);
|
||||
if (list.isEmpty()) {
|
||||
errorMsgs.add("文件暂无数据,请检查后重试。");
|
||||
resultMap.put("msg", errorMsgs);
|
||||
@@ -161,6 +163,9 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
|
||||
ProcessEsAnnualInit plan = iterator.next();
|
||||
if (ExcelUtils.isEmptyRow(plan)) {
|
||||
iterator.remove();
|
||||
if (list.isEmpty()) {
|
||||
errorMsgs.add("文件暂无数据,请检查后重试。");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
plan.setSort(String.valueOf(i++));
|
||||
@@ -171,6 +176,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
|
||||
String mainDraftingUnitResponsiblePerson = plan.getMainDraftingUnitResponsiblePerson();
|
||||
String standardPromoter = plan.getStandardPromoter();
|
||||
String contactUser = plan.getContactUser();
|
||||
String standardSystem = plan.getEnStandardSystem();
|
||||
String standardType = plan.getStandardType();
|
||||
String enStandardClassification = plan.getEnStandardClassification();
|
||||
|
||||
@@ -187,6 +193,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
|
||||
errMsg.append(excelUtils.validMainDraftingUnit(mainDraftingUnit, listDict));
|
||||
errMsg.append(excelUtils.validMainDraftingUnitResponsiblePerson(mainDraftingUnitResponsiblePerson, listDict));
|
||||
errMsg.append(excelUtils.validStandardPromoter(standardPromoter, listDict));
|
||||
errMsg.append(excelUtils.validStandardSystem(standardSystem, listDict));
|
||||
errMsg.append(excelUtils.validContactUser(contactUser, listDict));
|
||||
errMsg.append(excelUtils.validStandardType(standardType, listDict));
|
||||
errMsg.append(excelUtils.validStandardClassification(enStandardClassification, listDict));
|
||||
@@ -199,6 +206,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
|
||||
}
|
||||
|
||||
private String validProjectType(ProcessEsAnnualInit plan, List<SysDictItemCore> listDict, List<LawsEnterpriseStandard> esList) {
|
||||
StringBuilder errMsg = new StringBuilder();
|
||||
String projectType = plan.getProjectType();
|
||||
String originEnStandardNo = plan.getProjectType();
|
||||
String newEnStandardName = plan.getNewEnStandardName();
|
||||
@@ -212,46 +220,48 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
|
||||
if (projectType.equals(ESPProjectType.MODIFY.getName())) {
|
||||
// 检查企标编号是否有效
|
||||
if (StrUtil.isBlank(originEnStandardNo)) {
|
||||
return "'原企标编号'不能为空。";
|
||||
}
|
||||
if (!esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()).contains(originEnStandardNo)) {
|
||||
return "'原企标编号'无效。";
|
||||
errMsg.append("'原企标编号'不能为空。");
|
||||
} else {
|
||||
if (!esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()).contains(originEnStandardNo)) {
|
||||
return "'原企标编号'无效。";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 制定校验三个代号
|
||||
String enStandardCode = plan.getProjectType();
|
||||
String enStandardCode = plan.getEnStandardCode();
|
||||
String enNameCode = plan.getEnNameCode();
|
||||
String standardCategoryCode = plan.getStandardCategoryCode();
|
||||
// 检查企标编号是否有效
|
||||
if (StrUtil.isBlank(originEnStandardNo)) {
|
||||
return "'企业标准代号'不能为空。";
|
||||
}
|
||||
// 检查企业标准代号
|
||||
if (!excelUtils.validDict("enterprise_standard_code", enStandardCode, null, null, true, listDict)) {
|
||||
return "'企业标准代号'无效。";
|
||||
errMsg.append("'企业标准代号'不能为空。");
|
||||
} else {
|
||||
// 检查企业标准代号
|
||||
if (!excelUtils.validDict("enterprise_standard_code", enStandardCode, null, null, true, listDict)) {
|
||||
errMsg.append("'企业标准代号'无效。");
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank(originEnStandardNo)) {
|
||||
return "'企业名称代号'不能为空。";
|
||||
}
|
||||
// 检查企业标准代号
|
||||
if (!excelUtils.validDict("enterprise_name_code", enNameCode, null, null, true, listDict)) {
|
||||
return "'企业名称代号'无效。";
|
||||
errMsg.append("'企业名称代号'不能为空。");
|
||||
} else {
|
||||
// 检查企业标准代号
|
||||
if (!excelUtils.validDict("enterprise_name_code", enNameCode, null, null, true, listDict)) {
|
||||
errMsg.append("'企业名称代号'无效。");
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank(originEnStandardNo)) {
|
||||
return "'标准类别代号'不能为空。";
|
||||
errMsg.append("'标准类别代号'不能为空。");
|
||||
} else {
|
||||
// 检查企业标准代号
|
||||
if (!excelUtils.validDict("standard_category_code", standardCategoryCode, null, null, true, listDict)) {
|
||||
errMsg.append("'标准类别代号'无效。");
|
||||
}
|
||||
}
|
||||
// 检查企业标准代号
|
||||
if (!excelUtils.validDict("standard_category_code", standardCategoryCode, null, null, true, listDict)) {
|
||||
return "'标准类别代号'无效。";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
if (newEnStandardName.length() > 50) {
|
||||
return "'新企标名称'过长(最多50字)。";
|
||||
errMsg.append("'新企标名称'过长(最多50字)。");
|
||||
}
|
||||
return "";
|
||||
return errMsg.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
@@ -247,6 +247,9 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
ProcessEsAnnualReport plan = iterator.next();
|
||||
if (ExcelUtils.isEmptyRow(plan)) {
|
||||
iterator.remove();
|
||||
if (list.isEmpty()) {
|
||||
errorMsgs.add("文件暂无数据,请检查后重试。");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
plan.setSort(String.valueOf(i++));
|
||||
|
||||
Reference in New Issue
Block a user