Commit e4861c4a authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

# Conflicts: # amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
parents 5114b97e 6d0ff861
...@@ -99,6 +99,10 @@ public class ControllerAop { ...@@ -99,6 +99,10 @@ public class ControllerAop {
urls.add("/tzs/reg-unit-info/save"); urls.add("/tzs/reg-unit-info/save");
urls.add("/hygf/unit-info/region/tree"); urls.add("/hygf/unit-info/region/tree");
urls.add("/hygf/unit-info/management-unit/tree"); urls.add("/hygf/unit-info/management-unit/tree");
urls.add("/hygf/unit-info/hasExistPhone/.*");
urls.add("/hygf/unit-info/sendTelCode/.*");
urls.add("/hygf/unit-info/verifyTelCode/.*/.*");
urls.add("/hygf/peasant-household/mobile/login");
// 获取请求路径 // 获取请求路径
for (String uri : urls) { for (String uri : urls) {
......
package com.yeejoin.amos.boot.module.hygf.api.Enum;
/**
* @author DELL
* 手机登录类型: 2020年底 驻场开发
*/
public enum PhoneRegisterTypeEum {
WX("微信授权快捷登录",1),
PHONE_VERIFY("手机验证登录",2);
private String name;
private int code;
PhoneRegisterTypeEum(String name,int code){
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
package com.yeejoin.amos.boot.module.hygf.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 发货单枚举
*
* @author Provence
* @version v1.0
* @date 2023/8/18 16:49
*/
public class PreparationMoneyEnum {
/**
* 订单状态
*
*/
@Getter
@AllArgsConstructor
public enum DOCUMENT_STATE {
未完成("未完成", "0", "未完成"),// 订单状态0未完成1已完成2作废
已完成("已完成", "1", "0"),//发货状态 0 未发货1已发货
作废("已作废", "2", "1");//到货状态0未到货1已到货
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 编码
*/
private String describe;
public static String getName(String code) {
for(DOCUMENT_STATE type: DOCUMENT_STATE.values()) {
if (type.getCode().equals(code)) {
return type.getName();
}
}
return null;
}
}
/**
* 发货状态
*
*/
@Getter
@AllArgsConstructor
public enum SHIPMENT_STATUS {
未发货("未发货", "0", "未发货"),// 订单状态0未完成1已完成2作废
已发货("已发货", "1", "已发货");//发货状态 0 未发货1已发货
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 编码
*/
private String describe;
public static String getName(String code) {
for(SHIPMENT_STATUS type: SHIPMENT_STATUS.values()) {
if (type.getCode().equals(code)) {
return type.getName();
}
}
return null;
}
}
/**
* 到货状态
*
*/
@Getter
@AllArgsConstructor
public enum RECEIVING_STATUS {
未到货("未到货", "0", "未到货"),// 订单状态0未完成1已完成2作废
已到货("已到货", "1", "已到货");//发货状态 0 未发货1已发货
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 编码
*/
private String describe;
public static String getName(String code) {
for(RECEIVING_STATUS type: RECEIVING_STATUS.values()) {
if (type.getCode().equals(code)) {
return type.getName();
}
}
return null;
}
}
/**
* 业主类型
*
*/
@Getter
@AllArgsConstructor
enum OWNER_TYPE {
非居民("非居民", "0", "非居民"),
居民("居民", "1", "居民");//到货状态0未到货1已到货
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 编码
*/
private String describe;
}
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
/**
* TODO(一句话描述该类的功能)
*
* @author Provence
* @version v1.0
* @date 2023/8/22 12:58
*/
@Data
public class AccessTokenDto {
private String access_token;
private Integer expires_in;
private Integer errcode;
private String errmsg;
}
package com.yeejoin.amos.boot.module.hygf.api.dto; package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -20,6 +23,7 @@ public class ContractDataDto { ...@@ -20,6 +23,7 @@ public class ContractDataDto {
String companyTenantName; String companyTenantName;
String companyUsername; String companyUsername;
String companyContact; String companyContact;
Integer companyKeywordIndex;
Long emplateId; Long emplateId;
String companykeyword; String companykeyword;
Integer companyPage; Integer companyPage;
...@@ -29,4 +33,6 @@ public class ContractDataDto { ...@@ -29,4 +33,6 @@ public class ContractDataDto {
Integer personalPage; Integer personalPage;
Double personalOffsetX; Double personalOffsetX;
Double personalOffsetY; Double personalOffsetY;
Integer personalKeywordIndex;
private List<Long> sealId;
} }
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="ContractTemplateDto", description="")
public class ContractTemplateDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 模板名称")
private String templateName;
@ApiModelProperty(value = "模板id")
private Long templateId;
@ApiModelProperty(value = "公司签字位置")
private String companyKeyword;
@ApiModelProperty(value = "公司签字页码")
private Integer companyPage;
@ApiModelProperty(value = "公司签字位置x偏移量")
private Double companyOffsetx;
@ApiModelProperty(value = "公司签字位置y偏移量")
private Double companyOffsety;
@ApiModelProperty(value = "个人签字位置")
private String personalKeyword;
@ApiModelProperty(value = "个人签字页码")
private Integer personalPage;
@ApiModelProperty(value = "个人签字位置x偏移量")
private Double personalOffsetx;
@ApiModelProperty(value = "个人签字位置y偏移量")
private Double personalOffsety;
@ApiModelProperty(value = "序号")
private Integer num;
private Integer personalKeywordIndex;
private Integer companyKeywordIndex;
}
...@@ -98,7 +98,7 @@ public class HouseholdContractDto extends BaseDto { ...@@ -98,7 +98,7 @@ public class HouseholdContractDto extends BaseDto {
private String projectAddressName; private String projectAddressName;
@ApiModelProperty(value = "免租期免租期") @ApiModelProperty(value = "免租期免租期")
private String rentFree; private Date rentFree;
@ApiModelProperty(value = "租金计算日期") @ApiModelProperty(value = "租金计算日期")
private Date rentCalculationDate; private Date rentCalculationDate;
...@@ -121,9 +121,9 @@ public class HouseholdContractDto extends BaseDto { ...@@ -121,9 +121,9 @@ public class HouseholdContractDto extends BaseDto {
@ApiModelProperty(value = "电站功率") @ApiModelProperty(value = "电站功率")
private Double stationPower; private Double stationPower;
@ApiModelProperty(value = "合同契约锁id") @ApiModelProperty(value = "合同契约锁id")
private Double contractLockId; private Long contractLockId;
@ApiModelProperty(value = "印章id") @ApiModelProperty(value = "印章id")
private Double sealId; private Long sealId;
/** /**
* 发起状态 * 发起状态
...@@ -134,6 +134,6 @@ public class HouseholdContractDto extends BaseDto { ...@@ -134,6 +134,6 @@ public class HouseholdContractDto extends BaseDto {
* */ * */
private Date signingTime; private Date signingTime;
private String userId;
} }
...@@ -38,4 +38,8 @@ public class HouseholdContractPageDto extends Page<HouseholdContract> { ...@@ -38,4 +38,8 @@ public class HouseholdContractPageDto extends Page<HouseholdContract> {
* 签字状态 * 签字状态
*/ */
private String signStatus; private String signStatus;
private String userId;
} }
package com.yeejoin.amos.boot.module.hygf.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* @author Provence
* @version v1.0
* @date 2023/8/21 15:15
*/
@Data
public class MobileLoginParamDto {
@ApiModelProperty("用户userid")
private String userId;
@ApiModelProperty("二维码类型:region, personal")
private String qrCodeType;
/**
* 注册类型:1-微信授权快捷登录;2-手机验证登录
*/
@ApiModelProperty("注册类型:1-微信授权快捷登录;2-手机验证登录")
private int registerType;
/**
* 是否需要需要短信验证: true-验证; false-不验证
*/
@ApiModelProperty("是否需要需要短信验证: true-验证; false-不验证")
private Boolean isNeedVerify;
/**
* 注册类型为1时使用:微信用户数据字段1,根据1、2进行数据解密,计算出手机号
*/
@ApiModelProperty("注册类型为1时使用:微信用户数据字段1,根据1、2进行数据解密,计算出手机号")
private String encryptedData;
/**
* 注册类型为1时使用:微信用户数据字段2,根据1、2进行数据解密,计算出手机号
*/
@ApiModelProperty("注册类型为1时使用:微信用户数据字段1,根据1、2进行数据解密,计算出手机号")
private String iv;
/**
*注册类型为1时使用:微信用户数据字段3,根据1、2、3进行数据解密,计算出手机号
*/
@ApiModelProperty("注册类型为1时使用:微信用户数据字段3,根据1、2、3进行数据解密,计算出手机号")
private String code;
/**
* 注册类型为2-手机验证登录时使用:手机号
*/
@ApiModelProperty("注册类型为2-手机验证登录时使用:手机号")
private String phoneNo;
/**
* 注册类型为2-手机验证登录时使用:验证码
*/
@ApiModelProperty("注册类型为2-手机验证登录时使用:验证码")
private String verifyCode;
@ApiModelProperty("农户信息")
private PeasantHouseholdDto peasantHouseholdDto;
}
...@@ -73,6 +73,9 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -73,6 +73,9 @@ public class PeasantHouseholdDto extends BaseDto {
@ApiModelProperty(value = "勘察状态描述") @ApiModelProperty(value = "勘察状态描述")
private String surveyOrNotText; private String surveyOrNotText;
@ApiModelProperty(value = "证件类型")
private String idType;
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
private String idCard; private String idCard;
...@@ -103,4 +106,30 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -103,4 +106,30 @@ public class PeasantHouseholdDto extends BaseDto {
@ApiModelProperty(value = "常住地址文字") @ApiModelProperty(value = "常住地址文字")
@TableField(typeHandler = FastjsonTypeHandler.class) @TableField(typeHandler = FastjsonTypeHandler.class)
private List<String> permanentAddressText; private List<String> permanentAddressText;
@ApiModelProperty(value = "区域公司id")
private Long regionalCompaniesSeq;
@ApiModelProperty(value = "区域公司code")
private String regionalCompaniesCode;
@ApiModelProperty(value = "区域公司名称")
private String regionalCompaniesName;
@ApiModelProperty(value = "身份证正面")
@TableField(typeHandler = FastjsonTypeHandler.class)
private List<Object> idCardFront;
@ApiModelProperty(value = "身份证反面")
@TableField(typeHandler = FastjsonTypeHandler.class)
private List<Object> idCardOpposite;
@ApiModelProperty(value = "微信唯一id")
private String openId;
@ApiModelProperty(value = "是否已认证(0-未认证,1-已认证)")
private Integer isCertified;
@ApiModelProperty(value = "平台userId")
private String userId;
} }
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Provence
* @version v1.0
* @date 2023/8/21 13:16
*/
@Data
@ApiModel (value="PeasantHouseholdWxDto", description="微信农户登录信息")
public class PeasantHouseholdWxDto {
@ApiModelProperty (value = "token有效期")
private Long expire;
@ApiModelProperty (value = "userId")
private String userId;
@ApiModelProperty
private String userState;
@ApiModelProperty (value = "农户信息")
private PeasantHousehold peasantHousehold;
@ApiModelProperty
private Map<String, Object> userInfo;
@ApiModelProperty
private Map<String, Object> authInfo;
}
package com.yeejoin.amos.boot.module.hygf.api.dto; package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoneyLog;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotEmpty;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 发货单 * 发货单
...@@ -16,6 +24,7 @@ import java.util.Date; ...@@ -16,6 +24,7 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value="PreparationMoneyDto", description="发货单") @ApiModel(value="PreparationMoneyDto", description="发货单")
@JsonIgnoreProperties(ignoreUnknown = true)
public class PreparationMoneyDto extends BaseDto { public class PreparationMoneyDto extends BaseDto {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -34,6 +43,7 @@ public class PreparationMoneyDto extends BaseDto { ...@@ -34,6 +43,7 @@ public class PreparationMoneyDto extends BaseDto {
private String orderUser; private String orderUser;
@ApiModelProperty(value = "下单时间") @ApiModelProperty(value = "下单时间")
@JsonFormat (pattern="yyyy-MM-dd")
private Date orderTime; private Date orderTime;
@ApiModelProperty(value = "经销商id") @ApiModelProperty(value = "经销商id")
...@@ -43,7 +53,8 @@ public class PreparationMoneyDto extends BaseDto { ...@@ -43,7 +53,8 @@ public class PreparationMoneyDto extends BaseDto {
private String dealerName; private String dealerName;
@ApiModelProperty(value = " 发货地址") @ApiModelProperty(value = " 发货地址")
private String sendAddress; @TableField (typeHandler = FastjsonTypeHandler.class)
private List<String> sendAddress;
@ApiModelProperty(value = " 业主类型") @ApiModelProperty(value = " 业主类型")
private String ownerType; private String ownerType;
...@@ -64,16 +75,19 @@ public class PreparationMoneyDto extends BaseDto { ...@@ -64,16 +75,19 @@ public class PreparationMoneyDto extends BaseDto {
private String consigneePhone; private String consigneePhone;
@ApiModelProperty(value = "收货人地址") @ApiModelProperty(value = "收货人地址")
private String consigneeAddress; @TableField (typeHandler = FastjsonTypeHandler.class)
private List<String> consigneeAddress;
@ApiModelProperty(value = "收货人详细地址") @ApiModelProperty(value = "收货人详细地址")
private String consigneeDetailAddress; private String consigneeDetailAddress;
@ApiModelProperty(value = "发货单") @ApiModelProperty(value = "发货单")
private String invoice; @TableField(typeHandler = FastjsonTypeHandler.class)
private List<Object> invoice;
@ApiModelProperty(value = "收货单") @ApiModelProperty(value = "收货单")
private String receipt; @TableField(typeHandler = FastjsonTypeHandler.class)
private List<Object> receipt;
@ApiModelProperty(value = "订单状态0未完成1已完成2作废") @ApiModelProperty(value = "订单状态0未完成1已完成2作废")
private String documentState; private String documentState;
...@@ -99,4 +113,17 @@ public class PreparationMoneyDto extends BaseDto { ...@@ -99,4 +113,17 @@ public class PreparationMoneyDto extends BaseDto {
@ApiModelProperty(value = "总价") @ApiModelProperty(value = "总价")
private Double totalPrice; private Double totalPrice;
@ApiModelProperty(value = "到货时间")
@JsonFormat (pattern="yyyy-MM-dd")
private Date deliveryTime;
@ApiModelProperty(value = "发货电站列表")
@NotEmpty(message = "请选择发货电站")
private List<PeasantHouseholdDto> powerStations;
@ApiModelProperty(value = "BOM清单")
private List<DocumentBomDto> documentBoms;
@ApiModelProperty(value = "单据追踪")
private List<PreparationMoneyLogDto> preparationMoneyLogs;
} }
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 发货单
*
* @author system_generator
* @date 2023-08-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="PreparationMoneyLogDto", description="发货单追踪记录")
public class PreparationMoneyLogDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "货单id")
private Long preparationMoneyId;
@ApiModelProperty(value = "货单id")
private String operationContent;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-23
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="SealDictionaryDto", description="")
public class SealDictionaryDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "平台公司id")
private Long amosCompanySeq;
@ApiModelProperty(value = "平台公名称")
private String amosCompanyName;
@ApiModelProperty(value = "印章id")
private Long sealId;
@ApiModelProperty(value = "盖章人")
private String sealedUser;
@ApiModelProperty(value = "盖章人手机号")
private String sealedPhone;
private String category;
private String companyTenantName;
}
...@@ -12,4 +12,9 @@ public class TemplateParamDto { ...@@ -12,4 +12,9 @@ public class TemplateParamDto {
private String key; private String key;
private String value; private String value;
public TemplateParamDto(String key, String value) {
this.key = key;
this.value = value;
}
} }
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
/**
* TODO(一句话描述该类的功能)
*
* @author Provence
* @version v1.0
* @date 2023/8/22 13:05
*/
@Data
public class WechatQrCodeDTO {
/**
* 数据类型 (MIME Type)
*/
private String contentType;
/**
* byte数据 微信生成的二维码
*/
private byte[] buffer;
/**
* 错误码
*/
private Integer errCode;
/**
* 错误信息
*/
private String errMsg;
}
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("hygf_contract_template")
public class ContractTemplate extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 模板名称
*/
@TableField("template_name")
private String templateName;
/**
* 模板id
*/
@TableField("template_id")
private Long templateId;
/**
* 公司签字位置
*/
@TableField("company_keyword")
private String companyKeyword;
/**
* 公司签字页码
*/
@TableField("company_page")
private Integer companyPage;
/**
* 公司签字位置x偏移量
*/
@TableField("company_offsetx")
private Double companyOffsetx;
/**
* 公司签字位置y偏移量
*/
@TableField("company_offsety")
private Double companyOffsety;
/**
* 个人签字位置
*/
@TableField("personal_keyword")
private String personalKeyword;
/**
* 个人签字页码
*/
@TableField("personal_page")
private Integer personalPage;
/**
* 个人签字位置x偏移量
*/
@TableField("personal_offsetx")
private Double personalOffsetx;
/**
* 个人签字位置y偏移量
*/
@TableField("personal_offsety")
private Double personalOffsety;
@TableField("num")
private Integer num;
@TableField("personal_keyword_index")
private Integer personalKeywordIndex;
@TableField("company_keyword_index")
private Integer companyKeywordIndex;
}
...@@ -178,7 +178,7 @@ public class HouseholdContract extends BaseEntity { ...@@ -178,7 +178,7 @@ public class HouseholdContract extends BaseEntity {
免租期 免租期
*/ */
@TableField("rent_free") @TableField("rent_free")
private String rentFree; private Date rentFree;
/** /**
* 租金计算日期 * 租金计算日期
...@@ -225,13 +225,13 @@ public class HouseholdContract extends BaseEntity { ...@@ -225,13 +225,13 @@ public class HouseholdContract extends BaseEntity {
*合同契约锁id' *合同契约锁id'
* */ * */
@TableField("contract_lock_id") @TableField("contract_lock_id")
private Double contractLockId; private Long contractLockId;
/** /**
* 印章id * 印章id
* */ * */
@TableField("seal_id") @TableField("seal_id")
private Double sealId; private Long sealId;
/** /**
* 发起状态 * 发起状态
...@@ -245,4 +245,7 @@ public class HouseholdContract extends BaseEntity { ...@@ -245,4 +245,7 @@ public class HouseholdContract extends BaseEntity {
@TableField("signing_time") @TableField("signing_time")
private Date signingTime; private Date signingTime;
@TableField("user_id")
private String userId;
} }
...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.TableField; ...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
...@@ -140,4 +139,44 @@ public class PeasantHousehold extends BaseEntity { ...@@ -140,4 +139,44 @@ public class PeasantHousehold extends BaseEntity {
* */ * */
@TableField("developer") @TableField("developer")
private String developer; private String developer;
/*
* 区域公司id
* */
@TableField("regional_companies_seq")
private Long regionalCompaniesSeq;
/*
* 区域公司code
* */
@TableField("regional_companies_code")
private String regionalCompaniesCode;
/*
* 区域公司名称
* */
@TableField("regional_companies_name")
private String regionalCompaniesName;
/*
* 身份证正面
* */
@TableField(value = "id_card_front", typeHandler = FastjsonTypeHandler.class)
private List<Object> idCardFront;
/*
* 身份证反面
* */
@TableField(value = "id_card_opposite", typeHandler = FastjsonTypeHandler.class)
private List<Object> idCardOpposite;
/*
* 微信唯一id
* */
@TableField("open_id")
private String openId;
/*
* 是否已认证(0-未认证,1-已认证)
* */
@TableField("is_certified")
private Integer isCertified;
/*
* 平台userId
* */
@TableField("user_id")
private String userId;
} }
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("hygf_preparation_money") @TableName(value="hygf_preparation_money",autoResultMap = true)
public class PreparationMoney extends BaseEntity { public class PreparationMoney extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -70,8 +70,8 @@ public class PreparationMoney extends BaseEntity { ...@@ -70,8 +70,8 @@ public class PreparationMoney extends BaseEntity {
/** /**
* 发货地址 * 发货地址
*/ */
@TableField("send_address") @TableField(value = "send_address",typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.IGNORED)
private String sendAddress; private List<Object> sendAddress;
/** /**
* 业主类型 * 业主类型
...@@ -112,8 +112,8 @@ public class PreparationMoney extends BaseEntity { ...@@ -112,8 +112,8 @@ public class PreparationMoney extends BaseEntity {
/** /**
* 收货人地址 * 收货人地址
*/ */
@TableField("consignee_address") @TableField(value = "consignee_address",typeHandler = FastjsonTypeHandler.class)
private String consigneeAddress; private List<Object> consigneeAddress;
/** /**
* 收货人详细地址 * 收货人详细地址
...@@ -125,14 +125,14 @@ public class PreparationMoney extends BaseEntity { ...@@ -125,14 +125,14 @@ public class PreparationMoney extends BaseEntity {
* 发货单 * 发货单
*/ */
@TableField(value = "invoice",typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.IGNORED) @TableField(value = "invoice",typeHandler = FastjsonTypeHandler.class)
private List<Object> invoice; private List<Object> invoice;
/** /**
* 收货单 * 收货单
*/ */
@TableField(value = "receipt",typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.IGNORED) @TableField(value = "receipt",typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.IGNORED)
private String receipt; private List<Object> receipt;
/** /**
* 订单状态0未完成1已完成2已作废 * 订单状态0未完成1已完成2已作废
...@@ -188,4 +188,10 @@ public class PreparationMoney extends BaseEntity { ...@@ -188,4 +188,10 @@ public class PreparationMoney extends BaseEntity {
@TableField("validating") @TableField("validating")
private String validating; private String validating;
/**
* 到货时间
*/
@TableField("delivery_time")
private Date deliveryTime;
} }
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 发货单日志记录
*
* @author system_generator
* @date 2023-08-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors (chain = true)
@TableName (value = "hygf_preparation_money_log")
public class PreparationMoneyLog extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableField ("preparation_money_id")
private Long preparationMoneyId;
@TableField ("operation_content")
private String operationContent;
}
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-23
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("hygf_seal_dictionary")
public class SealDictionary extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 平台公司id
*/
@TableField("amos_company_seq")
private Long amosCompanySeq;
/**
* 平台公名称
*/
@TableField("amos_company_name")
private String amosCompanyName;
/**
* 印章id
*/
@TableField("seal_id")
private Long sealId;
/**
* 盖章人
*/
@TableField("sealed_user")
private String sealedUser;
/**
* 盖章人手机号
*/
@TableField("sealed_phone")
private String sealedPhone;
/*
契约锁业务分类
* **/
@TableField("category")
private String category;
/**
* 契约锁签署公司
* */
@TableField("company_tenant_name")
private String companyTenantName;
}
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.ContractTemplate;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-08-22
*/
public interface ContractTemplateMapper extends BaseMapper<ContractTemplate> {
}
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoneyLog;
/**
* 发货单 Mapper 接口
*
* @author system_generator
* @date 2023-08-17
*/
public interface PreparationMoneyLogMapper extends BaseMapper<PreparationMoneyLog> {
}
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.SealDictionary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-08-23
*/
public interface SealDictionaryMapper extends BaseMapper<SealDictionary> {
}
package com.yeejoin.amos.boot.module.hygf.api.service;
/**
* 接口类
*
* @author system_generator
* @date 2023-08-22
*/
public interface IContractTemplateService {
}
package com.yeejoin.amos.boot.module.hygf.api.service; package com.yeejoin.amos.boot.module.hygf.api.service;
import com.yeejoin.amos.boot.module.hygf.api.dto.DocumentBomDto;
import java.util.List;
/** /**
* 发货单bom接口类 * 发货单bom接口类
* *
......
package com.yeejoin.amos.boot.module.hygf.api.service;
/**
* 发货单接口类
*
* @author system_generator
* @date 2023-08-17
*/
public interface IPreparationMoneyLogService {
}
package com.yeejoin.amos.boot.module.hygf.api.service; package com.yeejoin.amos.boot.module.hygf.api.service;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto;
/** /**
* 发货单接口类 * 发货单接口类
* *
...@@ -9,4 +11,27 @@ package com.yeejoin.amos.boot.module.hygf.api.service; ...@@ -9,4 +11,27 @@ package com.yeejoin.amos.boot.module.hygf.api.service;
*/ */
public interface IPreparationMoneyService { public interface IPreparationMoneyService {
/**
* 新增/更新发货单
*
*
* @param model dto
* @return {@link PreparationMoneyDto}
* @author Provence
* @throws
*/
PreparationMoneyDto saveOrUpdateObject(PreparationMoneyDto model);
/**
* 更新发货单状态
*
*
* @param sequenceNbr 发货单ID
* @param operationType 操作类型(RECEIPT-确认收货, DELIVERY-发货, DISCARD-废弃)
* @return {@link Boolean}
* @author Provence
* @throws
*/
Boolean updatePreparationMoneyStatus(Long sequenceNbr, String operationType);
} }
package com.yeejoin.amos.boot.module.hygf.api.service;
/**
* 接口类
*
* @author system_generator
* @date 2023-08-23
*/
public interface ISealDictionaryService {
}
package com.yeejoin.amos.boot.module.hygf.api.service;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Provence
* @version v1.0
* @date 2023/8/22 12:53
*/
public interface IWxService {
/**
* 统一提供小程序Token
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
*
* @return
*/
String getAccessToken();
/**
* 统一产生第三方页面二维码
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
*
* @param access_token 接口调用凭证
* @param scene 传递的参数
* 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
String getSmallProQrCode(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline);
/**
* 统一产生第三方页面二维码
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
*
* @param access_token 接口调用凭证
* @param scene 传递的参数
* 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
byte[] getSmallProQrCodeByte(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline);
/**
* 小程序二维码请求-文件流
*
* @param access_token
* @param scene
* @param page
* @param width
* @param auto_color
* @param line_color
* @param is_hyaline
* @param response
* @param fileName
* @param fileType
*/
String getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline, HttpServletResponse response, String fileName, String fileType);
/**
* code转session
*
* @param code
* @return
*/
JSONObject getCode2Session(String code);
/**
* 获取sessionKey
*
* @param code
* @return
*/
String getSessionKey(String code);
/**
* 获取openId
*
* @param code
* @return
*/
String getOpenId(String code);
/**
* 获取电话号码
* @param session_key
* @param encryptedData
* @param iv
* @return
*/
String getPhoneNumber(String session_key, String encryptedData, String iv);
/* *//**
* 微信消息通知推送
* @param
*//*
void sendWeChatUpcomingMessage(List<String> openIds, String template, List<String> message) ;*/
String getName();
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.api.mapper.ContractTemplateMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.api.mapper.SealDictionaryMapper">
</mapper>
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.ContractTemplateServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.ContractTemplateDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
*
*
* @author system_generator
* @date 2023-08-22
*/
@RestController
@Api(tags = "Api")
@RequestMapping(value = "/contract-template")
public class ContractTemplateController extends BaseController {
@Autowired
ContractTemplateServiceImpl contractTemplateServiceImpl;
/**
* 新增
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增", notes = "新增")
public ResponseModel<ContractTemplateDto> save(@RequestBody ContractTemplateDto model) {
model = contractTemplateServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<ContractTemplateDto> updateBySequenceNbrContractTemplate(@RequestBody ContractTemplateDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(contractTemplateServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@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){
return ResponseHelper.buildResponse(contractTemplateServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个", notes = "根据sequenceNbr查询单个")
public ResponseModel<ContractTemplateDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(contractTemplateServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询")
public ResponseModel<Page<ContractTemplateDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
Page<ContractTemplateDto> page = new Page<ContractTemplateDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(contractTemplateServiceImpl.queryForContractTemplatePage(page));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<ContractTemplateDto>> selectForList() {
return ResponseHelper.buildResponse(contractTemplateServiceImpl.queryForContractTemplateList());
}
}
...@@ -113,4 +113,25 @@ public class DocumentBomController extends BaseController { ...@@ -113,4 +113,25 @@ public class DocumentBomController extends BaseController {
public ResponseModel<List<DocumentBomDto>> selectForList() { public ResponseModel<List<DocumentBomDto>> selectForList() {
return ResponseHelper.buildResponse(documentBomServiceImpl.queryForDocumentBomList()); return ResponseHelper.buildResponse(documentBomServiceImpl.queryForDocumentBomList());
} }
/**
* 根据货单id查询BOM清单
*
*
* @param preparationMoneyId preparationMoneyId
* @return {@link ResponseModel< List< DocumentBomDto>>}
* @author Provence
* @throws
* @date 2023/8/17 20:33
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "根据货单id查询BOM清单", notes = "根据货单id查询BOM清单")
@GetMapping(value = "/listByPreparationMoneyId")
public ResponseModel<Page<DocumentBomDto>> listByPreparationMoneyId(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam Long preparationMoneyId) {
Page<DocumentBomDto> page = new Page<DocumentBomDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(documentBomServiceImpl.queryForDocumentBomPage(page, preparationMoneyId));
}
} }
...@@ -4,13 +4,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,13 +4,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.hygf.api.Enum.HouseholdContractEnum; import com.yeejoin.amos.boot.module.hygf.api.Enum.HouseholdContractEnum;
import com.yeejoin.amos.boot.module.hygf.api.dto.HouseholdContractPageDto; import com.yeejoin.amos.boot.module.hygf.api.dto.HouseholdContractPageDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract; import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract;
import com.yeejoin.amos.boot.module.hygf.api.mapper.HouseholdContractMapper;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.QiyuesuoServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl;
import org.typroject.tyboot.core.foundation.context.RequestContext;
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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -34,6 +46,11 @@ public class HouseholdContractController extends BaseController { ...@@ -34,6 +46,11 @@ public class HouseholdContractController extends BaseController {
@Autowired @Autowired
HouseholdContractServiceImpl householdContractServiceImpl; HouseholdContractServiceImpl householdContractServiceImpl;
@Value("${regionalCompanies.company.seq}")
private Long regionalCompanies;
@Autowired
QiyuesuoServiceImpl qiyuesuoServiceImpl;
/** /**
* 新增 * 新增
...@@ -84,8 +101,17 @@ public class HouseholdContractController extends BaseController { ...@@ -84,8 +101,17 @@ public class HouseholdContractController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}") @GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个", notes = "根据sequenceNbr查询单个") @ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个", notes = "根据sequenceNbr查询单个")
public ResponseModel<HouseholdContractDto> selectOne(@PathVariable Long sequenceNbr) { public ResponseModel<HouseholdContract> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(householdContractServiceImpl.queryBySeq(sequenceNbr));
HouseholdContract householdContract = householdContractServiceImpl.getById(sequenceNbr);
if(householdContract.getContractLockId()!=null&&householdContract.getContractUrl()==null){
String url= qiyuesuoServiceImpl.getdownloadUrl(householdContract.getContractLockId());
householdContract.setContractUrl(url);
householdContractServiceImpl.updateById(householdContract);
}
return ResponseHelper.buildResponse(householdContract);
} }
/** /**
...@@ -121,22 +147,85 @@ public class HouseholdContractController extends BaseController { ...@@ -121,22 +147,85 @@ public class HouseholdContractController extends BaseController {
@ApiOperation(httpMethod = "post", value = "根据sequenceNbr发起", notes = "根据sequenceNbr发起") @ApiOperation(httpMethod = "post", value = "根据sequenceNbr发起", notes = "根据sequenceNbr发起")
public ResponseModel<HouseholdContractDto> qsBySequenceNbrHouseholdContract(@RequestBody HouseholdContractDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) { public ResponseModel<HouseholdContractDto> qsBySequenceNbrHouseholdContract(@RequestBody HouseholdContractDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(householdContractServiceImpl.updateWithModel(model)); return ResponseHelper.buildResponse(householdContractServiceImpl.updateWithModel(model));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/signing/{sequenceNbr}")
@ApiOperation(httpMethod = "Post", value = "签字", notes = "签字")
public ResponseModel<Boolean> signing(@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
HouseholdContract householdContrac= householdContractServiceImpl.getById(sequenceNbr);
householdContrac.setSignStatus(HouseholdContractEnum.签字状态_已签字.getCode());
return ResponseHelper.buildResponse(householdContractServiceImpl.updateById(householdContrac));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/stamp/{sequenceNbr}")
@ApiOperation(httpMethod = "Post", value = "盖章", notes = "盖章")
public ResponseModel<Boolean> stamp(@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
HouseholdContract householdContrac= householdContractServiceImpl.getById(sequenceNbr);
householdContrac.setStampStatus(HouseholdContractEnum.盖章状态_已盖章.getCode());
householdContrac.setSigningTime(new Date());
householdContrac.setStatus(HouseholdContractEnum.合同状态_已签署.getCode());
householdContrac.setSealedUser(getUserInfo().getRealName());
return ResponseHelper.buildResponse(householdContractServiceImpl.updateById(householdContrac));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/cancel/{sequenceNbr}")
@ApiOperation(httpMethod = "Post", value = "作废", notes = "作废")
public ResponseModel<Boolean> cancel(@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
HouseholdContract householdContrac= householdContractServiceImpl.getById(sequenceNbr);
householdContrac.setStatus(HouseholdContractEnum.合同状态_已作废.getCode());
return ResponseHelper.buildResponse(householdContractServiceImpl.updateById(householdContrac));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/sealId/tree")
@ApiOperation(httpMethod = "GET", value = "印章", notes = "印章")
public ResponseModel<List<CompanyModel>> sealId() {
FeignClientResult<Collection<CompanyModel>> feignClientResult= Privilege.companyClient.querySubAgencyTree(regionalCompanies);
List<CompanyModel> companyModel = (List<CompanyModel>)feignClientResult.getResult();
companyModel=companyModel.stream().filter(compan->compan.getCompanyCode()!=null&&!"".equals(compan.getCompanyCode())).collect(Collectors.toList());
return ResponseHelper.buildResponse(companyModel);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/reissue/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "重新发起", notes = "重新发起")
public ResponseModel<HouseholdContract> reissue(@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
HouseholdContract peasantHousehold= householdContractServiceImpl.getById(sequenceNbr);
//生成合同
HouseholdContract householdContract=new HouseholdContract();
householdContract.setPartyA(peasantHousehold.getPartyA());
householdContract.setPeasantHouseholdNumber(peasantHousehold.getPeasantHouseholdNumber());
householdContract.setPeasantHouseholdCard(peasantHousehold.getPeasantHouseholdCard());
householdContract.setDealerId(peasantHousehold.getDealerId());
householdContract.setDealerCode(peasantHousehold.getDealerCode());
householdContract.setDealerName(peasantHousehold.getDealerName());
householdContract.setPeasantHouseholdId(peasantHousehold.getSequenceNbr());
householdContract.setRegionalCompaniesCode(peasantHousehold.getRegionalCompaniesCode());
householdContract.setRegionalCompaniesName(peasantHousehold.getRegionalCompaniesName());
householdContract.setRegionalCompaniesSeq(peasantHousehold.getRegionalCompaniesSeq());
householdContract.setPeasantHouseholdPhone(peasantHousehold.getPeasantHouseholdPhone());
householdContract.setProjectAddressDetail(peasantHousehold.getProjectAddressDetail());
householdContract.setProjectAddressName(peasantHousehold.getProjectAddressName());
householdContract.setPermanentAddressDetail(peasantHousehold.getPermanentAddressDetail());
householdContract.setPermanentAddressName(peasantHousehold.getPermanentAddressName());
householdContract.setUserId(peasantHousehold.getUserId());
householdContractServiceImpl.addHouseholdContract(householdContract);
householdContractServiceImpl.reissueinitiateHouseholdContract(peasantHousehold,householdContract.getSequenceNbr());
return ResponseHelper.buildResponse(householdContract);
}
} }
...@@ -201,13 +201,14 @@ public class PeasantHouseholdController extends BaseController { ...@@ -201,13 +201,14 @@ public class PeasantHouseholdController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "农户信息分页查询", notes = "农户信息分页查询") @ApiOperation(httpMethod = "GET",value = "农户信息分页查询", notes = "农户信息分页查询")
public ResponseModel<Page<PeasantHouseholdDto>> queryForPage(@RequestParam(value = "current") int current, public ResponseModel<Page<PeasantHouseholdDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, @RequestParam(value = "size") int size,
@RequestParam(value = "ownersName",required = false)String ownersName) { @RequestParam(value = "ownersName",required = false)String ownersName,
@RequestParam(value = "developerId",required = false)Long developerId) {
Page<PeasantHouseholdDto> page = new Page<PeasantHouseholdDto>(); Page<PeasantHouseholdDto> page = new Page<PeasantHouseholdDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
AgencyUserModel userInfo = getUserInfo(); AgencyUserModel userInfo = getUserInfo();
String orgCode = userInfo.getCompanys().get(0).getOrgCode(); String orgCode = userInfo.getCompanys().get(0).getOrgCode();
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.queryForPeasantHouseholdPage(page,orgCode,ownersName)); return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.queryForPeasantHouseholdPage(page,orgCode,ownersName,developerId));
} }
/** /**
......
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.dto.MobileLoginParamDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdWxDto;
import com.yeejoin.amos.boot.module.hygf.api.service.IWxService;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import com.yeejoin.amos.feign.systemctl.model.SmsRecordModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
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.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 农户信息
*
* @author system_generator
* @date 2023-07-07
*/
@RestController
@Api (tags = "农户信息Api for mobile端")
@RequestMapping (value = "/peasant-household/mobile")
@Slf4j
public class PeasantHouseholdWxController extends BaseController {
@Autowired
RedisUtils redisUtil;
@Autowired
SurveyInformationServiceImpl surveyInformationServiceImpl;
@Autowired
PeasantHouseholdServiceImpl peasantHouseholdServiceImpl;
@Autowired
HouseholdContractServiceImpl householdContractServiceImpl;
@Autowired
private IWxService wxService;
@Value("${dealer.userId}")
private String defaultUserId;
@Value("${hygfProgram.loginPage:view/mine/minepage/LoginPhone}")
private String miniprogramLoginPage;
private static final String regionRedis = "app_region_redis";
/*@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping (value = "/authenticate", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信农户认证", notes = "微信农户认证")
public ResponseModel<Boolean> authenticate(@ApiParam(name = "农户信息id") @RequestParam Long sequenceNbr) {
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.doAuthenticate(sequenceNbr));
}*/
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation("获取验证码")
@GetMapping("/getAuthCode")
public ResponseModel<Boolean> getAuthCode(@RequestParam String phoneNo) {
HashMap<String, String> sendMap = new HashMap<>();
sendMap.put("mobile", phoneNo);
sendMap.put("smsType", "MOBILE_LOGIN");
FeignClientResult<SmsRecordModel> sendVerifyCodeResult = Systemctl.smsClient.sendVerifyCode(sendMap);
if (sendVerifyCodeResult.getStatus() != 200) {
if (log.isErrorEnabled()) {
log.error("调用平台发送验证码失败:{}", sendVerifyCodeResult.getDevMessage());
}
throw new BadRequest(sendVerifyCodeResult.getMessage());
}
return ResponseHelper.buildResponse(true);
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping (value = "/login", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信授权登陆", notes = "微信授权登陆")
public ResponseModel<PeasantHouseholdWxDto> wxUserLogin(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) {
if (StringUtils.isBlank(defaultUserId)) {
if (StringUtils.isBlank(mobileLoginParam.getUserId())) {
throw new BadRequest("二维码参数userId为空");
}
} else {
// 配置了测试用的userId 则覆盖扫码的userId
mobileLoginParam.setUserId(defaultUserId);
}
//peasantHouseholdServiceImpl.setPlatFormAccess();
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.wxUserLogin(mobileLoginParam));
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping (value = "/register", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信农户注册", notes = "微信农户注册")
public ResponseModel<PeasantHouseholdDto> wxUserRegister(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) {
// log.info("微信农户注册, 入参 => {}", JSONObject.toJSONString(mobileLoginParam));
if (null == mobileLoginParam.getPeasantHouseholdDto()) {
throw new BadRequest("农户信息不能为空");
}
PeasantHouseholdDto model = mobileLoginParam.getPeasantHouseholdDto();
AgencyUserModel userInfo = getUserInfo();
model.setUserId(userInfo.getUserId());// 绑定平台userId
model.setPeasantHouseholdNo(peasantHouseholdServiceImpl.getPeasantHouseholdNo());
model.setIsCertified(1);// 这里就实名认证
model.setSurveyOrNot(0);
model.setReview(0);
JSONArray regionName = getRegionName();
List<RegionModel> list = JSONArray.parseArray(regionName.toJSONString(), RegionModel.class);
// 处理项目地址
String area = "";
if (model.getProjectAddress() != null && model.getProjectAddress().size() != 0) {
for (Integer reg : model.getProjectAddress())
for (RegionModel re : list) {
if (re.getRegionCode().equals(Integer.valueOf(reg))) {
area = area + re.getRegionName() + "/";
}
}
model.setProjectAddressName(area.length() > 2 ? area.substring(0, area.length() - 2) : area);
if ("1".equals(model.getIsPermanent()) || "true".equals(model.getIsPermanent())) {
model.setPermanentAddress(model.getProjectAddress());
model.setPermanentAddressDetail(model.getProjectAddressDetail());
model.setPermanentAddressName(area.length() > 2 ? area.substring(0, area.length() - 2) : area);
} else {
// 处理常住地址
String permanent = "";
if (model.getPermanentAddress() != null && model.getPermanentAddress().size() != 0) {
for (Integer reg : model.getPermanentAddress())
for (RegionModel re : list) {
if (re.getRegionCode().equals(Integer.valueOf(reg))) {
permanent = permanent + re.getRegionName() + "/";
}
}
model.setPermanentAddressName(permanent.length() > 2 ? permanent.substring(0, permanent.length() - 2) : permanent);
}
}
}
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.savePeasantHousehold(model));
}
public JSONArray getRegionName() {
JSONArray jsonArray = new JSONArray();
if (redisUtil.hasKey(regionRedis)) {
jsonArray = JSONArray.parseArray(redisUtil.get(regionRedis).toString());
} else {
Collection<RegionModel> regionChild = new ArrayList<>();
RegionModel regionModel1 = new RegionModel();
regionChild.add(regionModel1);
FeignClientResult<Collection<RegionModel>> collectionFeignClientResult = Systemctl.regionClient.queryForTreeParent(610000L);
Collection<RegionModel> result = collectionFeignClientResult.getResult();
for (RegionModel regionModel : result) {
if (null != regionModel && null != regionModel.getChildren()) {
for (RegionModel child : regionModel.getChildren()) {
if (null != child && null != child.getChildren()) {
for (RegionModel childChild : child.getChildren()) {
jsonArray.add(childChild);
}
child.setChildren(regionChild);
jsonArray.add(child);
}
}
regionModel.setChildren(regionChild);
jsonArray.add(regionModel);
}
}
redisUtil.set(regionRedis, jsonArray);
}
return jsonArray;
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping("/getRegionQrCode")
@ApiOperation (httpMethod = "GET", value = " 获取区域经销商二维码", notes = " 获取区域经销商二维码")
public ResponseModel<Map<String, Object>> getRegionQrCode(
@RequestParam (value = "fileType", required = false, defaultValue = "png") String fileType,
@RequestParam (value = "width", required = false, defaultValue = "350") String width,
HttpServletResponse response) {
AgencyUserModel userInfo = getUserInfo();
log.info("获取区域经销商二维码, userId:{}", userInfo.getUserId());
String accessToken = wxService.getAccessToken();
// 生成二维码
String page = miniprogramLoginPage;
String scene = "userId=" + userInfo.getUserId() + "&qrCodeType=region";
// 返回当前用户ID
String picStr = wxService.getSmallProQrCodeResponse(accessToken, scene, page, Long.valueOf(width), null, null, null, response,
"二维码_" + userInfo.getUserId(), fileType);
PeasantHouseholdDto peasantHouseholdDto = peasantHouseholdServiceImpl.buildDefaultPeasantHouseholdDto("region", userInfo);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("qrCodePic", picStr);
resultMap.put("peasantHousehold", peasantHouseholdDto);
return ResponseHelper.buildResponse(resultMap);
}
@GetMapping("/getPersonalQrCode")
@ApiOperation (httpMethod = "GET", value = " 获取个人经销商二维码", notes = " 获取个人经销商二维码")
public void getPersonalQrCode(
@RequestParam (value = "fileType", required = false, defaultValue = "png") String fileType,
@RequestParam (value = "width", required = false, defaultValue = "350") String width,
HttpServletResponse response) {
AgencyUserModel userInfo = getUserInfo();
String accessToken = wxService.getAccessToken();
String page = "view/mine/minepage/Login" + "?userId=" + userInfo.getUserId() + "&qrCodeType=personal";
wxService.getSmallProQrCodeResponse(accessToken, null, page, Long.valueOf(width), null, null, null, response,
page, fileType);
}
}
package com.yeejoin.amos.boot.module.hygf.biz.controller; package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationPageDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationPageDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney; import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney;
import io.swagger.annotations.ApiModelProperty; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -12,11 +13,14 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController; ...@@ -12,11 +13,14 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PreparationMoneyServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PreparationMoneyServiceImpl;
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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto;
...@@ -45,8 +49,8 @@ public class PreparationMoneyController extends BaseController { ...@@ -45,8 +49,8 @@ public class PreparationMoneyController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增发货单", notes = "新增发货单") @ApiOperation(httpMethod = "POST", value = "新增发货单", notes = "新增发货单")
public ResponseModel<PreparationMoneyDto> save(@RequestBody PreparationMoneyDto model) { public ResponseModel<PreparationMoneyDto> save(@Validated @RequestBody PreparationMoneyDto model) {
model = preparationMoneyServiceImpl.createWithModel(model); model = preparationMoneyServiceImpl.saveOrUpdateObject(model);
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse(model);
} }
...@@ -61,7 +65,7 @@ public class PreparationMoneyController extends BaseController { ...@@ -61,7 +65,7 @@ public class PreparationMoneyController extends BaseController {
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新发货单", notes = "根据sequenceNbr更新发货单") @ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新发货单", notes = "根据sequenceNbr更新发货单")
public ResponseModel<PreparationMoneyDto> updateBySequenceNbrPreparationMoney(@RequestBody PreparationMoneyDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) { public ResponseModel<PreparationMoneyDto> updateBySequenceNbrPreparationMoney(@RequestBody PreparationMoneyDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(preparationMoneyServiceImpl.updateWithModel(model)); return ResponseHelper.buildResponse(preparationMoneyServiceImpl.saveOrUpdateObject(model));
} }
/** /**
...@@ -120,4 +124,47 @@ public class PreparationMoneyController extends BaseController { ...@@ -120,4 +124,47 @@ public class PreparationMoneyController extends BaseController {
public ResponseModel<List<PreparationMoneyDto>> selectForList() { public ResponseModel<List<PreparationMoneyDto>> selectForList() {
return ResponseHelper.buildResponse(preparationMoneyServiceImpl.queryForPreparationMoneyList()); return ResponseHelper.buildResponse(preparationMoneyServiceImpl.queryForPreparationMoneyList());
} }
/**
* 发货价格中金额列联动接口
*
* -根据发货电站表单传入的场站ID 查询数据然后计算相应的金额
*
*
* @param
* @return {@link ResponseModel< List< PreparationMoneyDto>>}
* @author Provence
* @throws
* @date 2023/8/17 18:23
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/getShippingPrice")
@ApiOperation(httpMethod = "POST", value = "发货价格数据查询", notes = "发货价格数据查询")
public ResponseModel<PreparationMoneyDto> getShippingPrice(@RequestBody List<PeasantHouseholdDto> dtos) {
List<Long> powerHouseholdIds = dtos.stream().map(PeasantHouseholdDto::getSequenceNbr).collect(Collectors.toList());
return ResponseHelper.buildResponse(preparationMoneyServiceImpl.caculateShippingPriceByPowerHouseHoldIds(powerHouseholdIds));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/detail")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个发货单详情", notes = "根据sequenceNbr查询单个发货单详情")
public ResponseModel<PreparationMoneyDto> getObject(@RequestParam Long sequenceNbr) {
return ResponseHelper.buildResponse(preparationMoneyServiceImpl.getObjectBySequenceNbr(sequenceNbr));
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/updatePreparationMoneyStatus")
@ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新发货单", notes = "根据sequenceNbr更新发货单")
public ResponseModel<Boolean> updateBySequenceNbr(@RequestParam(value = "sequenceNbr") Long sequenceNbr, @RequestParam(value = "operationType") String operationType) {
return ResponseHelper.buildResponse(preparationMoneyServiceImpl.updatePreparationMoneyStatus(sequenceNbr, operationType));
}
} }
package com.yeejoin.amos.boot.module.hygf.biz.controller; package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qiyuesuo.sdk.v2.SdkClient; import com.qiyuesuo.sdk.v2.SdkClient;
import com.qiyuesuo.sdk.v2.bean.*; import com.qiyuesuo.sdk.v2.bean.*;
import com.qiyuesuo.sdk.v2.exception.BaseSdkException; import com.qiyuesuo.sdk.v2.exception.BaseSdkException;
...@@ -10,16 +11,19 @@ import com.qiyuesuo.sdk.v2.response.ContractListResult; ...@@ -10,16 +11,19 @@ import com.qiyuesuo.sdk.v2.response.ContractListResult;
import com.qiyuesuo.sdk.v2.response.DocumentAddResult; import com.qiyuesuo.sdk.v2.response.DocumentAddResult;
import com.qiyuesuo.sdk.v2.response.MiniappTicketResult; import com.qiyuesuo.sdk.v2.response.MiniappTicketResult;
import com.qiyuesuo.sdk.v2.response.SdkResponse; import com.qiyuesuo.sdk.v2.response.SdkResponse;
import com.yeejoin.amos.boot.module.hygf.api.dto.ContractDataDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.HouseholdContractDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract;
import com.yeejoin.amos.boot.module.hygf.api.entity.SealDictionary;
import com.yeejoin.amos.boot.module.hygf.api.mapper.SealDictionaryMapper;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.QiyuesuoServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.QiyuesuoServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
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;
...@@ -42,9 +46,12 @@ import java.util.Map; ...@@ -42,9 +46,12 @@ import java.util.Map;
public class QiyuesuoController { public class QiyuesuoController {
private static final Logger logger = LoggerFactory.getLogger(QiyuesuoController.class); private static final Logger logger = LoggerFactory.getLogger(QiyuesuoController.class);
@Autowired
SealDictionaryMapper sealDictionaryMapper;
@Autowired @Autowired
QiyuesuoServiceImpl qiyuesuoService; QiyuesuoServiceImpl qiyuesuoService;
@Autowired
HouseholdContractServiceImpl householdContractServiceImpl;
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "post",value = "个人token", notes = "个人token") @ApiOperation(httpMethod = "post",value = "个人token", notes = "个人token")
...@@ -65,10 +72,27 @@ public class QiyuesuoController { ...@@ -65,10 +72,27 @@ public class QiyuesuoController {
return ResponseHelper.buildResponse(result.getResult()); return ResponseHelper.buildResponse(result.getResult());
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "post",value = "合同token", notes = "合同token")
@PostMapping (value = "/getContractTokengz/{sequenceNbr}")
public ResponseModel<Object> getContractSdkResponseSequenceNbr(@RequestBody ContractMiniappTicketRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
QueryWrapper<SealDictionary> queryWrapper=new QueryWrapper();
queryWrapper.eq("amos_company_seq",sequenceNbr);
SealDictionary sealDictionary=sealDictionaryMapper.selectOne(queryWrapper);
request.setUser(new User( sealDictionary.getSealedPhone(), "MOBILE"));
SdkResponse<MiniappTicketResult> result= qiyuesuoService.getContractSdkResponse(request);
return ResponseHelper.buildResponse(result.getResult());
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "post",value = "创建合同", notes = "创建合同")
@PostMapping (value = "/addContract")
public ResponseModel<HouseholdContract> initiateHouseholdContract(@RequestBody HouseholdContractDto model) {
HouseholdContract householdContract=householdContractServiceImpl.initiateHouseholdContract(model);
return ResponseHelper.buildResponse(householdContract);
}
...@@ -100,6 +124,20 @@ public class QiyuesuoController { ...@@ -100,6 +124,20 @@ public class QiyuesuoController {
return ResponseHelper.buildResponse(qysResponse.getResult()); return ResponseHelper.buildResponse(qysResponse.getResult());
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "post",value = "创建合同", notes = "创建合同") @ApiOperation(httpMethod = "post",value = "创建合同", notes = "创建合同")
@PostMapping (value = "/getUnit2000") @PostMapping (value = "/getUnit2000")
...@@ -126,14 +164,14 @@ public class QiyuesuoController { ...@@ -126,14 +164,14 @@ public class QiyuesuoController {
contract.setCategory(new Category("智信能源合同")); contract.setCategory(new Category("智信能源合同"));
// contract.setBizId(""); // contract.setBizId("");
contract.setSend(false); contract.setSend(false);
// 个人 // 个人
Signatory signatory1 = new Signatory(); Signatory signatory1 = new Signatory();
signatory1.setTenantName(username); signatory1.setTenantName(username);
signatory1.setTenantType("PERSONAL"); signatory1.setTenantType("PERSONAL");
signatory1.setReceiver(new User(username, contact, "MOBILE")); signatory1.setReceiver(new User(username, contact, "MOBILE"));
signatory1.setSerialNo(1); signatory1.setSerialNo(1);
// 对接方 // 对接方
Signatory signatory2 = new Signatory(); Signatory signatory2 = new Signatory();
signatory2.setTenantName("智信能源科技有限公司-测试"); signatory2.setTenantName("智信能源科技有限公司-测试");
signatory2.setTenantType("COMPANY"); signatory2.setTenantType("COMPANY");
...@@ -141,15 +179,15 @@ public class QiyuesuoController { ...@@ -141,15 +179,15 @@ public class QiyuesuoController {
signatory2.setSerialNo(2); signatory2.setSerialNo(2);
Action action = new Action("COMPANY", 0); Action action = new Action("COMPANY", 0);
signatory2.addAction(action); signatory2.addAction(action);
// 设置签署方 // 设置签署方
contract.addSignatory(signatory1); contract.addSignatory(signatory1);
contract.addSignatory(signatory2); contract.addSignatory(signatory2);
// 创建合同 // 创建合同
ContractDraftRequest request = new ContractDraftRequest(contract); ContractDraftRequest request = new ContractDraftRequest(contract);
String response = sdkClient.service(request); String response = sdkClient.service(request);
SdkResponse<Contract> responseObj = JSONUtils.toQysResponse(response, Contract.class); SdkResponse<Contract> responseObj = JSONUtils.toQysResponse(response, Contract.class);
// 返回结果 // 返回结果
Contract result=new Contract(); Contract result=new Contract();
if(responseObj.getCode() == 0) { if(responseObj.getCode() == 0) {
result = responseObj.getResult(); result = responseObj.getResult();
......
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SealDictionaryServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.SealDictionaryDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
*
*
* @author system_generator
* @date 2023-08-23
*/
@RestController
@Api(tags = "Api")
@RequestMapping(value = "/seal-dictionary")
public class SealDictionaryController extends BaseController {
@Autowired
SealDictionaryServiceImpl sealDictionaryServiceImpl;
/**
* 新增
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增", notes = "新增")
public ResponseModel<SealDictionaryDto> save(@RequestBody SealDictionaryDto model) {
model = sealDictionaryServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<SealDictionaryDto> updateBySequenceNbrSealDictionary(@RequestBody SealDictionaryDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(sealDictionaryServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@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){
return ResponseHelper.buildResponse(sealDictionaryServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个", notes = "根据sequenceNbr查询单个")
public ResponseModel<SealDictionaryDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(sealDictionaryServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询")
public ResponseModel<Page<SealDictionaryDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
Page<SealDictionaryDto> page = new Page<SealDictionaryDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(sealDictionaryServiceImpl.queryForSealDictionaryPage(page));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<SealDictionaryDto>> selectForList() {
return ResponseHelper.buildResponse(sealDictionaryServiceImpl.queryForSealDictionaryList());
}
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.yeejoin.amos.boot.module.hygf.api.entity.ContractTemplate;
import com.yeejoin.amos.boot.module.hygf.api.mapper.ContractTemplateMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IContractTemplateService;
import com.yeejoin.amos.boot.module.hygf.api.dto.ContractTemplateDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* 服务实现类
*
* @author system_generator
* @date 2023-08-22
*/
@Service
public class ContractTemplateServiceImpl extends BaseService<ContractTemplateDto,ContractTemplate,ContractTemplateMapper> implements IContractTemplateService {
/**
* 分页查询
*/
public Page<ContractTemplateDto> queryForContractTemplatePage(Page<ContractTemplateDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<ContractTemplateDto> queryForContractTemplateList() {
return this.queryForList("num" , true);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.hygf.api.entity.DesignInformation;
import com.yeejoin.amos.boot.module.hygf.api.entity.DocumentBom; import com.yeejoin.amos.boot.module.hygf.api.entity.DocumentBom;
import com.yeejoin.amos.boot.module.hygf.api.mapper.DocumentBomMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.DocumentBomMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IDocumentBomService; import com.yeejoin.amos.boot.module.hygf.api.service.IDocumentBomService;
import com.yeejoin.amos.boot.module.hygf.api.dto.DocumentBomDto; import com.yeejoin.amos.boot.module.hygf.api.dto.DocumentBomDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* 发货单bom服务实现类 * 发货单bom服务实现类
...@@ -17,6 +31,15 @@ import java.util.List; ...@@ -17,6 +31,15 @@ import java.util.List;
*/ */
@Service @Service
public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentBom,DocumentBomMapper> implements IDocumentBomService { public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentBom,DocumentBomMapper> implements IDocumentBomService {
/**
* 折扣率
*/
private final static double DISCOUNT_RATE = 1;
@Autowired
DesignInformationServiceImpl designInformationService;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -30,4 +53,110 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB ...@@ -30,4 +53,110 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB
public List<DocumentBomDto> queryForDocumentBomList() { public List<DocumentBomDto> queryForDocumentBomList() {
return this.queryForList("" , false); return this.queryForList("" , false);
} }
/**
* 分页查询 By preparationMoneyId
*/
public Page<DocumentBomDto> queryForDocumentBomPage(Page<DocumentBomDto> page, Long preparationMoneyId) {
return this.queryForPage(page, null, false, preparationMoneyId);
}
/**
* 查询 By preparationMoneyId
*/
public List<DocumentBomDto> listByPreparationMoneyId(Long preparationMoneyId) {
return this.queryForList(null, false, preparationMoneyId);
}
/**
* 根据发货电站组装BOM清单数据
*
*
* @param powerHouseholdIds powerHouseholdIds
* @return {@link List< DocumentBom>}
* @author Provence
* @throws
*/
public List<DocumentBom> assembleDocumentBom(List<Long> powerHouseholdIds) {
// hygf_design_information
List<DesignInformation> designInformations = designInformationService.query().in("peasant_household_id", powerHouseholdIds).list();
// [{"wlbm":"1","Symbol_key":"B1F7FEE3-9377-4A42-81FB-DEB8775EF67C","wlmc":"1","dcpgg":"1"}]
// 组件-assembly, 逆变器-inverter,电表箱-electricity_meter 根据物料编码 分组
List<DocumentBom> documentBoms = new ArrayList<>();
for (DesignInformation designInformation : designInformations) {
documentBoms.addAll(convertBom(designInformation.getAssembly(), "assembly"));
documentBoms.addAll(convertBom(designInformation.getInverter(), "inverter"));
documentBoms.addAll(convertBom(designInformation.getElectricityMeter(), "electricityMeter"));
}
// 根据物料编码 分组
return documentBoms.stream().collect(Collectors.groupingBy(DocumentBom::getMaterialNum)).values().stream()
.flatMap(list -> Stream.of(list.stream().reduce((o1, o2) -> {
o1.setDemandNumber(o1.getDemandNumber() + o2.getDemandNumber());
o1.setDiscountTotal(caculateDiscountTotal(o1).add(caculateDiscountTotal(o2)).doubleValue());
o1.setDiscountUnitPrice(caculateDiscountUnitPrice(o1).add(caculateDiscountUnitPrice(o2)).doubleValue());
return o1;
}).orElse(null)).filter(Objects::nonNull)).collect(Collectors.toList());
}
private BigDecimal caculateTotal(DocumentBom o1) {
return new BigDecimal(o1.getDemandNumber()).multiply(new BigDecimal(o1.getUnitPrice()));
}
private BigDecimal caculateDiscountTotal(DocumentBom o1) {
// 折扣总额 = 总价 - 折扣总价
return caculateTotal(o1).subtract(new BigDecimal(o1.getDemandNumber()).multiply(caculateDiscountUnitPrice(o1)));
}
private BigDecimal caculateDiscountUnitPrice(DocumentBom o1) {
// 折扣后单价 = 单价 * 折扣率
return new BigDecimal(o1.getUnitPrice()).multiply(new BigDecimal(DISCOUNT_RATE));
}
/**
* 设计信息内的组件-assembly, 逆变器-inverter,电表箱-electricity_meter json转成bom清单对象
*
*
* @param objects objects
* @param materialType materialType
* @return {@link List< DocumentBom>}
* @author Provence
* @throws
*/
private List<DocumentBom> convertBom(List<Object> objects, String materialType) {
if (CollectionUtils.isEmpty(objects)) {
return Collections.EMPTY_LIST;
}
List<DocumentBom> documentBoms = new ArrayList<>();
JSONArray jsonArray = JSONArray.parseArray(objects.toString());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject json = jsonArray.getJSONObject(i);
documentBoms.add(parseDocumentBom(json));
}
return documentBoms;
}
private DocumentBom parseDocumentBom(JSONObject json) {
DocumentBom documentBom = new DocumentBom();
String materialNum = json.getString("wlbm");//物料编码
String materialName = json.getString("wlmc");//物料名称
Integer demandNumber = json.getInteger("pzsl");//配置数量
Double price = json.getDouble("price");//价格
if (StringUtils.isAnyBlank(materialNum, materialName)) {
throw new RuntimeException("物料编码和物料名称不能为空");
}
if (null == demandNumber || null == price) {
throw new RuntimeException("价格和配置数量不能为空");
}
Double power = Double.valueOf(Optional.ofNullable(json.getString("gl")).orElse("0").replace("W", ""));// 去掉功率的单位
documentBom.setMaterialNum(materialNum);//物料编码
documentBom.setMaterialName(materialName);//物料名称
documentBom.setUnitPrice(price);
documentBom.setDemandNumber(demandNumber);
documentBom.setPower(power);
/*
类型和分组目前没有该字段
documentBom.setMaterialType(materialType);
documentBom.setMaterialGroup();*/
return documentBom;
}
} }
\ No newline at end of file
...@@ -3,20 +3,27 @@ package com.yeejoin.amos.boot.module.hygf.biz.service.impl; ...@@ -3,20 +3,27 @@ package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.hygf.api.Enum.HouseholdContractEnum; import com.yeejoin.amos.boot.module.hygf.api.Enum.HouseholdContractEnum;
import com.yeejoin.amos.boot.module.hygf.api.dto.HouseholdContractPageDto; import com.yeejoin.amos.boot.module.hygf.api.dto.*;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationPageDto; import com.yeejoin.amos.boot.module.hygf.api.entity.ContractTemplate;
import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract; import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney; import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney;
import com.yeejoin.amos.boot.module.hygf.api.entity.SealDictionary;
import com.yeejoin.amos.boot.module.hygf.api.mapper.ContractTemplateMapper;
import com.yeejoin.amos.boot.module.hygf.api.mapper.HouseholdContractMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.HouseholdContractMapper;
import com.yeejoin.amos.boot.module.hygf.api.mapper.SealDictionaryMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IHouseholdContractService; import com.yeejoin.amos.boot.module.hygf.api.service.IHouseholdContractService;
import com.yeejoin.amos.boot.module.hygf.api.dto.HouseholdContractDto;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.Period;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -32,6 +39,16 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD ...@@ -32,6 +39,16 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD
@Autowired @Autowired
HouseholdContractMapper householdContractMapper; HouseholdContractMapper householdContractMapper;
@Autowired
QiyuesuoServiceImpl qiyuesuoServiceImpl;
@Autowired
SealDictionaryMapper sealDictionaryMapper;
@Autowired
ContractTemplateMapper contractTemplateMapper;
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
...@@ -55,6 +72,9 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD ...@@ -55,6 +72,9 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD
qw.eq(StringUtils.isNotEmpty(dto.getInitiateStatus()), "initiate_status",dto.getInitiateStatus() ); qw.eq(StringUtils.isNotEmpty(dto.getInitiateStatus()), "initiate_status",dto.getInitiateStatus() );
qw.eq(StringUtils.isNotEmpty(dto.getSurveyStatus()), "survey_status",dto.getSurveyStatus() ); qw.eq(StringUtils.isNotEmpty(dto.getSurveyStatus()), "survey_status",dto.getSurveyStatus() );
qw.eq(StringUtils.isNotEmpty(dto.getSignStatus()), "sign_status",dto.getSignStatus() ); qw.eq(StringUtils.isNotEmpty(dto.getSignStatus()), "sign_status",dto.getSignStatus() );
qw.eq(StringUtils.isNotEmpty(dto.getUserId()), "user_id",dto.getUserId() );
if (StringUtils.isNotEmpty(dto.getOrderBy())) { if (StringUtils.isNotEmpty(dto.getOrderBy())) {
qw.orderBy(Boolean.TRUE, dto.getIsASC(), dto.getOrderBy()); qw.orderBy(Boolean.TRUE, dto.getIsASC(), dto.getOrderBy());
...@@ -79,6 +99,7 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD ...@@ -79,6 +99,7 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD
householdContractMapper.insert(householdContract); householdContractMapper.insert(householdContract);
} }
public String getnum() { public String getnum() {
SimpleDateFormat format = new SimpleDateFormat("YYYYMMddHHmmssSSS"); SimpleDateFormat format = new SimpleDateFormat("YYYYMMddHHmmssSSS");
Date date = new Date(); Date date = new Date();
...@@ -87,4 +108,152 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD ...@@ -87,4 +108,152 @@ public class HouseholdContractServiceImpl extends BaseService<HouseholdContractD
} }
public HouseholdContract initiateHouseholdContract(HouseholdContractDto model){
HouseholdContract householdContract= householdContractMapper.selectById(model.getSequenceNbr());
householdContract.setPartyA(model.getPartyA());
householdContract.setPartyB(model.getPartyB());
householdContract.setContractTemplateId(model.getContractTemplateId());
householdContract.setRentFree(model.getRentFree());
householdContract.setRentCalculationDate(model.getRentCalculationDate());
householdContract.setLeaseEndDate(model.getLeaseEndDate());
householdContract.setConstructionScale(model.getConstructionScale());
householdContract.setComponentQuantityBlock(model.getComponentQuantityBlock());
householdContract.setTotalInvestment(model.getTotalInvestment());
householdContract.setComponentPower(model.getComponentPower());
householdContract.setStationPower(model.getStationPower());
householdContract.setName(model.getName());
//调用第三方
ContractDataDto contractDataDto =new ContractDataDto();
contractDataDto.setUsername(model.getPartyA());
contractDataDto.setContact(model.getPeasantHouseholdPhone());
contractDataDto.setIDCard(model.getPeasantHouseholdCard());
contractDataDto.setSubject(model.getName());
QueryWrapper<SealDictionary> queryWrapper=new QueryWrapper();
queryWrapper.eq("amos_company_seq",householdContract.getRegionalCompaniesSeq());
SealDictionary sealDictionary=sealDictionaryMapper.selectOne(queryWrapper);
contractDataDto.setCategory(sealDictionary.getCategory());
contractDataDto.setCompanyTenantName(sealDictionary.getCompanyTenantName());
contractDataDto.setCompanyUsername(sealDictionary.getSealedUser());
contractDataDto.setCompanyContact(sealDictionary.getSealedPhone());
List<Long> listSealId= new ArrayList<>();
listSealId.add(sealDictionary.getSealId());
contractDataDto.setSealId(listSealId);
QueryWrapper<ContractTemplate> qu=new QueryWrapper();
qu.eq("template_id",model.getContractTemplateId());
ContractTemplate contractTemplate=contractTemplateMapper.selectOne(qu);
contractDataDto.setEmplateId(model.getContractTemplateId());
contractDataDto.setCompanykeyword(contractTemplate.getCompanyKeyword());
contractDataDto.setCompanyPage(contractTemplate.getCompanyPage());
contractDataDto.setCompanyOffsetX(contractTemplate.getCompanyOffsetx());
contractDataDto.setCompanyOffsetY(contractTemplate.getCompanyOffsety());
contractDataDto.setCompanyKeywordIndex(contractTemplate.getCompanyKeywordIndex());
contractDataDto.setPersonalkeyword(contractTemplate.getPersonalKeyword());
contractDataDto.setPersonalPage(contractTemplate.getPersonalPage());
contractDataDto.setPersonalOffsetX(contractTemplate.getPersonalOffsetx());
contractDataDto.setPersonalOffsetY(contractTemplate.getPersonalOffsety());
contractDataDto.setPersonalKeywordIndex(contractTemplate.getPersonalKeywordIndex());
List<TemplateParamDto> templateParam=new ArrayList<>();
SimpleDateFormat sdfdate = new SimpleDateFormat("yyyy-MM-dd");
templateParam.add(new TemplateParamDto("partyA",householdContract.getPartyA()!=null?householdContract.getPartyA():null));
templateParam.add(new TemplateParamDto("peasantHouseholdPhone",householdContract.getPeasantHouseholdPhone()!=null?householdContract.getPeasantHouseholdPhone():null));
templateParam.add(new TemplateParamDto("rentFree",householdContract.getRentFree()!=null?sdfdate.format(householdContract.getRentFree()):null));
templateParam.add(new TemplateParamDto("rentCalculationDate",householdContract.getRentCalculationDate()!=null?sdfdate.format(householdContract.getRentCalculationDate()):null));
templateParam.add(new TemplateParamDto("leaseEndDate",householdContract.getLeaseEndDate()!=null?sdfdate.format(householdContract.getLeaseEndDate()):null));
templateParam.add(new TemplateParamDto("constructionScale",householdContract.getConstructionScale()!=null?String.valueOf(householdContract.getConstructionScale()):null));
templateParam.add(new TemplateParamDto("componentQuantityBlock",householdContract.getComponentQuantityBlock()!=null?String.valueOf(householdContract.getComponentQuantityBlock()):null));
templateParam.add(new TemplateParamDto("totalInvestment",householdContract.getTotalInvestment()!=null?String.valueOf(householdContract.getTotalInvestment()):null));
templateParam.add(new TemplateParamDto("peasantHouseholdCard",householdContract.getPeasantHouseholdCard()!=null?householdContract.getPeasantHouseholdCard():null));
templateParam.add(new TemplateParamDto("permanentAddressDetail",householdContract.getPermanentAddressName()!=null?householdContract.getPermanentAddressName()+householdContract.getPermanentAddressDetail():null));
templateParam.add(new TemplateParamDto("projectAddressDetail",householdContract.getProjectAddressName()!=null?householdContract.getProjectAddressName()+householdContract.getProjectAddressDetail():null));
templateParam.add(new TemplateParamDto("componentPower",householdContract.getComponentPower()!=null?String.valueOf(householdContract.getComponentPower()):null));
templateParam.add(new TemplateParamDto("stationPower",householdContract.getStationPower()!=null?String.valueOf(householdContract.getStationPower()):null));
Long contractLockId=qiyuesuoServiceImpl.addContract(contractDataDto , templateParam);
householdContract.setContractLockId(contractLockId);
householdContract.setInitiateStatus(HouseholdContractEnum.发起状态_已发起.getCode());
householdContractMapper.updateById(householdContract);
return householdContract;
}
public HouseholdContract reissueinitiateHouseholdContract(HouseholdContract model,Long sequenceNbr){
HouseholdContract householdContract= householdContractMapper.selectById(sequenceNbr);
householdContract.setPartyA(model.getPartyA());
householdContract.setPartyB(model.getPartyB());
householdContract.setContractTemplateId(model.getContractTemplateId());
householdContract.setRentFree(model.getRentFree());
householdContract.setRentCalculationDate(model.getRentCalculationDate());
householdContract.setLeaseEndDate(model.getLeaseEndDate());
householdContract.setConstructionScale(model.getConstructionScale());
householdContract.setComponentQuantityBlock(model.getComponentQuantityBlock());
householdContract.setTotalInvestment(model.getTotalInvestment());
householdContract.setComponentPower(model.getComponentPower());
householdContract.setStationPower(model.getStationPower());
householdContract.setName(model.getName());
ContractDataDto contractDataDto =new ContractDataDto();
contractDataDto.setUsername(model.getPartyA());
contractDataDto.setContact(model.getPeasantHouseholdPhone());
contractDataDto.setIDCard(model.getPeasantHouseholdCard());
contractDataDto.setSubject(model.getName());
QueryWrapper<SealDictionary> queryWrapper=new QueryWrapper();
queryWrapper.eq("amos_company_seq",householdContract.getRegionalCompaniesSeq());
SealDictionary sealDictionary=sealDictionaryMapper.selectOne(queryWrapper);
contractDataDto.setCategory(sealDictionary.getCategory());
contractDataDto.setCompanyTenantName(sealDictionary.getCompanyTenantName());
contractDataDto.setCompanyUsername(sealDictionary.getSealedUser());
contractDataDto.setCompanyContact(sealDictionary.getSealedPhone());
List<Long> listSealId= new ArrayList<>();
listSealId.add(sealDictionary.getSealId());
contractDataDto.setSealId(listSealId);
QueryWrapper<ContractTemplate> qu=new QueryWrapper();
qu.eq("template_id",model.getContractTemplateId());
ContractTemplate contractTemplate=contractTemplateMapper.selectOne(qu);
contractDataDto.setEmplateId(model.getContractTemplateId());
contractDataDto.setCompanykeyword(contractTemplate.getCompanyKeyword());
contractDataDto.setCompanyPage(contractTemplate.getCompanyPage());
contractDataDto.setCompanyOffsetX(contractTemplate.getCompanyOffsetx());
contractDataDto.setCompanyOffsetY(contractTemplate.getCompanyOffsety());
contractDataDto.setCompanyKeywordIndex(contractTemplate.getCompanyKeywordIndex());
contractDataDto.setPersonalkeyword(contractTemplate.getPersonalKeyword());
contractDataDto.setPersonalPage(contractTemplate.getPersonalPage());
contractDataDto.setPersonalOffsetX(contractTemplate.getPersonalOffsetx());
contractDataDto.setPersonalOffsetY(contractTemplate.getPersonalOffsety());
contractDataDto.setPersonalKeywordIndex(contractTemplate.getPersonalKeywordIndex());
List<TemplateParamDto> templateParam=new ArrayList<>();
SimpleDateFormat sdfdate = new SimpleDateFormat("yyyy-MM-dd");
templateParam.add(new TemplateParamDto("partyA",householdContract.getPartyA()!=null?householdContract.getPartyA():null));
templateParam.add(new TemplateParamDto("peasantHouseholdPhone",householdContract.getPeasantHouseholdPhone()!=null?householdContract.getPeasantHouseholdPhone():null));
templateParam.add(new TemplateParamDto("rentFree",householdContract.getRentFree()!=null?sdfdate.format(householdContract.getRentFree()):null));
templateParam.add(new TemplateParamDto("rentCalculationDate",householdContract.getRentCalculationDate()!=null?sdfdate.format(householdContract.getRentCalculationDate()):null));
templateParam.add(new TemplateParamDto("leaseEndDate",householdContract.getLeaseEndDate()!=null?sdfdate.format(householdContract.getLeaseEndDate()):null));
templateParam.add(new TemplateParamDto("constructionScale",householdContract.getConstructionScale()!=null?String.valueOf(householdContract.getConstructionScale()):null));
templateParam.add(new TemplateParamDto("componentQuantityBlock",householdContract.getComponentQuantityBlock()!=null?String.valueOf(householdContract.getComponentQuantityBlock()):null));
templateParam.add(new TemplateParamDto("totalInvestment",householdContract.getTotalInvestment()!=null?String.valueOf(householdContract.getTotalInvestment()):null));
templateParam.add(new TemplateParamDto("peasantHouseholdCard",householdContract.getPeasantHouseholdCard()!=null?householdContract.getPeasantHouseholdCard():null));
templateParam.add(new TemplateParamDto("permanentAddressDetail",householdContract.getPermanentAddressName()!=null?householdContract.getPermanentAddressName()+householdContract.getPermanentAddressDetail():null));
templateParam.add(new TemplateParamDto("projectAddressDetail",householdContract.getProjectAddressName()!=null?householdContract.getProjectAddressName()+householdContract.getProjectAddressDetail():null));
templateParam.add(new TemplateParamDto("componentPower",householdContract.getComponentPower()!=null?String.valueOf(householdContract.getComponentPower()):null));
templateParam.add(new TemplateParamDto("stationPower",householdContract.getStationPower()!=null?String.valueOf(householdContract.getStationPower()):null));
Long contractLockId=qiyuesuoServiceImpl.addContract(contractDataDto , templateParam);
householdContract.setContractLockId(contractLockId);
householdContract.setInitiateStatus(HouseholdContractEnum.发起状态_已发起.getCode());
householdContractMapper.updateById(householdContract);
return householdContract;
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.Enum.PhoneRegisterTypeEum;
import com.yeejoin.amos.boot.module.hygf.api.dto.MobileLoginParamDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdWxDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.SurveyInformationDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.Commercial; import com.yeejoin.amos.boot.module.hygf.api.entity.Commercial;
import com.yeejoin.amos.boot.module.hygf.api.entity.ExtendedInformation; import com.yeejoin.amos.boot.module.hygf.api.entity.ExtendedInformation;
import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract;
import com.yeejoin.amos.boot.module.hygf.api.entity.Information; import com.yeejoin.amos.boot.module.hygf.api.entity.Information;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold; import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.entity.SurveyDetails; import com.yeejoin.amos.boot.module.hygf.api.entity.SurveyDetails;
import com.yeejoin.amos.boot.module.hygf.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PeasantHouseholdMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.PeasantHouseholdMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IPeasantHouseholdService; import com.yeejoin.amos.boot.module.hygf.api.service.IPeasantHouseholdService;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.service.IUnitInfoService;
import com.yeejoin.amos.boot.module.hygf.api.service.IWxService;
import com.yeejoin.amos.boot.module.jxiop.api.util.HttpUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.feign.privilege.model.LoginInfoModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.privilege.model.VerifyCodeAuthModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition; import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator; import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -28,8 +78,50 @@ import java.util.stream.Collectors; ...@@ -28,8 +78,50 @@ import java.util.stream.Collectors;
* @date 2023-07-07 * @date 2023-07-07
*/ */
@Service @Service
@Slf4j
public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto,PeasantHousehold,PeasantHouseholdMapper> implements IPeasantHouseholdService { public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto,PeasantHousehold,PeasantHouseholdMapper> implements IPeasantHouseholdService {
private Long TOKEN_TIME = 1209600l;
@Value("${amos.system.user.product}")
private String product;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${login.environment}")
private String loginEnvironment;
@Value("${farmer.orgCode}")
private String orgCode;
@Value("${farmer.sequenceNbr}")
private Long orgSequenceNbr;
@Value("${farmer.orgNamesWithoutRole:智信能源科技有限公司}")
private String orgNamesWithoutRole;
@Value("${dealer.appcode}")
private String appCodes;
@Value("${platform.access.loginId}")
private String platfromAccessLoginId;
@Value("${platform.access.password}")
private String platfromAccessPassword;
@Value("${farmer.roleId:1678211468450885633}")
private String farmerRoleId;
@Value("${farmer.registerPassword}")
private String registerPassword;
@Autowired
private RedisUtils redisUtils;
@Autowired
private IWxService wxService;
@Autowired @Autowired
SurveyInformationServiceImpl surveyInformationService; SurveyInformationServiceImpl surveyInformationService;
...@@ -45,6 +137,57 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto ...@@ -45,6 +137,57 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
@Autowired @Autowired
CommercialServiceImpl commercialService; CommercialServiceImpl commercialService;
@Autowired
SurveyInformationServiceImpl surveyInformationServiceImpl;
@Autowired
HouseholdContractServiceImpl householdContractServiceImpl;
@Autowired
UnitInfoServiceImpl unitInfoServiceImpl;
@Autowired
AmosRequestContext requestContext;
public static final String SECRETKEY = "qaz";
@Transactional (rollbackFor = Exception.class)
public PeasantHouseholdDto savePeasantHousehold(PeasantHouseholdDto model) {
SurveyInformationDto surveyInformationDto = new SurveyInformationDto();
surveyInformationServiceImpl.createWithModel(surveyInformationDto);
model.setSurveyInformationId(surveyInformationDto.getSequenceNbr());
model.setSurveyOrNot(0);
model.setReview(0);
if (model.getCreationTime() == null) {
model.setCreationTime(new Date());
}
model.setPeasantHouseholdNo(this.getPeasantHouseholdNo());
model.setIsCertified(model.getIsCertified() == null ? 0 : model.getIsCertified());// 未认证
PeasantHouseholdDto peasantHousehold= this.createWithModel(model);
//生成合同
HouseholdContract householdContract=new HouseholdContract();
householdContract.setPartyA(peasantHousehold.getOwnersName());
householdContract.setPeasantHouseholdNumber(peasantHousehold.getPeasantHouseholdNo());
householdContract.setPeasantHouseholdCard(peasantHousehold.getIdCard());
householdContract.setDealerId(peasantHousehold.getDeveloperId());
householdContract.setDealerCode(peasantHousehold.getDeveloperCode());
householdContract.setDealerName(peasantHousehold.getDeveloperName());
householdContract.setPeasantHouseholdId(peasantHousehold.getSequenceNbr());
householdContract.setRegionalCompaniesCode(peasantHousehold.getRegionalCompaniesCode());
householdContract.setRegionalCompaniesName(peasantHousehold.getRegionalCompaniesName());
householdContract.setRegionalCompaniesSeq(peasantHousehold.getRegionalCompaniesSeq());
householdContract.setPeasantHouseholdPhone(peasantHousehold.getTelephone());
householdContract.setProjectAddressDetail(peasantHousehold.getProjectAddressDetail());
householdContract.setProjectAddressName(peasantHousehold.getProjectAddressName());
householdContract.setPermanentAddressDetail(peasantHousehold.getPermanentAddressDetail());
householdContract.setPermanentAddressName(peasantHousehold.getPermanentAddressName());
householdContract.setUserId(peasantHousehold.getUserId());
householdContractServiceImpl.addHouseholdContract(householdContract);
return peasantHousehold;
}
public boolean deletePeasantHouseholdBySequenceNbr(Long sequenceNbr){ public boolean deletePeasantHouseholdBySequenceNbr(Long sequenceNbr){
PeasantHouseholdDto peasantHouseholdDto = this.queryBySeq(sequenceNbr); PeasantHouseholdDto peasantHouseholdDto = this.queryBySeq(sequenceNbr);
Long surveyInformationId = peasantHouseholdDto.getSurveyInformationId(); Long surveyInformationId = peasantHouseholdDto.getSurveyInformationId();
...@@ -73,8 +216,8 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto ...@@ -73,8 +216,8 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
/** /**
* 分页查询 * 分页查询
*/ */
public Page<PeasantHouseholdDto> queryForPeasantHouseholdPage(Page<PeasantHouseholdDto> page,String developerCode,@Condition(Operator.like) String ownersName) { public Page<PeasantHouseholdDto> queryForPeasantHouseholdPage(Page<PeasantHouseholdDto> page,String developerCode,@Condition(Operator.like) String ownersName,Long developerId) {
Page<PeasantHouseholdDto> peasantHouseholdDtoPage = this.queryForPage(page, "rec_date", false,developerCode,ownersName); Page<PeasantHouseholdDto> peasantHouseholdDtoPage = this.queryForPage(page, "rec_date", false,developerCode,ownersName,developerId);
List<PeasantHouseholdDto> records = peasantHouseholdDtoPage.getRecords(); List<PeasantHouseholdDto> records = peasantHouseholdDtoPage.getRecords();
List<PeasantHouseholdDto> newRecords = records.stream().map(item -> { List<PeasantHouseholdDto> newRecords = records.stream().map(item -> {
if(item.getSurveyOrNot() != null){ if(item.getSurveyOrNot() != null){
...@@ -109,4 +252,373 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto ...@@ -109,4 +252,373 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
public List<PeasantHouseholdDto> queryForPeasantHouseholdList() { public List<PeasantHouseholdDto> queryForPeasantHouseholdList() {
return this.queryForList("" , false); return this.queryForList("" , false);
} }
public Boolean doAuthenticate(Long sequenceNbr) {
// 判断是否注册过
PeasantHousehold peasantHousehold = this.getById(sequenceNbr);
if (null == peasantHousehold) {
throw new BadRequest("认证失败, 农户信息不存在");
}
peasantHousehold.setIsCertified(1);// 认证
return this.updateById(peasantHousehold);
}
public PeasantHouseholdWxDto wxUserLogin(MobileLoginParamDto wxDTO) {
// 通过手机号和验证码调用平台接口进行验证
String phoneNo = this.parsePhoneNo(wxDTO);
if (phoneNo == null) {
throw new BadRequest("获取手机号失败!");
}
log.info("用户手机号码 => {} 开始登录", phoneNo);
wxDTO.setPhoneNo(phoneNo);
//
RequestContext.setAppKey("AMOS_STUDIO");
RequestContext.setProduct("AMOS_STUDIO_WEB");
RequestContext.setToken(requestContext.getToken());
AgencyUserModel registerUserModel = null;
// 判断有无在平台内部注册过用户
FeignClientResult<LoginInfoModel> loginInfo = Privilege.agencyUserClient.getLoginInfo(phoneNo);
if (loginInfo != null && 200 == loginInfo.getStatus()) {
LoginInfoModel loginInfoModel = loginInfo.getResult();
if (loginInfoModel == null || !StringUtils.isNotBlank(loginInfoModel.getLoginId())) {
// 没有认证过, 去注册用户
FeignClientResult<AgencyUserModel> registerUserModelRestult = doRegister(wxDTO);
if (registerUserModelRestult != null && registerUserModelRestult.getStatus() != 200) {
log.error("调用平台创建用户信息失败:{}" + registerUserModelRestult.getDevMessage());
throw new BadRequest(registerUserModelRestult.getMessage());
}
registerUserModel = registerUserModelRestult.getResult();
}
}
// 登录
PeasantHouseholdWxDto loginResult = doLogin(wxDTO, registerUserModel);
// 判断是否注册过
List<PeasantHousehold> peasantHouseholds = this.query().eq("telephone", phoneNo).orderByDesc("rec_date").list();
PeasantHousehold peasantHousehold = peasantHouseholds.size() > 0 ? peasantHouseholds.get(0) : null;
// 没有注册过农户信息
if (null == peasantHousehold) {
peasantHousehold = new PeasantHousehold();
peasantHousehold.setIsCertified(0);
peasantHousehold.setSurveyOrNot(0);
peasantHousehold.setReview(0);
peasantHousehold.setTelephone(phoneNo);
PeasantHouseholdDto peasantHouseholdDto = buildDefaultPeasantHouseholdDto(wxDTO.getUserId(), wxDTO.getQrCodeType(), phoneNo);
peasantHousehold.setDeveloperCode(peasantHouseholdDto.getDeveloperCode());// 开发方code
peasantHousehold.setDeveloperId(peasantHouseholdDto.getDeveloperId());// 开发方id
peasantHousehold.setDeveloperName(peasantHouseholdDto.getDeveloperName());// 开发方名称
peasantHousehold.setDeveloper(peasantHouseholdDto.getDeveloper());// 开发人
peasantHousehold.setRegionalCompaniesSeq(peasantHouseholdDto.getRegionalCompaniesSeq());
peasantHousehold.setRegionalCompaniesCode(peasantHouseholdDto.getRegionalCompaniesCode());
peasantHousehold.setRegionalCompaniesName(peasantHouseholdDto.getRegionalCompaniesName());
// 过滤传给前端的数据
}
log.info("返回给前端数据, 手机号码 => {}, 农户信息 => {}", phoneNo, peasantHousehold);
// 装载农户信息
loginResult.setPeasantHousehold(peasantHousehold);
return loginResult;
}
/**
* 农户微信注册
*
*
* @param mobileLoginParamDto mobileLoginParamDto
* @return {@link AgencyUserModel}
* @author Provence
* @throws
* @date 2023/8/21 18:05
*/
public FeignClientResult<AgencyUserModel> doRegister(MobileLoginParamDto mobileLoginParamDto) {
CompanyModel companyInfo = new CompanyModel();
companyInfo.setSequenceNbr(orgSequenceNbr);
companyInfo.setCompanyOrgCode(Integer.valueOf(orgCode));
RoleModel allRoleList = null;
FeignClientResult<RoleModel> roleListResult = Privilege.roleClient.seleteOne(Long.valueOf(farmerRoleId));
if (roleListResult != null && roleListResult.getStatus() == 200) {
allRoleList = roleListResult.getResult();
}
List<RoleModel> userRoleList = new ArrayList<>();
List<String> split = Arrays.asList(StringUtils.split(appCodes, ','));
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
// 提前建立好一个默认角色
List<Long> roleIds = new ArrayList<>();
userRoleList.add(allRoleList);
roleIds.add(Long.valueOf(farmerRoleId));
roleSeqMap.put(companyInfo.getSequenceNbr(), roleIds);
orgRoles.put(companyInfo.getSequenceNbr(), userRoleList);
// 初始默认密码 a1234560
String custPassword = com.yeejoin.precontrol.common.utils.DesUtil.encode(registerPassword, SECRETKEY);
AgencyUserModel agencyUserModel = new AgencyUserModel();
agencyUserModel.setUserName(mobileLoginParamDto.getPhoneNo());
agencyUserModel.setRealName(mobileLoginParamDto.getPhoneNo());
agencyUserModel.setPassword(custPassword);
agencyUserModel.setRePassword(custPassword);
agencyUserModel.setLockStatus("UNLOCK");
agencyUserModel.setAgencyCode("JXIOP");
agencyUserModel.setMobile(mobileLoginParamDto.getPhoneNo());
agencyUserModel.setAppCodes(split);
agencyUserModel.setOrgRoles(orgRoles);
agencyUserModel.setOrgRoleSeqs(roleSeqMap);
log.debug("注册用户入参, agencyUserModel => {}", agencyUserModel);
FeignClientResult<AgencyUserModel> agencyUserResult = Privilege.agencyUserClient.create(agencyUserModel);
try {
FeignClientResult<LoginInfoModel> wechatResult = Privilege.agencyUserClient.createWechatLoginInfo(agencyUserResult.getResult());
log.info("wechatResult:{}", wechatResult);
} catch (Exception e) {
e.printStackTrace();
}
/* agencyUserModel.setOpenId("openid");
agencyUserModel.setVerifyCode(com.yeejoin.precontrol.common.utils.DesUtil.encode(mobileLoginParamDto.getPhoneNo(), SECRETKEY));
FeignClientResult<AgencyUserModel> wechatResult = Privilege.agencyUserClient.wechatRegister(agencyUserModel);*/
return agencyUserResult;
}
/**
* 农户微信登录
*
*
* @param param param
* @return {@link PeasantHouseholdWxDto}
* @author Provence
* @throws
* @date 2023/8/21 18:05
*/
public PeasantHouseholdWxDto doLogin(MobileLoginParamDto param, AgencyUserModel registerUserModel) {
RequestContext.setToken("");
RequestContext.setProduct("STUDIO_APP_MOBILE");
RequestContext.setAppKey("studio_normalapp_5133538");
String phoneNo = param.getPhoneNo();
if (phoneNo == null) {
throw new BadRequest("获取手机号失败!");
}
FeignClientResult loginResult;
if (!param.getIsNeedVerify() || ("dev".equals(loginEnvironment) && "666666".equals(param.getVerifyCode()))) {
// 授权登录
VerifyCodeAuthModel verifyCodeAuthModel = new VerifyCodeAuthModel();
verifyCodeAuthModel.setLoginId(phoneNo);
verifyCodeAuthModel.setVerifyCode(com.yeejoin.precontrol.common.utils.DesUtil.encode(phoneNo, SECRETKEY));// 手机号码 + 密码言
log.info("微信登录入参 => {}", verifyCodeAuthModel);
loginResult = Privilege.authClient.Wechat(verifyCodeAuthModel);
/* IdPasswordAuthModel authModel = new IdPasswordAuthModel();
authModel.setLoginId(phoneNo);
authModel.setPassword(com.yeejoin.precontrol.common.utils.DesUtil.encode(registerPassword, SECRETKEY));
loginResult = Privilege.authClient.idpassword(authModel);*/
} else {
// 验证码
VerifyCodeAuthModel model = new VerifyCodeAuthModel();
model.setLoginId(phoneNo);
model.setVerifyCode(param.getVerifyCode());
loginResult = Privilege.authClient.mobileVerifyCode(model);
}
if (loginResult == null || loginResult.getStatus() != 200) {
log.error("远程调用Privilege服务失败: " + loginResult.getDevMessage());
String message = StringUtils.isEmpty(loginResult.getMessage()) ? "账号或密码错误" : loginResult.getMessage();
throw new BadRequest(message);
}
HashMap resultMap = (HashMap) loginResult.getResult();
String token = resultMap.get("token").toString();
RequestContext.setToken(token);
// redisUtils.set(model.getPhone() + "_token", token, TOKEN_TIME);
// 设置登录信息
String userId = (String) resultMap.get("userId");
PeasantHouseholdWxDto peasantHouseholdWxDto = new PeasantHouseholdWxDto();
peasantHouseholdWxDto.setExpire(Long.valueOf((String) resultMap.get("expire")));
peasantHouseholdWxDto.setUserId(userId);
// 判断用户是否刚刚注册过
AgencyUserModel userModel;
/*if (registerUserModel != null) {
// 使用注册接口返回的用户信息
userModel = registerUserModel;
} else {
// 查询用户信息
FeignClientResult<AgencyUserModel> getme = Privilege.agencyUserClient.queryByUserId(userId);
*//*FeignClientResult<AgencyUserModel> getme = Privilege.agencyUserClient.getme();*//*
if (null == getme || getme.getStatus() != 200) {
throw new BadRequest("获取用户信息失败");
}
userModel = (AgencyUserModel) getme.getResult();
}*/
FeignClientResult<AgencyUserModel> getme = Privilege.agencyUserClient.queryByUserId(userId);
if (null == getme || getme.getStatus() != 200) {
throw new BadRequest("获取用户信息失败");
}
userModel = (AgencyUserModel) getme.getResult();
// 组装userInfo数据
Map<String, Object> userInfo = new HashMap<>();
userInfo.put("realName", userModel.getRealName());
userInfo.put("mobile", userModel.getMobile());
userInfo.put("orgNames", userModel.getOrgNames());
userInfo.put("orgNamesWithoutRole", userModel.getOrgNamesWithoutRole());
// userInfo.put("phoneNo", phoneNo);
// userInfo.put("companyId", userModel.getCompanys().get(0).getCompanyOrgCode());
//
// userInfo.put("userModel", userModel);
peasantHouseholdWxDto.setUserInfo(userInfo);
// 组装authInfo数据
Map<String, Object> authInfo = new HashMap<>();
authInfo.put("token", resultMap.get("token"));
authInfo.put("personId", resultMap.get("userId"));
authInfo.put("appKey", "STUDIO_APP_MOBILE");
authInfo.put("product", "studio_normalapp_5133538");
peasantHouseholdWxDto.setAuthInfo(authInfo);
return peasantHouseholdWxDto;
}
/**
* 通过区域/个人二维码扫描组装信息
*
* @param qrCodeType qrCodeType
* @param userInfo userInfo
* @return {@link PeasantHouseholdDto}
* @author Provence
* @throws
*/
public PeasantHouseholdDto buildDefaultPeasantHouseholdDto(String qrCodeType, AgencyUserModel userInfo) {
if (null == userInfo) {
throw new BadRequest("查询不到平台用户信息");
}
if (CollectionUtils.isEmpty(userInfo.getCompanys())) {
throw new BadRequest("查询不到经销商单位信息");
}
log.info("通过区域/个人二维码扫描组装信息, user => {}, user's companys => {}", userInfo.getUserId(), JSONObject.toJSONString(userInfo.getCompanys()));
Long sequenceNbr = userInfo.getCompanys().get(0).getSequenceNbr();
Integer companyOrgCode = userInfo.getCompanys().get(0).getCompanyOrgCode();
String companyName = userInfo.getCompanys().get(0).getCompanyName();
// unitInfoServiceImpl.createCompanyAndUser 创建经销商的时候绑定的平台用户
List<UnitInfo> unitInfos = unitInfoServiceImpl.list(new LambdaQueryWrapper<UnitInfo>().eq(UnitInfo::getAmosCompanySeq, sequenceNbr));
UnitInfo unitInfo;
if (CollectionUtils.isEmpty(unitInfos)) {
log.warn("userId:{} 查询不到经销商信息", userInfo.getUserId());
throw new BadRequest("查询不到经销商信息");
}
unitInfo = unitInfos.get(0);
Long regionalCompaniesSeq = unitInfo.getRegionalCompaniesSeq();
String regionalCompaniesCode = unitInfo.getRegionalCompaniesCode();
String regionalCompaniesName = unitInfo.getRegionalCompaniesName();
PeasantHouseholdDto dto = new PeasantHouseholdDto();
// 先在后台创建一个角色和公司,微信农户新建的用户使用统一的
// 用户光伏-微信农户
// 非扫码进入注册页面,默认
dto.setDeveloperCode(companyOrgCode.toString());// 开发方code
dto.setDeveloperId(sequenceNbr);// 开发方id
dto.setDeveloperName(companyName);// 开发方名称
dto.setDeveloper(userInfo.getRealName());// 开发人
dto.setRegionalCompaniesSeq(regionalCompaniesSeq);
dto.setRegionalCompaniesCode(regionalCompaniesCode);
dto.setRegionalCompaniesName(regionalCompaniesName);
return dto;
}
private PeasantHouseholdDto buildDefaultPeasantHouseholdDto(String userId, String qrCodeType, String phoneNo) {
// 获取区域
FeignClientResult<AgencyUserModel> userInfoResult = Privilege.agencyUserClient.queryByUserId(userId);// 获取用户
if (userInfoResult != null && userInfoResult.getStatus() != 200) {
throw new BadRequest("无效的userId");
}
AgencyUserModel userInfo = userInfoResult.getResult();
PeasantHouseholdDto dto = buildDefaultPeasantHouseholdDto(qrCodeType, userInfo);
dto.setTelephone(phoneNo);
return dto;
}
/**
* 手机号解析
*
* @param param MobileLoginParam.class
* @return String phoneNo
*/
private String parsePhoneNo(MobileLoginParamDto param) {
if (param.getRegisterType() == PhoneRegisterTypeEum.WX.getCode()) {
// 进行验证码解析
String encryptedData = param.getEncryptedData();
String iv = param.getIv();
String code = param.getCode();
return getPhoneNumber(wxService.getSessionKey(code), encryptedData, iv);
} else {
return param.getPhoneNo();
}
}
public String getPhoneNumber(String sessionkey, String encryptedData, String iv) {
byte[] encrypData = java.util.Base64.getDecoder().decode(encryptedData);
byte[] ivData = java.util.Base64.getDecoder().decode(iv);
byte[] sessionKey = java.util.Base64.getDecoder().decode(sessionkey);
String resultString = null;
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
SecretKeySpec keySpec = new SecretKeySpec(sessionKey, "AES");
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
resultString = new String(cipher.doFinal(encrypData), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
log.error("getPhoneNumber error:", e);
throw new BadRequest("微信授权失败, 请重新授权");
}
JSONObject object = JSONObject.parseObject(resultString);
if (object != null) {
// 拿到手机号码
String phone = object.getString("phoneNumber");
return phone;
}
return null;
}
/**
* 设置平台接口调用权限
*/
public void setPlatFormAccess() {
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
/*IdPasswordAuthModel authModel = new IdPasswordAuthModel();
authModel.setLoginId("admin_jxiop");
authModel.setPassword("AC286A35E74D2DD281EB979789DECF3A");*/
IdPasswordAuthModel authModel = new IdPasswordAuthModel();
authModel.setLoginId(platfromAccessLoginId);
authModel.setPassword(platfromAccessPassword);
FeignClientResult<Map<String, String>> authResult = Privilege.authClient.idpassword(authModel);
String token = authResult.getResult().get("token");
System.out.println("token:" + token);
RequestContext.setToken(token);
// 正常情况下,这里应该做缓存
}
/**
* 生成一个农户信息编号
*
*
* @param
* @return {@link String}
* @author Provence
* @throws
*/
public String getPeasantHouseholdNo() {
String redisKey = "getPeasantHouseholdNo";
String sdf = new SimpleDateFormat("yyyyMMdd").format(new Date());
long increment = redisUtils.incr(redisKey, 1);
if (increment == 0) {
redisUtils.expire(redisKey, nextDay());
}
return "N" + sdf + String.format("%05d", increment);
}
private long nextDay() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DAY_OF_MONTH, 1);
return (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyLogDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoneyLog;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PreparationMoneyLogMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IPreparationMoneyLogService;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
/**
* 发货单日志记录服务实现类
*
* @author system_generator
* @date 2023-08-17
*/
@Service
public class PreparationMoneyLogServiceImpl extends BaseService<PreparationMoneyLogDto, PreparationMoneyLog, PreparationMoneyLogMapper> implements IPreparationMoneyLogService {
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.hygf.api.Enum.PreparationMoneyEnum;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyLogDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationPageDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationPageDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.DocumentBom;
import com.yeejoin.amos.boot.module.hygf.api.entity.DocumentStation;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney; import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoneyLog;
import com.yeejoin.amos.boot.module.hygf.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PreparationMoneyMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.PreparationMoneyMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IPreparationMoneyService; import com.yeejoin.amos.boot.module.hygf.api.service.IPreparationMoneyService;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* 发货单服务实现类 * 发货单服务实现类
...@@ -27,9 +48,20 @@ public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto ...@@ -27,9 +48,20 @@ public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto
@Autowired @Autowired
private PreparationMoneyMapper preparationMoneyMapper; private PreparationMoneyMapper preparationMoneyMapper;
@Autowired
private PowerStationServiceImpl powerStationService;
@Autowired
private PeasantHouseholdServiceImpl peasantHouseholdService;
@Autowired
private DocumentBomServiceImpl documentBomService;
@Autowired
private DocumentStationServiceImpl documentStationService;
@Autowired
private AmosRequestContext amosRequestContext;
@Autowired
private UnitInfoServiceImpl unitInfoService;
@Autowired
private PreparationMoneyLogServiceImpl preparationMoneyLogService;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -66,4 +98,212 @@ public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto ...@@ -66,4 +98,212 @@ public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto
public List<PreparationMoneyDto> queryForPreparationMoneyList() { public List<PreparationMoneyDto> queryForPreparationMoneyList() {
return this.queryForList("" , false); return this.queryForList("" , false);
} }
/**
* 获取发货单详情 by sequenceNbr
*
*
* @param sequenceNbr sequenceNbr
* @return {@link PreparationMoneyDto}
* @author Provence
* @throws
*/
public PreparationMoneyDto getObjectBySequenceNbr(Long sequenceNbr) {
PreparationMoneyDto preparationMoneyDto = this.queryBySeq(sequenceNbr);
// 加载BOM清单数据
preparationMoneyDto.setDocumentBoms(documentBomService.listByPreparationMoneyId(sequenceNbr));
// 加载发货电站数据
List<Long> peasantHouseholdIds = documentStationService.list(new LambdaQueryWrapper<DocumentStation>()
.select(DocumentStation::getStationId)
.eq(DocumentStation::getPreparationMoneyId, sequenceNbr))
.stream().map(DocumentStation::getStationId).collect(Collectors.toList());
List<PeasantHousehold> peasantHouseholds = (List<PeasantHousehold>) peasantHouseholdService.listByIds(peasantHouseholdIds);
preparationMoneyDto.setPowerStations(peasantHouseholds.stream().map(o -> entityToDto(o)).collect(Collectors.toList()));
// 加载单据追踪数据
List<PreparationMoneyLog> preparationMoneyLogDtos = preparationMoneyLogService.list(new LambdaQueryWrapper<PreparationMoneyLog>().eq(PreparationMoneyLog::getPreparationMoneyId, sequenceNbr));
preparationMoneyDto.setPreparationMoneyLogs(preparationMoneyLogDtos.stream().map(o -> entityToDto(o)).collect(Collectors.toList()));
return preparationMoneyDto;
}
private PeasantHouseholdDto entityToDto(PeasantHousehold o) {
PeasantHouseholdDto dto = new PeasantHouseholdDto();
BeanUtils.copyProperties(o, dto);
return dto;
}
private PreparationMoneyLogDto entityToDto(PreparationMoneyLog o) {
PreparationMoneyLogDto dto = new PreparationMoneyLogDto();
BeanUtils.copyProperties(o, dto);
return dto;
}
/**
* 保存或更新发货单
*
*
* @param model model
* @return {@link PreparationMoneyDto}
* @author Provence
* @throws
*/
@Transactional
@Override
public PreparationMoneyDto saveOrUpdateObject(PreparationMoneyDto model) {
boolean isUpdate = false;
if (model.getSequenceNbr() != null) {
// update
PreparationMoney entity = this.getById(model);
if (entity == null) {
throw new RuntimeException("发货单不存在");
}
isUpdate = true;
}
// BOM 清单 后台查询数据库整合数据
List<PeasantHouseholdDto> powerStations = model.getPowerStations();
List<Long> powerHouseholdIds = powerStations.stream().map(PeasantHouseholdDto::getSequenceNbr).collect(Collectors.toList());
// 后台组装BOM清单
List<DocumentBom> documentBoms = documentBomService.assembleDocumentBom(powerHouseholdIds);
if (CollectionUtils.isEmpty(documentBoms)) {
// throw new BaseException("BOM清单为空", "400", "BOM清单为空");// 这里阻塞前端接口
// 根据发货电站信息无法组装成BOM清单
throw new RuntimeException("BOM清单为空");
}
// 根据BOM清单计算当前发货单的价格
PreparationMoneyDto pmd = caculateShippingPrice(documentBoms);
model.setInventoryPrice(pmd.getInventoryPrice());//清单价格
model.setDiscount(pmd.getDiscount());//折扣
model.setPromotion(pmd.getPromotion());//促销
model.setTotalPrice(pmd.getTotalPrice());//总价
// 前端传值改动太大, 从数据库获取dealerName
String dealerName = Optional.ofNullable(unitInfoService.query().eq("amos_company_seq", model.getDealerId()).one()).map(UnitInfo::getName).orElse(null);
model.setDealerName(dealerName);
// model.setContractPrice(pmd.getContractPrice());//合同价格
if (!isUpdate) {
// 初始化状态
model.setReceivingStatus(PreparationMoneyEnum.RECEIVING_STATUS.未到货.getName());
model.setShipmentStatus(PreparationMoneyEnum.SHIPMENT_STATUS.未发货.getName());
model.setDocumentState(PreparationMoneyEnum.DOCUMENT_STATE.未完成.getName());
}
PreparationMoney entity = new PreparationMoney();
BeanUtils.copyProperties(model, entity);
this.saveOrUpdate(entity);
documentBoms.stream().forEach(d -> d.setPreparationMoneyId(entity.getSequenceNbr()));
List<DocumentStation> documentStations = powerStations.stream().map(o -> buildDocumentStations(entity.getSequenceNbr(), o)).collect(Collectors.toList());
if (isUpdate) {
documentBomService.remove(new LambdaQueryWrapper<DocumentBom>().select(DocumentBom::getSequenceNbr).eq(DocumentBom::getPreparationMoneyId, entity.getSequenceNbr()));
documentStationService.remove(new LambdaQueryWrapper<DocumentStation>().select(DocumentStation::getSequenceNbr).eq(DocumentStation::getPreparationMoneyId, entity.getSequenceNbr()));
}
documentBomService.saveOrUpdateBatch(documentBoms);
documentStationService.saveOrUpdateBatch(documentStations);
// 记录操作日志
PreparationMoneyLog preparationMoneyLog = new PreparationMoneyLog();
preparationMoneyLog.setPreparationMoneyId(entity.getSequenceNbr());
preparationMoneyLog.setOperationContent(String.format("备货单保存【备货单号:%s】", entity.getOddNumbers()));
preparationMoneyLogService.save(preparationMoneyLog);
return model;
}
private DocumentStation buildDocumentStations(Long sequenceNbr, PeasantHouseholdDto dto) {
String recUserId = amosRequestContext.getUserId();
String recUserName = amosRequestContext.getUserName();
DocumentStation documentStation = new DocumentStation();
documentStation.setPreparationMoneyId(sequenceNbr);
documentStation.setStationId(dto.getSequenceNbr());
documentStation.setRecUserId(recUserId);
documentStation.setRecUserName(recUserName);
return documentStation;
}
/**
* 更新发货单状态
*
*
* @param sequenceNbr 发货单ID
* @param operationType 操作类型(RECEIPT-确认收货, DELIVERY-发货, DISCARD-废弃)
* @return {@link Boolean}
* @author Provence
* @throws
*/
@Override
public Boolean updatePreparationMoneyStatus(Long sequenceNbr, String operationType) {
PreparationMoney preparationMoney = preparationMoneyMapper.selectById(sequenceNbr);
if (preparationMoney == null) {
throw new RuntimeException("订单不存在");
}
PreparationMoneyLog preparationMoneyLog = new PreparationMoneyLog();
preparationMoneyLog.setPreparationMoneyId(preparationMoney.getSequenceNbr());
switch (operationType) {
case "RECEIPT":
// 确认收货 -> 到货状态 -> 已到货 -> 订单状态改为 已完成
if (!PreparationMoneyEnum.SHIPMENT_STATUS.已发货.getName().equals(preparationMoney.getShipmentStatus())) {
throw new RuntimeException("订单未发货, 无法确认收货");
}
preparationMoney.setReceivingStatus(PreparationMoneyEnum.RECEIVING_STATUS.已到货.getName());
preparationMoney.setDocumentState(PreparationMoneyEnum.DOCUMENT_STATE.已完成.getName());
preparationMoney.setDeliveryTime(new Date());
preparationMoneyLog.setOperationContent(String.format("备货单确认收货【备货单号:%s】", preparationMoney.getOddNumbers()));
break;
case "DELIVERY":
// 发货 -> 发货状态 -> 已发货
preparationMoney.setShipmentStatus(PreparationMoneyEnum.SHIPMENT_STATUS.已发货.getName());
preparationMoneyLog.setOperationContent(String.format("备货单发货【备货单号:%s】", preparationMoney.getOddNumbers()));
break;
case "DISCARD":
// 作废
// 订单状态 -> 已废弃
if (PreparationMoneyEnum.RECEIVING_STATUS.已到货.getName().equals(preparationMoney.getReceivingStatus())) {
throw new RuntimeException("订单已到货, 无法作废");
}
preparationMoney.setDocumentState(PreparationMoneyEnum.DOCUMENT_STATE.作废.getName());
preparationMoneyLog.setOperationContent(String.format("备货单作废【备货单号:%s】", preparationMoney.getOddNumbers()));
break;
default:
break;
}
preparationMoneyLogService.save(preparationMoneyLog);
return preparationMoneyMapper.updateById(preparationMoney) > 0;
}
/**
* 根据前端选择的发货电站ID列表计算BOM清单价格
*
*
* @param powerHouseholdIds 发货电站ID
* @return {@link PreparationMoneyDto}
* @author Provence
* @throws
*/
public PreparationMoneyDto caculateShippingPriceByPowerHouseHoldIds(List<Long> powerHouseholdIds) {
List<DocumentBom> documentBoms = documentBomService.assembleDocumentBom(powerHouseholdIds);
return caculateShippingPrice(documentBoms);
}
/**
* 根据前端选择的发货电站ID列表计算BOM清单价格
*
*
* @param documentBoms BOM清单
* @return {@link PreparationMoneyDto}
* @author Provence
* @throws
*/
public PreparationMoneyDto caculateShippingPrice(List<DocumentBom> documentBoms) {
// 获取BOM清单数据
// 单价 * 经销商折扣 * 促销 * 需求数量
BigDecimal totalPrice = new BigDecimal(0);
BigDecimal totaldemandNumber = new BigDecimal(0);
for (DocumentBom documentBom : documentBoms) {
BigDecimal unitPrice = new BigDecimal(documentBom.getUnitPrice() == null?0:documentBom.getUnitPrice());//单价
BigDecimal demandNumber = new BigDecimal(documentBom.getDemandNumber());//需求数量
totalPrice = totalPrice.add(unitPrice.multiply(demandNumber));
totaldemandNumber = totaldemandNumber.add(demandNumber);
}
PreparationMoneyDto preparationMoneyDto = new PreparationMoneyDto();
preparationMoneyDto.setInventoryPrice(totalPrice.divide(totaldemandNumber).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());//清单价格
preparationMoneyDto.setDiscount(0D);//折扣
preparationMoneyDto.setPromotion(0D);//促销
preparationMoneyDto.setContractPrice(0D);//合同价格 == 确认
preparationMoneyDto.setTotalPrice(totalPrice.doubleValue());
return preparationMoneyDto;
}
} }
\ No newline at end of file
...@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.hygf.biz.service.impl; ...@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.qiyuesuo.sdk.v2.SdkClient; import com.qiyuesuo.sdk.v2.SdkClient;
import com.qiyuesuo.sdk.v2.bean.*; import com.qiyuesuo.sdk.v2.bean.*;
import com.qiyuesuo.sdk.v2.bean.vo.DocumentUrlVO;
import com.qiyuesuo.sdk.v2.exception.BaseSdkException; import com.qiyuesuo.sdk.v2.exception.BaseSdkException;
import com.qiyuesuo.sdk.v2.json.JSONUtils; import com.qiyuesuo.sdk.v2.json.JSONUtils;
import com.qiyuesuo.sdk.v2.request.*; import com.qiyuesuo.sdk.v2.request.*;
import com.qiyuesuo.sdk.v2.response.ContractDownloadUrlResult;
import com.qiyuesuo.sdk.v2.response.DocumentAddResult; import com.qiyuesuo.sdk.v2.response.DocumentAddResult;
import com.qiyuesuo.sdk.v2.response.MiniappTicketResult; import com.qiyuesuo.sdk.v2.response.MiniappTicketResult;
import com.qiyuesuo.sdk.v2.response.SdkResponse; import com.qiyuesuo.sdk.v2.response.SdkResponse;
...@@ -109,17 +111,13 @@ public class QiyuesuoServiceImpl { ...@@ -109,17 +111,13 @@ public class QiyuesuoServiceImpl {
Integer personalPage= contractDataDto.getPersonalPage(); Integer personalPage= contractDataDto.getPersonalPage();
Double personalOffsetX= contractDataDto.getPersonalOffsetX(); Double personalOffsetX= contractDataDto.getPersonalOffsetX();
Double personalOffsetY= contractDataDto.getPersonalOffsetY(); Double personalOffsetY= contractDataDto.getPersonalOffsetY();
List<Long> corpSealIds=contractDataDto.getSealId();
SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret); SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret);
// 合同基本参数 // 合同基本参数
//进行日期格式化 //进行日期格式化
Contract contract = new Contract(); Contract contract = new Contract();
contract.setSubject(subject); contract.setSubject(subject);
contract.setDescription(subject); contract.setDescription(subject);
contract.setExpireTime(expireTime);
contract.setEndTime(endTime);
contract.setCategory(new Category(category)); contract.setCategory(new Category(category));
contract.setSend(false); contract.setSend(false);
// 个人 // 个人
...@@ -136,6 +134,8 @@ public class QiyuesuoServiceImpl { ...@@ -136,6 +134,8 @@ public class QiyuesuoServiceImpl {
signatory2.setReceiver(new User(companyUsername, companyContact, "MOBILE")); signatory2.setReceiver(new User(companyUsername, companyContact, "MOBILE"));
signatory2.setSerialNo(2); signatory2.setSerialNo(2);
Action action = new Action("COMPANY", 0); Action action = new Action("COMPANY", 0);
//指定印章
action.setCorpSealIds(corpSealIds);
signatory2.addAction(action); signatory2.addAction(action);
// 设置签署方 // 设置签署方
contract.addSignatory(signatory1); contract.addSignatory(signatory1);
...@@ -143,17 +143,18 @@ public class QiyuesuoServiceImpl { ...@@ -143,17 +143,18 @@ public class QiyuesuoServiceImpl {
// 创建合同 // 创建合同
ContractDraftRequest request = new ContractDraftRequest(contract); ContractDraftRequest request = new ContractDraftRequest(contract);
logger.info("创建草稿合同调用前"+JSON.toJSONString(request));
String response = sdkClient.service(request); String response = sdkClient.service(request);
SdkResponse<Contract> responseObj = JSONUtils.toQysResponse(response, Contract.class); SdkResponse<Contract> responseObj = JSONUtils.toQysResponse(response, Contract.class);
// 返回结果 // 返回结果
Contract result=new Contract(); Contract result=new Contract();
logger.info("创建草稿合同调用后"+JSON.toJSONString(responseObj));
if(responseObj.getCode() == 0) { if(responseObj.getCode() == 0) {
result = responseObj.getResult(); result = responseObj.getResult();
logger.info(JSON.toJSONString(responseObj)); logger.info(JSON.toJSONString(responseObj));
} else { } else {
logger.info("请求失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage()); logger.info("请求失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage());
} }
DocumentAddResult documentAddResult= this.getDocumentAddResult(result.getId(),subject, templateParam,emplateId); DocumentAddResult documentAddResult= this.getDocumentAddResult(result.getId(),subject, templateParam,emplateId);
List<Signatory> list= result.getSignatories(); List<Signatory> list= result.getSignatories();
Long ActionId=null; Long ActionId=null;
...@@ -177,7 +178,7 @@ public class QiyuesuoServiceImpl { ...@@ -177,7 +178,7 @@ public class QiyuesuoServiceImpl {
Stamper stamper2 = new Stamper(); Stamper stamper2 = new Stamper();
stamper2.setSignatoryId(SignatoryId); stamper2.setSignatoryId(SignatoryId);
stamper2.setDocumentId(documentAddResult.getDocumentId()); stamper2.setDocumentId(documentAddResult.getDocumentId());
stamper.setKeyword(personalkeyword); stamper2.setKeyword(personalkeyword);
stamper2.setType("PERSONAL"); stamper2.setType("PERSONAL");
stamper2.setPage(personalPage); stamper2.setPage(personalPage);
stamper2.setOffsetX(personalOffsetX); stamper2.setOffsetX(personalOffsetX);
...@@ -186,7 +187,6 @@ public class QiyuesuoServiceImpl { ...@@ -186,7 +187,6 @@ public class QiyuesuoServiceImpl {
stampers.add(stamper); stampers.add(stamper);
stampers.add(stamper2); stampers.add(stamper2);
SdkResponse<Object> data= this.getSdkResponse(result.getId(), stampers); SdkResponse<Object> data= this.getSdkResponse(result.getId(), stampers);
return result.getId(); return result.getId();
} }
...@@ -196,20 +196,24 @@ public class QiyuesuoServiceImpl { ...@@ -196,20 +196,24 @@ public class QiyuesuoServiceImpl {
// 添加合同文档 // 添加合同文档
List<TemplateParam> params = new ArrayList<>(); List<TemplateParam> params = new ArrayList<>();
for (TemplateParamDto templateParamDto : templateParam) { for (TemplateParamDto templateParamDto : templateParam) {
params.add(new TemplateParam(templateParamDto.getKey(), templateParamDto.getValue())); if(templateParamDto.getValue()!=null){
params.add(new TemplateParam(templateParamDto.getKey(), templateParamDto.getValue()));
}
} }
logger.info("合同参数"+JSON.toJSONString(params));
DocumentAddByTemplateRequest request = new DocumentAddByTemplateRequest(contractId, DocumentAddByTemplateRequest request = new DocumentAddByTemplateRequest(contractId,
emplateId , params, subject); emplateId , params, subject);
logger.info("添加合同文档前", JSON.toJSONString(request));
String response = sdkClient.service(request); String response = sdkClient.service(request);
SdkResponse<DocumentAddResult> responseObj = JSONUtils.toQysResponse(response, DocumentAddResult.class); SdkResponse<DocumentAddResult> responseObj = JSONUtils.toQysResponse(response, DocumentAddResult.class);
logger.info("添加合同文档后", JSON.toJSONString(responseObj));
DocumentAddResult result=null; DocumentAddResult result=null;
if (responseObj.getCode() == 0) { if (responseObj.getCode() == 0) {
result = responseObj.getResult(); result = responseObj.getResult();
logger.info("添加合同文档成功,文档ID:{}", JSON.toJSONString(result)); logger.info("添加合同文档成功,文档ID:{}", JSON.toJSONString(result));
} else { } else {
logger.info("请求失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage()); throw new RuntimeException("请求失败");
} }
return result; return result;
} }
...@@ -219,16 +223,44 @@ public class QiyuesuoServiceImpl { ...@@ -219,16 +223,44 @@ public class QiyuesuoServiceImpl {
// 发起合同 // 发起合同
SdkResponse<Object> responseObj =null; SdkResponse<Object> responseObj =null;
ContractSendRequest request = new ContractSendRequest(contractId, stampers); ContractSendRequest request = new ContractSendRequest(contractId, stampers);
logger.info("发起合同前", JSON.toJSONString(request));
String response = sdkClient.service(request); String response = sdkClient.service(request);
responseObj = JSONUtils.toQysResponse(response); responseObj = JSONUtils.toQysResponse(response);
logger.info("发起合同后", JSON.toJSONString(responseObj));
if(responseObj.getCode() == 0) { if(responseObj.getCode() == 0) {
logger.info("合同发起成功"); logger.info("合同发起成功");
} else { } else {
logger.info("请求失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage()); throw new RuntimeException("请求失败");
} }
return responseObj; return responseObj;
}
public String getdownloadUrl(Long contractId ) {
String url=null;
SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret);
ContractDownloadUrlRequest downloadRequest = new ContractDownloadUrlRequest(contractId);
String response = sdkClient.service(downloadRequest);
SdkResponse<ContractDownloadUrlResult> responseObj = JSONUtils.toQysResponse(response, ContractDownloadUrlResult.class);
if (responseObj.getCode().equals(0)) {
List<DocumentUrlVO> downloadUrls = responseObj.getResult().getDownloadUrls();
for (DocumentUrlVO vo : downloadUrls) {
if("CONTRACT".equals(vo.getDownloadItems())){
url= vo.getDownloadUrl();
}
}
} else {
throw new RuntimeException("请求失败");
}
return url;
} }
} }
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.yeejoin.amos.boot.module.hygf.api.entity.SealDictionary;
import com.yeejoin.amos.boot.module.hygf.api.mapper.SealDictionaryMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.ISealDictionaryService;
import com.yeejoin.amos.boot.module.hygf.api.dto.SealDictionaryDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* 服务实现类
*
* @author system_generator
* @date 2023-08-23
*/
@Service
public class SealDictionaryServiceImpl extends BaseService<SealDictionaryDto,SealDictionary,SealDictionaryMapper> implements ISealDictionaryService {
/**
* 分页查询
*/
public Page<SealDictionaryDto> queryForSealDictionaryPage(Page<SealDictionaryDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<SealDictionaryDto> queryForSealDictionaryList() {
return this.queryForList("" , false);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.HttpUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.dto.AccessTokenDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.WechatQrCodeDTO;
import com.yeejoin.amos.boot.module.hygf.api.service.IWxService;
import com.yeejoin.amos.boot.module.jxiop.api.util.HttpUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Base64;
/**
* 农户微信小程序
*
* @author Provence
* @version v1.0
* @date 2023/8/21 16:21
*/
@Slf4j
@Component
public class WxServiceImpl implements IWxService {
private final String SMALL_PRO_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?";
private final String SMALL_PRO_TOKEN = "wxToken";
private final String SMALL_PRO_QRCODE_URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?";
@Autowired
private RedisUtils redisUtil;
private static final String grant_type = "client_credential";
private static final String smallPrograName = "amos\\u5E73\\u53F0";
/**
* 公众号appid
*/
private static final String publicAppId = "wxf6f295ce82aa4aab";
/**
* 公众号secret
*/
private static final String publicSecret = "8df0d4c5968d0d65cba2a398eedfd1e8";
@Value ("${hygfProgram.appid}")
private String appId;
@Value ("${hygfProgram.secret}")
private String secret;
public String getSessionKey(String code) {
JSONObject jsonObject = getCode2Session(code);
String sessionKey = null;
if (jsonObject != null) {
sessionKey = jsonObject.getString("session_key");
}
return sessionKey;
}
@Override
public String getAccessToken() {
// 坑,redis取出来的值 微信说失效了 现在解决方案 是改小失效时间
String redisKey = SMALL_PRO_TOKEN + ":" + appId;
if (redisUtil.hasKey(redisKey)) {
return redisUtil.get(redisKey).toString();
}
AccessTokenDto accessToken = buildTokenParam(SMALL_PRO_TOKEN_URL, grant_type, appId, secret);
if (accessToken.getErrcode() == null) {
redisUtil.set(redisKey, accessToken.getAccess_token(), accessToken.getExpires_in() - 5);
}
return accessToken.getAccess_token();
}
private AccessTokenDto buildTokenParam(String url, String grant_type, String appid, String secret) {
StringBuffer buildUrl = new StringBuffer();
buildUrl.append(url).append("grant_type=" + grant_type).append("&appid=" + appid).append("&secret=" + secret);
try {
log.info("获取access_token入参 => {}", buildUrl);
String resultStr = HttpUtils.doGet(buildUrl.toString());
log.info("获取access_token返回值 => {}", resultStr);
AccessTokenDto accessToken = JSON.parseObject(resultStr, AccessTokenDto.class);
if (accessToken.getErrcode() != null && 0 != accessToken.getErrcode()) {
throw new RuntimeException(accessToken.getErrmsg());
}
return accessToken;
} catch (Exception e) {
log.error("获取access_token is error url:{}", buildUrl.toString());
throw new RuntimeException(e.getMessage());
}
}
/**
* @param url
* @param access_token 接口调用凭证
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
private WechatQrCodeDTO buildQrParam(String url, String access_token, String scene, String page, Long width,
Boolean auto_color, JSONObject line_color, Boolean is_hyaline) {
log.info("生成二维码入参, url=>{}, access_token=>{}, scene=>{}, page=>{},", url, access_token, scene, page);
WechatQrCodeDTO smallProQrCodeVo = new WechatQrCodeDTO();
StringBuffer buildUrl = new StringBuffer();
buildUrl.append(url).append("access_token=" + access_token);
JSONObject param = new JSONObject();
param.put("scene", scene);
param.put("page", page);
param.put("width", width);
param.put("auto_color", auto_color);
param.put("line_color", line_color);
param.put("is_hyaline", is_hyaline);
try {
RestTemplate rest = new RestTemplate();
log.info("request wxQrCode start.....");
ResponseEntity<Resource> entity = rest.postForEntity(buildUrl.toString(), param.toJSONString(),
Resource.class);
log.info("get wxQrCode entity:{}", entity.toString());
InputStream in = entity.getBody().getInputStream();
smallProQrCodeVo.setBuffer(inputStream2byte(in));
} catch (Exception e) {
log.error("getSmallProQrCode is error url:{} param:{}", buildUrl.toString(), JSON.toJSON(param));
throw new BadRequest(e.getMessage());
}
return smallProQrCodeVo;
}
/**
* 功能描述:
*
* @param inputStream 输入流
* @return byte[] 数组
* @author sqy
* @date 2019/3/28 16:03
* @version 1.0
*/
public static byte[] inputStream2byte(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while ((rc = inputStream.read(buff, 0, 100)) > 0) {
byteArrayOutputStream.write(buff, 0, rc);
}
return byteArrayOutputStream.toByteArray();
}
@Override
public String getSmallProQrCode(String access_token, String scene, String page, Long width, Boolean auto_color, JSONObject line_color, Boolean is_hyaline) {
WechatQrCodeDTO smallProQrCodeVo = buildQrParam(SMALL_PRO_QRCODE_URL, access_token, scene, page, width, auto_color,
line_color, is_hyaline);
// 小程序二维码
byte[] buffer = smallProQrCodeVo.getBuffer();
return JSON.toJSONString(buffer);
}
@Override
public byte[] getSmallProQrCodeByte(String access_token, String scene, String page, Long width, Boolean auto_color, JSONObject line_color, Boolean is_hyaline) {
WechatQrCodeDTO smallProQrCodeVo = buildQrParam(SMALL_PRO_QRCODE_URL, access_token, scene, page, width, auto_color,
line_color, is_hyaline);
// 小程序二维码 byte
return smallProQrCodeVo.getBuffer();
}
@Override
public String getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color, JSONObject line_color, Boolean is_hyaline, HttpServletResponse response, String fileName, String fileType) {
WechatQrCodeDTO smallProQrCodeVo = buildQrParam(SMALL_PRO_QRCODE_URL, access_token, scene, page, width,
auto_color, line_color, is_hyaline);
byte[] smallProQrCode = smallProQrCodeVo.getBuffer();
response.setContentType("image/" + fileType);
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + "." + fileType);
response.addHeader("Access-Control-Allow-Headers", "Content-Disposition");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
String picStr = Base64.getEncoder().encodeToString(smallProQrCode);
return picStr;
/*OutputStream os = null;
try {
os = response.getOutputStream();
os.write(smallProQrCode);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (os != null) os.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
if (os != null) os.close();
} catch (IOException e) {
e.printStackTrace();
}
}*/
}
@Override
public JSONObject getCode2Session(String code) {
String url = buildOpenIdUrl(appId, secret, code);
String resultStr = HttpUtil.sendHttpGet(url);
// resultStr => {"session_key":"Mj5xbDhcZU73DtUduI1xKg==","openid":"oRraY5aYJkxkDJiG4rBaaw4MSmPA"}
log.info("微信 Code2Session, code =>{}, 结果 => {}", code, resultStr);
JSONObject jsonObject = JSONObject.parseObject(resultStr);
if (jsonObject == null || jsonObject.getIntValue("errcode") != 0) {
throw new BadRequest("微信授权失败, 请重新授权");
}
return jsonObject;
}
private String buildOpenIdUrl(String appId, String secret, String code) {
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appId + "&secret=" + secret + "&js_code="
+ code + "&grant_type=authorization_code";
return url;
}
@Data
public static class ResponeVo {
int code;
CloseableHttpResponse response;
String content;
byte[] inStream;
InputStream inputStream;
}
@Override
public String getOpenId(String code) {
JSONObject jsonObject = getCode2Session(code);
String openId = null;
if (jsonObject != null) {
openId = jsonObject.getString("openid");
}
return openId;
}
@Override
public String getPhoneNumber(String session_key, String encryptedData, String iv) {
return null;
}
@Override
public String getName() {
return null;
}
}
...@@ -85,27 +85,27 @@ spring.jms.pub-sub-domain=false ...@@ -85,27 +85,27 @@ spring.jms.pub-sub-domain=false
myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
regulator.unit.code=86*258 regulator.unit.code=86*258
# 经销商应用code # ������Ӧ��code
dealer.appcode=studio_normalapp_5133538 dealer.appcode=studio_normalapp_5133538
hygf.sms.tempCode=SMS_HYGF_0001 hygf.sms.tempCode=SMS_HYGF_0001
# 华为短信相关配置 # ��Ϊ�����������
sms.huawei.url=https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1 sms.huawei.url=https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1
sms.huawei.appKey=n3FYPWO7Heo1ze212QRBvF4VA2E2 sms.huawei.appKey=n3FYPWO7Heo1ze212QRBvF4VA2E2
sms.huawei.appSecret=IFhiMpWROi7w4Ei21ZbfIjKyt97b sms.huawei.appSecret=IFhiMpWROi7w4Ei21ZbfIjKyt97b
# 模id # ģ��id
sms.huawei.templateId=6aaeb4bf916d4db0a1942c598912519e sms.huawei.templateId=6aaeb4bf916d4db0a1942c598912519e
# 签名通道号 # ǩ��ͨ����
sms.huawei.sender=1069368924410006092 sms.huawei.sender=1069368924410006092
# 签名名称 # 签名名称
sms.huawei.signature=华为云短信测试 sms.huawei.signature=华为云短信测试
# 审核pageId确认 # ���pageIdȷ��
power.station.examine.pageId=1680853427061551106 power.station.examine.pageId=1680853427061551106
# 电站审核计划id # ��վ��˼ƻ�id
power.station.examine.planId=c4ed1873-0dc6-4518-a7a9-dbc588ef35e5 power.station.examine.planId=c4ed1873-0dc6-4518-a7a9-dbc588ef35e5
# 用户组userGroupId # �û���userGroupId
hygf.user.group.id=1679755750924120066 hygf.user.group.id=1679755750924120066
...@@ -114,4 +114,30 @@ unitInfo.station.examine.planId=51776087-a9cf-4a87-9a03-24fd24a8cf45 ...@@ -114,4 +114,30 @@ unitInfo.station.examine.planId=51776087-a9cf-4a87-9a03-24fd24a8cf45
hygf.sms.tempCodeJXS=SMS_HYGF_0002 hygf.sms.tempCodeJXS=SMS_HYGF_0002
regionalCompanies.company.seq=1693499571071619074 regionalCompanies.company.seq=1693499571071619074
\ No newline at end of file
qiyuesuo.serverUrl = https://openapi.qiyuesuo.cn
qiyuesuo.accessKey = TdBmNkjAYd
qiyuesuo.accessSecret = y8KiDFKKDdC9Ld9Cm5zuy2rpXjxP5Z
# ============================================= v20230821 add properties =============================================
security.productWeb=AMOS_STUDIO_WEB
security.appKey=AMOS_STUDIO
login.environment=dev
# 光伏农户微信小程序信息
hygfProgram.appid=wx2188769349b1ddeb
hygfProgram.secret=3bfd098cfdac002126e728d2dbf83c0d
# 默认微信小程序农户经销商
farmer.orgCode=86
farmer.sequenceNbr=1620981815542046722
farmer.orgNamesWithoutRole=
farmer.roleId=1693501363645845505
# 配置接口授权用户
platform.access.loginId=hygf_platform
platform.access.password=AC286A35E74D2DD281EB979789DECF3A
# 测试用的经销商userid
dealer.userId=
# 测试的时候默认密码
farmer.registerPassword=a123456
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.entity; package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data; import lombok.Data;
...@@ -27,7 +29,7 @@ public class IdxBizPvPointVarCentralValue{ ...@@ -27,7 +29,7 @@ public class IdxBizPvPointVarCentralValue{
/** /**
* *
*/ */
@TableField("SEQUENCE_NBR") @TableId(value = "SEQUENCE_NBR" ,type = IdType.UUID)
private String sequenceNbr; private String sequenceNbr;
/** /**
......
...@@ -71,13 +71,13 @@ public class IdxBizPvPointVarCorrelation{ ...@@ -71,13 +71,13 @@ public class IdxBizPvPointVarCorrelation{
* *
*/ */
@TableField("ANALYSIS_POINT_ID") @TableField("ANALYSIS_POINT_ID")
private Integer analysisPointId; private String analysisPointId;
/** /**
* *
*/ */
@TableField("PROCESS_POINT_ID") @TableField("PROCESS_POINT_ID")
private Integer processPointId; private String processPointId;
/** /**
* 片区 * 片区
...@@ -131,7 +131,7 @@ public class IdxBizPvPointVarCorrelation{ ...@@ -131,7 +131,7 @@ public class IdxBizPvPointVarCorrelation{
* *
*/ */
@TableField("PROCESS_INDEX_ADDRESS") @TableField("PROCESS_INDEX_ADDRESS")
private Integer processIndexAddress; private String processIndexAddress;
/** /**
* 设备名称 * 设备名称
......
...@@ -38,7 +38,7 @@ import java.util.stream.Collectors; ...@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
@Service @Service
public class CommonServiceImpl { public class CommonServiceImpl {
private static final HashMap<String,Object> cacheExecInfo = new HashMap<>(); private static final HashMap<String, Object> cacheExecInfo = new HashMap<>();
//utc时间格式 //utc时间格式
public static final String FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'"; public static final String FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss"; public static final String FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss";
...@@ -58,7 +58,7 @@ public class CommonServiceImpl { ...@@ -58,7 +58,7 @@ public class CommonServiceImpl {
@Value("${gkblhf.key:input 1}") @Value("${gkblhf.key:input 1}")
String gkqjhfkey; String gkqjhfkey;
//----------------工况变量相关性计算请求属性配置------------------------ //----------------工况变量相关性计算请求属性配置------------------------
@Value("${gkxgxfxfan.url:b5797e0a-d456-44d3-9f21-9528e5321b74}") @Value("${gkxgxfxfan.url:7e40b660-67d5-4678-886d-da125a3c4587}")
String gkxgxfxurlfan; String gkxgxfxurlfan;
@Value("${gkxgxfxpv.url:3d583330-1b3c-4c7a-b904-9e94f3de9fc9}") @Value("${gkxgxfxpv.url:3d583330-1b3c-4c7a-b904-9e94f3de9fc9}")
String gkxgxfxurlpv; String gkxgxfxurlpv;
...@@ -148,55 +148,66 @@ public class CommonServiceImpl { ...@@ -148,55 +148,66 @@ public class CommonServiceImpl {
} }
public String getFanConditionVariablesByTimeThread(String startTime, String endTime) { public String getFanConditionVariablesByTimeThread(String startTime, String endTime) {
String result ="开始计算"; String result = "开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_QJHF.getKey()))){ if (!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_QJHF.getKey()))) {
result="正在计算中"; result = "正在计算中";
}else { } else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.FAN_QJHF.getKey()); MyServiceThread myServiceThread = new MyServiceThread(this, startTime, endTime, SmartAnalyseEnum.FAN_QJHF.getKey());
myServiceThread.start(); myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.FAN_QJHF.getKey(),myServiceThread); cacheExecInfo.put(SmartAnalyseEnum.FAN_QJHF.getKey(), myServiceThread);
} }
return result; return result;
} }
//遍历工况列表数据-风机 //遍历工况列表数据-风机
public void getFanConditionVariablesByTime(String startTime, String endTime) { public void getFanConditionVariablesByTime(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime); try {
String endTimeUTC =getUtcTimeString(endTime); String startTimeUTC = getUtcTimeString(startTime);
HashMap<String, List<IdxBizFanPointProcessVariableClassification>> idxBizFanPointProcessVariableClassificationHashMap = getIdxBizFanPointProcessVariableClassificationList(); String endTimeUTC = getUtcTimeString(endTime);
idxBizFanPointProcessVariableClassificationHashMap.keySet().forEach(s -> { HashMap<String, List<IdxBizFanPointProcessVariableClassification>> idxBizFanPointProcessVariableClassificationHashMap = getIdxBizFanPointProcessVariableClassificationList();
List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationHashMap.get(s); idxBizFanPointProcessVariableClassificationHashMap.keySet().forEach(s -> {
if (list.size() > 0) { List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationHashMap.get(s);
foreachHandlerConditionVariabFan(s, list, startTimeUTC, endTimeUTC); if (list.size() > 0) {
} foreachHandlerConditionVariabFan(s, list, startTimeUTC, endTimeUTC);
}); }
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey()); });
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey());
} catch (Exception exception) {
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey());
}
} }
public String getPvConditionVariablesByTimeThread(String startTime, String endTime) { public String getPvConditionVariablesByTimeThread(String startTime, String endTime) {
String result ="开始计算"; String result = "开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_QJHF.getKey()))){ if (!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_QJHF.getKey()))) {
result="正在计算中"; result = "正在计算中";
}else { } else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.PV_QJHF.getKey()); MyServiceThread myServiceThread = new MyServiceThread(this, startTime, endTime, SmartAnalyseEnum.PV_QJHF.getKey());
myServiceThread.start(); myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.PV_QJHF.getKey(),myServiceThread); cacheExecInfo.put(SmartAnalyseEnum.PV_QJHF.getKey(), myServiceThread);
} }
return result; return result;
} }
//遍历工况列表数据-光伏 //遍历工况列表数据-光伏
public void getPvConditionVariablesByTime(String startTime, String endTime) { public void getPvConditionVariablesByTime(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime); try {
String endTimeUTC =getUtcTimeString(endTime);
HashMap<String, List<IdxBizPvPointProcessVariableClassification>> idxBizPvPointProcessVariableClassificationHashMap = getIdxBizPvPointProcessVariableClassificationList(); String startTimeUTC = getUtcTimeString(startTime);
idxBizPvPointProcessVariableClassificationHashMap.keySet().forEach(s -> { String endTimeUTC = getUtcTimeString(endTime);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationHashMap.get(s); HashMap<String, List<IdxBizPvPointProcessVariableClassification>> idxBizPvPointProcessVariableClassificationHashMap = getIdxBizPvPointProcessVariableClassificationList();
if (list.size() > 0) { idxBizPvPointProcessVariableClassificationHashMap.keySet().forEach(s -> {
foreachHandlerConditionVariabPv(s, list, startTimeUTC, endTimeUTC); List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationHashMap.get(s);
} if (list.size() > 0) {
}); foreachHandlerConditionVariabPv(s, list, startTimeUTC, endTimeUTC);
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey()); }
});
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey());
} catch (Exception exception) {
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey());
}
} }
//遍历查询数据并调用并计算-风机 //遍历查询数据并调用并计算-风机
...@@ -204,7 +215,7 @@ public class CommonServiceImpl { ...@@ -204,7 +215,7 @@ public class CommonServiceImpl {
list.forEach(idxBizFanPointProcessVariableClassification -> { list.forEach(idxBizFanPointProcessVariableClassification -> {
logger.info("--------------------------------------------风机::开始查询influxdb--------------------------------"); logger.info("--------------------------------------------风机::开始查询influxdb--------------------------------");
List<Map<String, Object>> params = new ArrayList<>(); List<Map<String, Object>> params = new ArrayList<>();
String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizFanPointProcessVariableClassification.getIndexAddress(),startTime,endTime); String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList = influxdbUtil.query(sql); List<Map<String, Object>> returnList = influxdbUtil.query(sql);
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -216,9 +227,9 @@ public class CommonServiceImpl { ...@@ -216,9 +227,9 @@ public class CommonServiceImpl {
logger.info("------------------------------------------风机::开始调用工况变量区间划分算法----------------------------------------"); logger.info("------------------------------------------风机::开始调用工况变量区间划分算法----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params); realParams.put(gkqjhfkey, params);
String repsonse = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams)).execute().body();
if (repsonse.contains("\"status\":200")) { if (response.contains("\"status\":200") && response.contains("rows") && response.contains("rows")) {
JSONObject jsonObject = JSONObject.parseObject(repsonse); JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject result = (JSONObject) jsonObject.get("result"); JSONObject result = (JSONObject) jsonObject.get("result");
JSONObject result1 = (JSONObject) result.get("result1"); JSONObject result1 = (JSONObject) result.get("result1");
JSONArray rows = (JSONArray) result1.get("rows"); JSONArray rows = (JSONArray) result1.get("rows");
...@@ -232,7 +243,7 @@ public class CommonServiceImpl { ...@@ -232,7 +243,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------风机::工况变量区间划分更新业务表成功----------------------------------------"); logger.info("------------------------------------------风机::工况变量区间划分更新业务表成功----------------------------------------");
} }
try { try {
logger.info(repsonse); logger.info(response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info("------------------------------------------风机::调用工况变量区间划分算法结束----------------------------------------"); logger.info("------------------------------------------风机::调用工况变量区间划分算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -248,7 +259,7 @@ public class CommonServiceImpl { ...@@ -248,7 +259,7 @@ public class CommonServiceImpl {
list.forEach(idxBizPvPointProcessVariableClassification -> { list.forEach(idxBizPvPointProcessVariableClassification -> {
logger.info("--------------------------------------------光伏::开始查询influxdb--------------------------------"); logger.info("--------------------------------------------光伏::开始查询influxdb--------------------------------");
List<Map<String, Object>> params = new ArrayList<>(); List<Map<String, Object>> params = new ArrayList<>();
String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress(),startTime,endTime); String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList = influxdbUtil.query(sql); List<Map<String, Object>> returnList = influxdbUtil.query(sql);
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -260,9 +271,9 @@ public class CommonServiceImpl { ...@@ -260,9 +271,9 @@ public class CommonServiceImpl {
logger.info("------------------------------------------光伏::开始调用工况变量区间划分算法----------------------------------------"); logger.info("------------------------------------------光伏::开始调用工况变量区间划分算法----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params); realParams.put(gkqjhfkey, params);
String repsonse = HttpUtil.createPost(baseUrl + gkqjhfurlpv).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkqjhfurlpv).body(JSON.toJSONString(realParams)).execute().body();
if (repsonse.contains("\"status\":200")) { if (response.contains("\"status\":200") && response.contains("rows")) {
JSONObject jsonObject = JSONObject.parseObject(repsonse); JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject result = (JSONObject) jsonObject.get("result"); JSONObject result = (JSONObject) jsonObject.get("result");
JSONObject result1 = (JSONObject) result.get("result1"); JSONObject result1 = (JSONObject) result.get("result1");
JSONArray rows = (JSONArray) result1.get("rows"); JSONArray rows = (JSONArray) result1.get("rows");
...@@ -276,7 +287,7 @@ public class CommonServiceImpl { ...@@ -276,7 +287,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------风机::工况变量区间划分更新业务表成功----------------------------------------"); logger.info("------------------------------------------风机::工况变量区间划分更新业务表成功----------------------------------------");
} }
try { try {
logger.info(repsonse); logger.info(response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info("------------------------------------------光伏::调用工况变量区间划分算法结束----------------------------------------"); logger.info("------------------------------------------光伏::调用工况变量区间划分算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -314,65 +325,75 @@ public class CommonServiceImpl { ...@@ -314,65 +325,75 @@ public class CommonServiceImpl {
} }
public String getFanConditionVariablesByTimeAnalyseThread(String startTime, String endTime) { public String getFanConditionVariablesByTimeAnalyseThread(String startTime, String endTime) {
String result ="开始计算"; String result = "开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_XGX.getKey()))){ if (!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_XGX.getKey()))) {
result="正在计算中"; result = "正在计算中";
}else { } else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.FAN_XGX.getKey()); MyServiceThread myServiceThread = new MyServiceThread(this, startTime, endTime, SmartAnalyseEnum.FAN_XGX.getKey());
myServiceThread.start(); myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.FAN_XGX.getKey(),myServiceThread); cacheExecInfo.put(SmartAnalyseEnum.FAN_XGX.getKey(), myServiceThread);
} }
return result; return result;
} }
//相关性分析-风机入口 //相关性分析-风机入口
public void getFanConditionVariablesByTimeAnalyse(String startTime, String endTime) { public void getFanConditionVariablesByTimeAnalyse(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime); try {
String endTimeUTC =getUtcTimeString(endTime); String startTimeUTC = getUtcTimeString(startTime);
HashMap<String, List<IdxBizFanPointProcessVariableClassification>> idxBizFanPointProcessVariableClassificationHashMap = getIdxBizFanPointProcessVariableClassificationListOfAnaLyse(); String endTimeUTC = getUtcTimeString(endTime);
idxBizFanPointProcessVariableClassificationHashMap.keySet().forEach(s -> { HashMap<String, List<IdxBizFanPointProcessVariableClassification>> idxBizFanPointProcessVariableClassificationHashMap = getIdxBizFanPointProcessVariableClassificationListOfAnaLyse();
List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationHashMap.get(s); idxBizFanPointProcessVariableClassificationHashMap.keySet().forEach(s -> {
list.forEach(IdxBizFanPointProcessVariableClassification -> { List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationHashMap.get(s);
List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", IdxBizFanPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", IdxBizFanPointProcessVariableClassification.getSequenceNbr())); list.forEach(IdxBizFanPointProcessVariableClassification -> {
if (gongkuangList.size() > 0) { List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", IdxBizFanPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", IdxBizFanPointProcessVariableClassification.getSequenceNbr()));
foreachHandlerConditionVariabAnalyseFan(s, gongkuangList, startTimeUTC, endTimeUTC, IdxBizFanPointProcessVariableClassification); if (gongkuangList.size() > 0) {
} foreachHandlerConditionVariabAnalyseFan(s, gongkuangList, startTimeUTC, endTimeUTC, IdxBizFanPointProcessVariableClassification);
}
});
}); });
}); cacheExecInfo.remove(SmartAnalyseEnum.FAN_XGX.getKey());
cacheExecInfo.remove(SmartAnalyseEnum.FAN_XGX.getKey()); } catch (Exception exception) {
cacheExecInfo.remove(SmartAnalyseEnum.PV_XGX.getKey());
}
} }
public String getPvConditionVariablesByTimeAnalyseThread(String startTime, String endTime) { public String getPvConditionVariablesByTimeAnalyseThread(String startTime, String endTime) {
String result ="开始计算"; String result = "开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_XGX.getKey()))){ if (!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_XGX.getKey()))) {
result="正在计算中"; result = "正在计算中";
}else { } else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.PV_XGX.getKey()); MyServiceThread myServiceThread = new MyServiceThread(this, startTime, endTime, SmartAnalyseEnum.PV_XGX.getKey());
myServiceThread.start(); myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.PV_XGX.getKey(),myServiceThread); cacheExecInfo.put(SmartAnalyseEnum.PV_XGX.getKey(), myServiceThread);
} }
return result; return result;
} }
//相关性分析-光伏入口 //相关性分析-光伏入口
public void getPvConditionVariablesByTimeAnalyse(String startTime, String endTime) { public void getPvConditionVariablesByTimeAnalyse(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime); try {
String endTimeUTC =getUtcTimeString(endTime); String startTimeUTC = getUtcTimeString(startTime);
HashMap<String, List<IdxBizPvPointProcessVariableClassification>> idxBizPvPointProcessVariableClassificationHashMap = getIdxBizPvPointProcessVariableClassificationListOfAnaLyse(); String endTimeUTC = getUtcTimeString(endTime);
idxBizPvPointProcessVariableClassificationHashMap.keySet().forEach(s -> { HashMap<String, List<IdxBizPvPointProcessVariableClassification>> idxBizPvPointProcessVariableClassificationHashMap = getIdxBizPvPointProcessVariableClassificationListOfAnaLyse();
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationHashMap.get(s); idxBizPvPointProcessVariableClassificationHashMap.keySet().forEach(s -> {
list.forEach(idxBizPvPointProcessVariableClassification -> { List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationHashMap.get(s);
List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", idxBizPvPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", idxBizPvPointProcessVariableClassification.getSequenceNbr())); list.forEach(idxBizPvPointProcessVariableClassification -> {
if (gongkuangList.size() > 0) { List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", idxBizPvPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", idxBizPvPointProcessVariableClassification.getSequenceNbr()));
foreachHandlerConditionVariabAnalysePv(s, gongkuangList, startTimeUTC, endTimeUTC, idxBizPvPointProcessVariableClassification); if (gongkuangList.size() > 0) {
} foreachHandlerConditionVariabAnalysePv(s, gongkuangList, startTimeUTC, endTimeUTC, idxBizPvPointProcessVariableClassification);
}
});
}); });
}); cacheExecInfo.remove(SmartAnalyseEnum.PV_XGX.getKey());
cacheExecInfo.remove(SmartAnalyseEnum.PV_XGX.getKey()); } catch (Exception exception) {
cacheExecInfo.remove(SmartAnalyseEnum.PV_XGX.getKey());
}
} }
//遍历处理数据-组装风机 //遍历处理数据-组装风机
public void foreachHandlerConditionVariabAnalyseFan(String tableName, List<IdxBizFanPointVarCorrelation> list, String startTime, String endTime, IdxBizFanPointProcessVariableClassification idxBizFanPointProcessVariableClassification) { public void foreachHandlerConditionVariabAnalyseFan(String tableName, List<IdxBizFanPointVarCorrelation> list, String startTime, String endTime, IdxBizFanPointProcessVariableClassification idxBizFanPointProcessVariableClassification) {
String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and where time <= '%s' ", tableName, idxBizFanPointProcessVariableClassification.getIndexAddress(),startTime,endTime); String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList = influxdbUtil.query(sql1); List<Map<String, Object>> returnList = influxdbUtil.query(sql1);
List<Map<String, Object>> params = new ArrayList<>(); List<Map<String, Object>> params = new ArrayList<>();
returnList.forEach((k) -> { returnList.forEach((k) -> {
...@@ -386,7 +407,7 @@ public class CommonServiceImpl { ...@@ -386,7 +407,7 @@ public class CommonServiceImpl {
logger.info("---------------------------------风机相关性-----------开始查询influxdb--------------------------------"); logger.info("---------------------------------风机相关性-----------开始查询influxdb--------------------------------");
List<Map<String, Object>> params1 = new ArrayList<>(); List<Map<String, Object>> params1 = new ArrayList<>();
List<Map<String, Object>> requestParams = new ArrayList<>(); List<Map<String, Object>> requestParams = new ArrayList<>();
String sql = String.format("select value from %s where address='%s' and time >= '%s' and where time <= '%s' ", tableName, idxBizFanPointVarCorrelation.getProcessIndexAddress(),startTime,endTime); String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizFanPointVarCorrelation.getProcessIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList1 = influxdbUtil.query(sql); List<Map<String, Object>> returnList1 = influxdbUtil.query(sql);
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -405,9 +426,9 @@ public class CommonServiceImpl { ...@@ -405,9 +426,9 @@ public class CommonServiceImpl {
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkxgxfxkey, requestParams); realParams.put(gkxgxfxkey, requestParams);
logger.info("------------------------------风机相关性------------分析变量与工况变量相关性分析算参数---------------------------------------" + JSON.toJSONString(realParams)); logger.info("------------------------------风机相关性------------分析变量与工况变量相关性分析算参数---------------------------------------" + JSON.toJSONString(realParams));
String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurlfan).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkxgxfxurlfan).body(JSON.toJSONString(realParams)).execute().body();
if (repsonse.contains("\"status\":200")) { if (response.contains("\"status\":200") && response.contains("rows")) {
JSONObject jsonObject = JSONObject.parseObject(repsonse); JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject result = (JSONObject) jsonObject.get("result"); JSONObject result = (JSONObject) jsonObject.get("result");
JSONObject result1 = (JSONObject) result.get("result1"); JSONObject result1 = (JSONObject) result.get("result1");
JSONArray rows = (JSONArray) result1.get("rows"); JSONArray rows = (JSONArray) result1.get("rows");
...@@ -417,7 +438,7 @@ public class CommonServiceImpl { ...@@ -417,7 +438,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------"); logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
} }
try { try {
logger.info("response-------------" + repsonse); logger.info("response-------------" + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info("----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------"); logger.info("----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -429,7 +450,7 @@ public class CommonServiceImpl { ...@@ -429,7 +450,7 @@ public class CommonServiceImpl {
//遍历处理数据-组装风机 //遍历处理数据-组装风机
public void foreachHandlerConditionVariabAnalysePv(String tableName, List<IdxBizPvPointVarCorrelation> list, String startTime, String endTime, IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification) { public void foreachHandlerConditionVariabAnalysePv(String tableName, List<IdxBizPvPointVarCorrelation> list, String startTime, String endTime, IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification) {
String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress(),startTime,endTime); String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList = influxdbUtil.query(sql1); List<Map<String, Object>> returnList = influxdbUtil.query(sql1);
List<Map<String, Object>> params = new ArrayList<>(); List<Map<String, Object>> params = new ArrayList<>();
returnList.forEach((k) -> { returnList.forEach((k) -> {
...@@ -442,7 +463,7 @@ public class CommonServiceImpl { ...@@ -442,7 +463,7 @@ public class CommonServiceImpl {
logger.info("-------------------------------------光伏相关性-------开始查询influxdb--------------------------------"); logger.info("-------------------------------------光伏相关性-------开始查询influxdb--------------------------------");
List<Map<String, Object>> params1 = new ArrayList<>(); List<Map<String, Object>> params1 = new ArrayList<>();
List<Map<String, Object>> requestParams = new ArrayList<>(); List<Map<String, Object>> requestParams = new ArrayList<>();
String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointVarCorrelation.getProcessIndexAddress(),startTime,endTime); String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointVarCorrelation.getProcessIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList1 = influxdbUtil.query(sql); List<Map<String, Object>> returnList1 = influxdbUtil.query(sql);
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -459,9 +480,9 @@ public class CommonServiceImpl { ...@@ -459,9 +480,9 @@ public class CommonServiceImpl {
logger.info("---------------------------------光伏相关性---------分析变量与工况变量相关性分析算法开始----------------------------------------"); logger.info("---------------------------------光伏相关性---------分析变量与工况变量相关性分析算法开始----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkxgxfxkey, requestParams); realParams.put(gkxgxfxkey, requestParams);
String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurlpv).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkxgxfxurlpv).body(JSON.toJSONString(realParams)).execute().body();
if (repsonse.contains("\"status\":200")) { if (response.contains("\"status\":200") && response.contains("rows")) {
JSONObject jsonObject = JSONObject.parseObject(repsonse); JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject result = (JSONObject) jsonObject.get("result"); JSONObject result = (JSONObject) jsonObject.get("result");
JSONObject result1 = (JSONObject) result.get("result1"); JSONObject result1 = (JSONObject) result.get("result1");
JSONArray rows = (JSONArray) result1.get("rows"); JSONArray rows = (JSONArray) result1.get("rows");
...@@ -471,7 +492,7 @@ public class CommonServiceImpl { ...@@ -471,7 +492,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------"); logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
} }
try { try {
logger.info("response----光伏相关性---------" + repsonse); logger.info("response----光伏相关性---------" + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info("----------------------------------光伏相关性--------分析变量与工况变量相关性分析算法结束----------------------------------------"); logger.info("----------------------------------光伏相关性--------分析变量与工况变量相关性分析算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -514,23 +535,30 @@ public class CommonServiceImpl { ...@@ -514,23 +535,30 @@ public class CommonServiceImpl {
myServiceThread.start(); myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.FAN_ZXZ.getKey(), myServiceThread); cacheExecInfo.put(SmartAnalyseEnum.FAN_ZXZ.getKey(), myServiceThread);
} }
return result; return result;
} }
//中心值计算-风电
//中心值计算-风电
public void getFanConditionVariablesByTimeAnalyse1(String startTime, String endTime) { public void getFanConditionVariablesByTimeAnalyse1(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime); try {
String endTimeUTC =getUtcTimeString(endTime);
HashMap<String, List<IdxBizFanPointProcessVariableClassification>> IdxBizFanPointProcessVariableClassificationHashMap = getIdxBizFanPointProcessVariableClassificationListOfAnaLyse(); String startTimeUTC = getUtcTimeString(startTime);
IdxBizFanPointProcessVariableClassificationHashMap.keySet().forEach(s -> { String endTimeUTC = getUtcTimeString(endTime);
List<IdxBizFanPointProcessVariableClassification> list = IdxBizFanPointProcessVariableClassificationHashMap.get(s); HashMap<String, List<IdxBizFanPointProcessVariableClassification>> IdxBizFanPointProcessVariableClassificationHashMap = getIdxBizFanPointProcessVariableClassificationListOfAnaLyse();
list.forEach(IdxBizFanPointProcessVariableClassification -> { IdxBizFanPointProcessVariableClassificationHashMap.keySet().forEach(s -> {
List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", IdxBizFanPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", IdxBizFanPointProcessVariableClassification.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3")); List<IdxBizFanPointProcessVariableClassification> list = IdxBizFanPointProcessVariableClassificationHashMap.get(s);
if (gongkuangList.size() > 0) { list.forEach(IdxBizFanPointProcessVariableClassification -> {
foreachHandlerConditionVariabAnalyse1Fan(s, gongkuangList, startTimeUTC, endTimeUTC, IdxBizFanPointProcessVariableClassification); List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", IdxBizFanPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", IdxBizFanPointProcessVariableClassification.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3"));
} if (gongkuangList.size() > 0) {
foreachHandlerConditionVariabAnalyse1Fan(s, gongkuangList, startTimeUTC, endTimeUTC, IdxBizFanPointProcessVariableClassification);
}
});
}); });
}); cacheExecInfo.remove(SmartAnalyseEnum.FAN_ZXZ.getKey());
cacheExecInfo.remove(SmartAnalyseEnum.FAN_ZXZ.getKey()); } catch (Exception exception) {
cacheExecInfo.remove(SmartAnalyseEnum.FAN_ZXZ.getKey());
}
} }
public String getPvConditionVariablesByTimeAnalyse1Thread(String startTime, String endTime) { public String getPvConditionVariablesByTimeAnalyse1Thread(String startTime, String endTime) {
...@@ -542,29 +570,36 @@ public class CommonServiceImpl { ...@@ -542,29 +570,36 @@ public class CommonServiceImpl {
myServiceThread.start(); myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.PV_ZXZ.getKey(), myServiceThread); cacheExecInfo.put(SmartAnalyseEnum.PV_ZXZ.getKey(), myServiceThread);
} }
return result; return result;
} }
//中心值计算-光伏 //中心值计算-光伏
public void getPvConditionVariablesByTimeAnalyse1(String startTime, String endTime) { public void getPvConditionVariablesByTimeAnalyse1(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime); try {
String endTimeUTC =getUtcTimeString(endTime);
HashMap<String, List<IdxBizPvPointProcessVariableClassification>> idxBizPvPointProcessVariableClassificationHashMap = getIdxBizPvPointProcessVariableClassificationListOfAnaLyse();
idxBizPvPointProcessVariableClassificationHashMap.keySet().forEach(s -> { String startTimeUTC = getUtcTimeString(startTime);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationHashMap.get(s); String endTimeUTC = getUtcTimeString(endTime);
list.forEach(idxBizPvPointProcessVariableClassification -> { HashMap<String, List<IdxBizPvPointProcessVariableClassification>> idxBizPvPointProcessVariableClassificationHashMap = getIdxBizPvPointProcessVariableClassificationListOfAnaLyse();
List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", idxBizPvPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", idxBizPvPointProcessVariableClassification.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3")); idxBizPvPointProcessVariableClassificationHashMap.keySet().forEach(s -> {
if (gongkuangList.size() > 0) { List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationHashMap.get(s);
foreachHandlerConditionVariabAnalyse1Pv(s, gongkuangList, startTimeUTC, endTimeUTC, idxBizPvPointProcessVariableClassification); list.forEach(idxBizPvPointProcessVariableClassification -> {
} List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationMapper.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", idxBizPvPointProcessVariableClassification.getGatewayId()).eq("ANALYSIS_POINT_ID", idxBizPvPointProcessVariableClassification.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3"));
if (gongkuangList.size() > 0) {
foreachHandlerConditionVariabAnalyse1Pv(s, gongkuangList, startTimeUTC, endTimeUTC, idxBizPvPointProcessVariableClassification);
}
});
}); });
}); cacheExecInfo.remove(SmartAnalyseEnum.PV_ZXZ.getKey());
cacheExecInfo.remove(SmartAnalyseEnum.PV_ZXZ.getKey()); } catch (Exception exception) {
cacheExecInfo.remove(SmartAnalyseEnum.PV_ZXZ.getKey());
}
} }
//中心值参数组装-风电 //中心值参数组装-风电
public void foreachHandlerConditionVariabAnalyse1Fan(String tableName, List<IdxBizFanPointVarCorrelation> list, String startTime, String endTime, IdxBizFanPointProcessVariableClassification IdxBizFanPointProcessVariableClassification) { public void foreachHandlerConditionVariabAnalyse1Fan(String tableName, List<IdxBizFanPointVarCorrelation> list, String startTime, String endTime, IdxBizFanPointProcessVariableClassification IdxBizFanPointProcessVariableClassification) {
String sql0 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, IdxBizFanPointProcessVariableClassification.getIndexAddress(),startTime,endTime); String sql0 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, IdxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList = influxdbUtil.query(sql0); List<Map<String, Object>> returnList = influxdbUtil.query(sql0);
List<Map<String, Object>> params = new ArrayList<>(); List<Map<String, Object>> params = new ArrayList<>();
returnList.forEach((k) -> { returnList.forEach((k) -> {
...@@ -577,9 +612,9 @@ public class CommonServiceImpl { ...@@ -577,9 +612,9 @@ public class CommonServiceImpl {
List<Map<String, Object>> params1 = new ArrayList<>(); List<Map<String, Object>> params1 = new ArrayList<>();
List<Map<String, Object>> requestParams = new ArrayList<>(); List<Map<String, Object>> requestParams = new ArrayList<>();
// String sql = String.format("select value from %s where address='%s' and where time >= '%s' and where time <= '%s' ", tableName, IdxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime); // String sql = String.format("select value from %s where address='%s' and where time >= '%s' and where time <= '%s' ", tableName, IdxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(0).getProcessIndexAddress(),startTime,endTime); String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(0).getProcessIndexAddress(), startTime, endTime);
String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(1).getProcessIndexAddress(),startTime,endTime); String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(1).getProcessIndexAddress(), startTime, endTime);
String sql2 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(2).getProcessIndexAddress(),startTime,endTime); String sql2 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(2).getProcessIndexAddress(), startTime, endTime);
List<HashMap<String, Object>> values = new ArrayList<>(); List<HashMap<String, Object>> values = new ArrayList<>();
List<String> processPointIds = list.stream().map(idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList()); List<String> processPointIds = list.stream().map(idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList());
List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds)); List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds));
...@@ -659,22 +694,22 @@ public class CommonServiceImpl { ...@@ -659,22 +694,22 @@ public class CommonServiceImpl {
realParams.put(gkzxzjskey2, requestParams); realParams.put(gkzxzjskey2, requestParams);
logger.info("------------------------------风机中心值------请求参数---------------------------------------" + JSON.toJSONString(realParams)); logger.info("------------------------------风机中心值------请求参数---------------------------------------" + JSON.toJSONString(realParams));
String response = HttpUtil.createPost(baseUrl + gkzxzjsurlfan).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkzxzjsurlfan).body(JSON.toJSONString(realParams)).execute().body();
if (response.contains("\"status\":200")) { if (response.contains("\"status\":200") && response.contains("rows")) {
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject result = (JSONObject) jsonObject.get("result"); JSONObject result = (JSONObject) jsonObject.get("result");
JSONObject result1 = (JSONObject) result.get("result1"); JSONObject result1 = (JSONObject) result.get("result1");
JSONArray rows = (JSONArray) result1.get("rows"); JSONArray rows = (JSONArray) result1.get("rows");
JSONObject resultValues = rows.getJSONObject(0); JSONObject resultValues = rows.getJSONObject(0);
idxBizFanPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizFanPointVarCentralValue>().eq("ANALYSIS_POINT_ID",resultValues.get("analysisVariableId"))); idxBizFanPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizFanPointVarCentralValue>().eq("ANALYSIS_POINT_ID", resultValues.get("analysisVariableId")));
for (int i = 0; i <rows.size() ; i++) { for (int i = 0; i < rows.size(); i++) {
JSONObject idxCentralValue = rows.getJSONObject(i); JSONObject idxCentralValue = rows.getJSONObject(i);
IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue =new IdxBizFanPointVarCentralValue(); IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = new IdxBizFanPointVarCentralValue();
idxBizFanPointVarCentralValue.setProcess1Min(idxCentralValue.getDoubleValue("process1Min")); idxBizFanPointVarCentralValue.setProcess1Min(idxCentralValue.getDoubleValue("process1Min"));
idxBizFanPointVarCentralValue.setProcess2Min(idxCentralValue.getDoubleValue("process2Min")); idxBizFanPointVarCentralValue.setProcess2Min(idxCentralValue.getDoubleValue("process2Min"));
idxBizFanPointVarCentralValue.setProcess3Min(idxCentralValue.getDoubleValue("process3Min")); idxBizFanPointVarCentralValue.setProcess3Min(idxCentralValue.getDoubleValue("process3Min"));
idxBizFanPointVarCentralValue.setProcess1Max(idxCentralValue.getDoubleValue("process1Max")); idxBizFanPointVarCentralValue.setProcess1Max(idxCentralValue.getDoubleValue("process1Max"));
idxBizFanPointVarCentralValue.setPorcess2Max(idxCentralValue.getDoubleValue("process1Max")); idxBizFanPointVarCentralValue.setPorcess2Max(idxCentralValue.getDoubleValue("process2Max"));
idxBizFanPointVarCentralValue.setProcess3Max(idxCentralValue.getDoubleValue("process1Max")); idxBizFanPointVarCentralValue.setProcess3Max(idxCentralValue.getDoubleValue("process3Max"));
idxBizFanPointVarCentralValue.setAnalysisPointId(idxCentralValue.getString("analysisVariableId")); idxBizFanPointVarCentralValue.setAnalysisPointId(idxCentralValue.getString("analysisVariableId"));
idxBizFanPointVarCentralValue.setAnalysisPointName(IdxBizFanPointProcessVariableClassification.getPointName()); idxBizFanPointVarCentralValue.setAnalysisPointName(IdxBizFanPointProcessVariableClassification.getPointName());
idxBizFanPointVarCentralValue.setProcessPoint1Id(idxCentralValue.getString("processVariable1Id")); idxBizFanPointVarCentralValue.setProcessPoint1Id(idxCentralValue.getString("processVariable1Id"));
...@@ -696,7 +731,7 @@ public class CommonServiceImpl { ...@@ -696,7 +731,7 @@ public class CommonServiceImpl {
} }
try { try {
logger.info("------------------风机中心值--repsonse: " + response); logger.info("------------------风机中心值--response: " + response);
TimeUnit.SECONDS.sleep(zxzsleepTime); TimeUnit.SECONDS.sleep(zxzsleepTime);
logger.info("-----------------------------------风机中心值-------调用中心值计算算法结束----------------------------------------"); logger.info("-----------------------------------风机中心值-------调用中心值计算算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -707,7 +742,7 @@ public class CommonServiceImpl { ...@@ -707,7 +742,7 @@ public class CommonServiceImpl {
//中心值参数组装-光伏 //中心值参数组装-光伏
public void foreachHandlerConditionVariabAnalyse1Pv(String tableName, List<IdxBizPvPointVarCorrelation> list, String startTime, String endTime, IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification) { public void foreachHandlerConditionVariabAnalyse1Pv(String tableName, List<IdxBizPvPointVarCorrelation> list, String startTime, String endTime, IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification) {
String sql0 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress(),startTime,endTime); String sql0 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress(), startTime, endTime);
List<Map<String, Object>> returnList = influxdbUtil.query(sql0); List<Map<String, Object>> returnList = influxdbUtil.query(sql0);
List<Map<String, Object>> params = new ArrayList<>(); List<Map<String, Object>> params = new ArrayList<>();
returnList.forEach((k) -> { returnList.forEach((k) -> {
...@@ -719,9 +754,9 @@ public class CommonServiceImpl { ...@@ -719,9 +754,9 @@ public class CommonServiceImpl {
logger.info("-----------------------------------光伏中心值---------开始查询influxdb--------------------------------"); logger.info("-----------------------------------光伏中心值---------开始查询influxdb--------------------------------");
List<Map<String, Object>> params1 = new ArrayList<>(); List<Map<String, Object>> params1 = new ArrayList<>();
List<Map<String, Object>> requestParams = new ArrayList<>(); List<Map<String, Object>> requestParams = new ArrayList<>();
String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(0).getProcessIndexAddress(),startTime,endTime); String sql = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(0).getProcessIndexAddress(), startTime, endTime);
String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(1).getProcessIndexAddress(),startTime,endTime); String sql1 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(1).getProcessIndexAddress(), startTime, endTime);
String sql2 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(2).getProcessIndexAddress(),startTime,endTime); String sql2 = String.format("select value from %s where address='%s' and time >= '%s' and time <= '%s' ", tableName, list.get(2).getProcessIndexAddress(), startTime, endTime);
List<HashMap<String, Object>> values = new ArrayList<>(); List<HashMap<String, Object>> values = new ArrayList<>();
List<String> processPointIds = list.stream().map(idxBizPvPointVarCorrelation -> idxBizPvPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList()); List<String> processPointIds = list.stream().map(idxBizPvPointVarCorrelation -> idxBizPvPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList());
List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds)); List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds));
...@@ -800,22 +835,22 @@ public class CommonServiceImpl { ...@@ -800,22 +835,22 @@ public class CommonServiceImpl {
realParams.put(gkzxzjskey1, values); realParams.put(gkzxzjskey1, values);
realParams.put(gkzxzjskey2, requestParams); realParams.put(gkzxzjskey2, requestParams);
String response = HttpUtil.createPost(baseUrl + gkzxzjsurlpv).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkzxzjsurlpv).body(JSON.toJSONString(realParams)).execute().body();
if (response.contains("\"status\":200")) { if (response.contains("\"status\":200") && response.contains("rows")) {
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject result = (JSONObject) jsonObject.get("result"); JSONObject result = (JSONObject) jsonObject.get("result");
JSONObject result1 = (JSONObject) result.get("result1"); JSONObject result1 = (JSONObject) result.get("result1");
JSONArray rows = (JSONArray) result1.get("rows"); JSONArray rows = (JSONArray) result1.get("rows");
JSONObject resultValues = rows.getJSONObject(0); JSONObject resultValues = rows.getJSONObject(0);
idxBizPvPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizPvPointVarCentralValue>().eq("ANALYSIS_POINT_ID",resultValues.get("analysisVariableId"))); idxBizPvPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizPvPointVarCentralValue>().eq("ANALYSIS_POINT_ID", resultValues.get("analysisVariableId")));
for (int i = 0; i <rows.size() ; i++) { for (int i = 0; i < rows.size(); i++) {
JSONObject idxCentralValue = rows.getJSONObject(i); JSONObject idxCentralValue = rows.getJSONObject(i);
IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue =new IdxBizPvPointVarCentralValue(); IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue = new IdxBizPvPointVarCentralValue();
idxBizPvPointVarCentralValue.setProcess1Min(idxCentralValue.getDoubleValue("process1Min")); idxBizPvPointVarCentralValue.setProcess1Min(idxCentralValue.getDoubleValue("process1Min"));
idxBizPvPointVarCentralValue.setProcess2Min(idxCentralValue.getDoubleValue("process2Min")); idxBizPvPointVarCentralValue.setProcess2Min(idxCentralValue.getDoubleValue("process2Min"));
idxBizPvPointVarCentralValue.setProcess3Min(idxCentralValue.getDoubleValue("process3Min")); idxBizPvPointVarCentralValue.setProcess3Min(idxCentralValue.getDoubleValue("process3Min"));
idxBizPvPointVarCentralValue.setProcess1Max(idxCentralValue.getDoubleValue("process1Max")); idxBizPvPointVarCentralValue.setProcess1Max(idxCentralValue.getDoubleValue("process1Max"));
idxBizPvPointVarCentralValue.setProcess2Max(idxCentralValue.getDoubleValue("process1Max")); idxBizPvPointVarCentralValue.setProcess2Max(idxCentralValue.getDoubleValue("process2Max"));
idxBizPvPointVarCentralValue.setProcess3Max(idxCentralValue.getDoubleValue("process1Max")); idxBizPvPointVarCentralValue.setProcess3Max(idxCentralValue.getDoubleValue("process3Max"));
idxBizPvPointVarCentralValue.setAnalysisPointId(idxCentralValue.getString("analysisVariableId")); idxBizPvPointVarCentralValue.setAnalysisPointId(idxCentralValue.getString("analysisVariableId"));
idxBizPvPointVarCentralValue.setAnalysisPointIdName(idxBizPvPointProcessVariableClassification.getPointName()); idxBizPvPointVarCentralValue.setAnalysisPointIdName(idxBizPvPointProcessVariableClassification.getPointName());
idxBizPvPointVarCentralValue.setProcessPoint1Id(idxCentralValue.getString("processVariable1Id")); idxBizPvPointVarCentralValue.setProcessPoint1Id(idxCentralValue.getString("processVariable1Id"));
...@@ -836,7 +871,7 @@ public class CommonServiceImpl { ...@@ -836,7 +871,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------光伏中心值::中心值更新业务表成功----------------------------------------"); logger.info("------------------------------------------光伏中心值::中心值更新业务表成功----------------------------------------");
} }
try { try {
logger.info("-------------光伏中心值-------repsonse: " + response); logger.info("-------------光伏中心值-------response: " + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info("-----------------------------------光伏中心值-------调用中心值计算算法结束----------------------------------------"); logger.info("-----------------------------------光伏中心值-------调用中心值计算算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -975,9 +1010,7 @@ public class CommonServiceImpl { ...@@ -975,9 +1010,7 @@ public class CommonServiceImpl {
} }
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() && if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() && idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max() && idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max() &&
idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
map.put("analysisVariable", value4); map.put("analysisVariable", value4);
map.put("stdDev", idxBizUhef.getAnalysisStdDev()); map.put("stdDev", idxBizUhef.getAnalysisStdDev());
map.put("centerValue", idxBizUhef.getAnalysisCenterValue()); map.put("centerValue", idxBizUhef.getAnalysisCenterValue());
...@@ -991,36 +1024,33 @@ public class CommonServiceImpl { ...@@ -991,36 +1024,33 @@ public class CommonServiceImpl {
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey1, values); realParams.put(gkzxzjskey1, values);
String response = HttpUtil.createPost(baseUrl + jkzsjsfjurl).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + jkzsjsfjurl).body(JSON.toJSONString(realParams)).execute().body();
logger.info("--------------------repsonse: "+response);
logger.info("------------------------------------------调用健康指数计算算法结束----------------------------------------");
JSONObject result = JSON.parseObject(response).getJSONObject("result"); JSONObject result = JSON.parseObject(response).getJSONObject("result");
if (null != result){ if (null != result) {
JSONArray jsonArray = result.getJSONObject("result1").getJSONArray("rows"); JSONObject jsonObject = result.getJSONObject("result1").getJSONObject("rows");
List<JSONObject> jsonObjects = jsonArray.toJavaList(JSONObject.class); List<JSONObject> jsonObjects = JSON.parseArray(JSON.toJSONString(jsonObject), JSONObject.class);
String s = JSON.toJSONString(result.getJSONObject("result1").getString("rows"));
// List<JSONObject> jsonObjects = JSON.parseArray(s, JSONObject.class);
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
jsonObjects.stream().forEach(e-> ids.add(e.getString("analysisVariableId"))); jsonObjects.stream().forEach(e -> ids.add(e.getString("analysisVariableId")));
LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizFanPointProcessVariableClassification::getSequenceNbr,ids); queryWrapper.in(IdxBizFanPointProcessVariableClassification::getSequenceNbr, ids);
List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationMapper.selectList(queryWrapper); List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationMapper.selectList(queryWrapper);
List<IdxBizFanHealthIndex> idxBizFanHealthIndexs = new ArrayList<>(); List<IdxBizFanHealthIndex> idxBizFanHealthIndexs = new ArrayList<>();
for (IdxBizFanPointProcessVariableClassification obj : list) { for (IdxBizFanPointProcessVariableClassification obj : list) {
for (JSONObject object : jsonObjects) { for (JSONObject object : jsonObjects) {
if (obj.getSequenceNbr().equals(object.getString("analysisVariableId"))){ if (obj.getSequenceNbr().equals(object.getString("analysisVariableId"))) {
IdxBizFanHealthIndex idxBizFanHealthIndex = new IdxBizFanHealthIndex(); IdxBizFanHealthIndex idxBizFanHealthIndex = new IdxBizFanHealthIndex();
BeanUtils.copyProperties(obj,idxBizFanHealthIndex); BeanUtils.copyProperties(idxBizFanHealthIndex, obj);
idxBizFanHealthIndex.setHealthIndex(object.getDouble("indexValue")); idxBizFanHealthIndex.setHealthIndex(object.getDouble("indexValue"));
idxBizFanHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr()); idxBizFanHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizFanHealthIndex.setRecDate(time); idxBizFanHealthIndex.setRecDate(time);
idxBizFanHealthIndex.setSequenceNbr(null); idxBizFanHealthIndex.setSequenceNbr(null);
idxBizFanHealthIndex.setRecDate(new Date());
//获取健康指数对应等级 //获取健康指数对应等级
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType,"设备"); query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus,obj.getStation()); query.eq(IdxBizFanHealthLevel::getStatus, obj.getStation());
query.le(IdxBizFanHealthLevel::getGroupLowerLimit,object.getDouble("indexValue")); query.le(IdxBizFanHealthLevel::getGroupLowerLimit, object.getDouble("indexValue"));
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit,object.getDouble("indexValue")); query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, object.getDouble("indexValue"));
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query); IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel()); idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
idxBizFanHealthIndex.setAnalysisType("按时刻"); idxBizFanHealthIndex.setAnalysisType("按时刻");
...@@ -1030,8 +1060,14 @@ public class CommonServiceImpl { ...@@ -1030,8 +1060,14 @@ public class CommonServiceImpl {
} }
} }
idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs); idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs);
} }
try {
logger.info("--------------------response: " + response);
logger.info("------------------------------------------调用健康指数计算算法结束----------------------------------------");
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
...@@ -1071,7 +1107,7 @@ public class CommonServiceImpl { ...@@ -1071,7 +1107,7 @@ public class CommonServiceImpl {
for (IdxBizPvPointProcessVariableClassificationDto datum : data) { for (IdxBizPvPointProcessVariableClassificationDto datum : data) {
for (ESEquipments equipment : equipments) { for (ESEquipments equipment : equipments) {
if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())){ if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
datum.setCurrentValue(equipment.getValueDouble()); datum.setCurrentValue(equipment.getValueDouble());
} }
} }
...@@ -1079,7 +1115,7 @@ public class CommonServiceImpl { ...@@ -1079,7 +1115,7 @@ public class CommonServiceImpl {
LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper); List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper);
List< Map<String, Object>> datas = new ArrayList<>(); List<Map<String, Object>> datas = new ArrayList<>();
Map<String, Map<String, Object>> resultMap = new HashMap<>(); Map<String, Map<String, Object>> resultMap = new HashMap<>();
for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) { for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) {
double value1 = 0.00; double value1 = 0.00;
...@@ -1087,7 +1123,7 @@ public class CommonServiceImpl { ...@@ -1087,7 +1123,7 @@ public class CommonServiceImpl {
double value3 = 0.00; double value3 = 0.00;
double value4 = 0.00; double value4 = 0.00;
for (IdxBizPvPointProcessVariableClassificationDto datum : data) { for (IdxBizPvPointProcessVariableClassificationDto datum : data) {
if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())){ if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) {
value1 = datum.getCurrentValue(); value1 = datum.getCurrentValue();
} }
if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) { if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
...@@ -1101,14 +1137,12 @@ public class CommonServiceImpl { ...@@ -1101,14 +1137,12 @@ public class CommonServiceImpl {
} }
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() && if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() && idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getProcess2Max() && idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getProcess2Max() && map.put("analysisVariable", value4);
idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()){ map.put("stdDev", idxBizUhef.getAnalysisStdDev());
map.put("analysisVariable",value4); map.put("centerValue", idxBizUhef.getAnalysisCenterValue());
map.put("stdDev",idxBizUhef.getAnalysisStdDev()); map.put("analysisVariableId", idxBizUhef.getAnalysisPointId());
map.put("centerValue",idxBizUhef.getAnalysisCenterValue()); resultMap.put(idxBizUhef.getAnalysisPointId(), map);
map.put("analysisVariableId",idxBizUhef.getAnalysisPointId());
resultMap.put(idxBizUhef.getAnalysisPointId(),map);
} }
} }
Collection<Map<String, Object>> values = resultMap.values(); Collection<Map<String, Object>> values = resultMap.values();
...@@ -1118,30 +1152,30 @@ public class CommonServiceImpl { ...@@ -1118,30 +1152,30 @@ public class CommonServiceImpl {
realParams.put(gkzxzjskey1, values); realParams.put(gkzxzjskey1, values);
String response = HttpUtil.createPost(baseUrl + jkzsgfurl).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + jkzsgfurl).body(JSON.toJSONString(realParams)).execute().body();
JSONObject result = JSON.parseObject(response).getJSONObject("result"); JSONObject result = JSON.parseObject(response).getJSONObject("result");
if (null != result){ if (null != result) {
JSONObject jsonObject =result .getJSONObject("result1").getJSONObject("rows"); JSONObject jsonObject = result.getJSONObject("result1").getJSONObject("rows");
List<JSONObject> jsonObjects = JSON.parseArray(JSON.toJSONString(jsonObject), JSONObject.class); List<JSONObject> jsonObjects = JSON.parseArray(JSON.toJSONString(jsonObject), JSONObject.class);
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
jsonObjects.stream().forEach(e-> ids.add(e.getString("analysisVariableId"))); jsonObjects.stream().forEach(e -> ids.add(e.getString("analysisVariableId")));
LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizPvPointProcessVariableClassification::getSequenceNbr,ids); queryWrapper.in(IdxBizPvPointProcessVariableClassification::getSequenceNbr, ids);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationMapper.selectList(queryWrapper); List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationMapper.selectList(queryWrapper);
List<IdxBizPvHealthIndex> idxBizPvHealthIndexs = new ArrayList<>(); List<IdxBizPvHealthIndex> idxBizPvHealthIndexs = new ArrayList<>();
for (IdxBizPvPointProcessVariableClassification obj : list) { for (IdxBizPvPointProcessVariableClassification obj : list) {
for (JSONObject object : jsonObjects) { for (JSONObject object : jsonObjects) {
if (obj.getSequenceNbr().equals(object.getString("analysisVariableId"))){ if (obj.getSequenceNbr().equals(object.getString("analysisVariableId"))) {
IdxBizPvHealthIndex idxBizFanHealthIndex = new IdxBizPvHealthIndex(); IdxBizPvHealthIndex idxBizFanHealthIndex = new IdxBizPvHealthIndex();
BeanUtils.copyProperties(idxBizFanHealthIndex,obj); BeanUtils.copyProperties(idxBizFanHealthIndex, obj);
idxBizFanHealthIndex.setHealthIndex(object.getDouble("indexValue")); idxBizFanHealthIndex.setHealthIndex(object.getDouble("indexValue"));
idxBizFanHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr()); idxBizFanHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizFanHealthIndex.setRecDate(time); idxBizFanHealthIndex.setRecDate(time);
//获取健康指数对应等级 //获取健康指数对应等级
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType,"设备"); query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizPvHealthLevel::getStatus,obj.getStation()); query.eq(IdxBizPvHealthLevel::getStatus, obj.getStation());
query.le(IdxBizPvHealthLevel::getGroupLowerLimit,object.getDouble("indexValue")); query.le(IdxBizPvHealthLevel::getGroupLowerLimit, object.getDouble("indexValue"));
query.ge(IdxBizPvHealthLevel::getGroupUpperLimit,object.getDouble("indexValue")); query.ge(IdxBizPvHealthLevel::getGroupUpperLimit, object.getDouble("indexValue"));
IdxBizPvHealthLevel idxBizFanHealthLevel = idxBizPvHealthLevelMapper.selectOne(query); IdxBizPvHealthLevel idxBizFanHealthLevel = idxBizPvHealthLevelMapper.selectOne(query);
idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel()); idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
idxBizFanHealthIndex.setAnalysisType("按时刻"); idxBizFanHealthIndex.setAnalysisType("按时刻");
...@@ -1154,7 +1188,7 @@ public class CommonServiceImpl { ...@@ -1154,7 +1188,7 @@ public class CommonServiceImpl {
} }
try { try {
logger.info("--------------------repsonse: " + response); logger.info("--------------------response: " + response);
logger.info("------------------------------------------调用健康指数计算算法结束----------------------------------------"); logger.info("------------------------------------------调用健康指数计算算法结束----------------------------------------");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
......
...@@ -29,12 +29,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; ...@@ -29,12 +29,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator; import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest; import com.yeejoin.amos.component.robot.BadRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.runtime.directive.Break;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
...@@ -45,13 +41,11 @@ import org.springframework.util.ObjectUtils; ...@@ -45,13 +41,11 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.io.IOException; import java.io.File;
import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.parseArray;
/** /**
* @description: * @description:
...@@ -102,6 +96,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -102,6 +96,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired @Autowired
EmqKeeper emqKeeper; EmqKeeper emqKeeper;
//风机状态列表
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
@Value("${pictureUrl}") @Value("${pictureUrl}")
String pictureUrl; String pictureUrl;
...@@ -906,12 +903,16 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -906,12 +903,16 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public void getListByFJ(String gatewayId,String werks,String stationId){ public void getListByFJ(String gatewayId,String werks,String stationId){
HashMap<String,String> fanstatutsHashMap = new HashMap<>();
String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='瞬时风速' "; String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='瞬时风速' ";
String sql1 = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='有功功率'"; String sql1 = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='有功功率'";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> listData1 = influxDButils.getListData(sql1, IndicatorsDto.class); List<IndicatorsDto> listData1 = influxDButils.getListData(sql1, IndicatorsDto.class);
TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机"); TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机");
List<Map<String,Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationWerks(werks, tpriDmpDatabook.getDataid().toString()); List<Map<String,Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationWerks(werks, tpriDmpDatabook.getDataid().toString());
//获取风机列表
List<IndexDto> fanStatusList = getFanStatusList(stationId);
fanStatusList.forEach(indexDto -> {fanstatutsHashMap.put(indexDto.getEquipmentNumber(),indexDto.getState());});
int i = 0; int i = 0;
for (Map<String, Object> dataMap : dataMaps) { for (Map<String, Object> dataMap : dataMaps) {
List<String> numList = Arrays.asList(dataMap.get("equipNum").toString().split(",")); List<String> numList = Arrays.asList(dataMap.get("equipNum").toString().split(","));
...@@ -929,6 +930,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -929,6 +930,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
map.put("title",listDatum.getEquipmentNumber()); map.put("title",listDatum.getEquipmentNumber());
map.put("windSpeed",listDatum.getValue()); map.put("windSpeed",listDatum.getValue());
map.put("power",listDatum.getValueLabel()); map.put("power",listDatum.getValueLabel());
//获取风机状态如果获取到的状态为空-则默认为正常运行状态
String fantStatus = ObjectUtils.isEmpty(fanstatutsHashMap.get(num))?"正常运行":fanstatutsHashMap.get(num);
map.put("url",fanStatusImagePathPrefix + File.separator + "风机-" + fantStatus + ".gif");
statusMaps.add(map); statusMaps.add(map);
} }
} }
......
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