Commit 051c2d1f by foutouren

借用 新的 嘀加上架项目部分代码 来验证开发规范及AI Review的逻辑

0 parents
Showing 60 changed files with 6398 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc-api</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-devrules-api</artifactId>
<version>${devrules.api.version}</version>
<name>rpc-dj-devrules-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.devrules.listing.remote</deploy.scanPackage>
<devrules.api.version>1.0.1-SNAPSHOT</devrules.api.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>rpc-api-deploy-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-devrules-api</artifactId>
<version>${devrules.api.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
package cn.com.glsx.dj.devrules.listing.constant;
import java.math.BigDecimal;
/**
*
* @Title CommonConstants
* @Description:
* @author Suro
* @date 2021/8/4 15:41
* @version V1.0
* @Company:didihu.com.cn
**/
public class CommonConstants {
public static final String DEFAULT_UPDATE_BY = "system";
public static final String DEFAULT_SYSTEM_USER_NAME = "系统";
public static final String DEFAULT_EMPLOYEE_NAME = "管理员";
public static final String SUPER_ADMIN = "超管";
public static final String DEFAULT_FILM_GOOD_TYPES = "[1,4,6,12,14]";
public static final Integer DEFAULT_TEST_MERCHANT_ID = -1;
public static final String DIVERSION_MERCHANT = "流量方";
public static final String PARENT_DIVERSION_MERCHANT = "上级流量方";
public static final String PARTNER_MERCHANT = "服务商";
public static final Integer DEFAULT_BRAND_ID = -1;
public static final String OTHER = "其他";
/**
* 日期正则表达式,格式如2022-04-03
*/
public static final String DATE_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)\\1([0-2]\\d|\\d|30|31)$";
/**
* 月份正则表达式,格式如2022-04
*/
public static final String MONTH_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)$";
/**
* 日期正则表达式,格式如2022-04-03 00:00:00
*/
public static final String DATE_TIME_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)\\1([0-2]\\d|\\d|30|31)\\s\\d{2}(:)\\d{2}(:)\\d{2}$";
public static final BigDecimal ONEHUNDRED_BIGDECIMAL = BigDecimal.valueOf(100);
/**
* 车系是否选中标志位-选中
*/
public static final int SERIES_FLAG_SELECTED = 1;
/**
* 保留两位小数
*/
public static final int SCALE = 2;
public static final String DATE_START_TIME = " 00:00:00";
public static final String DATE_END_TIME = " 23:59:59";
public static final String FIRST_DATE = "-01";
public static final String LAST_DATE = "-31";
public static final String DATE_END_TIME_SECOND_EXCLUDED = " 23:59";
public static final BigDecimal DECIMAL_VALUE_MILLION = BigDecimal.valueOf(1000000);
public static final BigDecimal DECIMAL_VALUE_ALMOST_MILLION = new BigDecimal("999999.99");
}
package cn.com.glsx.dj.devrules.listing.dto;
import java.util.List;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingApproval;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingMerchantRef;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Data
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingApprovalDTO extends GoodsListingApproval {
private static final long serialVersionUID = -8787996244836851112L;
@ApiModelProperty(notes = "流量方列表")
private List<GoodsListingMerchantRef> merchantList;
@ApiModelProperty(notes = "流量方名称模糊搜索")
private String merchantName;
@ApiModelProperty(notes = "单据编号过滤,通过流量方名称模糊查询出来的单据编号")
private List<String> filterBusinessCodeList;
}
package cn.com.glsx.dj.devrules.listing.dto;
import java.util.List;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingDistributionRule;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingExpenseCategoryRule;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingGoodsTypeGroup;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingGoodsTypeGroupRelation;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Data
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingGoodsTypeGroupDTO extends GoodsListingGoodsTypeGroup{
/**
*
*/
private static final long serialVersionUID = -5726238364638899927L;
@ApiModelProperty(notes = "品类下商品列表")
private List<GoodsListingGoodsTypeGroupRelation> goodsTypeGroupRelationList;
@ApiModelProperty(notes = "品类下费用类目规则列表")
private List<GoodsListingExpenseCategoryRule> expenseCategoryRuleList;
@ApiModelProperty(notes = "实际分账设置列表")
private List<GoodsListingDistributionRule> merchantDistributionRules;
@ApiModelProperty(notes = "费用归属设置列表")
private List<GoodsListingDistributionRule> owningMerchantDistributionRules;
}
package cn.com.glsx.dj.devrules.listing.dto;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingMerchantRef;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Data
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingMerchantRefDTO extends GoodsListingMerchantRef {
/**
*
*/
private static final long serialVersionUID = -281416729140522885L;
@ApiModelProperty(notes = "基础场景编码")
private String baseSceneCode;
}
package cn.com.glsx.dj.devrules.listing.dto;
import java.util.List;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingProductBase;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Data
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingProductBaseDTO extends GoodsListingProductBase{
/**
*
*/
private static final long serialVersionUID = 472562419373251956L;
private List<GoodsListingProductDetailDTO> detailList;
}
package cn.com.glsx.dj.devrules.listing.dto;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingProductDetail;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Data
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingProductDetailDTO extends GoodsListingProductDetail {/**
*
*/
private static final long serialVersionUID = -7741593632455959273L;
private String devrulesCode;
}
package cn.com.glsx.dj.devrules.listing.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* 商品上架提交入参,沿用 CreateBusinessApproveDTO 的字段。
*/
@ApiModel(value = "GoodsListingSubmitDTO", description = "商品上架提交DTO")
@Data
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingSubmitDTO {
private static final long serialVersionUID = 7144230950772141291L;
@NotNull
@Size(min = 6, max = 6)
@ApiModelProperty(notes = "基础场景编码(6位)")
private String baseSceneCode;
}
package cn.com.glsx.dj.devrules.listing.dto;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingDivisionRuleAuto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class SaveDivisionBaseRuleDTO implements Serializable{/**
*
*/
private static final long serialVersionUID = -616261931693747012L;
@NotEmpty
@ApiModelProperty(notes="单据编号", required = true)
private String businessCode;
@NotEmpty
@ApiModelProperty(notes="支付渠道开启自动分账与分账时间设置")
private List<GoodsListingDivisionRuleAuto> divisionRuleAutos;
@ApiModelProperty(notes="实际分账4S店商户号,单店模式必传")
private Integer realityShopMerchantId;
@ApiModelProperty(notes="实际分账4S店商户名称,单店模式必传")
private String realityShopMerchantName;
@ApiModelProperty(notes="实际分账4S店商户用户类型,单店模式必传")
private Integer realityShopUserType;
@NotNull
@ApiModelProperty(notes="流量方分配对象级别(1:门店;2:上级)")
private Byte realityShopLevel;
private String updatedBy;
}
package cn.com.glsx.dj.devrules.listing.enums;
import java.util.Objects;
public class GoodsListingEnum {
//操作类型 1-发起 2-驳回 3-审核
public enum LogOperatorType{
//发起
INITIATE((byte) 1, "发起"),
//驳回
REJECT((byte) 2, "驳回"),
//审核
APPROVE((byte) 3, "审核");
private final Byte value;
private final String name;
LogOperatorType(Byte value, String name) {
this.value = value;
this.name = name;
}
public Byte getValue() {
return value;
}
public String getName() {
return name;
}
public static LogOperatorType fromValue(Byte value) {
for (LogOperatorType type : values()) {
if (Objects.equals(type.getValue(), value)) {
return type;
}
}
return null;
}
}
//'确认步骤:1.基础信息,2.上架商品;3.分账配置;4.对账配置;5.预估利润率;
public enum ConfirmStep{
//基础信息
BASE_INFO((byte) 1, "基础信息"),
//上架商品
GOODS((byte) 2, "上架商品"),
//分账配置
SETTLE_CONFIG((byte) 3, "分账配置"),
//对账配置
RECONCILIATION_CONFIG((byte) 4, "对账配置"),
//预估利润率
PROFIT_RATE((byte) 5, "预估利润率");
private final Byte value;
private final String name;
ConfirmStep(Byte value, String name) {
this.value = value;
this.name = name;
}
public Byte getValue() {
return value;
}
public String getName() {
return name;
}
public static ConfirmStep fromValue(Byte value) {
for (ConfirmStep step : values()) {
if (Objects.equals(step.getValue(), value)) {
return step;
}
}
return null;
}
}
//系统状态 0-草稿 1-待审核 2-已审核 3-驳回
public enum SystemStatus{
DRAFT((byte) 0, "草稿"),
PENDING((byte) 1, "待审核"),
APPROVED((byte) 2, "已审核"),
REJECTED((byte) 3, "驳回");
private final Byte value;
private final String name;
SystemStatus(Byte value, String name) {
this.value = value;
this.name = name;
}
public Byte getValue() {
return value;
}
public String getName() {
return name;
}
public static SystemStatus fromValue(Byte value) {
for (SystemStatus status : values()) {
if (Objects.equals(status.getValue(), value)) {
return status;
}
}
return null;
}
}
//上架类型 1-单店模式 2-项目制批量上架
public enum ShelfType {
//单店模式
SINGLE((byte) 1, "单店模式"),
//项目制批量上架
BATCH((byte) 2, "项目制批量上架");
private final Byte value;
private final String name;
ShelfType(Byte value, String name) {
this.value = value;
this.name = name;
}
public Byte getValue() {
return value;
}
public String getName() {
return name;
}
public static ShelfType fromValue(Byte value) {
for (ShelfType type : values()) {
if (Objects.equals(type.getValue(), value)) {
return type;
}
}
return null;
}
}
}
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingApproval", description = "商品上架审批")
@Table(name = "dj_car_life_goods_listing_approval")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingApproval implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5396061001018263048L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 上架类型 1-单店模式 2-项目制批量上架
*/
@ApiModelProperty(name = "shelfType", notes = "上架类型 1-单店模式 2-项目制批量上架")
@Column(name = "shelf_type")
private Byte shelfType;
/**
* 系统状态 0-草稿 1-待审核 2-已审核 3-驳回
*/
@ApiModelProperty(name = "systemStatus", notes = "系统状态 0-草稿 1-待审核 2-已审核 3-驳回")
@Column(name = "system_status")
private Byte systemStatus;
/**
* 驳回原因
*/
@ApiModelProperty(name = "rejectedReason", notes = "驳回原因")
@Column(name = "rejected_reason")
private String rejectedReason;
/**
* 商品上架表excel文件url
*/
@ApiModelProperty(name = "goodsCreateExcel", notes = "商品上架表excel文件url")
@Column(name = "goods_create_excel")
private String goodsCreateExcel;
/**
* 基础场景编码
*/
@ApiModelProperty(name = "baseSceneCode", notes = "基础场景编码")
@Column(name = "base_scene_code")
private String baseSceneCode;
/**
* 确认步骤:1.基础信息,2.上架商品;3.分账配置;4.对账配置;5.预估利润率;
*/
@ApiModelProperty(name = "confirmStep", notes = "确认步骤:1.基础信息,2.上架商品;3.分账配置;4.对账配置;5.预估利润率;")
@Column(name = "confirm_step")
private Byte confirmStep;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingBaseRule", description = "商品上架基础规则")
@Table(name = "dj_car_life_goods_listing_base_rule")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingBaseRule implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2756597249999541809L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 流量方是否线上自动分账
*/
@ApiModelProperty(name = "shopMerchantAutoDivide", notes = "流量方是否线上自动分账")
@Column(name = "shop_merchant_auto_divide")
private String shopMerchantAutoDivide;
/**
* 流量方线上分账对象
*/
@ApiModelProperty(name = "shopMerchantDivideTarget", notes = "流量方线上分账对象")
@Column(name = "shop_merchant_divide_target")
private Byte shopMerchantDivideTarget;
/**
* 服务商是否线上自动分账
*/
@ApiModelProperty(name = "partnerMerchantAutoDivide", notes = "服务商是否线上自动分账")
@Column(name = "partner_merchant_auto_divide")
private String partnerMerchantAutoDivide;
/**
* 服务商线上分账对象
*/
@ApiModelProperty(name = "partnerMerchantDivideTarget", notes = "服务商线上分账对象")
@Column(name = "partner_merchant_divide_target")
private Byte partnerMerchantDivideTarget;
/**
* 服务商2是否线上自动分账
*/
@ApiModelProperty(name = "partnerMerchant2AutoDivide", notes = "服务商2是否线上自动分账")
@Column(name = "partner_merchant2_auto_divide")
private String partnerMerchant2AutoDivide;
/**
* 服务商2线上分账对象
*/
@ApiModelProperty(name = "partnerMerchant2DivideTarget", notes = "服务商2线上分账对象")
@Column(name = "partner_merchant2_divide_target")
private Byte partnerMerchant2DivideTarget;
/**
* 其他费用线上分账对象
*/
@ApiModelProperty(name = "otherFeeDivideTarget", notes = "其他费用线上分账对象")
@Column(name = "other_fee_divide_target")
private Byte otherFeeDivideTarget;
/**
* 一线阳光是否开启线上积分
*/
@ApiModelProperty(name = "firstLineSunshineOnlinePointsFlag", notes = "一线阳光是否开启线上积分")
@Column(name = "first_line_sunshine_online_points_flag")
private String firstLineSunshineOnlinePointsFlag;
/**
* 一线阳光2是否开启线上积分
*/
@ApiModelProperty(name = "firstLineSunshine2OnlinePointsFlag", notes = "一线阳光2是否开启线上积分")
@Column(name = "first_line_sunshine2_online_points_flag")
private String firstLineSunshine2OnlinePointsFlag;
/**
* 实际分账4S店商户号
*/
@ApiModelProperty(name = "realityShopMerchantId", notes = "实际分账4S店商户号")
@Column(name = "reality_shop_merchant_id")
private Integer realityShopMerchantId;
/**
* 实际分账4S店商户名称
*/
@ApiModelProperty(name = "realityShopMerchantName", notes = "实际分账4S店商户名称")
@Column(name = "reality_shop_merchant_name")
private String realityShopMerchantName;
/**
* 实际分账4S店商户用户类型
*/
@ApiModelProperty(name = "realityShopUserType", notes = "实际分账4S店商户用户类型")
@Column(name = "reality_shop_user_type")
private Integer realityShopUserType;
/**
* 流量方分配对象级别(1:门店;2:上级)
*/
@ApiModelProperty(name = "realityShopLevel", notes = "流量方分配对象级别(1:门店;2:上级)")
@Column(name = "reality_shop_level")
private Byte realityShopLevel;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingDistributionRule", description = "商品上架分配规则")
@Table(name = "dj_car_life_goods_listing_distribution_rule")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingDistributionRule implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3795327711616184838L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 商品品类分组id
*/
@ApiModelProperty(name = "goodsTypeGroupId", notes = "商品品类分组id")
@Column(name = "goods_type_group_id")
private Integer goodsTypeGroupId;
/**
* 分账规则类型(1-费用归属设置,2-实际分账设置)
*/
@ApiModelProperty(name = "ruleType", notes = "分账规则类型(1-费用归属设置,2-实际分账设置)")
@Column(name = "rule_type")
private Byte ruleType;
/**
* 分配对象类型(1:平台方;2:服务商;3:4s店)
*/
@ApiModelProperty(name = "targetMerchantType", notes = "分配对象类型(1:平台方;2:服务商;3:4s店)")
@Column(name = "target_merchant_type")
private Byte targetMerchantType;
/**
* 分配对象类型(1:门店;2:上级)
*/
@ApiModelProperty(name = "targetMerchantLevel", notes = "分配对象类型(1:门店;2:上级)")
@Column(name = "target_merchant_level")
private Byte targetMerchantLevel;
/**
* 费用类目id
*/
@ApiModelProperty(name = "expenseCategoryId", notes = "费用类目id")
@Column(name = "expense_category_id")
private Integer expenseCategoryId;
/**
* 费用类目名
*/
@ApiModelProperty(name = "expenseCategoryName", notes = "费用类目名")
@Column(name = "expense_category_name")
private String expenseCategoryName;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingDivisionRuleAuto", description = "商品上架自动分账规则")
@Table(name = "dj_car_life_goods_listing_division_rule_auto")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingDivisionRuleAuto implements Serializable {
/**
*
*/
private static final long serialVersionUID = -3071660165836312115L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 支付渠道id
*/
@ApiModelProperty(name = "paymentChannelId", notes = "支付渠道id")
@Column(name = "payment_channel_id")
private String paymentChannelId;
/**
* 支付渠道名称
*/
@ApiModelProperty(name = "paymentChannelName", notes = "支付渠道名称")
@Column(name = "payment_channel_name")
private String paymentChannelName;
/**
* 分账方式(1线下对账,2线上分账)
*/
@ApiModelProperty(name = "divisionType", notes = "分账方式(1线下对账,2线上分账)")
@Column(name = "division_type")
private Byte divisionType;
/**
* 自动分账标识(Y是,N否)
*/
@ApiModelProperty(name = "autoFlag", notes = "自动分账标识(Y是,N否)")
@Column(name = "auto_flag")
private String autoFlag;
/**
* 分账时间方式(1:T+1,2:每月)
*/
@ApiModelProperty(name = "settleTimeType", notes = "分账时间方式(1:T+1,2:每月)")
@Column(name = "settle_time_type")
private Byte settleTimeType;
/**
* 分账时间每月几号
*/
@ApiModelProperty(name = "settleTime", notes = "分账时间每月几号")
@Column(name = "settle_time")
private Byte settleTime;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingExpenseCategoryRule", description = "商品上架费用类目规则")
@Table(name = "dj_car_life_goods_listing_expense_category_rule")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingExpenseCategoryRule implements Serializable {
/**
*
*/
private static final long serialVersionUID = 518147059573037341L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 商品品类分组id
*/
@ApiModelProperty(name = "goodsTypeGroupId", notes = "商品品类分组id")
@Column(name = "goods_type_group_id")
private Integer goodsTypeGroupId;
/**
* 费用类目id
*/
@ApiModelProperty(name = "expenseCategoryId", notes = "费用类目id")
@Column(name = "expense_category_id")
private Integer expenseCategoryId;
/**
* 费用类目名
*/
@ApiModelProperty(name = "expenseCategoryName", notes = "费用类目名")
@Column(name = "expense_category_name")
private String expenseCategoryName;
/**
* 计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "calculateMode", notes = "计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "calculate_mode")
private Byte calculateMode;
/**
* 计算方式(根据应用对象不同可取值与含义不同)
*/
@ApiModelProperty(name = "expenseCategoryCalculateType", notes = "计算方式(根据应用对象不同可取值与含义不同)")
@Column(name = "expense_category_calculate_type")
private Byte expenseCategoryCalculateType;
/**
* 费用类目计算值(%/元)
*/
@ApiModelProperty(name = "expenseCategoryValue", notes = "费用类目计算值(%/元)")
@Column(name = "expense_category_value")
private BigDecimal expenseCategoryValue;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingGoodsTypeGroup", description = "商品上架商品类型分组")
@Table(name = "dj_car_life_goods_listing_goods_type_group")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingGoodsTypeGroup implements Serializable {
/**
*
*/
private static final long serialVersionUID = -9051123201989809064L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 品类分组类型(1全部品类2品类集合)
*/
@ApiModelProperty(name = "groupType", notes = "品类分组类型(1全部品类2品类集合)")
@Column(name = "group_type")
private Byte groupType;
/**
* 规则类型(1:财务;3:对账)
*/
@ApiModelProperty(name = "ruleType", notes = "规则类型(1:财务;3:对账)")
@Column(name = "rule_type")
private Byte ruleType;
/**
* 分类品类(1:按商品分类;2:按具体商品;3:按商品套餐)
*/
@ApiModelProperty(name = "categoryType", notes = "分类品类(1:按商品分类;2:按具体商品;3:按商品套餐)")
@Column(name = "category_type")
private Byte categoryType;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingGoodsTypeGroupRelation", description = "商品上架商品类型分组关系")
@Table(name = "dj_car_life_goods_listing_goods_type_group_relation")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingGoodsTypeGroupRelation implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6373581807557596995L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 商品品类分组id
*/
@ApiModelProperty(name = "goodsTypeGroupId", notes = "商品品类分组id")
@Column(name = "goods_type_group_id")
private Integer goodsTypeGroupId;
/**
* 升级商品主键ID
*/
@ApiModelProperty(name = "upgradeGoodsId", notes = "升级商品主键ID")
@Column(name = "upgrade_goods_id")
private Integer upgradeGoodsId;
@ApiModelProperty(notes = "商户商品编码")
@Column(name = "merchant_goods_code")
private String merchantGoodsCode;
/**
* 商品ID
*/
@ApiModelProperty(name = "upgradeCommodityCode", notes = "商品ID")
@Column(name = "upgrade_commodity_code")
private String upgradeCommodityCode;
/**
* 升级商品名称
*/
@ApiModelProperty(name = "upgradeGoodsName", notes = "升级商品名称")
@Column(name = "upgrade_goods_name")
private String upgradeGoodsName;
/**
* 商品品类
*/
@ApiModelProperty(name = "goodsType", notes = "商品品类")
@Column(name = "goods_type")
private Integer goodsType;
/**
* 商品品类名
*/
@ApiModelProperty(name = "goodsTypeName", notes = "商品品类名")
@Column(name = "goods_type_name")
private String goodsTypeName;
/**
* 套餐编码
*/
@ApiModelProperty(name = "packageCode", notes = "套餐编码")
@Column(name = "package_code")
private String packageCode;
/**
* 套餐名称
*/
@ApiModelProperty(name = "packageName", notes = "套餐名称")
@Column(name = "package_name")
private String packageName;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingLog", description = "商品上架日志")
@Table(name = "dj_car_life_goods_listing_log")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingLog implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5099758450572109770L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 操作类型 1-发起 2-驳回 3-审核
*/
@ApiModelProperty(name = "operatorType", notes = "操作类型 1-发起 2-驳回 3-审核")
@Column(name = "operator_type")
private Byte operatorType;
/**
* 备注
*/
@ApiModelProperty(name = "remark", notes = "备注")
private String remark;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingMerchantRef", description = "商品上架商户引用")
@Table(name = "dj_car_life_goods_listing_merchant_ref")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingMerchantRef implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4700782766155078577L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 流量方商户号
*/
@ApiModelProperty(name = "merchantId", notes = "流量方商户号")
@Column(name = "merchant_id")
private Integer merchantId;
/**
* 流量方商户名称
*/
@ApiModelProperty(name = "merchantName", notes = "流量方商户名称")
@Column(name = "merchant_name")
private String merchantName;
/**
* 流量方上级商户
*/
@ApiModelProperty(name = "parentMerchantId", notes = "流量方上级商户")
@Column(name = "parent_merchant_id")
private Integer parentMerchantId;
/**
* 流量方上级商户号
*/
@ApiModelProperty(name = "parentMerchantName", notes = "流量方上级商户号")
@Column(name = "parent_merchant_name")
private String parentMerchantName;
/**
* 签约主体商户号
*/
@ApiModelProperty(name = "contractingMerchantId", notes = "签约主体商户号")
@Column(name = "contracting_merchant_id")
private Integer contractingMerchantId;
/**
* 签约主体商户名称
*/
@ApiModelProperty(name = "contractingMerchantName", notes = "签约主体商户名称")
@Column(name = "contracting_merchant_name")
private String contractingMerchantName;
/**
* 园区店商户号
*/
@ApiModelProperty(name = "yqMerchantId", notes = "园区店商户号")
@Column(name = "yq_merchant_id")
private Integer yqMerchantId;
/**
* 园区店商户名称
*/
@ApiModelProperty(name = "yqMerchantName", notes = "园区店商户名称")
@Column(name = "yq_merchant_name")
private String yqMerchantName;
/**
* 服务商商户号
*/
@ApiModelProperty(name = "partnerMerchantId", notes = "服务商商户号")
@Column(name = "partner_merchant_id")
private Integer partnerMerchantId;
/**
* 服务商商户名称
*/
@ApiModelProperty(name = "partnerMerchantName", notes = "服务商商户名称")
@Column(name = "partner_merchant_name")
private String partnerMerchantName;
/**
* 服务商2商户号
*/
@ApiModelProperty(name = "partnerMerchantId2", notes = "服务商2商户号")
@Column(name = "partner_merchant_id2")
private Integer partnerMerchantId2;
/**
* 服务商2商户名称
*/
@ApiModelProperty(name = "partnerMerchantName2", notes = "服务商2商户名称")
@Column(name = "partner_merchant_name2")
private String partnerMerchantName2;
/**
* 上级服务商商户号,会员权益升级时展示
*/
@ApiModelProperty(name = "parentPartnerMerchantId", notes = "上级服务商商户号,会员权益升级时展示")
@Column(name = "parent_partner_merchant_id")
private Integer parentPartnerMerchantId;
/**
* 上级服务商商户名称
*/
@ApiModelProperty(name = "parentPartnerMerchantName", notes = "上级服务商商户名称")
@Column(name = "parent_partner_merchant_name")
private String parentPartnerMerchantName;
/**
* 运营模式 1-直营 0-非直营,会员权益升级时展示
*/
@ApiModelProperty(name = "operationMode", notes = "运营模式 1-直营 0-非直营,会员权益升级时展示")
@Column(name = "operation_mode")
private Byte operationMode;
/**
* 财务规则id
*/
@ApiModelProperty(name = "settleRuleId", notes = "财务规则id")
@Column(name = "settle_rule_id")
private Integer settleRuleId;
/**
* 分账规则id
*/
@ApiModelProperty(name = "divisionRuleId", notes = "分账规则id")
@Column(name = "division_rule_id")
private Integer divisionRuleId;
/**
* 对账规则
*/
@ApiModelProperty(name = "reconciliationRuleId", notes = "对账规则")
@Column(name = "reconciliation_rule_id")
private Integer reconciliationRuleId;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingProductBase", description = "商品上架产品基础信息")
@Table(name = "dj_car_life_goods_listing_product_base")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingProductBase implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2494153876427337240L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 商品类型(1 商品 2套餐)
*/
@ApiModelProperty(name = "productType", notes = "商品类型(1 商品 2套餐)")
@Column(name = "product_type")
private Byte productType;
/**
* 结算方式
*/
@ApiModelProperty(name = "settlementType", notes = "结算方式")
@Column(name = "settlement_type")
private Byte settlementType;
/**
* 产品名称
*/
@ApiModelProperty(name = "productName", notes = "产品名称")
@Column(name = "product_name")
private String productName;
/**
* 销售占比(%)
*/
@ApiModelProperty(name = "salesProportionPercent", notes = "销售占比(%)")
@Column(name = "sales_proportion_percent")
private BigDecimal salesProportionPercent;
/**
* 收入
*/
@ApiModelProperty(name = "revenue", notes = "收入")
private BigDecimal revenue;
/**
* 流量方分润
*/
@ApiModelProperty(name = "trafficShareProfit", notes = "流量方分润")
@Column(name = "traffic_share_profit")
private BigDecimal trafficShareProfit;
/**
* 服务商分润
*/
@ApiModelProperty(name = "serviceProviderProfit", notes = "服务商分润")
@Column(name = "service_provider_profit")
private BigDecimal serviceProviderProfit;
/**
* 嘀加收入
*/
@ApiModelProperty(name = "djRevenue", notes = "嘀加收入")
@Column(name = "dj_revenue")
private BigDecimal djRevenue;
/**
* 嘀加成本
*/
@ApiModelProperty(name = "djCost", notes = "嘀加成本")
@Column(name = "dj_cost")
private BigDecimal djCost;
/**
* 管理层市场费
*/
@ApiModelProperty(name = "managerMarketFee", notes = "管理层市场费")
@Column(name = "manager_market_fee")
private BigDecimal managerMarketFee;
/**
* 管理层市场费1
*/
@ApiModelProperty(name = "managerMarketFee1", notes = "管理层市场费1")
@Column(name = "manager_market_fee1")
private BigDecimal managerMarketFee1;
/**
* 管理层市场费2
*/
@ApiModelProperty(name = "managerMarketFee2", notes = "管理层市场费2")
@Column(name = "manager_market_fee2")
private BigDecimal managerMarketFee2;
/**
* 一线阳光激励费
*/
@ApiModelProperty(name = "firstLineSunshineIncentiveFee", notes = "一线阳光激励费")
@Column(name = "first_line_sunshine_incentive_fee")
private BigDecimal firstLineSunshineIncentiveFee;
/**
* 一线阳光2激励费
*/
@ApiModelProperty(name = "firstLineSunshine2IncentiveFee", notes = "一线阳光2激励费")
@Column(name = "first_line_sunshine2_incentive_fee")
private BigDecimal firstLineSunshine2IncentiveFee;
/**
* 资源费
*/
@ApiModelProperty(name = "resourceFee", notes = "资源费")
@Column(name = "resource_fee")
private BigDecimal resourceFee;
/**
* 人力成本
*/
@ApiModelProperty(name = "laborCost", notes = "人力成本")
@Column(name = "labor_cost")
private BigDecimal laborCost;
/**
* 嘀加毛利
*/
@ApiModelProperty(name = "djGrossProfit", notes = "嘀加毛利")
@Column(name = "dj_gross_profit")
private BigDecimal djGrossProfit;
/**
* 利润率
*/
@ApiModelProperty(name = "profitRate", notes = "利润率")
@Column(name = "profit_rate")
private BigDecimal profitRate;
/**
* 信息是否填写完整(Y:是,N:否)
*/
@ApiModelProperty(name = "integrity", notes = "信息是否填写完整(Y:是,N:否)")
private String integrity;
/**
* 利润率是否计算完成(Y:是,N:否)
*/
@ApiModelProperty(name = "profitRateCalFinish", notes = "利润率是否计算完成(Y:是,N:否)")
@Column(name = "profit_rate_cal_finish")
private String profitRateCalFinish;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingProductDetail", description = "商品上架产品详情")
@Table(name = "dj_car_life_goods_listing_product_detail")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingProductDetail implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7022994695570715425L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 上架产品基础表主键ID
*/
@ApiModelProperty(name = "productBaseId", notes = "上架产品基础表主键ID")
@Column(name = "product_base_id")
private Integer productBaseId;
/**
* 升级商品主键ID
*/
@ApiModelProperty(name = "upgradeGoodsId", notes = "升级商品主键ID")
@Column(name = "upgrade_goods_id")
private Integer upgradeGoodsId;
@ApiModelProperty(notes = "商户商品编码")
@Column(name = "merchant_goods_code")
private String merchantGoodsCode;
/**
* 商品ID
*/
@ApiModelProperty(name = "upgradeCommodityCode", notes = "商品ID")
@Column(name = "upgrade_commodity_code")
private String upgradeCommodityCode;
/**
* 升级商品名称
*/
@ApiModelProperty(name = "upgradeGoodsName", notes = "升级商品名称")
@Column(name = "upgrade_goods_name")
private String upgradeGoodsName;
/**
* 商品别名
*/
@ApiModelProperty(name = "goodsAlias", notes = "商品别名")
@Column(name = "goods_alias")
private String goodsAlias;
/**
* 部位
*/
@ApiModelProperty(name = "position", notes = "部位")
private Integer position;
/**
* 售价
*/
@ApiModelProperty(name = "sellPrice", notes = "售价")
@Column(name = "sell_price")
private BigDecimal sellPrice;
/**
* 最低售价
*/
@ApiModelProperty(name = "minSellPrice", notes = "最低售价")
@Column(name = "min_sell_price")
private BigDecimal minSellPrice;
/**
* 升级产品成本
*/
@ApiModelProperty(name = "upgradeProductCost", notes = "升级产品成本")
@Column(name = "upgrade_product_cost")
private BigDecimal upgradeProductCost;
/**
* 回收成本
*/
@ApiModelProperty(name = "recoveryCost", notes = "回收成本")
@Column(name = "recovery_cost")
private BigDecimal recoveryCost;
/**
* 赠送成本
*/
@ApiModelProperty(name = "giftCost", notes = "赠送成本")
@Column(name = "gift_cost")
private BigDecimal giftCost;
/**
* 第三方成本
*/
@ApiModelProperty(name = "thirdPartyCost", notes = "第三方成本")
@Column(name = "third_party_cost")
private BigDecimal thirdPartyCost;
/**
* 库存模式 1-虚拟、2-实物
*/
@ApiModelProperty(name = "inventoryType", notes = "库存模式 1-虚拟、2-实物")
@Column(name = "inventory_type")
private Byte inventoryType;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingProductReconciliationRuleRef", description = "商品上架产品对账规则引用")
@Table(name = "dj_car_life_goods_listing_product_reconciliation_rule_ref")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingProductReconciliationRuleRef implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5485825245958191408L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 上架产品基础表主键ID
*/
@ApiModelProperty(name = "productBaseId", notes = "上架产品基础表主键ID")
@Column(name = "product_base_id")
private Integer productBaseId;
/**
* 上架产品明细表主键ID
*/
@ApiModelProperty(name = "productDetailId", notes = "上架产品明细表主键ID")
@Column(name = "product_detail_id")
private Integer productDetailId;
/**
* 商品上架对账规则主键ID
*/
@ApiModelProperty(name = "reconciliationRuleId", notes = "商品上架对账规则主键ID")
@Column(name = "reconciliation_rule_id")
private Integer reconciliationRuleId;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingProductSettleRuleRef", description = "商品上架产品结算规则引用")
@Table(name = "dj_car_life_goods_listing_product_settle_rule_ref")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingProductSettleRuleRef implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3393366748847635734L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 上架产品基础表主键ID
*/
@ApiModelProperty(name = "productBaseId", notes = "上架产品基础表主键ID")
@Column(name = "product_base_id")
private Integer productBaseId;
/**
* 上架产品明细表主键ID
*/
@ApiModelProperty(name = "productDetailId", notes = "上架产品明细表主键ID")
@Column(name = "product_detail_id")
private Integer productDetailId;
/**
* 商品上架结算规则主键ID
*/
@ApiModelProperty(name = "settleRuleId", notes = "商品上架结算规则主键ID")
@Column(name = "settle_rule_id")
private Integer settleRuleId;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingReconciliationRule", description = "商品上架对账规则")
@Table(name = "dj_car_life_goods_listing_reconciliation_rule")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingReconciliationRule implements Serializable {
/**
*
*/
private static final long serialVersionUID = -3443751641195501058L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 管理层市场费1计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "managerMarket1CalMode", notes = "管理层市场费1计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "manager_market1_cal_mode")
private Byte managerMarket1CalMode;
/**
* 管理层市场费1计算方式
*/
@ApiModelProperty(name = "managerMarket1CalType", notes = "管理层市场费1计算方式")
@Column(name = "manager_market1_cal_type")
private Byte managerMarket1CalType;
/**
* 管理层市场费1
*/
@ApiModelProperty(name = "managerMarket1CalTypeFee", notes = "管理层市场费1")
@Column(name = "manager_market1_cal_type_fee")
private BigDecimal managerMarket1CalTypeFee;
/**
* 管理层市场费2计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "managerMarket2CalMode", notes = "管理层市场费2计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "manager_market2_cal_mode")
private Byte managerMarket2CalMode;
/**
* 管理层市场费2计算方式
*/
@ApiModelProperty(name = "managerMarket2CalType", notes = "管理层市场费2计算方式")
@Column(name = "manager_market2_cal_type")
private Byte managerMarket2CalType;
/**
* 管理层市场费2
*/
@ApiModelProperty(name = "managerMarket2CalTypeFee", notes = "管理层市场费2")
@Column(name = "manager_market2_cal_type_fee")
private BigDecimal managerMarket2CalTypeFee;
/**
* 一线阳光计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "firstLineSunshineIncentiveFeeCalMode", notes = "一线阳光计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "first_line_sunshine_incentive_fee_cal_mode")
private Byte firstLineSunshineIncentiveFeeCalMode;
/**
* 一线阳光计算方式
*/
@ApiModelProperty(name = "firstLineSunshineIncentiveFeeCalType", notes = "一线阳光计算方式")
@Column(name = "first_line_sunshine_incentive_fee_cal_type")
private Byte firstLineSunshineIncentiveFeeCalType;
/**
* 一线阳光激励费
*/
@ApiModelProperty(name = "firstLineSunshineIncentiveFee", notes = "一线阳光激励费")
@Column(name = "first_line_sunshine_incentive_fee")
private BigDecimal firstLineSunshineIncentiveFee;
/**
* 一线阳光2计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "firstLineSunshine2IncentiveFeeCalMode", notes = "一线阳光2计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "first_line_sunshine2_incentive_fee_cal_mode")
private Byte firstLineSunshine2IncentiveFeeCalMode;
/**
* 一线阳光2计算方式
*/
@ApiModelProperty(name = "firstLineSunshine2IncentiveFeeCalType", notes = "一线阳光2计算方式")
@Column(name = "first_line_sunshine2_incentive_fee_cal_type")
private Byte firstLineSunshine2IncentiveFeeCalType;
/**
* 一线阳光激励费2
*/
@ApiModelProperty(name = "firstLineSunshine2IncentiveFee", notes = "一线阳光激励费2")
@Column(name = "first_line_sunshine2_incentive_fee")
private BigDecimal firstLineSunshine2IncentiveFee;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@ApiModel(value = "GoodsListingSettleRule", description = "商品上架结算规则")
@Table(name = "dj_car_life_goods_listing_settle_rule")
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class GoodsListingSettleRule implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7511968928041146340L;
/**
* 主键ID
*/
@ApiModelProperty(name = "id", notes = "主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 单据编号
*/
@ApiModelProperty(name = "businessCode", notes = "单据编号")
@Column(name = "business_code")
private String businessCode;
/**
* 流量方分润计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "shopMerchantCalMode", notes = "流量方分润计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "shop_merchant_cal_mode")
private Byte shopMerchantCalMode;
/**
* 流量方分润类型
*/
@ApiModelProperty(name = "shopMerchantDividetype", notes = "流量方分润类型")
@Column(name = "shop_merchant_divideType")
private Byte shopMerchantDividetype;
/**
* 流量方比例
*/
@ApiModelProperty(name = "shopMerchantDivideValue", notes = "流量方比例")
@Column(name = "shop_merchant_divide_value")
private BigDecimal shopMerchantDivideValue;
/**
* 服务商分润计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "partnerMerchantCalMode", notes = "服务商分润计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "partner_merchant_cal_mode")
private Byte partnerMerchantCalMode;
/**
* 服务商分润类型
*/
@ApiModelProperty(name = "partnerMerchantDividetype", notes = "服务商分润类型")
@Column(name = "partner_merchant_divideType")
private Byte partnerMerchantDividetype;
/**
* 服务商比例
*/
@ApiModelProperty(name = "partnerMerchantDivideValue", notes = "服务商比例")
@Column(name = "partner_merchant_divide_value")
private BigDecimal partnerMerchantDivideValue;
/**
* 服务商2分润计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "partnerMerchant2CalMode", notes = "服务商2分润计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "partner_merchant2_cal_mode")
private Byte partnerMerchant2CalMode;
/**
* 服务商2分润类型
*/
@ApiModelProperty(name = "partnerMerchant2Dividetype", notes = "服务商2分润类型")
@Column(name = "partner_merchant2_divideType")
private Byte partnerMerchant2Dividetype;
/**
* 服务商2比例
*/
@ApiModelProperty(name = "partnerMerchant2DivideValue", notes = "服务商2比例")
@Column(name = "partner_merchant2_divide_value")
private BigDecimal partnerMerchant2DivideValue;
/**
* 其他费用分润计算模式(1:按照品类计算 2:按整单计算)
*/
@ApiModelProperty(name = "otherFeeCalMode", notes = "其他费用分润计算模式(1:按照品类计算 2:按整单计算)")
@Column(name = "other_fee_cal_mode")
private Byte otherFeeCalMode;
/**
* 其他费用分润类型
*/
@ApiModelProperty(name = "otherFeeDividetype", notes = "其他费用分润类型")
@Column(name = "other_fee_divideType")
private Byte otherFeeDividetype;
/**
* 其他费用比例
*/
@ApiModelProperty(name = "otherFeeDivideValue", notes = "其他费用比例")
@Column(name = "other_fee_divide_value")
private BigDecimal otherFeeDivideValue;
/**
* 升级产品成本归属
*/
@ApiModelProperty(name = "upgradeProductCostTarget", notes = "升级产品成本归属")
@Column(name = "upgrade_product_cost_target")
private Byte upgradeProductCostTarget;
/**
* 回收成本归属
*/
@ApiModelProperty(name = "recoveryCostTarget", notes = "回收成本归属")
@Column(name = "recovery_cost_target")
private Byte recoveryCostTarget;
/**
* 第三方产品成本归属
*/
@ApiModelProperty(name = "thirdpartyCostTarget", notes = "第三方产品成本归属")
@Column(name = "thirdParty_cost_target")
private Byte thirdpartyCostTarget;
/**
* 创建人
*/
@ApiModelProperty(name = "createdBy", notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(name = "createdDate", notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@ApiModelProperty(name = "updatedBy", notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@ApiModelProperty(name = "updatedDate", notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.devrules.listing.remote;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingApprovalDTO;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingApproval;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingLog;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingMerchantRef;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value="商品上架审批接口", owner="zhoulm")
public interface GoodsListingApprovalRemote {
@ApiMethod("商品上架审批分页列表")
@ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<RpcPagination<GoodsListingApprovalDTO>> listWithPage(@NotNull RpcPagination<GoodsListingApprovalDTO> pagination);
@ApiMethod("查询商品上架审批详情")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<GoodsListingApproval> getByBusinessCode(@NotBlank String businessCode);
@ApiMethod("查询商品上架日志列表")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<List<GoodsListingLog>> listLogByBusinessCode(@NotBlank String businessCode);
@ApiMethod("商品上架驳回操作")
@ApiParam(name = "record", notes = "驳回信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<Boolean> reject(@NotNull GoodsListingApproval record);
@ApiMethod("查询单店模式下商户信息")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<GoodsListingMerchantRef> getOneMerchantByBusinessCode(@NotBlank String businessCode);
}
package cn.com.glsx.dj.devrules.listing.remote;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingGoodsTypeGroupDTO;
import cn.com.glsx.dj.devrules.listing.dto.SaveDivisionBaseRuleDTO;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingBaseRule;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingDivisionRuleAuto;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingGoodsTypeGroup;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingGoodsTypeGroupRelation;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value="商品上架-分账规则配置接口", owner="zhoulm")
public interface GoodsListingDivisionRuleRemote {
@ApiMethod("查询商品上架分账规则品类列表")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<List<GoodsListingGoodsTypeGroup>> listGoodsTypeGroupBase(@NotBlank String businessCode);
@ApiMethod("查询同单号下其他同品类组的商品关系,前端用于排除已选项,禁用不可选项")
@ApiParams({
@ApiParam(name="businessCode",notes="单据",dataType= ApiParam.DataTypeEnum.STRING,required=true),
@ApiParam(name="categoryType",notes="分类品类(1:按商品分类;2:按具体商品;3:按商品套餐)",dataType= ApiParam.DataTypeEnum.BYTE),
@ApiParam(name="goodsTypeGroupId",notes="品类分组ID",dataType= ApiParam.DataTypeEnum.INTEGER)
})
@ApiResponse("同单号下其他同品类组的商品关系列表")
RpcResponse<List<GoodsListingGoodsTypeGroupRelation>> listOtherGoodsTypeGroupRelation(@NotBlank String businessCode,
@NotNull Byte categoryType,Integer goodsTypeGroupId);
@ApiMethod("查询商品上架自动分账配置列表")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<List<GoodsListingDivisionRuleAuto>> listDivisionRuleAuto(@NotBlank String businessCode);
@ApiMethod("查询商品上架分账基础规则")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<GoodsListingBaseRule> getBaseRule(@NotBlank String businessCode);
@ApiMethod("保存分账基础规则")
@ApiParam(name = "dto", notes = "分账基础规则", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<SaveDivisionBaseRuleDTO> saveBaseRule(@NotNull SaveDivisionBaseRuleDTO dto);
@ApiMethod("获取品类详情")
@ApiParam(name = "goodsTypeGroupId", notes = "品类组ID", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
RpcResponse<GoodsListingGoodsTypeGroupDTO> getGoodsTypeGroupDetail(@NotNull Integer goodsTypeGroupId);
@ApiMethod("保存品类规则")
@ApiParam(name = "record", notes = "品类规则", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<GoodsListingGoodsTypeGroupDTO> saveGoodsTypeGroupRule(@NotNull GoodsListingGoodsTypeGroupDTO record);
}
package cn.com.glsx.dj.devrules.listing.remote;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingProductBaseDTO;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingProductBase;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value="商品上架-产品信息接口", owner="zhoulm")
public interface GoodsListingProductRemote {
@ApiMethod("查询商品上架产品基础信息列表")
@ApiParam(name = "businessCode", notes = "单据编号", dataType = ApiParam.DataTypeEnum.STRING, required = true)
RpcResponse<List<GoodsListingProductBase>> listBase(@NotBlank String businessCode);
@ApiMethod("查询商品上架产品详情")
@ApiParam(name = "ID", notes = "主键ID", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
RpcResponse<GoodsListingProductBaseDTO> getDetailById(@NotNull Integer id);
@ApiMethod("商品上架产品分页列表")
@ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<RpcPagination<GoodsListingProductBaseDTO>> listWithPage(@NotNull RpcPagination<GoodsListingProductBaseDTO> pagination);
}
package cn.com.glsx.dj.devrules.listing.remote;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingSubmitDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import javax.validation.constraints.NotNull;
@ApiService(value = "商品上架提交", owner = "codex")
public interface GoodsListingSubmitRemote {
@ApiMethod("商品上架提交")
@ApiParam(name = "submitDTO", notes = "商品上架提交参数", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("异步任务UUID")
RpcResponse<String> save(@NotNull GoodsListingSubmitDTO submitDTO);
}
# framework-archetype-rpc-api
RPC-API项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.dj.smartcarlife.dto 数据传输模型层
├─cn.com.glsx.dj.smartcarlife.enums 枚举定义
├─cn.com.glsx.dj.smartcarlife.model 数据模型层
└─cn.com.glsx.dj.smartcarlife.remote RPC暴露服务层
└─resources 资源文件目录
└─rpc
└─dubbo.xml dubbo接口配置
└─pom.xml pom文件
二、使用说明:
1、API改动后,请及时deploy到Maven仓库
三、注意事项:
1、rpc-api-deploy-maven-plugin api上报插件需配置当前api的jar包的引用。
\ No newline at end of file \ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-devrules</artifactId>
<version>1.0.1-SNAPSHOT</version>
<name>rpc-dj-goods-listing</name>
<packaging>war</packaging>
<properties>
<skipTests>true</skipTests>
<devrules.api.version>1.0.1-SNAPSHOT</devrules.api.version>
</properties>
<dependencies>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-distribute-lock</artifactId>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-devrules-api</artifactId>
<version>${devrules.api.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package cn.com.glsx.dj.devrules.listing;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.devrules.listing.config;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
@Autowired
protected ReferenceBuilderFactory factory;
protected final boolean check = false;
protected final int timeout = 30000;
}
package cn.com.glsx.dj.devrules.listing.config;
import com.github.pagehelper.Page;
import com.github.pagehelper.dialect.helper.MySqlDialect;
import org.apache.ibatis.cache.CacheKey;
import java.util.regex.Pattern;
public class HelperDialectCustom extends MySqlDialect {
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
Pattern compileFixed = Pattern.compile("/\\*customLimitPlace\\*/");
String compileLimit = "/\\*limit\\*/";
if (compileFixed.matcher(sql).find()) {
if (page.getStartRow() == 0) {
sql = sql.replaceFirst(compileLimit, "\n LIMIT ? ");
} else {
sql = sql.replaceFirst(compileLimit, "\n LIMIT ?, ? ");
}
return sql;
}
return super.getPageSql(sql, page, pageKey);
}
}
package cn.com.glsx.dj.devrules.listing.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 商品上架提交流程依赖的车生活远程服务。
*/
@Configuration
public class SmartcarlifeDubboConfig extends DubboConfig {
}
package cn.com.glsx.dj.devrules.listing.constant;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import cn.com.glsx.dj.smartcarlife.enums.FeeCategoryEnum;
/**
*
* @Title CommonConstants
* @Description:
* @author Suro
* @date 2021/8/4 15:41
* @version V1.0
* @Company:didihu.com.cn
**/
public class CommonConstants {
public static final String DEFAULT_UPDATE_BY = "system";
public static final String DEFAULT_SYSTEM_USER_NAME = "系统";
public static final String DEFAULT_EMPLOYEE_NAME = "管理员";
public static final String SUPER_ADMIN = "超管";
public static final String DEFAULT_FILM_GOOD_TYPES = "[1,4,6,12,14]";
public static final Integer DEFAULT_TEST_MERCHANT_ID = -1;
/**
* 日期正则表达式,格式如2022-04-03
*/
public static final String DATE_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)\\1([0-2]\\d|\\d|30|31)$";
/**
* 月份正则表达式,格式如2022-04
*/
public static final String MONTH_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)$";
/**
* 日期正则表达式,格式如2022-04-03 00:00:00
*/
public static final String DATE_TIME_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)\\1([0-2]\\d|\\d|30|31)\\s\\d{2}(:)\\d{2}(:)\\d{2}$";
public static final BigDecimal ONEHUNDRED_BIGDECIMAL = BigDecimal.valueOf(100);
/**
* 车系是否选中标志位-选中
*/
public static final int SERIES_FLAG_SELECTED = 1;
/**
* 保留两位小数
*/
public static final int SCALE = 2;
/**
* 保留四位小数
*/
public static final int SCALE_FOUR = 4;
public static final String DATE_START_TIME = " 00:00:00";
public static final String DATE_END_TIME = " 23:59:59";
public static final String FIRST_DATE = "-01";
public static final String LAST_DATE = "-31";
public static final String DATE_END_TIME_SECOND_EXCLUDED = " 23:59";
public static final BigDecimal DECIMAL_VALUE_MILLION = BigDecimal.valueOf(1000000);
public static final BigDecimal DECIMAL_VALUE_ALMOST_MILLION = new BigDecimal("999999.99");
/**
* 商户有效品牌的的最大数量,超过100则认为商户的品牌信息无效
*/
public static final Integer MAX_VALID_BRAND_COUNT = 100;
public static final String HMZX = "鸿蒙智行";
public static final String WEN_JIE = "问界";
public static final String NON_WEN_JIE = "非问界";
public static final Integer DEFAULT_BRAND_ID = -1;
public static final String OTHER = "其他";
/** 规格数据分隔符 **/
public static final String SPECIFICATION_SEPARATOR = ";~;";
public static final String STOCK_INSUFFICIENT = "库存不足";
/** 商品上架分账配置费用类目 **/
public static final List<Integer> GOODS_LISTING_DIVISION_EXPENSECATEGORY_IDS = Arrays.asList(
FeeCategoryEnum.TRAFFIC_FEE.getValue(),
FeeCategoryEnum.SERVICE_PROVIDER_PROFIT_SHARING.getValue(),
FeeCategoryEnum.PARTNER_SETTLE_RESOURCE_FEE.getValue(),
FeeCategoryEnum.SETTLE_OTHER_FEE.getValue()
);
public static final List<Integer> GOODS_LISTING_SCENE1_DISTRIBUTION_EXPENSECATEGORY_IDS = Arrays.asList(
FeeCategoryEnum.TRAFFIC_FEE.getValue(),
FeeCategoryEnum.SERVICE_PROVIDER_PROFIT_SHARING.getValue(),
FeeCategoryEnum.PARTNER_SETTLE_RESOURCE_FEE.getValue(),
FeeCategoryEnum.SETTLE_OTHER_FEE.getValue(),
FeeCategoryEnum.PRODUCT_COST.getValue(),
FeeCategoryEnum.RECOVERY_COST.getValue(),
FeeCategoryEnum.HANDLING_FEE.getValue()
);
public static final List<Integer> GOODS_LISTING_SCENE0_DISTRIBUTION_EXPENSECATEGORY_IDS = Arrays.asList(
FeeCategoryEnum.TRAFFIC_FEE.getValue(),
FeeCategoryEnum.SERVICE_PROVIDER_PROFIT_SHARING.getValue(),
FeeCategoryEnum.PARTNER_SETTLE_RESOURCE_FEE.getValue(),
FeeCategoryEnum.SETTLE_OTHER_FEE.getValue(),
FeeCategoryEnum.THIRD_PARTY_COST.getValue(),
FeeCategoryEnum.HANDLING_FEE.getValue()
);
}
package cn.com.glsx.dj.devrules.listing.model;
import java.util.List;
import lombok.Data;
@Data
public class CompareResult<T> {
private List<T> addList;
private List<T> deleteList;
private List<T> updateList;
}
package cn.com.glsx.dj.devrules.listing.remote;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingApprovalDTO;
import cn.com.glsx.dj.devrules.listing.enums.GoodsListingEnum.ShelfType;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingApproval;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingLog;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingMerchantRef;
import cn.com.glsx.dj.devrules.listing.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import lombok.extern.slf4j.Slf4j;
@DubboService(version = "1.0.0",validation = "true")
@Slf4j
public class GoodsListingApprovalRemoteImpl implements GoodsListingApprovalRemote {
@Override
public RpcResponse<RpcPagination<GoodsListingApprovalDTO>> listWithPage(
@NotNull RpcPagination<GoodsListingApprovalDTO> pagination) {
try{
return RpcResponse.success(RpcPagination.copyPage(pagination));
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<GoodsListingApproval> getByBusinessCode(@NotBlank String businessCode) {
try{
return RpcResponse.success(new GoodsListingApproval());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<GoodsListingLog>> listLogByBusinessCode(@NotBlank String businessCode) {
try{
return RpcResponse.success(new ArrayList<>());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> reject(@NotNull GoodsListingApproval record) {
try{
return RpcResponse.success(true);
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<GoodsListingMerchantRef> getOneMerchantByBusinessCode(@NotBlank String businessCode) {
try{
return RpcResponse.success(null);
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.devrules.listing.remote;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingGoodsTypeGroupDTO;
import cn.com.glsx.dj.devrules.listing.dto.SaveDivisionBaseRuleDTO;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingBaseRule;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingDivisionRuleAuto;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingGoodsTypeGroup;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingGoodsTypeGroupRelation;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import lombok.extern.slf4j.Slf4j;
@DubboService(version = "1.0.0",validation = "true")
@Slf4j
public class GoodsListingDivisionRuleRemoteImpl implements GoodsListingDivisionRuleRemote {
@Override
public RpcResponse<List<GoodsListingGoodsTypeGroup>> listGoodsTypeGroupBase(@NotBlank String businessCode) {
try{
return RpcResponse.success(new ArrayList<>());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<GoodsListingGoodsTypeGroupRelation>> listOtherGoodsTypeGroupRelation(
@NotBlank String businessCode, @NotNull Byte categoryType, Integer goodsTypeGroupId) {
try{
return RpcResponse.success(new ArrayList<>());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<GoodsListingDivisionRuleAuto>> listDivisionRuleAuto(@NotBlank String businessCode) {
try{
return RpcResponse.success(new ArrayList<>());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<GoodsListingBaseRule> getBaseRule(@NotBlank String businessCode) {
try{
return RpcResponse.success(new GoodsListingBaseRule());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<SaveDivisionBaseRuleDTO> saveBaseRule(SaveDivisionBaseRuleDTO dto) {
try{
return RpcResponse.success(new SaveDivisionBaseRuleDTO());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<GoodsListingGoodsTypeGroupDTO> getGoodsTypeGroupDetail(@NotNull Integer goodsTypeGroupId) {
try{
return RpcResponse.success(new GoodsListingGoodsTypeGroupDTO());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<GoodsListingGoodsTypeGroupDTO> saveGoodsTypeGroupRule(
@NotNull GoodsListingGoodsTypeGroupDTO record) {
try{
return RpcResponse.success(new GoodsListingGoodsTypeGroupDTO());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.devrules.listing.remote;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingProductBaseDTO;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingProductBase;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import lombok.extern.slf4j.Slf4j;
@DubboService(version = "1.0.0",validation = "true")
@Slf4j
public class GoodsListingProductRemoteImpl implements GoodsListingProductRemote {
@Override
public RpcResponse<List<GoodsListingProductBase>> listBase(@NotBlank String businessCode) {
try{
return RpcResponse.success(new ArrayList<>());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<GoodsListingProductBaseDTO> getDetailById(@NotNull Integer id) {
try {
return RpcResponse.success(new GoodsListingProductBaseDTO());
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<RpcPagination<GoodsListingProductBaseDTO>> listWithPage(
@NotNull RpcPagination<GoodsListingProductBaseDTO> pagination) {
try{
return RpcResponse.success(RpcPagination.copyPage(new ArrayList<>()));
} catch(Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.devrules.listing.remote;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingSubmitDTO;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@DubboService(validation = "true", version = "1.0.0")
public class GoodsListingSubmitRemoteImpl implements GoodsListingSubmitRemote {
@Override
public RpcResponse<String> save(GoodsListingSubmitDTO submitDTO) {
try {
return RpcResponse.success("submit success");
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.devrules.listing.util;
import cn.com.glsx.dj.devrules.listing.model.CompareResult;
import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.merchantRef.MerchantContractAddDTO;
import cn.com.glsx.dj.smartcarlife.dto.merchantRef.ServiceContractAddDTO;
import cn.com.glsx.dj.smartcarlife.dto.merchantRef.ServiceMerchantAddDTO;
import cn.com.glsx.dj.smartcarlife.dto.refund.RefundApplyRecordDTO;
import cn.com.glsx.dj.smartcarlife.model.*;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.scrm.proxy.enums.AccountTypeEnum;
import cn.com.glsx.scrm.proxy.model.ProxyBaseResponse;
import cn.com.glsx.scrm.proxy.model.merchant.MerchantRopResponse;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.oreframework.util.encrypt.MD5Util;
import org.springframework.beans.BeanUtils;
import javax.validation.constraints.NotNull;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Slf4j
public class CommonUtil {
private static final Pattern ENGLISH_CHAR_PATTERN = Pattern.compile("[a-zA-Z]");
private static final Pattern WHITE_SPACE_PATTERN = Pattern.compile("\\s+");
public static <T> RpcPagination<T> createPagination(T condition,int pageNum,int pageSize){
RpcPagination<T> pagination = new RpcPagination<>();
pagination.setCondition(condition);
pagination.setPageNum(pageNum);
pagination.setPageSize(pageSize);
return pagination;
}
public static <T> T getFirst(List<T> list) {
if(CollectionUtils.isNotEmpty(list)) {
return list.get(0);
}
return null;
}
public static boolean contains(String ori,String content,String separator) {
if(StringUtils.isBlank(ori) || StringUtils.isBlank(content) || StringUtils.isBlank(separator)) {
return false;
}
return Arrays.asList(ori.split(separator)).contains(content);
}
public static List<Integer> convert2Integer(String[] strArr) {
if(strArr == null || strArr.length == 0) {
return null;
}
List<Integer> list = new ArrayList<>();
for(String s:strArr) {
try {
list.add(Integer.valueOf(s));
}catch(Exception e) {
}
}
return list.isEmpty() ? null:list;
}
public static List<Integer> convert2Integer(List<String> l) {
if(CollectionUtils.isEmpty(l)) {
return null;
}
List<Integer> list = new ArrayList<>();
for(String s:l) {
try {
list.add(Integer.valueOf(s));
}catch(Exception e) {
}
}
return list.isEmpty() ? null:list;
}
public static List<Byte> convertByte(String[] strArr) {
if (strArr == null || strArr.length == 0) {
return null;
}
List<Byte> list = new ArrayList<>();
for (String s : strArr) {
try {
list.add(Byte.valueOf(s));
} catch (Exception e) {
}
}
return list.isEmpty() ? null : list;
}
public static<T> RpcResponse<T> convertRpcResponseBean(RpcResponse<ProxyBaseResponse> rpcRes, Class<T> clazz){
try {
if(rpcRes.hasResult()) {
return RpcResponse.success(rpcRes.getResult().getBean(clazz));
}
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, rpcRes.getMessage());
}catch(RpcServiceException e) {
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
/**
* 根据费用类目比例计算值, 默认保存两位小数,向上舍入
*
* @param baseValue 要计算的值
* @param ratio 比例
* @return
*/
public static BigDecimal calculateRatio(BigDecimal baseValue, BigDecimal ratio) {
return calculateRatio(baseValue, ratio, BigDecimal.ROUND_UP);
}
/**
* 根据费用类目比例计算值, 默认保存两位小数
*
* @param baseValue 要计算的值
* @param ratio 比例
* @param roundingMode 舍入方式
* @return
*/
public static BigDecimal calculateRatio(BigDecimal baseValue, BigDecimal ratio, int roundingMode) {
return calculateRatio(baseValue, ratio, CommonConstants.SCALE, roundingMode);
}
/**
*
* @param baseValue 要计算的值
* @param ratio 比例
* @param scale 保留的小数位
* @param roundingMode 舍入方式
* @return
*/
public static BigDecimal calculateRatio(BigDecimal baseValue, BigDecimal ratio, int scale, int roundingMode) {
return baseValue.multiply(ratio).divide(CommonConstants.ONEHUNDRED_BIGDECIMAL, scale, roundingMode);
}
/**
* decimal除法 默认保留两位小数,四舍五入
* @param dividend 被除数
* @param divisor 除数
* @return (被除数 / 除数)
*/
public static BigDecimal decimalDivide(BigDecimal dividend, BigDecimal divisor) {
if (Objects.isNull(dividend) || Objects.isNull(divisor) || divisor.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
return dividend.divide(divisor, CommonConstants.SCALE, RoundingMode.HALF_UP);
}
/**
* decimal除法
* @param dividend 被除数
* @param divisor 除数
* @param scale 保留小数位
* @param roundingMode 舍入模式
* @return (被除数 / 除数)
*/
public static BigDecimal decimalDivide(BigDecimal dividend, BigDecimal divisor, int scale, RoundingMode roundingMode) {
if (Objects.isNull(dividend) || Objects.isNull(divisor) || divisor.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
return dividend.multiply(CommonConstants.ONEHUNDRED_BIGDECIMAL).divide(divisor, scale, roundingMode);
}
/**
* decimal除法,求百分比 默认保留两位小数,四舍五入
* @param dividend 被除数
* @param divisor 除数
* @return (被除数 / 除数)
*/
public static BigDecimal decimalDividePercentage(BigDecimal dividend, BigDecimal divisor) {
if (Objects.isNull(dividend) || Objects.isNull(divisor) || divisor.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
return dividend.multiply(CommonConstants.ONEHUNDRED_BIGDECIMAL).divide(divisor, CommonConstants.SCALE, RoundingMode.HALF_UP);
}
/**
* decimal除法,计算百分比
* @param dividend 被除数
* @param divisor 除数
* @param scale 保留小数位
* @param roundingMode 舍入模式
* @return (被除数 / 除数) * 100%
*/
public static BigDecimal decimalDividePercentage(BigDecimal dividend, BigDecimal divisor, int scale, RoundingMode roundingMode) {
if (Objects.isNull(dividend) || Objects.isNull(divisor) || divisor.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
return dividend.multiply(CommonConstants.ONEHUNDRED_BIGDECIMAL).divide(divisor, scale, roundingMode);
}
/**
* integer除法,计算百分比
* @param dividend 被除数
* @param divisor 除数
* @param scale 保留小数位
* @param roundingMode 舍入模式
* @return (被除数 / 除数) * 100%
*/
public static BigDecimal integerDividePercentage(Integer dividend, Integer divisor, int scale, RoundingMode roundingMode) {
if (Objects.isNull(dividend) || Objects.isNull(divisor) || Objects.equals(divisor, 0)) {
return null;
}
return decimalDividePercentage(BigDecimal.valueOf(dividend), BigDecimal.valueOf(divisor), scale, roundingMode);
}
/**
* integer除法,计算百分比, 保留两位小鼠 四舍五入
* @param dividend 被除数
* @param divisor 除数
* @return (被除数 / 除数) * 100%
*/
public static BigDecimal integerDividePercentage(Integer dividend, Integer divisor) {
if (Objects.isNull(dividend) || Objects.isNull(divisor) || Objects.equals(divisor, 0)) {
return null;
}
return decimalDividePercentage(BigDecimal.valueOf(dividend), BigDecimal.valueOf(divisor), CommonConstants.SCALE, RoundingMode.HALF_UP);
}
/**
* 10进制转26进制
* @param serialNumber 26进制初始值 e.g. AAA
* @param serialNumber 10进制值 e.g. 100
* @return
*/
public static String generateSeqNumber(String seqNumberStr, Integer serialNumber) {
char[] chars = seqNumberStr.toCharArray();
while (serialNumber > 1) {
int lastIndex = seqNumberStr.length() - 1;
if (!(seqNumberStr.charAt(lastIndex) == 'Z' && seqNumberStr.charAt(0) == 'Z')) {
if (chars[lastIndex] == 'Z') {
int point = lastIndex - 1;
while (point >= 0) {
if (chars[point] == 'Z') {
point--;
} else {
chars[point] = (char) ((int) chars[point] + 1);
chars[lastIndex] = 'A';
break;
}
}
} else {
chars[lastIndex] = (char) (chars[lastIndex] + 1);
}
serialNumber--;
}
}
return new String(chars);
}
/**
*
* @Description: 比较两个list的差异性,获取从oldList 到newList 需要删除、新增、修改的List
* @param <T>
* @param oldList
* @param newList
* @param handler 用于确定对象如何比较
* @return
* @author zhoulm
*/
public static <T> CompareResult<T> getCompareResult(List<T> oldList,List<T> newList,CompareResultHandler<T> handler) {
CompareResult<T> result = new CompareResult<T>();
if(CollectionUtils.isEmpty(oldList)) {
result.setAddList(newList);
if(CollectionUtils.isNotEmpty(newList)) {
newList.forEach(item-> handler.addItemHandler(item));
}
return result;
}
if(CollectionUtils.isEmpty(newList)) {
result.setDeleteList(oldList);
if(CollectionUtils.isNotEmpty(oldList)) {
oldList.forEach(item-> handler.deleteItemHandler(item));
}
return result;
}
//删除
List<T> deleteList = oldList.stream().filter(item -> {
Optional<T> optional = newList.stream().filter(i -> handler.equals(i, item)).findFirst();
if(!optional.isPresent()) {
handler.deleteItemHandler(item);
return true;
}
return false;
}).collect(Collectors.toList());
//新增
List<T> addList = newList.stream().filter(item -> {
Optional<T> optional = oldList.stream().filter(i -> handler.equals(i, item)).findFirst();
if(!optional.isPresent()) {
handler.addItemHandler(item);
return true;
}
return false;
}).collect(Collectors.toList());
//更新
List<T> updateList = newList.stream().filter(item -> {
Optional<T> optional = oldList.stream().filter(i -> handler.equals(i, item)).findFirst();
if(optional.isPresent()) {
return handler.updateItemHandler(optional.get(),item);
}
return false;
}).collect(Collectors.toList());
result.setAddList(addList);
result.setDeleteList(deleteList);
result.setUpdateList(updateList);
return result;
}
/**
* 校验BigDecimal值是否在区间范围内,闭区间
* @param value 校验值
* @param minValue 最小值
* @param maxValue 最大值
* @param errorMessage 异常信息
* @return
*/
public static BigDecimal checkDecimalValueValid(@NotNull BigDecimal value, @NotNull BigDecimal minValue, @NotNull BigDecimal maxValue, String errorMessage) {
if (value.compareTo(minValue) < 0 || value.compareTo(maxValue) > 0) {
throw new RpcServiceException(DefaultErrorEnum.VALIDATE_FAILED, errorMessage);
}
return value;
}
/**
* Integer相加
* @param x Integer1
* @param y Integer2
* @return
*/
public static Integer addInteger(Integer x, Integer y) {
Integer z = null;
if (Objects.nonNull(x)) {
z = x;
}
if (Objects.isNull(x) && Objects.nonNull(y)) {
z = y;
}
if (Objects.nonNull(x) && Objects.nonNull(y)) {
z = x + y;
}
return z;
}
/**
* BigDecimal相加
* @param x BigDecimal1
* @param y BigDecimal2
* @return
*/
public static BigDecimal addBigDecimal(BigDecimal x, BigDecimal y) {
BigDecimal z = null;
if (Objects.nonNull(x)) {
z = x;
}
if (Objects.isNull(x) && Objects.nonNull(y)) {
z = y;
}
if (Objects.nonNull(x) && Objects.nonNull(y)) {
z = x.add(y);
}
return z;
}
public static Integer getStringToInteger(String str) {
if(StringUtils.isBlank(str)) {
return null;
}
return Integer.parseInt(str);
}
/**
* 去除字符串中的英文和空格
*/
public static String removeEnglishAndSpaces(String str) {
if (org.apache.commons.lang3.StringUtils.isBlank(str)) {
return org.apache.commons.lang3.StringUtils.EMPTY;
}
return WHITE_SPACE_PATTERN.matcher(ENGLISH_CHAR_PATTERN.matcher(str).replaceAll("")).replaceAll("");
}
//求交集
public static List<Integer> getRetainMerchantIdList(List<Integer> merchantId1List, List<Integer> merchantId2List) {
if (CollectionUtils.isEmpty(merchantId1List) ) {
return merchantId2List;
}
if (CollectionUtils.isNotEmpty(merchantId2List)) {
merchantId1List.retainAll(merchantId2List);
}
if (CollectionUtils.isEmpty(merchantId1List)) {
merchantId1List.add(-1);
}
return merchantId1List;
}
public static void main(String[] args) {
List<Integer> ids1 = new ArrayList<>();
ids1.add(1);
ids1.add(2);
List<Integer> ids2 = new ArrayList<>();
ids2.add(1);
ids2.add(2);
RefundApplyRecordDTO r1 = RefundApplyRecordDTO.builder().id(1).idList(ids1).matchApplyCode("3").build();
RefundApplyRecordDTO r2 = RefundApplyRecordDTO.builder().id(2).applyCode("4").idList(ids2).matchApplyCode("3").build();
System.out.println(r1.hashCode());
System.out.println(r2.hashCode());
}
//获取对象属性及属性值map key为属性名,value为属性值
public static <T> Map<String,Object> getCompareProperty(T obj,List<String> comparePropertiesList, List<String> ignoreList) {
if (Objects.isNull(obj)) {
return Collections.emptyMap();
}
Class<?> objClass = obj.getClass();
PropertyDescriptor[] propertyDescriptors = BeanUtils.getPropertyDescriptors(objClass);
Map<String,Object> compareProperMap = new HashMap<>();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
try {
String name = propertyDescriptor.getName();
if (CollectionUtils.isNotEmpty(comparePropertiesList) && !comparePropertiesList.contains(name)) {
continue;
}
if (CollectionUtils.isNotEmpty(ignoreList) && ignoreList.contains(name)) {
continue;
}
Method readMethod = propertyDescriptor.getReadMethod();
if (Objects.nonNull(readMethod)) {
compareProperMap.put(name, readMethod.invoke(obj));
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
return compareProperMap;
}
public static <T extends Annotation> T getAnnotation(final Class<?> cls,String filedName,Class<T> annotationClass) {
try {
Field field = FieldUtils.getDeclaredField(cls, filedName, true);
if(field != null) {
return field.getAnnotation(annotationClass);
}
}catch(Exception e) {
}
return null;
}
public static ServiceMerchant convertServiceMerchant(MerchantRopResponse m, AccountTypeEnum ...merchantType){
ServiceMerchant merchant = new ServiceMerchant();
merchant.setMerchantId(Integer.valueOf(m.getMerchantNo()));
merchant.setMerchantName(m.getMerchantName());
merchant.setShortName(m.getMerchantAbbreviation());
merchant.setUserType(m.getMerchantAccountLevel());
if(merchantType != null && org.apache.commons.lang3.StringUtils.isNotBlank(m.getAccountType())){
for(AccountTypeEnum a:merchantType) {
if(Arrays.asList(m.getAccountType().split(",")).contains(String.valueOf(a.getValue()))) {
merchant.setMerchantType(a.getValue());
break;
}
}
}
merchant.setAccountName(m.getMerchantLoginAccount());
merchant.setContactName(m.getMerchantLegalPerson());
merchant.setPhone(m.getMerchantLegalPersonPhone());
merchant.setAddress(m.getMerchantAddress());
//省市区名称及编码未同步
// merchant.setProvinceId(null);
// merchant.setProvinceName(null);
// merchant.setCityId(null);
// merchant.setCityName(null);
// merchant.setAreaName(null);
// merchant.setAreaId(null);
merchant.setLat(m.getLat());
merchant.setLng(m.getLng());
if(CollectionUtils.isNotEmpty(m.getMerchantFileResponses())) {
merchant.setShopPhoto(m.getMerchantFileResponses().get(0).getFileUrl());
}
merchant.setChannelType(m.getChannelType());
//merchant.setRegion(null);
merchant.setStayContactName(m.getResidentContact());
merchant.setStayPhone(m.getResidentPhone());
merchant.setCreatedDate(m.getCreatedTime());
return merchant;
}
public static ServiceMerchant convertServiceMerchant(ServiceMerchantAddDTO m, AccountTypeEnum ...merchantType){
RpcAssert.assertNotNull(m.getMerchantNo(), DefaultErrorEnum.DATA_NULL,"merchantId not be null");
ServiceMerchant merchant = new ServiceMerchant();
merchant.setMerchantId(Integer.valueOf(m.getMerchantNo()));
merchant.setMerchantName(m.getMerchantName());
merchant.setShortName(m.getMerchantAbbreviation());
merchant.setUserType(m.getMerchantAccountLevel());
if(merchantType != null && org.apache.commons.lang3.StringUtils.isNotBlank(m.getAccountType())){
for(AccountTypeEnum a:merchantType) {
if(Arrays.asList(m.getAccountType().split(",")).contains(String.valueOf(a.getValue()))) {
merchant.setMerchantType(a.getValue());
break;
}
}
}
merchant.setAccountName(m.getMerchantLoginAccount());
merchant.setContactName(m.getMerchantLegalPerson());
merchant.setPhone(m.getMerchantLegalPersonPhone());
merchant.setAddress(m.getMerchantAddress());
merchant.setProvinceId(m.getProvinceCode());
merchant.setProvinceName(m.getProvinceName());
merchant.setCityId(m.getCityCode());
merchant.setCityName(m.getCityName());
merchant.setLat(m.getLat());
merchant.setLng(m.getLng());
merchant.setShopPhoto(m.getShopPhoto());
merchant.setChannelType(m.getChannelType());
merchant.setStayContactName(m.getResidentContact());
merchant.setStayPhone(m.getResidentPhone());
merchant.setCreatedDate(new Date(m.getCreatedTime()));
return merchant;
}
/**
* 转换成服务商合同信息对象
* @param m
* @param merchantType
* @return
*/
public static MerchantContractServiceProvider convertMerchantContractServiceProvider(ServiceMerchantAddDTO m, AccountTypeEnum ...merchantType){
MerchantContractServiceProvider merchantContract = new MerchantContractServiceProvider();
ServiceContractAddDTO contractInfo = m.getContractInfo();
merchantContract.setServiceMerchantId(Integer.valueOf(m.getMerchantNo()));
merchantContract.setServiceMerchantName(m.getMerchantName());
merchantContract.setServiceProviderLevel(contractInfo.getServiceProviderLevel());
merchantContract.setServiceProviderType(contractInfo.getServiceProviderType());
merchantContract.setSubBusiness(contractInfo.getSubBusiness());
merchantContract.setContractStipulateRate(contractInfo.getContractStipulateRate());
merchantContract.setContractActualRate(contractInfo.getContractActualRate());
merchantContract.setContractOwnerMerchantId(contractInfo.getContractOwnerMerchantId());
merchantContract.setContractOwnerMerchantName(contractInfo.getContractOwnerMerchantName());
merchantContract.setContractCode(contractInfo.getContractCode());
return merchantContract;
}
/**
* 对象类型转换
* @param shopContractInfo
* @param accountTypeEnum
* @return
*/
public static MerchantContractFlow convertMerchantContractFlow(MerchantContractAddDTO shopContractInfo,
AccountTypeEnum accountTypeEnum) {
MerchantContractFlow merchantContractFlow = new MerchantContractFlow();
merchantContractFlow.setFlowMerchantId(shopContractInfo.getMerchantId());
merchantContractFlow.setFlowMerchantName(shopContractInfo.getMerchantName());
ServiceMerchantAddDTO firstFlowMerchantInfo = shopContractInfo.getFirstFlowMerchantInfo();
if(ObjectUtil.isNotEmpty(firstFlowMerchantInfo)){
merchantContractFlow.setFirstFlowMerchantId(Integer.parseInt(firstFlowMerchantInfo.getMerchantNo()));
merchantContractFlow.setFirstFlowMerchantName(firstFlowMerchantInfo.getMerchantName());
}
ServiceMerchantAddDTO flowChannelMerchantInfo = shopContractInfo.getFlowChannelMerchantInfo();
if(ObjectUtil.isNotEmpty(flowChannelMerchantInfo)) {
merchantContractFlow.setFlowChannelMerchantId(Integer.parseInt(flowChannelMerchantInfo.getMerchantNo()));
merchantContractFlow.setFlowChannelMerchantName(flowChannelMerchantInfo.getMerchantName());
}
merchantContractFlow.setCooperationModel(shopContractInfo.getCooperationModel());
merchantContractFlow.setPaymentMethod(shopContractInfo.getPaymentMethod());
merchantContractFlow.setContractStipulateRate(shopContractInfo.getContractStipulateRate());
merchantContractFlow.setContractActualRate(shopContractInfo.getContractActualRate());
merchantContractFlow.setContractOwnerMerchantId(shopContractInfo.getContractOwnerMerchantId());
merchantContractFlow.setContractOwnerMerchantName(shopContractInfo.getContractOwnerMerchantName());
merchantContractFlow.setContractCode(shopContractInfo.getContractCode());
merchantContractFlow.setIncomeOwnerMerchantId(shopContractInfo.getIncomeOwnerMerchantId());
merchantContractFlow.setIncomeOwnerMerchantName(shopContractInfo.getIncomeOwnerMerchantName());
merchantContractFlow.setIncomeOwnerMerchantAccount(shopContractInfo.getIncomeOwnerMerchantAccount());
merchantContractFlow.setGeneralTaxpayer(shopContractInfo.getGeneralTaxpayer());
return merchantContractFlow;
}
public static Integer parseMerchantType(ServiceMerchantAddDTO m, AccountTypeEnum ...merchantType) {
if(merchantType != null && org.apache.commons.lang3.StringUtils.isNotBlank(m.getAccountType())) {
for(AccountTypeEnum a:merchantType) {
if(Arrays.asList(m.getAccountType().split(",")).contains(String.valueOf(a.getValue()))) {
return a.getValue();
}
}
}
return null;
}
/**
* 将可变参数 List<String> 拼接为逗号分隔的字符串,并生成其 MD5 值
*
* @param lists 可变参数 List<String>
* @return 拼接后的字符串的 MD5 值
*/
public static String generateMd5FromLists(List<String>... lists) {
// 将多个 List<String> 合并为一个 List<String>
String concatenatedString = Arrays.stream(lists)
.filter(Objects::nonNull)
.flatMap(List::stream)
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining());
// 生成 MD5 值
return MD5Util.md5(concatenatedString);
}
public static String integerToString(Integer integer) {
if (Objects.isNull(integer)) {
return null;
}
return integer.toString();
}
}
package cn.com.glsx.dj.devrules.listing.util;
public interface CompareResultHandler<T> {
/**
*
* @Description:
* @param item1
* @param item2
* @return
* @author zhoulm
*/
boolean equals(T item1,T item2);
/**
*
* @Description:新增数据项处理
* @param addItem 新增项
* @author zhoulm
*/
default void addItemHandler(T addItem) {};
/**
*
* @Description:删除数据项处理
* @param deleteItem 新增项
* @author zhoulm
*/
default void deleteItemHandler(T deleteItem) {};
/**
*
* @Description:更新数据项处理
* @param oldItem 老项
* @param newItem 新项
* @author zhoulm
*/
default boolean updateItemHandler(T oldItem,T newItem) {return true;};
}
package cn.com.glsx.dj.devrules.listing.util;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAdjusters;
import java.time.temporal.WeekFields;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.validation.constraints.NotNull;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang.StringUtils;
import cn.com.glsx.dj.devrules.listing.constant.CommonConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class DateUtils extends cn.com.glsx.framework.core.util.DateUtils {
public static final String DATA_MONTH_PATTERN = "^\\d{4}(-)(1[0-2]|0\\d)$";
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter DEFAULT_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private static final DateTimeFormatter YEAR_MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM");
private static final DateTimeFormatter CHINESE_DATE_WITHOUT_YEAR_FORMATTER = DateTimeFormatter.ofPattern("M月d日", Locale.CHINESE);
public static final DateTimeFormatter CHINESE_DATE_FORMATTER = DateTimeFormatter.ofPattern(NYR_TIME_FORMAT);
public static final String FIRST_DATE_TIME = "yyyy-MM-dd 00:00:00";
public static final String END_DATE_TIME = "yyyy-MM-dd 23:59:59";
public static final String YESTERDAY = "昨日";
public static final String TODAY = "今日";
public static final String LAST_MONTH = "上月";
public static final String CURRENT_MONTH = "当月";
private static final String [] PARSER_PATTERNS = {"yyyy-MM-dd","yyyy-M-d HH:mm:ss","yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm:ss.S"};
public static int getDateYear(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.YEAR);
}
public static String getMonthFirstAndLastDayTime(String dataMonthStr) {
if (StringUtils.isNotBlank(dataMonthStr) && dataMonthStr.matches(DATA_MONTH_PATTERN)) {
LocalDate dataMonthDate = LocalDate.parse(dataMonthStr.concat("-01"), DEFAULT_DATE_FORMATTER);
String startDateTime = dataMonthDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay().format(DATE_TIME_FORMATTER);
String endDateTime = dataMonthDate.with(TemporalAdjusters.lastDayOfMonth()).atTime(23,59,59).format(DATE_TIME_FORMATTER);
return startDateTime + "," + endDateTime;
}
return null;
}
public static String getMonthLastDay(String dataMonthStr) {
if (StringUtils.isNotBlank(dataMonthStr) && dataMonthStr.matches(DATA_MONTH_PATTERN)) {
LocalDate dataMonthDate = LocalDate.parse(dataMonthStr.concat("-01"), DEFAULT_DATE_FORMATTER);
String endDateTime = dataMonthDate.with(TemporalAdjusters.lastDayOfMonth()).format(DEFAULT_DATE_FORMATTER);
return endDateTime;
}
return null;
}
public static Date getDayOfFirst(Date date) {
return parseDate(formatDate(date,FIRST_DATE_TIME),DATE_FORMAT_DATE_TIME);
}
public static Date getDayOfEnd(Date date) {
return parseDate(formatDate(date,END_DATE_TIME),DATE_FORMAT_DATE_TIME);
}
/**
* dataMonthStr yyyyMM
*/
public static String getMonthFirstAndLastDayTime2(String dataMonthStr) {
LocalDate dataMonthDate = LocalDate.parse(dataMonthStr.concat("01"), DateTimeFormatter.ofPattern("yyyyMMdd"));
String startDateTime = dataMonthDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay().format(DATE_TIME_FORMATTER);
String endDateTime = dataMonthDate.with(TemporalAdjusters.lastDayOfMonth()).atTime(23,59,59).format(DATE_TIME_FORMATTER);
return startDateTime + "," + endDateTime;
}
/**
* dataMonthStr yyyy
*/
public static String getYearFirstAndLastDayTime2(Integer dataMonthStr) {
LocalDate dataMonthDate = LocalDate.parse(dataMonthStr.toString().concat("0101"), DateTimeFormatter.ofPattern("yyyyMMdd"));
String startDateTime = dataMonthDate.with(TemporalAdjusters.firstDayOfYear()).atStartOfDay().format(DATE_TIME_FORMATTER);
String endDateTime = dataMonthDate.with(TemporalAdjusters.lastDayOfYear()).atTime(23,59,59).format(DATE_TIME_FORMATTER);
return startDateTime + "," + endDateTime;
}
/**
* 获取近多少天的所有日期,升序排列,格式为 yyyy-MM-dd
*
* @param dayNum 获取近多少天的所有日期
* @return
*/
public static List<String> getLatestDayList(Integer dayNum) {
List<String> dateList = Lists.newArrayList();
LocalDate date = LocalDate.now();
while (dayNum > 0) {
String formattedDate = date.format(DEFAULT_DATE_FORMATTER);
date = date.minusDays(1);
dateList.add(0, formattedDate);
dayNum --;
}
return dateList;
}
/**
* 获取两个日期范围内的所有日期,升序排列,格式为 yyyy-MM-dd
*
* @param startDate 起始日期 yyyy-MM-dd
* @param endDate 结束日期 yyyy-MM-dd
* @return
*/
public static List<String> getDateRangeList(String startDate, String endDate) {
List<String> dateList = Lists.newArrayList();
if (startDate.compareTo(endDate) > 0) {
return Lists.newArrayList();
}
LocalDate startLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ofPattern(DateUtils.DEFAULT_DATE_FORMAT));
LocalDate endLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ofPattern(DateUtils.DEFAULT_DATE_FORMAT));
while (endLocalDate.compareTo(startLocalDate) >= 0) {
dateList.add(startLocalDate.format(DateTimeFormatter.ofPattern(DateUtils.DEFAULT_DATE_FORMAT)));
startLocalDate = startLocalDate.plusDays(1);
}
return dateList;
}
/**
* 获取近多少个月所有月份,升序排列,格式为 yyyy-MM
*
* @return
*/
public static List<String> getLatestMonthList(Integer monthNum) {
List<String> monthList = Lists.newArrayList();
LocalDate date = LocalDate.now();
while (monthNum > 0) {
String yearAndMonth = date.format(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT8));
date = date.minusMonths(1);
monthList.add(0, yearAndMonth);
monthNum --;
}
return monthList;
}
public static Date getCurrentWeekDate(Long week) {
LocalDateTime date = LocalDateTime.now().with(WeekFields.ISO.dayOfWeek(), week);
return Date.from(date.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* 当天的开始时间 00:00:00
*/
public static Date getStartTimeCurrentDay() {
LocalDateTime firstDayOfMonth = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
return Date.from(firstDayOfMonth.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* 当天的结束时间 00:00:00
*/
public static Date getEndTimeCurrentDay() {
LocalDateTime firstDayOfMonth = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
return Date.from(firstDayOfMonth.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* 获取当前月的第一天
*/
public static Date getFirstDayCurrentMonth() {
LocalDateTime firstDayOfMonth = LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth())), LocalTime.MIN);
return Date.from(firstDayOfMonth.atZone(ZoneId.systemDefault()).toInstant());
}
public static Date getLastDayCurrentMonth() {
LocalDateTime lastDayOfMonth = LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.lastDayOfMonth())), LocalTime.MAX);
return Date.from(lastDayOfMonth.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* 获取上个月第一天日期
*
* @param date
* @return java.lang.String
* @author caiym
* @date 2024年04月17日 11:31:37
*/
public static String getFirstDayLastMonth(Date date){
// 获取上个月第一天日期
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.add(Calendar.MONTH, -1);
return formatDate(calendar.getTime(), DEFAULT_DATE_FORMAT);
}
/**
* 获取上个月最后一天日期
*
* @param date
* @return java.lang.String
* @author caiym
* @date 2024年04月17日 11:31:37
*/
public static String getLastDayLastMonth(Date date){
// 获取上个月最后一天日期
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
return formatDate(calendar.getTime(), DEFAULT_DATE_FORMAT);
}
public static Date getFirstDayCurrentYear() {
LocalDateTime firstDayOfYear = LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.firstDayOfYear())), LocalTime.MIN);
return Date.from(firstDayOfYear.atZone(ZoneId.systemDefault()).toInstant());
}
public static Date getLastDayCurrentYear() {
LocalDateTime firstDayOfYear = LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.lastDayOfYear())), LocalTime.MAX);
return Date.from(firstDayOfYear.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* 获取某个月的结束时间,先加减日期,后加减月份
* @param dayNum 多少天之前或多少天之后 值为0是当天
* @param monthNum 多少月之前或多少月之后, 值为0是本月的结束时间,为1是上月的结束时间
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getMonthEndTime(int dayNum, int monthNum, boolean addTime) {
LocalDate now = LocalDate.now().minusDays(dayNum);
now = now.minusMonths(monthNum - 1);
int year = now.getYear();
int month = now.getMonthValue();
LocalDate lastDayOfMonth = LocalDate.of(year, month, 1);
lastDayOfMonth = lastDayOfMonth.minusDays(1);
String result = lastDayOfMonth.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_END_TIME;
}
return result;
}
public static void main(String[] args) {
// System.out.println(plusMonths("2025-03", 1));
// System.out.println(getMonthEndTimeByDate("2025-03-17", true));
String[] strings = getFirstAndLastDayOfMonth("2026-01");
System.out.println(Arrays.toString(strings));
}
/**
* 获取指定日期所在月的第一天
* @param date 日期
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getMonthStartTimeByDate(String date, boolean addTime) {
LocalDate localDate = LocalDate.parse(date, DEFAULT_DATE_FORMATTER);
int year = localDate.getYear();
int month = localDate.getMonthValue();
LocalDate lastDayOfMonth = LocalDate.of(year, month, 1);
String result = lastDayOfMonth.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_END_TIME;
}
return result;
}
/**
* 获取指定日期所在月的最后一天
* @param date 日期
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getMonthEndTimeByDate(String date, boolean addTime) {
LocalDate localDate = LocalDate.parse(date, DEFAULT_DATE_FORMATTER);
localDate = localDate.minusMonths( - 1);
int year = localDate.getYear();
int month = localDate.getMonthValue();
LocalDate lastDayOfMonth = LocalDate.of(year, month, 1);
lastDayOfMonth = lastDayOfMonth.minusDays(1);
String result = lastDayOfMonth.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_END_TIME;
}
return result;
}
/**
* 获取某个月的开始时间,先加减日期,后加减月份
* @param dayNum 多少天之前或多少天之后 值为0是当天
* @param monthNum 多少月之前或多少月之后 值为0是本月的开始时间
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getMonthStartTime(int dayNum, int monthNum, boolean addTime) {
LocalDate now = LocalDate.now().minusDays(dayNum);
int year = now.getYear();
int month = now.getMonthValue();
LocalDate firstDayOfMonth = LocalDate.of(year, month, 1);
firstDayOfMonth = firstDayOfMonth.minusMonths(monthNum);
String result = firstDayOfMonth.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_START_TIME;
}
return result;
}
/**
* 获取指定时间n个月的开始时间
* @param date yyyy-MM-dd
* @param monthNum 多少月之前或多少月之后 值为0是本月的开始时间
* @param addTime 是否需要添加具体的时分秒
* @return
*/
public static String getMonthStartDateByDate(@NotNull String date, int monthNum, boolean addTime) {
try {
LocalDate localDate = LocalDate.parse(date, DEFAULT_DATE_FORMATTER);
localDate = localDate.minusMonths(monthNum);
String result = localDate.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_START_TIME;
}
return result;
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
/**
* 获取指定时间n个月的结束时间
* @param date yyyy-MM-dd
* @param monthNum 多少月之前或多少月之后 值为0是本月的开始时间
* @param addTime 是否需要添加具体的时分秒
* @return
*/
public static String getMonthEndDateByDate(@NotNull String date, int monthNum, boolean addTime) {
try {
LocalDate localDate = LocalDate.parse(date, DEFAULT_DATE_FORMATTER);
localDate = localDate.minusMonths(monthNum);
String result = localDate.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_END_TIME;
}
return result;
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
/**
* 根据当前日期获取多少天之前的结束时间
* @param day 多少天之前或多少天之后
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getDayEndDate(int day, boolean addTime) {
LocalDate data = LocalDate.now();
data = data.minusDays(day);
String result = data.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_END_TIME;
}
return result;
}
/**
* 根据当前日期获取多少天之前、多少个月之前的结束时间
* @param day 多少天之前或多少天之后
* @param day 多少月之前或多少月之后
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getDayEndByDateAndMonth(int day, int month, boolean addTime) {
LocalDate data = LocalDate.now();
data = data.minusDays(day).minusMonths(month);
String result = data.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_END_TIME;
}
return result;
}
/**
* 根据当前日期获取多少天之前的开始
* @param day 多少天之前或多少天之后
* @param addTime 是否需要具体的时分秒
* @return
*/
public static String getDayStartDate(int day, boolean addTime) {
LocalDate data = LocalDate.now();
data = data.minusDays(day);
String result = data.format(DEFAULT_DATE_FORMATTER);
if (addTime) {
return result + CommonConstants.DATE_START_TIME;
}
return result;
}
/**
* 获取上个月时间 格式:yyyy-MM
*/
public static String getLastMonthString(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1); // 月份减1
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
return sdf.format(calendar.getTime());
}
/**
* 获取本月时间 格式:yyyy-MM
*/
public static String getMonthString(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
return sdf.format(date);
}
/**
* 获取上个月的开始时间
* @return
*/
public static Date lastMonthFirstDayTime() {
Calendar instance = Calendar.getInstance();
instance.setTime(new Date());
instance.set(Calendar.MONTH,instance.get(Calendar.MONTH)-1);
instance.set(Calendar.DATE,1);
instance.set(Calendar.HOUR,0);
instance.set(Calendar.MINUTE,0);
instance.set(Calendar.SECOND,0);
return instance.getTime();
}
/**
* 获取当前月的开始时间
* @return
*/
public static Date currentMonthFirstDayTime() {
Calendar instance = Calendar.getInstance();
instance.setTime(new Date());
instance.set(Calendar.MONTH,instance.get(Calendar.MONTH));
instance.set(Calendar.DATE,1);
instance.set(Calendar.HOUR,0);
instance.set(Calendar.MINUTE,0);
instance.set(Calendar.SECOND,0);
return instance.getTime();
}
/**
* @description: 获取本月结束时间
* @author: lqWang
* @date: 2025/3/6 14:24
*/
public static Date getEndOfMonthDate() {
LocalDate lastDayOfMonth = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
LocalDateTime endOfDay = lastDayOfMonth.atTime(23, 59, 59);
ZonedDateTime zonedDateTime = endOfDay.atZone(ZoneId.systemDefault());
return Date.from(zonedDateTime.toInstant());
}
/**
* @description: 获取下个月开始时间
* @author: lqWang
* @date: 2024/12/2 15:15
*/
public static Date nextMonthFirstDayTime(){
LocalDate nextMonthFirstDay = LocalDate.now().plusMonths(1).withDayOfMonth(1);
LocalDateTime startOfNextMonth = nextMonthFirstDay.atStartOfDay();
return Date.from(startOfNextMonth.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* @description: 获取明天开始时间
* @author: lqWang
* @date: 2024/12/2 15:15
*/
public static Date nextDayFirstDayTime(){
LocalDate tomorrow = LocalDate.now().plusDays(1);
LocalDateTime startOfTomorrow = tomorrow.atStartOfDay();
return Date.from(startOfTomorrow.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* @description: 判断date是否在当前月份
* @param: [date]
* @date: 2025/4/11 10:55
*/
public static boolean isDateInCurrentMonth(Date date) {
LocalDateTime localDateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
LocalDateTime now = LocalDateTime.now();
return localDateTime.getYear() == now.getYear() && localDateTime.getMonth() == now.getMonth();
}
/**
* 判断当前日期是不是当月第一天
* @return
*/
public static boolean isMonthFirstDay(){
Calendar instance = Calendar.getInstance();
instance.setTime(new Date());
if (instance.get(Calendar.DATE)== Calendar.SUNDAY) {
return true;
}
return false;
}
/**
* 获取当前日期字符串
*
* @return java.lang.String
* @author caiym
* @date 2023年07月07日 15:39:41
*/
public static String getCurrentDateStr(){
return LocalDate.now().format(DEFAULT_DATE_FORMATTER);
}
public static Boolean isAfter(String dateA, String dateB){
LocalDate localDateA = LocalDate.parse(dateA, DEFAULT_DATE_FORMATTER);
LocalDate localDateB = LocalDate.parse(dateB, DEFAULT_DATE_FORMATTER);
return localDateA.isAfter(localDateB);
}
public static String formatDateStr(String date, String pattern) {
try {
Date date1 = org.apache.commons.lang.time.DateUtils.parseDate(date, PARSER_PATTERNS);
SimpleDateFormat format = new SimpleDateFormat(pattern);
return format.format(date1);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取日期的零点
*
* @return java.util.Date
* @author caiym
* @date 2024年01月31日 16:42:06
*/
public static Date getStartOfDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取日期的23点59分59秒
*
* @return java.util.Date
* @author caiym
* @date 2024年01月31日 16:42:06
*/
public static Date getEndOfDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取上一天的23点59分59秒
*/
public static Date getEndOfPreviousDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}
/**
* 获取给定日期所在月份的第一天(即该月的开始时间)
* @param date 给定的日期
* @return 该日期所在月份的第一天的Date对象
*/
public static Date getMonthStart(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取指定日期上个月的第一天00:00:00.000
* @param date 基准日期
* @return 上个月开始时间的Date对象
*/
public static Date getStartOfLastMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 将日期设置为上个月的第一天
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取指定日期上个月的最后一天23:59:59.999
* @param date 基准日期
* @return 上个月结束时间的Date对象
*/
public static Date getEndOfLastMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 将日期设置为上个月的第一天
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
// 获取上个月的最后一天
int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, lastDay);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}
/**
* 是否是同一天
*
* @param date1
* @param date2
* @return boolean
* @author caiym
* @date 2024年02月22日 14:01:12
*/
public static boolean isSameDay(Date date1, Date date2) {
if (date1 == null || date2 == null) {
return false;
}
LocalDate localDate1 = date1.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = date2.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return localDate1.isEqual(localDate2);
}
/**
* 获取本周周一日期
* @return 周一日期(yyyy-MM-dd)
*/
public static String getThisWeekMonday() {
int dayOfCurrentWeek = LocalDate.now().getDayOfWeek().getValue();
return getDayStartDate(dayOfCurrentWeek - 1, false);
}
/**
* 获取本周周日日期
* @return 周日日期(yyyy-MM-dd)
*/
public static String getThisWeekSunday() {
int dayOfCurrentWeek = LocalDate.now().getDayOfWeek().getValue();
return getDayEndDate(dayOfCurrentWeek - 7, false);
}
/**
* 获取指定日期所在周周一
* @param date
* @return
*/
public static String getMondayByDate(String date) {
LocalDate localDate = LocalDate.parse(date, DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT));
return getMondayByDate(localDate);
}
public static String getMondayByDate(LocalDate localDate) {
int dayOfCurrentWeek = localDate.getDayOfWeek().getValue();
localDate = localDate.minusDays(dayOfCurrentWeek -1 );
return localDate.format(DEFAULT_DATE_FORMATTER);
}
/**
* 将 Date 转换为 "M月d日" 格式的字符串
*/
public static String formatToMonthDay(Date date) {
if (date == null) {
return "";
}
LocalDate localDate = date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
return localDate.format(CHINESE_DATE_WITHOUT_YEAR_FORMATTER);
}
/**
* 获取指定日期所在周周日
* @param date
* @return
*/
public static String getSundayByDate(String date) {
LocalDate localDate = LocalDate.parse(date, DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT));
int dayOfCurrentWeek = localDate.getDayOfWeek().getValue();
localDate = localDate.minusDays(dayOfCurrentWeek - 7);
return localDate.format(DEFAULT_DATE_FORMATTER);
}
/**
* 获取指定日期的上周一
*
* @param date
* @return java.time.LocalDate
* @author caiym
* @date 2024年03月26日 16:41:59
*/
public static LocalDate getLastWeekMonday(LocalDate date) {
int dayOfCurrentWeek = date.getDayOfWeek().getValue();
return date.minusDays(dayOfCurrentWeek + 6);
}
public static String getLastWeekMonday(Date date){
// date转localDate
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 获取上周周一
LocalDate lastWeekMonday = getLastWeekMonday(localDate);
// 格式化日期
return lastWeekMonday.format(DEFAULT_DATE_FORMATTER);
}
public static String getLastWeekMonday() {
LocalDate lastWeekMonday = getLastWeekMonday(LocalDate.now());
return lastWeekMonday.format(DEFAULT_DATE_FORMATTER);
}
public static LocalDate getWeekMonday(LocalDate date) {
int dayOfCurrentWeek = date.getDayOfWeek().getValue() - 1;
return date.minusDays(dayOfCurrentWeek);
}
public static LocalDate getMonthFirstDay(LocalDate date) {
return date.minusDays(date.getDayOfMonth() - 1);
}
/**
* 获取指定日期所在月份的第一天
* 输入日期格式为yyyy-MM-dd,返回格式为yyyy-MM-dd
* @param dateStr
* @return java.lang.String
* @author caiym
* @date 2025年05月01日 15:16:53
*/
public static String getMonthFirstDayStr(String dateStr){
LocalDate date = LocalDate.parse(dateStr, DEFAULT_DATE_FORMATTER);
return getMonthFirstDay(date).format(DEFAULT_DATE_FORMATTER);
}
public static LocalDate getMonthLastDay(LocalDate date) {
return date.plusDays(date.lengthOfMonth() - date.getDayOfMonth());
}
public static String getStartOfLastWeekMonday() {
LocalDate lastWeekMonday = getLastWeekMonday(LocalDate.now());
LocalDateTime localDateTime = lastWeekMonday.atStartOfDay();
return localDateTime.format(DateTimeFormatter.ofPattern(DATE_FORMAT_DATE_TIME));
}
/**
* 获取指定日期的上周周日
*
* @param date
* @return java.time.LocalDate
* @author caiym
* @date 2024年03月26日 16:41:59
*/
public static LocalDate getLastWeekSunday(LocalDate date) {
int dayOfCurrentWeek = date.getDayOfWeek().getValue();
return date.minusDays(dayOfCurrentWeek);
}
public static LocalDate getLastWeekSunday(String dateStr) {
LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT));
return getLastWeekSunday(date);
}
public static String getLastWeekSunDay(Date date){
// date转localDate
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 获取上周周日
LocalDate lastWeekSunday = getLastWeekSunday(localDate);
// 格式化日期
return lastWeekSunday.format(DEFAULT_DATE_FORMATTER); }
public static LocalDate getWeekSunday(LocalDate date) {
int dayOfCurrentWeek = date.getDayOfWeek().getValue() - 1;
return date.plusDays(6 - dayOfCurrentWeek);
}
public static String getLastWeekSunday() {
LocalDate lastWeekSunday = getLastWeekSunday(LocalDate.now());
return lastWeekSunday.format(DEFAULT_DATE_FORMATTER);
}
public static String getEndOfLastWeekSunday() {
LocalDate lastWeekSunday = getLastWeekSunday(LocalDate.now());
LocalDateTime localDateTime = lastWeekSunday.atTime(23, 59, 59);
return localDateTime.format(DateTimeFormatter.ofPattern(DATE_FORMAT_DATE_TIME));
}
public static Date convertStartDate(LocalDate date) {
return Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
public static Date convertEndDate(LocalDate date) {
LocalDateTime localDateTime = date.atTime(23, 59, 59);
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
public static class WeekRange implements Serializable {
private static final long serialVersionUID = 5812973882941465757L;
private String startDate;
private String endDate;
}
// 主方法,返回给定日期范围内的周分组列表
public static List<WeekRange> getWeekRanges(String startDateStr, String endDateStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(startDateStr, formatter);
LocalDate endDate = LocalDate.parse(endDateStr, formatter);
List<WeekRange> weekRanges = new ArrayList<>();
if (startDate.isAfter(endDate)) {
return weekRanges;
}
LocalDate firstWeekStart = LocalDate.parse(startDateStr, formatter);
LocalDate lastWeekEnd = startDate.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
while (lastWeekEnd.isBefore(endDate)) {
WeekRange weekRange = WeekRange.builder()
.startDate(firstWeekStart.format(formatter))
.endDate(lastWeekEnd.format(formatter))
.build();
weekRanges.add(weekRange);
firstWeekStart = lastWeekEnd.plusDays(1);
lastWeekEnd = firstWeekStart.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
}
WeekRange weekRange = WeekRange.builder()
.startDate(firstWeekStart.format(formatter))
.endDate(endDate.format(formatter))
.build();
weekRanges.add(weekRange);
return weekRanges;
}
public static Integer getDayCountBetweenDate(String startDateStr, String endDateStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(startDateStr, formatter);
LocalDate endDate = LocalDate.parse(endDateStr, formatter);
return (int) ChronoUnit.DAYS.between(startDate, endDate) + 1;
}
public static String minusDays(String dateStr, int days) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(dateStr, formatter);
LocalDate newDate = date.minusDays(days);
return newDate.format(formatter);
}
public static String plusDays(String dateStr, int days) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(dateStr, formatter);
LocalDate newDate = date.plusDays(days);
return newDate.format(formatter);
}
/**
*
* @param month yyyy-MM
* @param days
* @return
*/
public static String plusMonths(String month, int months) {
LocalDate date = LocalDate.parse(month.concat("-01"), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate newDate = date.plusMonths(months);
return newDate.format(DateTimeFormatter.ofPattern("yyyy-MM"));
}
public static Boolean isDate(String dateStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
LocalDate.parse(dateStr, formatter);
return true;
} catch (DateTimeParseException e) {
return false;
}
}
public static boolean isWeek(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
return dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY;
}
/**
* 获取date的下一分钟整
*
* @param date
* @return java.util.Date
* @author caiym
* @date 2024年12月23日 14:43:53
*/
public static Date getNextMinute(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取date的前一毫秒
*
* @param date
* @return java.util.Date
* @author caiym
* @date 2024年12月23日 14:50:14
*/
public static Date getPreviousMillisecond(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MILLISECOND, -1);
return calendar.getTime();
}
/**
* @description: 获取当前日期是本月的第几天
* @return: int
* @author: lqWang
* @date: 2025/2/17 15:13
*/
public static int getCurrentDayOfMonth() {
LocalDate today = LocalDate.now();
// 获取当前日期是本月的第几天
int dayOfMonth = today.getDayOfMonth();
return dayOfMonth;
}
/**
* 获取date的所在月的第几天
* @param date
* @return int
*/
public static int getDayOfMonth(Date date) {
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
int dayOfMonth = localDate.getDayOfMonth();
return dayOfMonth;
}
/**
* 获取当前月有多少天
*/
public static int getDayInMonth(Date date) {
// 将 Date 转换为 LocalDate
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
LocalDate localDate = calendar.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDate();
// 获取当前年份和月份
YearMonth yearMonth = YearMonth.from(localDate);
// 获取当前月份的天数
int daysInMonth = yearMonth.lengthOfMonth();
return daysInMonth;
}
/**
* 获取date的前一秒
*
* @param date
* @return java.util.Date
* @author caiym
* @date 2024年12月23日 14:50:14
*/
public static Date getPreviousSecond(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.SECOND, -1);
return calendar.getTime();
}
/**
* @description: 获取上一天日期
* @param: [date]
* @return: java.util.Date
* @author: lqWang
* @date: 2025/1/13 18:50
*/
public static Date getPreviousDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);
return calendar.getTime();
}
/**
* @description: 获取上一个月份
* @param: [date]
* @return: java.lang.String
* @author: lqWang
* @date: 2025/1/13 18:54
*/
public static String getPreviousMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
return sdf.format(calendar.getTime());
}
/**
* @description: 获取上一个月开始时间
* @param: [date]
* @return: java.lang.String
* @author: lqWang
* @date: 2025/1/13 18:54
*/
public static Date getPreviousMonthStart(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
return calendar.getTime();
}
/**
* @description: 获取上一个月结束时间
* @param: [date]
* @return: java.lang.String
* @author: lqWang
* @date: 2025/1/13 18:55
*/
public static Date getPreviousMonthEnd(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1); // 将日期调整到上一个月
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); // 设置为上一个月的最后一天
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
return calendar.getTime();
}
/**
* 获取给定时间五分钟前的 Date 对象
* @param date 原始时间
* @return 五分钟前的 Date(若输入为 null 则返回 null)
*/
public static Date getFiveMinutesBefore(Date date) {
if (date == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MINUTE, -5); // 减去5分钟
return calendar.getTime();
}
/**
* @description: d1-d2,d3-d4,找到他们之间的交集,以每天的形式返回
* @param: [d1, d2, d3, d4]
* @return: java.util.List<java.util.Date>
* @author: lqWang
* @date: 2025/2/20 11:17
*/
public static List<Date> findIntersection(Date d1, Date d2, Date d3, Date d4) {
// 确保d1 <= d2 且 d3 <= d4
if (d1.after(d2)) {
throw new IllegalArgumentException("d1 should be before or equal to d2");
}
if (d3.after(d4)) {
throw new IllegalArgumentException("d3 should be before or equal to d4");
}
// 找到两个区间的开始和结束的最大值与最小值
Date start = d1.after(d3) ? d1 : d3;
Date end = d2.before(d4) ? d2 : d4;
List<Date> intersectionDates = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
// 遍历日期区间以找出交集
while (!calendar.getTime().after(end)) {
intersectionDates.add(calendar.getTime());
calendar.add(Calendar.DATE, 1);
}
return intersectionDates;
}
/**
* 获取date的下一分钟整的前一毫秒
*
* @param date
* @return java.util.Date
* @author caiym
* @date 2024年12月23日 14:50:06
*/
public static Date getNextMinutePreviousMillisecond(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(getNextMinute(date));
calendar.add(Calendar.MILLISECOND, -1);
return calendar.getTime();
}
/**
*
* @Description: 获取当月的天数
* @param yearMonth 月份 格式 yyyy-MM
* @return
*/
public static int lengthOfMonth(String yearMonth) {
return LocalDate.parse(yearMonth.concat("-01"), DateTimeFormatter.ofPattern("yyyy-MM-dd"))
.lengthOfMonth();
}
/**
* @description: 获取i个月后的年月份
* @param: [i]
* @return: java.lang.String
*/
public static String getMonth(int i) {
Calendar cal = Calendar.getInstance();
cal.add(cal.MONTH, i);
SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM");
return dft.format(cal.getTime());
}
public static Date min(Date d1,Date d2){
return d1.before(d2) ? d1:d2;
}
public static Date max(Date d1,Date d2){
return d1.after(d2) ? d1:d2;
}
public static String min(Date d1,Date d2,String format){
return formatDate(d1.before(d2) ? d1:d2,format);
}
public static String max(Date d1,Date d2,String format){
return formatDate(d1.after(d2) ? d1:d2,format);
}
/**
* 获取两个日期之间的所有日期
* @param start
* @param end
* @param format yyyy-MM-dd
* @return java.util.List<java.lang.String>
*/
public static List<String> getFormattedDatesBetween(
LocalDate start, LocalDate end, String format) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
return Stream.iterate(start, date -> date.plusDays(1))
.limit(ChronoUnit.DAYS.between(start, end) + 1)
.map(date -> date.format(formatter))
.collect(Collectors.toList());
}
public static long getTimestamp(String date, String pattern) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
LocalDateTime ldt = LocalDateTime.parse(date, formatter);
ZonedDateTime zdt = ldt.atZone(ZoneId.systemDefault());
return zdt.toInstant().toEpochMilli();
}
public static long getTimestamp(LocalDate localDate) {
ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
// System.out.println("时间戳(秒): " + zonedDateTime.toEpochSecond());
return zonedDateTime.toInstant().toEpochMilli();
}
public static LocalDate toLocalDate(Date date) {
return date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
}
public static Date toDate(LocalDateTime localDateTime){
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
public static List<LocalDate> getDatesBetween(LocalDate start, LocalDate end) {
List<LocalDate> dates = new ArrayList<>();
if (start.isAfter(end)) {
return dates;
}
LocalDate current = start;
while (!current.isAfter(end)) {
dates.add(current);
current = current.plusDays(1);
}
return dates;
}
public static LocalDate getLocalDateByMd(String text){
TemporalAccessor accessor = DateTimeFormatter.ofPattern("M/d", Locale.ENGLISH).parse(text);
int month = accessor.get(ChronoField.MONTH_OF_YEAR);
int day = accessor.get(ChronoField.DAY_OF_MONTH);
int year = LocalDate.now().getYear();
return LocalDate.of(year, month, day);
}
public static LocalDate[] getLastMondayAndLastWeekend(LocalDate localDate){
LocalDate[] localDates = new LocalDate[2];
LocalDate currentMonday = localDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
localDates[0] = currentMonday.minusWeeks(1);
localDates[1] = currentMonday.minusDays(1);;
return localDates;
}
public static Date addTime(Date date,int field, int amount){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(field,amount);
return calendar.getTime();
}
public static String addOneDay(String dateStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
LocalDate date = LocalDate.parse(dateStr, formatter);
LocalDate nextDay = date.plusDays(1);
return nextDay.format(formatter);
} catch (Exception e) {
log.info("DateUtils.addOneDay error:{},",e.getMessage(),e);
return dateStr;
}
}
public static long[] getHoursBetweenDates(Date date1, Date date2) {
Instant instant1 = date1.toInstant();
Instant instant2 = date2.toInstant();
Duration duration = Duration.between(instant1, instant2);
long totalMinutes = Math.abs(duration.toMinutes());
long hours = totalMinutes / 60;
long minutes = totalMinutes % 60;
return new long[]{hours,minutes};
}
public static int getMonthDays(Date date){
Calendar calendar = Calendar.getInstance();
if (date != null) calendar.setTime(date);
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
}
public static Map<String, String> calculateLateOrEarlyInfo(Date inputDate, boolean isLate) {
Map<String, String> map = new HashMap<>();
map.put("effectiveMinutes","0");
map.put("deductionDays","0.0");
if (inputDate == null) return map;
LocalDateTime inputDateTime = inputDate.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
LocalDate today = inputDateTime.toLocalDate();
LocalDateTime workStart = today.atTime(9, 30);
LocalDateTime lunchStart = today.atTime(12, 0);
LocalDateTime lunchEnd = today.atTime(13, 0);
LocalDateTime workEnd = today.atTime(17, 30);
long totalMinutes = 0;
long effectiveMinutes = 0;
LocalDateTime overlapStart;
LocalDateTime overlapEnd;
if (isLate) {
if (inputDateTime.isBefore(workStart)) {
return map;
}
totalMinutes = ChronoUnit.MINUTES.between(workStart, inputDateTime);
long maxLateMinutes = ChronoUnit.MINUTES.between(workStart, workEnd);
totalMinutes = Math.min(totalMinutes, maxLateMinutes);
overlapStart = lunchStart.isAfter(workStart) ? lunchStart : workStart;
overlapEnd = inputDateTime.isBefore(lunchEnd) ? inputDateTime : lunchEnd;
} else {
if (inputDateTime.isAfter(workEnd)) {
return map;
}
totalMinutes = ChronoUnit.MINUTES.between(inputDateTime, workEnd);
overlapStart = inputDateTime.isAfter(lunchStart) ? inputDateTime : lunchStart;
overlapEnd = lunchEnd.isBefore(workEnd) ? lunchEnd : workEnd;
}
long overlapMinutes = 0;
if (overlapStart.isBefore(overlapEnd) || overlapStart.isEqual(overlapEnd)) {
overlapMinutes = ChronoUnit.MINUTES.between(overlapStart, overlapEnd);
}
effectiveMinutes = totalMinutes - overlapMinutes;
if (effectiveMinutes < 0) effectiveMinutes = 0;
double deductionDays = (double) effectiveMinutes / 480.0;
deductionDays = Math.round(deductionDays * 100) / 100.0;
map.put("effectiveMinutes", String.valueOf(effectiveMinutes));
map.put("deductionDays", String.valueOf(deductionDays));
return map;
}
public static Date[] getMonthRange(Date inputDate) {
if (inputDate == null) {
inputDate = new Date();
}
LocalDate localDate = inputDate.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
LocalDate firstDayOfMonth = localDate.withDayOfMonth(1);
LocalDateTime startDateTime = firstDayOfMonth.atStartOfDay();
LocalDate lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1);
LocalDateTime endDateTime = lastDayOfMonth.atTime(LocalTime.MAX);
return new Date[] {
Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant())
};
}
public static LocalDate timestamp2LocalDate(long timestamp){
return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()).toLocalDate();
}
public static String timestamp2String(long timestamp,String pattern){
LocalDate date = Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDate();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
return date.format(formatter);
}
/**
* 计算日历天数差(考虑日期变化,忽略时间部分)
* @param date1 第一个日期
* @param date2 第二个日期
* @return 日历天数差(date2的日期 - date1的日期)
*/
public static long calendarDaysBetween(Date date1, Date date2) {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("日期参数不能为null");
}
// 标准化到UTC午夜时间(消除时间部分影响)
long time1 = date1.getTime();
long time2 = date2.getTime();
// 计算UTC日期的天数差
long days1 = TimeUnit.MILLISECONDS.toDays(time1);
long days2 = TimeUnit.MILLISECONDS.toDays(time2);
return days2 - days1;
}
/**
* 计算两个年月之间的月份差值
* @param start 开始年月,格式:yyyy-MM
* @param end 结束年月,格式:yyyy-MM
* @return 月份差值(正数或负数)
* @throws RuntimeException 如果日期格式无效
*/
public static int calculateMonthDiff(String start, String end) {
if (start == null || end == null) {
throw new IllegalArgumentException("日期参数不能为null");
}
try {
YearMonth startYm = YearMonth.parse(start, YEAR_MONTH_FORMATTER);
YearMonth endYm = YearMonth.parse(end, YEAR_MONTH_FORMATTER);
return (int) ChronoUnit.MONTHS.between(startYm, endYm);
} catch (Exception e) {
throw new RuntimeException("日期格式错误,请使用yyyy-MM格式", e);
}
}
/**
* 计算两个年月之间的月份差值
*/
public static int calculateMonthDiffAbs(String start, String end) {
int diff = calculateMonthDiff(start, end);
return diff;
}
/**
* 获取指定月份的第一天和最后一天
* @param monthStr 月份字符串,格式:yyyy-MM
* @return String数组,[0]=当月第一天,[1]=当月最后一天
* @throws DateTimeParseException 如果月份格式不正确
*/
public static String[] getFirstAndLastDayOfMonth(String monthStr) {
// 验证月份字符串格式
if (monthStr == null || monthStr.trim().isEmpty()) {
throw new IllegalArgumentException("月份字符串不能为空");
}
if (!monthStr.matches("\\d{4}-\\d{2}")) {
throw new IllegalArgumentException("月份格式不正确,应为 yyyy-MM");
}
try {
YearMonth.parse(monthStr, YEAR_MONTH_FORMATTER);
} catch (DateTimeParseException e) {
throw new IllegalArgumentException("无效的月份: " + monthStr, e);
}
// 解析月份
YearMonth yearMonth = YearMonth.parse(monthStr, YEAR_MONTH_FORMATTER);
// 获取当月第一天
LocalDate firstDay = yearMonth.atDay(1);
// 获取当月最后一天
LocalDate lastDay = yearMonth.atEndOfMonth();
// 转换为字符串格式
String firstDayStr = firstDay.atTime(0, 0, 0).format(DATE_TIME_FORMATTER);
String lastDayStr = lastDay.atTime(23, 59, 59).format(DATE_TIME_FORMATTER);
return new String[]{firstDayStr, lastDayStr};
}
/**
* 判断日期是周几,返回数字表示
* 参照JDK中Calendar的常量:SUNDAY = 1, MONDAY = 2, TUESDAY = 3,
* WEDNESDAY = 4, THURSDAY = 5, FRIDAY = 6, SATURDAY = 7
*
* @param date 日期
* @return 周几的数字表示(1-7)
*/
public static int getDayOfWeek(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 获取星期几,返回的就是JDK常量值
// 1=SUNDAY, 2=MONDAY, 3=TUESDAY, 4=WEDNESDAY, 5=THURSDAY, 6=FRIDAY, 7=SATURDAY
return calendar.get(Calendar.DAY_OF_WEEK);
}
}
ramework-archetype-rpc
RPC服务项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.dj.smartcarlife.config 配置层
├─cn.com.glsx.dj.smartcarlife.manager 通用处理层
├─cn.com.glsx.dj.smartcarlife.mapper Dao映射层
├─cn.com.glsx.dj.smartcarlife.remote RPC接口实现层
├─cn.com.glsx.dj.smartcarlife.service 业务层
├─cn.com.glsx.dj.smartcarlife.util 工具包
└─cn.com.glsx.dj.smartcarlife.Main.java 程序入口
├─resources 资源文件目录
├─config
├─application.properties 应用配置文件
├─META-INF
└─orm SQL配置文件
├─templates 模板目录
└─*.flt freemarker模板,(可用于邮件模板)
└─logback.xml 日志配置文件
└─webapp web前端文件目录
└─WEB-INF
└─bin shell脚本文件(包含启动、停止、重启等)
└─test 测试目录
├─java
└─cn.com.glsx.dj.smartcarlife/service 测试代码
└─resources 测试资源目录
└─pom.xml pom文件
二、使用说明:
1、运行项目前需在配置中心创建配置信息,配置内容参考三配置说明:
1.1> dataId : application.properties --> ore.diamond.dataId + ore.diamond.env
1.2> group : application.properties --> ore.diamond.group
1.3> content : 参考三配置说明
2、生成mybatis文件的插件,使用说明:
1.1> 生成之后可以删掉插件
1.2> IDEA内:点击右侧Maven Projects > 项目 plugins > mybatis-generator 运行
1.3> ECLIPSE内:右键点击项目,选择RUN AS maven build > 输入maven命令:
mybatis-generator:generate -e > 运行
3、Bean转换器mapstruct使用说明:
1.1> 在converter包内建立Bean转换对应的转换器,传入source和target的类型。
1.2> 在remote内使用spring的方式引入bean。
1.3> Bean的属性名一样的情况下,不需要重写方法。
4、自定义过滤器加入方式:
1.1> 在src.main.resources.META-INF.dubbo文件夹下新建文件com.alibaba.dubbo.rpc.Filter
1.2> 在该文件内写入自定义过滤器类的完整地址,以键值对的形式加入,左边为key名称,例如:
dubboAuthorizeFilter=cn.com.glsx.payment.roof.filter.DubboAuthorizeFilter
1.3> 在钻石配置中加入dubbo过滤器的配置,名字为key,例如:
ore.dubbo.provider.enabled=true
ore.dubbo.provider.filter=dubboAuthorizeFilter
三、配置说明:
#----------------------------------------------------------------------------------------------------------
# dubbo配置
# dubbo应用名称
ore.dubbo.application.name=rpc-dj-smartcarlife
# dubbo应用所有者
ore.dubbo.application.owner=zhoulm
# dubbo服务注册地址
ore.dubbo.registry.address=zookeeper://192.168.3.206:2181
# dubbo服务注册超时时间
ore.dubbo.registry.timeout=30000
# 默认协议:dubbo
ore.dubbo.protocol.name=dubbo
# dubbo服务扫描包路径
ore.dubbo.scan=cn.com.glsx.dj.smartcarlife.remote
# dubbo服务监控
ore.dubbo.monitor.protocol=registry
# dubbo服务统计
ore.dubbo.provider.filter=metrics
# dubbo配置中心
ore.dubbo.config-center.address=zookeeper://192.168.3.206:2181
# dubbo元数据中心
ore.dubbo.metadata-report.address=zookeeper://192.168.3.206:2181
┌------------------------------------------------------------┐
注:如需在RPC服务里面支持REST风格的服务
1、需在pom中添加如下依赖:
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-dubbo-rest</artifactId>
</dependency>
2、修改钻石配置
# dubbo协议配置(二选一)
#ore.dubbo.protocol.name=dubbo
#ore.dubbo.protocol.port=20880
# dubbo协议配置(二选一)
ore.dubbo.protocols.dubbo.name=dubbo
ore.dubbo.protocols.dubbo.port=20880
# REST协议配置
ore.dubbo.protocols.rest.name=rest
# 应用服务器(默认jetty)
ore.dubbo.protocols.rest.server=jetty
# 服务端口
ore.dubbo.protocols.rest.port=8080
# 最大连接数
ore.dubbo.protocols.rest.accepts=500
# 线程池大小
ore.dubbo.protocols.rest.threads=100
# 基础相对路径
ore.dubbo.protocols.rest.contextpath=rest-api
3、Java示例代码:
@Service //dubbo注解,注册服务
@Path("users") //JAX-RS注解
public class UserServiceRemoteImpl implements UserServiceRemote {
@POST //JAX-RS注解
@Path("register") //JAX-RS注解
@Consumes({MediaType.APPLICATION_JSON}) //JAX-RS注解
public void registerUser(User user) {
// save the user...
}
}
4、访问示例:
http://localhost:8080/rest-api/users/register
5、参考资料
resteasy框架使用介绍,参阅官方文档,地址:http://docs.jboss.org/resteasy/docs/3.6.0.Final/userguide/html/index.html
dubbo rest协议说明,参阅官方文档,地址:http://dubbo.apache.org/zh-cn/docs/user/references/protocol/rest.html
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.druid.url=jdbc:mysql://host:port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.druid.driver-class=com.mysql.jdbc.Driver
ore.druid.username=用户名
ore.druid.password=密码
ore.druid.initial-size=1
ore.druid.min-idle=1
ore.druid.max-active=20
ore.druid.test-on-borrow=true
# druid连接池监控配置
# 是否开启监控
ore.druid.monitor.enabled=true
# 监控后台用户名,默认:admin
ore.druid.monitor.login-username=admin
# 监控后台密码,默认:admin123
ore.druid.monitor.login-password=admin123
# 监控访问路径匹配规则,默认:/druid/*
ore.druid.monitor.url-mappings=/druid/*
# 监控访问IP白名单,多个以英文逗号“,”隔开,默认:127.0.0.1
ore.druid.monitor.allow=127.0.0.1
# 监控访问IP黑名单(存在共同时,deny优先于allow),多个以英文逗号“,”隔开
ore.druid.monitor.deny=192.168.0.1
# 是否能够重置数据,默认:false,则隐藏页面重置按钮
ore.druid.monitor.reset-enable=false
# 开启SQL监控
ore.druid.filter.stat.enabled=true
# 数据库类型
ore.druid.filter.stat.db-type=mysql
# 是否合并sql
ore.druid.filter.stat.merge-sql=true
# 是否记录慢查询
ore.druid.filter.stat.log-slow-sql=true
# 慢查询时间:200毫秒(默认3000毫秒)
ore.druid.filter.stat.slow-sql-millis=200
# 开启日志监控
ore.druid.filter.slf4j.enabled=true
ore.druid.filter.slf4j.data-source-log-enabled=true
ore.druid.filter.slf4j.statement-executable-sql-log-enable=true
# 开启Spring监控
ore.druid.monitor.spring.enabled=true
# 扫描的包路径,可配置多个,以逗号‘,’隔开
ore.druid.monitor.scanPackages=cn.com.glsx.dj.smartcarlife.mapper.*,cn.com.glsx.dj.smartcarlife.service.*
#----------------------------------------------------------------------------------------------------------
# mybatis配置
# 实体模型包
mybatis.type-aliases-package=cn.com.glsx.dj.smartcarlife.model
# SQL脚本文件路径
mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
# 开启mybatis sql打印
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
mapper.not-empty=false
mapper.identity=MYSQL
# 多数据源配置(主库/读写)
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.primary.druid.url=jdbc:mysql://主库host:主库port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.primary.druid.driver-class=com.mysql.jdbc.Driver
ore.primary.druid.username=用户名
ore.primary.druid.password=密码
ore.primary.druid.initial-size=1
ore.primary.druid.min-idle=1
ore.primary.druid.max-active=20
ore.primary.druid.test-on-borrow=true
# mybatis配置
# 实体模型包
ore.primary.mybatis.type-aliases-package=cn.com.glsx.dj.smartcarlife.model
# SQL脚本文件路径
ore.primary.mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
ore.primary.mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
ore.primary.mapper.not-empty=false
ore.primary.mapper.identity=MYSQL
┌------------------------------------------------------------┐
使用说明:
方式一:
1、引入SqlSessionTemplate
@Resource(name = "primarySqlSessionTemplate")
private SqlSessionTemplate primarySqlSessionTemplate;
2、获取XxMapper
XxMapper mapper = primarySqlSessionTemplate.getMapper(XxMapper.class);
3、调用
mapper.insert(record);
mapper.delete(record);
......
方式二:
1、XxMapper类上添加注解@PrimaryMapper
2、普通方式调用
└------------------------------------------------------------┘
# 多数据源配置(从库/只读)
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.secondary.druid.url=jdbc:mysql://从库host:从库port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.secondary.druid.driver-class=com.mysql.jdbc.Driver
ore.secondary.druid.username=用户名
ore.secondary.druid.password=密码
ore.secondary.druid.initial-size=1
ore.secondary.druid.min-idle=1
ore.secondary.druid.max-active=20
ore.secondary.druid.test-on-borrow=true
# mybatis配置
# 实体模型包
ore.secondary.mybatis.type-aliases-package=cn.com.glsx.dj.smartcarlife.model
# SQL脚本文件路径
ore.secondary.mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
ore.secondary.mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
ore.secondary.mapper.not-empty=false
ore.secondary.mapper.identity=MYSQL
┌------------------------------------------------------------┐
使用说明:
方式一:
1、引入SqlSessionTemplate
@Resource(name = "secondarySqlSessionTemplate")
private SqlSessionTemplate secondarySqlSessionTemplate;
2、获取XxMapper
XxMapper mapper = secondarySqlSessionTemplate.getMapper(XxMapper.class);
3、调用
mapper.insert(record);
mapper.delete(record);
......
方式二:
1、XxMapper类上添加注解@SecondaryMapper
2、普通方式调用
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# 分页配置
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
#----------------------------------------------------------------------------------------------------------
# Dubbo Swagger配置
# 是否启用swagger-dubbo,默认为true
swagger.dubbo.enable=true
# http请求地址,默认为http://ip:port/h/com.XXX.XxService/method
#swagger.dubbo.http=h
# rpc zk调用 or 本地调用,默认为rpc
#swagger.dubbo.cluster=rpc
# dubbo 服务版本号,可不配置
swagger.dubbo.application.version=0.0.1-SNAPSHOT
# dubbo服务groupId,可不配置
swagger.dubbo.application.groupId=cn.com.glsx.dj
# dubbo服务artifactId,可不配置
swagger.dubbo.application.artifactId=rpc-dj-smartcarlife
┌------------------------------------------------------------┐
使用说明:
1、接口或实现类的方法上添加Swagger注解@ApiOperation(nickname = "queryBy**", value = "查询**", notes = "根据**查询**", httpMethod="GET")[非必须]
2、接口参数添加Swagger注解@ApiParam(value = "参数名称", required=true)[非必须]
3、对象属性添加Swagger注解@ApiModelProperty(value = "属性名称")[非必须]
注意事项:
1、对于服务接口方法重载,为了在http请求中唯一确认一个方法,需要使用注解@ApiOperation(nickname = "byId"),通过nickname标记唯一路径(如果不填写,将只显示一个方法)。
此时,rest的请求地址为:http://ip:port/h/com.XXX.XxService/method/byId
2、Object对象作为http请求参数为json string格式
3、swagger注解既可以写在接口上,也可以写在实现类上
4、原生类型作为http请求参数为必填
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# Freemarker模板配置
# 模板存放路径
spring.freemarker.template-loader-path=classpath:/templates/
# 是否开启模板缓存,默认是开启,开发时请关闭
spring.freemarker.cache=false
# 模板的编码设置,默认UTF-8
spring.freemarker.charset=UTF-8
# 是否检测模板已存在本地
spring.freemarker.check-template-location=true
# 模板的媒体类型设置,默认为text/html
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
# 后缀设置,默认为.ftl
spring.freemarker.suffix=.ftl
┌------------------------------------------------------------┐
注:如需使用freemarker需在pom中添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# kafka生产者配置
spring.kafka.producer.metadata.broker.list=192.168.3.207:9092
spring.kafka.producer.topic=消息主题
spring.kafka.producer.serializer.class=kafka.serializer.DefaultEncoder
spring.kafka.producer.type=async
spring.kafka.producer.request.required.acks=1
┌------------------------------------------------------------┐
注:如需使用kafka发送消息需在pom中添加如下依赖
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-jms</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# kafka消费者配置
spring.kafka.consumer.group.id=rpc-dj-smartcarlife-consumer
spring.kafka.consumer.zookeeper.connect=192.168.3.207:2181
spring.kafka.consumer.zookeeper.connection.timeout.ms=15000
spring.kafka.consumer.zookeeper.session.timeout.ms=15000
spring.kafka.consumer.auto.commit.interval.ms=1000
spring.kafka.consumer.auto.offset.reset=largest
spring.kafka.consumer.topic=消息主题
# 默认分区消费线程数
spring.kafka.consumer.partitionsNum=6
# 指定主题分区消费线程数
spring.kafka.consumer.消息主题.partitionsNum=2
┌------------------------------------------------------------┐
注:如需使用kafka接收消息需在pom中添加如下依赖
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-jms</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# redis配置
ore.redis.hostName=192.168.3.207
ore.redis.port=6379
ore.redis.password=
ore.redis.pool.maxActive=600
ore.redis.pool.maxWait=10000
ore.redis.pool.maxTotal=300
ore.redis.pool.maxIdle=300
ore.redis.pool.minIdle=0
ore.redis.timeout=30000
┌------------------------------------------------------------┐
注:如需使用redis,需在pom中添加如下依赖
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-redis</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# 雪花算法
# 开启雪花算法
ore.snowflake.enabled=true
# 数据中心ID(0~31)
ore.snowflake.data-center-id=1
# 工作节点ID(0~31)
ore.snowflake.worker-id=1
┌------------------------------------------------------------┐
使用说明:
1、注入SnowflakeWorker
@Autowired
private SnowflakeWorker snowflakeWorker;
2、调用本地方法
long randomId = snowflakeWorker.nextId();
└------------------------------------------------------------┘
# 调用新框架的工具类
cn.com.glsx.dj.smartcarlife.util.SpringCloudHttpUtil
# 配置类
cn.com.glsx.dj.smartcarlife.config.GSCConfig
cn.com.glsx.dj.smartcarlife.config.GSCParam
# 配置参考
#调用新框架配置
gsc.common.gscPool[gsc-vcp-web-facade].baseurl=http://192.168.3.145:9898/gsc-vcp-web-facade
gsc.common.gscPool[gsc-vcp-web-facade].appId=dj_zhixin
gsc.common.gscPool[gsc-vcp-web-facade].nonce=48e5e13229b82c1b4e6e8c96151f0637
gsc.common.gscPool[gsc-vcp-web-facade].secret=c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b
server.port=10100
server.servlet.context-path=/rpc-dj-devrules
server.display-name=rpc-dj-devrules
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/rpc-dj-devrules/rpc-dj-devrules.log
logging.level.root=INFO
logging.level=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=rpc-dj-devrules
ore.diamond.env=release
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</pattern>
</layout>
<encoder>
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<!-- druid连接池慢查询日志记录 -->
<appender name="DruidFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}.druid_slow_sql</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2020-01-01日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2020-01-01的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}.druid_slow_sql-%d{yyyy-MM-dd}.%i</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,命名日志文件,例如log-error-2020-01-01.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>200MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<appender-ref ref="DruidFILE" />
</root>
</configuration>
\ No newline at end of file \ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file \ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
package cn.com.glsx.dj.devrules.listing.service;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.devrules.listing.dto.GoodsListingApprovalDTO;
import cn.com.glsx.dj.devrules.listing.enums.GoodsListingEnum.ShelfType;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingApproval;
import cn.com.glsx.dj.smartcarlife.service.BaseServiceTest;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class GoodsListingApprovalServiceTest extends BaseServiceTest {
@Autowired
private GoodsListingApprovalService goodsListingApprovalService;
@Test
public void testListWithPage(){
RpcPagination<GoodsListingApprovalDTO> pagination = new RpcPagination<>();
pagination.setCondition(GoodsListingApprovalDTO.builder()
.shelfType(ShelfType.SINGLE.getValue()).merchantName("test1")
.build());
log.info("result:{}",goodsListingApprovalService.listWithPage(pagination));
}
@Test
public void testGetByBusinessCode() {
log.info("result:{}",goodsListingApprovalService.getByBusinessCode("GL202604181701592783"));
}
@Test
public void testInsert() {
GoodsListingApproval record = GoodsListingApproval.builder()
.shelfType(ShelfType.SINGLE.getValue())
.goodsCreateExcel("test-excel")
.baseSceneCode("111111")
.updatedBy("test-user")
.build();
log.info("result:{}",goodsListingApprovalService.insert(record));
}
@Test
public void testReject() {
GoodsListingApproval record = GoodsListingApproval.builder()
.businessCode("GL202604181701592783")
.rejectedReason("test-reject")
.updatedBy("test-user")
.build();
log.info("result:{}",goodsListingApprovalService.reject(record));
}
}
package cn.com.glsx.dj.devrules.listing.service;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.devrules.listing.enums.GoodsListingEnum.LogOperatorType;
import cn.com.glsx.dj.devrules.listing.model.GoodsListingLog;
import cn.com.glsx.dj.smartcarlife.service.BaseServiceTest;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class GoodsListingLogServiceTest extends BaseServiceTest{
@Autowired
private GoodsListingLogService goodsListingLogService;
@Test
public void testInsert() {
GoodsListingLog record = GoodsListingLog.builder()
.operatorType(LogOperatorType.INITIATE.getValue())
.businessCode("GL202604181701592783")
.updatedBy("test-user")
.build();
log.info("result:{}",goodsListingLogService.insert(record));
}
@Test
public void testListByBusinessCode() {
log.info("result:{}",goodsListingLogService.listByBusinessCode("GL202604181701592783"));
}
}
package cn.com.glsx.dj.smartcarlife.manager;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.dj.devrules.listing.Main;
/**
* @Title: BaseServiceTest.java
* @Description:
* @author zhoulm
* @date 2018年1月6日 下午1:23:03
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseManagerTest {
}
package cn.com.glsx.dj.smartcarlife.remote;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.dj.devrules.listing.Main;
/**
* @Title: BaseRemoteTest.java
* @Description:
* @author zhoulm
* @date 2018年1月6日 下午3:58:33
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseRemoteTest {
}
package cn.com.glsx.dj.smartcarlife.service;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.dj.devrules.listing.Main;
/**
* @Title: BaseServiceTest.java
* @Description:
* @author zhoulm
* @date 2018年1月6日 下午1:23:03
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseServiceTest {
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<!-- 确保已安装mybatis generator eclipse插件 -->
<generatorConfiguration>
<context id="DB2Tables" targetRuntime="MyBatis3">
<property name="javaFileEncoding" value="UTF-8"/>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="org.oreframework.datasource.mybatis.mapper.OreMapper"/>
<property name="caseSensitive" value="true"/>
<property name="useActualColumnNames" value="true" />
<!--<property name="beginningDelimiter" value="`"/>-->
<!--<property name="endingDelimiter" value="`"/>-->
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.227:3306/dj_smartcarlife?characterEncoding=utf8" userId="dev_admin" password="1f7e1ed2" />
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="cn.com.glsx.dj.devrules.listing.model" targetProject="../rpc-dj-goods-listing-api/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="META-INF/orm" targetProject="src/main/resources">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator targetPackage="cn.com.glsx.dj.devrules.listing.mapper" targetProject="MAVEN" type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 可配置多个mybatis-generator:generate -->
<table tableName="dj_car_life_goods_listing_approval" domainObjectName="GoodsListingApproval" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>
</generatorConfiguration>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!