You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
5.0 KiB
128 lines
5.0 KiB
package com.qs.crm;
|
|
|
|
import com.qs.crm.entity.BmsChannel;
|
|
import com.qs.crm.entity.BmsChannelPoint;
|
|
import com.qs.crm.entity.BmsRegion2;
|
|
import com.qs.crm.entity.BmsSupplierChannel;
|
|
import com.qs.crm.xltentity.XltChannel;
|
|
import com.qs.crm.xltentity.XltChannelDealer;
|
|
import com.qs.crm.xltentity.XltPoint;
|
|
import com.qs.util.DateUtils;
|
|
import org.noear.wood.DbContext;
|
|
import org.noear.wood.utils.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
@Component
|
|
public class BmsPointSync {
|
|
|
|
@Value("${xlt.url}")
|
|
String xltUrl;
|
|
@Value("${xlt.user}")
|
|
String xltUser;
|
|
@Value("${xlt.pass}")
|
|
String xltPass;
|
|
|
|
@Value("${jsl.url}")
|
|
String jslUrl;
|
|
@Value("${jsl.user}")
|
|
String jslUser;
|
|
@Value("${jsl.pass}")
|
|
String jslPass;
|
|
|
|
public DbContext getJslDbContext(){
|
|
return new DbContext("test",jslUrl,jslUser,jslPass);
|
|
}
|
|
|
|
public DbContext getXltDbContext(){
|
|
return new DbContext("xlt",xltUrl,xltUser,xltPass);
|
|
}
|
|
|
|
public void syncPoint() throws Exception {
|
|
DbContext jslDb = getJslDbContext();
|
|
DbContext xltDb = getXltDbContext();
|
|
|
|
Date day = DateUtils.nextDay(-10);
|
|
|
|
|
|
String sql ="select w1.id,w1.number_,w1.name,xiancheng,chengshi,shengfen,w1.cashRegister as cash_register,w1.area as shop_area,w1.floor '店面层数',w1.xihuaDiDui '同品类地堆数',d2.number as channel_code,w1.sysId as sys_id " +
|
|
",xihuaArer '同品类面积',xihuaDuanJia '同品类端架数',dentifriceShelf '同品类货架节数(各产品)',contactP,w3.phone,w3.email,w3.mobileTel " +
|
|
",w1.addDate,w1.address,w1.dingWei_address,w2.WDTypeName as type_name ,wl.WDLevelName as level_name,d2.name sysName,d3.dealerNumber,d3.dealerName,d1.city,d4.province " +
|
|
"from emp_system_dealer e1 " +
|
|
"inner join DealerSystem d2 on e1.system_id = d2.id " +
|
|
"inner join WangDian w1 on d2.id = w1.sysId " +
|
|
"left join DealerConnTable d3 on e1.dealer_id = d3.id " +
|
|
"left join DealerCity d1 on d3.cid = d1.id " +
|
|
"left join DealerProvince d4 on d1.pid = d4.id " +
|
|
"left join DealerArea d5 on d5.id = d4.aid " +
|
|
"left join WDType w2 on w1.type = w2.id " +
|
|
"left join WDContact w3 on w1.id = w3.WDID " +
|
|
"left join WDLevel wl on w1.wdlevel = wl.id " +
|
|
"where w1.isval = 0 and d5.id = ? ";
|
|
|
|
String id = "40288a73601f131601602b0fbe010074";
|
|
|
|
List<XltPoint> pointList = xltDb.sql(sql,id).getList(XltPoint.class);
|
|
|
|
for(XltPoint a:pointList) {
|
|
|
|
List<BmsChannelPoint> points = jslDb.sql("select * from bms_channel_point where del_flag=0 and point_code = ?",a.getNumber_()).getList(BmsChannelPoint.class);
|
|
if(points.size()>0){
|
|
continue;
|
|
}
|
|
|
|
List<BmsChannel> channelList = jslDb.sql("select * from bms_channel where del_flag=0 and channel_code =? ",a.getChannel_code()).getList(BmsChannel.class);
|
|
|
|
if(channelList.size()==0){
|
|
continue;
|
|
}
|
|
|
|
BmsChannelPoint point = new BmsChannelPoint();
|
|
point.setChannelId(channelList.get(0).getId());
|
|
point.setChannelName(channelList.get(0).getChannelName());
|
|
point.setPointCode(a.getNumber_());
|
|
point.setPointName(a.getName());
|
|
if(a.getShop_area()!=null) {
|
|
point.setShopArea(a.getShop_area().toString());
|
|
}
|
|
point.setCountCheckstand(a.getCash_register());
|
|
point.setPointLevel(a.getLevel_name());
|
|
point.setPointType(a.getType_name());
|
|
point.setAddress(a.getAddress());
|
|
point.setTenantId("001");
|
|
point.setCostFlag(1);
|
|
point.setDelFlag("0");
|
|
|
|
// BmsRegion2 region2 = jslDb.sql("select * from bms_region2 where del_flag=0 and name = ?",a.getXiancheng()).getItem(BmsRegion2.class);
|
|
// if(region2==null || StringUtils.isEmpty(region2.getPathIds())){
|
|
// System.out.println(a.getName());
|
|
// }else{
|
|
// String[] regionPath = region2.getPathIds().split("_");
|
|
// if(regionPath.length!=3){
|
|
// System.out.println(a.getName());
|
|
// }else{
|
|
// point.setBizRegionId(region2.getId());
|
|
// point.setBizRegionPathIds(region2.getPathIds());
|
|
// point.setBizRegionPath(region2.getPathNames());
|
|
// }
|
|
// }
|
|
|
|
jslDb.table("bms_channel_point").setEntity(point).insert();
|
|
}
|
|
}
|
|
|
|
public void syncChannelDealer() throws Exception {
|
|
DbContext jslDb = getJslDbContext();
|
|
DbContext xltDb = getXltDbContext();
|
|
|
|
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
new BmsPointSync().syncPoint();
|
|
}
|
|
}
|
|
|