|
@@ -10,7 +10,10 @@ import com.dahuatech.icc.oauth.http.DefaultClient;
|
|
|
import com.dahuatech.icc.oauth.http.IClient;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
import com.huimv.common.utils.StringUtilsWork;
|
|
|
+import com.huimv.video.dhicc.result.R;
|
|
|
+import com.huimv.video.dhicc.util.GetResponse;
|
|
|
import com.huimv.video.dhicc.util.HttpClient;
|
|
|
+import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -19,10 +22,9 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.huimv.video.dhicc.icc.CommonConstant.IPAndPort;
|
|
|
|
|
@@ -31,32 +33,128 @@ import static com.huimv.video.dhicc.icc.CommonConstant.IPAndPort;
|
|
|
public class AiFaceController {
|
|
|
|
|
|
//这个接口里面的条件还是后端来写死吧 后端写比前端写简单一点
|
|
|
- @RequestMapping("/fr/groups")
|
|
|
- public Result addgroupspeople(HttpServletRequest request,
|
|
|
- @RequestParam(name = "name") String name
|
|
|
+ @RequestMapping("/groups")
|
|
|
+ public R addgroupspeople(HttpServletRequest request,
|
|
|
+ @RequestParam(name = "farmId") Integer farmId
|
|
|
) throws Exception {
|
|
|
- System.out.println(name);
|
|
|
- //这儿直接写死了
|
|
|
- String URL = "http://36.26.62.70:10080/api/fr/groups";
|
|
|
- System.out.println(URL);
|
|
|
- //发送请求
|
|
|
- HttpClient httpClient = new HttpClient(URL);
|
|
|
- httpClient.setHttps(false);
|
|
|
- httpClient.addParameter("name", name);
|
|
|
- httpClient.post();
|
|
|
- String content = httpClient.getContent();
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
- System.out.println(jsonObject.toJSONString());
|
|
|
- System.out.println("添加底库");
|
|
|
- return new Result(10000, "添加成功",true);
|
|
|
+
|
|
|
+ if(farmId!=1){
|
|
|
+ //返回为空数据
|
|
|
+ return R.ok("当前牧场无设备").put("data", null );
|
|
|
+ }
|
|
|
+
|
|
|
+ GetResponse getResponse = new GetResponse();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ Date date = new Date();
|
|
|
+ c.setTime(date);
|
|
|
+ c.set(Calendar.MINUTE, 0);
|
|
|
+ c.set(Calendar.SECOND, 0);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, +2);
|
|
|
+ Date A = c.getTime();
|
|
|
+ String formatA = format.format(A);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date B = c.getTime();
|
|
|
+ String formatB = format.format(B);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date C = c.getTime();
|
|
|
+ String formatC = format.format(C);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date D = c.getTime();
|
|
|
+ String formatD = format.format(D);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date E = c.getTime();
|
|
|
+ String formatE = format.format(E);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date F = c.getTime();
|
|
|
+ String formatF = format.format(F);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date G = c.getTime();
|
|
|
+ String formatG = format.format(G);
|
|
|
+
|
|
|
+ c.add(Calendar.HOUR, -2);
|
|
|
+ Date H = c.getTime();
|
|
|
+ String formatH = format.format(H);
|
|
|
+
|
|
|
+ List result = new ArrayList();
|
|
|
+
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ map1.put("time",splitTimeByHoure(B));
|
|
|
+ map1.put("value",getCountByHoure( B , A ));
|
|
|
+
|
|
|
+ Map map2 = new HashMap();
|
|
|
+ map2.put("time",splitTimeByHoure(C));
|
|
|
+ map2.put("value",getCountByHoure( C , B));
|
|
|
+
|
|
|
+ Map map3 = new HashMap();
|
|
|
+ map3.put("time",splitTimeByHoure(D));
|
|
|
+ map3.put("value",getCountByHoure(D, C));
|
|
|
+
|
|
|
+ Map map4 = new HashMap();
|
|
|
+ map4.put("time",splitTimeByHoure(E));
|
|
|
+ map4.put("value",getCountByHoure(E , D));
|
|
|
+
|
|
|
+
|
|
|
+ Map map5 = new HashMap();
|
|
|
+ map5.put("time",splitTimeByHoure(F));
|
|
|
+ map5.put("value",getCountByHoure( F ,E));
|
|
|
+
|
|
|
+
|
|
|
+ Map map6 = new HashMap();
|
|
|
+ map6.put("time",splitTimeByHoure(G));
|
|
|
+ map6.put("value",getCountByHoure( G , F));
|
|
|
+
|
|
|
+ Map map7 = new HashMap();
|
|
|
+ map7.put("time",splitTimeByHoure(H));
|
|
|
+ map7.put("value",getCountByHoure(H , G));
|
|
|
+
|
|
|
+ result.add(map1);
|
|
|
+ result.add(map2);
|
|
|
+ result.add(map3);
|
|
|
+ result.add(map4);
|
|
|
+ result.add(map5);
|
|
|
+ result.add(map6);
|
|
|
+ result.add(map7);
|
|
|
+ //翻转
|
|
|
+ Collections.reverse(result);
|
|
|
+ return R.ok("请求成功").put("data", result ).put("namalCount",12).put("alarmCount",45);
|
|
|
}
|
|
|
|
|
|
+ public String getCountByHoure(Date startTime ,Date EndTime) throws IOException {
|
|
|
|
|
|
|
|
|
+ long startTimes = startTime.getTime();
|
|
|
+ long endTimes = EndTime.getTime();
|
|
|
|
|
|
+ //这儿直接写死了--只查那=南门口
|
|
|
+ //开始时间 结束时间
|
|
|
+ String URL = "http://36.26.62.70:10080/api/pass_records?_t=1640069918983&start_page=1&page_count=3000&begin_time="+startTimes+"&end_time="+endTimes+"&camera_id=5";
|
|
|
+ // System.out.println(URL);
|
|
|
+ //发送请求
|
|
|
+ HttpClient httpClient = new HttpClient(URL);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+ System.out.println(content.toString());
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ JSONObject data1 = JSONObject.parseObject(jsonObject.get("data").toString());
|
|
|
+ return data1.get("total").toString();
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
+ public String splitTimeByHoure(Date date) throws ParseException {
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("HH:mm");//设置日期格式,这里只取出小时和分钟
|
|
|
+ String format = df.format(date);
|
|
|
+ return format;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|