行政执法台账导入导出功能优化

main
15036302109 8 months ago
parent f8419f24cc
commit ff310a4c25

@ -118,39 +118,16 @@ public class EhsLawEnforcementController extends BaseController {
* *
*/ */
@PostMapping("/importTemplate") @PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException { public void importTemplate(HttpServletResponse response) throws Exception {
List<EhsLawEnforcement> teamWorkerList = new ArrayList<>(); ExcelUtil<EhsLawEnforcement> util = new ExcelUtil<>(EhsLawEnforcement.class);
// 获取企业类别字典数据 util.importComboTemplateExcel(response, "行政公文台账信息批量导入模板");
List<SysDictData> enterpriseTypeData = dictTypeService.selectDictDataByType("enterprise_category");
String[] header =
{"单位名称#",
"地址#",
"负责人#",
"联系电话#",
"存在隐患#",
"是否是重大隐患(Y是,N否)#",
"整改措施#",
"整改责任人#",
"企业类别(输入1,2,3..参考企业类别信息sheet)#",
"企业人数#",
"是否建立双预防(Y是,N否)#",
"时间(格式为2023-12-12)#",
"其他#",
"备注#"};
ExcelExp e1 = new ExcelExp("行政公文台账信息", header, teamWorkerList, EhsLawEnforcement.class);
header = new String[]{"行业值#dictValue", "行业名称#dictLabel"};
ExcelExp e2 = new ExcelExp("企业类别信息", header, enterpriseTypeData, SysDictData.class);
List<ExcelExp> mysheet = new ArrayList<>();
mysheet.add(e1);
mysheet.add(e2);
ExcelExportUtil.exportManySheetExcel("行政公文台账信息批量导入模板", mysheet, response);
} }
//批量导入 params是classFirst的值 //批量导入 params是classFirst的值
@PostMapping("/importData") @PostMapping("/importData")
public AjaxResult importHubManage(MultipartFile file, Boolean updateSupport, Long params) throws Exception { public AjaxResult importHubManage(MultipartFile file, Boolean updateSupport, Long params) throws Exception {
ExcelUtil<LawEnforceImportTemplate> util = new ExcelUtil<>(LawEnforceImportTemplate.class); ExcelUtil<EhsLawEnforcement> util = new ExcelUtil<>(EhsLawEnforcement.class);
List<LawEnforceImportTemplate> list = util.importExcel(file.getInputStream()); List<EhsLawEnforcement> list = util.importExcel(file.getInputStream());
String message = ehsLawEnforcementService.importData(list, updateSupport, params); String message = ehsLawEnforcementService.importData(list, updateSupport, params);
return AjaxResult.success(message); return AjaxResult.success(message);
} }

@ -67,7 +67,7 @@ public class EhsLawEnforcement extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "是否重大隐患") @Excel(name = "是否重大隐患", dictType = "sys_yes_no")
private String isLargeRisk; private String isLargeRisk;
/** /**
@ -85,7 +85,7 @@ public class EhsLawEnforcement extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "企业类别") @Excel(name = "企业类别", dictType = "enterprise_category")
private Integer enterpriseCategory; private Integer enterpriseCategory;
/** /**
@ -97,14 +97,14 @@ public class EhsLawEnforcement extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "是否建立双预防") @Excel(name = "是否建立双预防", dictType = "sys_yes_no")
private String isEstablishPrevention; private String isEstablishPrevention;
/** /**
* *
*/ */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "时间(yyyy-MM-dd格式)", width = 30, dateFormat = "yyyy-MM-dd")
private Date time; private Date time;
/** /**
@ -116,7 +116,7 @@ public class EhsLawEnforcement extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "类别") //@Excel(name = "类别")
private Long classFirst; private Long classFirst;
} }

@ -38,5 +38,5 @@ public interface IEhsLawEnforcementService extends IService<EhsLawEnforcement> {
* @param params classFirst * @param params classFirst
* @return * @return
*/ */
public String importData(List<LawEnforceImportTemplate> list, Boolean updateSupport, Long params) throws Exception; public String importData(List<EhsLawEnforcement> list, Boolean updateSupport, Long params) throws Exception;
} }

