package com.huimv.video.dhicc.ScreenController; import com.dahuatech.icc.exception.ClientException; import com.huimv.video.dhicc.result.R; import com.huimv.video.dhicc.util.GetResponse; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; import java.util.*; @RestController @RequestMapping("/screen/car") //没有连接ICC的数据库 所以操作比较麻烦 public class ScreenCarController { //过车的数据//这个是车辆闸机的过车数据 /** * 应该优化一下放到表里面去 不然的话这样请求一整页的数据会很慢 * 保存ntamade * 通过开始结束时间来查页数 * &queryTimeBegin=2021-12-01+00%3A00%3A00& * queryTimeEnd=2021-12-01+23%3A59%3A59& */ // https://36.26.62.70:447/evo-apigw/ipms/carcapture/find/conditions?pageNum=1&pageSize=10&queryTimeBegin=2021-12-01+00%3A00%3A00&queryTimeEnd=2021-12-01+23%3A59%3A59&_=1638356246174 @RequestMapping("/count_car_record") public R ddgetCarRecord(HttpServletRequest request ) throws ClientException { 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.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.add(Calendar.DATE, +1); Date A = c.getTime(); String formatA = format.format(A); c.add(Calendar.DATE, -1); Date B = c.getTime(); String formatB = format.format(B); c.add(Calendar.DATE, -1); Date C = c.getTime(); String formatC = format.format(C); c.add(Calendar.DATE, -1); Date D = c.getTime(); String formatD = format.format(D); c.add(Calendar.DATE, -1); Date E = c.getTime(); String formatE = format.format(E); c.add(Calendar.DATE, -1); Date F = c.getTime(); String formatF = format.format(F); c.add(Calendar.DATE, -1); Date G = c.getTime(); String formatG = format.format(G); c.add(Calendar.DATE, -1); Date H = c.getTime(); String formatH = format.format(H); List result = new ArrayList(); Map map1 = new HashMap(); map1.put("time",splitTime(B)); map1.put("value",getResponse.SendMassageGetPage( formatB , formatA )); Map map2 = new HashMap(); map2.put("time",splitTime(C)); map2.put("value",getResponse.SendMassageGetPage( formatC , formatB)); Map map3 = new HashMap(); map3.put("time",splitTime(D)); map3.put("value",getResponse.SendMassageGetPage(formatD, formatC)); Map map4 = new HashMap(); map4.put("time",splitTime(E)); map4.put("value",getResponse.SendMassageGetPage(formatE , formatD)); Map map5 = new HashMap(); map5.put("time",splitTime(F)); map5.put("value",getResponse.SendMassageGetPage( formatF , formatE)); Map map6 = new HashMap(); map6.put("time",splitTime(G)); map6.put("value",getResponse.SendMassageGetPage( formatG , formatF)); Map map7 = new HashMap(); map7.put("time",splitTime(H)); map7.put("value",getResponse.SendMassageGetPage(formatH , formatG)); 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 ); } public String splitTime(Date date){ Calendar calendar = Calendar.getInstance(); calendar.setTime(date); String date1 = calendar.get(Calendar.MONTH)+1+"/"+calendar.get(Calendar.DATE); return date1; } }