9 files modified
13 files added
| New file |
| | |
| | | package cn.gistack.auth.granter; |
| | | |
| | | import cn.gistack.auth.utils.TokenUtil; |
| | | import cn.gistack.common.cache.CacheNames; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.security.authentication.*; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; |
| | | import org.springframework.security.oauth2.common.exceptions.UserDeniedAuthorizationException; |
| | | import org.springframework.security.oauth2.provider.*; |
| | | import org.springframework.security.oauth2.provider.token.AbstractTokenGranter; |
| | | import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 验证码TokenGranter |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class AccountPhoneTokenGranter extends AbstractTokenGranter { |
| | | |
| | | private static final String GRANT_TYPE = "accountPhone"; |
| | | |
| | | private final AuthenticationManager authenticationManager; |
| | | |
| | | private BladeRedis bladeRedis; |
| | | |
| | | public AccountPhoneTokenGranter(AuthenticationManager authenticationManager, |
| | | AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, BladeRedis bladeRedis) { |
| | | this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE); |
| | | this.bladeRedis = bladeRedis; |
| | | } |
| | | |
| | | protected AccountPhoneTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices, |
| | | ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) { |
| | | super(tokenServices, clientDetailsService, requestFactory, grantType); |
| | | this.authenticationManager = authenticationManager; |
| | | } |
| | | |
| | | @Override |
| | | protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) { |
| | | Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters()); |
| | | String phone = parameters.get("username"); |
| | | String password = parameters.get("password"); |
| | | String code = parameters.get("code"); |
| | | // 获取验证码 |
| | | String redisCode = bladeRedis.get(CacheNames.PHONE_KEY + phone); |
| | | // 判断验证码 |
| | | if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.CAPTCHA_NOT_CORRECT); |
| | | } |
| | | // 通过手机号查询用户 |
| | | Authentication userAuth = new UsernamePasswordAuthenticationToken(phone, "CUSTOM_LOGIN_SMS"); |
| | | ((AbstractAuthenticationToken) userAuth).setDetails(parameters); |
| | | try { |
| | | userAuth = authenticationManager.authenticate(userAuth); |
| | | } |
| | | catch (AccountStatusException | BadCredentialsException ase) { |
| | | //covers expired, locked, disabled cases (mentioned in section 5.2, draft 31) |
| | | throw new InvalidGrantException(ase.getMessage()); |
| | | } |
| | | // If the username/password are wrong the spec says we should send 400/invalid grant |
| | | |
| | | if (userAuth == null || !userAuth.isAuthenticated()) { |
| | | throw new InvalidGrantException("Could not authenticate user: " + phone); |
| | | } |
| | | |
| | | OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest); |
| | | return new OAuth2Authentication(storedOAuth2Request, userAuth); |
| | | } |
| | | } |
| | |
| | | granters.add(new SocialTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), userClient, socialProperties)); |
| | | //单点登录授权模式 |
| | | granters.add(new OAuthTokenGranter(authenticationManager, endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), bladeRedis)); |
| | | |
| | | //账户验证码模式 |
| | | granters.add(new AccountPhoneTokenGranter(authenticationManager, endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), bladeRedis )); |
| | | // 组合tokenGranter集合 |
| | | return new CompositeTokenGranter(granters); |
| | | } |
| | |
| | | |
| | | String FINISH_TASK = API_PREFIX + "finishTask"; |
| | | |
| | | String INIT_ALGORITHM = API_PREFIX + "initAlgorithm"; |
| | | |
| | | /** |
| | | * 获取arima预测结果 |
| | | * @param type |
| | |
| | | |
| | | @GetMapping(FINISH_TASK) |
| | | Boolean finishTask(@RequestParam("taskId") String taskId); |
| | | |
| | | @PostMapping(INIT_ALGORITHM) |
| | | void initAlgorithm(@RequestBody List<String> resList); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void initAlgorithm(List<String> resList) { |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.nky.resultpojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class BaseCd { |
| | | private String cd; |
| | | private String cd_nm; |
| | | private String ch; |
| | | private String res_cd; |
| | | private String cd_type; |
| | | } |
| New file |
| | |
| | | package cn.gistack.nky.resultpojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class NkyBindDetailResult { |
| | | private String damId; |
| | | private String pointId; |
| | | private String type; |
| | | private String algorithmCategory; |
| | | private String status; |
| | | private String forward; |
| | | private String reverse; |
| | | private String alarmType; |
| | | private String reserve1; |
| | | private String monitoringFrequency; |
| | | private String canchaNumber; |
| | | private String firstWater; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.nky.resultpojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ResDamMonitorResult { |
| | | |
| | | private String code; |
| | | private String name; |
| | | |
| | | private String town_ad_code; |
| | | private String town_ad_name; |
| | | private String county_ad_code; |
| | | private String county_ad_name; |
| | | private String city_ad_code; |
| | | private String city_ad_name; |
| | | private String province_ad_code; |
| | | private String province_ad_name; |
| | | private String is_sy; |
| | | private String is_sl; |
| | | private String is_wy; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.nky.resultpojo; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ZtResult { |
| | | |
| | | private int pageNo; |
| | | private int pageSize; |
| | | private int totalCount; |
| | | private List<ResDamMonitorResult> resultList; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.nky.resultpojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @PROJECT_NAME: skjcmanager |
| | | * @DESCRIPTION: 中台返回resultpojo |
| | | * @USER: aix |
| | | * @DATE: 2023/7/28 17:21 |
| | | */ |
| | | @Data |
| | | public class ZtResultPo2 { |
| | | |
| | | private List<BaseCd> data; |
| | | |
| | | private Integer code; |
| | | |
| | | private String msg; |
| | | |
| | | } |
| | |
| | | |
| | | import cn.gistack.nky.entity.AlarmGet; |
| | | import cn.gistack.nky.fegin.INkyClient; |
| | | import cn.gistack.nky.service.IAlarmGetService; |
| | | import cn.gistack.nky.service.IArimaPredictService; |
| | | import cn.gistack.nky.service.IHstPredictService; |
| | | import cn.gistack.nky.service.INkyService; |
| | | import cn.gistack.nky.resultpojo.BaseCd; |
| | | import cn.gistack.nky.resultpojo.NkyBindDetailResult; |
| | | import cn.gistack.nky.resultpojo.ResDamMonitorResult; |
| | | import cn.gistack.nky.service.*; |
| | | import cn.gistack.nky.vo.AlarmGetVO; |
| | | import cn.gistack.nky.vo.PageVO; |
| | | import cn.gistack.sm.patrol.feign.PatrolTaskClient; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @NonDS |
| | | @ApiIgnore |
| | |
| | | private final IHstPredictService hstPredictService; |
| | | private final IAlarmGetService alarmGetService; |
| | | private final PatrolTaskClient patrolTaskClient; |
| | | private final IZtApiService ztApiService; |
| | | |
| | | |
| | | @Override |
| | |
| | | String taskType = "1641037874390999041"; |
| | | |
| | | //杨树堰水库大坝预警巡查 |
| | | String title = StringUtil.format("{}大坝预警巡查",byId.getReservoirName()); |
| | | String title = StringUtil.format("{}大坝预警巡查", byId.getReservoirName()); |
| | | |
| | | //杨树堰水库在2023-11-29 17:41:19时监测到位移GN1测点,测点值为2.37,预警等级为三级 |
| | | |
| | | String resNm = byId.getReservoirName(); |
| | | String tm = DateUtil.format(byId.getTime(),"MM月dd日HH时mm分"); |
| | | String tm = DateUtil.format(byId.getTime(), "MM月dd日HH时mm分"); |
| | | String typeName = byId.getTypeName(); |
| | | String cdNm = byId.getCdName(); |
| | | String value = byId.getValue(); |
| | | String level =String.valueOf( byId.getLevel()); |
| | | String level = String.valueOf(byId.getLevel()); |
| | | |
| | | String content=StringUtil.format("{}在{}时监测到{}{}测点值为{},预警等级为{}级", |
| | | resNm,tm,typeName,cdNm,value,level); |
| | | String content = StringUtil.format("{}在{}时监测到{}{}测点值为{},预警等级为{}级", |
| | | resNm, tm, typeName, cdNm, value, level); |
| | | String resCd = byId.getDamId(); |
| | | |
| | | //创建巡查任务 |
| | | String taskId = patrolTaskClient.createTask(processDefinitionId,taskType,title,content,resCd); |
| | | String taskId = patrolTaskClient.createTask(processDefinitionId, taskType, title, content, resCd); |
| | | alarmGet.setTaskId(taskId); |
| | | return alarmGetService.updateById(alarmGet); |
| | | } |
| | |
| | | |
| | | AlarmGet alarmGet = alarmGetService.getOne(new QueryWrapper<AlarmGet>().eq("TASK_ID", taskId)); |
| | | |
| | | if (alarmGet != null){ |
| | | if (alarmGet != null) { |
| | | //设置预警为已处理 |
| | | alarmGet.setStatus("1"); |
| | | Boolean aBoolean = updateStatus(alarmGet); |
| | | return aBoolean; |
| | | return aBoolean; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(INIT_ALGORITHM) |
| | | public void initAlgorithm(List<String> resList) { |
| | | List<ResDamMonitorResult> resDamMonitorResultList = ztApiService.getResDamMonitor(); |
| | | //获取水库之后,根据标识是否有监测站请求测点 |
| | | resDamMonitorResultList.forEach(resDamMonitorResult -> { |
| | | String resGuid = resDamMonitorResult.getCode(); |
| | | if (resDamMonitorResult.getIs_sy().equals("1")){ |
| | | activeAlgorithm(resGuid,"sy","1"); |
| | | } |
| | | if (resDamMonitorResult.getIs_sl().equals("1")){ |
| | | activeAlgorithm(resGuid,"sl","2"); |
| | | } |
| | | if (resDamMonitorResult.getIs_wy().equals("1")){ |
| | | activeAlgorithm(resGuid,"wy","3,4,5"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void activeAlgorithm(String resGuid,String type,String nkyType){ |
| | | String taskCategory = "2107"; |
| | | List<BaseCd> cdList = ztApiService.getBaseCd(resGuid,type); |
| | | List<String> nkyTypeList = Arrays.asList(nkyType.split(",")); |
| | | |
| | | |
| | | cdList.forEach(baseCd -> { |
| | | String pointId = baseCd.getCd(); |
| | | |
| | | nkyTypeList.forEach(nkyTypeFlag->{ |
| | | |
| | | //请求测点之后,循环测点,判断算法绑定情况 |
| | | List<NkyBindDetailResult> nkyBindDetailResultList = nkyService.getBindDetail(baseCd.getRes_cd(),baseCd.getCd(),nkyTypeFlag); |
| | | //过滤出 多元线性回归预测模型异常判定 algorithmCategory: 2107 |
| | | List<NkyBindDetailResult> filterCollect = nkyBindDetailResultList.stream().filter(nkyBindDetailResult -> nkyBindDetailResult.getAlgorithmCategory().equals(taskCategory)).collect(Collectors.toList()); |
| | | |
| | | if (filterCollect.size() == 0){ |
| | | //如果是空的,说明没有启用该算法;先启用该算法 |
| | | // JSONObject bindEnableParams = new JSONObject(); |
| | | // |
| | | // bindEnableParams.put("status",1); |
| | | // bindEnableParams.put("taskCategory",taskCategory); |
| | | // bindEnableParams.put("damId",resGuid); |
| | | // bindEnableParams.put("pointId",pointId); |
| | | // bindEnableParams.put("type",nkyTypeFlag); |
| | | // boolean bindEnableRes = nkyService.bindEnable(bindEnableParams); |
| | | // //成功启用,设置值 |
| | | // if (bindEnableRes){ |
| | | // |
| | | // JSONObject bindParamParams = new JSONObject(); |
| | | // |
| | | // bindParamParams.put("damId",resGuid); |
| | | // bindParamParams.put("pointId",pointId); |
| | | // bindParamParams.put("type",nkyTypeFlag); |
| | | // bindParamParams.put("algorithmCategory",taskCategory); |
| | | // bindParamParams.put("reserve1","4,3.3,2.7,2"); |
| | | // |
| | | // boolean bindParamRes = nkyService.bindParam(bindParamParams); |
| | | // } |
| | | |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.gistack.nky.entity.ArimaPredict; |
| | | import cn.gistack.nky.entity.HstPredict; |
| | | import cn.gistack.nky.requestpojo.*; |
| | | import cn.gistack.nky.resultpojo.NkyBindDetailResult; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @PROJECT_NAME: skjcmanager |
| | |
| | | * @param alarmGetPo |
| | | */ |
| | | AlarmGet alarmGetData(AlarmGetPo alarmGetPo); |
| | | |
| | | List<NkyBindDetailResult> getBindDetail(String resCd, String cd, String s); |
| | | |
| | | boolean bindEnable(JSONObject params); |
| | | |
| | | boolean bindParam(JSONObject bindParamParams); |
| | | } |
| | |
| | | package cn.gistack.nky.service; |
| | | |
| | | |
| | | import cn.gistack.nky.resultpojo.DataBigResultPojo; |
| | | import cn.gistack.nky.resultpojo.DataResChildrenPo; |
| | | import cn.gistack.nky.resultpojo.DataResPo; |
| | | import cn.gistack.nky.resultpojo.*; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | | import java.util.List; |
| | |
| | | List<DataResPo> getResSl(); |
| | | |
| | | List<DataResChildrenPo> getSl(); |
| | | |
| | | List<ResDamMonitorResult> getResDamMonitor(); |
| | | |
| | | List<BaseCd> getBaseCd(String code, String sy); |
| | | } |
| | |
| | | import cn.gistack.nky.entity.HstPredict; |
| | | import cn.gistack.nky.entity.RequestRecord; |
| | | import cn.gistack.nky.requestpojo.*; |
| | | import cn.gistack.nky.resultpojo.NkyBindDetailResult; |
| | | import cn.gistack.nky.service.INkyService; |
| | | import cn.gistack.nky.service.IRequestRecordService; |
| | | import com.alibaba.fastjson.JSON; |
| | |
| | | |
| | | //判定异常 |
| | | private static final String ALARM_GET = "alarm/get"; |
| | | |
| | | private static final String BIND_DETAIL = "bind/detail"; |
| | | private static final String BIND_ENABLE = "bind/enable"; |
| | | private static final String BIND_PARAM = "bind/param"; |
| | | |
| | | @Override |
| | | public Boolean arimaPredict(ArimaPredictReqPo po) { |
| | |
| | | return alarmGet; |
| | | } |
| | | |
| | | @Override |
| | | public List<NkyBindDetailResult> getBindDetail(String resCd, String cd, String type) { |
| | | |
| | | JSONObject params = new JSONObject(); |
| | | params.put("damId",resCd); |
| | | params.put("pointId",cd); |
| | | params.put("type",type); |
| | | |
| | | JSONObject result = requestNkyApi(BIND_DETAIL, JSON.toJSONString(params)); |
| | | |
| | | JSONArray dataList = result.getJSONArray("data"); |
| | | List<NkyBindDetailResult> nkyBindDetailResultList = dataList.toJavaList(NkyBindDetailResult.class); |
| | | return nkyBindDetailResultList; |
| | | } |
| | | |
| | | @Override |
| | | public boolean bindEnable(JSONObject params) { |
| | | JSONObject jsonObject = requestNkyApi(BIND_ENABLE, JSON.toJSONString(params)); |
| | | |
| | | if (jsonObject.get("status").equals("200")) { |
| | | return true; |
| | | }else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean bindParam(JSONObject bindParamParams) { |
| | | JSONObject jsonObject = requestNkyApi(BIND_PARAM, JSON.toJSONString(bindParamParams)); |
| | | |
| | | if (jsonObject.get("status").equals("200")) { |
| | | return true; |
| | | }else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 请求南科院接口 |
| | | * @param url |
| | |
| | | JSONObject jsonObject = JSONObject.parseObject(resultStr); |
| | | return jsonObject; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package cn.gistack.nky.service.impl; |
| | | |
| | | import cn.gistack.common.utils.SpringContextUtil; |
| | | import cn.gistack.nky.resultpojo.DataBigResultPojo; |
| | | import cn.gistack.nky.resultpojo.DataResChildrenPo; |
| | | import cn.gistack.nky.resultpojo.DataResPo; |
| | | import cn.gistack.nky.resultpojo.ZtResultPo; |
| | | import cn.gistack.nky.resultpojo.*; |
| | | import cn.gistack.nky.service.IZtApiService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | |
| | | * 渗流监测 |
| | | */ |
| | | private static final String SL_API ="/services/1234567890ABCDEFGHIJKLMN/monitor/sl/api?res_nm=&cd=&city_cd=&county_cd=&pageNo=1&pageSize=9999"; |
| | | |
| | | private static final String RES_DAM_MONITOR ="/services/1234567890ABCDEFGHIJKLMN/res_dam_monitor/api?province_cd=420000000000&res_nm="; |
| | | private static final String BASE_CD ="/services/1234567890ABCDEFGHIJKLMN/base/cd/api"; |
| | | |
| | | |
| | | int getSyCount = 0; |
| | |
| | | public List<DataResChildrenPo> getSl() { |
| | | Map<String, Object> params = new LinkedHashMap<>(); |
| | | return getData(SL_API, "get", params); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResDamMonitorResult> getResDamMonitor() { |
| | | Map<String, Object> params = new LinkedHashMap<>(); |
| | | return getResDamMonitorResult(RES_DAM_MONITOR, "get", params); |
| | | } |
| | | |
| | | @Override |
| | | public List<BaseCd> getBaseCd(String resGuid, String type) { |
| | | Map<String, Object> params = new LinkedHashMap<>(); |
| | | String url = BASE_CD + StringUtil.format("?res_cd={}&type={}",resGuid,type); |
| | | // 获取环境 |
| | | String activeProfile = SpringContextUtil.getActiveProfile(); |
| | | if (activeProfile.equals("dev")) { |
| | | url = LOCAL+ url ; |
| | | } |
| | | if (activeProfile.equals("prod")) { |
| | | url = ONLINE+ url ; |
| | | } |
| | | if (activeProfile.equals("test")) { |
| | | url = ONLINE + url; |
| | | } |
| | | |
| | | HttpMethod method; |
| | | method = HttpMethod.GET; |
| | | // 声明一个header变量 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 设置apikey |
| | | headers.set("apikey",API_KEY); |
| | | |
| | | HttpEntity<String> httpEntity = new HttpEntity(null, headers); |
| | | log.info("中台请求地址:{}", url); |
| | | RestTemplate template = new RestTemplate(); |
| | | ResponseEntity<ZtResultPo2> ztResultPojoResponseEntity = template.exchange(url, method,httpEntity, ZtResultPo2.class,params); |
| | | List<BaseCd> returnResult = new ArrayList<>(); |
| | | if (ztResultPojoResponseEntity.getStatusCodeValue() == 200) { |
| | | returnResult = ztResultPojoResponseEntity.getBody().getData(); |
| | | } |
| | | return returnResult; |
| | | } |
| | | |
| | | private List<DataResChildrenPo> getData(String url, String type, Map<String, Object> params) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private List<ResDamMonitorResult> getResDamMonitorResult(String url, String type, Map<String, Object> params){ |
| | | |
| | | // 获取环境 |
| | | String activeProfile = SpringContextUtil.getActiveProfile(); |
| | | if (activeProfile.equals("dev")) { |
| | | url = LOCAL+ url ; |
| | | } |
| | | if (activeProfile.equals("prod")) { |
| | | url = ONLINE+ url ; |
| | | } |
| | | if (activeProfile.equals("test")) { |
| | | url = ONLINE + url; |
| | | } |
| | | |
| | | |
| | | HttpMethod method; |
| | | if (type.toLowerCase().equals("get".toLowerCase())) { |
| | | method = HttpMethod.GET; |
| | | } else { |
| | | method = HttpMethod.POST; |
| | | } |
| | | // 声明一个header变量 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 设置apikey |
| | | headers.set("apikey",API_KEY); |
| | | |
| | | HttpEntity<String> httpEntity = new HttpEntity(null, headers); |
| | | log.info("中台请求地址:{}", url); |
| | | RestTemplate template = new RestTemplate(); |
| | | ResponseEntity<ZtResult> ztResultPojoResponseEntity = template.exchange(url, method,httpEntity, ZtResult.class,params); |
| | | if (ztResultPojoResponseEntity.getStatusCodeValue() == 200) { |
| | | List<ResDamMonitorResult> resDamMonitorResultList = ztResultPojoResponseEntity.getBody().getResultList(); |
| | | return resDamMonitorResultList; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.sjztmd.controller; |
| | | |
| | | import cn.gistack.sm.sjztmd.entity.AttWmstBase; |
| | | import cn.gistack.sm.sjztmd.service.IAttWmstBaseService; |
| | | import cn.gistack.sm.sjztmd.vo.AttWmstBaseVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | |
| | | @Slf4j |
| | | @Api(tags = "视频") |
| | | @RestController |
| | | @RequestMapping("/sjztmd/attWmstBase") |
| | | @AllArgsConstructor |
| | | public class AttWmstBaseController { |
| | | private final IAttWmstBaseService attWmstBaseService; |
| | | |
| | | @GetMapping("/getPage") |
| | | public R getPage(Query query , AttWmstBaseVO attWmstBaseVO){ |
| | | IPage<AttWmstBaseVO> page = attWmstBaseService.getPage(Condition.getPage(query),attWmstBaseVO); |
| | | return R.data(page); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | public R update(AttWmstBase attWmstBase){ |
| | | boolean res = attWmstBaseService.customizeUpdate(attWmstBase); |
| | | return R.data(res); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.sjztmd.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * 视频(中台表) |
| | | */ |
| | | @Data |
| | | @TableName("\"att_wmst_base\"") |
| | | public class AttWmstBase { |
| | | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableField("\"guid\"") |
| | | @TableId("\"guid\"") |
| | | private String guid; |
| | | |
| | | /** |
| | | * 水库id |
| | | */ |
| | | @ApiModelProperty(value = "水库id") |
| | | @TableField("\"res_guid\"") |
| | | private String resGuid; |
| | | |
| | | /** |
| | | * 视频id |
| | | */ |
| | | @ApiModelProperty(value = "视频id") |
| | | @TableField("\"video_guid\"") |
| | | private String videoGuid; |
| | | |
| | | /** |
| | | * 视频点名称 |
| | | */ |
| | | @ApiModelProperty(value = "视频点名称") |
| | | @TableField("\"video_name\"") |
| | | private String videoName; |
| | | |
| | | /** |
| | | * 在线状态(0离线,1在线) |
| | | */ |
| | | @ApiModelProperty(value = "在线状态(0离线,1在线)") |
| | | @TableField("\"online\"") |
| | | private String online; |
| | | |
| | | /** |
| | | * 在线状态(1海康老平台,2海康楚天云平台) |
| | | */ |
| | | @ApiModelProperty(value = "来源") |
| | | @TableField("\"sys_resource\"") |
| | | private String sysResource; |
| | | |
| | | /** |
| | | * 建站时间 |
| | | */ |
| | | @ApiModelProperty(value = "建站时间") |
| | | @TableField("\"comp_time\"") |
| | | private String compTime; |
| | | |
| | | |
| | | /** |
| | | * 厂商 |
| | | */ |
| | | @ApiModelProperty(value = "厂商") |
| | | @TableField("\"factory\"") |
| | | private String factory; |
| | | |
| | | |
| | | /** |
| | | * 采集时间 |
| | | */ |
| | | @ApiModelProperty(value = "采集时间") |
| | | @TableField("\"collect_time\"") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private String collectTime; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.sjztmd.mapper; |
| | | |
| | | import cn.gistack.sm.sjztmd.entity.AttWmstBase; |
| | | import cn.gistack.sm.sjztmd.entity.YwTermitesTask; |
| | | import cn.gistack.sm.sjztmd.vo.AttWmstBaseVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | public interface AttWmstBaseMapper extends BaseMapper<AttWmstBase> { |
| | | |
| | | List<AttWmstBaseVO> getPage(IPage<AttWmstBaseVO> page, AttWmstBaseVO attWmstBaseVO); |
| | | |
| | | boolean customizeUpdate(@Param("attWmstBase") AttWmstBase attWmstBase); |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.sm.sjztmd.mapper.AttWmstBaseMapper"> |
| | | |
| | | |
| | | <update id="customizeUpdate"> |
| | | UPDATE SJZT_MD."att_wmst_base" |
| | | SET "res_guid" = #{attWmstBase.resGuid} |
| | | where "guid" = #{attWmstBase.guid} |
| | | </update> |
| | | </mapper> |
| New file |
| | |
| | | package cn.gistack.sm.sjztmd.service; |
| | | |
| | | import cn.gistack.sm.sjztmd.entity.AttWmstBase; |
| | | import cn.gistack.sm.sjztmd.vo.AttWmstBaseVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | public interface IAttWmstBaseService { |
| | | IPage<AttWmstBaseVO> getPage(IPage<AttWmstBaseVO> page, AttWmstBaseVO videoClassVO); |
| | | |
| | | boolean customizeUpdate(AttWmstBase attWmstBase); |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.sjztmd.service.impl; |
| | | |
| | | import cn.gistack.sm.sjztmd.entity.AttWmstBase; |
| | | import cn.gistack.sm.sjztmd.mapper.AttWmstBaseMapper; |
| | | import cn.gistack.sm.sjztmd.service.IAttWmstBaseService; |
| | | import cn.gistack.sm.sjztmd.vo.AttWmstBaseVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class AttWmstBaseServiceImpl extends ServiceImpl<AttWmstBaseMapper,AttWmstBase> implements IAttWmstBaseService { |
| | | @Override |
| | | public IPage<AttWmstBaseVO> getPage(IPage<AttWmstBaseVO> page, AttWmstBaseVO attWmstBaseVO) { |
| | | return page.setRecords(baseMapper.getPage(page,attWmstBaseVO)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean customizeUpdate(AttWmstBase attWmstBase) { |
| | | return baseMapper.customizeUpdate(attWmstBase); |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.sjztmd.vo; |
| | | |
| | | import cn.gistack.sm.sjztmd.entity.AttWmstBase; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class AttWmstBaseVO extends AttWmstBase { |
| | | } |
| | |
| | | |
| | | import cn.gistack.job.executor.thread.MyThread; |
| | | import cn.gistack.nky.fegin.INkyClient; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.xxl.job.core.log.XxlJobLogger; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 南科院预测数据定时器 |
| | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @XxlJob("initAlgorithmHandler") |
| | | public ReturnT<String> initAlgorithmHandler(String param) { |
| | | XxlJobLogger.log("定时器执行时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(DateUtil.now())); |
| | | |
| | | JSONObject jsonParam = JSON.parseObject(param); |
| | | List<String> resList = new ArrayList<>(); |
| | | if (jsonParam != null){ |
| | | String resGuids = jsonParam.getString("resGuids"); |
| | | resList = Arrays.asList(resGuids.split(",")); |
| | | } |
| | | |
| | | nkyClient.initAlgorithm(resList); |
| | | |
| | | |
| | | XxlJobLogger.log("定时器执行结束时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(DateUtil.now())); |
| | | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | |
| | | } |