123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package com.huimv.manage.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.huimv.manage.service.IApplyService;
- import com.huimv.manage.util.Const;
- import com.huimv.manage.util.Result;
- import com.huimv.manage.webservice.Soap;
- import com.huimv.manage.webservice.task.ProduceMissionTask;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.*;
- import java.io.UnsupportedEncodingException;
- /**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
- @CrossOrigin
- @RestController
- @Slf4j
- @RequestMapping(value = "/eartag/apply")
- public class ApplyController {
- @Value("${webservice.url}")
- private String webServiceUrl;
- @Value("${webservice.producerId}")
- private String producerId;
- @Autowired
- private IApplyService applyService;
- @Autowired
- private Soap soap;
- @Autowired
- private ProduceMissionTask produceMissionTask;
- /**
- * @Method : listTask
- * @Description :
- * @Params : []
- * @Return : java.lang.String
- *
- * @Author : ZhuoNing
- * @Date : 2021/10/27
- * @Time : 20:28
- */
- @RequestMapping(value = "/listApply",method = RequestMethod.GET)
- // public Result listApply(@RequestParam(value = "accessToken",required=false) String accessToken,
- // @RequestParam(value = "applyId",required=false) int applyId,
- // @RequestParam(value = "startDate",required=false) String startDate,
- // @RequestParam(value = "endDate",required=false) String endDate,
- // @RequestParam(value = "returnState",required=false) int returnState,
- // @RequestParam(value = "deliverState",required=false) int deliverState,
- // @RequestParam(value = "pageSize",required=true) int pageSize)
- public Result listApply()
- {
- return applyService.listApply();
- }
- /**
- * @Method : getNewTask
- * @Description :
- * @Params : []
- * @Return : java.lang.String
- *
- * @Author : ZhuoNing
- * @Date : 2021/10/27
- * @Time : 20:29
- */
- @RequestMapping(value = "/getNewApply",method = RequestMethod.GET)
- public Result getNewTask() throws UnsupportedEncodingException {
- log.info("producerId>>"+producerId);
- log.info("webServiceUrl>>"+webServiceUrl);
- // 从远程接口下载新任务号数据
- JSONArray downloadApplyJa = produceMissionTask.parseReturnNewMissionXML(soap.callSoap(produceMissionTask.getNewMissionXML(producerId),webServiceUrl));
- // test
- // JSONArray downloadApplyJa = newProduceMission.parseApplyXML(newProduceMission.getNewMessionResult_test());
- if(downloadApplyJa == null){
- return new Result(Const.CODE_APPLY_PARSE,Const.APPLY_PARSE_ERROR,false);
- }
- // 过滤已经入库的任务号
- JSONArray newApplyJa = applyService.filterExistApply(downloadApplyJa);
- if(newApplyJa.size() > 0){
- // test
- // System.out.println("获取任务号:"+newApplyJa.size());
- // for(int a=0;a<newApplyJa.size();a++){
- // JSONObject applyJo = newApplyJa.getJSONObject(a);
- // System.out.println(applyJo);
- // }
- // 保存新任务(号)
- return applyService.saveNewMission(newApplyJa);
- }else{
- return new Result(Const.CODE_APPLY_NO_NEW, Const.APPLY_NO_NEW,false);
- }
- }
- /**
- * @Method : setReturnDownloadState
- * @Description : 设置返回任务已下载
- * @Params : [applyId]
- * @Return : com.huimv.manage.util.Result
- *
- * @Author : ZhuoNing
- * @Date : 2021/10/29
- * @Time : 11:08
- */
- @RequestMapping(value = "/setReturnDownloadState",method = RequestMethod.POST)
- public Result setReturnDownloadState(@RequestParam(value = "applyId") int applyId) throws UnsupportedEncodingException {
- // Step1.构造请求字串
- // Step2.发送请求传
- // Step3.请求结果入库
- String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML(soap.callSoap(produceMissionTask.getSetMissionHasDownloadXML(applyId),webServiceUrl));
- if(stateBln.trim().equalsIgnoreCase("true")){
- // 修改状态
- return applyService.setMissionHasDownloadState(applyId,1);
- }else{
- return new Result(Const.CODE_UPDATE_STATE_FAIL,Const.UPDATE_STATE_FAIL,false);
- }
- }
- }
|