|
@@ -0,0 +1,184 @@
|
|
|
|
+package com.ozs.web.controller.accountmanagment;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.ozs.common.annotation.Log;
|
|
|
|
+import com.ozs.common.core.controller.BaseController;
|
|
|
|
+import com.ozs.common.core.domain.AjaxResult;
|
|
|
|
+import com.ozs.common.core.domain.entity.SysDept;
|
|
|
|
+import com.ozs.common.core.domain.entity.SysDictData;
|
|
|
|
+import com.ozs.common.enums.BusinessType;
|
|
|
|
+import com.ozs.common.utils.AppendUtils;
|
|
|
|
+import com.ozs.common.utils.StringUtils;
|
|
|
|
+import com.ozs.common.utils.poi.ExcelUtil;
|
|
|
|
+import com.ozs.service.entity.*;
|
|
|
|
+import com.ozs.service.entity.vo.*;
|
|
|
|
+import com.ozs.service.mapper.MsgAlarmMapper;
|
|
|
|
+import com.ozs.service.service.*;
|
|
|
|
+import com.ozs.system.service.DataScoreUtil;
|
|
|
|
+import com.ozs.system.service.ISysDeptService;
|
|
|
|
+import com.ozs.system.service.ISysDictDataService;
|
|
|
|
+import com.ozs.system.service.ISysDictTypeService;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 报警信息表 前端控制器
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author ozs
|
|
|
|
+ * @since 2023-02-22
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/service/msgAlarmMatter")
|
|
|
|
+public class MsgAlarmMatterController extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DataScoreUtil dataScoreUtil;
|
|
|
|
+ public static final String PATTERN = "^(\\d+.\\d{1,3}|\\d+)$";
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ MsgAlarmMatterService msgAlarmMatterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ BaseRailwayManagementService baseRailwayManagementService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysDictTypeService dictTypeService;
|
|
|
|
+ @Resource
|
|
|
|
+ private MsgAlarmExtService msgAlarmExtService;
|
|
|
|
+ /**
|
|
|
|
+ * 报警信息分页
|
|
|
|
+ *
|
|
|
|
+ * @param msgAlarmVo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/list")
|
|
|
|
+ @Log(title = "报警信息管理", businessType = BusinessType.SELECT)
|
|
|
|
+ public AjaxResult selectMsgAlarm(@RequestBody MsgAlarmMatterVo msgAlarmVo) {
|
|
|
|
+ msgAlarmVo = (MsgAlarmMatterVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
|
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile())) {
|
|
|
|
+ msgAlarmVo.setAlarmMile(msgAlarmVo.getAlarmMile() * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginMile())) {
|
|
|
|
+ msgAlarmVo.setBeginMile(msgAlarmVo.getBeginMile() * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
|
|
|
|
+ msgAlarmVo.setEndMile(msgAlarmVo.getEndMile() * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isEmptySunhh(msgAlarmVo.getAlarmMileBD())) {
|
|
|
|
+ if (!msgAlarmVo.getAlarmMileBD().toString().matches(PATTERN)) {
|
|
|
|
+ return error("监控范围开始里程位置填写格式不正确");
|
|
|
|
+ } else {
|
|
|
|
+ msgAlarmVo.setAlarmMile(msgAlarmVo.getAlarmMileBD().multiply(new BigDecimal("1000")).intValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ IPage<MsgAlarmMatter> page = msgAlarmMatterService.queryPage(msgAlarmVo);
|
|
|
|
+ page.setTotal(page.getTotal());
|
|
|
|
+ page.setCurrent(page.getCurrent());
|
|
|
|
+ page.setPages(page.getPages());
|
|
|
|
+
|
|
|
|
+ if (!ObjectUtils.isEmpty(page) && page.getRecords().size() > 0) {
|
|
|
|
+ List<MsgAlarmMatter> dto1 = page.getRecords().stream().map(o -> {
|
|
|
|
+ LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
|
|
+ if (!ObjectUtils.isEmpty(o.getRailwayCode())) {
|
|
|
|
+ queryWrapper.eq(BaseRailwayManagement::getRailwayCode, o.getRailwayCode());
|
|
|
|
+ }
|
|
|
|
+ BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
|
|
+ if (!StringUtils.isEmptySunhh(baseRailwayManagement) && !StringUtils.isEmptySunhh(baseRailwayManagement.getRailwayName())) {
|
|
|
|
+ o.setRailwayName(baseRailwayManagement.getRailwayName());
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isEmptySunhh(o.getReleasedBy())) {
|
|
|
|
+// BaseUser user = baseUserService.getUser(o.getReleasedBy());
|
|
|
|
+// if (!StringUtils.isEmptySunhh(user) && !StringUtils.isEmptySunhh(user.getNickName())) {
|
|
|
|
+// o.setReleasedByName(user.getNickName());
|
|
|
|
+// }
|
|
|
|
+ o.setReleasedByName(o.getReleasedBy());
|
|
|
|
+ }
|
|
|
|
+ String mils = AppendUtils.stringAppend(o.getAlarmMile());
|
|
|
|
+ o.setAlarmMiles(mils);
|
|
|
|
+ o.setLineDirName(o.getLineDir() == 1 ? "上行" : "下行");
|
|
|
|
+ List<SysDictData> data = dictTypeService.selectDictDataByType("sys_alarm_type");
|
|
|
|
+ data.stream().forEach(sysDictData -> {
|
|
|
|
+ if (sysDictData.getDictValue().equals(o.getAlarmType().toString())) {
|
|
|
|
+ o.setAlarmTypeName(sysDictData.getDictLabel());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ List<MsgAlarmExt> list1 = msgAlarmExtService.list(new LambdaQueryWrapper<MsgAlarmExt>().eq(MsgAlarmExt::getAlarmId, o.getAlarmId()));
|
|
|
|
+ if (!ObjectUtils.isEmpty(list1)) {
|
|
|
|
+ List<String> collect = list1.stream().map(MsgAlarmExt::getAlarmAttPath).collect(Collectors.toList());
|
|
|
|
+ o.setImageUrls(collect);
|
|
|
|
+ }
|
|
|
|
+ return o;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ page.setRecords(dto1);
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出报警消息
|
|
|
|
+ *
|
|
|
|
+ * @param response
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/exportMsgAlarm")
|
|
|
|
+ @Log(title = "报警信息管理", businessType = BusinessType.EXPORT)
|
|
|
|
+ public void exportMsgAlarm(HttpServletResponse response, @RequestBody MsgAlarmMatterVo msgAlarmVo) {
|
|
|
|
+ msgAlarmVo = (MsgAlarmMatterVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
|
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile())) {
|
|
|
|
+ msgAlarmVo.setAlarmMile(msgAlarmVo.getAlarmMile() * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginMile())) {
|
|
|
|
+ msgAlarmVo.setBeginMile(msgAlarmVo.getBeginMile() * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
|
|
|
|
+ msgAlarmVo.setEndMile(msgAlarmVo.getEndMile() * 1000);
|
|
|
|
+ }
|
|
|
|
+ List<MsgAlarmMatter> msgAlarmList = msgAlarmMatterService.msgAlarmList(msgAlarmVo);
|
|
|
|
+ for (MsgAlarmMatter o : msgAlarmList) {
|
|
|
|
+ LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ if (!StringUtils.isEmptySunhh(o.getRailwayCode())) {
|
|
|
|
+ queryWrapper.eq(BaseRailwayManagement::getRailwayCode, o.getRailwayCode());
|
|
|
|
+ }
|
|
|
|
+ BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
|
|
+ if (!StringUtils.isEmptySunhh(baseRailwayManagement) && !StringUtils.isEmptySunhh(baseRailwayManagement.getRailwayName())) {
|
|
|
|
+ o.setRailwayName(baseRailwayManagement.getRailwayName());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(o.getReleasedBy())) {
|
|
|
|
+// BaseUser user = baseUserService.getUser(o.getReleasedBy());
|
|
|
|
+// if (!StringUtils.isEmptySunhh(user) && !StringUtils.isEmptySunhh(user.getNickName())) {
|
|
|
|
+// o.setReleasedByName(user.getNickName());
|
|
|
|
+// }
|
|
|
|
+ o.setReleasedByName(o.getReleasedBy());
|
|
|
|
+ }
|
|
|
|
+ String mils = AppendUtils.stringAppend(o.getAlarmMile());
|
|
|
|
+ o.setAlarmMiles(mils);
|
|
|
|
+ o.setLineDirName(o.getLineDir() == 1 ? "上行" : "下行");
|
|
|
|
+ o.setAlarmTypeStr(o.getAlarmType() == 1 ? "泥石流" : (o.getAlarmType() == 2 ? "异物侵限" : (o.getAlarmType() == 3 ? "断轨监测" : "未知")));
|
|
|
|
+ o.setIsReleaseName(o.getIsRelease() == 1 ? "已解除" : (o.getIsRelease() == 2 ? "未解除" : "未知"));
|
|
|
|
+ List<SysDictData> data = dictTypeService.selectDictDataByType("sys_alarm_type");
|
|
|
|
+ data.stream().forEach(sysDictData -> {
|
|
|
|
+ if (sysDictData.getDictValue().equals(o.getAlarmType().toString())) {
|
|
|
|
+ o.setAlarmTypeName(sysDictData.getDictLabel());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ ExcelUtil<MsgAlarmMatter> util = new ExcelUtil<>(MsgAlarmMatter.class);
|
|
|
|
+ util.exportExcel(response, msgAlarmList, "报警信息管理");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|