| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.core.utils.StringTools; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.ActionLogMapper; |
| | | import com.doumee.dao.business.BikesMapper; |
| | |
| | | update.setBackUserid(user.getId()); |
| | | update.setBackType(Constants.ONE); |
| | | update.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey()); |
| | | update.setBackSiteId(collect.get(Constants.FORCE_BACK_SITE).getCode()); |
| | | update.setBackLockId(Constants.formatIntegerFromStr(collect.get(Constants.FORCE_BACK_LOCK).getCode())); |
| | | String logInfo = null; |
| | | Bikes bike =null; |
| | | if(Constants.equalsInteger(model.getType(),Constants.ZERO)){ |
| | | //如果是自行车,绑定到虚拟站点和锁头 |
| | | update.setBackSiteId(collect.get(Constants.FORCE_BACK_SITE).getCode()); |
| | | update.setBackLockId(Constants.formatIntegerFromStr(collect.get(Constants.FORCE_BACK_LOCK).getCode())); |
| | | //插入虚拟锁头和站点上------- |
| | | bike = new Bikes(); |
| | | bike.setIsdeleted(Constants.ZERO); |
| | | bike.setCode(model.getBikeCode()); |
| | | bike.setType(model.getType()); |
| | | bike.setSiteId(update.getBackSiteId()); |
| | | bike.setLockId(update.getBackLockId()); |
| | | if(bikesMapper.selectCount(new QueryWrapper<>(bike)) == 0){ |
| | | bike.setId(Constants.getUUID()); |
| | | bike.setParamId(model.getParamId()); |
| | | bike.setLastBackDate(model.getRentDate()); |
| | | bike.setStatus(Constants.ZERO); |
| | | bike.setType(Constants.ZERO); |
| | | bike.setInfo("强制还车绑定"); |
| | | bikesMapper.insert(bike); |
| | | } |
| | | }else{ |
| | | //如果是电车,请求web端接口关闭车辆信息 |
| | | bike = sendCloseElecBikeRequest(memberRides.getBikeCode(),Constants.ONE); |
| | | } |
| | | logInfo = bike!=null?bike.getInfo():null; |
| | | Integer freeRentTime = Integer.valueOf(collect.get(Constants.FREE_RENT_TIME).getCode()); |
| | | Integer rideTime = DateUtil.betweenMin(model.getRentDate(), update.getBackDate()); |
| | | //计算骑行计费时长 |
| | |
| | | String beforeContent = JSONObject.toJSONString(model); |
| | | //修改后 |
| | | String after = JSONObject.toJSONString(update); |
| | | |
| | | //插入虚拟锁头和站点上------- |
| | | Bikes bike = new Bikes(); |
| | | bike.setIsdeleted(Constants.ZERO); |
| | | bike.setCode(model.getBikeCode()); |
| | | bike.setType(model.getType()); |
| | | bike.setSiteId(update.getBackSiteId()); |
| | | bike.setLockId(update.getBackLockId()); |
| | | if(bikesMapper.selectCount(new QueryWrapper<>(bike)) == 0){ |
| | | bike.setId(Constants.getUUID()); |
| | | bike.setParamId(model.getParamId()); |
| | | bike.setLastBackDate(model.getRentDate()); |
| | | bike.setStatus(Constants.ZERO); |
| | | bike.setType(Constants.ZERO); |
| | | bike.setInfo("强制还车绑定"); |
| | | bikesMapper.insert(bike); |
| | | } |
| | | |
| | | ActionLog log = new ActionLog(); |
| | | log.setId(Constants.getUUID()); |
| | |
| | | log.setObjType(Constants.ActionLogObjType.memberrides); |
| | | log.setResult(Constants.ZERO); |
| | | log.setObjId(model.getId()); |
| | | log.setInfo(logInfo); |
| | | log.setType(Constants.ACTIONLOG_TYPE.FORCE_BACK.getKey()); |
| | | log.setContent(Constants.ACTIONLOG_TYPE.FORCE_BACK.getInfo()); |
| | | log.setTitle(Constants.ACTIONLOG_TYPE.FORCE_BACK.getName()); |
| | |
| | | actionLogMapper.insert(log); |
| | | |
| | | } |
| | | /** |
| | | * 如果是电车,请求web端接口关闭车辆信息 |
| | | */ |
| | | private Bikes sendCloseElecBikeRequest(String bikeCode,int type) { |
| | | Bikes bike = bikesMapper.selectOne(new QueryWrapper<Bikes>().lambda() |
| | | .eq(Bikes::getType,Constants.ONE) |
| | | .eq(Bikes::getIsdeleted,Constants.ZERO) |
| | | .eq(Bikes::getCode,bikeCode) |
| | | ); |
| | | if(bike == null){ |
| | | return null; |
| | | } |
| | | bike.setInfo("强制还车关闭车锁失败!"); |
| | | if(StringUtils.isNotBlank(bike.getDeviceSn())){ |
| | | try { |
| | | //请求地址 |
| | | String url = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ELEC_BIKE_CONTRIL_API_URL).getCode(); |
| | | JSONObject param = new JSONObject(); |
| | | param.put("clientId",StringTools.leftTrip(bike.getDeviceSn(),'0')); |
| | | param.put("type",type);//0开锁 1关锁 |
| | | String res = HttpsUtil.postJsonString(url,param.toJSONString()); |
| | | JSONObject json = JSONObject.parseObject(res); |
| | | if(json.get("code").equals("200")){ |
| | | //发起指令成功 |
| | | bike.setInfo("强制还车关闭车锁成功!"); |
| | | }else{ |
| | | bike.setInfo("强制还车关闭车锁失败!"+json.get("msg")); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }else{ |
| | | bike.setInfo("强制还车关闭车锁失败,未绑定控制器sn!"); |
| | | } |
| | | bikesMapper.updateById(bike); |
| | | return bike; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String url = "http://localhost:10025/jtt808/device/8500"; |
| | | JSONObject param = new JSONObject(); |
| | | param.put("clientId",StringTools.leftTrip("0067244400211",'0')); |
| | | param.put("type",0);//0开锁 1关锁 |
| | | String res = HttpsUtil.postJsonString(url,param.toJSONString()); |
| | | System.out.println(res); |
| | | } |
| | | public ConcurrentMap<String,Integer> cacheOpenLock = new ConcurrentReferenceHashMap<>(); |
| | | |
| | | @Override |