Parcourir la source

修改猪舍档案

523096025 il y a 4 ans
Parent
commit
5db25ad191

+ 0 - 33
shiwan/admin/src/main/java/com/huimv/admin/analyse/AITest.java

@@ -1,33 +0,0 @@
-package com.huimv.admin.analyse;
-
-import com.huimv.admin.utils.HttpClient;
-import org.apache.http.HttpResponse;
-import org.apache.http.util.EntityUtils;
-
-import javax.servlet.http.HttpUtils;
-import java.util.HashMap;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.admin.analyse
- * @Description : TODO
- * @Author : yuxuexuan
- * @Create : 2020/12/26 0026 19:53
- **/
-
-public class AITest {
-    public static void main(String[] args) throws Exception {
-
-        String access_token_url = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials" +
-                "&client_id=" + APIConstants.API_KEY
-                + "&client_secret=" + APIConstants.SECRET_KEY;
-
-        HttpClient httpClient = new HttpClient(access_token_url);
-        httpClient.setHttps(false);
-        httpClient.get();
-
-        String content = httpClient.getContent();
-        System.out.println(content);
-
-    }
-}

+ 0 - 42
shiwan/admin/src/main/java/com/huimv/admin/analyse/APIConstants.java

@@ -1,42 +0,0 @@
-package com.huimv.admin.analyse;
-
-import com.baidu.aip.face.AipFace;
-import org.json.JSONObject;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.admin.analyse
- * @Description : TODO
- * @Author : yuxuexuan
- * @Create : 2020/12/26 0026 19:41
- **/
-public class APIConstants {
-    //设置APPID/AK/SK
-    public static final String APP_ID = "23396383";
-    public static final String API_KEY = "EiCulalmXcwLlxqicQrlYdxe";
-    public static final String SECRET_KEY = "YYWBzZqyx6CTtzA9ldmfMME85AXMNTlx";
-
-   /* public static void main(String[] args) {
-        // 初始化一个AipFace
-        AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);
-
-        // 可选:设置网络连接参数
-        client.setConnectionTimeoutInMillis(2000);
-        client.setSocketTimeoutInMillis(60000);
-
-        // 可选:设置代理服务器地址, http和socket二选一,或者均不设置
-       // client.setHttpProxy("proxy_host", proxy_port);  // 设置http代理
-       // client.setSocketProxy("proxy_host", proxy_port);  // 设置socket代理
-
-        // 调用接口
-        String image = "取决于image_type参数,传入BASE64字符串或URL字符串或FACE_TOKEN字符串";
-        String imageType = "BASE64";
-
-        // 人脸检测
-        JSONObject res = client.detect(image, imageType, options);
-        System.out.println(res.toString(2));
-
-    }*/
-}
-
-

+ 0 - 36
shiwan/admin/src/main/java/com/huimv/admin/analyse/Comparison.java

@@ -1,36 +0,0 @@
-package com.huimv.admin.analyse;
-
-import com.alibaba.fastjson.JSON;
-import com.baidu.aip.face.AipFace;
-import com.baidu.aip.face.MatchRequest;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.admin.analyse
- * @Description : TODO
- * @Author : yuxuexuan
- * @Create : 2020/12/27 0027 14:11
- **/
-public class Comparison {
-
-
-   public void Comparison(AipFace client){
-       String image1 = "C:/Users/Administrator/Desktop/1609048902097.jpg";
-       String image2 = "C:/Users/Administrator/Desktop/1609048912029.jpg";
-
-       // image1/image2也可以为url或facetoken, 相应的imageType参数需要与之对应。
-       MatchRequest req1 = new MatchRequest(image1, "BASE64");
-       MatchRequest req2 = new MatchRequest(image2, "BASE64");
-       ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
-       requests.add(req1);
-       requests.add(req2);
-
-       JSONObject res = client.match(requests);
-       System.out.println(res.toString(2));
-
-   }
-}

+ 0 - 70
shiwan/admin/src/main/java/com/huimv/admin/analyse/Sample.java

