Commit d873402e authored by 赵啸非's avatar 赵啸非

添加自定义导入

parent 4a6ee7e7
package com.mortals.xhx.module.matter.model.vo; package com.mortals.xhx.module.matter.model.vo;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.matter.model.*; import com.mortals.xhx.module.matter.model.*;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 自定义导入对象 * 自定义导入对象
*
* @author: zxfei * @author: zxfei
* @date: 2025/3/24 9:44 * @date: 2025/3/24 9:44
*/ */
@Data @Data
public class MatterCustomImportEntity extends BaseEntityLong { public class MatterCustomImportEntity extends BaseEntityLong {
/**
* 区域编码
*/
@Excel(name = "区域编码")
private String areaCode;
/** /**
* 事项名称 * 事项名称
*/ */
@Excel(name = "事项名称")
private String matterName; private String matterName;
/** /**
* 部门名称 * 部门名称
*/ */
@Excel(name = "部门名称")
private String deptName; private String deptName;
/**
* 承诺办结时限
*/
@Excel(name = "承诺办结时限")
private String promiseTimeLimitShow;
/** /**
* 事项详情链接 * 事项详情链接
*/ */
@Excel(name = "办事指南地址", type = Excel.Type.IMPORT)
private String url; private String url;
/**
* pc详细地址
*/
@Excel(name = "网办地址")
private String netApplyUrl;
/**
* 备注信息
*/
@Excel(name = "流程描述")
private String flowDesc;
/**
* 备注信息
*/
@Excel(name = "备注")
private String remark;
/**
* 投诉电话
*/
private String cousultingTelephoneShow;
/**
* 事项类型
*/
@Excel(name = "事项类型")
private String eventTypeShow;
@Override
public int hashCode() {
return Objects.hash(this.areaCode, this.getMatterName());
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof MatterCustomImportEntity) {
MatterCustomImportEntity tmp = (MatterCustomImportEntity) obj;
if ((this.getAreaCode() + this.getMatterName()).equals(tmp.getAreaCode() + tmp.getMatterName())) {
if (this.getId() == tmp.getId()) {
return true;
}
}
}
return false;
}
} }
\ No newline at end of file
...@@ -9,10 +9,12 @@ import com.mortals.framework.service.ICRUDService; ...@@ -9,10 +9,12 @@ import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterDao; import com.mortals.xhx.module.matter.dao.MatterDao;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery; import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.model.vo.MatterCustomImportEntity;
import com.mortals.xhx.module.matter.model.vo.MatterInfo; import com.mortals.xhx.module.matter.model.vo.MatterInfo;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteMatterEntity; import com.mortals.xhx.module.site.model.SiteMatterEntity;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -89,4 +91,7 @@ public interface MatterService extends ICRUDService<MatterEntity, Long> { ...@@ -89,4 +91,7 @@ public interface MatterService extends ICRUDService<MatterEntity, Long> {
Rest<Void> genMatterTXT(MatterQuery matterQuery, Context context); Rest<Void> genMatterTXT(MatterQuery matterQuery, Context context);
Rest<String> doImportCustomData(List<MatterCustomImportEntity> list, Context context);
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.service.impl; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.service.impl;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.setting.Setting; import cn.hutool.setting.Setting;
...@@ -36,6 +37,7 @@ import com.mortals.xhx.module.dept.model.DeptQuery; ...@@ -36,6 +37,7 @@ import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matter.dao.MatterDao; import com.mortals.xhx.module.matter.dao.MatterDao;
import com.mortals.xhx.module.matter.model.*; import com.mortals.xhx.module.matter.model.*;
import com.mortals.xhx.module.matter.model.vo.MatterCustomImportEntity;
import com.mortals.xhx.module.matter.model.vo.MatterInfo; import com.mortals.xhx.module.matter.model.vo.MatterInfo;
import com.mortals.xhx.module.matter.service.*; import com.mortals.xhx.module.matter.service.*;
import com.mortals.xhx.module.matters.model.MattersDetailEntity; import com.mortals.xhx.module.matters.model.MattersDetailEntity;
...@@ -2056,6 +2058,127 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -2056,6 +2058,127 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
} }
public Rest<String> doImportCustomData(List<MatterCustomImportEntity> list, Context context) {
//内部先去重复
list = list.stream().distinct().collect(Collectors.toList());
int SucessCount = 0;
int failCount = 0;
for (MatterCustomImportEntity matterCustomImportEntity : list) {
if (ObjectUtils.isEmpty(matterCustomImportEntity.getAreaCode())) {
failCount++;
continue;
}
//通过判断事项区域和名称,判断是否存在 存在则不添加
MatterEntity matterEntity = this.selectOne(new MatterQuery().areaCode(matterCustomImportEntity.getAreaCode()).matterName(matterCustomImportEntity.getMatterName()));
if (ObjectUtils.isEmpty(matterEntity)) {
matterEntity = new MatterEntity();
matterEntity.initAttrValue();
BeanUtils.copyProperties(matterCustomImportEntity, matterEntity, BeanUtil.getNullPropertyNames(matterCustomImportEntity));
matterEntity.setMatterNo(RandomUtil.randomString(12));
matterEntity.setTid("/file/fileupload/flow.jpg");
matterEntity.setCreateTime(new Date());
matterEntity.setCreateUserId(1L);
this.save(matterEntity);
//保存区域站点部门
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().name(matterEntity.getDeptName()));
if (ObjectUtils.isEmpty(deptEntity)) {
deptEntity = new DeptEntity();
deptEntity.initAttrValue();
deptEntity.setName(matterEntity.getDeptName());
deptEntity.setDeptNumber(RandomUtil.randomString(12));
SiteEntity siteEntity = siteService.selectOne(new SiteQuery().areaCode(matterEntity.getAreaCode()));
if (!ObjectUtils.isEmpty(siteEntity)) {
deptEntity.setSiteId(siteEntity.getId());
} else {
//创建一个本级站点
siteEntity = new SiteEntity();
siteEntity.initAttrValue();
siteEntity.setAreaCode(matterEntity.getAreaCode());
siteEntity.setAreaName(matterEntity.getAreaName());
siteEntity.setSiteName(matterEntity.getAreaName());
siteEntity.setCreateTime(new Date());
siteEntity.setCreateUserId(1L);
siteService.save(siteEntity);
deptEntity.setSiteId(siteEntity.getId());
}
deptEntity.setCreateTime(new Date());
deptEntity.setCreateUserId(1L);
deptService.save(deptEntity);
matterEntity.setDeptCode(deptEntity.getDeptNumber());
this.update(matterEntity);
}
//todo 固定新增办事流程
ArrayList<MatterFlowlimitEntity> matterFlowlimitEntities = new ArrayList<>();
MatterFlowlimitEntity matterFlowlimitEntity = new MatterFlowlimitEntity();
matterFlowlimitEntity.setMatterId(matterEntity.getId());
matterFlowlimitEntity.setMatterName(matterEntity.getMatterName());
matterFlowlimitEntity.setMatterCode(matterEntity.getMatterNo());
matterFlowlimitEntity.setFlowName("1. 申请准备。");
matterFlowlimitEntity.setFlowDesc("(1)访问对应的网上办理渠道,完成用户注册登录;\n" +
"(2)找到企业登记一件事办理事项,了解办事指南,准备申请材料;将申请材料处理为电子版。");
matterFlowlimitEntity.setCreateTime(new Date());
matterFlowlimitEntity.setCreateUserId(1L);
matterFlowlimitEntities.add(matterFlowlimitEntity);
matterFlowlimitEntity = new MatterFlowlimitEntity();
matterFlowlimitEntity.setMatterId(matterEntity.getId());
matterFlowlimitEntity.setMatterName(matterEntity.getMatterName());
matterFlowlimitEntity.setMatterCode(matterEntity.getMatterNo());
matterFlowlimitEntity.setFlowName("2. 在线申请。");
matterFlowlimitEntity.setFlowDesc("(1)自行在线申请,上传申请材料(清晰可见)。如需补正材料,按系统的补正流程进行。\n" +
"(2)向政务大厅申请帮办代办服务。");
matterFlowlimitEntity.setCreateTime(new Date());
matterFlowlimitEntity.setCreateUserId(1L);
matterFlowlimitEntities.add(matterFlowlimitEntity);
matterFlowlimitEntity = new MatterFlowlimitEntity();
matterFlowlimitEntity.setMatterId(matterEntity.getId());
matterFlowlimitEntity.setMatterName(matterEntity.getMatterName());
matterFlowlimitEntity.setMatterCode(matterEntity.getMatterNo());
matterFlowlimitEntity.setFlowName("3. 领取结果。");
matterFlowlimitEntity.setFlowDesc("(1)电子化结果。选择对应申请的网上办理渠道领取。\n" +
"(2)纸质档结果。可选择免费快递邮寄或窗口领取。");
matterFlowlimitEntity.setCreateTime(new Date());
matterFlowlimitEntity.setCreateUserId(1L);
matterFlowlimitEntities.add(matterFlowlimitEntity);
matterFlowlimitService.save(matterFlowlimitEntities);
SucessCount++;
} else {
failCount++;
}
}
return Rest.ok("成功:" + SucessCount + " 失败:" + failCount);
}
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -343,15 +343,15 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe ...@@ -343,15 +343,15 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
boolean setnx = cacheService.setnx("genMatterTxt:" + areaCode, "1", 60 * 20); boolean setnx = cacheService.setnx("genMatterTxt:" + areaCode, "1", 60 * 20);
if (!setnx) { if (!setnx) {
return baseAreaEntity.getName() + ".txt 正在生成中,请稍后查看文件!"; return baseAreaEntity.getName() + ".txt 正在生成中,请稍后查看文件!";
} }
new Thread(() -> { new Thread(() -> {
Rest<Void> voidRest = this.service.genMatterTXT(query, getContext()); Rest<Void> voidRest = this.service.genMatterTXT(query, getContext());
cacheService.del("genMatterTxt:" + areaCode); cacheService.del("genMatterTxt:" + areaCode);
}).start(); }).start();
//http://192.168.0.98:11071/home/txt/ //http://192.168.0.98:11071/home/txt/
// model.put(MESSAGE_INFO, "异步生成文件中,请稍后查看文件!,文件访问地址:http://192.168.0.98:11071" + genFilePath+"/"); // model.put(MESSAGE_INFO, "异步生成文件中,请稍后查看文件!,文件访问地址:http://192.168.0.98:11071" + genFilePath+"/");
return "异步生成文件中,请稍后查看文件!,文件访问地址: http://192.168.0.98:11071" + genFilePath; return "异步生成文件中,请稍后查看文件!,文件访问地址: http://192.168.0.98:11071" + genFilePath;
...@@ -366,9 +366,8 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe ...@@ -366,9 +366,8 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
} }
@PostMapping("/importDataCustom") @PostMapping("/importDataCustom")
@UnAuth
public String importDataCustom(MultipartFile file, boolean updateSupport) { public String importDataCustom(MultipartFile file, boolean updateSupport) {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
Map<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
...@@ -381,12 +380,12 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe ...@@ -381,12 +380,12 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
int code = VALUE_RESULT_SUCCESS; int code = VALUE_RESULT_SUCCESS;
try { try {
ExcelUtil<MatterCustomImportEntity, Long> util = new ExcelUtil<>(MatterCustomImportEntity.class); ExcelUtil<MatterCustomImportEntity, Long> util = new ExcelUtil<>(MatterCustomImportEntity.class);
doImportExcelBefore(excelConfData);
List<MatterCustomImportEntity> list = util.importExcel((String) excelConfData.get("sheetName"), file.getInputStream(), (Integer) excelConfData.get("headereRow"), (Integer) excelConfData.get("dataRow")); List<MatterCustomImportEntity> list = util.importExcel((String) excelConfData.get("sheetName"), file.getInputStream(), (Integer) excelConfData.get("headereRow"), (Integer) excelConfData.get("dataRow"));
// doImportDataBefore(list, updateSupport, context); Rest<String> rest = this.service.doImportCustomData(list, context);
// String message = this.service.importList(list, updateSupport, getContext()); // doImportDataBefore(list, updateSupport, context);
// doImportExcelAfter(file, list, getContext()); // String message = this.service.importList(list, updateSupport, getContext());
//model.put(MESSAGE_INFO, message); // doImportExcelAfter(file, list, getContext());
model.put(MESSAGE_INFO, rest.getMsg());
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) { } catch (Exception e) {
code = VALUE_RESULT_FAILURE; code = VALUE_RESULT_FAILURE;
......
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