Commit 540dafa2 authored by chenzhao's avatar chenzhao

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

parents e016f793 fe0ce735
......@@ -1525,7 +1525,7 @@
and update_date >=
#{startTime} and #{endTime} >= update_date
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
and wes.biz_org_code like concat(#{orgCode}, '%')
</if>
) as allNum,
(
......@@ -1539,7 +1539,7 @@
where
wed.code like '92010800%'
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
and wes.biz_org_code like concat(#{orgCode}, '%')
</if>
) as allEqu) as allEqu,
(
......@@ -1558,7 +1558,7 @@
and wesi.update_date >=
#{startTime} and #{endTime} >= update_date
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
and wes.biz_org_code like concat(#{orgCode}, '%')
</if>
) as startNum) as startNum
</select>
......
......@@ -28,7 +28,7 @@ public class IcbcEnum {
@AllArgsConstructor
public static enum OpenAccountState {
INITIAL("初始", "00"),
INITIAL("未开户", "00"),
OPENING("开户中", "01"),
......@@ -65,7 +65,7 @@ public class IcbcEnum {
@Getter
@NoArgsConstructor
@AllArgsConstructor
enum ProtocolStatus {
public static enum ProtocolStatus {
NOT_EFFECTIVE("未生效", "0"),
......@@ -86,5 +86,17 @@ public class IcbcEnum {
*/
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,8 +32,16 @@ public class HygfIcbcRecordQueryDTO {
private String phone;
@ApiModelProperty (value = "区域公司")
private String regionalCompaniesSeq;
private String regionalCompaniesName;
@ApiModelProperty (value = "所属地址")
private String address;
private String addressName;
private Integer current;
private Integer size;
private Integer limit;
private Integer offset;
}
......@@ -21,5 +21,8 @@ import java.util.List;
public interface HygfIcbcRecordMapper extends BaseMapper<HygfIcbcRecord> {
@UserEmpower (field = {"ph.regional_companies_code"}, dealerField = {"ph.developer_code", "ph.regional_companies_code", "ph.developer_user_id"}, fieldConditions = {"in", "in", "in"}, relationship = "and")
Integer listObjectCount(@Param ("param") HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO);
@UserEmpower (field = {"ph.regional_companies_code"}, dealerField = {"ph.developer_code", "ph.regional_companies_code", "ph.developer_user_id"}, fieldConditions = {"in", "in", "in"}, relationship = "and")
List<HygfIcbcRecordDTO> listObject(@Param ("param") HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO);
}
......@@ -15,7 +15,6 @@ import java.util.List;
*/
public interface RegionalCompaniesMapper extends BaseMapper<RegionalCompanies> {
List<RegionalCompanies> selectListData(@Param("regionalCompaniesName") String regionalCompaniesName,@Param("unitId")Long unitId,@Param("sequenceNbr")Long sequenceNbr);
RegionalCompanies selectByid(@Param("sequenceNbr")Long sequenceNbr);
RegionalCompanies selectRegionName(@Param("sequenceNbr")Long sequenceNbr);
......
......@@ -44,7 +44,7 @@
</if>
</where>
ORDER BY u.audit_status ,u.rec_date DESC
ORDER BY u.audit_status ,u.rec_date DESC,u.sequence_nbr DESC
</select>
......
......@@ -9,12 +9,42 @@
sequence_nbr,cust_name,id_card,phone,medium_id,project_id,open_account_state,protocol_status,protocol_start_time,protocol_end_time,trx_limit_amount,day_limit_amount,protocol_limit_amount,app_id,out_user_id,out_vendor_id,sign_entrsut_prtl_status
</sql>
<select id="listObjectCount" resultType="integer">
SELECT
count( DISTINCT ph.amos_user_id )
FROM
hygf_peasant_household ph LEFT JOIN hygf_icbc_record icbc ON ph.amos_user_id = icbc.amos_user_id
<where>
ph.is_delete = 0
<if test="param != null">
<if test="param.openAccountStatus != null and param.openAccountStatus != ''">
AND icbc.protocol_status = #{param.openAccountStatus}
</if>
<if test="param.custName != null and param.custName != ''">
AND ph.owners_name LIKE CONCAT('%', #{param.custName}, '%')
</if>
<if test="param.idCard != null and param.idCard != ''">
AND ph.id_card LIKE CONCAT('%', #{param.idCard}, '%')
</if>
<if test="param.phone != null and param.phone != ''">
AND ph.telephone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.regionalCompaniesName != null and param.regionalCompaniesName != ''">
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>
</where>
</select>
<select id="listObject" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO">
SELECT DISTINCT
icbc.sequence_nbr,
ph.owners_name as custName,
ph.telephone as phone,
ph.id_card,
ifnull(icbc.cust_name, ph.owners_name) as custName,
ifnull(icbc.phone, ph.telephone) as phone,
ifnull(icbc.id_card, ph.id_card) as idCard,
ph.amos_user_id,
icbc.open_account_status,
icbc.protocol_status
......@@ -35,11 +65,17 @@
<if test="param.phone != null and param.phone != ''">
AND ph.telephone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.regionalCompaniesSeq != null and param.regionalCompaniesSeq != ''">
AND ph.regional_companies_seq = #{param.regionalCompaniesSeq}
<if test="param.regionalCompaniesName != null and param.regionalCompaniesName != ''">
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>
</where>
<if test="param.offset != null and param.offset != '' and param.limit != null and param.limit != ''">
LIMIT ${param.offset}, ${param.limit}
</if>
GROUP BY
ph.amos_user_id
ORDER BY
......
......@@ -39,7 +39,7 @@
and std_user_biz.amos_user_name like concat(concat('%',#{dto.amosUserName}),'%')
</if>
<if test="dto.amosUnitOrgCode!=null">
and hygf_personnel_business.amos_unit_org_code like concat(concat(#{dto.amosUnitOrgCode}),"%")
and hygf_personnel_business.amos_unit_org_code like concat(concat(#{dto.amosUnitOrgCode}),'%')
</if>
......
......@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.mapper.PowerStationMapper">
<select id="queryPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto">
select * from (select
select * from (select DISTINCT
hygf_power_station.*,
b.initiate_status,
b.contract_lock_id,
......@@ -33,7 +33,7 @@
<if test="processStatus != null and processStatus != ''">
and hygf_power_station.process_status = #{processStatus}
</if>
GROUP BY hygf_peasant_household.sequence_nbr
<!-- GROUP BY hygf_peasant_household.sequence_nbr-->
ORDER BY hygf_power_station.rec_date desc
) a
</select>
......
......@@ -41,7 +41,7 @@ LEFT JOIN hygf_document_station on hygf_document_station.station_id=hygf_peasan
</select>
<select id="preparationStation" resultType="java.util.Map">
select b.* from ( select
select b.* from ( select DISTINCT
hygf_peasant_household.peasant_household_no as peasantHouseholdNo,
hygf_peasant_household.owners_name as ownersName,
hygf_peasant_household.regional_companies_name as regionalCompaniesName,
......@@ -81,7 +81,7 @@ LEFT JOIN hygf_document_station on hygf_document_station.station_id=hygf_peasan
and hygf_peasant_household.preparation_money_state not in ('待发货','待补货','暂存发货') and preparation_money_state is not null and preparation_money_state != ''
</if>
</where>
GROUP BY hygf_peasant_household.sequence_nbr
<!-- GROUP BY hygf_peasant_household.sequence_nbr-->
<if test=" preparationMoneyState == 1 ">
order by hygf_preparation_money.delivery_time DESC
</if>
......
......@@ -3,32 +3,60 @@
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.mapper.RegionalCompaniesMapper">
<select id="selectListData" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.RegionalCompanies">
<!-- select * from (-->
<!-- select-->
<!-- hygf_regional_companies.*,-->
<!-- (SELECT GROUP_CONCAT(REGION_NAME) from-->
<!-- (SELECT T2.REGION_NAME-->
<!-- FROM (-->
<!-- SELECT-->
<!-- @r AS _id,-->
<!-- (SELECT @r := parent_id FROM systemctl_region WHERE sequence_nbr = _id) AS parent_id,-->
<!-- @l := @l + 1 AS lvl-->
<!-- FROM-->
<!-- (SELECT @r := privilege_company.REGION_SEQ, @l := 0) vars,-->
<!-- systemctl_region h-->
<!-- WHERE @r != 0) T1-->
<!-- JOIN systemctl_region T2-->
<!-- ON T1._id = T2.sequence_nbr-->
<!-- ORDER BY T1.lvl DESC) s) regionalAddress-->
<!-- from hygf_regional_companies LEFT JOIN privilege_company on-->
<!-- hygf_regional_companies.regional_companies_seq=privilege_company.SEQUENCE_NBR-->
<!-- where hygf_regional_companies.is_delete=0-->
<!-- <if test="regionalCompaniesName!=null and regionalCompaniesName!=''">-->
<!-- and hygf_regional_companies.regional_companies_name like concat(concat('%',#{regionalCompaniesName}),'%')-->
<!-- </if>-->
<!-- <if test="unitId!=null and unitId!=''">-->
<!-- and hygf_regional_companies.unit_id=#{unitId}-->
<!-- </if>-->
<!-- <if test="sequenceNbr!=null and sequenceNbr!=''">-->
<!-- and hygf_regional_companies.unit_info_id=#{sequenceNbr}-->
<!-- </if>-->
<!-- ) a-->
select * from (
select
hygf_regional_companies.*,
(SELECT GROUP_CONCAT(REGION_NAME) from
(SELECT T2.REGION_NAME
FROM (
SELECT
@r AS _id,
(SELECT @r := parent_id FROM systemctl_region WHERE sequence_nbr = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := privilege_company.REGION_SEQ, @l := 0) vars,
systemctl_region h
WHERE @r != 0) T1
JOIN systemctl_region T2
ON T1._id = T2.sequence_nbr
ORDER BY T1.lvl DESC) s) regionalAddress
hygf_regional_companies.*,(
WITH RECURSIVE tree_path AS (
SELECT SEQUENCE_NBR, parent_id, REGION_NAME,`level`
FROM systemctl_region
WHERE SEQUENCE_NBR = privilege_company.REGION_SEQ
UNION ALL
SELECT tn.SEQUENCE_NBR, tn.parent_id, tn.REGION_NAME,tn.`level`
FROM systemctl_region tn
JOIN tree_path tp ON tn.SEQUENCE_NBR = tp.parent_id
)
SELECT GROUP_CONCAT(REGION_NAME ORDER BY `level` asc) FROM tree_path
) regionalAddress
from hygf_regional_companies LEFT JOIN privilege_company on
hygf_regional_companies.regional_companies_seq=privilege_company.SEQUENCE_NBR
where hygf_regional_companies.is_delete=0
<if test="regionalCompaniesName!=null and regionalCompaniesName!=''">
and hygf_regional_companies.regional_companies_name like concat(concat('%',#{regionalCompaniesName}),'%')
</if>
<if test="unitId!=null and unitId!=''">
and hygf_regional_companies.unit_id=#{unitId}
</if>
......@@ -42,20 +70,18 @@
select
(SELECT GROUP_CONCAT(REGION_NAME) from
(SELECT T2.REGION_NAME
FROM (
SELECT
@r AS _id,
(SELECT @r := parent_id FROM systemctl_region WHERE sequence_nbr = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := privilege_company.REGION_SEQ, @l := 0) vars,
systemctl_region h
WHERE @r != 0) T1
JOIN systemctl_region T2
ON T1._id = T2.sequence_nbr
ORDER BY T1.lvl DESC) s) regionalAddress
(
WITH RECURSIVE tree_path AS (
SELECT SEQUENCE_NBR, parent_id, REGION_NAME,`level`
FROM systemctl_region
WHERE SEQUENCE_NBR = privilege_company.REGION_SEQ
UNION ALL
SELECT tn.SEQUENCE_NBR, tn.parent_id, tn.REGION_NAME,tn.`level`
FROM systemctl_region tn
JOIN tree_path tp ON tn.SEQUENCE_NBR = tp.parent_id
)
SELECT GROUP_CONCAT(REGION_NAME ORDER BY `level` asc) FROM tree_path
) regionalAddress
from hygf_regional_companies LEFT JOIN privilege_company on
hygf_regional_companies.regional_companies_seq=privilege_company.SEQUENCE_NBR
where hygf_regional_companies.is_delete=0 and hygf_regional_companies.sequence_nbr=#{sequenceNbr}
......@@ -65,24 +91,42 @@
</select>
<select id="selectRegionName" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.RegionalCompanies">
<!-- select-->
<!-- privilege_company.COMPANY_CODE companyCode,-->
<!-- privilege_company.COMPANY_NAME regionalCompaniesName,-->
<!-- privilege_company.ORG_CODE regionalCompaniesCode,-->
<!-- (SELECT GROUP_CONCAT(REGION_NAME) from-->
<!-- (SELECT T2.REGION_NAME-->
<!-- FROM (-->
<!-- SELECT-->
<!-- @r AS _id,-->
<!-- (SELECT @r := parent_id FROM systemctl_region WHERE sequence_nbr = _id) AS parent_id,-->
<!-- @l := @l + 1 AS lvl-->
<!-- FROM-->
<!-- (SELECT @r := privilege_company.REGION_SEQ, @l := 0) vars,-->
<!-- systemctl_region h-->
<!-- WHERE @r != 0) T1-->
<!-- JOIN systemctl_region T2-->
<!-- ON T1._id = T2.sequence_nbr-->
<!-- ORDER BY T1.lvl DESC) s) regionalAddress-->
<!-- from privilege_company where privilege_company.SEQUENCE_NBR=#{sequenceNbr}-->
select
privilege_company.COMPANY_CODE companyCode,
privilege_company.COMPANY_NAME regionalCompaniesName,
privilege_company.ORG_CODE regionalCompaniesCode,
(SELECT GROUP_CONCAT(REGION_NAME) from
(SELECT T2.REGION_NAME
FROM (
SELECT
@r AS _id,
(SELECT @r := parent_id FROM systemctl_region WHERE sequence_nbr = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := privilege_company.REGION_SEQ, @l := 0) vars,
systemctl_region h
WHERE @r != 0) T1
JOIN systemctl_region T2
ON T1._id = T2.sequence_nbr
ORDER BY T1.lvl DESC) s) regionalAddress
(
WITH RECURSIVE tree_path AS (
SELECT SEQUENCE_NBR, parent_id, REGION_NAME,`level`
FROM systemctl_region
WHERE SEQUENCE_NBR = privilege_company.REGION_SEQ
UNION ALL
SELECT tn.SEQUENCE_NBR, tn.parent_id, tn.REGION_NAME,tn.`level`
FROM systemctl_region tn
JOIN tree_path tp ON tn.SEQUENCE_NBR = tp.parent_id
)
SELECT GROUP_CONCAT(REGION_NAME ORDER BY `level` asc) FROM tree_path
) regionalAddress
from privilege_company where privilege_company.SEQUENCE_NBR=#{sequenceNbr}
</select>
......
......@@ -17,7 +17,7 @@
and privilege_user_org_role.ROLE_SEQ=#{roleId}
<if test="orgCode!=null">
and privilege_company.ORG_CODE like concat(#{orgCode},"%")
and privilege_company.ORG_CODE like concat(#{orgCode},'%')
</if>
ORDER BY privilege_agency_user.USER_ID DESC
</select>
......
......@@ -26,7 +26,7 @@ from privilege_company where IS_DELETED=0 and AGENCY_CODE='JXIOP'
and privilege_company.COMPANY_TYPE=#{dto.companyType}
</if>
<if test="dto.orgCode!=null">
and privilege_company.ORG_CODE like concat(concat(#{dto.orgCode}),"%")
and privilege_company.ORG_CODE like concat(concat(#{dto.orgCode}),'%')
</if>
<if test="dto.comid!=null">
and privilege_company.SEQUENCE_NBR !=#{dto.comid}
......
......@@ -4,7 +4,7 @@
<select id="georgcodelist" resultType="Map">
select ORG_CODE orgCode from privilege_company where COMPANY_TYPE='region' and LEVEL='outer_company'
select ORG_CODE orgCode from privilege_company where COMPANY_TYPE='region' and `LEVEL`='outer_company'
<if test="orgs != null and orgs.size() >0">
and ORG_CODE not in
......
......@@ -85,14 +85,14 @@ public class HygfIcbcController extends BaseController {
return hygfIcbcService.registerWalletCallback(request, response);
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping (value = "/{sequenceNbr}")
@ApiOperation (httpMethod = "GET", value = "根据sequenceNbr查询注册电子钱包", notes = "注册电子钱包")
public ResponseModel<HygfIcbcRecordDTO> getObject(@PathVariable String sequenceNbr) {
return ResponseHelper.buildResponse(hygfIcbcService.getObject(Long.valueOf(sequenceNbr)));
@TycloudOperation (ApiLevel = UserType.AGENCY)
@GetMapping (value = "/{userId}")
@ApiOperation (httpMethod = "GET", value = "根据农户userId查询注册电子钱包", notes = "注册电子钱包")
public ResponseModel<HygfIcbcRecordDTO> getObject(@PathVariable String userId) {
return ResponseHelper.buildResponse(hygfIcbcService.getObject(userId));
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation (ApiLevel = UserType.AGENCY)
@GetMapping (value = "/list")
@ApiOperation (httpMethod = "GET", value = "聚富通电子钱包列表查询", notes = "聚富通电子钱包列表查询")
@UserLimits
......@@ -104,11 +104,9 @@ public class HygfIcbcController extends BaseController {
@GetMapping (value = "/page")
@ApiOperation (httpMethod = "GET", value = "聚富通电子钱包分页查询", notes = "聚富通电子钱包分页查询")
@UserLimits
public ResponseModel<Page<HygfIcbcRecordDTO>> queryForPage(@RequestParam (value = "current") int current,
@RequestParam(value = "size") int size,
@ApiParam @RequestParam HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) {
public ResponseModel<Page<HygfIcbcRecordDTO>> queryForPage(@ApiParam HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) {
return ResponseHelper.buildResponse(hygfIcbcService.queryForPage(current, size, hygfIcbcRecordQueryDTO));
return ResponseHelper.buildResponse(hygfIcbcService.queryForPage(hygfIcbcRecordQueryDTO.getCurrent(), hygfIcbcRecordQueryDTO.getSize(), hygfIcbcRecordQueryDTO));
}
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException;
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.UiIcbcClient;
import com.icbc.api.request.JftApiUserEntrustopenacctQueryRequestV1;
......@@ -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.service.IHygfIcbcService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
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.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -40,6 +38,7 @@ import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
......@@ -48,6 +47,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
......@@ -85,14 +87,29 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
private static final String APIGW_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwFgHD4kzEVPdOj03ctKM7KV+16bWZ5BMNgvEeuEQwfQYkRVwI9HFOGkwNTMn5hiJXHnlXYCX+zp5r6R52MY0O7BsTCLT7aHaxsANsvI9ABGx3OaTVlPB59M6GPbJh0uXvio0m1r/lTW3Z60RU6Q3oid/rNhP3CiNgg0W6O3AGqwIDAQAB";
private static final String OUT_VENDOR_ID = "071301";
private static final String PROJECT_ID = "PJ14001401B000160171";
@Value ("${hygf.icbc.trxLmtAmt:200000}")
/**
* 协议总限额
*/
@Value ("${hygf.icbc.protocolLimitAmount:2500000000}")
private String protocolLimitAmount;
/**
* 单笔限额
*/
@Value ("${hygf.icbc.trxLmtAmt:10000000}")
private String trxLmtAmt;
@Value ("${hygf.icbc.dayLmtAmt:200000}")
/**
* 日累计限额
*/
@Value ("${hygf.icbc.dayLmtAmt:20000000}")
private String dayLmtAmt;
@Value ("${hygf.icbc.loanTotalAmt:200000}")
@Value ("${hygf.icbc.loanTotalAmt:0}")
private String loanTotalAmt;
@Value ("${hygf.icbc.notifyUrl:}")
private String notifyUrl;
/**
* 合作方接收结果通知 URL
*/
@Value ("${hygf.icbc.callbackUrl:}")
private String callbackUrl;
@Resource (type = PeasantHouseholdServiceImpl.class)
......@@ -133,14 +150,14 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String formattedDate = formatter.format(newDate);
bizContent.setProtocolEndDate(formattedDate); // 协议到期日
bizContent.setProtocolLimitAmount("99999999999999999"); // 协议累计额
bizContent.setProtocolLimitAmount(protocolLimitAmount); // 协议累计额
JSONObject templateParams = new JSONObject();
templateParams.put("prtl_enddate", formattedDate);
templateParams.put("loan_total_amt", loanTotalAmt);
templateParams.put("trx_lmt_amt", trxLmtAmt);
templateParams.put("day_lmt_amt", dayLmtAmt);
templateParams.put("prtl_enddate", formattedDate);// 协议到期日
templateParams.put("loan_total_amt", loanTotalAmt);// 贷款限额(单位:分)
templateParams.put("trx_lmt_amt", trxLmtAmt);// 单笔限额(单位:分)
templateParams.put("day_lmt_amt", dayLmtAmt);// 日累计限额(单位:分)
bizContent.setTemplateParams(templateParams.toJSONString());
bizContent.setCallbackUrl(notifyUrl);
bizContent.setCallbackUrl(callbackUrl);
bizContent.setCamsPublicKey(CAMS_PUBLIC_KEY);
request.setBizContent(bizContent);
......@@ -186,11 +203,16 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
request.setBizContent(bizContent);
JftApiUserEntrustopenacctQueryResponseV1 response;
try {
log.info("户用光伏开户签约同步开户结果查询数据接口, => 入参: {}", JSON.toJSONString(request));
response = client.execute(request, System.currentTimeMillis() + "");
log.info("户用光伏开户签约同步开户结果查询数据接口, => 响应: {}", JSON.toJSONString(response));
return response;
} catch (IcbcApiException e) {
e.printStackTrace();
log.error("聚富通委托代扣签约同步开户结果查询数据接口error: ", e);
log.error("户用光伏开户签约同步开户结果查询数据接口 error: ", e);
return null;
} catch (Exception e) {
log.error("户用光伏开户签约同步开户结果查询数据接口 error: ", e);
return null;
}
}
......@@ -207,9 +229,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
*/
public Object registerWalletCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("户用光伏开户签约异步通知, => 验签");
boolean verifyFlag = verifySignData(request, notifyUrl);
String returnJson;
// 获取其他参数略...
String returnJson = null;
try {
boolean verifyFlag = verifySignData(request, "/hygf/icbc/notify");
if (verifyFlag) {
// 验签成功
String biz_content = request.getParameter("biz_content");
......@@ -224,8 +246,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String projectId = data.get("projectId");
String openAccoutSucceedFlag = data.get("openAccoutSucceedFlag");
String signEntrsutPrtlSucceedFlag = data.get("signEntrsutPrtlSucceedFlag");
JftApiUserEntrustopenacctQueryResponseV1 jftApiUserEntrustopenacctQueryResponse = this.getHygfIcbcWalletInfo(outUserId);
System.out.println(jftApiUserEntrustopenacctQueryResponse);
JftApiUserEntrustopenacctQueryResponseV1 hygfIcbcWalletInfo = this.getHygfIcbcWalletInfo(outUserId);
// region 保存数据
HygfIcbcRecord hygfIcbcRecord = this.lambdaQuery().eq(HygfIcbcRecord::getAmosUserId, outUserId).last(" limit 1").one();
if (hygfIcbcRecord == null) {
......@@ -233,20 +254,23 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
}
hygfIcbcRecord.setCustName(custName);
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.setProjectId(projectId);
hygfIcbcRecord.setOpenAccountStatus(openAccoutSucceedFlag);
hygfIcbcRecord.setProtocolStatus(jftApiUserEntrustopenacctQueryResponse.getProtocolStatus());
hygfIcbcRecord.setProtocolStartTime(jftApiUserEntrustopenacctQueryResponse.getProtocolStartDate());
hygfIcbcRecord.setProtocolEndTime(jftApiUserEntrustopenacctQueryResponse.getProtocolEndDate());
hygfIcbcRecord.setTrxLimitAmount(jftApiUserEntrustopenacctQueryResponse.getTrxLimitAmount());
hygfIcbcRecord.setDayLimitAmount(jftApiUserEntrustopenacctQueryResponse.getDayLimitAmount());
hygfIcbcRecord.setProtocolLimitAmount(jftApiUserEntrustopenacctQueryResponse.getProtocolLimitAmount());
hygfIcbcRecord.setAppId(jftApiUserEntrustopenacctQueryResponse.getAppId());
hygfIcbcRecord.setOutUserId(jftApiUserEntrustopenacctQueryResponse.getOutUserId());
hygfIcbcRecord.setOutVendorId(jftApiUserEntrustopenacctQueryResponse.getOutVendorId());
hygfIcbcRecord.setSignEntrsutPrtlStatus(signEntrsutPrtlSucceedFlag);
if (hygfIcbcWalletInfo != null) {
hygfIcbcRecord.setProtocolStatus(hygfIcbcWalletInfo.getProtocolStatus());
hygfIcbcRecord.setProtocolStartTime(hygfIcbcWalletInfo.getProtocolStartDate());
hygfIcbcRecord.setProtocolEndTime(hygfIcbcWalletInfo.getProtocolEndDate());
hygfIcbcRecord.setTrxLimitAmount(hygfIcbcWalletInfo.getTrxLimitAmount());
hygfIcbcRecord.setDayLimitAmount(hygfIcbcWalletInfo.getDayLimitAmount());
hygfIcbcRecord.setProtocolLimitAmount(hygfIcbcWalletInfo.getProtocolLimitAmount());
hygfIcbcRecord.setAppId(hygfIcbcWalletInfo.getAppId());
hygfIcbcRecord.setOutUserId(hygfIcbcWalletInfo.getOutUserId());
hygfIcbcRecord.setOutVendorId(hygfIcbcWalletInfo.getOutVendorId());
}
// hygfIcbcRecord.setDiscardStatus();
hygfIcbcRecord.setAmosUserId(outUserId);
hygfIcbcRecord.setRecDate(new Date());
......@@ -255,7 +279,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String copReturnCode = "0";// 通知合作方接收成功的返回码,固定
String copReturnMsg = "success";// 合作方的返回信息,固定
returnJson = sign(request, copReturnCode, copReturnMsg);
log.error("通知响应json结果:{}", returnJson);
log.info("通知响应json结果:{}", returnJson);
return returnJson;
} else {// 验签失败
String copReturnCode = "‐12345";
......@@ -263,11 +287,35 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
returnJson = sign(request, copReturnCode, copReturnMsg);
log.error("通知响应json结果:{}", returnJson);
}
} catch (Exception e) {
log.error("户用光伏开户签约异步通知, => error:", e);
}
return returnJson;
}
public HygfIcbcRecordDTO getObject(Long sequenceNbr) {
HygfIcbcRecordDTO hygfIcbcRecordDTO = this.queryBySeq(sequenceNbr);
public HygfIcbcRecordDTO getObject(String amosUserId) {
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;
}
......@@ -277,16 +325,21 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
}
public Page<HygfIcbcRecordDTO> queryForPage(int current, int size, HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) {
PageHelper.startPage(current, size);
// List<HygfIcbcRecord> hygfIcbcRecords = this.lambdaQuery().eq(StringUtils.isNotEmpty(hygfIcbcRecordQueryDTO.getOpenAccountState()), HygfIcbcRecord::getOpenAccountState, hygfIcbcRecordQueryDTO.getOpenAccountState()).like(StringUtils.isNotEmpty(hygfIcbcRecordQueryDTO.getCustName()), HygfIcbcRecord::getCustName, hygfIcbcRecordQueryDTO.getCustName()).like(StringUtils.isNotEmpty(hygfIcbcRecordQueryDTO.getIdCard()), HygfIcbcRecord::getIdCard, hygfIcbcRecordQueryDTO.getIdCard()).eq(StringUtils.isNotEmpty(hygfIcbcRecordQueryDTO.getPhone()), HygfIcbcRecord::getPhone, hygfIcbcRecordQueryDTO.getPhone()).list();
// PageHelper.startPage(current, size);
Integer total = hygfIcbcRecordMapper.listObjectCount(hygfIcbcRecordQueryDTO);
hygfIcbcRecordQueryDTO.setLimit(size);
if (current == 0) {
hygfIcbcRecordQueryDTO.setOffset(0);
} else {
// int offset = (current - 1) * size > total ? : (current - 1) * size;
hygfIcbcRecordQueryDTO.setOffset((current - 1) * size);
}
List<HygfIcbcRecordDTO> list = hygfIcbcRecordMapper.listObject(hygfIcbcRecordQueryDTO);
toModels(list);
PageInfo<HygfIcbcRecordDTO> pageInfo = new PageInfo<>(list);
Page<HygfIcbcRecordDTO> page = new Page<>();
page.setSize(pageInfo.getSize());
page.setCurrent(pageInfo.getPageNum());
page.setTotal(pageInfo.getTotal());
page.setRecords(list);
page.setSize(size);
page.setCurrent(current);
page.setTotal(total);
page.setRecords(toModels(list));
return page;
}
......@@ -295,12 +348,17 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
return Collections.emptyList();
}
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 分组
return hygfIcbcRecords.stream().map(hygfIcbcRecordDTO -> {
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));
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;
}).collect(Collectors.toList());
}
......@@ -326,6 +384,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String biz_content = request.getParameter("biz_content");
String sign_type = request.getParameter("sign_type");
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("api", api);
params.put("app_id", app_id);
......@@ -337,9 +396,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
params.put("sign_type", sign_type);// 目前上行网关签名暂时仅支持RSA
/**********验证工行上行网关RSA签名**********/
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);
log.error("验签结果:[[{}]]", flag);
log.info("验签结果:[[{}]]", flag);
return flag;
}
......@@ -357,7 +416,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String responseBizContent = "{\"return_code\":\"" + copReturnCode + "\",\"return_msg\":\"" + copReturnMsg + "\"" + ",\"msg_id\":\"" + msg_id + "\"}";
String charset = request.getParameter("charset");// 调用过程使用的编码格式
/**********商户对消息返回响应进行签名,签名方式需与在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 signParam = IcbcSignature.sign(signStr, signType, MY_PRIVATE_KEY, charset);
String returnJson = "{\"response_biz_content\":" + responseBizContent + ",\"sign_type\":\"" + signType + "\"" + ",\"sign\":\"" + signParam + "\"}";
......@@ -379,4 +439,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
byte[] bt = Base64.decode(String.valueOf(ch));
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
spring.elasticsearch.rest.read-timeout=30000
## 聚富通 配置
hygf.icbc.notifyUrl=http://47.92.234.253:8088/hygf/icbc/notify
\ No newline at end of file
hygf.icbc.callbackUrl=https://yth.yunqingtech.com/hygf/icbc/notify
\ No newline at end of file
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.baomidou.mybatisplus.annotation.TableField;
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.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.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.IdxBizPvWarningRuleSet;
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
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.tdengine.FanWarningRecord;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
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
......@@ -83,7 +96,8 @@ public class IdxBizFanWarningRecordController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{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);
return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.updateWithModel(model));
}
......@@ -97,7 +111,8 @@ public class IdxBizFanWarningRecordController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{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));
}
......@@ -124,8 +139,8 @@ public class IdxBizFanWarningRecordController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "分页查询", notes = "分页查询")
public ResponseModel<Page<IdxBizFanWarningRecordDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) {
public ResponseModel<Page<IdxBizFanWarningRecordDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<IdxBizFanWarningRecordDto> page = new Page<IdxBizFanWarningRecordDto>();
page.setCurrent(current);
page.setSize(size);
......@@ -144,7 +159,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(idxBizFanWarningRecordServiceImpl.queryForIdxBizFanWarningRecordList());
}
/**
* 根据sequenceNbr查询
*
......@@ -158,18 +172,19 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
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<>();
for (int i = 0; i < idxBizFanWarningRecordList.size(); i++) {
IdxBizFanWarningRuleSet idxBizFanWarningRecord = idxBizFanWarningRecordList.get(i);
if (idxBizFanWarningRecord.getWarningName().equals("注意")) {
map.putAll(BeanUtil.beanToMap(idxBizFanWarningRecord));
} else if (idxBizFanWarningRecord.getWarningName().equals("警告")) {
//警告周期
// 警告周期
map.put("jgWarningCycle", idxBizFanWarningRecord.getWarningCycle());
map.put("jgWarningIf", idxBizFanWarningRecord.getWarningIf());
} else if (idxBizFanWarningRecord.getWarningName().equals("危险")) {
//警告周期
// 警告周期
map.put("wxWarningCycle", idxBizFanWarningRecord.getWarningCycle());
map.put("wxWarningIf", idxBizFanWarningRecord.getWarningIf());
}
......@@ -177,7 +192,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(map);
}
/**
* 根据pointId修改信息
*
......@@ -190,15 +204,16 @@ public class IdxBizFanWarningRecordController extends BaseController {
public ResponseModel<Boolean> updateByPointInfo(@RequestBody JSONObject analysisInfo) {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
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) {
BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "sequenceNbr", "warningName");
if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) {
//警告周期
// 警告周期
idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString());
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) {
//警告周期
// 警告周期
idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString());
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
}
......@@ -207,7 +222,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(b);
}
/**
* 根据sequenceNbr查询
*
......@@ -221,18 +235,19 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
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<>();
for (int i = 0; i < idxBizPvWarningRecordList.size(); i++) {
IdxBizPvWarningRuleSet idxBizPvWarningRecord = idxBizPvWarningRecordList.get(i);
if (idxBizPvWarningRecord.getWarningName().equals("注意")) {
map.putAll(BeanUtil.beanToMap(idxBizPvWarningRecord));
} else if (idxBizPvWarningRecord.getWarningName().equals("警告")) {
//警告周期
// 警告周期
map.put("jgWarningCycle", idxBizPvWarningRecord.getWarningCycle());
map.put("jgWarningIf", idxBizPvWarningRecord.getWarningIf());
} else if (idxBizPvWarningRecord.getWarningName().equals("危险")) {
//警告周期
// 警告周期
map.put("wxWarningCycle", idxBizPvWarningRecord.getWarningCycle());
map.put("wxWarningIf", idxBizPvWarningRecord.getWarningIf());
}
......@@ -240,7 +255,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(map);
}
/**
* 根据pointId修改信息
*
......@@ -253,15 +267,16 @@ public class IdxBizFanWarningRecordController extends BaseController {
public ResponseModel<Boolean> updateByPointInfoPv(@RequestBody JSONObject analysisInfo) {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
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) {
BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "sequenceNbr", "warningName");
if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) {
//警告周期
// 警告周期
idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString());
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) {
//警告周期
// 警告周期
idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString());
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
}
......@@ -270,7 +285,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(b);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/stringToMap")
@ApiOperation(httpMethod = "get", value = "字符串转为对象格式", notes = "字符串转为对象格式")
......@@ -293,16 +307,17 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(","));
query.in(IdxBizPvWarningRuleSet::getAnalysisPointId, analysisPointIds);
List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper().selectList(query);
List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper()
.selectList(query);
for (IdxBizPvWarningRuleSet idxBizPvWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "analysisPointIds");
if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) {
//警告周期
// 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("jgWarningCycle"))) {
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
}
} else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) {
//警告周期
// 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("wxWarningCycle"))) {
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
}
......@@ -312,7 +327,6 @@ public class IdxBizFanWarningRecordController extends BaseController {
return ResponseHelper.buildResponse(b);
}
/**
* 根据pointId修改信息
*
......@@ -326,16 +340,17 @@ public class IdxBizFanWarningRecordController extends BaseController {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(","));
query.in(IdxBizFanWarningRuleSet::getAnalysisPointId, analysisPointIds);
List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper().selectList(query);
List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper()
.selectList(query);
for (IdxBizFanWarningRuleSet idxBizFanWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "analysisPointIds");
if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) {
//警告周期
// 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("jgWarningCycle"))) {
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
}
} else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) {
//警告周期
// 警告周期
if (StringUtils.isNotBlank(analysisInfo.getString("wxWarningCycle"))) {
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
}
......@@ -350,40 +365,67 @@ public class IdxBizFanWarningRecordController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "查询各风机预警状况", notes = "查询各风机预警状况")
public ResponseModel<Map<String, Object>> selectFanWarningNum(@RequestParam String station) {
LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> wrapper = new LambdaQueryWrapper<>();
wrapper.select(IdxBizFanPointProcessVariableClassification::getEquipmentName);
wrapper.eq(IdxBizFanPointProcessVariableClassification::getStation, station);
wrapper.groupBy(IdxBizFanPointProcessVariableClassification::getEquipmentName);
wrapper.last(" ORDER BY RIGHT(EQUIPMENT_NAME,6) desc");
List<IdxBizFanPointProcessVariableClassification> variableClassificationList = idxBizFanPointProcessVariableClassificationMapper.selectList(wrapper);
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<IdxBizFanPointProcessVariableClassification> variableClassificationList = idxBizFanPointProcessVariableClassificationMapper
.selectList(wrapper);
QueryWrapper<FanWarningRecord> lambdaQw = new QueryWrapper<>();
lambdaQw.select("COUNT(1) AS c,equipment_name AS equipmentname,warning_name AS warningname");
lambdaQw.lambda().eq(FanWarningRecord::getStation, station);
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> zyList = new ArrayList<>();
List<Integer> jgList = 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 -> {
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);
zyList.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<>();
wxMapResult.put("data", wxList);
......@@ -395,6 +437,7 @@ public class IdxBizFanWarningRecordController extends BaseController {
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);
......@@ -402,28 +445,69 @@ public class IdxBizFanWarningRecordController extends BaseController {
}
@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);
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<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);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectWarningPoint")
@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.setCurrent(current);
page.setSize(size);
List<String> gatewayIds = this.getGatewayIds();
List<FanWarningRecord> maps = fanWaringRecordMapper.selectWarningPoint(STATION, EQUIPMENTNAME, (current - 1) * size, size, gatewayIds);
page.setRecords(maps);
int total = fanWaringRecordMapper.selectWarningPointTotal(STATION, EQUIPMENTNAME);
// List<String> gatewayIds = this.getGatewayIds();
LambdaQueryWrapper<FanWarningRecord> lambdaQw = new LambdaQueryWrapper<>();
lambdaQw.eq(FanWarningRecord::getStation, STATION);
lambdaQw.eq(FanWarningRecord::getEquipmentName, EQUIPMENTNAME);
lambdaQw.eq(FanWarningRecord::getDisposotionState, "待确认");
int total = fanWaringRecordMapper.selectCount(lambdaQw);
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);
}
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
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.service.impl.IdxBizPvWarningRecordServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
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.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.List;
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.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 {
@Autowired
IdxBizPvWarningRecordServiceImpl idxBizPvWarningRecordServiceImpl;
@Autowired
PvWaringRecordMapper pvWaringRecordMapper;
@Autowired
IdxBizPvPointProcessVariableClassificationMapper idxBizPvPointProcessVariableClassificationMapper;
/**
* 新增
*
......@@ -112,4 +144,161 @@ public class IdxBizPvWarningRecordController extends BaseController {
public ResponseModel<List<IdxBizPvWarningRecordDto>> selectForList() {
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);
}
}
......@@ -8,7 +8,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
......@@ -17,6 +16,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ObjectUtils;
......@@ -153,6 +153,7 @@ public class TDBigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.last("limit 1");
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
if ("FDZ".equals(stationBasic.getStationType())) {
......@@ -175,10 +176,16 @@ public class TDBigScreenAnalyseController extends BaseController {
}
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(areaCode)) {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
wrapper.like(FanHealthIndex::getArea, "%" + areaCode + "%");
} else {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "全域");
}
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
stringBigDecimalHashMap.put("value",BigDecimal.valueOf( fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
stringBigDecimalHashMap.put("value", BigDecimal.valueOf(fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
......@@ -269,6 +276,91 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 折线图", notes = "场站设备健康状态指数与趋势 - 折线图")
@GetMapping(value = "/getHealthListInfoByMinute")
public ResponseModel<Map<String, Object>> getHealthListInfoByMinute(@RequestParam(required = false) String areaCode,
@RequestParam(required = false) String stationCode, @RequestParam(required = false) String area,
@RequestParam(required = false) String station, @RequestParam(required = false) String analysisType,
@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
if (StrUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId();
} else if (StrUtil.isNotEmpty(station)) {
// 由于命名不统一
StationBasic stationBasic = stationBasicMapper.selectOne(new LambdaQueryWrapper<StationBasic>()
.eq(StationBasic::getStationName, station.substring(0, station.length() - 1) + '场').or()
.eq(StationBasic::getStationName, station.substring(0, station.length() - 1) + '站'));
stationCode = stationBasic.getFanGatewayId();
}
if (StrUtil.isNotEmpty(areaCode)) {
areaCode = "%" + areaCode + "%";
} else if (StrUtil.isNotEmpty(area)) {
areaCode = "%" + area + "%";
}
String finalStationCode = stationCode;
String finalAreaCode = areaCode;
List<String> valueList;
List<String> dateList;
List<Map<String, Object>> arrayList = new ArrayList<>();
HashMap<String, Object> resultMap = new HashMap<>();
HashMap<String, Object> stringStringHashMap = new HashMap<>();
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.last("limit 15");
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(finalStationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(finalStationCode);
if ("FDZ".equals(stationBasic.getStationType())) {
stationCode = stationBasic.getFanGatewayId();
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.eq(FanHealthIndex::getGatewayId, stationCode);
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper);
valueList = fanHealthIndexList.stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
dateList = fanHealthIndexList.stream().map(t -> t.getRecDate()).collect(Collectors.toList());
} else {
LambdaQueryWrapper<PvHealthIndex> pvwrapper = new LambdaQueryWrapper<PvHealthIndex>();
pvwrapper.eq(PvHealthIndex::getAnalysisObjType, "场站");
pvwrapper.eq(PvHealthIndex::getGatewayId, stationCode);
pvwrapper.orderByDesc(PvHealthIndex::getTs);
pvwrapper.last("limit 15");
List<PvHealthIndex> pvHealthIndexList = pvHealthIndexMapper.selectList(pvwrapper);
valueList = pvHealthIndexList.stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
dateList = pvHealthIndexList.stream().map(t -> t.getRecDate()).collect(Collectors.toList());
}
stringStringHashMap.put("data", valueList);
arrayList.add(stringStringHashMap);
resultMap.put("axisData", dateList);
resultMap.put("seriesData", arrayList);
return ResponseHelper.buildResponse(resultMap);
}
if (CharSequenceUtil.isNotEmpty(finalAreaCode)) {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
wrapper.like(FanHealthIndex::getArea, finalAreaCode);
} else {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "全域");
}
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper);
valueList = fanHealthIndexList.stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
dateList = fanHealthIndexList.stream().map(t -> t.getRecDate()).collect(Collectors.toList());
stringStringHashMap.put("data", valueList);
arrayList.add(stringStringHashMap);
resultMap.put("axisData", dateList);
resultMap.put("seriesData", arrayList);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各片区设备预警情况(条) ", notes = "全域各片区设备预警情况(条) ")
@GetMapping(value = "/getAllEquipAlarmInfo")
......@@ -352,19 +444,7 @@ public class TDBigScreenAnalyseController extends BaseController {
List<String> list = new ArrayList<>();
// FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA");
//
// List<CompanyModel> companyModels = new ArrayList<>();
//
// if (!ObjectUtils.isEmpty(listFeignClientResult)) {
// if (listFeignClientResult.getStatus() == 200) {
// companyModels = listFeignClientResult.getResult();
// } else {
// throw new RuntimeException(listFeignClientResult.getMessage());
// }
// }
// list = companyModels.stream().map(CompanyModel::getCompanyName).collect(Collectors.toList());
//
list = Arrays.asList("华北区域", "东北区域", "华东区域", "华南区域", "西南区域", "西北区域", "华中区域");
......@@ -375,6 +455,66 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "片区、场站设备健康状态指数 ", notes = "片区、场站设备健康状态指数 ")
@GetMapping(value = "/getHealthInfoByMinute")
public ResponseModel<Map<String, Object>> getHealthInfoByMinute(@RequestParam(required = false) String areaCode) {
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(areaCode)) {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.like(FanHealthIndex::getArea, "%" + areaCode + "%");
}else{
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
}
List<Object> seriesData = new ArrayList<>();
List<String> axisData = new ArrayList<>();
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper);
Map<String, Object> resultMap = new HashMap<>();
if (CharSequenceUtil.isNotEmpty(areaCode)) {
Map<String, Map<String, List<FanHealthIndex>>> groupedData = fanHealthIndexList.stream()
.collect(Collectors.groupingBy(FanHealthIndex::getArea, Collectors.groupingBy(FanHealthIndex::getStation)));
Map<String, Map<String, FanHealthIndex>> latestData = groupedData.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
e -> e.getValue().values().stream()
.map(list -> list.stream()
.max(Comparator.comparing(FanHealthIndex::getTs))
.get())
.collect(Collectors.toMap(FanHealthIndex::getStation, Function.identity()))
));
List<Object> finalSeriesData = new ArrayList<>();
List<String> finalAxisData = new ArrayList<>();
latestData.values().forEach(s -> {
s.forEach((k,v) -> {
finalSeriesData.add(v.getHealthIndex());
finalAxisData.add(v.getStation());
});
});
seriesData.addAll(finalSeriesData);
axisData.addAll(finalAxisData);
}else{
Map<String, List<FanHealthIndex>> groupedData = fanHealthIndexList.stream()
.collect(Collectors.groupingBy(FanHealthIndex::getArea));
Map<String, FanHealthIndex> latestData = groupedData.values().stream().map(list -> list.stream()
.max(Comparator.comparing(FanHealthIndex::getTs))
.get())
.collect(Collectors.toMap(FanHealthIndex::getArea, Function.identity()));
seriesData = latestData.values().stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
axisData = latestData.values().stream().map(t -> t.getArea()).collect(Collectors.toList());
}
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各场站设备实时预警处置信息", notes = "全域各场站设备实时预警处置信息")
@GetMapping(value = "/getEquipWarningInfoByPage")
......
......@@ -160,7 +160,7 @@
</if>
</where>
ORDER BY
log.CREATE_DATE DESC
log.REC_DATE DESC
LIMIT #{start}, #{size}
</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