@@ -1,70 +0,0 @@
-package com.huimv.admin.analyse;
-
-import com.baidu.aip.face.AipFace;
-import com.baidu.aip.http.AipRequest;
-import com.baidu.aip.util.Base64Util;
-import com.baidu.aip.util.Util;
-import org.json.JSONObject;
-
-import java.io.IOException;
-import java.util.Base64;
-import java.util.HashMap;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.admin.analyse
- * @Description : TODO
- * @Author : yuxuexuan
- * @Create : 2020/12/27 0027 13:21
- **/
-
-public class Sample {
-
-    public static final String APP_ID = "23396383";
-    public static final String API_KEY = "EiCulalmXcwLlxqicQrlYdxe";
-    public static final String SECRET_KEY = "YYWBzZqyx6CTtzA9ldmfMME85AXMNTlx";
-    public static void main(String[] args) throws IOException {
-        //初始化一个FaceClient
-        AipFace face = new AipFace(APP_ID,API_KEY ,SECRET_KEY);
-      /*  //可选:设置网络连接参数
-        face.setConnectionTimeoutInMillis(60000);
-        face.setSocketTimeoutInMillis(60000);
-        //调用API
-        HashMap map = new HashMap();
-        //
-        map.put("face_fields", "age,beauty,expression,gender,glasses,race,qualities");
-        String path = "G:/BaiduNetdiskDownload/pc/wallhaven-9mxjqk.png";
-        AipRequest aipRequest = new AipRequest();
-        aipRequest.setBody(map);
-        String image = Base64Util.encode(Util.readFileByBytes(path));
-
-        String groupId = "shiwan";
-        String userId = "yxx";
-
-
-        JSONObject result = face.addUser(image,"BASE64",groupId,userId,map);
-        System.out.println(result.toString(2));*/
-      sample(face);
-    }
-
-    public static void sample(AipFace client) throws IOException {
-        // 传入可选参数调用接口
-        HashMap<String, String> options = new HashMap<String, String>();
-        options.put("quality_control", "NORMAL");
-        options.put("liveness_control", "LOW");
-
-        //String path = "G:/BaiduNetdiskDownload/pc/wallhaven-39mdmy.jpg";
-       String path = "C:/Users/Administrator/Desktop/1.jpg";
-        String image = Base64Util.encode(Util.readFileByBytes(path));
-        String imageType = "BASE64";
-        String groupIdList = "shiwan";
-       /* String idCardNumber = "yxx";
-        String name = "shiwan";*/
-
-
-        // 身份验证
-        JSONObject res =  client.search(image, imageType, groupIdList , options);
-        System.out.println(res.toString(2));
-
-    }
-}

+ 0 - 29
shiwan/admin/src/main/java/com/huimv/admin/analyse/Test.java

