TestController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. package easydo.technology.controller;
  2. import java.sql.Connection;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import javax.annotation.Resource;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import javax.sql.DataSource;
  10. import com.alibaba.fastjson.JSONObject;
  11. import easydo.technology.exception.BizException;
  12. import easydo.technology.model.*;
  13. import easydo.technology.model.vo.GLDContract;
  14. import easydo.technology.service.GLDCostService;
  15. import org.springframework.security.crypto.password.PasswordEncoder;
  16. import org.springframework.web.bind.annotation.*;
  17. import easydo.technology.annotation.WebLog;
  18. import easydo.technology.components.JdbcClient;
  19. import easydo.technology.service.GLDMasterService;
  20. import easydo.technology.util.HttpClientUtil;
  21. import easydo.technology.utils.RedisUtils;
  22. import easydo.technology.utils.StringUtil;
  23. import lombok.extern.java.Log;
  24. @Log
  25. @RestController
  26. @RequestMapping("/test")
  27. public class TestController {
  28. @Resource
  29. DataSource dataSource;
  30. @Resource
  31. JdbcClient jdbcClient;
  32. @Resource
  33. GLDMasterService gldMasterService;
  34. @Resource
  35. private PasswordEncoder passwordEncoder;
  36. @Resource
  37. RedisUtils redisUtils;
  38. @Resource
  39. GLDCostService gldCostService;
  40. /*
  41. * public static void main(String[] args) {
  42. * String url = "http://218.201.101.181:14780/tenant/v2/tenants?size=20000";
  43. * String auth =
  44. * "Basic YlFvc0tIeWJkSlZUZGtMcXA0U1VIMlE0ejNZQjc5eVA6b1ZmaU5zR1c1NVZzSW5ITTlDOVI3c2g0SHlpVGMxY2w="
  45. * ;
  46. * String token = "cn-b3c73fac-2629-4337-94fb-e79c289d1979";
  47. * String tenantId = "5600001";
  48. *
  49. * JSONObject object = HttpClientUtil.sendGLDGET_getTenantId(url, token);
  50. * log.info(object.toJSONString());
  51. * //{"access_token":"cn-b3c73fac-2629-4337-94fb-e79c289d1979","scope":
  52. * "paas-clouddoc,paas-gdoc_tenant,paas-new-storage-service_admin,paas-organization_admin,paas-gws_tenant,paas-organization_tenant,paas-comment-service_tenant,paas-databag_tenant,paas-new-storage-service_tenant,paas-databag_admin,paas_databag_tenant,paas-raw-storage-service_tenant"
  53. * ,"token_type":"bearer","exp":1723342092,"expires_in":74670}
  54. * }
  55. */
  56. // public static void main(String[] args) {
  57. // String url =
  58. // "http://218.201.101.181:14780/flow-app-local/v4/flow-definitions/query-for-start?formId=flow/STD_Dcm_PROCUREMENT_SYSTEM&mgtGroupId=11200297";
  59. // Map<String, String> header = new HashMap<>();
  60. // header.put("Authorization",
  61. // "Basic
  62. // YlFvc0tIeWJkSlZUZGtMcXA0U1VIMlE0ejNZQjc5eVA6b1ZmaU5zR1c1NVZzSW5ITTlDOVI3c2g0SHlpVGMxY2w=");
  63. // header.put("x-tenant-id", "5600003");
  64. // JSONArray resObject = HttpClientUtil.sendGETWithHeader_Arr(url, header);
  65. // log.info(resObject.toJSONString());
  66. // }
  67. /*
  68. * public static void main(String[] args) {
  69. * // String url =
  70. * "http://218.201.101.181:8180/seeyon/thirdpartyController.do?ticket=-5127817351537210703";
  71. * // String username = HttpClientUtil.sendOaGET_USERNAME(url);
  72. * // log.info(username);
  73. *
  74. * String url = "http://218.201.101.181:8180/seeyon/rest/token";
  75. * JSONObject object = new JSONObject();
  76. * object.put("userName", "zcxt");
  77. * object.put("password", "2679fc6b-df18-4563-9b8e-773b59bdcb62");
  78. * JSONObject resObject = HttpClientUtil.sendPOST(url, object.toJSONString());
  79. * String accessToken = resObject.getString("id");
  80. * log.info(accessToken);
  81. *
  82. * String getUserInfoUrl =
  83. * "http://218.201.101.181:8180/seeyon/rest/orgMember?loginName=guanglianda";
  84. * Map<String, String> header = new HashMap<>();
  85. * header.put("token", accessToken);
  86. * // header.put("Authorization", "Bearer " + accessToken);
  87. * JSONObject resObj = HttpClientUtil.sendGETWithHeader_Obj(getUserInfoUrl,
  88. * header);
  89. * log.info(resObj);
  90. * }
  91. */
  92. @WebLog
  93. @RequestMapping(value = "/getPage")
  94. public Object getPage() throws Exception {
  95. Connection connection = null;
  96. Map<String, Object> map = new HashMap<>();
  97. try {
  98. connection = dataSource.getConnection();
  99. // connection.setAutoCommit(false);
  100. map.put("isHaveContract", 0);
  101. map.put("projectIdBegin", 1);
  102. List<Purchase> list = jdbcClient.getJdbcList(map, Purchase.class, connection);
  103. for (Purchase model : list) {
  104. List<GLDContract> contractList = gldCostService.getContractList(model.getProjectId(),
  105. model.getPurchaseNo());
  106. if (!contractList.isEmpty()) {
  107. PurchaseBidNotice bidNotice = new PurchaseBidNotice();
  108. bidNotice.setPurchaseId(model.getId());
  109. bidNotice = jdbcClient.getJdbcModel(bidNotice, connection);
  110. Supplier supplier = new Supplier();
  111. supplier.setId(bidNotice.getBidCompanyIds());
  112. supplier = jdbcClient.getJdbcModel(supplier, connection);
  113. for (GLDContract contract : contractList) {
  114. PurchaseContract purchaseContract = new PurchaseContract();
  115. purchaseContract.setPurchaseId(model.getId());
  116. purchaseContract.setProjectId(model.getProjectId());
  117. purchaseContract.setContractName(contract.getName());
  118. purchaseContract.setContractNo(contract.getCode());
  119. purchaseContract.setSignAmount(contract.getTaxAmount());
  120. purchaseContract.setCreateTime(contract.getCreateTime());
  121. purchaseContract.setEndTime(contract.getApprovedEndTime());
  122. purchaseContract.setObjectId(contract.getObjectId());
  123. purchaseContract.setFileName(contract.getFileName());
  124. purchaseContract.setSupplierId(supplier.getId());
  125. purchaseContract.setSupplierName(supplier.getSupplierName());
  126. purchaseContract.setSupplierNo(supplier.getSupplierNo());
  127. jdbcClient.jdbcInsert(purchaseContract, connection);
  128. }
  129. model.setIsHaveContract(true);
  130. jdbcClient.jdbcUpdateById(model, connection);
  131. }
  132. }
  133. // connection.commit();
  134. } catch (Exception e) {
  135. // connection.commit();
  136. throw e;
  137. } finally {
  138. jdbcClient.finallyExecute(connection);
  139. }
  140. return "success";
  141. }
  142. @WebLog
  143. @RequestMapping(value = "/getPassword")
  144. public Object getPage(@RequestBody SysUser user) throws Exception {
  145. // redisUtils.set("test", "123456", 600);
  146. // log.info(redisUtils.get("test").toString());
  147. // if(true){
  148. // throw new BizException("122345678");
  149. // }
  150. JSONObject object = new JSONObject();
  151. object.put("password", passwordEncoder.encode(user.getUsername()));
  152. return object;
  153. }
  154. @WebLog
  155. @GetMapping(value = "/test")
  156. public void test(HttpServletResponse response, HttpServletRequest request, @RequestParam String objectId,
  157. @RequestParam(required = false) String fileName) throws Exception {
  158. String url = "http://jsf-int.glodon.com/cost-management/openapi/attachments/" + objectId;
  159. Map<String, String> header = new HashMap<>();
  160. header.put("Authorization",
  161. "Basic a0ZkMkE4UkhSM1l1ZlplQ1lVUGNjVWFMblJWQW5ZZ1c6VTJNakoycVZiaGNVYlI5VlVyUUdYeVFQekp1WkdoNm4=");
  162. header.put("X-CORAL-TENANT", "865509948108800");
  163. if (StringUtil.isEmpty(fileName)) {
  164. fileName = "contract.pdf";
  165. }
  166. HttpClientUtil.sendGETWithHeader_OutputStream(url, header, request, response, fileName);
  167. }
  168. // public static void main(String[] args) {
  169. // String creationDate = LocalDateUtil.localDateTimeFormat(LocalDateTime.now(),
  170. // "yyyy-MM-dd HH:mm");
  171. // String creationDate2 = LocalDateUtil.localDateTimeFormat(LocalDateTime.now(),
  172. // "yyyy-MM-dd HH:mm:ss");
  173. // String url = "http://218.201.101.181:8180" + "/seeyon/rest/token";
  174. // JSONObject object = new JSONObject();
  175. // object.put("userName", "zcxt");
  176. // object.put("password", "2679fc6b-df18-4563-9b8e-773b59bdcb62");
  177. // JSONObject resObject = HttpClientUtil.sendPOST(url, object.toJSONString());
  178. // log.info("查询OAtoken的res======>" + resObject.toJSONString());
  179. // String token = resObject.getString("id");
  180. // Map<String, String> header = new HashMap<>();
  181. // header.put("token", token);
  182. // String sendTodoUrl = "http://218.201.101.181:8180" +
  183. // "/seeyon/rest/thirdpartyPending/receive?token=" + token;
  184. // object = new JSONObject();
  185. // object.put("registerCode", "3007");
  186. // object.put("taskId", "4e12f28b-8e15-4f82-afbf-59dd0b083394");
  187. // object.put("title", "供应商评价");
  188. // object.put("senderName", "guanglianda");
  189. // object.put("classify", "招采系统");
  190. // object.put("contentType", "招采系统");
  191. // object.put("state", 0);
  192. // object.put("thirdSenderId", "");
  193. // object.put("thirdReceiverId", "");
  194. // object.put("creationDate", creationDate);
  195. // object.put("content", "");
  196. // object.put("h5url", "");
  197. // object.put("url", "http://172.16.1.150:8810/purchase/getDetail?"
  198. // +
  199. // "type=supplier_evaluate&path=supplier-evaluation-detail&businessId=d0ff0a8b-54bf-4351-ad8d-e7cd26fc181e");
  200. // object.put("noneBindingSender", "guanglianda");
  201. // object.put("noneBindingReceiver", "guanglianda");
  202. // JSONObject resObj = HttpClientUtil.sendPOSTWithHeader(sendTodoUrl,
  203. // object.toJSONString(), header);
  204. // log.info("生成OA待办req======>" + object.toJSONString() + ",res======>"
  205. // + resObj.toJSONString());
  206. // String updateTodoUrl = "http://218.201.101.181:8180" +
  207. // "/seeyon/rest/thirdpartyPending/updatePendingState?token=" + token;
  208. // object = new JSONObject();
  209. // object.put("registerCode", "3007");
  210. // object.put("taskId","4e12f28b-8e15-4f82-afbf-59dd0b083394" );
  211. // object.put("state",1 );
  212. // object.put("subState",2 );
  213. // JSONObject resObj =
  214. // HttpClientUtil.sendPOSTWithHeader(updateTodoUrl,object.toJSONString(),
  215. // header);
  216. // log.info("更新OA待办req======>" + object.toJSONString() + ",res======>"
  217. // + resObj.toJSONString());
  218. // String sendMessageUrl = "http://218.201.101.181:8180" +
  219. // "/seeyon/rest/thirdpartyMessage/receive/singleMessage?token=" + token;
  220. // object = new JSONObject();
  221. // object.put("thirdpartyRegisterCode", "3007");
  222. // object.put("thirdpartyMessageId", "1");
  223. // object.put("messageContent", "您有一条待测试的消息。");
  224. // object.put("thirdpartyReceiverId", 0);
  225. // object.put("creation_date", creationDate2);
  226. // object.put("noneBindingSender", "guanglianda");
  227. // object.put("noneBindingReceiver", "guanglianda");
  228. // JSONObject resObj = HttpClientUtil.sendPOSTWithHeader(sendMessageUrl,
  229. // object.toJSONString(), header);
  230. // log.info("推送OA消息req======>" + object.toJSONString() + ",res======>"
  231. // + resObj.toJSONString());
  232. // }
  233. }