Commit 8b45c19a authored by 刘文胜's avatar 刘文胜

excel转换

parent 4353c979
......@@ -2,7 +2,10 @@ package com.hdp.pi.dto.kolon;
import java.io.Serializable;
import org.apache.commons.lang.StringUtils;
import com.hdp.pi.utils.kolon.CONSTANTS;
import com.hdp.pi.utils.kolon.Util;
public class KolonMemberDTO implements Serializable {
......@@ -35,18 +38,22 @@ public class KolonMemberDTO implements Serializable {
public KolonMemberDTO(){
}
public KolonMemberDTO(String[] s) {
public KolonMemberDTO(String[] row) {
super();
this.csNo = Long.valueOf(s[1]);
this.status = CONSTANTS.STATUS.get(s[2]);
this.bonus = Integer.valueOf(s[3]);
this.cardNo = s[4];
this.lifecycle = s[5];
this.customerType = CONSTANTS.CUSTERMERTYPE.get(s[6]);
this.lastName = s[7];
this.firstName = s[8];
this.email = s[9];
this.phone = s[10];
this.csNo = Long.valueOf(Util.getByIndex(row, 1));
this.status = CONSTANTS.STATUS.get(Util.getByIndex(row, 2));
String b_str = Util.getByIndex(row, 3);
if(StringUtils.isNotEmpty(b_str)){
this.bonus = Integer.valueOf(b_str);
}
this.cardNo = Util.getByIndex(row, 4);
this.lifecycle = Util.getByIndex(row, 5);
this.customerType = CONSTANTS.CUSTERMERTYPE.get(Util.getByIndex(row, 6));
this.lastName = Util.getByIndex(row, 7);
this.firstName = Util.getByIndex(row, 8);
this.email = Util.getByIndex(row, 9);
this.phone = Util.getByIndex(row, 10);
this.wechatLastName= this.lastName;
this.wechatFirstName= this.firstName;
}
......
......@@ -202,31 +202,20 @@ public class KolonMemberServiceImpl implements KolonMemberService {
saleRepository.save(sale);
}
private String getByIndex(String[] row,int index){
if(row == null){
return "";
}
if(index < 0 || index >= row.length){
return "";
}
return row[index];
}
private Product newProduct(String[] row){
Product p = new Product();
try{
p.id = getByIndex(row, 0);
p.title = getByIndex(row, 1);
p.category = getByIndex(row, 2);
p.image = getByIndex(row, 3);
p.link = getByIndex(row, 4);
p.avaliable = getByIndex(row, 5);
p.dept = getByIndex(row, 6);
p.seaons = getByIndex(row, 7);
p.planyy = getByIndex(row, 8);
p.color = getByIndex(row, 9);
p.price = getByIndex(row, 10);
p.id = Util.getByIndex(row, 0);
p.title = Util.getByIndex(row, 1);
p.category = Util.getByIndex(row, 2);
p.image = Util.getByIndex(row, 3);
p.link = Util.getByIndex(row, 4);
p.avaliable = Util.getByIndex(row, 5);
p.dept = Util.getByIndex(row, 6);
p.seaons = Util.getByIndex(row, 7);
p.planyy = Util.getByIndex(row, 8);
p.color = Util.getByIndex(row, 9);
p.price = Util.getByIndex(row, 10);
}catch(Throwable e){
e.printStackTrace();
}
......@@ -236,12 +225,12 @@ public class KolonMemberServiceImpl implements KolonMemberService {
private Sale newSale(String[] row){
Sale s = new Sale();
try{
s.oId = getByIndex(row, 0);
s.oDate = Integer.valueOf(getByIndex(row, 1));
s.customer = getByIndex(row, 2);
s.item = getByIndex(row, 3);
s.quantity = Integer.valueOf(getByIndex(row, 4));
s.amount = Double.valueOf(getByIndex(row, 5));
s.oId = Util.getByIndex(row, 0);
s.oDate = Integer.valueOf(Util.getByIndex(row, 1));
s.customer = Util.getByIndex(row, 2);
s.item = Util.getByIndex(row, 3);
s.quantity = Integer.valueOf(Util.getByIndex(row, 4));
s.amount = Double.valueOf(Util.getByIndex(row, 5));
}catch(Throwable e){
e.printStackTrace();
}
......
......@@ -55,7 +55,9 @@ public class FtpScheduledTask {
* 同步数据
*/
public void readCSVFile() {
kolonMemberService.syncData();
kolonMemberService.syncMemberData();
kolonMemberService.syncProductData();
kolonMemberService.syncSaleData();
}
/**
......
......@@ -19,4 +19,14 @@ public class Util {
return (s == null || "".equals(s)) ? false : true;
}
public static String getByIndex(String[] row,int index){
if(row == null){
return "";
}
if(index < 0 || index >= row.length){
return "";
}
return row[index];
}
}
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