111
k94314517
2025-02-20 68057e752bd9767e76c021610966719e3a227467
111
已修改6个文件
97 ■■■■ 文件已修改
server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/src/main/java/com/doumee/core/utils/PositionUtil.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/web/src/main/java/com/doumee/api/web/BusinessApi.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/web/src/main/java/com/doumee/task/ScheduleTool.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java
@@ -10,6 +10,7 @@
import com.doumee.dao.business.model.Sites;
import com.doumee.dao.business.web.request.RepairRequest;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@@ -18,6 +19,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
 * Created by IntelliJ IDEA.
@@ -91,6 +93,26 @@
    }
    public static void lowVoltageNotice(String bikeCode,String place,String siteName,String token,String robotCode,String chatToken)throws Exception{
        String desc = "【低电量提醒】车辆编号:{车辆编号},当前位置:{定位位置},当前站点:{站点名称}。";
        if(StringUtils.isBlank(bikeCode)){
            return;
        }
        desc.replace("{车辆编号}",bikeCode);
        if(StringUtils.isNotBlank(place)){
           desc.replace("{定位位置}",place);
        }else{
            desc.replace("{定位位置}","未知");
        }
        if(StringUtils.isNotBlank(siteName)){
            desc.replace("{站点名称}",siteName);
        }else{
            desc.replace("{站点名称}","未知");
        }
        sendNoticeNew(desc,token,robotCode,chatToken);
    }
    /**
     * 钉钉通知 - 站点储车告警
     * @param siteName
server/services/src/main/java/com/doumee/core/utils/PositionUtil.java
@@ -13,6 +13,7 @@
 * 计算距离
 */
public class PositionUtil {
    public static String getTxMapAddrByLatAndLng(Double lat,Double lng,String host,String mapkey){
        try {
            if(lat == null || lng ==null){
server/web/src/main/java/com/doumee/api/web/BusinessApi.java
@@ -136,7 +136,7 @@
    @LoginRequired
    @ApiOperation(value = "热销套餐", notes = "热销套餐")
    @GetMapping("/discountPage")
    @PostMapping("/discountPage")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
    })
@@ -147,7 +147,16 @@
        return ApiResponse.success(discountService.findPage(pageWrap));
    }
    @LoginRequired
    @ApiOperation(value = "套餐详情", notes = "套餐详情")
    @GetMapping("/discountDetail")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "id", value = "套餐主键", required = true)
    })
    public ApiResponse<Discount> discountPage (@RequestParam String id) {
        return ApiResponse.success(discountService.findById(id));
    }
    @LoginRequired
server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java
@@ -130,7 +130,7 @@
     */
    @AsyncBatch(poolSize = 2, maxElements = 4000, maxWait = 1000)
    @Mapping(types = 位置信息汇报, desc = "位置信息汇报")
    public void T0200(List<T0200> list) {
    public void T0200(List<T0200> list) throws Exception {
        jtt808Service.updateBikesInfo(list);
        System.out.println(JSONObject.toJSONString(list)
      );
server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
@@ -8,12 +8,14 @@
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.Constants;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.dingding.DingDingNotice;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.PositionUtil;
import com.doumee.core.utils.StringTools;
import com.doumee.core.wx.WxMiniUtilService;
import com.doumee.dao.business.*;
import com.doumee.dao.business.join.BikesJoinMapper;
import com.doumee.dao.business.join.GoodsorderJoinMapper;
import com.doumee.dao.business.join.MemberRidesJoinMapper;
import com.doumee.dao.business.join.RefundJoinMapper;
@@ -51,9 +53,9 @@
@Service
public class Jtt808Service {
    @Value("${tencent.map.remoteHost:}")
    @Value("${tencent.map.remoteHost}")
    private String mapHost;
    @Value("${tencent.map.appKey:}")
    @Value("${tencent.map.appKey}")
    private String mapKey;
    @Autowired
    private MessageManager messageManager;
@@ -61,6 +63,8 @@
    private GoodsorderService goodsorderService;
    @Autowired
    private BikesMapper bikesMapper;
    @Autowired
    private BikesJoinMapper bikesJoinMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
@@ -279,8 +283,12 @@
        }
    }
    public void updateBikesInfo(List<T0200> list) {
    public void updateBikesInfo(List<T0200> list) throws Exception{
        Date date = new Date();
        BigDecimal lowVoltage = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.LOW_VOLTAGE).getCode());
        String ddToken = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_TOKEN).getCode();
        String ddRobotCode = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_ROBOTCODE).getCode();
        String ddChatToken = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_CHATTOKEN).getCode();
        for(T0200 m : list){
            Bikes bike = new Bikes();
            bike.setDeviceSn(m.getClientId());
@@ -321,6 +329,17 @@
                    .set(Bikes::getSiteId,site ==null?null:site.getId())
                    .set( Bikes::getHeartDate,date)
                    .eq(Bikes::getId,bikes.getId()));
            if(bikes.getVoltage().compareTo(lowVoltage)>=Constants.ZERO
                    && bike.getVoltage().compareTo(lowVoltage)<Constants.ZERO){
                //发送钉钉通知
                DingDingNotice.lowVoltageNotice(bikes.getCode(),
                        PositionUtil.getTxMapAddrByLatAndLng(Double.valueOf(bike.getLatitude().toString()),Double.valueOf(bike.getLongitude().toString()),mapHost,mapKey)
                        ,Objects.nonNull(site)?site.getName():null,
                        ddToken,
                        ddRobotCode,
                        ddChatToken);
            }
        }
    }
@@ -503,7 +522,7 @@
                .eq(Goodsorder::getStatus,Constants.ONE)
                .eq(MemberRides::getIsdeleted,Constants.ZERO)
                .eq(MemberRides::getType,Constants.ONE)
                .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING)
                .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey())
                .apply(" NOW() >= t.create_date  + INTERVAL '2 hours' ")
        );
@@ -536,11 +555,6 @@
            goodsorder.setEditor(null);
            goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides);
        }
    }
server/web/src/main/java/com/doumee/task/ScheduleTool.java
@@ -10,6 +10,7 @@
import com.doumee.core.wx.WxPayProperties;
import com.doumee.dao.business.model.Sites;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.jtt808.web.service.Jtt808Service;
import com.doumee.service.business.*;
import com.doumee.service.system.SystemDictDataService;
import lombok.extern.slf4j.Slf4j;
@@ -30,22 +31,32 @@
 * @date 2021-10-10 14:40:35
 * https://www.bejson.com/othertools/cron/  cron 表达式生成地址
 */
//@Component
//@EnableScheduling
@Component
@EnableScheduling
@Slf4j
public class ScheduleTool {
    @Autowired
    private Jtt808Service jtt808Service;
    /**
     * 站点车辆满架率预警
     * @throws Exception
     */
    @Scheduled(fixedDelay = 1000L *20L )
    public void reSubMqtt() throws Exception {
        log.info("=====================检查是否需要重新订阅===========start============");
        MqttClientInit.isSubClientValid();
        log.info("=====================检查是否需要重新订阅===========end============");
    }
//    @Scheduled(fixedDelay = 1000L *20L )
//    public void reSubMqtt() throws Exception {
//        log.info("=====================检查是否需要重新订阅===========start============");
//        MqttClientInit.isSubClientValid();
//        log.info("=====================检查是否需要重新订阅===========end============");
//    }
    @Scheduled(fixedDelay = 1000L * 5L )
    public void autoBackBike() throws Exception {
        log.info("=====================临时停车超时 自动还车===========start============");
        jtt808Service.autoBackBike();
        log.info("=====================临时停车超时 自动还车===========end============");
    }
}