@@ -1,29 +0,0 @@
-package com.huimv.admin.analyse;
-
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.util.HashMap;
-
-import com.baidu.aip.util.Base64Util;
-import com.huimv.admin.utils.HttpUtils;
-import org.json.JSONObject;
-
-import com.baidu.aip.face.AipFace;
-
-
-public class  Test {
-    public static void main(String[] args) throws Exception {
-        /****************/
-        String Filepath = "G:/BaiduNetdiskDownload/pc/wallhaven-9mxjqk.png";
-        String image = Base64Util.encode(Filepath.getBytes());
-        String url = "https://aip.baidubce.com/rest/2.0/face/v1/detect";
-        String params = URLEncoder.encode("image", "UTF-8") + "=" + URLEncoder.encode(image, "UTF-8") + "&face_fields=age,beauty,expression,gender,glasses,race,qualities";
-        try {
-            HttpUtils httpUtil = new HttpUtils();
-            String result = HttpUtils.post(url, "24.2f135b4b7f7e21953a7cd9dacc14586b.2592000.1611635464.282335-23396383", params);
-            System.out.println(result);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}

+ 1 - 1
shiwan/admin/src/main/java/com/huimv/admin/repo/secondary/DaJqdaRepo.java

@@ -10,7 +10,7 @@ import java.util.List;
 public interface DaJqdaRepo extends JpaRepository<DaJqda, Integer>, JpaSpecificationExecutor<DaJqda> {
 
     @Query(nativeQuery = true ,value = "SELECT MAX(id) FROM da_jqda ")
-    List<String> findMax();
+    List<Integer> findMax();
 
     List<DaJqda> findAllByZSID(Integer ZSID);
 }

+ 4 - 2
shiwan/admin/src/main/java/com/huimv/admin/repo/secondary/DaZsdaRepository.java

@@ -8,8 +8,10 @@ import org.springframework.data.jpa.repository.Query;
 import java.util.List;
 
 public interface DaZsdaRepository extends JpaRepository<DaZsda, Integer>, JpaSpecificationExecutor<DaZsda> {
-	
-	@Query(nativeQuery = true ,value = "select * from da_zsda where ZSMC like %?1% and MCID = 11 and ZFBZ = 0 limit ?2 , ?3")
+    @Query(nativeQuery = true ,value = "select * from da_zsda where MCID = 11 and ZFBZ = 0")
+    List<DaZsda> findAlla();
+
+	@Query(nativeQuery = true ,value = "select * from da_zsda where ZSMC like %?1% and MCID = 11 and ZFBZ = 0  order by XGSJ DESC limit ?2 , ?3")
     List<DaZsda> findAll(String name, Integer startPage, Integer pageSize);
 
     @Query(nativeQuery = true ,value = "SELECT MAX(id) FROM da_zsda ")

+ 26 - 16
shiwan/admin/src/main/java/com/huimv/admin/service/secondary/impl/DaZsdaServiceImpl.java

@@ -1,6 +1,5 @@
 package com.huimv.admin.service.secondary.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.huimv.admin.domain.secondary.DaJqda;
 import com.huimv.admin.domain.secondary.DaZsda;
 import com.huimv.admin.repo.secondary.DaJqdaRepo;
@@ -14,7 +13,6 @@ import org.springframework.stereotype.Service;
 import java.util.*;
 
 @Service
-@DS("thired")
 public class DaZsdaServiceImpl implements DaZsdaService {
 
 	@Autowired
@@ -29,28 +27,32 @@ public class DaZsdaServiceImpl implements DaZsdaService {
 
 			return new Result(ResultCode.FAIL);
 		}
-		try {
+//		try {
 
 			entity.setMcid(11);
-			Integer  id = rep.findMax().get(0);
+
 			entity.setXgsj(new Date());
+			entity.setZfbz(0);
 			rep.save(entity);
 
 
-			String  JQID = jqdaRepo.findMax().get(0);
 
-			String jqid = "000"+(Integer.parseInt(JQID)+1);
+			Integer  id = rep.findMax().get(0);
+			Integer  JQID = jqdaRepo.findMax().get(0);
+			String Jqid =  jqdaRepo.findById(JQID).get().getJQID();
+			String jqid = "000"+(Integer.parseInt(Jqid)+1);
 			DaJqda daJqda =new DaJqda() ;
 			daJqda.setZSID(id);
 			daJqda.setJQID(jqid);
+			daJqda.setXGSJ(new Date());
 
 			jqdaRepo.save(daJqda);
 
 
 			return new Result(ResultCode.SUCCESS);
-		}catch (Exception e){
-			return new Result(ResultCode.FAIL);
-		}
+//		}catch (Exception e){
+//			return new Result(ResultCode.FAIL);
+//		}
 	}
 
 
@@ -78,6 +80,7 @@ public class DaZsdaServiceImpl implements DaZsdaService {
 		try {
 			entity.setMcid(11);
 			entity.setXgsj(new Date());
+			entity.setZfbz(0);
 			rep.save(entity);
 			return new Result(ResultCode.SUCCESS);
 		}catch (Exception e){
@@ -87,16 +90,17 @@ public class DaZsdaServiceImpl implements DaZsdaService {
 
 	@Override
 	public Result findAll(String name , Integer pageNum , Integer pageSize) {
-		try {
+//		try {
 			Map map = new HashMap();
 			Integer startPage = (pageNum-1) * pageSize;
 			List<DaZsda> all = rep.findAll(name,startPage,pageSize);
-			int size = all.size() ;
+			int size = rep.findAlla().size();
 			map.put("total",size);
 			map.put("totalPageNum",(size  +  pageSize  - 1) / pageSize);
-			Map map1 = new HashMap();
+
 			List list = new ArrayList();
 			for (DaZsda daZsda : all) {
+				Map map1 = new HashMap();
 				Integer id = daZsda.getId();
 				map1.put("id",id);
 				map1.put("csq1",daZsda.getCsq1());
@@ -118,15 +122,21 @@ public class DaZsdaServiceImpl implements DaZsdaService {
 				map1.put("zsmc",daZsda.getZsmc());
 				map1.put("zsqy",daZsda.getZsqy());
 				map1.put("ssqy",daZsda.getSsqy());
-				map1.put("jqid",jqdaRepo.findAllByZSID(id).get(0).getJQID());
+				List<DaJqda> allByZSID = jqdaRepo.findAllByZSID(id);
+				if (allByZSID != null && allByZSID.size()>0){
+					map1.put("jqid",allByZSID.get(0).getJQID());
+				}else {
+					map1.put("jqid",null);
+				}
+
 				list.add(map1);
 			}
 			map.put("data",list);
 			
 			return new Result(ResultCode.SUCCESS,map);
-		}catch (Exception e){
-			return new Result(ResultCode.FAIL);
-		}
+//		}catch (Exception e){
+//			return new Result(ResultCode.FAIL);
+//		}
 	}
 
 	@Override

+ 0 - 167
shiwan/admin/src/main/java/com/huimv/admin/utils/HttpClient.java

@@ -1,167 +0,0 @@
-package com.huimv.admin.utils;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.*;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.TrustStrategy;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.util.EntityUtils;
-
-import javax.net.ssl.SSLContext;
-import java.io.IOException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/*****
- * @Author:  yangdi  hm
- * @Description: entity
- ****/
-public   class HttpClient {
-    private String url;
-    private Map<String, String> param;
-    private int statusCode;
-    private String content;
-    private String xmlParam;
-    private boolean isHttps;
-
-    public boolean isHttps() {
-        return isHttps;
-    }
-
-    public  void   setHttps(boolean isHttps) {
-        this.isHttps = isHttps;
-    }
-
-    public String getXmlParam() {
-        return xmlParam;
-    }
-
-    public void setXmlParam(String xmlParam) {
-        this.xmlParam = xmlParam;
-    }
-
-    public HttpClient(String url, Map<String, String> param) {
-        this.url = url;
-        this.param = param;
-    }
-
-    public HttpClient(String url) {
-        this.url = url;
-    }
-
-    public void setParameter(Map<String, String> map) {
-        param = map;
-    }
-
-    public void addParameter(String key, String value) {
-        if (param == null)
-            param = new HashMap<String, String>();
-        param.put(key, value);
-    }
-
-    public void post() throws ClientProtocolException, IOException {
-        HttpPost http = new HttpPost(url);
-        setEntity(http);
-        execute(http);
-    }
-
-    public void put() throws ClientProtocolException, IOException {
-        HttpPut http = new HttpPut(url);
-        setEntity(http);
-        execute(http);
-    }
-
-    public void get() throws ClientProtocolException, IOException {
-        if (param != null) {
-            StringBuilder url = new StringBuilder(this.url);
-            boolean isFirst = true;
-            for (String key : param.keySet()) {
-                if (isFirst) {
-                    url.append("?");
-                }else {
-                    url.append("&");
-                }
-                url.append(key).append("=").append(param.get(key));
-            }
-            this.url = url.toString();
-        }
-        HttpGet http = new HttpGet(url);
-        execute(http);
-    }
-    /**
-     * set http post,put param
-     */
-    private void setEntity(HttpEntityEnclosingRequestBase http) {
-        if (param != null) {
-            List<NameValuePair> nvps = new LinkedList<NameValuePair>();
-            for (String key : param.keySet()) {
-                nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数
-            }
-            http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数
-        }
-        if (xmlParam != null) {
-            http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));
-        }
-    }
-
-    private void execute(HttpUriRequest http) throws ClientProtocolException,
-            IOException {
-        CloseableHttpClient httpClient = null;
-        try {
-            if (isHttps) {
-                SSLContext sslContext = new SSLContextBuilder()
-                        .loadTrustMaterial(null, new TrustStrategy() {
-                            // 信任所有
-                            @Override
-                            public boolean isTrusted(X509Certificate[] chain,
-                                                     String authType)
-                                    throws CertificateException {
-                                return true;
-                            }
-                        }).build();
-                SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
-                        sslContext);
-                httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
-                        .build();
-            } else {
-                httpClient = HttpClients.createDefault();
-            }
-            CloseableHttpResponse response = httpClient.execute(http);
-            try {
-                if (response != null) {
-                    if (response.getStatusLine() != null) {
-                        statusCode = response.getStatusLine().getStatusCode();
-                    }
-                    HttpEntity entity = response.getEntity();
-                    // 响应内容
-                    content = EntityUtils.toString(entity, Consts.UTF_8);
-                }
-            } finally {
-                response.close();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            httpClient.close();
-        }
-    }
-
-    public int getStatusCode() {
-        return statusCode;
-    }
-    public String getContent() throws ParseException, IOException {
-        return content;
-    }
-}