|
|
@@ -1,14 +1,19 @@
|
|
|
package com.lc.ibps.business.service.impl;
|
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.lc.ibps.api.form.sql.util.BeanUtils;
|
|
|
import com.lc.ibps.base.core.constants.StringPool;
|
|
|
import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.business.service.AuditService;
|
|
|
+import com.lc.ibps.cloud.entity.APIResult;
|
|
|
import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
|
|
|
import com.lc.ibps.common.api.INewsMgrService;
|
|
|
import com.lc.ibps.common.system.persistence.entity.NewsPo;
|
|
|
+import com.lc.ibps.untils.SqlUtil;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -31,6 +36,8 @@ public class AuditServiceImpl implements AuditService {
|
|
|
|
|
|
private final String T_RYPXCJB = "t_rypxcjb";
|
|
|
|
|
|
+ private final String LOG_TABLE = "t_business_log";
|
|
|
+
|
|
|
@Resource
|
|
|
private ICommonDao<?> commonDao;
|
|
|
|
|
|
@@ -319,6 +326,38 @@ public class AuditServiceImpl implements AuditService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public APIResult<Map<String,Object>> dataToSql(String logId) throws Exception {
|
|
|
+ APIResult<Map<String,Object>> result = new APIResult<>();
|
|
|
+ Map<String,Object> sqlMap = new HashMap<>();
|
|
|
+ String sql = "select data_ from "+LOG_TABLE+" where id_ ='"+logId+"'";
|
|
|
+ Map<String,Object> map = commonDao.queryOne(sql);
|
|
|
+ if (BeanUtils.isNotEmpty(map) && BeanUtils.isNotEmpty(map.get("data_"))){
|
|
|
+ JSONArray jsonArray = JSONUtil.parseArray(map.get("data_").toString());
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+ String tableName = jsonObject.getStr("table_name");
|
|
|
+ String id = jsonObject.getStr("id_");
|
|
|
+ String sql2 = "select id_ from "+tableName+" where id_ ='"+id+"'";
|
|
|
+ Map<String,Object> data = commonDao.queryOne(sql2);
|
|
|
+ jsonObject.remove("table_name");
|
|
|
+ if (BeanUtils.isNotEmpty(data) && BeanUtils.isNotEmpty(data.get("id_"))){
|
|
|
+ // update
|
|
|
+ String updateSql = SqlUtil.buildUpdateSql(jsonObject, tableName, id);
|
|
|
+ sqlBuilder.append(updateSql).append(";");
|
|
|
+ }else {
|
|
|
+ // insert
|
|
|
+ String insertSql = SqlUtil.buildInsertSql(jsonObject,tableName);
|
|
|
+ sqlBuilder.append(insertSql).append(";");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlMap.put("sql", sqlBuilder.toString());
|
|
|
+ result.setData(sqlMap);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询检验科主任
|