思迅同步品牌问题修复
This commit is contained in:
parent
ec9ec45cb0
commit
f097de7733
@ -1,19 +1,14 @@
|
||||
package com.small.client.Utils;
|
||||
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.small.client.dto.StoreDbConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
@ -47,6 +42,9 @@ public class HttpUtils {
|
||||
|
||||
public static final String URL_SYNC_ACTIVE_SHOP="/shop/sync/third/syncAtiveShop";//同步活动商品到服务器
|
||||
|
||||
public static final String URL_SYNC_REFRESH="/shop/sync/third/syncRefreshTime";//同步记录刷新时间
|
||||
|
||||
|
||||
public static String postData(RestTemplate restTemplate, String url,Object modelObject){
|
||||
// 创建表单参数
|
||||
// MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
|
||||
@ -2,8 +2,6 @@ package com.small.client.dao;
|
||||
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerException;
|
||||
|
||||
import com.small.client.dto.DataBaseInfo;
|
||||
import com.small.client.dto.ResultDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -488,4 +486,34 @@ public class BaseDao {
|
||||
}
|
||||
|
||||
|
||||
public ResultDto getclsMapBrand(String ip, String username, String password,Integer portNumber, String dataBaseName){
|
||||
Connection connection=getConnection(ip,username,password,portNumber,dataBaseName);
|
||||
String sql= "select tb.code_name,cls.item_clsname\n" +
|
||||
"from\n" +
|
||||
"(\n" +
|
||||
"select * \n" +
|
||||
" from(\n" +
|
||||
" select \n" +
|
||||
" ROW_NUMBER() OVER(partition by b.item_clsno order by item_no) as rn,b.item_clsno,b.item_brand\n" +
|
||||
" from t_bd_item_info b\n" +
|
||||
" )t where rn=1\n" +
|
||||
")cb left join T_BD_BASE_CODE tb on cb.item_brand=tb.code_id\n" +
|
||||
"left join t_bd_item_cls cls on cb.item_clsno=cls.item_clsno" ;
|
||||
sql=String.format(sql);
|
||||
log.info(sql);
|
||||
ResultDto resultDto=new ResultDto();
|
||||
ResultSet rs=null;
|
||||
try {
|
||||
PreparedStatement ps= connection.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
log.info("数据库查询异常方法{},异常信息{}","com.suisung.mall.shop.sixun.dao.BaseDao.baseFindListJoin",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
resultDto.setResultSet(rs);
|
||||
resultDto.setConnection(connection);
|
||||
return resultDto;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,20 +2,17 @@ package com.small.client.dao;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.small.client.Utils.BigDecimalFormatter;
|
||||
import com.small.client.dto.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 考虑到每个思迅软件都是自己的数据,所以采用动态获取的方式获取数据
|
||||
@ -228,7 +225,7 @@ public class SxDataDao extends BaseDao{
|
||||
sxSyncGoods.setValid_days(getStopDate(rs));//保质期 todo stop_date-build_date?
|
||||
|
||||
sxSyncGoods.setItem_brand_name(rs.getString("item_brandname"));
|
||||
sxSyncGoods.setItemBrand(rs.getString("item_brand"));
|
||||
sxSyncGoods.setItemBrand(rs.getString("item_brand").trim());
|
||||
sxSyncGoods.setItem_clsno(rs.getString("item_clsno").trim());
|
||||
sxSyncGoods.setItem_size(rs.getString("item_size"));
|
||||
|
||||
@ -269,8 +266,8 @@ public class SxDataDao extends BaseDao{
|
||||
int cardStatus=rs.getInt("card_status");
|
||||
if(cardStatus!=1){
|
||||
sxSyncVip.setVip_name(rs.getString("vip_name"));//会员名称
|
||||
sxSyncVip.setVip_sex(rs.getString("vip_sex"));//会员名称
|
||||
sxSyncVip.setMobile(rs.getString("mobile"));//会员名称
|
||||
sxSyncVip.setVip_sex(rs.getString("vip_sex").trim());//性别
|
||||
sxSyncVip.setMobile(rs.getString("mobile"));//手机号
|
||||
sxSyncVip.setBirthday(rs.getString("birthday"));//会员生日
|
||||
sxSyncVip.setCard_type(rs.getString("card_type")==null?"v1":rs.getString("card_type"));//会员生日
|
||||
sxSyncVip.setCard_no(rs.getString("card_id"));//会员卡号
|
||||
@ -325,11 +322,11 @@ public class SxDataDao extends BaseDao{
|
||||
try {
|
||||
while (rs.next()) {
|
||||
BrandModel brandModel=new BrandModel();
|
||||
brandModel.setBrand_name(rs.getString("code_name"));
|
||||
brandModel.setBrand_desc(rs.getString("code_name"));
|
||||
brandModel.setCodeId(rs.getString("code_id"));
|
||||
brandModel.setBrand_name(rs.getString("code_name").trim());
|
||||
brandModel.setBrand_desc(rs.getString("code_name").trim());
|
||||
brandModel.setCodeId(rs.getString("code_id").trim());
|
||||
brandModel.setBrand_image("");
|
||||
brandModel.setCategory("0");
|
||||
//brandModel.setCategory("0");
|
||||
brandModel.setBrand_recommend("0");//是否推荐
|
||||
brandModels.add(brandModel);
|
||||
// log.info(rs.getString("type_no")+"--"+rs.getString("code_name"));//分类编码-分类名称
|
||||
@ -682,4 +679,36 @@ public class SxDataDao extends BaseDao{
|
||||
return activeShopInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
*获取分类品牌映射
|
||||
* @param dataBaseInfo
|
||||
* @return
|
||||
*/
|
||||
public List<ClsBrandDto> getclsMapBrand(DataBaseInfo dataBaseInfo){
|
||||
ResultDto resultDto=getclsMapBrand(dataBaseInfo.getIp()
|
||||
,dataBaseInfo.getUserName()
|
||||
,dataBaseInfo.getPassword()
|
||||
,dataBaseInfo.getDbPort()
|
||||
,dataBaseInfo.getDataBaseName());
|
||||
ResultSet rs= resultDto.getResultSet();
|
||||
List<ClsBrandDto> clsBrandDtos=new ArrayList<>();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
ClsBrandDto clsBrandDto=new ClsBrandDto();
|
||||
clsBrandDto.setItemClsname(rs.getString("item_clsname").trim());
|
||||
clsBrandDto.setCodeName(rs.getString("code_name").trim());
|
||||
clsBrandDtos.add(clsBrandDto);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
resultDto.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return clsBrandDtos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
19
client/src/main/java/com/small/client/dto/ClsBrandDto.java
Normal file
19
client/src/main/java/com/small/client/dto/ClsBrandDto.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.small.client.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ClsBrandDto implements Serializable {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "分类名称")
|
||||
private String itemClsname;
|
||||
|
||||
@ApiModelProperty(value = "品牌名称")
|
||||
private String codeName;
|
||||
|
||||
|
||||
}
|
||||
@ -29,4 +29,6 @@ public class SxCategoryModel {
|
||||
@ApiModelProperty(value = "第二级父类")
|
||||
private String second_category_name;
|
||||
|
||||
@ApiModelProperty(value = "品牌名称")
|
||||
private String brandName;
|
||||
}
|
||||
|
||||
@ -7,12 +7,10 @@ import com.small.client.dao.SxDataDao;
|
||||
import com.small.client.dto.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -35,10 +33,10 @@ public abstract class SxDataAbstService {
|
||||
syncThirdMemberReq = new SyncThirdMemberReq();
|
||||
syncThirdMemberReq.setUser_nickname(sxSyncVip.getVip_name());
|
||||
syncThirdMemberReq.setUser_realname(sxSyncVip.getVip_name());
|
||||
if ("男".equals(sxSyncVip.getVip_name())) {//todo 需要确认数据是不是这样判断
|
||||
if ("男".equals(sxSyncVip.getVip_sex())) {//todo 需要确认数据是不是这样判断
|
||||
syncThirdMemberReq.setUser_gender(1);
|
||||
}
|
||||
if ("男".equals(sxSyncVip.getVip_name())) {
|
||||
if ("女".equals(sxSyncVip.getVip_sex())) {
|
||||
syncThirdMemberReq.setUser_gender(2);
|
||||
}
|
||||
syncThirdMemberReq.setUser_mobile(sxSyncVip.getMobile());
|
||||
@ -48,12 +46,7 @@ public abstract class SxDataAbstService {
|
||||
syncThirdMemberReq.setUser_points(sxSyncVip.getNow_acc_num());
|
||||
syncThirdMemberReq.setUser_money(sxSyncVip.getResidual_amt());
|
||||
if(sxSyncVip.getVip_date()!=null){
|
||||
try {
|
||||
syncThirdMemberReq.setJoin_time(DateUtils.parseDate(sxSyncVip.getVip_date()));
|
||||
} catch (ParseException e) {
|
||||
log.info("时间转换异常{0}",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
syncThirdMemberReq.setJoin_time(sxSyncVip.getVip_date());
|
||||
}
|
||||
syncThirdMemberReqList.add(syncThirdMemberReq);
|
||||
}
|
||||
@ -67,7 +60,7 @@ public abstract class SxDataAbstService {
|
||||
* @param allSxSyncCategories 所有分类
|
||||
* @return
|
||||
*/
|
||||
public List<SxCategoryModel> ConVToSxCategoryModel(List<SxSyncCategory> sxSyncCategories,List<SxSyncCategory> allSxSyncCategories) {
|
||||
public List<SxCategoryModel> ConVToSxCategoryModel(List<SxSyncCategory> sxSyncCategories,List<SxSyncCategory> allSxSyncCategories, Map<String,String> clsBrandMap) {
|
||||
if(CollectionUtil.isEmpty(sxSyncCategories)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@ -79,6 +72,7 @@ public abstract class SxDataAbstService {
|
||||
sxCategoryModel=new SxCategoryModel();
|
||||
sxCategoryModel.setCategory_image(SxDataDao.DEFAULT_IMG);
|
||||
sxCategoryModel.setCategory_name(sxSyncCategory.getItem_clsname());
|
||||
sxCategoryModel.setBrandName(clsBrandMap.get(sxSyncCategory.getItem_clsname()));
|
||||
//寻找父级
|
||||
if(null!=sxSyncCategory.getCls_parent()){
|
||||
SxSyncCategory firstNode=getParentNode(allSxSyncCategories,sxSyncCategory.getCls_parent());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user