| 
					
				 | 
			
			
				@@ -0,0 +1,351 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.ozs.controller.matter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson2.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson2.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.annotation.SdkLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.enums.BusinessTypeSdk; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.ApiTokenUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.stateSecrets.SM4Utils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.config.AjaxResults; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.vo.Files; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.vo.ParameterVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.vo.ReleaseAlarmVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.vo.ReqMsgAlarmMatterVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.vo.RespGeoHazardMonitorVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.ObjectUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 1. 获取身份认证控制层 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @author Administrator 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class MatterMonitorTokenController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String PATTERNS = "^[0-9]*$"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ApiTokenUtils apiTokenUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    MsgAlarmMatterService msgAlarmMatterService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    MsgAlarmFrequencyMatterService msgAlarmFrequencyMatterService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    SvcAddressService svcAddressService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    BaseCameraManagementService baseCameraManagementService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private MsgAlarmExtService msgAlarmExtService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private BaseRailwayManagementService baseRailwayManagementService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private BaseUserService baseUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${base.imgUrl}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String imgUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private BaseMeasurePointService baseMeasurePointService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 异物侵限获取web访问令牌 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("/api/token") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @SdkLog(title = "获取web访问令牌", businessType = BusinessTypeSdk.TOKEN) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String getWebToken(@RequestBody SvcAddress svcAddress) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 生成令牌 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<SvcAddress> lw = new LambdaQueryWrapper<SvcAddress>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!ObjectUtils.isEmpty(svcAddress.getClientId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lw.eq(SvcAddress::getClientId, svcAddress.getClientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jsonObject.put("resultCode", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jsonObject.put("message", "失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jsonObject.put("data", "客户端编号不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SvcAddress serviceOne = svcAddressService.getOne(lw); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!ObjectUtils.isEmpty(serviceOne)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (serviceOne.getClientSecret().equals(svcAddress.getClientSecret())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ArrayList<String> objects = apiTokenUtils.createGeoHazardMonitorToken(svcAddress.getGrantType(), svcAddress.getClientId(), svcAddress.getClientSecret()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (objects.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    RespGeoHazardMonitorVo respGeoHazardMonitorVo = new RespGeoHazardMonitorVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    respGeoHazardMonitorVo.setAccessToken(objects.get(1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Long l = Long.valueOf(objects.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    respGeoHazardMonitorVo.setExpiresIn(l / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    respGeoHazardMonitorVo.setTokenType("令牌类型"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jsonObject.put("resultCode", 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jsonObject.put("message", "成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jsonObject.put("data", respGeoHazardMonitorVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jsonObject.put("resultCode", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jsonObject.put("message", "失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jsonObject.put("data", "生成token失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                jsonObject.put("resultCode", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                jsonObject.put("message", "失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                jsonObject.put("data", "客户端密钥错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jsonObject.put("resultCode", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jsonObject.put("message", "失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jsonObject.put("data", "参数验证失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 报警信息数据传输 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("/api/alarm") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public synchronized String alarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        long begin = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("报警信息数据传输开始时间: " + simpleDateFormat.format(new Date(begin))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String token = apiTokenUtils.getGeoHazardMonitorToken(request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("token:{}", token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("parameter:{}", parameterVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AjaxResults AjaxResults1 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtils.isNotEmpty(token)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String[] split = token.split("-"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(parameterVo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "parameterVo参数不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ReqMsgAlarmMatterVo reqMsgAlarmMatterVo = JSON.parseObject(s, ReqMsgAlarmMatterVo.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!reqMsgAlarmMatterVo.getAlarmMile().toString().matches(PATTERNS)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警里程位置填写错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (reqMsgAlarmMatterVo.getLineDir() != 1 && reqMsgAlarmMatterVo.getLineDir() != 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "行别填写错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getAlarmRailway())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                queryWrapper.eq(BaseRailwayManagement::getRailwayCode, reqMsgAlarmMatterVo.getAlarmRailway()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(baseRailwayManagement)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "填写的报警线路编码不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getAlarmId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警的唯一标识不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getAlarmTime())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警时间不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getAlarmAttr())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警病害属性不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (reqMsgAlarmMatterVo.getAlarmType() < 1 || reqMsgAlarmMatterVo.getAlarmType() > 4) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警病害类型填写错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!reqMsgAlarmMatterVo.getAlarmLevel().toString().matches(PATTERNS)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警级别填写错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getPointCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "测点编码不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getFiles())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警文件集合不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BaseMeasurePoint one = baseMeasurePointService.getOne(new LambdaQueryWrapper<BaseMeasurePoint>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(BaseMeasurePoint::getPointCode, reqMsgAlarmMatterVo.getPointCode())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(one)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "系统中不存在该测点编码"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (reqMsgAlarmMatterVo.getAlarmTime().toString().length() == 10) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                reqMsgAlarmMatterVo.setAlarmTime(reqMsgAlarmMatterVo.getAlarmTime() * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("reqMsgAlarmVo:{}", reqMsgAlarmMatterVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<MsgAlarmMatter> lw = new LambdaQueryWrapper<MsgAlarmMatter>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!ObjectUtils.isEmpty(reqMsgAlarmMatterVo.getAlarmId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lw.eq(MsgAlarmMatter::getAlarmId, reqMsgAlarmMatterVo.getAlarmId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            MsgAlarmMatter alarm = msgAlarmMatterService.getOne(lw); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BaseUser admin = baseUserService.getUserName("admin"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            MsgAlarmFrequencyMatter msgAlarmFrequencyMatter = new MsgAlarmFrequencyMatter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(alarm)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MsgAlarmMatter msgAlarmMatter = new MsgAlarmMatter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String[] alarmAttr = reqMsgAlarmMatterVo.getAlarmAttr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (alarmAttr.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    StringBuilder builder = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (int i = 0; i < alarmAttr.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        builder.append(alarmAttr[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (i < alarmAttr.length - 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            builder.append(":"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msgAlarmMatter.setAlarmAttr(builder.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BeanUtils.copyProperties(reqMsgAlarmMatterVo, msgAlarmMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BeanUtils.copyProperties(reqMsgAlarmMatterVo, msgAlarmFrequencyMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmMatter.setCreateBy(admin.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmMatter.setUpdateBy(admin.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("时间++++ long ---- " + reqMsgAlarmMatterVo.getAlarmTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("时间++++" + new Date(reqMsgAlarmMatterVo.getAlarmTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmMatter.setAlarmTime(new Date(reqMsgAlarmMatterVo.getAlarmTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("时间++++get" + msgAlarmMatter.getAlarmTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmMatter.setRailwayCode(reqMsgAlarmMatterVo.getAlarmRailway()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String source = split[split.length - 2]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmMatter.setSource(source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (Files file : reqMsgAlarmMatterVo.getFiles()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (ObjectUtils.isEmpty(file.getFileType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        AjaxResults1 = new AjaxResults(0, "文件类型不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (ObjectUtils.isEmpty(file.getFileName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        AjaxResults1 = new AjaxResults(0, "文件名称不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    MsgAlarmExt msgAlarmExt = new MsgAlarmExt(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msgAlarmExt.setAlarmId(msgAlarmMatter.getAlarmId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMdd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String format1 = dateFormat1.format(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String fileName = imgUrl + "/yiwuqinxian/" + reqMsgAlarmMatterVo.getAlarmRailway() + "/" + reqMsgAlarmMatterVo.getPointCode() + "/" + format1 + "/" + file.getFileName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msgAlarmExt.setAlarmAttPath(fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msgAlarmExt.setAlarmAttType(file.getFileType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msgAlarmExt.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msgAlarmExtService.save(msgAlarmExt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmMatterService.save(msgAlarmMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setCreateBy(admin.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setUpdateBy(admin.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setRailwayCode(reqMsgAlarmMatterVo.getAlarmRailway()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setAlarmTime(new Date(reqMsgAlarmMatterVo.getAlarmTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatterService.save(msgAlarmFrequencyMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                log.info("alarmJSON :{}", JSON.toJSONString(msgAlarmMatter)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                log.info("->>>>>>>>>>>>>>>>>>>>>>>>>>" + msgAlarmMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                String result = HttpClientUtil.postJson(sdkUrl, JSON.toJSONString(msgAlarmMatter)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                log.info("->>>>>>>>>>>>>>>>>>>>>>>>>>>>" + result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                log.info("result:{}", result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BeanUtils.copyProperties(reqMsgAlarmMatterVo, msgAlarmFrequencyMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setCreateBy(admin.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setUpdateBy(admin.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setAlarmTime(new Date(reqMsgAlarmMatterVo.getAlarmTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatter.setRailwayCode(reqMsgAlarmMatterVo.getAlarmRailway()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msgAlarmFrequencyMatterService.save(msgAlarmFrequencyMatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AjaxResults1 = new AjaxResults(1, "ok"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            long end = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("报警信息数据传输结束时间: " + simpleDateFormat.format(new Date(end))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("报警信息数据传输请求用时时间:" + (end - begin) + "毫秒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AjaxResults1 = new AjaxResults(2, "token验证失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return JSONObject.toJSONString(AjaxResults1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 报警解除接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param parameterVo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param request 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("/api/releaseAlarm") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String releaseAlarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AjaxResults AjaxResults1 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String token = apiTokenUtils.getGeoHazardMonitorToken(request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("token:{}", token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("parameter:{}", parameterVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtils.isNotEmpty(token)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(parameterVo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "parameterVo参数不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ReleaseAlarmVo releaseAlarmVo = JSON.parseObject(s, ReleaseAlarmVo.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(releaseAlarmVo.getAlarmId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "报警的唯一标识不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseTime())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "解除报警时间不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseContent())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "解除原因不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(releaseAlarmVo.getOperator())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "解除人不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<MsgAlarmMatter> wrapper = new LambdaQueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            wrapper.eq(MsgAlarmMatter::getAlarmId, releaseAlarmVo.getAlarmId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            MsgAlarmMatter msgAlarm = msgAlarmMatterService.getOne(wrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtils.isEmpty(msgAlarm)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "不存在该报警的唯一标识的数据"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (releaseAlarmVo.getReleaseTime().toString().length() == 10) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                releaseAlarmVo.setReleaseTime(releaseAlarmVo.getReleaseTime() * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Calendar cal = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cal.setTime(new Date(releaseAlarmVo.getReleaseTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cal.set(Calendar.MILLISECOND, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cal.set(Calendar.MILLISECOND, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarm.setReleasedTime(cal.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarm.setReleaseContent(releaseAlarmVo.getReleaseContent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarm.setReleasedBy(releaseAlarmVo.getOperator()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarm.setUpdateBy(releaseAlarmVo.getOperator()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarm.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarm.setIsRelease(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            boolean count = msgAlarmMatterService.updateById(msgAlarm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("alarmId", msgAlarm.getAlarmId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("releaseState", 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(1, "ok", map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("releaseState", 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AjaxResults1 = new AjaxResults(0, "失败", map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), "f5408458becc8c68"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AjaxResults1 = new AjaxResults(2, "token验证失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return JSONObject.toJSONString(AjaxResults1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |