| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.jfpt.alarm.entity.Alarm; |
| | | import org.springblade.jfpt.alarm.service.IAlarmService; |
| | | import org.springblade.jfpt.alarm.vo.AlarmVO; |
| | | import org.springblade.jfpt.alarm.wrapper.AlarmWrapper; |
| | | import org.springblade.jfpt.animalheat.service.AnimalHeatService; |
| | | import org.springblade.jfpt.alarm.vo.AlarmExcel; |
| | | import org.springblade.jfpt.animalheat.vo.AnimalHeatExcel; |
| | | import org.springblade.jfpt.healthcode.service.IhealthcodeService; |
| | | import org.springblade.jfpt.operation.service.IOperationService; |
| | | import org.springblade.jfpt.operation.vo.OperationVO; |
| | | import org.springblade.jfpt.parcel.service.ParcelService; |
| | | import org.springblade.jfpt.parcel.util.DateUtils; |
| | | import org.springblade.jfpt.parcel.vo.ConditionVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | public class AlarmController extends BladeController { |
| | | |
| | | private final IAlarmService alarmService; |
| | | |
| | | private final AnimalHeatService animalHeatService; |
| | | |
| | | private final IOperationService operationService; |
| | | |
| | | private IhealthcodeService ihealthcodeService; |
| | | |
| | | private ParcelService parcelService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | if (alarm.getAlarmTime() != null && alarm.getAlarmTime().equals("")){ |
| | | alarm.setAlarmTime(null); |
| | | } |
| | | if (alarm.getCid() != null && alarm.getCid().equals("")){ |
| | | alarm.setCid("0"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //return null; |
| | | return R.status(alarmService.saveOrUpdate(alarm)); |
| | | } |
| | | |
| | |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 |
| | | String time = df.format(new Date());// new Date()为获取当前系统时间 |
| | | ArrayList<String> strings = pastDay(time); |
| | | String[] str={"医疗求助","火警","紧急求救","盗警","普通报警","交通","中心调度","系统测试","未知"}; |
| | | String[] str={"医疗求助","火警","紧急求救","盗警","普通报警","交通","中心调度","电话报警"}; |
| | | Map<String, Object> maps = new HashMap<String, Object>(); |
| | | for (int j=0;j<strings.size();j++){ |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | |
| | | case "中心调度" : |
| | | map.put("中心调度",list.get(i).get("cou")); |
| | | break; |
| | | case "系统测试" : |
| | | map.put("系统测试",list.get(i).get("cou")); |
| | | case "电话报警" : |
| | | map.put("电话报警",list.get(i).get("cou")); |
| | | break; |
| | | default : |
| | | map.put("未知",list.get(i).get("cou")); |
| | |
| | | listc.add(maps); |
| | | return R.data(listc); |
| | | } |
| | | |
| | | |
| | | public static String getPastDate(int past) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past); |
| | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String result = format.format(today); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 主动报警统计 饼图展示 |
| | | * @param response |
| | | * @param conditionVo status 0:本日 1:本月 2:本月 |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectAlarmSum") |
| | | public R selectAlarmSum(HttpServletResponse response, ConditionVo conditionVo) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | //返回数据 |
| | | return R.data(alarmService.selectAlarmSum(conditionVo)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 一周警情统计(主动报警+被动报警类型(体温异常,红码,违禁品)) 2021-3-16 arsn 柱状图展示 |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectAlertScount") |
| | | public R selectAlertScount(HttpServletResponse response,ConditionVo conditionVo) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | //创建类型,时间对象,分别存取类型,时间数据 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<String> types = new ArrayList<>(); |
| | | List<String> times = new ArrayList<>(); |
| | | List<Map<String, Object>> dataList = new ArrayList<>(); |
| | | //获取类型集合数据 |
| | | String [] type = {"一键求助","违禁品","红色健康码","体温异常"}; |
| | | types = Arrays.asList(type); |
| | | if (null!=conditionVo.getStartTime()){ |
| | | //获取时间集合数据 |
| | | times = DateUtils.getTimeOverOneDate(conditionVo.getStartTime(), conditionVo.getEndTime()); |
| | | //1.统计时间段内一键求助警情数量数据 4-7 修改展示紧急求助 |
| | | Map<String, Object> alarmData = alarmService.selectAlarmTimeData(conditionVo); |
| | | alarmData.put("name", "一键求助"); |
| | | //2.统计时间段内违禁品的数量数据 |
| | | Map<String, Object> parcelData = parcelService.selectParcelData(conditionVo); |
| | | parcelData.put("name", "违禁品"); |
| | | //3.统计时间段内红色健康码人数数量数据 |
| | | Map<String, Object> healthcodeData = ihealthcodeService.selectHealthcodeTimeData(conditionVo); |
| | | healthcodeData.put("name", "红色健康码"); |
| | | //4.统计时间段内体温异常人数数量数据 |
| | | Map<String, Object> animalData = animalHeatService.selectAnimalTimeData(conditionVo); |
| | | animalData.put("name", "体温异常"); |
| | | //封装数据 |
| | | dataList.add(alarmData); |
| | | dataList.add(parcelData); |
| | | dataList.add(healthcodeData); |
| | | dataList.add(animalData); |
| | | }else { |
| | | //获取时间集合数据(今天及今天之前6天的日期) |
| | | times = DateUtils.pastDay(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); |
| | | //1.统计7天内一键求助警情数量数据 3-20 修改展示紧急求助 |
| | | Map<String, Object> alarmData = alarmService.selectAlarmData(); |
| | | alarmData.put("name", "一键求助"); |
| | | //2.统计7天内违禁品的数量数据 |
| | | conditionVo.setStatus(1); |
| | | Map<String, Object> parcelData = parcelService.selectParcelData(conditionVo); |
| | | parcelData.put("name", "违禁品"); |
| | | //3.统计7天内红色健康码人数数量数据 |
| | | Map<String, Object> healthcodeData = ihealthcodeService.selectHealthcodeData(); |
| | | healthcodeData.put("name", "红色健康码"); |
| | | //4.统计7天内体温异常人数数量数据 |
| | | Map<String, Object> animalData = animalHeatService.selectAnimalData(); |
| | | animalData.put("name", "体温异常"); |
| | | //封装数据 |
| | | dataList.add(alarmData); |
| | | dataList.add(parcelData); |
| | | dataList.add(healthcodeData); |
| | | dataList.add(animalData); |
| | | } |
| | | map.put("types",types); |
| | | map.put("times",times); |
| | | map.put("dataList",dataList); |
| | | //返回数据 |
| | | return R.data(map); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * 修改警情类型 |
| | | * 修改警情类型/同时修改人员状态 |
| | | */ |
| | | @PostMapping("/updateJtype") |
| | | public R updateJtype(String id, String czTime, String bz, HttpServletResponse response) { |
| | | public R updateJtype(OperationVO operation, HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | alarmService.updateJtype(id,czTime,bz); |
| | | alarmService.updateJtype(operation.getJid(),operation.getJtype(),operation.getBz()); |
| | | alarmService.updatePoliceStatus(operation.getRid(),"0"); |
| | | operationService.save(operation); |
| | | return R.success("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有保安信息 |
| | | */ |
| | | @PostMapping("/queryBa") |
| | | public R queryBa(OperationVO operation, HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | return R.data(alarmService.queryBa()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 统计预警设备数量 |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectEq") |
| | | public R selectEq(HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | List<Map<String, Object>> lists = new ArrayList<>(); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 |
| | | String time = df.format(new Date());// new Date()为获取当前系统时间 |
| | | ArrayList<String> strings = pastDay(time); |
| | | Map<String, Object> maps = new HashMap<String, Object>(); |
| | | for (int j=0;j<strings.size();j++){ |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | List<Map<String, Object>> list = alarmService.selectEq(strings.get(j)); |
| | | map.put("time",strings.get(j)); |
| | | map.put("Coun",list.size()); |
| | | lists.add(map); |
| | | } |
| | | return R.data(lists); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 警情日平均占比 |
| | | * @param response 跨域配置 |
| | | * @param conditionVo 条件 |
| | | * @return |
| | | */ |
| | | @GetMapping("/selAlarmDayAveragePro") |
| | | public R selAlarmDayAveragePro(HttpServletResponse response,ConditionVo conditionVo) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | List<Integer> list = new ArrayList<>(); |
| | | //获取时间天数 |
| | | if (null!= conditionVo.getStartTime() && conditionVo.getStartTime()!="" |
| | | && null!=conditionVo.getEndTime() && conditionVo.getEndTime()!="") { |
| | | int times = DateUtils.getTimeOverOneDate(conditionVo.getStartTime(), conditionVo.getEndTime()).size(); |
| | | //查询当前时间段一键求助报警总次数 |
| | | int alarmTimeCount = alarmService.selAlarmTimeCount(conditionVo); |
| | | //查询当前时间段违禁品总个数 |
| | | int parcelTimeCount = parcelService.selParcelTimeCount(conditionVo); |
| | | //查询当前时间段红色健康码总个数 |
| | | int healthcodeTimeCount = ihealthcodeService.selHealthcodeTimeCount(conditionVo); |
| | | //查询当前时间段体温异常总次数 |
| | | int animalTimeCount = animalHeatService.selAnimalTimeCount(conditionVo); |
| | | //封装数据 |
| | | list.add(alarmTimeCount); |
| | | list.add(parcelTimeCount); |
| | | list.add(healthcodeTimeCount); |
| | | list.add(animalTimeCount); |
| | | //返回数据 |
| | | return R.data(list); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 一键求助报警确认时间占比 |
| | | * @param response 跨域配置 |
| | | * @param conditionVo 条件 |
| | | * @return |
| | | */ |
| | | @GetMapping("/selConfirmTimePro") |
| | | public R selConfirmTimePro(HttpServletResponse response,ConditionVo conditionVo){ |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | if (null!= conditionVo.getStartTime() && conditionVo.getStartTime()!="" |
| | | && null!=conditionVo.getEndTime() && conditionVo.getEndTime()!="") { |
| | | return R.data(alarmService.selConfirmTimePro(conditionVo)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 警情时间分布 0-2 2-4 4-6 6-8 .... 22-24 |
| | | * @param response 跨域配置 |
| | | * @param conditionVo 条件 |
| | | * @return |
| | | */ |
| | | @GetMapping("/selAlarmTimeDis") |
| | | public R selAlarmTimeDis(HttpServletResponse response,ConditionVo conditionVo) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //获取时间天数 |
| | | if (null!= conditionVo.getStartTime() && conditionVo.getStartTime()!="" |
| | | && null!=conditionVo.getEndTime() && conditionVo.getEndTime()!="") { |
| | | int times = DateUtils.getTimeOverOneDate(conditionVo.getStartTime(), conditionVo.getEndTime()).size(); |
| | | //查询当前时间段区间时间一键求助报警个数 |
| | | List<Integer> alarmTimeDis = alarmService.selAlarmTimeDis(conditionVo); |
| | | //查询当前时间段区间时间违禁品个数 |
| | | List<Integer> parcelTimeDis = parcelService.selParcelTimeDis(conditionVo); |
| | | //查询当前时间段区间时间红色健康码个数 |
| | | List<Integer> healthcodeTimeDis = ihealthcodeService.selHealthcodeTimeDis(conditionVo); |
| | | //查询当前时间段区间时间体温异常次数 |
| | | List<Integer> animalTimeDis = animalHeatService.selAnimalTimeDis(conditionVo); |
| | | //封装数据 |
| | | map.put("alarmTimeDis",alarmTimeDis); |
| | | map.put("parcelTimeDis",parcelTimeDis); |
| | | map.put("healthcodeTimeDis",healthcodeTimeDis); |
| | | map.put("animalTimeDis",animalTimeDis); |
| | | //返回数据 |
| | | return R.data(map); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询本年所有月份的警情数量 |
| | | * @param response 跨域配置 |
| | | * @param deviceNumber 条件 |
| | | * @return |
| | | */ |
| | | @GetMapping("/queryYearAlarm") |
| | | public List<Map<String, Object>> queryYearAlarm(HttpServletResponse response, String deviceNumber) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | |
| | | List<Map<String,Object>> list = alarmService.queryYearAlarm(deviceNumber); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 导出主动报警数据表格 |
| | | * @param alarmVO 查询条件 |
| | | * @param response |
| | | */ |
| | | @GetMapping("/export-alarm") |
| | | public void exportAlarm(AlarmVO alarmVO, HttpServletResponse response){ |
| | | List<AlarmExcel> list = alarmService.exportAlarm(alarmVO); |
| | | ExcelUtil.export(response, "主动报警数据" + DateUtil.time(), "主动报警数据表", list, AlarmExcel.class); |
| | | } |
| | | } |