wang-hao-jie
2021-12-09 fdeaff15619f5f2e851f74f7b5e2b203b157856d
违章记录
8个文件已修改
222 ■■■■ 已修改文件
pom.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/DrivingRecordMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IDrivingRecordService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IDrivingRecordServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java 112 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -194,6 +194,7 @@
                <artifactId>selenium-java</artifactId>
                <version>${selenuim.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java
@@ -64,6 +64,9 @@
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private IEventLogService iEventLogService;
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "通过id获取")
    public Result<OrderTask> get(@PathVariable String id) {
@@ -270,6 +273,13 @@
            }
        }
        iOrderTaskService.saveOrUpdate(orderTask);
        Car car = iCarService.getById(orderTask.getCarId());
        EventLog eventLog = new EventLog();
        eventLog.setCarNo(car.getCarNo());
        eventLog.setRefId(orderId);
        eventLog.setType(6);//6:配送完成
        iEventLogService.saveOrUpdate(eventLog);
        return ResultUtil.success("添加成功");
    }
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java
@@ -13,6 +13,7 @@
import cn.exrick.xboot.your.service.IOrderTaskService;
import cn.exrick.xboot.your.util.HaiKangPost;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
@@ -45,6 +46,9 @@
    @Autowired
    private ICarService iCarService;
    @Autowired
    private HaiKangPost haiKangPost;
    @RequestMapping(value = "/getIndex1", method = RequestMethod.GET)
    @ApiOperation(value = "获取首页数据")
@@ -81,13 +85,16 @@
        return new ResultUtil<Object>().setData(data.getRecords());
    }
