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

main
15036302109 8 months ago
parent f8419f24cc
commit ff310a4c25

@ -118,39 +118,16 @@ public class EhsLawEnforcementController extends BaseController {
*
*/
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException {
List<EhsLawEnforcement> teamWorkerList = new ArrayList<>();
// 获取企业类别字典数据
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);
public void importTemplate(HttpServletResponse response) throws Exception {
ExcelUtil<EhsLawEnforcement> util = new ExcelUtil<>(EhsLawEnforcement.class);
util.importComboTemplateExcel(response, "行政公文台账信息批量导入模板");
}
//批量导入 params是classFirst的值
@PostMapping("/importData")
public AjaxResult importHubManage(MultipartFile file, Boolean updateSupport, Long params) throws Exception {
ExcelUtil<LawEnforceImportTemplate> util = new ExcelUtil<>(LawEnforceImportTemplate.class);
List<LawEnforceImportTemplate> list = util.importExcel(file.getInputStream());
ExcelUtil<EhsLawEnforcement> util = new ExcelUtil<>(EhsLawEnforcement.class);
List<EhsLawEnforcement> list = util.importExcel(file.getInputStream());
String message = ehsLawEnforcementService.importData(list, updateSupport, params);
return AjaxResult.success(message);
}

@ -67,7 +67,7 @@ public class EhsLawEnforcement extends BaseEntity {
/**
*
*/
@Excel(name = "是否重大隐患")
@Excel(name = "是否重大隐患", dictType = "sys_yes_no")
private String isLargeRisk;
/**
@ -85,7 +85,7 @@ public class EhsLawEnforcement extends BaseEntity {
/**
*
*/
@Excel(name = "企业类别")
@Excel(name = "企业类别", dictType = "enterprise_category")
private Integer enterpriseCategory;
/**
@ -97,14 +97,14 @@ public class EhsLawEnforcement extends BaseEntity {
/**
*
*/
@Excel(name = "是否建立双预防")
@Excel(name = "是否建立双预防", dictType = "sys_yes_no")
private String isEstablishPrevention;
/**
*
*/
@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;
/**
@ -116,7 +116,7 @@ public class EhsLawEnforcement extends BaseEntity {
/**
*
*/
@Excel(name = "类别")
//@Excel(name = "类别")
private Long classFirst;
}

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

Loading…
Cancel
Save