Commit 53f18771 authored by 刘林's avatar 刘林

Merge remote-tracking branch 'origin/develop_dl' into develop_dl

parents 9157ffd3 7d5825e3
package com.yeejoin.equipmanage.common.entity.dto;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author DELL
*/
@Data
public class EquipQrDateDto {
/**
* 类型
*/
private String type;
/**
* 对比属性
*/
private String contrast;
/**
* 需要赋码判断的数据
*/
private List<Map<String, String>> data;
}
package com.yeejoin.equipmanage.common.enums;
/**
* 赋码计算规则
* @author DELL
*/
public enum CalculationRulesEnum {
EQ("eq", "等于"),
NE("ne", "不等于"),
GT("gt", "大于"),
GE("ge", "大于等于"),
LT("lt", "小于"),
LE("le", "小于等于");
private String code;
private String type;
CalculationRulesEnum(String code, String type) {
this.code=code;
this.type=type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static CalculationRulesEnum getEnum(String code) {
CalculationRulesEnum calculationRulesEnum = null;
for(CalculationRulesEnum type: CalculationRulesEnum.values()) {
if (type.getCode().equals(code)) {
calculationRulesEnum = type;
break;
}
}
return calculationRulesEnum;
}
}
...@@ -3260,6 +3260,9 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -3260,6 +3260,9 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
public PeopleInfoDto selectPeopleByIdNoAuth(Long id) { public PeopleInfoDto selectPeopleByIdNoAuth(Long id) {
PeopleBasicInfoDto peopleBasicInfoDto = new PeopleBasicInfoDto(); PeopleBasicInfoDto peopleBasicInfoDto = new PeopleBasicInfoDto();
OrgUsr orgUsr = this.baseMapper.selectById(id); OrgUsr orgUsr = this.baseMapper.selectById(id);
QueryWrapper<OrgUsr> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.eq("sequenceNbr", orgUsr.getParentId());
OrgUsr orgUsrParent = this.baseMapper.selectOne(queryWrapper2);
// 动态表单数据 // 动态表单数据
List<FormValue> formValues = getFormValue(id); List<FormValue> formValues = getFormValue(id);
...@@ -3297,7 +3300,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -3297,7 +3300,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
peopleBasicInfoDto.setSequenceNbr(orgUsr.getSequenceNbr().toString()); peopleBasicInfoDto.setSequenceNbr(orgUsr.getSequenceNbr().toString());
peopleBasicInfoDto.setCompany(orgUsr.getParentId()); peopleBasicInfoDto.setCompany(orgUsr.getParentId());
peopleBasicInfoDto.setBizOrgName(orgUsr.getParentName()); peopleBasicInfoDto.setBizOrgName(orgUsr.getParentName());
peopleBasicInfoDto.setBizOrgCode(orgUsr.getBizOrgCode()); peopleBasicInfoDto.setBizOrgCode(orgUsrParent.getBizOrgCode());
peopleBasicInfoDto.setCompanyCode(orgUsr.getParentId()); peopleBasicInfoDto.setCompanyCode(orgUsr.getParentId());
peopleBasicInfoDto.setCompanyName(orgUsr.getParentName()); peopleBasicInfoDto.setCompanyName(orgUsr.getParentName());
peopleBasicInfoDto.setPersonStatus(orgUsr.getPersonStatus()); peopleBasicInfoDto.setPersonStatus(orgUsr.getPersonStatus());
......
package com.yeejoin.equipmanage.action;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.equipmanage.common.entity.dto.EquipQrDateDto;
import com.yeejoin.equipmanage.common.enums.CalculationRulesEnum;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.service.ICarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 赋码动作
* @author DELL
*/
@Component
@RuleActionBean(beanLabel = "动态预案")
@Slf4j
public class UpdateQrCodeAction {
@Autowired
private ICarService carService;
private final String CAR_ID = "carId";
@RuleMethod(methodLabel = "更新码", project = "车辆更新码颜色")
public void updateCarQrCode(@MethodParam(paramLabel = "判断值") String value, @MethodParam(paramLabel = "赋码颜色") String color,
@MethodParam(paramLabel = "判断对象") Object equipQrDateDto, @MethodParam(paramLabel = "是否启用") Boolean enable,
@MethodParam(paramLabel = "计算规则") String rule) {
if (Boolean.TRUE.equals(enable)) {
EquipQrDateDto equipQrDateDtoN = JSONObject.parseObject(equipQrDateDto.toString(), EquipQrDateDto.class);
List<Map<String, String>> data = equipQrDateDtoN.getData();
String contrast = equipQrDateDtoN.getContrast();
if (!CollectionUtils.isEmpty(data)) {
List<String> collect = data.stream().map(map -> {
try {
String carId = null;
String s = map.get(contrast).replace("T", " ");
Date date = DateUtils.longStr2Date(s);
int i = DateUtils.dateBetween(date, new Date());
CalculationRulesEnum anEnum = CalculationRulesEnum.getEnum(rule);
switch (anEnum) {
case EQ:
if (i == Integer.parseInt(value)) {
carId = String.valueOf(map.get(CAR_ID));
}
break;
case GT:
if (i > Integer.parseInt(value)) {
carId = String.valueOf(map.get(CAR_ID));
}
break;
case GE:
if (i >= Integer.parseInt(value)) {
carId = String.valueOf(map.get(CAR_ID));
}
break;
case LE:
if (i <= Integer.parseInt(value)) {
carId = String.valueOf(map.get(CAR_ID));
}
break;
case LT:
if (i < Integer.parseInt(value)) {
carId = String.valueOf(map.get(CAR_ID));
}
break;
case NE:
if (i != Integer.parseInt(value)) {
carId = String.valueOf(map.get(CAR_ID));
}
break;
default:
break;
}
return carId;
} catch (ParseException e) {
log.error("日期转换失败");
e.printStackTrace();
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
carService.updateCarQrCode(collect, color);
}
}
}
}
...@@ -119,6 +119,7 @@ public class CarIotNewListener extends EmqxListener { ...@@ -119,6 +119,7 @@ public class CarIotNewListener extends EmqxListener {
deviceInfo.get(iotCode).interrupt(); deviceInfo.get(iotCode).interrupt();
deviceInfo.remove(iotCode); deviceInfo.remove(iotCode);
} catch (Exception e) { } catch (Exception e) {
deviceInfo.remove(iotCode);
} }
logger.info("topic---------------------" + topic + "开启计时线程"); logger.info("topic---------------------" + topic + "开启计时线程");
ThreadCar threadCar = new ThreadCar(topic, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, clipping_time); ThreadCar threadCar = new ThreadCar(topic, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, clipping_time);
......
...@@ -37,6 +37,6 @@ public interface CarPropertyMapper extends BaseMapper<CarProperty> { ...@@ -37,6 +37,6 @@ public interface CarPropertyMapper extends BaseMapper<CarProperty> {
Map<String, Object> getCarPropertyByCarIds(List<Long> carIds); Map<String, Object> getCarPropertyByCarIds(List<Long> carIds);
List<Map<String, Object>> selectIndexByTime(String carStartIndexKey); List<Map<String, String>> selectIndexByTime(String carStartIndexKey);
} }
package com.yeejoin.equipmanage.quartz; package com.yeejoin.equipmanage.quartz;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.equipmanage.common.entity.dto.EquipQrDateDto;
import com.yeejoin.equipmanage.service.ICarService; import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.impl.CarServiceImpl; import com.yeejoin.equipmanage.service.impl.CarServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -8,6 +10,9 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -8,6 +10,9 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/** /**
* 定时监控车辆相关指标 * 定时监控车辆相关指标
* @author xxz * @author xxz
...@@ -20,13 +25,25 @@ public class CarPropertyJob { ...@@ -20,13 +25,25 @@ public class CarPropertyJob {
@Autowired @Autowired
private ICarService carService; private ICarService carService;
@Autowired
private RuleTrigger ruleTrigger;
/** /**
* 车辆赋红码。定时查询车辆启停更新时间, * 车辆赋红码。定时查询车辆启停更新时间,
*/ */
@Scheduled(cron = "${update.car.qrCode}") @Scheduled(cron = "${update.car.qrCode}")
public void UpdateCarQrCode(){ public void UpdateCarQrCode() {
carService.updateCarStartStatus(); List<Map<String, String>> list = carService.updateCarStartStatus();
EquipQrDateDto equipQrDateDto = new EquipQrDateDto();
equipQrDateDto.setContrast("updateDate");
equipQrDateDto.setType("car");
equipQrDateDto.setData(list);
try {
ruleTrigger.publish(equipQrDateDto, "中心配置赋码规则/update-qr-code", null);
} catch (Exception e) {
log.error("调用规则失败: {}", e.getMessage());
}
} }
} }
...@@ -211,7 +211,12 @@ public interface ICarService extends IService<Car> { ...@@ -211,7 +211,12 @@ public interface ICarService extends IService<Car> {
/** /**
* 查询车辆启动状态,赋码 * 查询车辆启动状态,赋码
*/ */
void updateCarStartStatus(); List<Map<String, String>> updateCarStartStatus();
/**
* 赋码
*/
void updateCarQrCode(List<String> carIds, String status);
} }
...@@ -1969,14 +1969,12 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -1969,14 +1969,12 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
} }
@Override @Override
public void updateCarStartStatus() { public List<Map<String, String>> updateCarStartStatus() {
List<Map<String, Object>> list = carPropertyMapper.selectIndexByTime(CAR_START_INDEX_KEY); return carPropertyMapper.selectIndexByTime(CAR_START_INDEX_KEY);
List<String> carIds = list.stream().map(o -> String.valueOf(o.get("carId"))).collect(Collectors.toList());
// 近七天未启动赋红码
updateCarQrCode(carIds, "2");
} }
private void updateCarQrCode(List<String> carIds, String status) { @Override
public void updateCarQrCode(List<String> carIds, String status) {
carMapper.updateStatusByIds(carIds, status); carMapper.updateStatusByIds(carIds, status);
} }
} }
...@@ -52,9 +52,9 @@ public class IFireResourceSupervisionServiceImpl implements IFireResourceSupervi ...@@ -52,9 +52,9 @@ public class IFireResourceSupervisionServiceImpl implements IFireResourceSupervi
private FireResourceStatsDTO buildFireResourceStatsDTO(Map<String, Object> resultMap) { private FireResourceStatsDTO buildFireResourceStatsDTO(Map<String, Object> resultMap) {
FireResourceStatsDTO fireResourceStats = new FireResourceStatsDTO(); FireResourceStatsDTO fireResourceStats = new FireResourceStatsDTO();
fireResourceStats.setTotalCounts((long) resultMap.get("totalCount")); fireResourceStats.setTotalCounts(Long.valueOf(resultMap.get("totalCount").toString()));
fireResourceStats.setYellowCounts((long) resultMap.get("yellowCodeCount")); fireResourceStats.setYellowCounts(Long.valueOf(resultMap.get("yellowCodeCount").toString()) );
fireResourceStats.setRedCounts((long) resultMap.get("redCodeCount")); fireResourceStats.setRedCounts(Long.valueOf(resultMap.get("redCodeCount").toString()));
long expCount = fireResourceStats.getYellowCounts() + fireResourceStats.getRedCounts(); long expCount = fireResourceStats.getYellowCounts() + fireResourceStats.getRedCounts();
double abnormalRatio = 0; double abnormalRatio = 0;
......
...@@ -3,7 +3,6 @@ package com.yeejoin.equipmanage.service.impl; ...@@ -3,7 +3,6 @@ package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -27,8 +26,10 @@ import org.springframework.scheduling.annotation.EnableAsync; ...@@ -27,8 +26,10 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
...@@ -66,6 +67,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -66,6 +67,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Value("${mileage.parameter}") @Value("${mileage.parameter}")
private Double mileageParameter; private Double mileageParameter;
@Resource
private EmqKeeper emqKeeper;
private static final Logger log = LoggerFactory.getLogger(HttpUtil.class); private static final Logger log = LoggerFactory.getLogger(HttpUtil.class);
private final String GUIDE_KEY = "813684495d9a3981dd2c7694916fe404"; private final String GUIDE_KEY = "813684495d9a3981dd2c7694916fe404";
...@@ -89,7 +93,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -89,7 +93,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
double speed = 0; double speed = 0;
WlCarMileage wlCarMileage = this.getById(id); WlCarMileage wlCarMileage = this.getById(id);
String iotCode = wlCarMileage.getIotCode(); String iotCode = wlCarMileage.getIotCode();
String measurement = "0THMcLKR"; String measurement = iotCode.substring(0,8);
String deviceName = iotCode.replace(measurement, ""); String deviceName = iotCode.replace(measurement, "");
// 由于iot存在毫秒故结束时间要+1秒 iot+1秒有bug还是查不到 +2秒 // 由于iot存在毫秒故结束时间要+1秒 iot+1秒有bug还是查不到 +2秒
ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName, wlCarMileage.getStartTime(), ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName, wlCarMileage.getStartTime(),
...@@ -337,9 +341,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -337,9 +341,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
double startLongitude = lastObj.getDoubleValue("FireCar_Longitude"); double startLongitude = lastObj.getDoubleValue("FireCar_Longitude");
double startLatitude = lastObj.getDoubleValue("FireCar_Latitude"); double startLatitude = lastObj.getDoubleValue("FireCar_Latitude");
// 当前速度 // 当前速度
double v = Double.parseDouble(String.valueOf(lastObj.get("FireCar_Speed"))); Double v = Double.parseDouble(String.valueOf(lastObj.get("FireCar_Speed")));
int ceil = (int) Math.ceil(v); item.setStartSpeed(v.intValue());
item.setStartSpeed(ceil);
double travel = 0.0; double travel = 0.0;
// 获取里程 // 获取里程
for (int i = 0; i < filterList.size() - 1; i++) { for (int i = 0; i < filterList.size() - 1; i++) {
...@@ -354,7 +357,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -354,7 +357,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
// 里程耗时 // 里程耗时
long takeTime = (date.getTime()) - (item.getStartTime().getTime()); long takeTime = (date.getTime()) - (item.getStartTime().getTime());
// 修改0点未结束里程记录 // 修改0点未结束里程记录
item.setEndSpeed(ceil); item.setEndSpeed(v.intValue());
item.setEndTime(date); item.setEndTime(date);
item.setEndLatitude(startLatitude); item.setEndLatitude(startLatitude);
item.setEndLongitude(startLongitude); item.setEndLongitude(startLongitude);
...@@ -374,12 +377,22 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -374,12 +377,22 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
item.setEndName(null); item.setEndName(null);
item.setTravel(null); item.setTravel(null);
item.setTakeTime(null); item.setTakeTime(null);
item.setStartSpeed(ceil); item.setStartSpeed(v.intValue());
item.setStartTime(item.getDate()); item.setStartTime(item.getDate());
item.setStartLongitude(startLongitude); item.setStartLongitude(startLongitude);
item.setStartLatitude(startLatitude); item.setStartLatitude(startLatitude);
this.baseMapper.insert(item); this.baseMapper.insert(item);
HashMap<String,String> messageMap = new HashMap<>();
messageMap.put("FireCar_Latitude", String.valueOf(startLatitude));
messageMap.put("FireCar_Longitude", String.valueOf(startLongitude));
messageMap.put("FireCar_Speed",String.valueOf(v.intValue()));
messageMap.put("time",String.valueOf(item.getDate().getTime()));
messageMap.put("name","轨迹切分消息!!!");
log.info("-----------新增开始里程成功:::"+JSONObject.toJSONString(item)+"-----------------"); log.info("-----------新增开始里程成功:::"+JSONObject.toJSONString(item)+"-----------------");
try {
emqKeeper.getMqttClient().publish(item.getIotCode().substring(0, 8)+"/"+item.getIotCode().substring(8)+"/property",JSON.toJSON(messageMap).toString().getBytes("UTF-8"),1,false);
} catch (Exception e) {
}
//根据iotcode获取车辆并且同步经纬度到车辆 //根据iotcode获取车辆并且同步经纬度到车辆
Car car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", item.getIotCode())); Car car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", item.getIotCode()));
car.setLongitude(startLongitude); car.setLongitude(startLongitude);
...@@ -390,7 +403,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -390,7 +403,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
}); });
log.info("轨迹切分任务执行完成.............."); log.info("轨迹切分任务执行完成..............");
log.info("-------------------对于切割完成的数据进行倒计时操作----------------------------------"); log.info("-------------------对于切割完成的数据进行倒计时操作----------------------------------");
ThreadCarMileageTreatment threadCarMileageTreatment = new ThreadCarMileageTreatment(); ThreadCarMileageTreatment threadCarMileageTreatment = new ThreadCarMileageTreatment(this,iCarService , iotFeign);
log.info("-------------------对于切割完成的数据进行倒计时开始----------------------------------"); log.info("-------------------对于切割完成的数据进行倒计时开始----------------------------------");
threadCarMileageTreatment.start(); threadCarMileageTreatment.start();
log.info("-------------------对于切割完成的数据进行倒计时结束----------------------------------"); log.info("-------------------对于切割完成的数据进行倒计时结束----------------------------------");
......
...@@ -8,19 +8,14 @@ import com.yeejoin.equipmanage.common.entity.WlCarMileage; ...@@ -8,19 +8,14 @@ import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.utils.CoordinateUtil; import com.yeejoin.equipmanage.common.utils.CoordinateUtil;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.service.ICarService; import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
import com.yeejoin.equipmanage.service.impl.CarServiceImpl; import com.yeejoin.equipmanage.service.impl.CarServiceImpl;
import com.yeejoin.equipmanage.service.impl.WlCarMileageServiceImpl; import com.yeejoin.equipmanage.service.impl.WlCarMileageServiceImpl;
import com.yeejoin.equipmanage.utils.CarUtils; import com.yeejoin.equipmanage.utils.CarUtils;
import liquibase.pro.packaged.E;
import org.jfree.util.Log;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -28,20 +23,21 @@ import java.util.ArrayList; ...@@ -28,20 +23,21 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@Component @Component
public class ThreadCarMileageTreatment extends Thread { public class ThreadCarMileageTreatment extends Thread {
Logger logger = LoggerFactory.getLogger(ThreadCarMileageTreatment.class); Logger logger = LoggerFactory.getLogger(ThreadCarMileageTreatment.class);
@Autowired private final WlCarMileageServiceImpl wlCarMileageServiceImpl;
private WlCarMileageServiceImpl wlCarMileageServiceImpl; private final ICarService iCarService;
private final IotFeign iotFeign;
@Autowired
CarServiceImpl carServiceImpl;
@Autowired
private IotFeign iotFeign;
@Value("${mileage.clippingtime}") @Value("${mileage.clippingtime}")
private Long clipping_time; private Long clipping_time;
public ThreadCarMileageTreatment(WlCarMileageServiceImpl wlCarMileageServiceImpl, ICarService iCarService, IotFeign iotFeign) {
this.wlCarMileageServiceImpl = wlCarMileageServiceImpl;
this.iCarService = iCarService;
this.iotFeign = iotFeign;
}
@Override @Override
public void run() { public void run() {
logger.info("----------------------------------------------------开始处理未结束里程---------------------------------"); logger.info("----------------------------------------------------开始处理未结束里程---------------------------------");
...@@ -52,19 +48,21 @@ public class ThreadCarMileageTreatment extends Thread { ...@@ -52,19 +48,21 @@ public class ThreadCarMileageTreatment extends Thread {
Car car =null; Car car =null;
List<WlCarMileage> wlCarMileageList = wlCarMileageServiceImpl.list(new QueryWrapper<WlCarMileage>().isNull("end_time")); List<WlCarMileage> wlCarMileageList = wlCarMileageServiceImpl.list(new QueryWrapper<WlCarMileage>().isNull("end_time"));
for (int i = 0; i < wlCarMileageList.size(); i++) { for (int i = 0; i < wlCarMileageList.size(); i++) {
car = carServiceImpl.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileageList.get(i).getIotCode())); car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileageList.get(i).getIotCode()));
String coordinateSting = String.valueOf(car.getLongitude()) + String.valueOf(car.getLatitude()); String coordinateSting = String.valueOf(car.getLongitude()) + String.valueOf(car.getLatitude());
hashMap.put(car.getIotCode(), coordinateSting); hashMap.put(car.getIotCode(), coordinateSting);
} }
logger.info("----------------获取到的未处理的车辆坐标信息::"+JSONObject.toJSONString(hashMap));
try { try {
Thread.sleep(clipping_time); Thread.sleep(clipping_time);
for (int i = 0; i < wlCarMileageList.size(); i++) { for (int i = 0; i < wlCarMileageList.size(); i++) {
WlCarMileage wlCarMileage =wlCarMileageList.get(i); WlCarMileage wlCarMileage =wlCarMileageList.get(i);
car = carServiceImpl.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileage.getIotCode())); car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileage.getIotCode()));
String coordinateSting = String.valueOf(car.getLongitude()) + String.valueOf(car.getLatitude()); String coordinateSting = String.valueOf(car.getLongitude()) + String.valueOf(car.getLatitude());
if (coordinateSting.equals(hashMap.get(car.getIotCode()))) { //增加对于无效坐标的兼容处理,由于无效坐标的存储精度不一样 可能会导致0的位数发生差异从而到时无法判断生效
if (coordinateSting.equals(hashMap.get(car.getIotCode()))||(handlerUnActiveCoodinate(coordinateSting).equals(handlerUnActiveCoodinate(hashMap.get(car.getIotCode()))))) {
String iotCode = car.getIotCode(); String iotCode = car.getIotCode();
String measurement = "0THMcLKR"; String measurement = iotCode.substring(0,8);
String deviceName = iotCode.replace(measurement, ""); String deviceName = iotCode.replace(measurement, "");
last = wlCarMileageServiceImpl last = wlCarMileageServiceImpl
.getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, iotCode) .getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, iotCode)
...@@ -139,6 +137,8 @@ public class ThreadCarMileageTreatment extends Thread { ...@@ -139,6 +137,8 @@ public class ThreadCarMileageTreatment extends Thread {
wlCarMileageServiceImpl.updateById(last); wlCarMileageServiceImpl.updateById(last);
} }
} }
public String handlerUnActiveCoodinate(String coodeinateString){
return coodeinateString.replace("0","").replace(".","");
}
} }
...@@ -2038,6 +2038,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2038,6 +2038,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
int xcdw = 0; int xcdw = 0;
int hgdw = 0; int hgdw = 0;
int lcdw = 0; int lcdw = 0;
int zxcdw = 0;
for (Map<String, Object> map : statics for (Map<String, Object> map : statics
) { ) {
if(map.get("code").equals("xfxcjrljxcdw")) { if(map.get("code").equals("xfxcjrljxcdw")) {
...@@ -2049,6 +2050,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2049,6 +2050,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if(map.get("code").equals("xfxcjrlcdw")) { if(map.get("code").equals("xfxcjrlcdw")) {
lcdw = Integer.parseInt(map.get("value").toString()); lcdw = Integer.parseInt(map.get("value").toString());
} }
if(map.get("code").equals("xfxcjrzxcdw")) {
zxcdw = Integer.parseInt(map.get("value").toString());
}
} }
if(xcdw == 0) { if(xcdw == 0) {
for (Map<String, Object> map : statics for (Map<String, Object> map : statics
...@@ -2056,6 +2060,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2056,6 +2060,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if(map.get("code").equals("xfxchgzb")) { if(map.get("code").equals("xfxchgzb")) {
map.put("value","0"); map.put("value","0");
} }
}
} else {
for (Map<String, Object> map : statics
) {
if(map.get("code").equals("xfxchgzb")) {
map.put("value",String.valueOf((((double)hgdw / (double)xcdw)) *100));
}
}
}
if(zxcdw == 0) {
for (Map<String, Object> map : statics
) {
if(map.get("code").equals("xfxclcl")) { if(map.get("code").equals("xfxclcl")) {
map.put("value","0"); map.put("value","0");
} }
...@@ -2063,11 +2079,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2063,11 +2079,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
} else { } else {
for (Map<String, Object> map : statics for (Map<String, Object> map : statics
) { ) {
if(map.get("code").equals("xfxchgzb")) {
map.put("value",(hgdw / xcdw)*100);
}
if(map.get("code").equals("xfxclcl")) { if(map.get("code").equals("xfxclcl")) {
map.put("value",(lcdw / xcdw)*100 ); map.put("value",String.valueOf((((double)lcdw / (double)zxcdw))*100) );
} }
} }
} }
......
...@@ -100,12 +100,13 @@ ...@@ -100,12 +100,13 @@
<select id="selectIndexByTime" resultType="map"> <select id="selectIndexByTime" resultType="map">
SELECT SELECT
car_id carId car_id carId,
update_date updateDate
FROM FROM
wl_car_property wl_car_property
WHERE WHERE
equipment_index_key = #{carStartIndexKey} AND `value` IS NOT NULL AND equipment_index_key = #{carStartIndexKey} AND `value` IS NOT NULL
DATE_SUB(CURDATE( ), INTERVAL 7 DAY ) > update_date -- AND DATE_SUB(CURDATE( ), INTERVAL 7 DAY ) > update_date
</select> </select>
</mapper> </mapper>
...@@ -5967,8 +5967,8 @@ ...@@ -5967,8 +5967,8 @@
<select id="selectCarStats" resultType="java.util.Map"> <select id="selectCarStats" resultType="java.util.Map">
SELECT SELECT
COUNT(*) AS totalCount, COUNT(*) AS totalCount,
0 AS yellowCodeCount, SUM(CASE WHEN wc.equip_status = 1 then 1 else 0 end ) AS yellowCodeCount,
0 AS redCodeCount SUM(CASE WHEN wc.equip_status = 2 then 1 else 0 end ) AS redCodeCount
FROM FROM
wl_car wc wl_car wc
LEFT JOIN wl_equipment wle ON wle.id = wc.equipment_id LEFT JOIN wl_equipment wle ON wle.id = wc.equipment_id
...@@ -6063,9 +6063,8 @@ ...@@ -6063,9 +6063,8 @@
LEFT JOIN wl_equipment_detail AS det ON spe.equipment_detail_id = det.id LEFT JOIN wl_equipment_detail AS det ON spe.equipment_detail_id = det.id
LEFT JOIN wl_equipment AS wle ON wle.id = det.equipment_id LEFT JOIN wl_equipment AS wle ON wle.id = det.equipment_id
LEFT JOIN wl_equipment_category cate ON cate.id = wle.category_id LEFT JOIN wl_equipment_category cate ON cate.id = wle.category_id
LEFT JOIN wl_stock_detail AS wlsd on wlsd.equipment_detail_id = det.id
WHERE WHERE
find_in_set(#{systemId},spe.system_id) and spe.single = true and wlsd.`status` = 1 find_in_set(#{systemId},spe.system_id) and spe.single = true
ORDER BY ORDER BY
spe.equip_status desc spe.equip_status desc
</select> </select>
......
...@@ -1359,6 +1359,20 @@ ...@@ -1359,6 +1359,20 @@
<select id="getStatics" resultType="java.util.Map"> <select id="getStatics" resultType="java.util.Map">
SELECT SELECT
'0' AS `key`,
ifnull( sum( `p_plan_task`.`point_num` ), 0 ) AS `value`,
'' AS unit,
'今日总巡查点位' AS `name`,
'xfxcjrzxcdw' AS code
FROM
`p_plan_task`
WHERE
DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE ()
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'1' AS `key`, '1' AS `key`,
ifnull( sum( `p_plan_task`.`finish_num` ), 0 ) AS `value`, ifnull( sum( `p_plan_task`.`finish_num` ), 0 ) AS `value`,
'' AS unit, '' AS unit,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment