Commit fcbc2c35 by yinyong

周转突增新增仓库类型判断

parent 09fe7a25
......@@ -34,6 +34,15 @@ public class DcAutoUprushConfig {
private BigDecimal percentage;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_uprush_config.hq_type
*
* @mbg.generated
*/
private String hqType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
......@@ -48,6 +57,7 @@ public class DcAutoUprushConfig {
sb.append(", id=").append(id);
sb.append(", warehouseCode=").append(warehouseCode);
sb.append(", percentage=").append(percentage);
sb.append(", hqType=").append(hqType);
sb.append("]");
return sb.toString();
}
......@@ -72,7 +82,8 @@ public class DcAutoUprushConfig {
DcAutoUprushConfig other = (DcAutoUprushConfig) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getWarehouseCode() == null ? other.getWarehouseCode() == null : this.getWarehouseCode().equals(other.getWarehouseCode()))
&& (this.getPercentage() == null ? other.getPercentage() == null : this.getPercentage().equals(other.getPercentage()));
&& (this.getPercentage() == null ? other.getPercentage() == null : this.getPercentage().equals(other.getPercentage()))
&& (this.getHqType() == null ? other.getHqType() == null : this.getHqType().equals(other.getHqType()));
}
/**
......@@ -88,6 +99,7 @@ public class DcAutoUprushConfig {
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getWarehouseCode() == null) ? 0 : getWarehouseCode().hashCode());
result = prime * result + ((getPercentage() == null) ? 0 : getPercentage().hashCode());
result = prime * result + ((getHqType() == null) ? 0 : getHqType().hashCode());
return result;
}
}
\ No newline at end of file
......@@ -559,6 +559,76 @@ public class DcAutoUprushConfigExample {
addCriterion("percentage not between", value1, value2, "percentage");
return (Criteria) this;
}
public Criteria andHqTypeIsNull() {
addCriterion("hq_type is null");
return (Criteria) this;
}
public Criteria andHqTypeIsNotNull() {
addCriterion("hq_type is not null");
return (Criteria) this;
}
public Criteria andHqTypeEqualTo(String value) {
addCriterion("hq_type =", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeNotEqualTo(String value) {
addCriterion("hq_type <>", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeGreaterThan(String value) {
addCriterion("hq_type >", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeGreaterThanOrEqualTo(String value) {
addCriterion("hq_type >=", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeLessThan(String value) {
addCriterion("hq_type <", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeLessThanOrEqualTo(String value) {
addCriterion("hq_type <=", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeLike(String value) {
addCriterion("hq_type like", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeNotLike(String value) {
addCriterion("hq_type not like", value, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeIn(List<String> values) {
addCriterion("hq_type in", values, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeNotIn(List<String> values) {
addCriterion("hq_type not in", values, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeBetween(String value1, String value2) {
addCriterion("hq_type between", value1, value2, "hqType");
return (Criteria) this;
}
public Criteria andHqTypeNotBetween(String value1, String value2) {
addCriterion("hq_type not between", value1, value2, "hqType");
return (Criteria) this;
}
}
/**
......
......@@ -9,6 +9,7 @@
<id column="id" jdbcType="INTEGER" property="id" />
<result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode" />
<result column="percentage" jdbcType="DECIMAL" property="percentage" />
<result column="hq_type" jdbcType="VARCHAR" property="hqType" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
......@@ -81,7 +82,7 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, warehouse_code, percentage
id, warehouse_code, percentage, hq_type
</sql>
<select id="selectByExample" parameterType="com.bailuntec.domain.example.DcAutoUprushConfigExample" resultMap="BaseResultMap">
<!--
......@@ -142,10 +143,10 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into dc_auto_uprush_config (id, warehouse_code, percentage
)
values (#{id,jdbcType=INTEGER}, #{warehouseCode,jdbcType=VARCHAR}, #{percentage,jdbcType=DECIMAL}
)
insert into dc_auto_uprush_config (id, warehouse_code, percentage,
hq_type)
values (#{id,jdbcType=INTEGER}, #{warehouseCode,jdbcType=VARCHAR}, #{percentage,jdbcType=DECIMAL},
#{hqType,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcAutoUprushConfig">
<!--
......@@ -163,6 +164,9 @@
<if test="percentage != null">
percentage,
</if>
<if test="hqType != null">
hq_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -174,6 +178,9 @@
<if test="percentage != null">
#{percentage,jdbcType=DECIMAL},
</if>
<if test="hqType != null">
#{hqType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.bailuntec.domain.example.DcAutoUprushConfigExample" resultType="java.lang.Long">
......@@ -202,6 +209,9 @@
<if test="record.percentage != null">
percentage = #{record.percentage,jdbcType=DECIMAL},
</if>
<if test="record.hqType != null">
hq_type = #{record.hqType,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -215,7 +225,8 @@
update dc_auto_uprush_config
set id = #{record.id,jdbcType=INTEGER},
warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
percentage = #{record.percentage,jdbcType=DECIMAL}
percentage = #{record.percentage,jdbcType=DECIMAL},
hq_type = #{record.hqType,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -233,6 +244,9 @@
<if test="percentage != null">
percentage = #{percentage,jdbcType=DECIMAL},
</if>
<if test="hqType != null">
hq_type = #{hqType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -243,7 +257,8 @@
-->
update dc_auto_uprush_config
set warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
percentage = #{percentage,jdbcType=DECIMAL}
percentage = #{percentage,jdbcType=DECIMAL},
hq_type = #{hqType,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcAutoUprushConfig">
......@@ -263,6 +278,9 @@
<if test="percentage != null">
percentage,
</if>
<if test="hqType != null">
hq_type,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -275,6 +293,9 @@
<if test="percentage != null">
#{percentage,jdbcType=DECIMAL},
</if>
<if test="hqType != null">
#{hqType,jdbcType=VARCHAR},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
......@@ -287,6 +308,9 @@
<if test="percentage != null">
percentage = #{percentage,jdbcType=DECIMAL},
</if>
<if test="hqType != null">
hq_type = #{hqType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<insert id="upsert" parameterType="com.bailuntec.domain.entity.DcAutoUprushConfig">
......@@ -296,14 +320,15 @@
@project https://github.com/itfsw/mybatis-generator-plugin
-->
insert into dc_auto_uprush_config
(id, warehouse_code, percentage)
(id, warehouse_code, percentage, hq_type)
values
(#{id,jdbcType=INTEGER}, #{warehouseCode,jdbcType=VARCHAR}, #{percentage,jdbcType=DECIMAL}
)
(#{id,jdbcType=INTEGER}, #{warehouseCode,jdbcType=VARCHAR}, #{percentage,jdbcType=DECIMAL},
#{hqType,jdbcType=VARCHAR})
on duplicate key update
id = #{id,jdbcType=INTEGER},
warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
percentage = #{percentage,jdbcType=DECIMAL}
percentage = #{percentage,jdbcType=DECIMAL},
hq_type = #{hqType,jdbcType=VARCHAR}
</insert>
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcAutoUprushConfigExample" resultMap="BaseResultMap">
<!--
......
......@@ -144,7 +144,10 @@ public class AutoTurnoverJob extends PointJob {
String bailunSku = dcBaseStock.getBailunSku();
String warehouseCode = dcBaseStock.getWarehouseCode();
DcAutoSales dcAutoSales = null;
DcBaseWarehouse dcBaseWarehouse = null;
try {
DcBaseWarehouseMapper baseWarehouseMapper = SessionUtil.getSession().getMapper(DcBaseWarehouseMapper.class);
dcBaseWarehouse = baseWarehouseMapper.selectOneByExample(DcBaseWarehouseExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example());
BigDecimal incrementalRatio = BigDecimal.ONE;
BigDecimal compareSales = BigDecimal.ZERO;
DcAutoSalesMapper autoSalesMapper = null;
......@@ -153,12 +156,14 @@ public class AutoTurnoverJob extends PointJob {
Map<String, BigDecimal> map = autoSalesMapper.getSalesAvg(queryTime, bailunSku, warehouseCode);
DcAutoUprushConfigMapper dcAutoUprushConfigMapper = SessionUtil.getSession().getMapper(DcAutoUprushConfigMapper.class);
DcAutoUprushConfig dcAutoUprushConfig = dcAutoUprushConfigMapper.selectOneByExample(DcAutoUprushConfigExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example());
if(dcAutoUprushConfig == null && dcBaseWarehouse != null) {
dcAutoUprushConfig = dcAutoUprushConfigMapper.selectOneByExample(DcAutoUprushConfigExample.newAndCreateCriteria().andHqTypeEqualTo(dcBaseWarehouse.getHqType()).example());
}
if(dcAutoUprushConfig != null && map != null) {
incrementalRatio = incrementalRatio.add(dcAutoUprushConfig.getPercentage());
compareSales = (map.get("seven_sales").add(map.get("fourteen_sales"))).divide(BigDecimal.valueOf(2), RoundingMode.HALF_EVEN).multiply(incrementalRatio);
}
autoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
if(compareSales.compareTo(BigDecimal.ZERO) == 0) {
salesVolumeDTO = autoSalesMapper.getSalesVolumeDTONoCompare(queryTime, bailunSku, warehouseCode);
}else {
......@@ -180,7 +185,7 @@ public class AutoTurnoverJob extends PointJob {
} finally {
SessionUtil.closeSession();
}
autoTurnoverUseDcAutoSales(bailunSku, warehouseCode, dcAutoSales, dcBaseStock);
autoTurnoverUseDcAutoSales(bailunSku, warehouseCode, dcAutoSales, dcBaseStock, dcBaseWarehouse);
}
/*
......@@ -189,7 +194,7 @@ public class AutoTurnoverJob extends PointJob {
* 库存信息传入,dcBaseStock
* 计算自动周转
*/
private void autoTurnoverUseDcAutoSales(String bailunSku, String warehouseCode, DcAutoSales dcAutoSales, DcBaseStock dcBaseStock) throws Exception {
private void autoTurnoverUseDcAutoSales(String bailunSku, String warehouseCode, DcAutoSales dcAutoSales, DcBaseStock dcBaseStock, DcBaseWarehouse dcBaseWarehouse) throws Exception {
LocalDate recordTime = LocalDate.now();
DcAutoTurnover dcAutoTurnover = new DcAutoTurnover();
dcAutoTurnover.setBailunSku(bailunSku);
......@@ -203,7 +208,6 @@ public class AutoTurnoverJob extends PointJob {
* 供应链长度 = 周转天数 = 供应商交期 + 入库时间(2天质检入库时间) + 调拨头程 + 调拨打包 + 海外仓入库
*/
DcBaseSku turnoverSku = null;
DcBaseWarehouse dcBaseWarehouse = null;
//从采购平均指标,仓库平均指标拿周转天数, 拿不到的或者数值异常的, 才按上面的来
DcAveragePurchase dcAveragePurchase = null;
DcAverageWarehouse dcAverageWarehouse = null;
......@@ -212,8 +216,7 @@ public class AutoTurnoverJob extends PointJob {
try {
DcBaseSkuMapper baseSkuMapper = SessionUtil.getSession().getMapper(DcBaseSkuMapper.class);
turnoverSku = baseSkuMapper.selectOneByExample(DcBaseSkuExample.newAndCreateCriteria().andBailunSkuEqualTo(bailunSku).example());
DcBaseWarehouseMapper baseWarehouseMapper = SessionUtil.getSession().getMapper(DcBaseWarehouseMapper.class);
dcBaseWarehouse = baseWarehouseMapper.selectOneByExample(DcBaseWarehouseExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example());
DcAveragePurchaseMapper dcAveragePurchaseMapper = SessionUtil.getSession().getMapper(DcAveragePurchaseMapper.class);
dcAveragePurchase = dcAveragePurchaseMapper.selectOneByExample(DcAveragePurchaseExample.newAndCreateCriteria().andBailunSkuEqualTo(bailunSku).andWarehouseCodeEqualTo(warehouseCode).andSupplierIdEqualTo(turnoverSku.getSuppliersId()).example());
DcAverageWarehouseMapper dcAverageWarehouseMapper = SessionUtil.getSession().getMapper(DcAverageWarehouseMapper.class);
......
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