Преглед изворни кода

增加任务模块的查询参数。

zhuoning пре 3 година
родитељ
комит
48948a1b44

+ 15 - 1
huimv-manage/src/main/java/com/huimv/manage/dao/repo/EtApplyRepo.java

@@ -1,6 +1,10 @@
 package com.huimv.manage.dao.repo;
 package com.huimv.manage.dao.repo;
 
 
 import com.huimv.manage.dao.entity.EtApplyEntity;
 import com.huimv.manage.dao.entity.EtApplyEntity;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.jpa.repository.Query;
@@ -8,7 +12,17 @@ import org.springframework.data.jpa.repository.Query;
 import java.util.List;
 import java.util.List;
 
 
 public interface EtApplyRepo extends JpaRepository<EtApplyEntity, Integer>, JpaSpecificationExecutor<EtApplyEntity> {
 public interface EtApplyRepo extends JpaRepository<EtApplyEntity, Integer>, JpaSpecificationExecutor<EtApplyEntity> {
+
     //
     //
-    @Query(nativeQuery = true , value = "SELECT * FROM et_apply ORDER BY id DESC")
+    @Query(nativeQuery = true, value = "SELECT * FROM et_apply ORDER BY id DESC")
     List<EtApplyEntity> listApply();
     List<EtApplyEntity> listApply();
+
+    //
+    @Query(nativeQuery = true, value = "SELECT * FROM et_apply ORDER BY id DESC")
+    List<EtApplyEntity> listApply(Pageable pageable, Specification specification);
+
+    //
+    @Query(nativeQuery = true, value = "SELECT * FROM et_apply WHERE apply_id =?1 ORDER BY id DESC",
+            countQuery = "SELECT count(*) FROM et_apply WHERE apply_id =?1")
+    Page<EtApplyEntity> listApply(Pageable pageable,int applyId);
 }
 }

+ 47 - 51
huimv-manage/src/main/java/com/huimv/manage/eartag/controller/ApplyController.java

@@ -6,6 +6,7 @@ import com.huimv.manage.util.Const;
 import com.huimv.manage.util.Result;
 import com.huimv.manage.util.Result;
 import com.huimv.manage.webservice.Soap;
 import com.huimv.manage.webservice.Soap;
 import com.huimv.manage.webservice.task.ProduceMissionTask;
 import com.huimv.manage.webservice.task.ProduceMissionTask;
+import com.sun.istack.Nullable;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
+import java.util.Date;
 
 
 /**
 /**
  * @Project : huimv.shiwan
  * @Project : huimv.shiwan
@@ -39,54 +41,49 @@ public class ApplyController {
     private ProduceMissionTask produceMissionTask;
     private ProduceMissionTask produceMissionTask;
 
 
     /**
     /**
-     * @Method      : listTask
-     * @Description : 
-     * @Params      : []
-     * @Return      : java.lang.String
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/27       
-     * @Time        : 20:28
+     * @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,
-                            HttpServletRequest request)
-//    public Result listApply()
-    {
-
-        return applyService.listApply();
+    @RequestMapping(value = "/listApply", method = RequestMethod.GET)
+    public Result listApply(@RequestParam(value = "applyId", required = false) Integer applyId,
+                            @RequestParam(value = "startDate", required = false) Date startDate,
+                            @RequestParam(value = "endDate", required = false) Date endDate,
+                            @RequestParam(value = "returnState", required = false) Integer returnState,
+                            @RequestParam(value = "deliverState", required = false) Integer deliverState,
+                            @RequestParam(value = "pageSize", required = true) Integer pageSize,
+                            @RequestParam(value = "pageNo", required = true) Integer pageNo){
+        //
+        return applyService.listApply(applyId, startDate, endDate, returnState, deliverState, pageSize, pageNo);
     }
     }
 
 
     /**
     /**
-     * @Method      : getNewTask
-     * @Description : 
-     * @Params      : []
-     * @Return      : java.lang.String
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/27       
-     * @Time        : 20:29
+     * @Method : getNewTask
+     * @Description :
+     * @Params : []
+     * @Return : java.lang.String
+     * @Author : ZhuoNing
+     * @Date : 2021/10/27
+     * @Time : 20:29
      */
      */
