| | |
| | | import com.java110.common.constant.CommonConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.BusinessException; |
| | | import com.java110.common.factory.DataTransactionFactory; |
| | | import com.java110.common.log.LoggerEngine; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.common.util.ResponseTemplateUtil; |
| | | import com.java110.entity.service.DataQuery; |
| | | import com.java110.entity.service.ServiceSql; |
| | | import com.java110.service.dao.IQueryServiceDAO; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | |
| | | doExecuteProc(dataQuery); |
| | | }catch (BusinessException e){ |
| | | logger.error("公用查询异常:",e); |
| | | dataQuery.setResponseInfo(ResponseTemplateUtil.createBusinessResponseJson(ResponseConstant.RESULT_PARAM_ERROR, |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_PARAM_ERROR, |
| | | e.getMessage())); |
| | | } |
| | | |
| | |
| | | doExecuteUpdateProc(dataQuery); |
| | | }catch (BusinessException e){ |
| | | logger.error("公用查询异常:",e); |
| | | dataQuery.setResponseInfo(ResponseTemplateUtil.createBusinessResponseJson(ResponseConstant.RESULT_PARAM_ERROR, |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_PARAM_ERROR, |
| | | e.getMessage())); |
| | | } |
| | | |
| | |
| | | try { |
| | | JSONObject params = dataQuery.getRequestParams(); |
| | | JSONObject sqlObj = JSONObject.parseObject(dataQuery.getServiceSql().getSql()); |
| | | |
| | | List<Object> currentParams = new ArrayList<Object>(); |
| | | String currentSql = ""; |
| | | for(String key : sqlObj.keySet()) { |
| | | currentSql = sqlObj.getString(key); |
| | |
| | | currentSqlNew += sqls[sqlIndex]; |
| | | continue; |
| | | } |
| | | currentSqlNew += params.get(sqls[sqlIndex]) instanceof Integer ? params.getInteger(sqls[sqlIndex]) : "'" + params.getString(sqls[sqlIndex]) + "'"; |
| | | currentSqlNew += "?"; |
| | | currentParams.add(params.get(sqls[sqlIndex]) instanceof Integer ? params.getInteger(sqls[sqlIndex]) : "'" + params.getString(sqls[sqlIndex]) + "'"); |
| | | //currentSqlNew += params.get(sqls[sqlIndex]) instanceof Integer ? params.getInteger(sqls[sqlIndex]) : "'" + params.getString(sqls[sqlIndex]) + "'"; |
| | | } |
| | | |
| | | int flag = queryServiceDAOImpl.updateSql(currentSqlNew); |
| | | int flag = queryServiceDAOImpl.updateSql(currentSqlNew,currentParams.toArray()); |
| | | |
| | | if (flag < 1) { |
| | | throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR, "调用接口失败"); |
| | | throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR, "数据交互失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | param = param.substring(0,param.length()-1); |
| | | } |
| | | |
| | | dataQuery.setResponseInfo(ResponseTemplateUtil.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | "成功",JSONObject.parseObject(interpreter.eval("execute("+param+")").toString()))); |
| | | }catch (Exception e){ |
| | | logger.error("数据交互异常:",e); |
| | |
| | | } |
| | | } |
| | | |
| | | dataQuery.setResponseInfo(ResponseTemplateUtil.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | "成功",business)); |
| | | } |
| | | |
| | |
| | | try { |
| | | JSONObject params = dataQuery.getRequestParams(); |
| | | JSONObject sqlObj = JSONObject.parseObject(dataQuery.getServiceSql().getSql()); |
| | | List<Object> currentParams = new ArrayList<Object>(); |
| | | |
| | | String currentSql = sqlObj.getString(dataQuery.getTemplateKey()); |
| | | String[] sqls = currentSql.split("#"); |
| | |
| | | continue; |
| | | } |
| | | if (sqls[sqlIndex].startsWith("PARENT_")) { |
| | | if(obj.isEmpty()){ |
| | | currentSqlNew += "?"; |
| | | currentParams.add("''"); |
| | | continue; |
| | | } |
| | | for (String key : obj.keySet()) { |
| | | if (sqls[sqlIndex].substring("PARENT_".length()).equals(key)) { |
| | | currentSqlNew += obj.get(key) instanceof Integer |
| | | ? obj.getInteger(key) : "'" + obj.getString(key) + "'"; |
| | | /*currentSqlNew += obj.get(key) instanceof Integer |
| | | ? obj.getInteger(key) : "'" + obj.getString(key) + "'";*/ |
| | | currentSqlNew += "?"; |
| | | currentParams.add(obj.get(key) instanceof Integer |
| | | ? obj.getInteger(key) : "" + obj.getString(key) + ""); |
| | | continue; |
| | | } |
| | | } |
| | | } else { |
| | | currentSqlNew += params.get(sqls[sqlIndex]) instanceof Integer ? params.getInteger(sqls[sqlIndex]) : "'" + params.getString(sqls[sqlIndex]) + "'"; |
| | | currentSqlNew += "?"; |
| | | currentParams.add(params.get(sqls[sqlIndex]) instanceof Integer ? params.getInteger(sqls[sqlIndex]) : "" + params.getString(sqls[sqlIndex]) + ""); |
| | | //currentSqlNew += params.get(sqls[sqlIndex]) instanceof Integer ? params.getInteger(sqls[sqlIndex]) : "'" + params.getString(sqls[sqlIndex]) + "'"; |
| | | } |
| | | } |
| | | |
| | | List<Map> results = queryServiceDAOImpl.executeSql(currentSqlNew); |
| | | List<Map<String,Object>> results = queryServiceDAOImpl.executeSql(currentSqlNew, currentParams.toArray()); |
| | | |
| | | if (results == null || results.size() == 0) { |
| | | obj.put(values[1], new JSONObject()); |
| | |
| | | throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"存储过程 procName = " + dataQuery.getServiceSql().getProc() + " 返回结果不是Json格式"); |
| | | } |
| | | |
| | | dataQuery.setResponseInfo(ResponseTemplateUtil.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | "成功",JSONObject.parseObject(jsonStr))); |
| | | } |
| | | |
| | |
| | | throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"存储过程 procName = " + dataQuery.getServiceSql().getProc() + " 返回结果不是Json格式"); |
| | | } |
| | | |
| | | dataQuery.setResponseInfo(ResponseTemplateUtil.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, |
| | | "成功",JSONObject.parseObject(jsonStr))); |
| | | } |
| | | |