@ -58,7 +58,7 @@ public class EhsLawEnforcementServiceImpl extends ServiceImpl<EhsLawEnforcementM
* @return * @return
*/ */
@Override @Override
public String importData(List<LawEnforceImportTemplate> list, Boolean updateSupport, Long params) throws Exception { public String importData(List<EhsLawEnforcement> list, Boolean updateSupport, Long params) throws Exception {
if (StringUtils.isNull(list) || list.size() == 0) { if (StringUtils.isNull(list) || list.size() == 0) {
throw new Exception("导入行政执法台账数据不能为空!"); throw new Exception("导入行政执法台账数据不能为空!");
} }
@ -67,7 +67,7 @@ public class EhsLawEnforcementServiceImpl extends ServiceImpl<EhsLawEnforcementM
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
for (LawEnforceImportTemplate lawEnforceImportTemplate : list) { for (EhsLawEnforcement item : list) {
EhsLawEnforcement temp = new EhsLawEnforcement(); EhsLawEnforcement temp = new EhsLawEnforcement();
/** /**
@ -75,20 +75,20 @@ public class EhsLawEnforcementServiceImpl extends ServiceImpl<EhsLawEnforcementM
* id,,id * id,,id
*/ */
// temp.setId(IdUtils.fastSimpleUUID()); // temp.setId(IdUtils.fastSimpleUUID());
temp.setEnterpriseName(lawEnforceImportTemplate.getEnterpriseName());// 单位名称 temp.setEnterpriseName(item.getEnterpriseName());// 单位名称
temp.setLocation(lawEnforceImportTemplate.getLocation());// 地址 temp.setLocation(item.getLocation());// 地址
temp.setResponsiblePerson(lawEnforceImportTemplate.getResponsiblePerson());// 负责人 temp.setResponsiblePerson(item.getResponsiblePerson());// 负责人
temp.setPhone(lawEnforceImportTemplate.getPhone());// 联系电话 temp.setPhone(item.getPhone());// 联系电话
temp.setRisk(lawEnforceImportTemplate.getRisk());// 存在隐患 temp.setRisk(item.getRisk());// 存在隐患
temp.setIsLargeRisk(lawEnforceImportTemplate.getIsLargeRisk().toUpperCase());// 是否重大隐患 temp.setIsLargeRisk(item.getIsLargeRisk().toUpperCase());// 是否重大隐患
temp.setRectificationMeasure(lawEnforceImportTemplate.getRectificationMeasure());// 整改措施 temp.setRectificationMeasure(item.getRectificationMeasure());// 整改措施
temp.setRectificationPeople(lawEnforceImportTemplate.getRectificationPeople());// 整改责任人 temp.setRectificationPeople(item.getRectificationPeople());// 整改责任人
temp.setEnterpriseCategory(lawEnforceImportTemplate.getEnterpriseCategory());// 企业类别 temp.setEnterpriseCategory(item.getEnterpriseCategory());// 企业类别
temp.setEmployeeNum(lawEnforceImportTemplate.getEmployeeNum());// 企业人数 temp.setEmployeeNum(item.getEmployeeNum());// 企业人数
temp.setIsEstablishPrevention(lawEnforceImportTemplate.getIsEstablishPrevention().toUpperCase());// 是否建立双预防 temp.setIsEstablishPrevention(item.getIsEstablishPrevention().toUpperCase());// 是否建立双预防
temp.setTime(lawEnforceImportTemplate.getTime());// 时间 temp.setTime(item.getTime());// 时间
temp.setRemark(lawEnforceImportTemplate.getRemark());// 备注 temp.setRemark(item.getRemark());// 备注
temp.setOther(lawEnforceImportTemplate.getOther());// 其他 temp.setOther(item.getOther());// 其他
temp.setClassFirst(params);// 类别 temp.setClassFirst(params);// 类别
try { try {
//插入数据 //插入数据

Loading…
Cancel
Save