-    @RequestMapping(value = "/getNewApply",method = RequestMethod.GET)
+    @RequestMapping(value = "/getNewApply", method = RequestMethod.GET)
     public Result getNewTask(HttpServletRequest request) throws UnsupportedEncodingException {
     public Result getNewTask(HttpServletRequest request) throws UnsupportedEncodingException {
-        log.info("producerId>>"+producerId);
-        log.info("webServiceUrl>>"+webServiceUrl);
+        log.info("producerId>>" + producerId);
+        log.info("webServiceUrl>>" + webServiceUrl);
         // 从远程接口下载新任务号数据
         // 从远程接口下载新任务号数据
-        JSONArray downloadApplyJa = produceMissionTask.parseReturnNewMissionXML(soap.callSoap(produceMissionTask.getNewMissionXML(producerId),webServiceUrl));
+        JSONArray downloadApplyJa = produceMissionTask.parseReturnNewMissionXML(soap.callSoap(produceMissionTask.getNewMissionXML(producerId), webServiceUrl));
         // test
         // test
 //        JSONArray downloadApplyJa = newProduceMission.parseApplyXML(newProduceMission.getNewMessionResult_test());
 //        JSONArray downloadApplyJa = newProduceMission.parseApplyXML(newProduceMission.getNewMessionResult_test());
-        if(downloadApplyJa == null){
-            return new Result(Const.CODE_APPLY_PARSE,Const.APPLY_PARSE_ERROR,false);
+        if (downloadApplyJa == null) {
+            return new Result(Const.CODE_APPLY_PARSE, Const.APPLY_PARSE_ERROR, false);
         }
         }
         // 过滤已经入库的任务号
         // 过滤已经入库的任务号
         JSONArray newApplyJa = applyService.filterExistApply(downloadApplyJa);
         JSONArray newApplyJa = applyService.filterExistApply(downloadApplyJa);
-        if(newApplyJa.size() > 0){
+        if (newApplyJa.size() > 0) {
             // test
             // test
 //            System.out.println("获取任务号:"+newApplyJa.size());
 //            System.out.println("获取任务号:"+newApplyJa.size());
 //            for(int a=0;a<newApplyJa.size();a++){
 //            for(int a=0;a<newApplyJa.size();a++){
@@ -95,33 +92,32 @@ public class ApplyController {
 //            }
 //            }
             // 保存新任务(号)
             // 保存新任务(号)
             return applyService.saveNewMission(newApplyJa);
             return applyService.saveNewMission(newApplyJa);
-        }else{
-            return new Result(Const.CODE_APPLY_NO_NEW, Const.APPLY_NO_NEW,false);
+        } else {
+            return new Result(Const.CODE_APPLY_NO_NEW, Const.APPLY_NO_NEW, false);
         }
         }
     }
     }
 
 
     /**
     /**
-     * @Method      : setReturnDownloadState
+     * @Method : setReturnDownloadState
      * @Description : 设置返回任务已下载
      * @Description : 设置返回任务已下载
-     * @Params      : [applyId]
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/29       
-     * @Time        : 11:08
+     * @Params : [applyId]
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/29
+     * @Time : 11:08
      */
      */
-    @RequestMapping(value = "/setReturnDownloadState",method = RequestMethod.GET)
+    @RequestMapping(value = "/setReturnDownloadState", method = RequestMethod.GET)
     public Result setReturnDownloadState(@RequestParam(value = "applyId") int applyId, HttpServletRequest request) throws UnsupportedEncodingException {
     public Result setReturnDownloadState(@RequestParam(value = "applyId") int applyId, HttpServletRequest request) throws UnsupportedEncodingException {
         // Step1.构造请求字串
         // Step1.构造请求字串
         // Step2.发送请求传
         // Step2.发送请求传
         // Step3.请求结果入库
         // Step3.请求结果入库
 
 
-        String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML(soap.callSoap(produceMissionTask.getSetMissionHasDownloadXML(applyId),webServiceUrl));
-        if(stateBln.trim().equalsIgnoreCase("true")){
+        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);
+            return applyService.setMissionHasDownloadState(applyId, 1);
+        } else {
+            return new Result(Const.CODE_UPDATE_STATE_FAIL, Const.UPDATE_STATE_FAIL, false);
         }
         }
     }
     }
 }
 }

