Commit 17dc2517 authored by 曲欣红's avatar 曲欣红

1

parent 0019039d
package com.egolm.sso.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://service.sso.egolm.com")
public interface PriceListService {
@WebMethod
public void execute(String xml);
}
package com.egolm.sso.service.impl; package com.egolm.sso.service.impl;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -22,6 +20,8 @@ import org.springframework.stereotype.Component; ...@@ -22,6 +20,8 @@ import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.egolm.sso.service.CommonService; import com.egolm.sso.service.CommonService;
import com.egolm.sso.service.MaterialMasterService; import com.egolm.sso.service.MaterialMasterService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.StringUtil;
@Component @Component
@WebService(serviceName = "MaterialMasterService", targetNamespace = "http://service.sso.egolm.com", endpointInterface = "com.egolm.sso.service.MaterialMasterService") @WebService(serviceName = "MaterialMasterService", targetNamespace = "http://service.sso.egolm.com", endpointInterface = "com.egolm.sso.service.MaterialMasterService")
...@@ -33,10 +33,6 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -33,10 +33,6 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
@Autowired @Autowired
CommonService common; CommonService common;
private static DateFormat datef = new SimpleDateFormat("yyyyMMdd");
private static DateFormat datetimef = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static DateFormat timef = new SimpleDateFormat("HHmmss");
@Override @Override
public void execute(String xml) { public void execute(String xml) {
System.out.println(common.getNextval("Test")); System.out.println(common.getNextval("Test"));
...@@ -44,13 +40,11 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -44,13 +40,11 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
Element record = getRecordElement(xml); Element record = getRecordElement(xml);
Map<String, String> header = new HashMap<>();
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<Map<String, String>> items = new ArrayList<>();
List<Element> itemList = record.elements("ITEM"); List<Element> itemList = record.elements("ITEM");
...@@ -66,8 +60,8 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -66,8 +60,8 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
/***************header**************/ /***************header**************/
goods.put("DIS_CODE", DIS_CODE); goods.put("DIS_CODE", DIS_CODE);
goods.put("DATUM", datef.parse(DATUM)); goods.put("DATUM", DateUtil.parseDate(DATUM, DateUtil.FMT_DATE));
goods.put("UZEIT", timef.parse(UZEIT)); goods.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME)/*timef.parse(UZEIT)*/);
/***************header**************/ /***************header**************/
/***************item**************/ /***************item**************/
...@@ -76,8 +70,8 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -76,8 +70,8 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("NET_WEIGHT", Double.valueOf(element.elementText("NTGEW"))); goods.put("NET_WEIGHT", Double.valueOf(element.elementText("NTGEW")));
goods.put("WETGHT_UNIT", element.elementText("GEWEI")); goods.put("WETGHT_UNIT", element.elementText("GEWEI"));
goods.put("CATEGORY_CODE", element.elementText("PLINE")); goods.put("CATEGORY_CODE", element.elementText("PLINE"));
goods.put("CREATION_DATE", datef.parse(element.elementText("ERSDA"))); goods.put("CREATION_DATE", DateUtil.parseDate(element.elementText("ERSDA"), DateUtil.FMT_DATE));
goods.put("LAST_CHANGE_DATE", datef.parse(element.elementText("LAEDA"))); goods.put("LAST_CHANGE_DATE", DateUtil.parseDate(element.elementText("LAEDA"), DateUtil.FMT_DATE));
goods.put("GOODS_NAME", element.elementText("NORMT")); goods.put("GOODS_NAME", element.elementText("NORMT"));
goods.put("VMSTA", element.elementText("VMSTA")); goods.put("VMSTA", element.elementText("VMSTA"));
goods.put("STKTYP", element.elementText("STKTYP")); goods.put("STKTYP", element.elementText("STKTYP"));
...@@ -119,10 +113,10 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -119,10 +113,10 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
String BATCH = (String) goods.get("BATCH"); String BATCH = (String) goods.get("BATCH");
if(BATCH==null||"".equals(BATCH.trim())) { if(BATCH==null||"".equals(BATCH.trim())) {
BATCH = datef.format(new Date())+"-1"; BATCH = DateUtil.formatDate(new Date(), DateUtil.FMT_DATE)+"-1"/*datef.format(new Date())+"-1"*/;
}else { }else {
String[] ss = BATCH.split("-"); String[] ss = BATCH.split("-");
String newDate = datef.format(new Date()); String newDate = DateUtil.formatDate(new Date(), DateUtil.FMT_DATE);
int v = 1; int v = 1;
if(ss[0].equals(newDate)) { if(ss[0].equals(newDate)) {
v = Integer.valueOf(ss[1])+1; v = Integer.valueOf(ss[1])+1;
...@@ -132,7 +126,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -132,7 +126,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("BATCH", BATCH); goods.put("BATCH", BATCH);
goods.put("SEND_STATUS", "N"); goods.put("SEND_STATUS", "N");
goods.put("UPDATED", datetimef.format(new Date())); goods.put("UPDATED", DateUtil.formatDate(new Date(), DateUtil.FMT_DATE_TIME)/*datetimef.format(new Date())*/);
System.out.println(JSON.toJSONString(goods)); System.out.println(JSON.toJSONString(goods));
...@@ -163,19 +157,15 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -163,19 +157,15 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
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"));
System.out.println("-------------------------------");
System.out.println(sql);
System.out.println(JSON.toJSONString(args));
System.out.println("-------------------------------");
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"; String countSql = "select count(1) from t_ven_goods";
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
String ID = System.currentTimeMillis() + prependZero(count+1, 5); String ID = System.currentTimeMillis() + StringUtil.prependZero(count+1, 5);
goods.put("ID", ID); goods.put("ID", ID);
goods.put("CREATED", datetimef.format(new Date())); goods.put("CREATED", DateUtil.formatDate(new Date(), DateUtil.FMT_DATE_TIME)/*datetimef.format(new Date())*/);
goods.put("CREATEDBY", ""); goods.put("CREATEDBY", "");
...@@ -191,25 +181,9 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -191,25 +181,9 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
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("-------------------------------");
System.out.println(insertSql);
System.out.println(JSON.toJSONString(values));
System.out.println("-------------------------------");
jdbcTemplate.update(insertSql, values.toArray()); jdbcTemplate.update(insertSql, values.toArray());
} }
private String prependZero(int Num, int length) {
return prependZero(Num+"", length);
}
private String prependZero(String Num, int length) {
String prepend = "";
for(int i=Num.length(); i<length; i++) {
prepend = prepend + "0";
}
return prepend + Num;
}
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);
......
package com.egolm.sso.service.impl;
import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.egolm.sso.service.CommonService;
import com.egolm.sso.service.PriceListService;
@Component
@WebService(serviceName = "PriceListService", targetNamespace = "http://service.sso.egolm.com", endpointInterface = "com.egolm.sso.service.PriceListService")
public class PriceListServiceImpl implements PriceListService {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
@Override
public void execute(String xml) {
// TODO Auto-generated method stub
}
}
package com.egolm.sso.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
public class DateUtil {
public static Map<String, DateFormat> fmtMap;
public static final String FMT_DATE = "yyyyMMdd";
public static final String FMT_TIME = "HHmmss";
public static final String FMT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
public static String formatDate(Date d, String fmt) {
DateFormat df = getFmt(fmt);
return formatDate(d, df);
}
public static String formatDate(Date d, DateFormat fmt) {
return fmt.format(d);
}
public static Date parseDate(String d, String fmt) throws ParseException {
DateFormat df = getFmt(fmt);
return parseDate(d, df);
}
public static Date parseDate(String d, DateFormat fmt) throws ParseException {
return fmt.parse(d);
}
public static DateFormat getFmt(String fmt) {
DateFormat df = fmtMap.get(fmt);
if(df == null) {
df = new SimpleDateFormat(fmt);
}
return df;
}
}
package com.egolm.sso.util;
public class StringUtil {
public static String prependZero(int Num, int length) {
return prependZero(Num+"", length);
}
public static String prependZero(String Num, int length) {
String prepend = "";
for(int i=Num.length(); i<length; i++) {
prepend = prepend + "0";
}
return prepend + Num;
}
}
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