Compare commits

..

No commits in common. "d4a31e1236c5d5b1ce48bad181eee7cc6512dffb" and "9c0a8428f28a0fd007f2a7dd2082d6edd2383346" have entirely different histories.

7 changed files with 13 additions and 240 deletions

View File

@ -21,19 +21,9 @@ public class WebController {
@Autowired @Autowired
private SxDataService sxDataService; private SxDataService sxDataService;
@RequestMapping("/test") @RequestMapping("/upload")
public void upload(){ public void upload(){
CommentModel commentModel= sxDataService.getCommentModel(); System.out.println("upload");
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
if(dataBaseInfo==null){
log.error("syncGoods dataBaseInfo is null");
return;
}
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
}
// sxDataService.getCategoryChildren(new DataBaseInfo(),"0101");
System.out.println(sxDataService.getCategoryChildren(dataBaseInfo,"01"));
//webClientService.uploudSxData(); //webClientService.uploudSxData();
} }
@ -130,19 +120,7 @@ public class WebController {
@RequestMapping("/syncStoreData") @RequestMapping("/syncStoreData")
public void syncStoreData(){ public void syncStoreData(){
CommentModel commentModel= sxDataService.getCommentModel(); sxDataService.syncStoreData(new DataBaseInfo(),sxDataService.getCommentModel());
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
if(dataBaseInfo==null){
log.error("syncGoods dataBaseInfo is null");
return;
}
if(StringUtils.isEmpty(commentModel.getSyncTime())){
commentModel =sxDataService.getCommentModel();
}
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
}
sxDataService.syncStoreData(dataBaseInfo,commentModel);
} }
@ -158,7 +136,7 @@ public class WebController {
commentModel =sxDataService.getCommentModel(); commentModel =sxDataService.getCommentModel();
} }
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){ if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
commentModel.setSyncTime(DateUtil.formatDate(dataBaseInfo.getRefreshTime())); commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
} }
sxDataService.syncAtive(new DataBaseInfo(),commentModel); sxDataService.syncAtive(new DataBaseInfo(),commentModel);
// sxDataService.syncAtive(new DataBaseInfo(),new CommentModel()); // sxDataService.syncAtive(new DataBaseInfo(),new CommentModel());
@ -176,7 +154,7 @@ public class WebController {
commentModel =sxDataService.getCommentModel(); commentModel =sxDataService.getCommentModel();
} }
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){ if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
commentModel.setSyncTime(DateUtil.formatDate(dataBaseInfo.getRefreshTime())); commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
} }
sxDataService.syncAtiveShops(new DataBaseInfo(),commentModel); sxDataService.syncAtiveShops(new DataBaseInfo(),commentModel);
//sxDataService.syncAtiveShops(new DataBaseInfo(),new CommentModel()); //sxDataService.syncAtiveShops(new DataBaseInfo(),new CommentModel());

View File

