ApplyController.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.huimv.manage.controller;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.huimv.manage.service.IApplyService;
  5. import com.huimv.manage.util.Result;
  6. import com.huimv.manage.util.ResultCode;
  7. import com.huimv.manage.webservice.Soap;
  8. import com.huimv.manage.webservice.task.NewProduceMission;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.web.bind.annotation.CrossOrigin;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import java.io.UnsupportedEncodingException;
  17. /**
  18. * @Project : huimv.shiwan
  19. * @Package : com.huimv.biosafety.uface.controller
  20. * @Description : TODO
  21. * @Version : 1.0
  22. * @Author : ZhuoNing
  23. * @Create : 2020-12-25
  24. **/
  25. @CrossOrigin
  26. @RestController
  27. @Slf4j
  28. @RequestMapping(value = "/apply")
  29. public class ApplyController {
  30. @Value("${webservice.url}")
  31. private String webServiceUrl;
  32. @Value("${webservice.producerId}")
  33. private String producerId;
  34. @Autowired
  35. private IApplyService applyService;
  36. @Autowired
  37. private Soap soap;
  38. @Autowired
  39. private NewProduceMission newProduceMission;
  40. /**
  41. * @Method : listTask
  42. * @Description :
  43. * @Params : []
  44. * @Return : java.lang.String
  45. *
  46. * @Author : ZhuoNing
  47. * @Date : 2021/10/27
  48. * @Time : 20:28
  49. */
  50. @RequestMapping(value = "/listApply",method = RequestMethod.GET)
  51. public Result listApply(){
  52. return applyService.listApply();
  53. }
  54. /**
  55. * @Method : getNewTask
  56. * @Description :
  57. * @Params : []
  58. * @Return : java.lang.String
  59. *
  60. * @Author : ZhuoNing
  61. * @Date : 2021/10/27
  62. * @Time : 20:29
  63. */
  64. @RequestMapping(value = "/getNewApply",method = RequestMethod.GET)
  65. public Result getNewTask() throws UnsupportedEncodingException {
  66. log.info("producerId>>"+producerId);
  67. log.info("webServiceUrl>>"+webServiceUrl);
  68. //
  69. JSONArray applyJa = newProduceMission.parseApplyXML(soap.callSoap(newProduceMission.getNewMissionText(producerId),webServiceUrl));
  70. //
  71. // JSONArray applyJa = newProduceMission.parseApplyXML(newProduceMission.getNewMessionResult());
  72. if(applyJa.size() > 0){
  73. // System.out.println("获取任务号:"+applyJa.size());
  74. // for(int a=0;a<applyJa.size();a++){
  75. // JSONObject applyJo = applyJa.getJSONObject(a);
  76. // System.out.println(applyJo);
  77. // }
  78. // 保存新任务(号)
  79. return applyService.saveNewMission(applyJa);
  80. }else{
  81. return new Result(ResultCode.SUCCESS,"目前暂无新任务.");
  82. }
  83. }
  84. }