|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.uas.erp.schedular.service.SettingService;
|
|
|
import com.uas.erp.schedular.util.BeanUtil;
|
|
|
+import com.uas.erp.schedular.util.CollectionUtil;
|
|
|
import com.uas.erp.schedular.web.ResultListWrap;
|
|
|
import com.uas.erp.schedular.web.ResultWrap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -209,7 +210,7 @@ public class RestJdbcTemplate {
|
|
|
* @return
|
|
|
*/
|
|
|
public String generateCode(String sequenceName, int type) {
|
|
|
- return getString("{call Sp_GetMaxNumber(?,?)}", sequenceName, type);
|
|
|
+ return callForString("{call Sp_GetMaxNumber(?,?,?)}", sequenceName, type);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -242,4 +243,38 @@ public class RestJdbcTemplate {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * call procedure
|
|
|
+ * @param exec call语句
|
|
|
+ * @param args in参数
|
|
|
+ * @param outParams out参数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> callForMap(String exec, Object[] args, String[] outParams){
|
|
|
+ HttpEntity request = new HttpEntity<Executable>(Executable.call(exec, outParams, args));
|
|
|
+ ParameterizedTypeReference<ResultWrap<List<Map<String, Object>>>> responseType = new ParameterizedTypeReference<ResultWrap<List<Map<String, Object>>>>(){};
|
|
|
+ ResponseEntity<ResultWrap<List<Map<String, Object>>>> response = restTemplate.exchange(getUrl() + "/v1/exec", HttpMethod.POST, request, responseType);
|
|
|
+ ResultWrap<List<Map<String, Object>>> result = response.getBody();
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ List<Map<String, Object>> list = result.getContent();
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ return list.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ throw new RuntimeException(result.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * call procedure and return string
|
|
|
+ * @param exec
|
|
|
+ * @param args
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String callForString(String exec, Object... args) {
|
|
|
+ Map<String, Object> data = callForMap(exec, args, new String[]{"v_return"});
|
|
|
+ Object code = null == data ? null : data.get("v_return");
|
|
|
+ return null == code ? null : code.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|