|
|
|
@ -4,7 +4,9 @@ import cn.estsh.i3plus.core.api.iservice.busi.ISysDictionaryService;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.serviceimpl.base.SystemInitService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.ExcelTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
@ -17,6 +19,7 @@ import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.LocaleUtils;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
@ -26,6 +29,12 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -51,6 +60,12 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
@Autowired
|
|
|
|
|
private SystemInitService systemInitService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EntityManager entityManager;
|
|
|
|
|
|
|
|
|
|
@Resource(name= CommonConstWords.IMPP_REDIS_RES)
|
|
|
|
|
private ImppRedis redisRes;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加字典
|
|
|
|
|
* @param sysDictionary 字典信息
|
|
|
|
@ -475,4 +490,47 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下载系统字典的模板文件
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/download-template")
|
|
|
|
|
@ApiOperation(value = "下载系统字典的上传模板",notes = "下载系统字典的上传模板")
|
|
|
|
|
public void downSysDictionaryTemplate(HttpServletResponse response){
|
|
|
|
|
try {
|
|
|
|
|
ExcelTool excelTool = new ExcelTool(entityManager, redisRes);
|
|
|
|
|
String importTemplateCode = "SysDictionaryImportTemplate";
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
|
|
response.setHeader("Content-Disposition",
|
|
|
|
|
"attachment;fileName=" + URLEncoder.encode(importTemplateCode + ".xls", "UTF-8"));
|
|
|
|
|
response.flushBuffer();
|
|
|
|
|
|
|
|
|
|
response.getOutputStream().write(excelTool.importTemplate(SysDictionary.class));
|
|
|
|
|
response.getOutputStream().flush();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error("下载异常", e);
|
|
|
|
|
throw ImppExceptionBuilder.newInstance().setErrorDetail(e.getMessage()).build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/import")
|
|
|
|
|
@ApiOperation(value = "导入系统字典文件")
|
|
|
|
|
public ResultBean importSysOrderNoRule(@RequestParam("file") MultipartFile file) {
|
|
|
|
|
try {
|
|
|
|
|
ExcelTool excelTool = new ExcelTool(entityManager, redisRes);
|
|
|
|
|
List<SysDictionary> sysDictionaryList = excelTool.importData(file.getOriginalFilename(), file.getInputStream(), SysDictionary.class);
|
|
|
|
|
sysDictionaryList.forEach(sysDictionary -> {
|
|
|
|
|
sysDictionaryService.insertSysDictionary(sysDictionary);
|
|
|
|
|
});
|
|
|
|
|
return ResultBean.success("导入成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|