Commit c91baf41 authored by hezhuozhi's avatar hezhuozhi

Merge remote-tracking branch 'origin/developer' into developer

parents aff995c7 f20f68ae
...@@ -65,7 +65,7 @@ public class IcbcEnum { ...@@ -65,7 +65,7 @@ public class IcbcEnum {
@Getter @Getter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
enum ProtocolStatus { public static enum ProtocolStatus {
NOT_EFFECTIVE("未生效", "0"), NOT_EFFECTIVE("未生效", "0"),
...@@ -86,5 +86,17 @@ public class IcbcEnum { ...@@ -86,5 +86,17 @@ public class IcbcEnum {
*/ */
private String code; private String code;
public static String getNameByCode(String code, String defaultName) {
for (ProtocolStatus state : ProtocolStatus.values()) {
if (state.getCode().equals(code)) {
return state.getName();
}
}
if (StringUtils.isNotEmpty(defaultName)) {
return defaultName;
}
return null;
}
} }
} }
...@@ -32,10 +32,10 @@ public class HygfIcbcRecordQueryDTO { ...@@ -32,10 +32,10 @@ public class HygfIcbcRecordQueryDTO {
private String phone; private String phone;
@ApiModelProperty (value = "区域公司") @ApiModelProperty (value = "区域公司")
private String regionalCompaniesSeq; private String regionalCompaniesName;
@ApiModelProperty (value = "所属地址") @ApiModelProperty (value = "所属地址")
private String address; private String addressName;
private Integer current; private Integer current;
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
</sql> </sql>
<select id="listObjectCount" resultType="integer"> <select id="listObjectCount" resultType="integer">
SELECT count(1) SELECT
count( DISTINCT ph.amos_user_id )
FROM FROM
hygf_peasant_household ph LEFT JOIN hygf_icbc_record icbc ON ph.amos_user_id = icbc.amos_user_id hygf_peasant_household ph LEFT JOIN hygf_icbc_record icbc ON ph.amos_user_id = icbc.amos_user_id
<where> <where>
...@@ -28,21 +29,22 @@ ...@@ -28,21 +29,22 @@
<if test="param.phone != null and param.phone != ''"> <if test="param.phone != null and param.phone != ''">
AND ph.telephone LIKE CONCAT('%', #{param.phone}, '%') AND ph.telephone LIKE CONCAT('%', #{param.phone}, '%')
</if> </if>
<if test="param.regionalCompaniesSeq != null and param.regionalCompaniesSeq != ''"> <if test="param.regionalCompaniesName != null and param.regionalCompaniesName != ''">
AND ph.regional_companies_seq = #{param.regionalCompaniesSeq} AND ph.regional_companies_name LIKE CONCAT('%', #{param.regionalCompaniesName}, '%')
</if>
<if test="param.addressName != null and param.addressName != ''">
AND ph.project_address LIKE CONCAT('%', #{param.addressName}, '%')
</if> </if>
</if> </if>
</where> </where>
GROUP BY
ph.amos_user_id
</select> </select>
<select id="listObject" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO"> <select id="listObject" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO">
SELECT DISTINCT SELECT DISTINCT
icbc.sequence_nbr, icbc.sequence_nbr,
ph.owners_name as custName, ifnull(icbc.cust_name, ph.owners_name) as custName,
ph.telephone as phone, ifnull(icbc.phone, ph.telephone) as phone,
ph.id_card, ifnull(icbc.id_card, ph.id_card) as idCard,
ph.amos_user_id, ph.amos_user_id,
icbc.open_account_status, icbc.open_account_status,
icbc.protocol_status icbc.protocol_status
...@@ -63,8 +65,11 @@ ...@@ -63,8 +65,11 @@
<if test="param.phone != null and param.phone != ''"> <if test="param.phone != null and param.phone != ''">
AND ph.telephone LIKE CONCAT('%', #{param.phone}, '%') AND ph.telephone LIKE CONCAT('%', #{param.phone}, '%')
</if> </if>
<if test="param.regionalCompaniesSeq != null and param.regionalCompaniesSeq != ''"> <if test="param.regionalCompaniesName != null and param.regionalCompaniesName != ''">
AND ph.regional_companies_seq = #{param.regionalCompaniesSeq} AND ph.regional_companies_name LIKE CONCAT('%', #{param.regionalCompaniesName}, '%')
</if>
<if test="param.addressName != null and param.addressName != ''">
AND ph.project_address LIKE CONCAT('%', #{param.addressName}, '%')
</if> </if>
</if> </if>
</where> </where>
......
...@@ -85,14 +85,14 @@ public class HygfIcbcController extends BaseController { ...@@ -85,14 +85,14 @@ public class HygfIcbcController extends BaseController {
return hygfIcbcService.registerWalletCallback(request, response); return hygfIcbcService.registerWalletCallback(request, response);
} }
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation (ApiLevel = UserType.AGENCY)
@GetMapping (value = "/{sequenceNbr}") @GetMapping (value = "/{userId}")
@ApiOperation (httpMethod = "GET", value = "根据sequenceNbr查询注册电子钱包", notes = "注册电子钱包") @ApiOperation (httpMethod = "GET", value = "根据农户userId查询注册电子钱包", notes = "注册电子钱包")
public ResponseModel<HygfIcbcRecordDTO> getObject(@PathVariable String sequenceNbr) { public ResponseModel<HygfIcbcRecordDTO> getObject(@PathVariable String userId) {
return ResponseHelper.buildResponse(hygfIcbcService.getObject(Long.valueOf(sequenceNbr))); return ResponseHelper.buildResponse(hygfIcbcService.getObject(userId));
} }
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation (ApiLevel = UserType.AGENCY)
@GetMapping (value = "/list") @GetMapping (value = "/list")
@ApiOperation (httpMethod = "GET", value = "聚富通电子钱包列表查询", notes = "聚富通电子钱包列表查询") @ApiOperation (httpMethod = "GET", value = "聚富通电子钱包列表查询", notes = "聚富通电子钱包列表查询")
@UserLimits @UserLimits
......
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.icbc.api.DefaultIcbcClient; import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException; import com.icbc.api.IcbcApiException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.icbc.api.IcbcConstants; import com.icbc.api.IcbcConstants;
import com.icbc.api.UiIcbcClient; import com.icbc.api.UiIcbcClient;
import com.icbc.api.request.JftApiUserEntrustopenacctQueryRequestV1; import com.icbc.api.request.JftApiUserEntrustopenacctQueryRequestV1;
...@@ -22,11 +22,9 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold; ...@@ -22,11 +22,9 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.mapper.HygfIcbcRecordMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.HygfIcbcRecordMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IHygfIcbcService; import com.yeejoin.amos.boot.module.hygf.api.service.IHygfIcbcService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -40,6 +38,7 @@ import java.net.URLDecoder; ...@@ -40,6 +38,7 @@ import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -48,6 +47,9 @@ import java.util.Collections; ...@@ -48,6 +47,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -150,7 +152,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -150,7 +152,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
bizContent.setProtocolEndDate(formattedDate); // 协议到期日 bizContent.setProtocolEndDate(formattedDate); // 协议到期日
bizContent.setProtocolLimitAmount(protocolLimitAmount); // 协议累计额 bizContent.setProtocolLimitAmount(protocolLimitAmount); // 协议累计额
JSONObject templateParams = new JSONObject(); JSONObject templateParams = new JSONObject();
templateParams.put("prtl_enddate", formattedDate);//协议到期日 templateParams.put("prtl_enddate", formattedDate);// 协议到期日
templateParams.put("loan_total_amt", loanTotalAmt);// 贷款限额(单位:分) templateParams.put("loan_total_amt", loanTotalAmt);// 贷款限额(单位:分)
templateParams.put("trx_lmt_amt", trxLmtAmt);// 单笔限额(单位:分) templateParams.put("trx_lmt_amt", trxLmtAmt);// 单笔限额(单位:分)
templateParams.put("day_lmt_amt", dayLmtAmt);// 日累计限额(单位:分) templateParams.put("day_lmt_amt", dayLmtAmt);// 日累计限额(单位:分)
...@@ -201,11 +203,16 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -201,11 +203,16 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
request.setBizContent(bizContent); request.setBizContent(bizContent);
JftApiUserEntrustopenacctQueryResponseV1 response; JftApiUserEntrustopenacctQueryResponseV1 response;
try { try {
log.info("户用光伏开户签约同步开户结果查询数据接口, => 入参: {}", JSON.toJSONString(request));
response = client.execute(request, System.currentTimeMillis() + ""); response = client.execute(request, System.currentTimeMillis() + "");
log.info("户用光伏开户签约同步开户结果查询数据接口, => 响应: {}", JSON.toJSONString(response));
return response; return response;
} catch (IcbcApiException e) { } catch (IcbcApiException e) {
e.printStackTrace(); e.printStackTrace();
log.error("聚富通委托代扣签约同步开户结果查询数据接口error: ", e); log.error("户用光伏开户签约同步开户结果查询数据接口 error: ", e);
return null;
} catch (Exception e) {
log.error("户用光伏开户签约同步开户结果查询数据接口 error: ", e);
return null; return null;
} }
} }
...@@ -222,8 +229,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -222,8 +229,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
*/ */
public Object registerWalletCallback(HttpServletRequest request, HttpServletResponse response) throws Exception { public Object registerWalletCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("户用光伏开户签约异步通知, => 验签"); log.info("户用光伏开户签约异步通知, => 验签");
boolean verifyFlag = verifySignData(request, callbackUrl); String returnJson = null;
String returnJson; try {
boolean verifyFlag = verifySignData(request, "/hygf/icbc/notify");
if (verifyFlag) { if (verifyFlag) {
// 验签成功 // 验签成功
String biz_content = request.getParameter("biz_content"); String biz_content = request.getParameter("biz_content");
...@@ -246,7 +254,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -246,7 +254,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
} }
hygfIcbcRecord.setCustName(custName); hygfIcbcRecord.setCustName(custName);
hygfIcbcRecord.setIdCard(certNo); hygfIcbcRecord.setIdCard(certNo);
// hygfIcbcRecord.setPhone(); PeasantHousehold peasantHousehold = peasantHouseholdService.lambdaQuery().select(PeasantHousehold::getTelephone).eq(PeasantHousehold::getAmosUserId, outUserId).last("limit 1").one();
hygfIcbcRecord.setPhone(peasantHousehold != null ? peasantHousehold.getTelephone() : "");
hygfIcbcRecord.setMediumId(newPayAcc); hygfIcbcRecord.setMediumId(newPayAcc);
hygfIcbcRecord.setProjectId(projectId); hygfIcbcRecord.setProjectId(projectId);
hygfIcbcRecord.setOpenAccountStatus(openAccoutSucceedFlag); hygfIcbcRecord.setOpenAccountStatus(openAccoutSucceedFlag);
...@@ -278,11 +287,35 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -278,11 +287,35 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
returnJson = sign(request, copReturnCode, copReturnMsg); returnJson = sign(request, copReturnCode, copReturnMsg);
log.error("通知响应json结果:{}", returnJson); log.error("通知响应json结果:{}", returnJson);
} }
} catch (Exception e) {
log.error("户用光伏开户签约异步通知, => error:", e);
}
return returnJson; return returnJson;
} }
public HygfIcbcRecordDTO getObject(Long sequenceNbr) { public HygfIcbcRecordDTO getObject(String amosUserId) {
HygfIcbcRecordDTO hygfIcbcRecordDTO = this.queryBySeq(sequenceNbr); HygfIcbcRecord hygfIcbcRecord = this.lambdaQuery().eq(HygfIcbcRecord::getAmosUserId, amosUserId).last("limit 1").one();
HygfIcbcRecordDTO hygfIcbcRecordDTO = new HygfIcbcRecordDTO();
if (hygfIcbcRecord == null) {
PeasantHousehold peasantHousehold = peasantHouseholdService.lambdaQuery()
.select(PeasantHousehold::getTelephone, PeasantHousehold::getOwnersName, PeasantHousehold::getIdCard)
.eq(PeasantHousehold::getAmosUserId, amosUserId).last("limit 1").one();
hygfIcbcRecordDTO.setCustName(peasantHousehold.getOwnersName());
hygfIcbcRecordDTO.setIdCard(peasantHousehold.getIdCard());
hygfIcbcRecordDTO.setPhone(peasantHousehold.getTelephone());
hygfIcbcRecordDTO.setOpenAccountStatus(IcbcEnum.OpenAccountState.INITIAL.getCode());
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(IcbcEnum.OpenAccountState.INITIAL.getCode(), IcbcEnum.OpenAccountState.INITIAL.getName()));
} else {
Bean.toModel(hygfIcbcRecord, hygfIcbcRecordDTO);
List<String> amosUserIds = Arrays.asList(hygfIcbcRecordDTO.getAmosUserId());
List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery().in(PeasantHousehold::getAmosUserId, amosUserIds).list();
Map<String, List<PeasantHousehold>> PeasantHouseholdMap = peasantHouseholds.stream().collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
List<PeasantHousehold> peasantHouseholdList = PeasantHouseholdMap.get(hygfIcbcRecordDTO.getAmosUserId());
hygfIcbcRecordDTO.setPeasantHouseholds(Bean.toModels(peasantHouseholdList, HygfIcbcRecordDTO.IcbcPeasantHousehold.class));
}
return hygfIcbcRecordDTO; return hygfIcbcRecordDTO;
} }
...@@ -295,7 +328,12 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -295,7 +328,12 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
// PageHelper.startPage(current, size); // PageHelper.startPage(current, size);
Integer total = hygfIcbcRecordMapper.listObjectCount(hygfIcbcRecordQueryDTO); Integer total = hygfIcbcRecordMapper.listObjectCount(hygfIcbcRecordQueryDTO);
hygfIcbcRecordQueryDTO.setLimit(size); hygfIcbcRecordQueryDTO.setLimit(size);
if (current == 0) {
hygfIcbcRecordQueryDTO.setOffset(0);
} else {
// int offset = (current - 1) * size > total ? : (current - 1) * size;
hygfIcbcRecordQueryDTO.setOffset((current - 1) * size); hygfIcbcRecordQueryDTO.setOffset((current - 1) * size);
}
List<HygfIcbcRecordDTO> list = hygfIcbcRecordMapper.listObject(hygfIcbcRecordQueryDTO); List<HygfIcbcRecordDTO> list = hygfIcbcRecordMapper.listObject(hygfIcbcRecordQueryDTO);
Page<HygfIcbcRecordDTO> page = new Page<>(); Page<HygfIcbcRecordDTO> page = new Page<>();
page.setSize(size); page.setSize(size);
...@@ -310,12 +348,17 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -310,12 +348,17 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
return Collections.emptyList(); return Collections.emptyList();
} }
List<String> amosUserIds = hygfIcbcRecords.stream().map(HygfIcbcRecordDTO::getAmosUserId).collect(Collectors.toList()); List<String> amosUserIds = hygfIcbcRecords.stream().map(HygfIcbcRecordDTO::getAmosUserId).collect(Collectors.toList());
List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery().in(PeasantHousehold::getAmosUserId, amosUserIds).list(); List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery().select(PeasantHousehold::getAmosUserId, PeasantHousehold::getRegionalCompaniesName).in(PeasantHousehold::getAmosUserId, amosUserIds).list();
Map<String, List<PeasantHousehold>> PeasantHouseholdMap = peasantHouseholds.stream().collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组 Map<String, List<PeasantHousehold>> PeasantHouseholdMap = peasantHouseholds.stream().collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组
return hygfIcbcRecords.stream().map(hygfIcbcRecordDTO -> { return hygfIcbcRecords.stream().map(hygfIcbcRecordDTO -> {
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName())); hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
List<PeasantHousehold> peasantHouseholdList = PeasantHouseholdMap.get(hygfIcbcRecordDTO.getAmosUserId()); List<PeasantHousehold> peasantHouseholdList = PeasantHouseholdMap.get(hygfIcbcRecordDTO.getAmosUserId());
hygfIcbcRecordDTO.setPeasantHouseholds(Bean.toModels(peasantHouseholdList, HygfIcbcRecordDTO.IcbcPeasantHousehold.class)); if (!CollectionUtils.isEmpty(peasantHouseholdList)) {
// 根据区域经销商名称去重
List<HygfIcbcRecordDTO.IcbcPeasantHousehold> icbcPeasantHouseholds = Bean.toModels(peasantHouseholdList, HygfIcbcRecordDTO.IcbcPeasantHousehold.class);
hygfIcbcRecordDTO.setPeasantHouseholds(icbcPeasantHouseholds.stream().filter(distinctByKey(HygfIcbcRecordDTO.IcbcPeasantHousehold::getRegionalCompaniesName)).collect(Collectors.toList()));
}
return hygfIcbcRecordDTO; return hygfIcbcRecordDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
...@@ -341,6 +384,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -341,6 +384,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String biz_content = request.getParameter("biz_content"); String biz_content = request.getParameter("biz_content");
String sign_type = request.getParameter("sign_type"); String sign_type = request.getParameter("sign_type");
String sign = request.getParameter("sign"); String sign = request.getParameter("sign");
log.info("verifySignData入参,from:[[{}]], api:[[{}]], app_id:[[{}]], charset:[[{}]], format:[[{}]], encrypt_type:[[{}]], timestamp:[[{}]], biz_content:[[{}]], sign_type:[[{}]], sign:[[{}]]", from, api, app_id, charset, format, encrypt_type);
params.put("from", from); params.put("from", from);
params.put("api", api); params.put("api", api);
params.put("app_id", app_id); params.put("app_id", app_id);
...@@ -352,9 +396,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -352,9 +396,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
params.put("sign_type", sign_type);// 目前上行网关签名暂时仅支持RSA params.put("sign_type", sign_type);// 目前上行网关签名暂时仅支持RSA
/**********验证工行上行网关RSA签名**********/ /**********验证工行上行网关RSA签名**********/
String signStr = WebUtils.buildOrderedSignStr(path, params); String signStr = WebUtils.buildOrderedSignStr(path, params);
log.error("验签入参,signStr:[[{}]], sign_type:[[{}]], APIGW_PUBLIC_KEY: [[{}]],charset:[[{}]],sign:[[{}]]", signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign); log.info("验签入参,signStr:[[{}]], sign_type:[[{}]], APIGW_PUBLIC_KEY: [[{}]],charset:[[{}]],sign:[[{}]]", signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign);
boolean flag = IcbcSignature.verify(signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign); boolean flag = IcbcSignature.verify(signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign);
log.error("验签结果:[[{}]]", flag); log.info("验签结果:[[{}]]", flag);
return flag; return flag;
} }
...@@ -372,7 +416,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -372,7 +416,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String responseBizContent = "{\"return_code\":\"" + copReturnCode + "\",\"return_msg\":\"" + copReturnMsg + "\"" + ",\"msg_id\":\"" + msg_id + "\"}"; String responseBizContent = "{\"return_code\":\"" + copReturnCode + "\",\"return_msg\":\"" + copReturnMsg + "\"" + ",\"msg_id\":\"" + msg_id + "\"}";
String charset = request.getParameter("charset");// 调用过程使用的编码格式 String charset = request.getParameter("charset");// 调用过程使用的编码格式
/**********商户对消息返回响应进行签名,签名方式需与在API平台登记APP的sign_type保持一致(目前基本都是RSA2)**********/ /**********商户对消息返回响应进行签名,签名方式需与在API平台登记APP的sign_type保持一致(目前基本都是RSA2)**********/
String signType = IcbcConstants.SIGN_TYPE_RSA2; // String signType = IcbcConstants.SIGN_TYPE_RSA2;
String signType = IcbcConstants.SIGN_TYPE_RSA;
String signStr = "\"response_biz_content\":" + responseBizContent + "," + "\"sign_type\":" + "\"" + signType + "\""; String signStr = "\"response_biz_content\":" + responseBizContent + "," + "\"sign_type\":" + "\"" + signType + "\"";
String signParam = IcbcSignature.sign(signStr, signType, MY_PRIVATE_KEY, charset); String signParam = IcbcSignature.sign(signStr, signType, MY_PRIVATE_KEY, charset);
String returnJson = "{\"response_biz_content\":" + responseBizContent + ",\"sign_type\":\"" + signType + "\"" + ",\"sign\":\"" + signParam + "\"}"; String returnJson = "{\"response_biz_content\":" + responseBizContent + ",\"sign_type\":\"" + signType + "\"" + ",\"sign\":\"" + signParam + "\"}";
...@@ -394,4 +439,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -394,4 +439,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
byte[] bt = Base64.decode(String.valueOf(ch)); byte[] bt = Base64.decode(String.valueOf(ch));
return new String(bt, "UTF-8"); return new String(bt, "UTF-8");
} }
public static <T> Predicate<T> distinctByKey(Function<? super T, Object> distinctField) {
Map<Object, Boolean> distinctMap = new ConcurrentHashMap<>();
return object -> distinctMap.putIfAbsent(distinctField.apply(object), Boolean.TRUE) == null;
}
} }
\ No newline at end of file
...@@ -248,4 +248,4 @@ spring.elasticsearch.rest.password=123456 ...@@ -248,4 +248,4 @@ spring.elasticsearch.rest.password=123456
spring.elasticsearch.rest.read-timeout=30000 spring.elasticsearch.rest.read-timeout=30000
## 聚富通 配置 ## 聚富通 配置
hygf.icbc.callbackUrl=http://47.92.234.253:8088/hygf/icbc/notify hygf.icbc.callbackUrl=https://yth.yunqingtech.com/hygf/icbc/notify
\ No newline at end of file \ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.bean.BeanUtil; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanWarningRecordDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanWarningRecordDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointProcessVariableClassificationMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointProcessVariableClassificationMapper;
...@@ -18,21 +42,10 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRuleS ...@@ -18,21 +42,10 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRuleS
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRuleSetServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* @author system_generator * @author system_generator
...@@ -83,7 +96,8 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -83,7 +96,8 @@ public class IdxBizFanWarningRecordController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}") @PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新") @ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<IdxBizFanWarningRecordDto> updateBySequenceNbrIdxBizFanWarningRecord(@RequestBody IdxBizFanWarningRecordDto model, @PathVariable(value = "sequenceNbr") String sequenceNbr) { public ResponseModel<IdxBizFanWarningRecordDto> updateBySequenceNbrIdxBizFanWarningRecord(
@RequestBody IdxBizFanWarningRecordDto model, @PathVariable(value = "sequenceNbr") String sequenceNbr) {
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.updateWithModel(model)); return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.updateWithModel(model));
} }
...@@ -97,7 +111,8 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -97,7 +111,8 @@ public class IdxBizFanWarningRecordController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}") @DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除", notes = "根据sequenceNbr删除") @ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除", notes = "根据sequenceNbr删除")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) { public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.removeById(sequenceNbr)); return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.removeById(sequenceNbr));
} }
...@@ -124,8 +139,8 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -124,8 +139,8 @@ public class IdxBizFanWarningRecordController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "分页查询", notes = "分页查询") @ApiOperation(httpMethod = "GET", value = "分页查询", notes = "分页查询")
public ResponseModel<Page<IdxBizFanWarningRecordDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam public ResponseModel<Page<IdxBizFanWarningRecordDto>> queryForPage(@RequestParam(value = "current") int current,
(value = "size") int size) { @RequestParam(value = "size") int size) {
Page<IdxBizFanWarningRecordDto> page = new Page<IdxBizFanWarningRecordDto>(); Page<IdxBizFanWarningRecordDto> page = new Page<IdxBizFanWarningRecordDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
...@@ -144,7 +159,6 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -144,7 +159,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.queryForIdxBizFanWarningRecordList()); return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.queryForIdxBizFanWarningRecordList());
} }
/** /**
* 根据sequenceNbr查询 * 根据sequenceNbr查询
* *
...@@ -158,18 +172,19 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -158,18 +172,19 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanWarningRuleSet::getAnalysisPointId, ANALYSISPOINTID); query.eq(IdxBizFanWarningRuleSet::getAnalysisPointId, ANALYSISPOINTID);
List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper().selectList(query); List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper()
.selectList(query);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
for (int i = 0; i < idxBizFanWarningRecordList.size(); i++) { for (int i = 0; i < idxBizFanWarningRecordList.size(); i++) {
IdxBizFanWarningRuleSet idxBizFanWarningRecord = idxBizFanWarningRecordList.get(i); IdxBizFanWarningRuleSet idxBizFanWarningRecord = idxBizFanWarningRecordList.get(i);
if (idxBizFanWarningRecord.getWarningName().equals("注意")) { if (idxBizFanWarningRecord.getWarningName().equals("注意")) {
map.putAll(BeanUtil.beanToMap(idxBizFanWarningRecord)); map.putAll(BeanUtil.beanToMap(idxBizFanWarningRecord));
} else if (idxBizFanWarningRecord.getWarningName().equals("警告")) { } else if (idxBizFanWarningRecord.getWarningName().equals("警告")) {
//警告周期 // 警告周期
map.put("jgWarningCycle", idxBizFanWarningRecord.getWarningCycle()); map.put("jgWarningCycle", idxBizFanWarningRecord.getWarningCycle());
map.put("jgWarningIf", idxBizFanWarningRecord.getWarningIf()); map.put("jgWarningIf", idxBizFanWarningRecord.getWarningIf());
} else if (idxBizFanWarningRecord.getWarningName().equals("危险")) { } else if (idxBizFanWarningRecord.getWarningName().equals("危险")) {
//警告周期 // 警告周期
map.put("wxWarningCycle", idxBizFanWarningRecord.getWarningCycle()); map.put("wxWarningCycle", idxBizFanWarningRecord.getWarningCycle());
map.put("wxWarningIf", idxBizFanWarningRecord.getWarningIf()); map.put("wxWarningIf", idxBizFanWarningRecord.getWarningIf());
} }
...@@ -177,7 +192,6 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -177,7 +192,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(map); return ResponseHelper.buildResponse(map);
} }
/** /**
* 根据pointId修改信息 * 根据pointId修改信息
* *
...@@ -190,15 +204,16 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -190,15 +204,16 @@ public class IdxBizFanWarningRecordController extends BaseController {
public ResponseModel<Boolean> updateByPointInfo(@RequestBody JSONObject analysisInfo) { public ResponseModel<Boolean> updateByPointInfo(@RequestBody JSONObject analysisInfo) {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanWarningRuleSet::getAnalysisPointId, analysisInfo.get("analysisPointId")); query.eq(IdxBizFanWarningRuleSet::getAnalysisPointId, analysisInfo.get("analysisPointId"));
List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper().selectList(query); List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper()
.selectList(query);
for (IdxBizFanWarningRuleSet idxBizFanWarningRuleSet : idxBizFanWarningRecordList) { for (IdxBizFanWarningRuleSet idxBizFanWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "sequenceNbr", "warningName"); BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "sequenceNbr", "warningName");
if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) { if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) {
//警告周期 // 警告周期
idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString()); idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString());
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString()); idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) { } else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) {
//警告周期 // 警告周期
idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString()); idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString());
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString()); idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
} }
...@@ -207,7 +222,6 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -207,7 +222,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(b); return ResponseHelper.buildResponse(b);
} }
/** /**
* 根据sequenceNbr查询 * 根据sequenceNbr查询
* *
...@@ -221,18 +235,19 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -221,18 +235,19 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvWarningRuleSet::getAnalysisPointId, ANALYSISPOINTID); query.eq(IdxBizPvWarningRuleSet::getAnalysisPointId, ANALYSISPOINTID);
List<IdxBizPvWarningRuleSet> idxBizPvWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper().selectList(query); List<IdxBizPvWarningRuleSet> idxBizPvWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper()
.selectList(query);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
for (int i = 0; i < idxBizPvWarningRecordList.size(); i++) { for (int i = 0; i < idxBizPvWarningRecordList.size(); i++) {
IdxBizPvWarningRuleSet idxBizPvWarningRecord = idxBizPvWarningRecordList.get(i); IdxBizPvWarningRuleSet idxBizPvWarningRecord = idxBizPvWarningRecordList.get(i);
if (idxBizPvWarningRecord.getWarningName().equals("注意")) { if (idxBizPvWarningRecord.getWarningName().equals("注意")) {
map.putAll(BeanUtil.beanToMap(idxBizPvWarningRecord)); map.putAll(BeanUtil.beanToMap(idxBizPvWarningRecord));
} else if (idxBizPvWarningRecord.getWarningName().equals("警告")) { } else if (idxBizPvWarningRecord.getWarningName().equals("警告")) {
//警告周期 // 警告周期
map.put("jgWarningCycle", idxBizPvWarningRecord.getWarningCycle()); map.put("jgWarningCycle", idxBizPvWarningRecord.getWarningCycle());
map.put("jgWarningIf", idxBizPvWarningRecord.getWarningIf()); map.put("jgWarningIf", idxBizPvWarningRecord.getWarningIf());
} else if (idxBizPvWarningRecord.getWarningName().equals("危险")) { } else if (idxBizPvWarningRecord.getWarningName().equals("危险")) {
//警告周期 // 警告周期
map.put("wxWarningCycle", idxBizPvWarningRecord.getWarningCycle()); map.put("wxWarningCycle", idxBizPvWarningRecord.getWarningCycle());
map.put("wxWarningIf", idxBizPvWarningRecord.getWarningIf()); map.put("wxWarningIf", idxBizPvWarningRecord.getWarningIf());
} }
...@@ -240,7 +255,6 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -240,7 +255,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(map); return ResponseHelper.buildResponse(map);
} }
/** /**
* 根据pointId修改信息 * 根据pointId修改信息
* *
...@@ -253,15 +267,16 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -253,15 +267,16 @@ public class IdxBizFanWarningRecordController extends BaseController {
public ResponseModel<Boolean> updateByPointInfoPv(@RequestBody JSONObject analysisInfo) { public ResponseModel<Boolean> updateByPointInfoPv(@RequestBody JSONObject analysisInfo) {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvWarningRuleSet::getAnalysisPointId, analysisInfo.get("analysisPointId")); query.eq(IdxBizPvWarningRuleSet::getAnalysisPointId, analysisInfo.get("analysisPointId"));
List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper().selectList(query); List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper()
.selectList(query);
for (IdxBizPvWarningRuleSet idxBizPvWarningRuleSet : idxBizFanWarningRecordList) { for (IdxBizPvWarningRuleSet idxBizPvWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "sequenceNbr", "warningName"); BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "sequenceNbr", "warningName");
if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) { if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) {
//警告周期 // 警告周期
idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString()); idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString());
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString()); idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) { } else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) {
//警告周期 // 警告周期
idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString()); idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString());
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString()); idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
} }
...@@ -270,7 +285,6 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -270,7 +285,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(b); return ResponseHelper.buildResponse(b);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/stringToMap") @GetMapping(value = "/stringToMap")
@ApiOperation(httpMethod = "get", value = "字符串转为对象格式", notes = "字符串转为对象格式") @ApiOperation(httpMethod = "get", value = "字符串转为对象格式", notes = "字符串转为对象格式")
...@@ -293,16 +307,17 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -293,16 +307,17 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(",")); List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(","));
query.in(IdxBizPvWarningRuleSet::getAnalysisPointId, analysisPointIds); query.in(IdxBizPvWarningRuleSet::getAnalysisPointId, analysisPointIds);
List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper().selectList(query); List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper()
.selectList(query);
for (IdxBizPvWarningRuleSet idxBizPvWarningRuleSet : idxBizFanWarningRecordList) { for (IdxBizPvWarningRuleSet idxBizPvWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "analysisPointIds"); BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "analysisPointIds");
if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) { if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) {
//警告周期 // 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("jgWarningCycle"))) { if (StringUtils.isNotBlank(analysisInfo.getString("jgWarningCycle"))) {
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString()); idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} }
} else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) { } else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) {
//警告周期 // 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("wxWarningCycle"))) { if (StringUtils.isNotBlank(analysisInfo.getString("wxWarningCycle"))) {
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString()); idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
} }
...@@ -312,7 +327,6 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -312,7 +327,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(b); return ResponseHelper.buildResponse(b);
} }
/** /**
* 根据pointId修改信息 * 根据pointId修改信息
* *
...@@ -326,16 +340,17 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -326,16 +340,17 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(",")); List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(","));
query.in(IdxBizFanWarningRuleSet::getAnalysisPointId, analysisPointIds); query.in(IdxBizFanWarningRuleSet::getAnalysisPointId, analysisPointIds);
List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper().selectList(query); List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper()
.selectList(query);
for (IdxBizFanWarningRuleSet idxBizFanWarningRuleSet : idxBizFanWarningRecordList) { for (IdxBizFanWarningRuleSet idxBizFanWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "analysisPointIds"); BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "analysisPointIds");
if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) { if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) {
//警告周期 // 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("jgWarningCycle"))) { if (StringUtils.isNotBlank(analysisInfo.getString("jgWarningCycle"))) {
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString()); idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} }
} else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) { } else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) {
//警告周期 // 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("wxWarningCycle"))) { if (StringUtils.isNotBlank(analysisInfo.getString("wxWarningCycle"))) {
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString()); idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
} }
...@@ -350,40 +365,67 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -350,40 +365,67 @@ public class IdxBizFanWarningRecordController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "查询各风机预警状况", notes = "查询各风机预警状况") @ApiOperation(httpMethod = "GET", value = "查询各风机预警状况", notes = "查询各风机预警状况")
public ResponseModel<Map<String, Object>> selectFanWarningNum(@RequestParam String station) { public ResponseModel<Map<String, Object>> selectFanWarningNum(@RequestParam String station) {
LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> wrapper = new LambdaQueryWrapper<>();
wrapper.select(IdxBizFanPointProcessVariableClassification::getEquipmentName); wrapper.select(IdxBizFanPointProcessVariableClassification::getEquipmentName);
wrapper.eq(IdxBizFanPointProcessVariableClassification::getStation, station); wrapper.eq(IdxBizFanPointProcessVariableClassification::getStation, station);
wrapper.groupBy(IdxBizFanPointProcessVariableClassification::getEquipmentName); wrapper.groupBy(IdxBizFanPointProcessVariableClassification::getEquipmentName);
wrapper.last(" ORDER BY RIGHT(EQUIPMENT_NAME,6) desc"); wrapper.last(" ORDER BY RIGHT(EQUIPMENT_NAME,6) desc");
List<IdxBizFanPointProcessVariableClassification> variableClassificationList = idxBizFanPointProcessVariableClassificationMapper.selectList(wrapper); List<IdxBizFanPointProcessVariableClassification> variableClassificationList = idxBizFanPointProcessVariableClassificationMapper
.selectList(wrapper);
Map<String, Object> resultMap = new HashMap<>(); QueryWrapper<FanWarningRecord> lambdaQw = new QueryWrapper<>();
List<String> gatewayIds = this.getGatewayIds(); lambdaQw.select("COUNT(1) AS c,equipment_name AS equipmentname,warning_name AS warningname");
List<Map<String, Object>> maps = fanWaringRecordMapper.selectFanWarningNum(station, gatewayIds); lambdaQw.lambda().eq(FanWarningRecord::getStation, station);
Map<String, Map<String, Object>> equipmentNameInfoMap = maps.stream().collect(Collectors.toMap(t -> t.get("EQUIPMENT_NAME").toString(), t -> t)); lambdaQw.lambda().eq(FanWarningRecord::getDisposotionState, "待确认");
lambdaQw.lambda().groupBy(FanWarningRecord::getEquipmentName);
lambdaQw.lambda().groupBy(FanWarningRecord::getWarningName);
List<Map<String, Object>> lists = fanWaringRecordMapper.selectMaps(lambdaQw);
// Map<String, Object> resultMap = new HashMap<>();
// List<String> gatewayIds = this.getGatewayIds();
// List<Map<String, Object>> maps = fanWaringRecordMapper.selectFanWarningNum(station, gatewayIds);
// Map<String, Map<String, Object>> equipmentNameInfoMap = maps.stream()
// .collect(Collectors.toMap(t -> t.get("EQUIPMENT_NAME").toString(), t -> t));
List<Integer> wxList = new ArrayList<>(); List<Integer> wxList = new ArrayList<>();
List<Integer> zyList = new ArrayList<>(); List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = new ArrayList<>(); List<Integer> jgList = new ArrayList<>();
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (Map<String, Object> map : maps) {
wxList.add(Integer.valueOf(map.get("危险").toString()));
zyList.add(Integer.valueOf(map.get("注意").toString()));
jgList.add(Integer.valueOf(map.get("警告").toString()));
list.add(map.get("EQUIPMENT_NAME").toString());
Map<String, Map<String, Integer>> countMap = new HashMap<>();
for (Map<String, Object> map : lists) {
String equipmentName = String.valueOf(map.get("equipmentname"));
int count = Integer.valueOf(String.valueOf(map.get("c")));
String warningName = String.valueOf(map.get("warningname"));
Map<String, Integer> equipMap = countMap.get(equipmentName);
if (equipMap == null) {
equipMap = new HashMap<>();
} }
equipMap.put(warningName, count);
countMap.put(equipmentName, equipMap);
}
variableClassificationList.forEach(item -> { variableClassificationList.forEach(item -> {
if (!equipmentNameInfoMap.containsKey(item.getEquipmentName())) { Map<String, Integer> equipMap = countMap.get(item.getEquipmentName());
if (equipMap != null) {
wxList.add(equipMap.get("危险") != null ? equipMap.get("危险") : 0);
zyList.add(equipMap.get("注意") != null ? equipMap.get("注意") : 0);
jgList.add(equipMap.get("警告") != null ? equipMap.get("警告") : 0);
} else {
wxList.add(0); wxList.add(0);
zyList.add(0); zyList.add(0);
jgList.add(0); jgList.add(0);
list.add(item.getEquipmentName());
} }
list.add(item.getEquipmentName());
}); });
// for (Map<String, Object> map : maps) {
// wxList.add(Integer.valueOf(map.get("危险").toString()));
// zyList.add(Integer.valueOf(map.get("注意").toString()));
// jgList.add(Integer.valueOf(map.get("警告").toString()));
// list.add(map.get("EQUIPMENT_NAME").toString());
//
// }
HashMap<String, Object> wxMapResult = new HashMap<>(); HashMap<String, Object> wxMapResult = new HashMap<>();
wxMapResult.put("data", wxList); wxMapResult.put("data", wxList);
...@@ -395,6 +437,7 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -395,6 +437,7 @@ public class IdxBizFanWarningRecordController extends BaseController {
jgMapResult.put("data", jgList); jgMapResult.put("data", jgList);
jgMapResult.put("name", "警告"); jgMapResult.put("name", "警告");
Map<String, Object> resultMap = new HashMap<String, Object>();
List<Map<String, Object>> hashMaps = Arrays.asList(wxMapResult, zyMapResult, jgMapResult); List<Map<String, Object>> hashMaps = Arrays.asList(wxMapResult, zyMapResult, jgMapResult);
resultMap.put("axisData", list); resultMap.put("axisData", list);
resultMap.put("seriesData", hashMaps); resultMap.put("seriesData", hashMaps);
...@@ -402,28 +445,69 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -402,28 +445,69 @@ public class IdxBizFanWarningRecordController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectEquipWarningTotal") @GetMapping(value = "/selectEquipWarningTotal")
@ApiOperation(httpMethod = "GET", value = "预警信息统计富文本", notes = "预警信息统计富文本") @ApiOperation(httpMethod = "GET", value = "预警信息统计富文本", notes = "预警信息统计富文本")
public ResponseModel<Map<String, Object>> selectEquipWarningTotal(@RequestParam String STATION, @RequestParam String EQUIPMENTNAME) { public ResponseModel<Map<String, Object>> selectEquipWarningTotal(@RequestParam String STATION,
List<String> gatewayIds = this.getGatewayIds(); @RequestParam String EQUIPMENTNAME) {
Map<String, Object> maps = fanWaringRecordMapper.selectEquipWarningTotal(STATION, EQUIPMENTNAME, gatewayIds); // List<String> gatewayIds = this.getGatewayIds();
// Map<String, Object> maps = fanWaringRecordMapper.selectEquipWarningTotal(STATION, EQUIPMENTNAME, gatewayIds);
QueryWrapper<FanWarningRecord> lambdaQw = new QueryWrapper<>();
lambdaQw.select("COUNT(1) AS c,warning_name AS warningname");
lambdaQw.lambda().eq(FanWarningRecord::getStation, STATION);
lambdaQw.lambda().eq(FanWarningRecord::getDisposotionState, "待确认");
lambdaQw.lambda().eq(FanWarningRecord::getEquipmentName, EQUIPMENTNAME);
lambdaQw.lambda().groupBy(FanWarningRecord::getEquipmentName);
lambdaQw.lambda().groupBy(FanWarningRecord::getWarningName);
List<Map<String, Object>> lists = fanWaringRecordMapper.selectMaps(lambdaQw);
Map<String, Object> maps = new HashMap<>();
maps.put("zhuyi", 0);
maps.put("weixian", 0);
maps.put("jinggao", 0);
int total = 0;
for (Map<String, Object> map : lists) {
if ("注意".equals(String.valueOf(map.get("warningname")))) {
maps.put("zhuyi", map.get("c"));
total+=Integer.valueOf(String.valueOf(map.get("c")));
} else if ("危险".equals(String.valueOf(map.get("warningname")))) {
maps.put("weixian", map.get("c"));
total+=Integer.valueOf(String.valueOf(map.get("c")));
} else if ("警告".equals(String.valueOf(map.get("warningname")))) {
maps.put("jinggao", map.get("c"));
total+=Integer.valueOf(String.valueOf(map.get("c")));
}
}
maps.put("total", total);
return ResponseHelper.buildResponse(maps); return ResponseHelper.buildResponse(maps);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectWarningPoint") @GetMapping(value = "/selectWarningPoint")
@ApiOperation(httpMethod = "GET", value = "预警监测设备右侧预警重复列表", notes = "预警监测设备右侧预警重复列表") @ApiOperation(httpMethod = "GET", value = "预警监测设备右侧预警重复列表", notes = "预警监测设备右侧预警重复列表")
public ResponseModel<Page<FanWarningRecord>> selectFanWarningNum(@RequestParam String STATION, @RequestParam String EQUIPMENTNAME, @RequestParam Integer current, @RequestParam Integer size) { public ResponseModel<Page<FanWarningRecord>> selectWarningPoint(@RequestParam String STATION,
@RequestParam String EQUIPMENTNAME, @RequestParam Integer current, @RequestParam Integer size) {
Page<FanWarningRecord> page = new Page<>(); Page<FanWarningRecord> page = new Page<>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
List<String> gatewayIds = this.getGatewayIds(); // List<String> gatewayIds = this.getGatewayIds();
List<FanWarningRecord> maps = fanWaringRecordMapper.selectWarningPoint(STATION, EQUIPMENTNAME, (current - 1) * size, size, gatewayIds); LambdaQueryWrapper<FanWarningRecord> lambdaQw = new LambdaQueryWrapper<>();
page.setRecords(maps); lambdaQw.eq(FanWarningRecord::getStation, STATION);
int total = fanWaringRecordMapper.selectWarningPointTotal(STATION, EQUIPMENTNAME); lambdaQw.eq(FanWarningRecord::getEquipmentName, EQUIPMENTNAME);
lambdaQw.eq(FanWarningRecord::getDisposotionState, "待确认");
int total = fanWaringRecordMapper.selectCount(lambdaQw);
page.setTotal(total); page.setTotal(total);
lambdaQw.orderByDesc(FanWarningRecord::getTs);
String limit = "LIMIT " + (current - 1) * size + "," + size;
lambdaQw.last(limit);
List<FanWarningRecord> list = fanWaringRecordMapper.selectList(lambdaQw);
// List<FanWarningRecord> maps =
// fanWaringRecordMapper.selectWarningPoint(STATION, EQUIPMENTNAME, (current -
// 1) * size, size, gatewayIds);
page.setRecords(list);
return ResponseHelper.buildResponse(page); return ResponseHelper.buildResponse(page);
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.ArrayList;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import java.util.Arrays;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvWarningRecordDto; import java.util.HashMap;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl; import java.util.List;
import io.swagger.annotations.Api; import java.util.Map;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvWarningRecordDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointProcessVariableClassification;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointProcessVariableClassificationMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* *
...@@ -30,6 +54,14 @@ public class IdxBizPvWarningRecordController extends BaseController { ...@@ -30,6 +54,14 @@ public class IdxBizPvWarningRecordController extends BaseController {
@Autowired @Autowired
IdxBizPvWarningRecordServiceImpl idxBizPvWarningRecordServiceImpl; IdxBizPvWarningRecordServiceImpl idxBizPvWarningRecordServiceImpl;
@Autowired
PvWaringRecordMapper pvWaringRecordMapper;
@Autowired
IdxBizPvPointProcessVariableClassificationMapper idxBizPvPointProcessVariableClassificationMapper;
/** /**
* 新增 * 新增
* *
...@@ -112,4 +144,161 @@ public class IdxBizPvWarningRecordController extends BaseController { ...@@ -112,4 +144,161 @@ public class IdxBizPvWarningRecordController extends BaseController {
public ResponseModel<List<IdxBizPvWarningRecordDto>> selectForList() { public ResponseModel<List<IdxBizPvWarningRecordDto>> selectForList() {
return ResponseHelper.buildResponse(idxBizPvWarningRecordServiceImpl.queryForIdxBizPvWarningRecordList()); return ResponseHelper.buildResponse(idxBizPvWarningRecordServiceImpl.queryForIdxBizPvWarningRecordList());
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectFanWarningNum")
@ApiOperation(httpMethod = "GET", value = "查询各风机预警状况", notes = "查询各风机预警状况")
public ResponseModel<Map<String, Object>> selectFanWarningNum(@RequestParam String station) {
LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> wrapper = new LambdaQueryWrapper<>();
wrapper.select(IdxBizPvPointProcessVariableClassification::getSubarray);
wrapper.eq(IdxBizPvPointProcessVariableClassification::getStation, station);
wrapper.groupBy(IdxBizPvPointProcessVariableClassification::getSubarray);
wrapper.last(" ORDER BY RIGHT(SUBARRAY,6) desc");
List<IdxBizPvPointProcessVariableClassification> variableClassificationList = idxBizPvPointProcessVariableClassificationMapper
.selectList(wrapper);
QueryWrapper<PvWarningRecord> lambdaQw = new QueryWrapper<>();
lambdaQw.select("COUNT(1) AS c,subarray AS subarray,warning_name AS warningname");
lambdaQw.lambda().eq(PvWarningRecord::getStation, station);
lambdaQw.lambda().eq(PvWarningRecord::getDisposotionState, "待确认");
lambdaQw.lambda().groupBy(PvWarningRecord::getSubarray);
lambdaQw.lambda().groupBy(PvWarningRecord::getWarningName);
List<Map<String, Object>> lists = pvWaringRecordMapper.selectMaps(lambdaQw);
// Map<String, Object> resultMap = new HashMap<>();
// List<String> gatewayIds = this.getGatewayIds();
// List<Map<String, Object>> maps = fanWaringRecordMapper.selectFanWarningNum(station, gatewayIds);
// Map<String, Map<String, Object>> equipmentNameInfoMap = maps.stream()
// .collect(Collectors.toMap(t -> t.get("EQUIPMENT_NAME").toString(), t -> t));
List<Integer> wxList = new ArrayList<>();
List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = new ArrayList<>();
List<String> list = new ArrayList<>();
Map<String, Map<String, Integer>> countMap = new HashMap<>();
for (Map<String, Object> map : lists) {
String subarray = String.valueOf(map.get("subarray"));
int count = Integer.valueOf(String.valueOf(map.get("c")));
String warningName = String.valueOf(map.get("warningname"));
Map<String, Integer> equipMap = countMap.get(subarray);
if (equipMap == null) {
equipMap = new HashMap<>();
}
equipMap.put(warningName, count);
countMap.put(subarray, equipMap);
}
variableClassificationList.forEach(item -> {
Map<String, Integer> equipMap = countMap.get(item.getSubarray());
if(equipMap!=null)
{
wxList.add(equipMap.get("危险") != null ? equipMap.get("危险") : 0);
zyList.add(equipMap.get("注意") != null ? equipMap.get("注意") : 0);
jgList.add(equipMap.get("警告") != null ? equipMap.get("警告") : 0);
}else
{
wxList.add(0);
zyList.add(0);
jgList.add(0);
}
list.add(item.getSubarray());
});
// for (Map<String, Object> map : maps) {
// wxList.add(Integer.valueOf(map.get("危险").toString()));
// zyList.add(Integer.valueOf(map.get("注意").toString()));
// jgList.add(Integer.valueOf(map.get("警告").toString()));
// list.add(map.get("EQUIPMENT_NAME").toString());
//
// }
HashMap<String, Object> wxMapResult = new HashMap<>();
wxMapResult.put("data", wxList);
wxMapResult.put("name", "危险");
HashMap<String, Object> zyMapResult = new HashMap<>();
zyMapResult.put("data", zyList);
zyMapResult.put("name", "注意");
HashMap<String, Object> jgMapResult = new HashMap<>();
jgMapResult.put("data", jgList);
jgMapResult.put("name", "警告");
Map<String, Object> resultMap = new HashMap<String, Object>();
List<Map<String, Object>> hashMaps = Arrays.asList(wxMapResult, zyMapResult, jgMapResult);
resultMap.put("axisData", list);
resultMap.put("seriesData", hashMaps);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectEquipWarningTotal")
@ApiOperation(httpMethod = "GET", value = "预警信息统计富文本", notes = "预警信息统计富文本")
public ResponseModel<Map<String, Object>> selectEquipWarningTotal(@RequestParam String STATION,
@RequestParam String EQUIPMENTNAME) {
// List<String> gatewayIds = this.getGatewayIds();
// Map<String, Object> maps = fanWaringRecordMapper.selectEquipWarningTotal(STATION, EQUIPMENTNAME, gatewayIds);
QueryWrapper<PvWarningRecord> lambdaQw = new QueryWrapper<>();
lambdaQw.select("COUNT(1) AS c,warning_name AS warningname");
lambdaQw.lambda().eq(PvWarningRecord::getStation, STATION);
lambdaQw.lambda().eq(PvWarningRecord::getDisposotionState, "待确认");
lambdaQw.lambda().eq(PvWarningRecord::getEquipmentName, EQUIPMENTNAME);
lambdaQw.lambda().groupBy(PvWarningRecord::getEquipmentName);
lambdaQw.lambda().groupBy(PvWarningRecord::getWarningName);
List<Map<String, Object>> lists = pvWaringRecordMapper.selectMaps(lambdaQw);
Map<String, Object> maps = new HashMap<>();
maps.put("zhuyi", 0);
maps.put("weixian", 0);
maps.put("jinggao", 0);
int total = 0;
for (Map<String, Object> map : lists) {
if ("注意".equals(String.valueOf(map.get("warningname")))) {
maps.put("zhuyi", map.get("c"));
total+=Integer.valueOf(String.valueOf(map.get("c")));
} else if ("危险".equals(String.valueOf(map.get("warningname")))) {
maps.put("weixian", map.get("c"));
total+=Integer.valueOf(String.valueOf(map.get("c")));
} else if ("警告".equals(String.valueOf(map.get("warningname")))) {
maps.put("jinggao", map.get("c"));
total+=Integer.valueOf(String.valueOf(map.get("c")));
}
}
maps.put("total", total);
return ResponseHelper.buildResponse(maps);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectWarningPoint")
@ApiOperation(httpMethod = "GET", value = "预警监测设备右侧预警重复列表", notes = "预警监测设备右侧预警重复列表")
public ResponseModel<Page<PvWarningRecord>> selectWarningPoint(@RequestParam String STATION,
@RequestParam String EQUIPMENTNAME, @RequestParam Integer current, @RequestParam Integer size) {
Page<PvWarningRecord> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
// List<String> gatewayIds = this.getGatewayIds();
LambdaQueryWrapper<PvWarningRecord> lambdaQw = new LambdaQueryWrapper<>();
lambdaQw.eq(PvWarningRecord::getStation, STATION);
lambdaQw.eq(PvWarningRecord::getEquipmentName, EQUIPMENTNAME);
lambdaQw.eq(PvWarningRecord::getDisposotionState, "待确认");
int total = pvWaringRecordMapper.selectCount(lambdaQw);
page.setTotal(total);
lambdaQw.orderByDesc(PvWarningRecord::getTs);
String limit = "LIMIT " + (current - 1) * size + "," + size;
lambdaQw.last(limit);
List<PvWarningRecord> list = pvWaringRecordMapper.selectList(lambdaQw);
// List<PvWarningRecord> maps =
// fanWaringRecordMapper.selectWarningPoint(STATION, EQUIPMENTNAME, (current -
// 1) * size, size, gatewayIds);
page.setRecords(list);
return ResponseHelper.buildResponse(page);
}
} }
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
</if> </if>
</where> </where>
ORDER BY ORDER BY
log.CREATE_DATE DESC log.REC_DATE DESC
LIMIT #{start}, #{size} LIMIT #{start}, #{size}
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment