diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/AuthController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/AuthController.java index d6114d2..14253dc 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/AuthController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/AuthController.java @@ -14,6 +14,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.ImppExceptionEnum; +import cn.estsh.impp.framework.boot.util.LocaleUtils; import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; @@ -150,7 +151,8 @@ public class AuthController extends CoreBaseController { LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep); return ResultBean.fail(busExcep); } catch (Exception e) { - LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e); + LOGGER.error(LocaleUtils.getEnumLocaleResDesc(ImppExceptionEnum.SYSTEM_EXCEPTION, + ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription()) + ":{}", e.getMessage(), e); return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode()); } } diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java index 0a1b1a2..0a167f8 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java @@ -19,9 +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.ResultBean; -import cn.estsh.impp.framework.boot.util.ValidatorBean; +import cn.estsh.impp.framework.boot.util.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -188,7 +186,7 @@ public class WhiteController extends CoreBaseController { recordSysUserLog(null, loginName,CommonEnumUtil.USER_LOGIN_STATUS.SYSTEM_ERROR.getValue(), ipAddr); } catch (Exception e) { result = ResultBean.fail(e.getMessage()).setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode()) - .setErrorMsg(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription()); + .setErrorMsg(LocaleUtils.getEnumLocaleResDesc(ImppExceptionEnum.SYSTEM_EXCEPTION, ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription())); // 记录登录记录 recordSysUserLog(null, loginName,CommonEnumUtil.USER_LOGIN_STATUS.SYSTEM_ERROR.getValue(), ipAddr); @@ -393,4 +391,17 @@ public class WhiteController extends CoreBaseController { return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } } + + + @GetMapping("/sys-organize/enum") + @ApiOperation(value = "获取全部组织", notes = "获取全部组织") + public ResultBean getEnum(){ + try { + return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(Arrays.asList(CommonEnumUtil.IS_VAILD.values())); + }catch(ImppBusiException busExcep){ + return ResultBean.fail(busExcep); + }catch(Exception e){ + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } } diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysDictionaryController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysDictionaryController.java index 4aa5307..ac718d0 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysDictionaryController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysDictionaryController.java @@ -17,6 +17,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.LocaleUtils; import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; @@ -407,7 +408,7 @@ public class SysDictionaryController extends CoreBaseController{ if(group.containsKey(softType.getValue())){ child = new HashMap(); child.put("id",softType.getValue()); - child.put("name",softType.getDescription()); + child.put("name", LocaleUtils.getEnumLocaleResDesc(softType,softType.getDescription())); child.put("childList",group.get(softType.getValue())); dictTree.add(child); } diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysEnumController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysEnumController.java index 4516827..1c9d31e 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysEnumController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysEnumController.java @@ -4,6 +4,7 @@ import cn.estsh.i3plus.platform.common.util.PlatformConstWords; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; import cn.estsh.impp.framework.base.controller.CoreBaseController; +import cn.estsh.impp.framework.boot.util.LocaleUtils; import cn.estsh.impp.framework.boot.util.ResultBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -36,7 +37,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "功能类型", notes = "查询全部功能类型功能") public ResultBean getEnumMethodLevel() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.METHOD_LEVEL.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.METHOD_LEVEL.values())); } /** @@ -48,7 +49,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "数据功能状态", notes = "查询全部数据状态功能") public ResultBean getEnumUserDataStatus() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.DATA_STATUS.values())); + LocaleUtils.getEnumLocaleResValuesToList((CommonEnumUtil.DATA_STATUS.values()))); } /** @@ -62,7 +63,7 @@ public class SysEnumController extends CoreBaseController { List enumList = new ArrayList(); enumList.add(CommonEnumUtil.DATA_STATUS.ENABLE); enumList.add(CommonEnumUtil.DATA_STATUS.DISABLE); - return new ResultBean(true, "操作成功", enumList); + return new ResultBean(true, "操作成功", LocaleUtils.getEnumLocaleResValueList(enumList)); } /** @@ -74,7 +75,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "组织类型", notes = "查询全部组织类型功能") public ResultBean getEnumOrganizeType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.ORGANIZE_YTPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.ORGANIZE_YTPE.values())); } /** @@ -86,7 +87,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "任务类型", notes = "查询全部任务类型功能") public ResultBean getTaskMethodType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.TASK_METHOD_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.TASK_METHOD_TYPE.values())); } /** @@ -98,7 +99,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "用户类型", notes = "查询全部用户类型功能") public ResultBean getUserType() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.USER_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.USER_TYPE.values())); } /** @@ -110,7 +111,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "用户账号状态", notes = "查询全部用户账号功能") public ResultBean getUserStatus() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.USER_STATUS.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.USER_STATUS.values())); } /** @@ -122,7 +123,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "日志等级", notes = "日志等级") public ResultBean getLogLevel() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.LOG_LEVEL.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.LOG_LEVEL.values())); } /** @@ -134,7 +135,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "软件类型", notes = "软件类型") public ResultBean getSoftType() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.SOFT_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.SOFT_TYPE.values())); } /** @@ -146,7 +147,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "操作日志类型", notes = "操作日志类型") public ResultBean getOperateType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.OPERATE_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.OPERATE_TYPE.values())); } /** @@ -156,7 +157,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "用户消息状态", notes = "用户消息状态") public ResultBean getUserMessageStatus() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.MESSAGE_STATUS.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.MESSAGE_STATUS.values())); } @@ -167,7 +168,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "用户消息类型", notes = "用户消息类型") public ResultBean getUserMessageType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.MESSAGE_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.MESSAGE_TYPE.values())); } @@ -178,7 +179,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "硬件连接类型", notes = "硬件连接类型") public ResultBean getToolConnType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.TOOL_CONN_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.TOOL_CONN_TYPE.values())); } @@ -189,7 +190,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "硬件数据类型", notes = "硬件数据类型") public ResultBean getToolDataType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.TOOL_DATA_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.TOOL_DATA_TYPE.values())); } @@ -200,7 +201,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "系统参数类型", notes = "系统参数") public ResultBean getSysParamType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.SYS_CONFIG_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.SYS_CONFIG_TYPE.values())); } @@ -211,7 +212,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "系统资源类型") public ResultBean getSysLocaleResourceType() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE.values())); } @@ -222,7 +223,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "用户性别", notes = "用户性别") public ResultBean getUserSex() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.USER_ESX.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.USER_ESX.values())); } @@ -233,7 +234,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "用户状态", notes = "用户状态") public ResultBean getUserInfoStatus() { return new ResultBean(true, "操作成功", - Arrays.asList(CommonEnumUtil.USER_INFO_STATUS.values())); + LocaleUtils.getEnumLocaleResValuesToList(CommonEnumUtil.USER_INFO_STATUS.values())); } /** @@ -248,7 +249,7 @@ public class SysEnumController extends CoreBaseController { list.add(ImppEnumUtil.SYS_VALUE_TYPE.DATE); list.add(ImppEnumUtil.SYS_VALUE_TYPE.SWITCH); - return new ResultBean(true, "操作成功", list); + return new ResultBean(true, "操作成功", LocaleUtils.getEnumLocaleResValueList(list)); } /** @@ -258,7 +259,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "系统参数值类型", notes = "用户状态") public ResultBean getSysConfigValueType() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.SYS_VALUE_TYPE.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.SYS_VALUE_TYPE.values())); } @@ -270,7 +271,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "系统配置组", notes = "系统配置组") public ResultBean getSysConfigGroup() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.SYS_CONFIG_GROUP.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.SYS_CONFIG_GROUP.values())); } /** @@ -282,7 +283,7 @@ public class SysEnumController extends CoreBaseController { List list = new ArrayList<>(); list.add(ImppEnumUtil.MESSAGE_TYPE.MAIL); list.add(ImppEnumUtil.MESSAGE_TYPE.LETTER); - return new ResultBean(true, "操作成功", list); + return new ResultBean(true, "操作成功", LocaleUtils.getEnumLocaleResValueList(list)); } /** @@ -294,7 +295,7 @@ public class SysEnumController extends CoreBaseController { public ResultBean getExternalNoticeMethod() { List list = new ArrayList<>(); list.add(ImppEnumUtil.MESSAGE_TYPE.MAIL); - return new ResultBean(true, "操作成功", list); + return new ResultBean(true, "操作成功", LocaleUtils.getEnumLocaleResValueList(list)); } /** @@ -305,7 +306,7 @@ public class SysEnumController extends CoreBaseController { @ApiOperation(value = "字典分组", notes = "字典分组") public ResultBean getDictionaryGroup() { return new ResultBean(true, "操作成功", - Arrays.asList(ImppEnumUtil.DICTIONARY_GROUP.values())); + LocaleUtils.getEnumLocaleResValuesToList(ImppEnumUtil.DICTIONARY_GROUP.values())); } diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysUserInfoController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysUserInfoController.java index 5bd0177..ab355b7 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysUserInfoController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysUserInfoController.java @@ -19,6 +19,7 @@ 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; import io.swagger.annotations.Api; @@ -401,7 +402,8 @@ public class SysUserInfoController extends CoreBaseController{ }catch(ImppBusiException busExcep){ LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep); }catch(Exception e){ - LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e); + LOGGER.error(LocaleUtils.getEnumLocaleResDesc(ImppExceptionEnum.SYSTEM_EXCEPTION, + ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription()) + ":{}", e.getMessage(), e); } } diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/util/ResourceImportUtil.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/util/ResourceImportUtil.java index 1cd4fbe..fe5c926 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/util/ResourceImportUtil.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/util/ResourceImportUtil.java @@ -3,6 +3,8 @@ package cn.estsh.i3plus.core.apiservice.util; import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +import cn.estsh.i3plus.pojo.platform.bean.SysConfig; +import cn.estsh.i3plus.pojo.platform.bean.SysDictionary; import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.CellType; @@ -12,6 +14,8 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @Description : @@ -23,7 +27,7 @@ import java.io.*; public class ResourceImportUtil { public static void main(String[] args) { - File file = new File("C:\\Users\\yunha\\Desktop\\副本资源文件.xlsx"); + File file = new File("C:\\Users\\yunha\\Desktop\\资源文件.xlsx"); File sql = new File("C:\\Users\\yunha\\Desktop\\imppRource.sql"); int i = 1; try { @@ -42,7 +46,7 @@ public class ResourceImportUtil { if(row == null|| row.getCell(2) == null|| row.getCell(3) == null){ continue; -} + } System.out.println(snowflakeIdMaker.nextId()+"行:"+i); row.getCell(2).setCellType(CellType.STRING); row.getCell(3).setCellType(CellType.STRING); @@ -53,8 +57,9 @@ public class ResourceImportUtil { sysLocaleResource.setResourceKey(row.getCell(2).getStringCellValue()); sysLocaleResource.setResourceValue(row.getCell(2).getStringCellValue()); System.out.println(sql(sysLocaleResource)); - - bufferWritter.write(sql(sysLocaleResource)); + if(isContainChinese(row.getCell(2).getStringCellValue())){ + bufferWritter.write(sql(sysLocaleResource)); + } sysLocaleResource.setId(snowflakeIdMaker.nextId()); sysLocaleResource.setLanguageCode("US/en"); @@ -87,7 +92,9 @@ public class ResourceImportUtil { sysLocaleResource.setResourceValue(row.getCell(3).getStringCellValue()); System.out.println(sql(sysLocaleResource)); - bufferWritter.write(sql(sysLocaleResource)); + if(isContainChinese(row.getCell(2).getStringCellValue())){ + bufferWritter.write(sql(sysLocaleResource)); + } sysLocaleResource.setId(snowflakeIdMaker.nextId()); sysLocaleResource.setLanguageCode("US/en"); @@ -117,7 +124,9 @@ public class ResourceImportUtil { sysLocaleResource.setResourceValue(row.getCell(3).getStringCellValue()); System.out.println(sql(sysLocaleResource)); - bufferWritter.write(sql(sysLocaleResource)); + if(isContainChinese(row.getCell(2).getStringCellValue())){ + bufferWritter.write(sql(sysLocaleResource)); + } sysLocaleResource.setId(snowflakeIdMaker.nextId()); sysLocaleResource.setLanguageCode("US/en"); @@ -130,6 +139,79 @@ public class ResourceImportUtil { bufferWritter.write(sql(sysLocaleResource)); } + // ENUM + Sheet enumSheet = wb.getSheet("ENUM"); + i =1; + for (; i < enumSheet.getLastRowNum(); i++) { + row = wmsSheet.getRow(i); + + System.out.println(snowflakeIdMaker.nextId()+" ENUM 行:"+i); + row.getCell(2).setCellType(CellType.STRING); + row.getCell(3).setCellType(CellType.STRING); + sysLocaleResource.setId(snowflakeIdMaker.nextId()); + sysLocaleResource.setLanguageCode("CN/zh"); + sysLocaleResource.setLanguageNameRdd("简体中文"); + sysLocaleResource.setResourceType( getType(row.getCell(1).getStringCellValue())); + sysLocaleResource.setResourceKey(row.getCell(2).getStringCellValue()); + sysLocaleResource.setResourceValue(row.getCell(2).getStringCellValue()); + System.out.println(sql(sysLocaleResource)); + + if(isContainChinese(row.getCell(2).getStringCellValue())){ + bufferWritter.write(sql(sysLocaleResource)); + } + + sysLocaleResource.setId(snowflakeIdMaker.nextId()); + sysLocaleResource.setLanguageCode("US/en"); + sysLocaleResource.setLanguageNameRdd("English"); + sysLocaleResource.setResourceType( getType(row.getCell(1).getStringCellValue())); + sysLocaleResource.setResourceKey(row.getCell(2).getStringCellValue()); + sysLocaleResource.setResourceValue(row.getCell(3).getStringCellValue()); + System.out.println(sql(sysLocaleResource)); + + bufferWritter.write(sql(sysLocaleResource)); + } + + + + // 字典 + Sheet dcSheet = wb.getSheet("字典"); + i =1; + for (; i < dcSheet.getLastRowNum(); i++) { + row = dcSheet.getRow(i); + + System.out.println(snowflakeIdMaker.nextId()+" 字典 行:"+i); + row.getCell(0).setCellType(CellType.STRING); + row.getCell(1).setCellType(CellType.STRING); + row.getCell(2).setCellType(CellType.STRING); + SysDictionary sysDictionary = new SysDictionary(); + sysDictionary.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + sysDictionary.setName(row.getCell(1).getStringCellValue()); + sysDictionary.setParentNameRdd(row.getCell(2).getStringCellValue()); + + System.out.println(sql(sysDictionary)); + bufferWritter.write(sql(sysDictionary)); + } + + // 参数 + Sheet configSheet = wb.getSheet("参数"); + i =1; + for (; i < configSheet.getLastRowNum(); i++) { + row = configSheet.getRow(i); + + System.out.println(snowflakeIdMaker.nextId()+" 参数 行:"+i); + row.getCell(0).setCellType(CellType.STRING); + row.getCell(1).setCellType(CellType.STRING); + row.getCell(2).setCellType(CellType.STRING); + + SysConfig sysConfig = new SysConfig(); + sysConfig.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + sysConfig.setName(row.getCell(1).getStringCellValue()); + sysConfig.setConfigDescription(row.getCell(2).getStringCellValue()); + + System.out.println(sql(sysConfig)); + bufferWritter.write(sql(sysConfig)); + } + bufferWritter.flush(); bufferWritter.close(); @@ -161,4 +243,33 @@ public class ResourceImportUtil { +sysLocaleResource.getResourceKey().replaceAll("\"","\\\\\\\"")+"\",\""+sysLocaleResource.getResourceValue().replaceAll("\"","\\\\\\\"")+"\",1);\n"; } + + private static String sql(SysConfig sysConfig){ + return "UPDATE `sys_config` SET `config_description` = '"+sysConfig.getConfigDescription()+"', `name` = '"+sysConfig.getName()+ + "' WHERE `id` = "+sysConfig.getId()+" ;\n"; + } + + private static String sql(SysDictionary sysDictionary){ + return "UPDATE `sys_dictionary` SET `name` = '"+sysDictionary.getName().replaceAll("'","\\\\\\'")+"', `parent_name_rdd` =" + + " '"+sysDictionary.getParentNameRdd().replaceAll("'","\\\\\\'")+ + "' WHERE `id` = " + + sysDictionary.getId()+" ;\n"; + } + + + /** + * 判断字符串中是否包含中文 + * @param str + * 待校验字符串 + * @return 是否为中文 + * @warn 不能校验是否为中文标点符号 + */ + public static boolean isContainChinese(String str) { + Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); + Matcher m = p.matcher(str); + if (m.find()) { + return true; + } + return false; + } }