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

1

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