From bfec43d8044a0795af918b123fae91d76af9ee06 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Fri, 21 Jul 2023 22:09:32 +0800 Subject: [PATCH] =?UTF-8?q?sql=20format=20=E5=BC=82=E5=B8=B8=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E6=8F=90=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiyh/utils/recordset/FormatSqlUtil.java | 3 +- .../controller/CommonDataAsyncController.java | 3 +- .../XkHospitalCommonDefinition.java | 3 + .../row/HrmDepartmentRowDefinition.java | 5 ++ .../wang/xk_hospital/test/XkHospitalTest.java | 75 ++++++++++--------- 5 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java b/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java index 0a6303b..a52a5f8 100644 --- a/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java +++ b/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java @@ -2,6 +2,7 @@ package aiyh.utils.recordset; import com.alibaba.druid.sql.SQLUtils; import com.alibaba.druid.sql.parser.ParserException; +import com.icbc.api.internal.apache.http.E; import weaver.conn.RecordSet; import java.util.Objects; @@ -27,7 +28,7 @@ public class FormatSqlUtil { } try { return SQLUtils.format(sql, dbType); - } catch (ParserException e) { + } catch (Exception e) { return toSqlString(sql); } } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java index 4f07883..711ddb2 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java @@ -4,6 +4,7 @@ import aiyh.utils.ApiResult; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService; import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -42,7 +43,7 @@ public class CommonDataAsyncController { if(StrUtil.isBlank(configId) || StrUtil.isBlank(type)){ throw new CustomerException("configId or type can not be empty!"); } - logger.info(Util.logStr("configId : {}, type : {}, params : {}", configId, type, params)); + logger.info(Util.logStr("configId : {}, type : {}, params : {}", configId, type, JSONObject.toJSONString(params))); service.async(configId, type, params); return ApiResult.successNoData(); }catch (Exception e){ diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java index e447d77..18086ab 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java @@ -5,6 +5,7 @@ import aiyh.utils.Util; import aiyh.utils.response_deal.mapper.ConfigMapper; import com.api.xuanran.wang.xk_hospital.data_async.mapper.XkHospitalDataAsyncMapper; import com.engine.common.service.impl.ThemeServiceImpl; +import ln.LN; import org.apache.log4j.Logger; import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.resource.ResourceComInfo; @@ -55,6 +56,8 @@ public class XkHospitalCommonDefinition { **/ protected static ResourceComInfo RESOURCE_COM_INFO = null; + protected final LN ln = new LN(); + static { try { RESOURCE_COM_INFO = new ResourceComInfo(); diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java index 50ac6fe..b80a2d8 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java @@ -8,6 +8,7 @@ import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.mapper.ConfigMapper; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition; +import ln.LN; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; @@ -41,6 +42,10 @@ public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition imple if(StrUtil.isBlank(dataId)){ int nextId = -1; if(HRM_RESOURCE.equals(table)){ + int licenseNum = ln.CkHrmnum(); + if(licenseNum < 1){ + throw new CustomerException("当前可用license数量不足!"); + } nextId = Util.getNextHrmId(); }else if(DEPARTMENT.equals(table)){ nextId = Util.getNextDepartmentId(); diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java index 1afaa31..7926f48 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -74,42 +74,45 @@ public class XkHospitalTest extends BaseTest { @Test public void testC(){ String json = "{\n" + - "\t\"ID\":\"主键\",\n" + - "\t\"GroupID\":\"test_yl_01\",\n" + - "\t\"GroupCode\":\"test_yl_dm_03\",\n" + - "\t\"GroupName\":\"医疗组名称1\",\n" + - "\t\"DeptCode\":\"test03\",\n" + - "\t\"DeptName\":\"测试科室03\",\n" + - "\t\"WardCode\":\"病区代码\",\n" + - "\t\"WardName\":\"病区名称\",\n" + - "\t\"Ward_BedNumber\":\"病区床位数,int类型\",\n" + - "\t\"IsDelete\":\"是否停用,bool类型\",\n" + - "\t\"Remark\":\"备注\",\n" + - "\t\"Wards\":[\t\n" + - "\t\t{\t\t\t\n" + - "\t\t\t\"ID\":\"1\",\n" + - "\t\t\t\"WardCode\":\"bq_01\",\n" + - "\t\t\t\"WardName\":\"病区名称01_2_3\"\n" + - "\t\t},{\t\t\t\n" + - "\t\t\t\"ID\":\"2\",\n" + - "\t\t\t\"WardCode\":\"bq_03\",\n" + - "\t\t\t\"WardName\":\"病区名称02_1_3\"\n" + - "\t\t}\n" + - "\t],\n" + - "\t\"WardHeads\":[\n" + - "\t\t{\n" + - "\t\t\t\"ID\":\"1\",\n" + - "\t\t\t\"EmplCode\":\"TEST10\",\n" + - "\t\t\t\"EmplName\":\"傻逼01\",\n" + - "\t\t\t\"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + - "\t\t},{\n" + - "\t\t\t\"ID\":\"2\",\n" + - "\t\t\t\"EmplCode\":\"TEST10\",\n" + - "\t\t\t\"EmplName\":\"傻逼02\",\n" + - "\t\t\t\"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + - "\t\t}\n" + - "\t]\n" + - "}\n"; + " \"ID\":\"主键\",\n" + + " \"GroupID\":\"test_yl_01\",\n" + + " \"GroupCode\":\"test_yl_dm_03\",\n" + + " \"GroupName\":\"医疗组名称1\",\n" + + " \"DeptCode\":\"test03\",\n" + + " \"DeptName\":\"测试科室03\",\n" + + " \"WardCode\":\"testbq_dm_1\",\n" + + " \"WardName\":\"测试主表病区名称1\",\n" + + " \"Ward_BedNumber\":\"病区床位数,int类型\",\n" + + " \"IsDelete\":\"是否停用,bool类型\",\n" + + " \"Remark\":\"备注\",\n" + + " \"Wards\":[\n" + + " {\n" + + " \"ID\":\"1\",\n" + + " \"WardCode\":\"bq_01\",\n" + + " \"WardName\":\"病区名称01_2_3\"\n" + + " },\n" + + " {\n" + + " \"ID\":\"2\",\n" + + " \"WardCode\":\"bq_03\",\n" + + " \"WardName\":\"病区名称02_1_3\"\n" + + " }\n" + + " ],\n" + + " \"WardHeads\":[\n" + + " {\n" + + " \"ID\":\"1\",\n" + + " \"EmplCode\":\"TEST10\",\n" + + " \"EmplName\":\"傻逼01\",\n" + + " \"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + + " },\n" + + " {\n" + + " \"ID\":\"2\",\n" + + " \"EmplCode\":\"TEST10\",\n" + + " \"EmplName\":\"傻逼02\",\n" + + " \"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + + " }\n" + + " ]\n" + + "}"; + System.out.println(json); Map map = JSONObject.parseObject(json, Map.class); Util.null2DefaultStr(null,""); service.async("4bce0693734d","common", map);