//    @RequestMapping(value = "/getCars", method = RequestMethod.GET)
//    @ApiOperation(value = "获取车辆信息")
//    public Result<Object> getCars() {
//        List<Car> list = iCarService.list();
//        String codes[] = new String[list.size()];
//
//        HaiKangPost.findLatestGps()
//        return new ResultUtil<Object>().setData(data.getRecords());
//    }
    @RequestMapping(value = "/getCars", method = RequestMethod.GET)
    @ApiOperation(value = "获取车辆定位信息")
    public Result<Object> getCars() {
        List<Car> list = iCarService.list();
        String codes[] = new String[list.size()];
        for(int i=0;i<list.size();i++){
            codes[i] = list.get(i).getCode();
        }
        String latestGps = haiKangPost.findLatestGps(codes);
        return new ResultUtil<Object>().setData(JSONUtil.parseObj(latestGps));
    }
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/DrivingRecordMapper.java
@@ -17,4 +17,7 @@
    @Select("select min(mileage) from t_driving_record where user_id=#{userId}")
    Integer minByUserId(String userId);
    @Select("select sum(likes) from t_driving_record where user_id=#{userId}")
    Integer sumLikeByUserId(String userId);
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java
@@ -33,8 +33,11 @@
    @Autowired
    private ICustomerService iCustomerService;
    @Autowired
    private IAlarmService iAlarmService;
    @Scheduled(cron="0 0 * * * ?")//每晚凌晨1点执行
    public void execute() throws IOException {
    public void execute(){
        List<User> all = userService.findAll();
        for(User user:all){
            Integer type2 = user.getType2();
@@ -51,49 +54,65 @@
                    Integer max = iDrivingRecordService.maxByUserId(user.getId());
                    Integer min = iDrivingRecordService.minByUserId(user.getId());
                    if(max==null||min==null){
                        one.setSafeDriving(0);
                        one.setDriving(0);
                        one.setSafeDriving(0);//安全驾驶里程
                        one.setDriving(0);//驾驶里程
                    }else{
                        one.setSafeDriving(max-min);
                        one.setDriving(max-min);
                        one.setSafeDriving(max-min);//安全驾驶里程
                        one.setDriving(max-min);//驾驶里程
                    }
                    QueryWrapper<DrivingRecord> wrapper2 = new QueryWrapper<>();
                    wrapper2.eq("user_id",user.getId());
                    int count = iDrivingRecordService.count(wrapper2);
                    one.setOutCar(count);
                    one.setOutCar(count);//出车次数
                    one.setLikes(iDrivingRecordService.sumLikeByUserId(user.getId()));//点赞数
                    QueryWrapper<Alarm> wrapper3 = new QueryWrapper<>();
                    wrapper3.eq("car_user_id",user.getId());
                    wrapper3.eq("type",1);
                    one.setFatigueDriving(iAlarmService.count(wrapper3));//疲劳驾驶
                    wrapper3.eq("type",3);
                    one.setNoBelt(iAlarmService.count(wrapper3));//不系安全带
                    wrapper3.eq("type",4);
                    one.setSmoking(iAlarmService.count(wrapper3));//抽烟
                    wrapper3.eq("type",2);
                    one.setPhone(iAlarmService.count(wrapper3));//接打电话
                }
                //配送员
                if(type2==1){
                    QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<>();
                    wrapper2.eq("user_id",user.getId());
                    int count = iOrderTaskService.count(wrapper2);
                    one.setSends(count);//配送次数
                    wrapper2.ne("status",0);
                    int count2 = iOrderTaskService.count(wrapper2);
                    wrapper2.ne("level",0);
                    wrapper2.gt("level",2);
                    int count5 = iOrderTaskService.count(wrapper2);
                    if(count2==0){
                        one.setLikesRate(0);
                    }else{
                        int rate = (count5/count2)*100;
                        one.setLikesRate(rate);
                    }
                    one.setSends(count);
                    one.setSends2(count2);
                    one.setSends2(count2);//送达次数
                    QueryWrapper<Area> wrapper3 = new QueryWrapper<>();
                    wrapper3.eq("user_id",user.getId());
                    Area area = iAreaService.getOne(wrapper3);
                    if(area!=null){
                        QueryWrapper<Customer> wrapper4 = new QueryWrapper<>();
                        wrapper4.eq("area_id",area.getId());
                        int count3 = iCustomerService.count(wrapper4);
                        one.setService(count3);
                        one.setService(count3);//服务商户数
                    }
                    int i = iOrderTaskService.countLike();
                    one.setLikes(i);//点赞次数
                    int likeCount = iOrderTaskService.count();
                    if(likeCount==0){
                        one.setLikesRate(0);//点赞率
                    }else{
                        one.setLikesRate((i*100)/likeCount);//点赞率
                    }
                    QueryWrapper<Alarm> wrapper4 = new QueryWrapper<>();
                    wrapper4.eq("follow_user_id",user.getId());
                    wrapper4.eq("type",5);
                    one.setAbnormalOpen(iAlarmService.count(wrapper4));//异常开启
                }
                iUserStatisticService.saveOrUpdate(one);
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IDrivingRecordService.java
@@ -14,4 +14,6 @@
    Integer maxByUserId(String id);
    Integer minByUserId(String id);
    int sumLikeByUserId(String id);
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IDrivingRecordServiceImpl.java
@@ -33,4 +33,14 @@
    public Integer minByUserId(String userId) {
        return drivingRecordMapper.minByUserId(userId);
    }
    @Override
    public int sumLikeByUserId(String userId) {
        Integer i = drivingRecordMapper.sumLikeByUserId(userId);
        if(i==null){
            return 0;
        }else{
            return i;
        }
    }
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java
@@ -1,37 +1,40 @@
package cn.exrick.xboot.your.util;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import cn.exrick.xboot.your.vo.FindHistoryGpsRequest;
import cn.exrick.xboot.your.vo.PlaybackURLsVo;
import cn.exrick.xboot.your.vo.PreviewURLsVo;
import cn.exrick.xboot.your.vo.TalkURLsVo;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.hikvision.artemis.sdk.Client;
import com.hikvision.artemis.sdk.Request;
import com.hikvision.artemis.sdk.Response;
import com.hikvision.artemis.sdk.constant.Constants;
import com.hikvision.artemis.sdk.enums.Method;
import org.springframework.stereotype.Component;
/**
 * 海康车机接口
 */
@Component
public class HaiKangPost {
    /**
     * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
     */
    static {
        ArtemisConfig.host = "111.63.178.115:1443";// 平台门户/nginx的IP和端口(必须使用https协议,https端口默认为443)
        ArtemisConfig.appKey = "28156526"; // 秘钥appkey
        ArtemisConfig.appSecret = "MNkyjHuids4XxFONSOaL";// 秘钥appSecret
    }
    /**
     * STEP2:设置OpenAPI接口的上下文
     */
    private static final String ARTEMIS_PATH = "/artemis";
    private static final String HOST = "111.63.178.115:1443";
    private static final String APP_KEY = "28156526";
    private static final String APP_SECRET = "MNkyjHuids4XxFONSOaL";
    //根据车辆编号及时段获取历史定位信息
    public static String findHistoryGps(FindHistoryGpsRequest findHistoryGpsRequest){
    public String findHistoryGps(FindHistoryGpsRequest findHistoryGpsRequest){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/gps/findHistoryGps";
        Map<String,String> path = new HashMap<String,String>(2){
            {
@@ -39,12 +42,12 @@
            }
        };
        String body= JSONUtil.toJsonStr(findHistoryGpsRequest);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        String result = doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
    //查询指定车辆编号的最新定位
    public static String findLatestGps(String[] code){
    public String findLatestGps(String[] code){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/gps/findLatestGps";
        Map<String,String> path = new HashMap<String,String>(2){
            {
@@ -52,12 +55,12 @@
            }
        };
        String body= JSONUtil.toJsonStr(code);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        String result = doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
    //获取监控点预览取流URL
    public static String previewURLs(PreviewURLsVo previewURLsVo){
    public String previewURLs(PreviewURLsVo previewURLsVo){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/previewURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
@@ -65,12 +68,12 @@
            }
        };
        String body= JSONUtil.toJsonStr(previewURLsVo);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        String result = doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
    //获取监控点回放取流URL
    public static String playbackURLs(PlaybackURLsVo playbackURLsVo){
    public String playbackURLs(PlaybackURLsVo playbackURLsVo){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/playbackURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
@@ -78,12 +81,12 @@
            }
        };
        String body= JSONUtil.toJsonStr(playbackURLsVo);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        String result = doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
    //语音对讲
    public static String talkURLs(TalkURLsVo talkURLsVo){
    public String talkURLs(TalkURLsVo talkURLsVo){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/talkURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
@@ -91,12 +94,12 @@
            }
        };
        String body= JSONUtil.toJsonStr(talkURLsVo);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        String result = doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
    //按事件类型获取事件订阅信息
    public static String getTopicInfo(){
    public String getTopicInfo(){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/common/v1/event/getTopicInfo";
        Map<String,String> path = new HashMap<String,String>(2){
            {
@@ -108,20 +111,69 @@
        map.put("eventTypes",eventTypes);
        String body= JSONUtil.toJsonStr(map);
        System.out.println(body);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        String result = doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
    public static void main(String[] args) {
        getTopicInfo();
    public String doPostStringArtemis(Map<String, String> path, String body, Map<String, String> querys, String accept, String contentType) {
        String httpSchema = (String)path.keySet().toArray()[0];
        if (httpSchema != null && !StrUtil.isEmpty(httpSchema)) {
            String responseStr = null;
//        FindHistoryGpsRequest findHistoryGpsRequest = new FindHistoryGpsRequest();
//        findHistoryGpsRequest.setVehicleIndexCode("b279d865eabe497db465eb2f4d2cc87d");
//        findHistoryGpsRequest.setPageNo(1);
//        findHistoryGpsRequest.setPageSize(20);
//        findHistoryGpsRequest.setBeginTime("2021-11-25T03:10:01.000+08:00");
//        findHistoryGpsRequest.setEndTime("2021-11-25T12:10:01.000+08:00");
//        System.out.println(findHistoryGps(findHistoryGpsRequest));
            try {
                Map<String, String> headers = new HashMap();
                if (StrUtil.isNotBlank(accept)) {
                    headers.put("Accept", accept);
                } else {
                    headers.put("Accept", "*/*");
                }
                if (StrUtil.isNotBlank(contentType)) {
                    headers.put("Content-Type", contentType);
                } else {
                    headers.put("Content-Type", "application/text;charset=UTF-8");
                }
                Request request = new Request(Method.POST_STRING, httpSchema + HOST, (String)path.get(httpSchema), APP_KEY, APP_SECRET, Constants.DEFAULT_TIMEOUT);
                request.setHeaders(headers);
                request.setQuerys(querys);
                request.setStringBody(body);
                Response response = Client.execute(request);
                responseStr = getResponseResult2(response);
            } catch (Exception var10) {
            }
            return responseStr;
        } else {
            throw new RuntimeException("http和https参数错误httpSchema: " + httpSchema);
        }
    }
    private String getResponseResult2(Response response) {
        String responseStr = null;
        int statusCode = response.getStatusCode();
        if (!String.valueOf(statusCode).startsWith("2") && !String.valueOf(statusCode).startsWith("3")) {
            String msg = response.getErrorMessage();
            responseStr = response.getBody();
        } else {
            responseStr = response.getBody();
        }
        return responseStr;
    }
    public static void main(String[] args) {
        //getTopicInfo();
        FindHistoryGpsRequest findHistoryGpsRequest = new FindHistoryGpsRequest();
        findHistoryGpsRequest.setVehicleIndexCode("b279d865eabe497db465eb2f4d2cc87d");
        findHistoryGpsRequest.setPageNo(1);
        findHistoryGpsRequest.setPageSize(20);
        findHistoryGpsRequest.setBeginTime("2021-11-25T03:10:01.000+08:00");
        findHistoryGpsRequest.setEndTime("2021-11-25T12:10:01.000+08:00");
        HaiKangPost haiKangPost = new HaiKangPost();
        System.out.println(haiKangPost.findHistoryGps(findHistoryGpsRequest));
//        String code[] = {"b279d865eabe497db465eb2f4d2cc87d"};
//        System.out.println(findLatestGps(code));