@ -182,33 +182,6 @@ public class BaseDao {
return total; return total;
} }
public Integer getTotalSpecShop(String ip, String username, String password,Integer portNumber, String dataBaseName,String where){
int total=0;
Connection connection=getConnection(ip,username,password,portNumber,dataBaseName);
try {
String sql="select count(1) from t_pub_plan_detail_b d left join t_pub_plan_master m on " +
" d.plan_no =m.plan_no %s";
sql=String.format(sql,where);
log.info(sql);
PreparedStatement ps= connection.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
while (rs.next()){
total=rs.getInt(1);
}
} catch (SQLException e) {
log.info("数据库查询异常方法{},异常信息{}","com.suisung.mall.shop.sixun.dao.BaseDao.getBaseTotal",e.getMessage());
throw new RuntimeException(e);
}
finally {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return total;
}
public Integer getVipBaseTotal(String ip, String username, String password,Integer portNumber, String dataBaseName, String table,String where){ public Integer getVipBaseTotal(String ip, String username, String password,Integer portNumber, String dataBaseName, String table,String where){
int total=0; int total=0;
Connection connection=getConnection(ip,username,password,portNumber,dataBaseName); Connection connection=getConnection(ip,username,password,portNumber,dataBaseName);

View File

@ -55,9 +55,6 @@ public class SxDataDao extends BaseDao{
public final static String DEFAULT_IMG="https://digitalassets.tesla.com/tesla-contents/image/upload/f_auto,q_auto/Homepage-Model-Y-2-Promo-Hero-Tablet-CN.png"; public final static String DEFAULT_IMG="https://digitalassets.tesla.com/tesla-contents/image/upload/f_auto,q_auto/Homepage-Model-Y-2-Promo-Hero-Tablet-CN.png";
private final static String T_PUB_PLAN_MASTER="t_pub_plan_master";//活动方案表
private final static String T_PUB_PLAN_DETAIL_B="t_pub_plan_detail_b";//活动商品表
private final static String PLAN_NO="plan_no";//活动方案表排序字段
/** /**
* 查找商品分类数据 * 查找商品分类数据
* @param dataBaseInfo * @param dataBaseInfo
@ -604,17 +601,6 @@ public class SxDataDao extends BaseDao{
where); where);
} }
/**
*
* @param dataBaseInfo
* @return
*/
public Integer getNewActiveCount(DataBaseInfo dataBaseInfo){
String where=dataBaseInfo.getWhere()+" and rule_no in('DD','PS','PM') and range_flag='I'";
return getBaseTotal(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName(),
T_PUB_PLAN_MASTER,where);
}
/** /**
* *
* @param dataBaseInfo * @param dataBaseInfo
@ -726,141 +712,4 @@ public class SxDataDao extends BaseDao{
return clsBrandDtos; return clsBrandDtos;
} }
/**
*获取促销活动价格 时段特价单
* @param dataBaseInfo
* DD-直接折扣 t_pub_plan_sendext t_pub_plan_detail_b
* PS-直接特价 t_pub_plan_detail_b
* PM-im促销 t_pub_plan_detail_b
* range_flag='I' 代表按商品维度促销
* @return
*/
public List<ActiveDto> getNewActiveList(DataBaseInfo dataBaseInfo,int pageNo,int pageSize){
String where=dataBaseInfo.getWhere()+" and rule_no in('DD','PS','PM') and range_flag='I'";
ResultDto resultDto=baseFindListPage(dataBaseInfo.getIp()
,dataBaseInfo.getUserName()
,dataBaseInfo.getPassword()
,dataBaseInfo.getDbPort()
,dataBaseInfo.getDataBaseName()
,T_PUB_PLAN_MASTER
,PLAN_NO
,pageNo
,pageSize
,where);
ResultSet rs= resultDto.getResultSet();
List<ActiveDto> activeDtos=new ArrayList<>();
try {
while (rs.next()) {
ActiveDto activeDto=new ActiveDto();
String specialType=rs.getString("rule_no").trim();
String activityName=rs.getString("plan_name").trim();
if(specialType.equals("DD")){//折扣
activeDto.setActivityTypeId(2);
}
if(specialType.equals("PS")||specialType.equals("PM")){//特价秒杀
activeDto.setActivityTypeId(1);
}
if(specialType.equals("E")){//满减 todo
}
activeDto.setActivityName(activityName);
activeDto.setActivity_remark(rs.getString("plan_memo").trim());
activeDto.setFlowNo(rs.getString("plan_no"));
activeDto.setActivityReleasetime(rs.getDate("oper_date"));
activeDto.setActivityStarttime(rs.getDate("begin_date"));
activeDto.setActivityEndtime(rs.getDate("end_date"));
if(DateUtil.compare(activeDto.getActivityEndtime(),DateUtil.date())>0){
activeDto.setActivityState(1);//正常进行中
}else {
activeDto.setActivityState(2);//结束
}
activeDtos.add(activeDto);
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
try {
resultDto.getConnection().close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return activeDtos;
}
/**
* 获取折扣商品
* @param dataBaseInfo
* @return
*/
public List<ActiveShopInfo> getSpecShops(DataBaseInfo dataBaseInfo,int pageNo,int pageSize){
String where=dataBaseInfo.getWhere()+" and b.range_flag='I' and rule_no in('DD','PS','PM')";
ResultDto resultDto=baseFindListJoinPage(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName(),
T_PUB_PLAN_DETAIL_B,T_PUB_PLAN_MASTER,"plan_no","plan_no","flow_id","t.rule_no,t.plan_name,t.begin_date,t.end_date",pageNo,pageSize,where);
ResultSet rs= resultDto.getResultSet();
List<ActiveShopInfo> activeShopInfos=new ArrayList<>();
try {
while (rs.next()) {
ActiveShopInfo activeShopInfo=new ActiveShopInfo();
activeShopInfo.setItemNo(rs.getString("item_no").trim());
String specialType=rs.getString("rule_no").trim();
String activityName=rs.getString("plan_name").trim();
if(specialType.equals("DD")){//折扣 折扣和满减分类比较多目前只同步商品级别的
BigDecimal discount=rs.getBigDecimal("value");
//String discountStr=BigDecimalFormatter.formatWithoutTrailingZeros(discount.multiply(new BigDecimal(10)));
// activeShopInfo.setActivityName(activityName);
activeShopInfo.setDiscount(discount);
activeShopInfo.setActivityTypeId(2);
}
if(specialType.equals("PS")||specialType.equals("PM")){//特价秒杀
//activeShopInfo.setActivityName(activityName);
activeShopInfo.setOldPrice(rs.getBigDecimal("num2"));
activeShopInfo.setSpecPrice(rs.getBigDecimal("value"));
activeShopInfo.setActivityTypeId(1);
}
// if(specialType.equals("FR")){//满减 todo 没有同步
// String total1=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("old_price"));
// String max1=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("spe_price"));
// String max2=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("spe_price").add(rs.getBigDecimal("new_price1")));
// String total2=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("old_price").add(rs.getBigDecimal("old_price1")));
// activeShopInfo.setActivityName(""+total1+""+max1+",满"+total2+""+max2);
// activeShopInfo.setActivityTypeId(3);
// }
activeShopInfo.setActivityName(activityName);
activeShopInfo.setActivityItemMinQuantity(rs.getBigDecimal("limit_qty"));
activeShopInfo.setActivityStarttime(rs.getDate("begin_date"));
activeShopInfo.setActivityEndtime(rs.getDate("end_date"));
activeShopInfo.setFlowNo(rs.getString("plan_no"));
activeShopInfo.setItemNo(rs.getString("item_no").trim());
if(DateUtil.compare(activeShopInfo.getActivityEndtime(),DateUtil.date())>0){
activeShopInfo.setActivityState(1);//正常进行中
}else {
activeShopInfo.setActivityState(2);//结束
}
activeShopInfos.add(activeShopInfo);
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
try {
resultDto.getConnection().close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return activeShopInfos;
}
/**
*
* @param dataBaseInfo
* @return
*/
public Integer getTotalSpecShop(DataBaseInfo dataBaseInfo){
String where=dataBaseInfo.getWhere()+" and d.range_flag='I' and rule_no in('DD','PS','PM')";
return getTotalSpecShop(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),
dataBaseInfo.getDataBaseName(),where);
}
} }

View File

@ -17,9 +17,6 @@ public class ActiveDto implements Serializable {
@ApiModelProperty(value = "活动名称") @ApiModelProperty(value = "活动名称")
private String activityName; private String activityName;
@ApiModelProperty(value = "活动说明")
private String activity_remark;
@ApiModelProperty(value = "活动类型 1秒杀2单件折扣3满减") @ApiModelProperty(value = "活动类型 1秒杀2单件折扣3满减")
private Integer activityTypeId; private Integer activityTypeId;

View File

@ -72,5 +72,4 @@ public interface SxDataService {
*/ */
void syncAtiveShops(DataBaseInfo dataBaseInfo,CommentModel commentModel); void syncAtiveShops(DataBaseInfo dataBaseInfo,CommentModel commentModel);
String getCategoryChildren(DataBaseInfo dataBaseInfo,String parentId);
} }

View File

@ -238,26 +238,6 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
return parentId; return parentId;
} }
/**
* 获取父节点下的子节点
* @param dataBaseInfo
* @param parentId
* @return
*/
@Override
public String getCategoryChildren(DataBaseInfo dataBaseInfo,String parentId){
List<SxSyncCategory> sxSyncCategories=new SxDataDao().findTBdItemClsList(dataBaseInfo);
String childrens=commonCache.get(CommonCache.CACHE_CATEGROY+parentId);
if(StringUtils.isEmpty(childrens)){
log.info(JSONUtil.toJsonStr(buildTree(sxSyncCategories,parentId)));
childrens=commonCache.get(CommonCache.CACHE_CATEGROY+parentId);
if(StringUtils.isEmpty(childrens)){
return parentId;
}
}
return childrens;
}
/** /**
* 构建树节点 * 构建树节点
* @param sxSyncCategories * @param sxSyncCategories
@ -281,7 +261,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
public List<SxSyncCategory> getRootNode(List<SxSyncCategory> sxSyncCategories){ public List<SxSyncCategory> getRootNode(List<SxSyncCategory> sxSyncCategories){
List<SxSyncCategory> rootNodeList=new ArrayList<>(); List<SxSyncCategory> rootNodeList=new ArrayList<>();
for (SxSyncCategory node : sxSyncCategories) { for (SxSyncCategory node : sxSyncCategories) {
if (StringUtils.isEmpty(node.getCls_parent())) { if (null==node.getCls_parent()) {
rootNodeList.add(node); rootNodeList.add(node);
} }
} }
@ -729,10 +709,10 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
Integer total =0; Integer total =0;
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){ if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
where+=" and b.start_date>'"+commentModel.getSyncTime()+"' "; where+=" and b.start_date>'"+commentModel.getSyncTime()+"' ";
// where+=" or b.oper_date>'"+commentModel.getSyncTime()+"') "; where+=" or b.oper_date>'"+commentModel.getSyncTime()+"' ";
} }
dataBaseInfo.setWhere(where); dataBaseInfo.setWhere(where);
total = sxDataDao.getNewActiveCount(dataBaseInfo); total = sxDataDao.getActiveCount(dataBaseInfo);
if(total==0){ if(total==0){
log.info("暂无活动同步"); log.info("暂无活动同步");
return; return;
@ -744,7 +724,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
Date tenMinutesAgo = Date.from(Instant.now());//刷新时间 Date tenMinutesAgo = Date.from(Instant.now());//刷新时间
Date refreshDate= DateUtil.date(tenMinutesAgo); Date refreshDate= DateUtil.date(tenMinutesAgo);
for (int i = 1; i <=pages; i++) { for (int i = 1; i <=pages; i++) {
List<ActiveDto> activeDtos= sxDataDao.getNewActiveList(dataBaseInfo,i,SxDataDao.PAGESIZE); List<ActiveDto> activeDtos= sxDataDao.getActiveList(dataBaseInfo,i,SxDataDao.PAGESIZE);
Gson gson=new GsonBuilder() Gson gson=new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式 .setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式
.create(); .create();
@ -768,12 +748,12 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
String where="where 1=1"; String where="where 1=1";
Integer total =0; Integer total =0;
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){ if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
where+=" and m.oper_date>'"+commentModel.getSyncTime()+"' "; where+=" and start_date>'"+commentModel.getSyncTime()+"' ";
// where+=" or m.oper_date>'"+commentModel.getSyncTime()+"') "; where+=" or oper_date>'"+commentModel.getSyncTime()+"' ";
} }
dataBaseInfo.setWhere(where); dataBaseInfo.setWhere(where);
total = sxDataDao.getTotalSpecShop(dataBaseInfo); total = sxDataDao.getAllSpecCount(dataBaseInfo);
if(total==0){ if(total==0){
log.info("暂无活动商品同步"); log.info("暂无活动商品同步");
return; return;
@ -785,7 +765,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
Date tenMinutesAgo = Date.from(Instant.now());//刷新时间 Date tenMinutesAgo = Date.from(Instant.now());//刷新时间
Date refreshDate= DateUtil.date(tenMinutesAgo);//todo 要记录刷新时间 Date refreshDate= DateUtil.date(tenMinutesAgo);//todo 要记录刷新时间
for (int i = 1; i <=pages; i++) { for (int i = 1; i <=pages; i++) {
List<ActiveShopInfo> activeDtos= sxDataDao.getSpecShops(dataBaseInfo,i,SxDataDao.PAGESIZE); List<ActiveShopInfo> activeDtos= sxDataDao.getAllSpecPriceList(dataBaseInfo,i,SxDataDao.PAGESIZE);
Gson gson=new GsonBuilder() Gson gson=new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式 .setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式
.registerTypeAdapter(BigDecimal.class,new BigDecimalTypeAdapter()) .registerTypeAdapter(BigDecimal.class,new BigDecimalTypeAdapter())

View File

@ -17,9 +17,6 @@ public class ActiveModel implements Serializable {
@ApiModelProperty(value = "活动名称") @ApiModelProperty(value = "活动名称")
private String activityName; private String activityName;
@ApiModelProperty(value = "活动说明")
private String activity_remark;
@ApiModelProperty(value = "活动类型 1秒杀2单件折扣3满减") @ApiModelProperty(value = "活动类型 1秒杀2单件折扣3满减")
private Integer activityTypeId; private Integer activityTypeId;