+ 40 - 47
huimv-manage/src/main/java/com/huimv/manage/eartag/controller/PackageController.java

@@ -37,78 +37,71 @@ public class PackageController {
     private IPackageService packageService;
     private IPackageService packageService;
 
 
     /**
     /**
-     * @Method      : listPackage
+     * @Method : listPackage
      * @Description : 展示列表
      * @Description : 展示列表
-     * @Params      : [pageSize]
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/29       
-     * @Time        : 15:37
+     * @Params : [pageSize]
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/29
+     * @Time : 15:37
      */
      */
-    @RequestMapping(value = "/listPackage",method = RequestMethod.GET)
-    public Result listPackage(@RequestParam(value = "pageSize")int pageSize){
-//    public Result listPackage(@RequestParam(value = "accessToken",required = true) String accessToken,
-//                              @RequestParam(value = "applyId",required = true) int applyId,
-//                              @RequestParam(value = "packageId",required = false) int packageId,
-//                              @RequestParam(value = "startDate",required = false) String startDate,
-//                              @RequestParam(value = "endDate",required = false) String endDate,
-//                              @RequestParam(value = "returnState",required = false) int returnState,
-//                              @RequestParam(value = "pageSize",required = true) int pageSize, HttpServletRequest request){
-
+    @RequestMapping(value = "/listPackage", method = RequestMethod.GET)
+//    public Result listPackage(@RequestParam(value = "pageSize")int pageSize){
+    public Result listPackage(
+            @RequestParam(value = "applyId", required = false) Integer applyId,
+            @RequestParam(value = "packageId", required = false) Integer packageId,
+            @RequestParam(value = "startDate", required = false) String startDate,
+            @RequestParam(value = "endDate", required = false) String endDate,
+            @RequestParam(value = "returnState", required = false) Integer returnState,
+            @RequestParam(value = "pageSize", required = true) Integer pageSize) {
         //
         //
         return packageService.listPackage(pageSize);
         return packageService.listPackage(pageSize);
     }
     }
 
 
     /**
     /**
-     * @Method      : getNewPackage
+     * @Method : getNewPackage
      * @Description : 根据任务号下载新批次
      * @Description : 根据任务号下载新批次
-     * @Params      : [applyId]
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/29       
-     * @Time        : 15:42
+     * @Params : [applyId]
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/29
+     * @Time : 15:42
      */
      */
-    @RequestMapping(value = "/getNewPackage",method = RequestMethod.GET)
+    @RequestMapping(value = "/getNewPackage", method = RequestMethod.GET)
     public Result getNewPackage(@RequestParam(value = "applyId") int applyId, HttpServletRequest request) throws UnsupportedEncodingException {
     public Result getNewPackage(@RequestParam(value = "applyId") int applyId, HttpServletRequest request) throws UnsupportedEncodingException {
         //
         //
         return packageService.getNewPackage(applyId);
         return packageService.getNewPackage(applyId);
     }
     }
 
 
     /**
     /**
-     * @Method      : setReturnDownloadState
+     * @Method : setReturnDownloadState
      * @Description : 设置返回批次已下载状态
      * @Description : 设置返回批次已下载状态
-     * @Params      : [packageIds, ids]
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/29       
-     * @Time        : 18:51
+     * @Params : [packageIds, ids]
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/29
+     * @Time : 18:51
      */
      */
-    @RequestMapping(value = "/setReturnDownloadState",method = RequestMethod.GET)
-    public Result setReturnDownloadState(@RequestParam(value = "packageIds") String packageIds,@RequestParam(value = "ids") String ids, HttpServletRequest request) throws UnsupportedEncodingException {
+    @RequestMapping(value = "/setReturnDownloadState", method = RequestMethod.GET)
+    public Result setReturnDownloadState(@RequestParam(value = "packageIds") String packageIds, @RequestParam(value = "ids") String ids, HttpServletRequest request) throws UnsupportedEncodingException {
         //
         //
-        return packageService.setReturnDownloadState(packageIds,ids);
+        return packageService.setReturnDownloadState(packageIds, ids);
     }
     }
 
 
     /**
     /**
-     * @Method      : setProduceState
+     * @Method : setProduceState
      * @Description : 设置生产状态
      * @Description : 设置生产状态
-     * @Params      : []
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/29       
-     * @Time        : 19:22
+     * @Params : []
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/29
+     * @Time : 19:22
      */
      */
-    @RequestMapping(value = "/setProduceState",method = RequestMethod.GET)
-    public Result setProduceState(@RequestParam(value = "ids") String ids,@RequestParam(value = "state") int state, HttpServletRequest request){
+    @RequestMapping(value = "/setProduceState", method = RequestMethod.GET)
+    public Result setProduceState(@RequestParam(value = "ids") String ids, @RequestParam(value = "state") int state, HttpServletRequest request) {
         //
         //
-        return packageService.setProduceState(ids,state);
+        return packageService.setProduceState(ids, state);
     }
     }
 
 
 
 
-
-
 }
 }

