Commit a40368a1 by wutong

订单部分SKU仓库按自定义规则计算头程费; 新增一些工具类, 可以推送消息到企业微信

parent 8f3432a9
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcBaseOmsConfigCostFirst;
import com.bailuntec.domain.example.DcBaseOmsConfigCostFirstExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcBaseOmsConfigCostFirstMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
long countByExample(DcBaseOmsConfigCostFirstExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int deleteByExample(DcBaseOmsConfigCostFirstExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int insert(DcBaseOmsConfigCostFirst record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int insertSelective(DcBaseOmsConfigCostFirst record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseOmsConfigCostFirst selectOneByExample(DcBaseOmsConfigCostFirstExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
List<DcBaseOmsConfigCostFirst> selectByExample(DcBaseOmsConfigCostFirstExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
DcBaseOmsConfigCostFirst selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcBaseOmsConfigCostFirst record, @Param("example") DcBaseOmsConfigCostFirstExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcBaseOmsConfigCostFirst record, @Param("example") DcBaseOmsConfigCostFirstExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcBaseOmsConfigCostFirst record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
int updateByPrimaryKey(DcBaseOmsConfigCostFirst record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcBaseOmsConfigCostFirst record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcBaseOmsConfigCostFirst record);
}
\ No newline at end of file
......@@ -14,6 +14,11 @@
<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
......
package com.bailuntec.domain.entity;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DcBaseOmsConfigCostFirst {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_oms_config_cost_first.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_oms_config_cost_first.bailun_sku
*
* @mbg.generated
*/
private String bailunSku;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_oms_config_cost_first.warehouse_code
*
* @mbg.generated
*/
private String warehouseCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_oms_config_cost_first.price
*
* @mbg.generated
*/
private BigDecimal price;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_oms_config_cost_first.company_id
*
* @mbg.generated
*/
private Integer companyId;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", bailunSku=").append(bailunSku);
sb.append(", warehouseCode=").append(warehouseCode);
sb.append(", price=").append(price);
sb.append(", companyId=").append(companyId);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
DcBaseOmsConfigCostFirst other = (DcBaseOmsConfigCostFirst) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getBailunSku() == null ? other.getBailunSku() == null : this.getBailunSku().equals(other.getBailunSku()))
&& (this.getWarehouseCode() == null ? other.getWarehouseCode() == null : this.getWarehouseCode().equals(other.getWarehouseCode()))
&& (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
&& (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_oms_config_cost_first
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getBailunSku() == null) ? 0 : getBailunSku().hashCode());
result = prime * result + ((getWarehouseCode() == null) ? 0 : getWarehouseCode().hashCode());
result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode());
return result;
}
}
\ No newline at end of file
package com.bailuntec.utils;
import java.io.PrintWriter;
import java.io.StringWriter;
public class ExceptionUtil {
/**
* 将Throwable异常转换为字符串.
*
* @param cause 需要转换的异常
* @return 转换后的异常字符串
*/
public static String transform(final Throwable cause) {
if (null == cause) {
return "";
}
StringWriter result = new StringWriter();
try (PrintWriter writer = new PrintWriter(result)) {
cause.printStackTrace(writer);
}
return result.toString();
}
}
package com.bailuntec.utils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class RedisUtil {
private final static PropertiesUtil propertiesUtil = PropertiesUtil.getInstance("redis");
private static JedisPool jedisPool;
private RedisUtil() {
}
public static Jedis getResource() {
synchronized (RedisUtil.class) {
if (jedisPool == null) {
jedisPool = new JedisPool(propertiesUtil.getPropertyAsString("host"), propertiesUtil.getPropertyAsInt("port"));
}
return jedisPool.getResource();
}
}
public static void destory() {
synchronized (RedisUtil.class) {
if (jedisPool != null) {
jedisPool.destroy();
}
}
}
}
package com.bailuntec.utils;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.params.SetParams;
import java.io.IOException;
@Slf4j
public final class RobotWorkWeixin {
private final static OkHttpClient client = OkHttpUtil.getInstance();
/**
* 推送消息到企业微信机器人
* 如果计算的Key值在Redis存在, 则一天内不会重复推送
* @param webhook 微信回调地址
* @param content 异常内容
*/
public static void push(final String webhook, final String content) {
Jedis jedis = RedisUtil.getResource();
String contentSub = content.length() > 2000?content.substring(0,2000):content;
String key = DigestUtils.md5DigestAsHex((webhook + contentSub).getBytes());
if (!jedis.exists(key)) {
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"msgtype\": \"text\",\"text\": {\"content\": \"" + contentSub + "\"}}");
Request request = new Request.Builder()
.url(webhook)
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
try {
response = client.newCall(request).execute();
} catch (IOException e) {
throw new RuntimeException("回调企业微信机器人失败", e);
} finally {
if (response != null ) {
response.close();
}
}
jedis.setex(key,86400,contentSub);
}
jedis.close();
}
}
......@@ -4,8 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--<properties resource="db-tj.properties"/>-->
<!-- <properties resource="db-dev.properties"/>-->
<properties resource="db-prod.properties"/>
<properties resource="db-dev.properties"/>
<!-- <properties resource="db-prod.properties"/>-->
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
......
#host=127.0.0.1
host=redis.blt.com
port=6379
\ No newline at end of file
......@@ -45,12 +45,21 @@
<elastic-job-lite-core.version>2.1.5</elastic-job-lite-core.version>
<druid.version>1.1.12</druid.version>
<docker-maven-plugin.version>1.2.0</docker-maven-plugin.version>
<jedis.version>3.0.1</jedis.version>
<skipDockerBuild>true</skipDockerBuild>
</properties>
<dependencyManagement>
<dependencies><!--这下面进行依赖管理 -->
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment