Browse Source

la

recovery
wang0018 5 years ago
parent
commit
e40e269b85
  1. 19
      wisdomcar/src/main/java/com/ccsens/wisdomcar/api/StatisticsController.java
  2. 2
      wisdomcar/src/main/java/com/ccsens/wisdomcar/bean/dto/StatisticsDto.java
  3. 8
      wisdomcar/src/main/java/com/ccsens/wisdomcar/bean/vo/StatisticsVo.java
  4. 6
      wisdomcar/src/main/java/com/ccsens/wisdomcar/persist/dao/StatisticsDao.java
  5. 114
      wisdomcar/src/main/java/com/ccsens/wisdomcar/rabbitMQ/RabbitController.java
  6. 12
      wisdomcar/src/main/java/com/ccsens/wisdomcar/service/RecordService.java
  7. 13
      wisdomcar/src/main/java/com/ccsens/wisdomcar/service/StatisticsService.java
  8. 4
      wisdomcar/src/main/resources/application.yml
  9. 17
      wisdomcar/src/main/resources/mapper_dao/StatisticsDao.xml

19
wisdomcar/src/main/java/com/ccsens/wisdomcar/api/StatisticsController.java

@ -29,14 +29,15 @@ public class StatisticsController {
@Resource @Resource
private IStatisticsService statisticsService; private IStatisticsService statisticsService;
@ApiOperation(value = "查看测评结果", notes = "") // @ApiOperation(value = "查看测评结果", notes = "")
@RequestMapping(value = "/get/result", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) // @RequestMapping(value = "/get/result", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<StatisticsVo.FastEdResult> getResult(@ApiParam @Validated @RequestBody QueryDto<StatisticsDto.Hospital> params) { // public JsonResponse<StatisticsVo.FastEdResult> getResult(@ApiParam @Validated @RequestBody QueryDto<StatisticsDto.Hospital> params) {
log.info("查看测评结果:{}",params); // log.info("查看测评结果:{}",params);
StatisticsVo.FastEdResult fastEdResult = statisticsService.getResult(params.getParam()); // StatisticsVo.FastEdResult fastEdResult = statisticsService.getResult(params.getParam());
log.info("查看测评结果"); // log.info("查看测评结果");
return JsonResponse.newInstance().ok(fastEdResult); // return JsonResponse.newInstance().ok(fastEdResult);
} // }
@ApiOperation(value = "统计医院中小车得使用情况", notes = "") @ApiOperation(value = "统计医院中小车得使用情况", notes = "")
@RequestMapping(value = "/get/selResult", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/get/selResult", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<StatisticsVo.UseNumsVo> selResult(@ApiParam @Validated @RequestBody QueryDto<StatisticsDto.UseNum> params) { public JsonResponse<StatisticsVo.UseNumsVo> selResult(@ApiParam @Validated @RequestBody QueryDto<StatisticsDto.UseNum> params) {
@ -50,7 +51,7 @@ public class StatisticsController {
@ApiOperation(value = "急救各个节点时间统计", notes = "") @ApiOperation(value = "急救各个节点时间统计", notes = "")
@RequestMapping(value = "/getPointTime", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/getPointTime", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse getPointTime(@ApiParam @Validated @RequestBody QueryDto<StatisticsDto.Hospital> params) { public JsonResponse<StatisticsVo.PointTimeList> getPointTime(@ApiParam @Validated @RequestBody QueryDto<StatisticsDto.Hospital> params) {
log.info("急救各个节点时间统计:{}",params); log.info("急救各个节点时间统计:{}",params);
StatisticsVo.PointTimeList pointTime = statisticsService.getPointTime(params.getParam()); StatisticsVo.PointTimeList pointTime = statisticsService.getPointTime(params.getParam());
log.info("急救各个节点时间统计"); log.info("急救各个节点时间统计");

2
wisdomcar/src/main/java/com/ccsens/wisdomcar/bean/dto/StatisticsDto.java

@ -13,7 +13,7 @@ import javax.validation.constraints.NotNull;
@Data @Data
public class StatisticsDto { public class StatisticsDto {
@Data @Data
@ApiModel("查询小车本年和往年使用次数") @ApiModel("医院id和年份")
public static class UseNum{ public static class UseNum{
@NotBlank @NotBlank
@ApiModelProperty("year,比如直接传入 2020 即可") @ApiModelProperty("year,比如直接传入 2020 即可")

8
wisdomcar/src/main/java/com/ccsens/wisdomcar/bean/vo/StatisticsVo.java

@ -36,8 +36,6 @@ public class StatisticsVo {
@Data @Data
@ApiModel("各个结点时长") @ApiModel("各个结点时长")
public static class PointTime{ public static class PointTime{
@ApiModelProperty("节点名")
private String name;
@ApiModelProperty("节点耗时") @ApiModelProperty("节点耗时")
private Long time; private Long time;
} }
@ -47,10 +45,10 @@ public class StatisticsVo {
@ApiModel("各个结点时长集合") @ApiModel("各个结点时长集合")
public static class PointTimeList{ public static class PointTimeList{
@ApiModelProperty("当前数据") @ApiModelProperty("当前数据")
private List<PointTime> pointTimeCurrentList; private List<Long> pointTimeCurrentList;
@ApiModelProperty("医院数据") @ApiModelProperty("医院数据")
private List<PointTime> pointTimeHospital; private List<Long> pointTimeHospital;
@ApiModelProperty("国际数据") @ApiModelProperty("国际数据")
private List<PointTime> pointTimeInternation; private List<Long> pointTimeInternation;
} }
} }

6
wisdomcar/src/main/java/com/ccsens/wisdomcar/persist/dao/StatisticsDao.java

@ -11,11 +11,11 @@ public interface StatisticsDao extends FirstAidMapper {
List<StatisticsVo.PointTime> getPointTimeCurrent(@Param("id") Long id); List<Long> getPointTimeCurrent(@Param("id") Long id);
List<StatisticsVo.PointTime> getPointTimeHospital(@Param("id") Long id); List<Long> getPointTimeHospital(@Param("id") Long id);
List<StatisticsVo.PointTime> getPointTimeInternation(@Param("id") Long id); List<Long> getPointTimeInternation(@Param("id") Long id);
public List<Integer> selResult(@Param("param")StatisticsDto.UseNum param); public List<Integer> selResult(@Param("param")StatisticsDto.UseNum param);

114
wisdomcar/src/main/java/com/ccsens/wisdomcar/rabbitMQ/RabbitController.java

@ -1,57 +1,57 @@
package com.ccsens.wisdomcar.rabbitMQ; //package com.ccsens.wisdomcar.rabbitMQ;
//
import cn.hutool.core.collection.CollectionUtil; //import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; //import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import com.ccsens.util.bean.message.common.OutMessage; //import com.ccsens.util.bean.message.common.OutMessage;
import com.ccsens.util.bean.message.common.OutMessageSet; //import com.ccsens.util.bean.message.common.OutMessageSet;
import com.ccsens.util.config.RabbitMQConfig; //import com.ccsens.util.config.RabbitMQConfig;
import com.ccsens.wisdomcar.bean.dto.Message.CarRecordMessageDto; //import com.ccsens.wisdomcar.bean.dto.Message.CarRecordMessageDto;
import com.ccsens.wisdomcar.service.IRecordService; //import com.ccsens.wisdomcar.service.IRecordService;
import com.ccsens.wisdomcar.service.RecordService; //import com.ccsens.wisdomcar.service.RecordService;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; //import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; //import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
import javax.annotation.Resource; //import javax.annotation.Resource;
import java.util.List; //import java.util.List;
import java.util.Set; //import java.util.Set;
//
@Slf4j //@Slf4j
@Component //@Component
@RabbitListener(queues = RabbitMQConfig.WISDOM_CAR) //@RabbitListener(queues = RabbitMQConfig.WISDOM_CAR)
public class RabbitController { //public class RabbitController {
@Resource // @Resource
private IRecordService recordService; // private IRecordService recordService;
//
private Logger logger = LoggerFactory.getLogger(RabbitController.class); // private Logger logger = LoggerFactory.getLogger(RabbitController.class);
//
@RabbitHandler // @RabbitHandler
public void process(String messageJson) { // public void process(String messageJson) {
logger.info("平车上传消息数据: {}",messageJson); // logger.info("平车上传消息数据: {}",messageJson);
OutMessageSet outMessageSet = JSONObject.parseObject(messageJson,OutMessageSet.class); // OutMessageSet outMessageSet = JSONObject.parseObject(messageJson,OutMessageSet.class);
if(ObjectUtil.isNull(outMessageSet)){ // if(ObjectUtil.isNull(outMessageSet)){
return; // return;
} // }
Set<OutMessage> messageSet = outMessageSet.getMessageSet(); // Set<OutMessage> messageSet = outMessageSet.getMessageSet();
if (CollectionUtil.isEmpty(messageSet)) { // if (CollectionUtil.isEmpty(messageSet)) {
return; // return;
} // }
messageSet.forEach(outMessage -> { // messageSet.forEach(outMessage -> {
CarRecordMessageDto carRecordMessageDto = JSONObject.parseObject(outMessage.getData(),CarRecordMessageDto.class); // CarRecordMessageDto carRecordMessageDto = JSONObject.parseObject(outMessage.getData(),CarRecordMessageDto.class);
if(ObjectUtil.isNull(carRecordMessageDto)){ // if(ObjectUtil.isNull(carRecordMessageDto)){
return; // return;
} // }
try { // try {
recordService.disposeMessage(carRecordMessageDto); // recordService.disposeMessage(carRecordMessageDto);
} catch (Exception e) { // } catch (Exception e) {
log.error("处理平车信息异常",e); // log.error("处理平车信息异常",e);
e.printStackTrace(); // e.printStackTrace();
} // }
}); // });
} // }
//
} //}

12
wisdomcar/src/main/java/com/ccsens/wisdomcar/service/RecordService.java

@ -129,28 +129,28 @@ public class RecordService implements IRecordService{
//第一个传感器 //第一个传感器
CarRecordMessageDto sensorMessage1 = new CarRecordMessageDto(); CarRecordMessageDto sensorMessage1 = new CarRecordMessageDto();
BeanUtil.copyProperties(carRecordMessageDto,sensor1); BeanUtil.copyProperties(carRecordMessageDto,sensorMessage1);
sensorMessage1.setType(Constant.WEIGHT_SENSOR_1); sensorMessage1.setType(Constant.WEIGHT_SENSOR_1);
sensorMessage1.setValue(sensor1 + ""); sensorMessage1.setValue(sensor1 + "");
//发送消息 //发送消息
sendRecordMessage(sensorMessage1,userIdSet); sendRecordMessage(sensorMessage1,userIdSet);
//第二个传感器 //第二个传感器
CarRecordMessageDto sensorMessage2 = new CarRecordMessageDto(); CarRecordMessageDto sensorMessage2 = new CarRecordMessageDto();
BeanUtil.copyProperties(carRecordMessageDto,sensor1); BeanUtil.copyProperties(carRecordMessageDto,sensorMessage2);
sensorMessage2.setType(Constant.WEIGHT_SENSOR_2); sensorMessage2.setType(Constant.WEIGHT_SENSOR_2);
sensorMessage2.setValue(sensor2 + ""); sensorMessage2.setValue(sensor2 + "");
//发送消息 //发送消息
sendRecordMessage(sensorMessage2,userIdSet); sendRecordMessage(sensorMessage2,userIdSet);
//第三个传感器 //第三个传感器
CarRecordMessageDto sensorMessage3 = new CarRecordMessageDto(); CarRecordMessageDto sensorMessage3 = new CarRecordMessageDto();
BeanUtil.copyProperties(carRecordMessageDto,sensor1); BeanUtil.copyProperties(carRecordMessageDto,sensorMessage3);
sensorMessage3.setType(Constant.WEIGHT_SENSOR_3); sensorMessage3.setType(Constant.WEIGHT_SENSOR_3);
sensorMessage3.setValue(sensor3 + ""); sensorMessage3.setValue(sensor3 + "");
//发送消息 //发送消息
sendRecordMessage(sensorMessage3,userIdSet); sendRecordMessage(sensorMessage3,userIdSet);
//第四个传感器 //第四个传感器
CarRecordMessageDto sensorMessage4 = new CarRecordMessageDto(); CarRecordMessageDto sensorMessage4 = new CarRecordMessageDto();
BeanUtil.copyProperties(carRecordMessageDto,sensor1); BeanUtil.copyProperties(carRecordMessageDto,sensorMessage4);
sensorMessage4.setType(Constant.WEIGHT_SENSOR_4); sensorMessage4.setType(Constant.WEIGHT_SENSOR_4);
sensorMessage4.setValue(sensor4 + ""); sensorMessage4.setValue(sensor4 + "");
//发送消息 //发送消息
@ -161,9 +161,9 @@ public class RecordService implements IRecordService{
int shakeX = random.nextInt(65535); int shakeX = random.nextInt(65535);
int shakeY = random.nextInt(65535); int shakeY = random.nextInt(65535);
int shakeZ = random.nextInt(65535); int shakeZ = random.nextInt(65535);
//第四个传感器 //震动传感器
CarRecordMessageDto shakeMessage = new CarRecordMessageDto(); CarRecordMessageDto shakeMessage = new CarRecordMessageDto();
BeanUtil.copyProperties(carRecordMessageDto,sensor1); BeanUtil.copyProperties(carRecordMessageDto,shakeMessage);
shakeMessage.setType(Constant.WEIGHT_SENSOR_4); shakeMessage.setType(Constant.WEIGHT_SENSOR_4);
shakeMessage.setValue(shakeX + "," + shakeY + "," + shakeZ); shakeMessage.setValue(shakeX + "," + shakeY + "," + shakeZ);
//发送消息 //发送消息

13
wisdomcar/src/main/java/com/ccsens/wisdomcar/service/StatisticsService.java

@ -59,19 +59,18 @@ public class StatisticsService implements IStatisticsService{
@Override @Override
public StatisticsVo.PointTimeList getPointTime(StatisticsDto.Hospital param) { public StatisticsVo.PointTimeList getPointTime(StatisticsDto.Hospital param) {
List<StatisticsVo.PointTime> pointTimeCurrent1 = new ArrayList<>(); List<Long> pointTimeCurrent1 = new ArrayList<>();
//当前数据 //当前数据
List<StatisticsVo.PointTime> pointTimeCurrent = statisticsDao.getPointTimeCurrent(param.getId()); List<Long> pointTimeCurrent = statisticsDao.getPointTimeCurrent(param.getId());
for (int i = 0; i <7; i++) { for (int i = 0; i <pointTimeCurrent.size() ; i++) {
if (i<6){ if (i<6){
pointTimeCurrent.get(i).setTime(pointTimeCurrent.get(i+1).getTime()/1000-pointTimeCurrent.get(i).getTime()/1000); pointTimeCurrent1.add(pointTimeCurrent.get(i+1)-pointTimeCurrent.get(i));
} }
} }
//医院数据 //医院数据
List<StatisticsVo.PointTime> pointTimeHospital = statisticsDao.getPointTimeHospital(param.getId()); List<Long> pointTimeHospital = statisticsDao.getPointTimeHospital(param.getId());
//国际数据 //国际数据
List<StatisticsVo.PointTime> pointTimeInternation = statisticsDao.getPointTimeInternation(param.getId()); List<Long> pointTimeInternation = statisticsDao.getPointTimeInternation(param.getId());
StatisticsVo.PointTimeList pointTimeList = new StatisticsVo.PointTimeList(); StatisticsVo.PointTimeList pointTimeList = new StatisticsVo.PointTimeList();
pointTimeList.setPointTimeCurrentList(pointTimeCurrent1); pointTimeList.setPointTimeCurrentList(pointTimeCurrent1);

4
wisdomcar/src/main/resources/application.yml

@ -1,6 +1,6 @@
spring: spring:
profiles: profiles:
active: dev active: test
include: common, util-dev include: common, util-test

17
wisdomcar/src/main/resources/mapper_dao/StatisticsDao.xml

@ -34,30 +34,29 @@ FROM
<select id="getPointTimeCurrent" parameterType="java.util.Map" resultType="com.ccsens.wisdomcar.bean.vo.StatisticsVo$PointTime">
select tfar.begin_time/1000, tfar.type as name <select id="getPointTimeCurrent" parameterType="java.util.Map" resultType="Long">
select tfar.begin_time/1000 as time
from from
t_first_aid_record tfar ,(select id from t_first_aid tfa where tfa.hospital_id=0 and tfa.rec_status=0 ORDER BY tfa.begin_time) t t_first_aid_record tfar ,(select id from t_first_aid tfa where tfa.hospital_id=#{id} and tfa.rec_status=0 ORDER BY tfa.begin_time) t
where tfar.rec_status=0 and t.id = tfar.first_aid_id where tfar.rec_status=0 and t.id = tfar.first_aid_id
</select> </select>
<select id="getPointTimeHospital" parameterType="java.util.Map" resultType="com.ccsens.wisdomcar.bean.vo.StatisticsVo$PointTime"> <select id="getPointTimeHospital" parameterType="java.util.Map" resultType="Long">
select select
ts.`name`,
MIN(tfas.duration)/1000 as time MIN(tfas.duration)/1000 as time
from from
t_first_aid_standard tfas left JOIN t_step ts on tfas.step_id = ts.id t_first_aid_standard tfas left JOIN t_step ts on tfas.step_id = ts.id
where tfas.hospital_id=0 and tfas.type=1 and tfas.rec_status = 0 and ts.rec_status=0 where tfas.hospital_id=#{id} and tfas.type=1 and tfas.rec_status = 0 and ts.rec_status=0
GROUP BY tfas.step_id; GROUP BY tfas.step_id;
</select> </select>
<select id="getPointTimeInternation" parameterType="java.util.Map" resultType="com.ccsens.wisdomcar.bean.vo.StatisticsVo$PointTime"> <select id="getPointTimeInternation" parameterType="java.util.Map" resultType="Long">
select select
ts.`name`,
MIN(tfas.duration)/1000 as time MIN(tfas.duration)/1000 as time
from from
t_first_aid_standard tfas left JOIN t_step ts on tfas.step_id = ts.id t_first_aid_standard tfas left JOIN t_step ts on tfas.step_id = ts.id
where tfas.hospital_id=0 and tfas.type=0 and tfas.rec_status = 0 and ts.rec_status=0 where tfas.hospital_id=#{id} and tfas.type=0 and tfas.rec_status = 0 and ts.rec_status=0
GROUP BY tfas.step_id; GROUP BY tfas.step_id;
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save