Commit 02af6f48 authored by 曲欣红's avatar 曲欣红

1

parent 1e9c7630
......@@ -31,6 +31,11 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
@Override
public void execute(String xml) {
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime();
Element record = StringUtil.getDataElement(xml, "RECORD");
Element headerSending = record.element("HEADER_SENDING");
......@@ -40,24 +45,23 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
List<Element> itemList = record.elements("ITEM");
try {
for (Element element : itemList) {
String GOODS_CODE = element.elementText("MATNR");
Map<String, Object> goods = getGoods(DIS_CODE, GOODS_CODE);
if(goods == null) {
if (goods == null) {
goods = new HashMap<>();
}
/***************header**************/
/*************** header **************/
goods.put("DIS_CODE", DIS_CODE);
goods.put("DATUM", DateUtil.parseDate(DATUM, DateUtil.FMT_DATE));
goods.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME)/*timef.parse(UZEIT)*/);
/***************header**************/
goods.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME)/* timef.parse(UZEIT) */);
/*************** header **************/
/***************item**************/
/*************** item **************/
goods.put("GOODS_CODE", GOODS_CODE);
goods.put("ROUGH_WEIGHT", Double.valueOf(element.elementText("BRGEW")));
goods.put("NET_WEIGHT", Double.valueOf(element.elementText("NTGEW")));
......@@ -70,12 +74,12 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("STKTYP", element.elementText("STKTYP"));
goods.put("SPEC", element.elementText("UMREZ"));
/*******************新增字段,样例中没有******************/
/******************* 新增字段,样例中没有 ******************/
goods.put("GOODS_NAME_EN", element.elementText("NORMT_EN"));
goods.put("AUMNG", element.elementText("AUMNG"));
goods.put("VRKME", element.elementText("VRKME"));
goods.put("BASE_UNIT", element.elementText("MEINS"));
goods.put("STATISTICS_UNIT", element.elementText("SCHME"));//(统计单位--》发货单位)
goods.put("STATISTICS_UNIT", element.elementText("SCHME"));// (统计单位--》发货单位)
goods.put("LAENG", element.elementText("LAENG"));
goods.put("BREIT", element.elementText("BREIT"));
goods.put("HOEHE", element.elementText("HOEHE"));
......@@ -86,49 +90,40 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("MEABM_B", element.elementText("MEABM_B"));
goods.put("PUBLIC", element.elementText("PUBLIC"));
goods.put("INTERNET", element.elementText("INTERNET"));
/*******************新增字段,样例中没有******************/
/******************************************/
goods.put("CATEGORY_NAME", "");//品类名称
goods.put("PRODUCTION_LINE_CODE", "");//产线(产地)编码
goods.put("PRODUCTION_LINE_NAME", "");//产线(产地)名称
goods.put("MSTAV", "");//停产标志2
goods.put("BARCODE", "");//物料条码
goods.put("TAX_RATE", 0);//税率
goods.put("GOODS_KEY", "");//物料唯一码
goods.put("SEND_TIME", new Date());//发送时间
goods.put("DIS_UPDATE_STATUS", "N");//分销商更新结果(Y成功,N失败)
/******************************************/
/***************item**************/
/******************* 新增字段,样例中没有 ******************/
/******************************************/
goods.put("CATEGORY_NAME", "");// 品类名称
goods.put("PRODUCTION_LINE_CODE", "");// 产线(产地)编码
goods.put("PRODUCTION_LINE_NAME", "");// 产线(产地)名称
goods.put("MSTAV", "");// 停产标志2
goods.put("BARCODE", "");// 物料条码
goods.put("TAX_RATE", 0);// 税率
goods.put("GOODS_KEY", "");// 物料唯一码
goods.put("SEND_TIME", now);// 发送时间
goods.put("DIS_UPDATE_STATUS", "N");// 分销商更新结果(Y成功,N失败)
/******************************************/
/*************** item **************/
/**
* 数据库没有数据追踪号对应字段TRACE_NO
*/
String BATCH = (String) goods.get("BATCH");
if(BATCH==null||"".equals(BATCH.trim())) {
BATCH = DateUtil.formatDate(new Date(), DateUtil.FMT_DATE)+"-1"/*datef.format(new Date())+"-1"*/;
}else {
String[] ss = BATCH.split("-");
String newDate = DateUtil.formatDate(new Date(), DateUtil.FMT_DATE);
int v = 1;
if(ss[0].equals(newDate)) {
v = Integer.valueOf(ss[1])+1;
}
BATCH = newDate+"-"+v;
}
goods.put("TRACE_NO", "sapmaterialmaster"+DateUtil.formatDate(new Date(), DateUtil.FMT_DATETIME));
Long BATCHID = common.getNextval(today + "_t_ven_goods_BATCH_" + DIS_CODE + "" + GOODS_CODE);
String BATCH = today+"-"+BATCHID;
goods.put("TRACE_NO", "sapmaterialmaster" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
goods.put("BATCH", BATCH);
goods.put("SEND_STATUS", "N");
goods.put("UPDATED", DateUtil.formatDate(new Date(), DateUtil.FMT_DATE_TIME)/*datetimef.format(new Date())*/);
goods.put("UPDATED",
DateUtil.formatDate(now, DateUtil.FMT_DATE_TIME)/* datetimef.format(new Date()) */);
if(goods.get("ID")!=null) {
if (goods.get("ID") != null) {
updateGoods(goods);
}else {
} else {
insertGoods(goods);
}
}
}catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -141,46 +136,48 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
for (Entry<String, Object> entry : goods.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if(!key.equals("ID")) {
if (!key.equals("ID")) {
sql = sql + key + " = ?, ";
args.add(value);
}
}
sql = sql.substring(0, sql.length()-2);
sql = sql.substring(0, sql.length() - 2);
sql = sql + " where ID = ?";
args.add(goods.get("ID"));
jdbcTemplate.update(sql, args.toArray());
}
private void insertGoods(Map<String, Object> goods) {
String countSql = "select count(1) from t_ven_goods";
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
String ID = System.currentTimeMillis() + StringUtil.prependZero(count+1, 5);
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime();
Long idIndex = common.getNextval(today + "_t_ven_goods");
String ID = time + "" + idIndex;
goods.put("ID", ID);
goods.put("CREATED", DateUtil.formatDate(new Date(), DateUtil.FMT_DATE_TIME)/*datetimef.format(new Date())*/);
goods.put("CREATED", DateUtil.formatDate(now, DateUtil.FMT_DATE_TIME)/* datetimef.format(new Date()) */);
goods.put("CREATEDBY", "system");
goods.put("UPDATEDBY", "");
String insertSql = "insert into t_ven_goods ";
String fieldSql = "(";
String valuesSql = "(";
List<Object> values = new ArrayList<>();
for(Entry<String, Object> entry : goods.entrySet()) {
for (Entry<String, Object> entry : goods.entrySet()) {
fieldSql = fieldSql + entry.getKey() + ", ";
valuesSql = valuesSql + "?, ";
values.add(entry.getValue());
}
fieldSql = fieldSql.substring(0, fieldSql.length()-2);
valuesSql = valuesSql.substring(0, valuesSql.length()-2);
fieldSql = fieldSql.substring(0, fieldSql.length() - 2);
valuesSql = valuesSql.substring(0, valuesSql.length() - 2);
insertSql = insertSql + fieldSql + ") values " + valuesSql + ")";
jdbcTemplate.update(insertSql, values.toArray());
}
private Map<String, Object> getGoods(String DIS_CODE, String GOODS_CODE){
private Map<String, Object> getGoods(String DIS_CODE, String GOODS_CODE) {
String sql = "select * from t_ven_goods where DIS_CODE = ? and GOODS_CODE = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, DIS_CODE, GOODS_CODE);
if(list!=null&&list.size()>0) {
if (list != null && list.size() > 0) {
return list.get(0);
}
return null;
......
......@@ -31,6 +31,11 @@ public class PriceListServiceImpl implements PriceListService {
@Override
public void execute(String xml) {
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime();
Element record = StringUtil.getDataElement(xml, "RECORD");
Element headerSending = record.element("HEADER_SENDING");
......@@ -46,15 +51,15 @@ public class PriceListServiceImpl implements PriceListService {
Map<String, Object> priceObj = getPriceObj(KUNNR, MATNR);
if(priceObj == null) {
if (priceObj == null) {
priceObj = new HashMap<>();
}
/**********header***********/
/********** header ***********/
priceObj.put("KUNNR", KUNNR);
priceObj.put("DATUM", DATUM);
priceObj.put("UZEIT", UZEIT);
/**********header***********/
/**********item***********/
/********** header ***********/
/********** item ***********/
priceObj.put("MATNR", MATNR);
priceObj.put("KBETR", StringUtil.toDouble(element.elementText("KBETR")));
priceObj.put("KONWA", element.elementText("KONWA"));
......@@ -64,45 +69,30 @@ public class PriceListServiceImpl implements PriceListService {
priceObj.put("MAKTX", element.elementText("MAKTX"));
priceObj.put("PRSCH", StringUtil.toDouble(element.elementText("PRSCH")));
priceObj.put("DATAM", element.elementText("DATAM"));
Date DATBI;
String DATBIStr = element.elementText("DATBI");
if(DATBIStr==null||DATBIStr.equals("")) {
DATBI = new Date();
}else {
DATBI = DateUtil.parseDate(DATBIStr, DateUtil.FMT_DATE);
}
priceObj.put("DATBI", DATBI);
priceObj.put("DATBI", DateUtil.parseDateNoEmpty(element.elementText("DATBI"), DateUtil.FMT_DATE));
priceObj.put("PLINE", element.elementText("PLINE"));
priceObj.put("PRSCH_1", StringUtil.toDouble(element.elementText("PRSCH_1")));
/**********item***********/
/********** item ***********/
/*************************/
priceObj.put("SEND_DATE", new Date());//发送时间
/*************************/
/*************************/
priceObj.put("SEND_DATE", new Date(0));// 发送时间
/*************************/
priceObj.put("SEND_STATUS", "N");
String BATCH = (String) priceObj.get("BATCH");
if(BATCH==null||"".equals(BATCH.trim())) {
BATCH = DateUtil.formatDate(new Date(), DateUtil.FMT_DATE)+"-1"/*datef.format(new Date())+"-1"*/;
}else {
String[] ss = BATCH.split("-");
String newDate = DateUtil.formatDate(new Date(), DateUtil.FMT_DATE);
int v = 1;
if(ss[0].equals(newDate)) {
v = Integer.valueOf(ss[1])+1;
}
BATCH = newDate+"-"+v;
}
priceObj.put("TRACE_NO", "sappricelist"+DateUtil.formatDate(new Date(), DateUtil.FMT_DATETIME));
Long BATCHID = common.getNextval(today + "_t_price_list_BATCH_" + KUNNR + "" + MATNR);
String BATCH = today + "-" + BATCHID;
priceObj.put("TRACE_NO", "sappricelist" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
priceObj.put("BATCH", BATCH);
priceObj.put("UPDATED", DateUtil.formatDate(new Date(), DateUtil.FMT_DATE_TIME));
if(priceObj.get("ID")!=null) {
priceObj.put("UPDATED", now);
if (priceObj.get("ID") != null) {
updatePriceObj(priceObj);
}else {
} else {
insertPriceObj(priceObj);
}
}
}catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -115,46 +105,48 @@ public class PriceListServiceImpl implements PriceListService {
for (Entry<String, Object> entry : priceObj.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if(!key.equals("ID")) {
if (!key.equals("ID")) {
sql = sql + key + " = ?, ";
args.add(value);
}
}
sql = sql.substring(0, sql.length()-2);
sql = sql.substring(0, sql.length() - 2);
sql = sql + " where ID = ?";
args.add(priceObj.get("ID"));
jdbcTemplate.update(sql, args.toArray());
}
private void insertPriceObj(Map<String, Object> priceObj) {
String countSql = "select count(1) from t_price_list";
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
String ID = System.currentTimeMillis() + StringUtil.prependZero(count+1, 5);
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime();
Long idIndex = common.getNextval(today + "_t_ven_goods");
Long ID = Long.valueOf(time + "" + idIndex);
priceObj.put("ID", ID);
priceObj.put("CREATED", DateUtil.formatDate(new Date(), DateUtil.FMT_DATE_TIME)/*datetimef.format(new Date())*/);
priceObj.put("CREATED", now);
priceObj.put("CREATEDBY", "system");
priceObj.put("UPDATEDBY", "");
String insertSql = "insert into t_price_list ";
String fieldSql = "(";
String valuesSql = "(";
List<Object> values = new ArrayList<>();
for(Entry<String, Object> entry : priceObj.entrySet()) {
for (Entry<String, Object> entry : priceObj.entrySet()) {
fieldSql = fieldSql + entry.getKey() + ", ";
valuesSql = valuesSql + "?, ";
values.add(entry.getValue());
}
fieldSql = fieldSql.substring(0, fieldSql.length()-2);
valuesSql = valuesSql.substring(0, valuesSql.length()-2);
fieldSql = fieldSql.substring(0, fieldSql.length() - 2);
valuesSql = valuesSql.substring(0, valuesSql.length() - 2);
insertSql = insertSql + fieldSql + ") values " + valuesSql + ")";
jdbcTemplate.update(insertSql, values.toArray());
}
private Map<String, Object> getPriceObj(String KUNNR, String MATNR){
private Map<String, Object> getPriceObj(String KUNNR, String MATNR) {
String sql = "select * from t_price_list where KUNNR = ? and MATNR = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, KUNNR, MATNR);
if(list!=null&&list.size()>0) {
if (list != null && list.size() > 0) {
return list.get(0);
}
return null;
......
......@@ -85,6 +85,8 @@ public class SoConfirmQuotationServiceImpl implements SoConfirmQuotationService{
}
Long hID = Long.valueOf(time+idIndex);
header.put("ID", hID);
header.put("TRACE_NO", "sapsoconfirmquotation"+DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
insertTo(header, "t_so_confirmation_header");
......@@ -160,13 +162,17 @@ public class SoConfirmQuotationServiceImpl implements SoConfirmQuotationService{
String valuesSql = "(";
List<Object> values = new ArrayList<>();
for(Entry<String, Object> entry : obj.entrySet()) {
Object value = entry.getValue();
if(value!=null) {
fieldSql = fieldSql + entry.getKey() + ", ";
valuesSql = valuesSql + "?, ";
values.add(entry.getValue());
}
}
fieldSql = fieldSql.substring(0, fieldSql.length()-2);
valuesSql = valuesSql.substring(0, valuesSql.length()-2);
insertSql = insertSql + fieldSql + ") values " + valuesSql + ")";
System.out.println(JSON.toJSONString(values));
jdbcTemplate.update(insertSql, values.toArray());
}
......
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