sql format 异常捕获提升

dev
wangxuanran 2023-07-21 22:09:32 +08:00
parent 194042f5e9
commit bfec43d804
5 changed files with 51 additions and 38 deletions

View File

@ -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);
}
}

View File

@ -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){

View File

@ -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();

View File

@ -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();

View File

@ -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);