+ 4 - 0
huimv-manage/src/main/java/com/huimv/manage/eartag/service/IApplyService.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.huimv.manage.dao.entity.EtApplyEntity;
 import com.huimv.manage.dao.entity.EtApplyEntity;
 import com.huimv.manage.util.Result;
 import com.huimv.manage.util.Result;
 
 
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 public interface IApplyService {
 public interface IApplyService {
@@ -18,4 +19,7 @@ public interface IApplyService {
 
 
     // 修改任务状态信息
     // 修改任务状态信息
     Result setMissionHasDownloadState(int applyId, int id);
     Result setMissionHasDownloadState(int applyId, int id);
+
+    // 展示任务列表(带分页)
+    Result listApply(Integer applyId, Date startDate, Date endDate, Integer returnState, Integer deliverState, Integer pageSize, Integer pageNo);
 }
 }

+ 81 - 38
huimv-manage/src/main/java/com/huimv/manage/eartag/service/impl/ApplyServiceImpl.java

@@ -6,15 +6,23 @@ import com.huimv.manage.dao.entity.EtApplyEntity;
 import com.huimv.manage.dao.repo.EtApplyRepo;
 import com.huimv.manage.dao.repo.EtApplyRepo;
 import com.huimv.manage.eartag.service.IApplyService;
 import com.huimv.manage.eartag.service.IApplyService;
 import com.huimv.manage.util.Const;
 import com.huimv.manage.util.Const;
+import com.huimv.manage.util.DataUtil;
 import com.huimv.manage.util.Result;
 import com.huimv.manage.util.Result;
 import com.huimv.manage.util.ResultCode;
 import com.huimv.manage.util.ResultCode;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.ExampleMatcher;
+//import org.springframework.cglib.core.Predicate;
+import org.springframework.data.domain.*;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 
+import javax.persistence.criteria.*;
 import java.sql.Timestamp;
 import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 import java.util.Optional;
 import java.util.Optional;
 
 
 /**
 /**
@@ -26,40 +34,74 @@ import java.util.Optional;
  * @Create : 2020-12-25
  * @Create : 2020-12-25
  **/
  **/
 @Service
 @Service
+@Slf4j
 public class ApplyServiceImpl implements IApplyService {
 public class ApplyServiceImpl implements IApplyService {
-
+    @Autowired
+    private DataUtil dataUtil;
     @Autowired
     @Autowired
     private EtApplyRepo applyRepo;
     private EtApplyRepo applyRepo;
 
 
     /**
     /**
-     * @Method      : listApply
+     * @Method : listApply
      * @Description : 所有任务展示列表
      * @Description : 所有任务展示列表
-     * @Params      : []
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/28       
-     * @Time        : 18:20
+     * @Params : []
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/28
+     * @Time : 18:20
      */
      */
     @Override
     @Override
     public Result listApply() {
     public Result listApply() {
         //
         //
-        return new Result(ResultCode.SUCCESS,applyRepo.listApply());
+        return new Result(ResultCode.SUCCESS, applyRepo.listApply());
+    }
+
+    @Override
+    public Result listApply(Integer applyId, Date startDate, Date endDate, Integer returnState, Integer deliverState, Integer pageSize, Integer pageNo) {
+        Specification<EtApplyEntity> sf = (Specification<EtApplyEntity>) (root, criteriaQuery, criteriaBuilder) -> {
+            //
+            List<Predicate> predList = new ArrayList<>();
+            if (null != applyId) {
+                predList.add(criteriaBuilder.equal(root.get("applyId").as(Integer.class), applyId));
+            }
+            if (null != startDate) {
+                predList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("startDate").as(Date.class), startDate));
+            }
+            if (null != endDate) {
+                predList.add(criteriaBuilder.lessThanOrEqualTo(root.get("endDate").as(Date.class), endDate));
+            }
+            if (null != returnState) {
+                predList.add(criteriaBuilder.equal(root.get("returnState").as(Integer.class), returnState));
+            }
+            if (null != deliverState) {
+                predList.add(criteriaBuilder.equal(root.get("deliverState").as(Integer.class), deliverState));
+            }
+            //
+            Predicate[] pred = new Predicate[predList.size()];
+            Predicate and = criteriaBuilder.and(predList.toArray(pred));
+            criteriaQuery.where(and);
+            //
+            List<Order> orders = new ArrayList<>();
+            orders.add(criteriaBuilder.desc(root.get("id")));
+            return criteriaQuery.orderBy(orders).getRestriction();
+        };
+        Pageable pageable = PageRequest.of( pageNo - 1, pageSize);
+//        return new Result(ResultCode.SUCCESS,applyRepo.listApply(pageable,applyId));
+        return new Result(ResultCode.SUCCESS, applyRepo.findAll(sf, pageable));
     }
     }
 
 
     /**
     /**
-     * @Method      : saveNewMission
+     * @Method : saveNewMission
      * @Description : 保存新任务(号)
      * @Description : 保存新任务(号)
-     * @Params      : [applyJa]
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/28       
-     * @Time        : 18:20
+     * @Params : [applyJa]
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/28
+     * @Time : 18:20
      */
      */
     @Override
     @Override
     public Result saveNewMission(JSONArray applyJa) {
     public Result saveNewMission(JSONArray applyJa) {
-        for(int a=0;a<applyJa.size();a++){
+        for (int a = 0; a < applyJa.size(); a++) {
             JSONObject applyJo = applyJa.getJSONObject(a);
             JSONObject applyJo = applyJa.getJSONObject(a);
             EtApplyEntity applyEntity = new EtApplyEntity();
             EtApplyEntity applyEntity = new EtApplyEntity();
             applyEntity.setMissionProcessor(applyJo.getString("missionProcessor"));
             applyEntity.setMissionProcessor(applyJo.getString("missionProcessor"));
@@ -88,18 +130,18 @@ public class ApplyServiceImpl implements IApplyService {
     public JSONArray filterExistApply(JSONArray downloadApplyJa) {
     public JSONArray filterExistApply(JSONArray downloadApplyJa) {
         JSONArray newApplyJa = new JSONArray();
         JSONArray newApplyJa = new JSONArray();
 
 
-        for(int a=0;a<downloadApplyJa.size();a++){
+        for (int a = 0; a < downloadApplyJa.size(); a++) {
             JSONObject downApplyJo = downloadApplyJa.getJSONObject(a);
             JSONObject downApplyJo = downloadApplyJa.getJSONObject(a);
 //            System.out.println("downApplyJo>>"+downApplyJo);
 //            System.out.println("downApplyJo>>"+downApplyJo);
 //            System.out.println("applyId>>"+downApplyJo.getIntValue("applyId"));
 //            System.out.println("applyId>>"+downApplyJo.getIntValue("applyId"));
             EtApplyEntity applyEntity = new EtApplyEntity();
             EtApplyEntity applyEntity = new EtApplyEntity();
             applyEntity.setApplyId(downApplyJo.getIntValue("applyId"));
             applyEntity.setApplyId(downApplyJo.getIntValue("applyId"));
             ExampleMatcher matcher = ExampleMatcher.matching()
             ExampleMatcher matcher = ExampleMatcher.matching()
-                    .withMatcher("apply_id" ,ExampleMatcher.GenericPropertyMatchers.contains());
-            Example example = Example.of(applyEntity,matcher);
+                    .withMatcher("apply_id", ExampleMatcher.GenericPropertyMatchers.contains());
+            Example example = Example.of(applyEntity, matcher);
 //            boolean applyExistBln = applyRepo.exists(example);
 //            boolean applyExistBln = applyRepo.exists(example);
 //            System.out.println("applyExistBln>>"+applyExistBln);
 //            System.out.println("applyExistBln>>"+applyExistBln);
-            if(!applyRepo.exists(example)){
+            if (!applyRepo.exists(example)) {
                 newApplyJa.add(downApplyJo);
                 newApplyJa.add(downApplyJo);
             }
             }
         }
         }
@@ -107,31 +149,32 @@ public class ApplyServiceImpl implements IApplyService {
     }
     }
 
 
     /**
     /**
-     * @Method      : setMissionHasDownloadState
-     * @Description : 
-     * @Params      : [applyId, state]
-     * @Return      : com.huimv.manage.util.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/10/29       
-     * @Time        : 15:36
+     * @Method : setMissionHasDownloadState
+     * @Description :
+     * @Params : [applyId, state]
+     * @Return : com.huimv.manage.util.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/10/29
+     * @Time : 15:36
      */
      */
     @Override
     @Override
     public Result setMissionHasDownloadState(int applyId, int state) {
     public Result setMissionHasDownloadState(int applyId, int state) {
         EtApplyEntity applyEntity = new EtApplyEntity();
         EtApplyEntity applyEntity = new EtApplyEntity();
         applyEntity.setApplyId(applyId);
         applyEntity.setApplyId(applyId);
         ExampleMatcher matcher = ExampleMatcher.matching()
         ExampleMatcher matcher = ExampleMatcher.matching()
-                .withMatcher("apply_id" ,ExampleMatcher.GenericPropertyMatchers.contains());
-        Example example = Example.of(applyEntity,matcher);
-        Optional optional= applyRepo.findOne(example);
-        if (optional.isPresent()){
-            EtApplyEntity applyEntity1  = (EtApplyEntity) optional.get();
+                .withMatcher("apply_id", ExampleMatcher.GenericPropertyMatchers.contains());
+        Example example = Example.of(applyEntity, matcher);
+        Optional optional = applyRepo.findOne(example);
+        if (optional.isPresent()) {
+            EtApplyEntity applyEntity1 = (EtApplyEntity) optional.get();
             applyEntity1.setSetDownState(state);
             applyEntity1.setSetDownState(state);
             applyEntity1.setSetDownDate(new Timestamp(new Date().getTime()));
             applyEntity1.setSetDownDate(new Timestamp(new Date().getTime()));
             applyRepo.saveAndFlush(applyEntity1);
             applyRepo.saveAndFlush(applyEntity1);
             return new Result(ResultCode.SUCCESS);
             return new Result(ResultCode.SUCCESS);
-        }else{
-            return new Result(Const.CODE_NO_RECORD,Const.NO_RECORD,false);
+        } else {
+            return new Result(Const.CODE_NO_RECORD, Const.NO_RECORD, false);
         }
         }
     }
     }
+
+
 }
 }

+ 32 - 0
huimv-manage/src/main/java/com/huimv/manage/util/DataUtil.java

@@ -0,0 +1,32 @@
+package com.huimv.manage.util;
+
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class DataUtil {
+
+    //解析日期
+    public Date parseDate(String date) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.parse(sdf.format(sdf.parse(date).getTime()));
+    }
+
+    //解析日期和时间
+    public Date parseDateTime(String dateTime) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdfmat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdfmat.parse(sdfmat.format(sdf.parse(dateTime).getTime()));
+    }
+}