Commit d594a1ff by wutong

自动周转新增按仓库类型和仓库编码跑周转数据.

parent d2a3b199
......@@ -26,6 +26,7 @@ public class Application {
private static final String EVENT_RDB_STORAGE_PASSWORD = propertiesUtil.getPropertyAsString("EVENT_RDB_STORAGE_PASSWORD");
public static void main(String[] args) {
new JobScheduler(createRegistryCenter(), createJobConfiguration(),createJobEventConfiguration(), new AutoTurnoverJobListener()).init();
new JobScheduler(createRegistryCenter(), createJobConfigurationParam(),createJobEventConfiguration(), new AutoTurnoverJobListener()).init();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
......@@ -40,6 +41,12 @@ public class Application {
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
private static LiteJobConfiguration createJobConfigurationParam() {
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(propertiesUtil.getPropertyAsString("JOB_NAME_PARAM"), propertiesUtil.getPropertyAsString("JOB_CRON_PARAM"), propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT_PARAM")).build();
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, AutoTurnoverJob.class.getCanonicalName());
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
private static JobEventConfiguration createJobEventConfiguration() {
JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource());
......
......@@ -2,6 +2,7 @@ package com.bailuntec.job;
import com.bailuntec.domain.dto.SalesVolumeDTO;
import com.bailuntec.domain.entity.DcAutoSales;
import com.bailuntec.domain.example.DcAutoSalesExample;
import com.bailuntec.domain.pojo.DataNode;
import com.bailuntec.domain.pojo.LinerRegression;
import com.bailuntec.mapper.DcAutoSalesMapper;
......@@ -82,11 +83,13 @@ public class AutoSalesServiceImpl implements AutoSalesService {
dcAutoSales.setFitRVariable(fittingResult[2]);
try {
DcAutoSalesMapper dcAutoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
dcAutoSalesMapper.upsertSelective(dcAutoSales);
SessionUtil.getSession().commit();
int i = dcAutoSalesMapper.updateByExampleSelective(dcAutoSales, DcAutoSalesExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoSales.getBailunSku()).andWarehouseCodeEqualTo(dcAutoSales.getWarehouseCode()).example());
if (i == 0) {
dcAutoSalesMapper.insertSelective(dcAutoSales);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Mybatis操作DB失败", e);
throw new RuntimeException("Mybatis操作dcAutoSalesDB失败", e);
} finally {
SessionUtil.closeSession();
}
......
......@@ -25,12 +25,14 @@ public class AutoTurnoverJobListener implements ElasticJobListener {
public void beforeJobExecuted(ShardingContexts shardingContexts) {
try {
DcAutoTurnoverMapper autoTurnoverMapper = SessionUtil.getSession().getMapper(DcAutoTurnoverMapper.class);
autoTurnoverMapper.truncateAutoInboundTable();
autoTurnoverMapper.truncateAutoInventoryTable();
autoTurnoverMapper.truncateAutoShortSupplyTable();
autoTurnoverMapper.truncateAutoTurnoverTable();
autoTurnoverMapper.truncateAutoSalesTable();
autoTurnoverMapper.truncateAutoExceptionTable();
if ( shardingContexts.getJobName().equals("show-auto-turnover")) {
autoTurnoverMapper.truncateAutoInboundTable();
autoTurnoverMapper.truncateAutoInventoryTable();
autoTurnoverMapper.truncateAutoShortSupplyTable();
autoTurnoverMapper.truncateAutoTurnoverTable();
autoTurnoverMapper.truncateAutoSalesTable();
autoTurnoverMapper.truncateAutoExceptionTable();
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Mybatis操作DB失败", e);
......@@ -46,7 +48,6 @@ public class AutoTurnoverJobListener implements ElasticJobListener {
int pageSize = 1000;
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
List<DcAutoException> dcAutoExceptions = null;
SqlSession sqlSession = SessionUtil.getFactory().openSession(true);
try {
DcAutoExceptionMapper mapper = sqlSession.getMapper(DcAutoExceptionMapper.class);
......
......@@ -122,10 +122,15 @@ public interface DcBaseStockMapper {
*/
int upsertSelective(DcBaseStock record);
List<DcBaseStock> listStockById(@Param("v1") int v1, @Param("v2") int v2);
List<DcBaseStock> listNoChinaWarehouse(@Param("v1") int v1, @Param("v2") int v2);
List<DcBaseStock> listParameterStockById(@Param("jobParameter")String jobParameter,@Param("v1") int v1, @Param("v2") int v2);
List<DcBaseStock> listOrderByFba(@Param("v1") int v1, @Param("v2") int v2);
List<DcBaseStock> listWarehouseStockById(@Param("warehouseCode")String warehouseCode,@Param("v1") int v1, @Param("v2") int v2);
List<DcBaseStock> listInStockNotInAutoTurnover();
long countByParam(@Param("jobParameter") String jobParameter);
long countByWarehouseCode(@Param("warehouseCode")String warehouseCode);
}
\ No newline at end of file
......@@ -1198,11 +1198,34 @@
SELECT * FROM dc_base_stock tb1 inner join dc_base_warehouse tb2 on tb1.warehouse_code = tb2.warehouse_code and tb2.hq_type in ('FBA仓','海外仓','第三方仓库') order by type_id desc limit #{v1}, #{v2}
</select>
<select id="listOrderByFba" resultType="com.bailuntec.domain.entity.DcBaseStock">
<select id="listStockById" resultType="com.bailuntec.domain.entity.DcBaseStock">
SELECT * FROM dc_base_stock order by id asc limit #{v1}, #{v2}
</select>
<select id="listParameterStockById" resultType="com.bailuntec.domain.entity.DcBaseStock">
select * from dc_base_stock tb1
left join (select warehouse_code,hq_type from dc_base_warehouse where hq_type=#{jobParameter}) tb2
on tb1.warehouse_code=tb2.warehouse_code where tb2.warehouse_code is not null order by tb1.id asc limit #{v1}, #{v2}
</select>
<select id="listWarehouseStockById" resultType="com.bailuntec.domain.entity.DcBaseStock">
select * from dc_base_stock tb1 where warehouse_code=#{warehouseCode} order by id asc limit #{v1}, #{v2}
</select>
<select id="listInStockNotInAutoTurnover" resultType="com.bailuntec.domain.entity.DcBaseStock">
SELECT tb1.* FROM dc_base_stock tb1 LEFT JOIN dc_auto_turnover tb2 ON tb1.bailun_sku = tb2.bailun_sku and tb1.warehouse_code = tb2.warehouse_code WHERE tb2.bailun_sku is null;
</select>
<select id="countByParam" resultType="long">
select count(*)
from dc_base_stock tb1
left join (select warehouse_code,hq_type from dc_base_warehouse where hq_type=#{jobParameter}) tb2
on tb1.warehouse_code=tb2.warehouse_code where tb2.warehouse_code is not null;
</select>
<select id="countByWarehouseCode" resultType="long">
select count(*)
from dc_base_stock tb1
where warehouse_code=#{warehouseCode}
</select>
</mapper>
\ No newline at end of file
SKUMS_PARENT_CATEGORIES_URL=http://10.0.6.13:8001/api/BailunCateData/GetMyParentCategories
#SKUMS_PARENT_CATEGORIES_URL=http://api.sku.bailuntec.com/api/BailunCateData/GetMyParentCategories
TJ_OUT_STOCK_URL=http://tj.bailuntec.com/ApiService/GetNoStockForDataCenter
\ No newline at end of file
......@@ -11,4 +11,7 @@ ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE=data-center
JOB_NAME=show-auto-turnover
JOB_CRON=0 30 0 * * ? *
SHARDING_TOTAL_COUNT=4
\ No newline at end of file
SHARDING_TOTAL_COUNT=8
JOB_NAME_PARAM=show-auto-turnover-param
JOB_CRON_PARAM=0 30 0 * * ? 2099
SHARDING_TOTAL_COUNT_PARAM=8
\ No newline at end of file
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