Commit 2dc8ab0c by yinyong

WMS物流费用接口数据对接、半成品数据更改

parent 84922038
......@@ -2,6 +2,7 @@ package com.bailuntec;
import com.alibaba.druid.pool.DruidDataSource;
import com.bailuntec.job.FbaStockJob;
import com.bailuntec.job.WmsLogisticsJob;
import com.bailuntec.job.WmsStockJob;
import com.bailuntec.listener.FbaStockListener;
import com.bailuntec.listener.WmsStockListener;
......@@ -29,6 +30,7 @@ public class Application {
public static void main(String[] args) {
new JobScheduler(createRegistryCenter(),createJobConfiguration(),createJobEventConfiguration(),new FbaStockListener()).init();
new JobScheduler(createRegistryCenter(),createJobConfiguration1(),createJobEventConfiguration(),new WmsStockListener()).init();
new JobScheduler(createRegistryCenter(),createJobConfiguration2()).init();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
......@@ -51,6 +53,13 @@ public class Application {
return simpleJobRootConfig;
}
private static LiteJobConfiguration createJobConfiguration2() {
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(propertiesUtil.getPropertyAsString("JOB_NAME_LOGISTICS"), propertiesUtil.getPropertyAsString("JOB_CRON_LOGISTICS"), propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT")).build();
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, WmsLogisticsJob.class.getCanonicalName());
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
private static JobEventConfiguration createJobEventConfiguration() {
JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource());
return jobEventRdbConfig;
......
package com.bailuntec.domain.pojo;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class Logistics {
private List<String> Company_Codes;
private String TrackingNo;
private String AllocatecargoOrderCode;
private LocalDateTime StartModificationTime;
private LocalDateTime EndModificationTime;
private Integer pageIndex;
private Integer pageCount;
}
package com.bailuntec.domain.pojo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class WmsLogisticsInfo {
private String targetUrl;
private Boolean success;
private String error;
private String unAuthorizedRequest;
private Result result;
@Data
public class Result{
private Integer pageIndex;
private Integer totalPages;
private Integer total;
private Boolean hasPreViousPage;
private Boolean hasNextPage;
private List<LogisticsInner> result;
@Data
public class LogisticsInner{
@JSONField(name = "id")
private Integer wmsId;
@JSONField(name = "company_Code")
private String companyCode;
@JSONField(name = "company_Name")
private String companyName;
private String billCode;
private String trackingNo;
private BigDecimal merchantOutputWeightKg;
private BigDecimal merchantShipmentCostCny;
private LocalDateTime merchantReconciliationTime;
private String reconciliationType;
private String infoId;
private BigDecimal outputWeightKg;
private BigDecimal bailunShipmentCostCny;
private LocalDateTime shipmentTime;
private String diffStateType;
private BigDecimal merchantOutputWeightKgOriginal;
private BigDecimal merchantShipmentCostSnyOriginal;
private BigDecimal costDiffDecimal;
private BigDecimal weightDiffDecimal;
private String lineName;
private String feeCode;
private String remark;
private String generateBillStatus;
private String feeProductType;
private LocalDateTime lastModificationTime;
private LocalDateTime gmtCreateTime;
private LocalDateTime gmtModifyTime;
}
}
}
package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bailuntec.domain.entity.DcBaseLogistics;
import com.bailuntec.domain.entity.DcBaseStock;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.example.DcBaseLogisticsExample;
import com.bailuntec.domain.example.DcBaseStockExample;
import com.bailuntec.domain.pojo.*;
import com.bailuntec.mapper.DcBaseLogisticsMapper;
import com.bailuntec.mapper.DcBaseStockMapper;
import com.bailuntec.mapper.DcBaseWarehouseMapper;
import com.bailuntec.mapper.JobPointLogMapper;
import com.bailuntec.support.PointJob;
import com.bailuntec.utils.OkHttpUtil;
import com.bailuntec.utils.PropertiesUtil;
import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.List;
@Slf4j
public class WmsLogisticsJob extends PointJob {
private PropertiesUtil propertiesUtil = PropertiesUtil.getInstance("const");
@Override
public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) {
Logistics wmsLogistic = new Logistics();
wmsLogistic.setStartModificationTime(jobPointLog.getStartTime().minusHours(9));
wmsLogistic.setEndModificationTime(jobPointLog.getEndTime());
wmsLogistic.setPageCount(jobPointLog.getPageSize());
do {
OkHttpClient client = OkHttpUtil.getInstance();
MediaType mediaType = MediaType.parse("application/json");
wmsLogistic.setPageIndex(jobPointLog.getPageIndex() > 0? jobPointLog.getPageIndex() : 1);
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(wmsLogistic));
Request request = new Request.Builder()
.url(propertiesUtil.getPropertyAsString("LOGISTICS_WMS_URL"))
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
String resultStr = null;
try {
response = client.newCall(request).execute();
resultStr = response.body().string();
} catch (IOException e) {
throw new RuntimeException("调用wms系统库存接口失败", e);
} finally {
if (response != null) {
response.close();
}
}
if (StringUtils.isNotBlank(resultStr)) {
WmsLogisticsInfo wmsLogisticsInfo = JSON.parseObject(resultStr, WmsLogisticsInfo.class);
if (wmsLogisticsInfo.getSuccess() != null && wmsLogisticsInfo.getSuccess()) {
WmsLogisticsInfo.Result result = wmsLogisticsInfo.getResult();
List<WmsLogisticsInfo.Result.LogisticsInner> items = result.getResult();
if (jobPointLog.getPageIndex().equals(0)) {
int totalPage = result.getTotal() % jobPointLog.getPageSize() == 0 ? result.getTotal() / jobPointLog.getPageSize() : result.getTotal() / jobPointLog.getPageSize() + 1;
jobPointLog.setPageIndex(totalPage + 1);
}
if (items != null && items.size() > 0) {
try {
DcBaseLogisticsMapper dcBaseLogisticsMapper = SessionUtil.getSession().getMapper(DcBaseLogisticsMapper.class);
DcBaseLogistics dcBaseLogistics = new DcBaseLogistics();
items.forEach(wmsStockItem -> {
try {
BeanUtils.copyProperties(dcBaseLogistics, wmsStockItem);
dcBaseLogistics.setMerchantOutputWeightKg(dcBaseLogistics.getMerchantOutputWeightKg().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setMerchantShipmentCostCny(dcBaseLogistics.getMerchantShipmentCostCny().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setOutputWeightKg(dcBaseLogistics.getOutputWeightKg().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setBailunShipmentCostCny(dcBaseLogistics.getBailunShipmentCostCny().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setMerchantOutputWeightKgOriginal(dcBaseLogistics.getMerchantOutputWeightKgOriginal().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setMerchantShipmentCostSnyOriginal(dcBaseLogistics.getMerchantShipmentCostSnyOriginal().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setCostDiffDecimal(dcBaseLogistics.getCostDiffDecimal().setScale(4, RoundingMode.HALF_EVEN));
dcBaseLogistics.setWeightDiffDecimal(dcBaseLogistics.getWeightDiffDecimal().setScale(4, RoundingMode.HALF_EVEN));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("WMS物流BeanUtils.copyProperties失败");
}
int i = dcBaseLogisticsMapper.updateByExampleSelective(dcBaseLogistics, DcBaseLogisticsExample.newAndCreateCriteria().andWmsIdEqualTo(dcBaseLogistics.getWmsId()).example());
if (i == 0) {
dcBaseLogisticsMapper.insertSelective(dcBaseLogistics);
}
});
if (jobPointLog.getPageIndex() % 5 == 0) {
JobPointLogMapper jobPointLogMapper = SessionUtil.getSession().getMapper(JobPointLogMapper.class);
jobPointLogMapper.upsertSelective(jobPointLog);
}
} catch (Exception e) {
throw new RuntimeException("MYBATIS操作DB失败", e);
} finally {
SessionUtil.closeSession();
}
}
} else {
throw new RuntimeException("调用wms物流费接口失败");
}
} else {
throw new RuntimeException("调用wms物流费接口失败");
}
jobPointLog.setPageIndex(jobPointLog.getPageIndex() - 1);
} while (jobPointLog.getPageIndex() > 0);
jobPointLog.setPageIndex(0);
jobPointLog.setStartTime(jobPointLog.getEndTime());
jobPointLog.setEndTime(jobPointLog.getStartTime().plusDays(jobPointLog.getIntervalTime()).isAfter(LocalDateTime.now()) ? LocalDateTime.now() : jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()));
}
}
......@@ -2,3 +2,5 @@ STOCK_FBA_URL=http://172.31.255.247/api/services/app/ThirdStockFbaService/GetFba
STOCK_WMS_URL=http://172.31.255.247/api/services/app/WMSStockService/SearchAllProductStockByPage
#STOCK_FBA_URL=http://api.wms.bailuntec.com/api/services/app/ThirdStockFbaService/GetFbaStocks
#STOCK_WMS_URL=http://api.wms.bailuntec.com/api/services/app/WMSStockService/SearchAllProductStockByPage
LOGISTICS_WMS_URL=http://wms.bailuntec.com/api/services/app/LogisticsReconciliationService/GetNormalDataQuery
\ No newline at end of file
......@@ -13,4 +13,6 @@ JOB_NAME_FBA=base-sync-stock-fba
JOB_CRON_FBA=0 30 01/03 * * ? *
JOB_NAME_WMS=base-sync-stock-wms
JOB_CRON_WMS=0/1 * * * * ? *
JOB_NAME_LOGISTICS=base-sync-logistics-wms
JOB_CRON_LOGISTICS=0/1 * * * * ? *
SHARDING_TOTAL_COUNT=1
\ No newline at end of file
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcBaseLogistics;
import com.bailuntec.domain.example.DcBaseLogisticsExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcBaseLogisticsMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
long countByExample(DcBaseLogisticsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int deleteByExample(DcBaseLogisticsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int insert(DcBaseLogistics record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int insertSelective(DcBaseLogistics record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseLogistics selectOneByExample(DcBaseLogisticsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
List<DcBaseLogistics> selectByExample(DcBaseLogisticsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
DcBaseLogistics selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcBaseLogistics record, @Param("example") DcBaseLogisticsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcBaseLogistics record, @Param("example") DcBaseLogisticsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcBaseLogistics record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
*/
int updateByPrimaryKey(DcBaseLogistics record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcBaseLogistics record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_logistics
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcBaseLogistics record);
}
\ No newline at end of file
......@@ -345,7 +345,7 @@ public class BalanceSheetService {
int rows = 5000;
int page = 1;
try {
param = "?btime=2020-03-15&etime=" + DateTimeUtil.dateToString(datePlusOne, DateTimeUtil.DATE_FORMAT);
param = "?btime="+DateTimeUtil.dateToString(DateTimeUtil.addDays(datePlusOne, -3), DateTimeUtil.DATE_FORMAT)+"&etime=" + DateTimeUtil.dateToString(datePlusOne, DateTimeUtil.DATE_FORMAT);
SemiPageResultDTO responseDTO = JSONObject.parseObject(HttpUtil.httpGet(getSemiStockLogUrl + param +
"&page=" + page + "&rows=" + rows), SemiPageResultDTO.class);
if(responseDTO.getSuccess() && responseDTO.getData().getTotalItems() > 0){
......
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