소스 검색

供应商同步

y1456 1 년 전
부모
커밋
f66262743b

+ 1 - 0
OpenAPI/bin/.gitignore

@@ -0,0 +1 @@
+/indi/

+ 29 - 24
baseapp/.classpath

@@ -1,24 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/public"/>
-	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/client"/>
-	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/private"/>
-	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/test"/>
-	<classpathentry kind="src" output="baseapp/classes" path="baseapp/resources"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Ant_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Product_Common_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Middleware_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Framework_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Public_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Client_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Private_Library">
-		<accessrules>
-			<accessrule kind="accessible" pattern="**"/>
-		</accessrules>
-	</classpathentry>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Lang_Library"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Generated_EJB"/>
-	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/NCCloud_Library"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="arap/classes" path="arap/src/public"/>
+	<classpathentry kind="src" output="arap/classes" path="arap/src/client"/>
+	<classpathentry kind="src" output="arap/classes" path="arap/src/private"/>
+	<classpathentry kind="src" output="arap/classes" path="arap/src/test"/>
+	<classpathentry kind="src" output="arap/classes" path="arap/resources"/>
+	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/public"/>
+	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/client"/>
+	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/private"/>
+	<classpathentry kind="src" output="baseapp/classes" path="baseapp/src/test"/>
+	<classpathentry kind="src" output="baseapp/classes" path="baseapp/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Ant_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Product_Common_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Middleware_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Framework_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Public_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Client_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Private_Library">
+		<accessrules>
+			<accessrule kind="accessible" pattern="**"/>
+		</accessrules>
+	</classpathentry>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Lang_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Generated_EJB"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/NCCloud_Library"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 8 - 0
baseapp/arap/META-INF/servlet.upm

@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<module name="arap">
+    <public>
+         <component accessProtected="false"  name="PushSupplierToYH" remote="true" singleton="true" tx="CMT">
+            <implementation>nc.bs.arap.impl.SupplierMaintainImpl</implementation>
+        </component>
+    </public>
+</module>

+ 5 - 0
baseapp/arap/classes/.gitignore

@@ -0,0 +1,5 @@
+/SupplierMaintainImpl.class
+/nc/
+/BaseServlet.class
+/GetDataUtil.class
+/.gitkeep

+ 3 - 0
baseapp/arap/component.xml

@@ -0,0 +1,3 @@
+<component name="arap" displayname="arap">
+  <dependencies/>
+</component>

+ 8 - 0
baseapp/arap/resources/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO

+ 3 - 0
baseapp/arap/script/conf/initdata/items.xml

@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<items>
+</items>

+ 8 - 0
baseapp/arap/src/client/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO

+ 138 - 0
baseapp/arap/src/private/nc/bs/arap/impl/SupplierMaintainImpl.java

@@ -0,0 +1,138 @@
+package nc.bs.arap.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.alibaba.fastjson.JSONObject;
+
+import nc.bs.framework.adaptor.IHttpServletAdaptor;
+import nc.bs.framework.common.InvocationInfoProxy;
+import nc.bs.framework.common.NCLocator;
+import nc.bs.framework.server.ISecurityTokenCallback;
+import nc.bs.yinhe.plugin.GetDataUtil;
+import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoService;
+import nc.log.NcLog;
+import nc.pub.billcode.itf.IBillcodeManage;
+import nc.vo.bd.supplier.SupplierVO;
+import nc.vo.pub.lang.UFBoolean;
+import nc.vo.pub.lang.UFDateTime;
+import nc.bs.servlet.service.BaseServlet;
+
+public class SupplierMaintainImpl extends BaseServlet implements IHttpServletAdaptor{
+	// 请求名称
+	private	String name = "";
+
+	@Override
+	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+		try {
+			String parameter = buildJson(req, resp, this.getClass().getName());
+			JSONObject arys = JSONObject.parseObject(parameter);
+			name = arys.getString("name");
+			checkJson(arys);
+			NcLog.info("供应商档案:" + parameter);
+			resp.getWriter().write(collect(arys));
+		} catch (Exception e) {
+			//前端控制台打印xml数据
+			resp.getWriter().write(formatData(name,"","0",e.getMessage()==null?e.toString():e.getMessage()));
+			StringWriter stringWriter = new StringWriter();
+			e.printStackTrace(new PrintWriter(stringWriter));
+			//获取详细信息
+			String msg=stringWriter.getBuffer().toString();
+			NcLog.info("供应商档案:"+msg);
+		}
+	
+	}
+
+	private  String collect(JSONObject arys) throws Exception{
+		//登录NCC
+		NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(), "pfxx".getBytes());
+		//设置数据源
+		InvocationInfoProxy.getInstance().setUserDataSource("NCC01");
+		//用户主键
+		String userpk = GetDataUtil.getUser(arys.getString("creator")).getCuserid();
+		InvocationInfoProxy.getInstance().setUserId(userpk);
+		//指定集团pk
+		String grouppk = GetDataUtil.getGroup(arys.getString("group")).getPk_group();
+		InvocationInfoProxy.getInstance().setGroupId(grouppk);
+		//判断是否存在该供应商名称,有返回供应商编码,无调用供应商新增接口返回供应商编码
+		String  code = GetDataUtil.queyrFWName(name);
+		if(code != null) {
+			return formatData(name,code,"1","");
+		}else {
+			SupplierVO supplierVO = new SupplierVO();
+			//集团
+			supplierVO.setPk_group(grouppk);
+			//组织
+			supplierVO.setPk_org(grouppk);
+			//创建时间
+			//supplierVO.setCreationtime(new UFDateTime(arys.getString("billDate")));
+			//创建人
+			supplierVO.setCreator(userpk);
+			//分布式
+			supplierVO.setDataoriginflag(0);
+			//启用状态
+			supplierVO.setEnablestate(2);
+			//客户Y
+			supplierVO.setIscustomer(new UFBoolean("N"));
+			//散户N
+			supplierVO.setIsfreecust(new UFBoolean("N"));
+			//外部检测机构N
+			supplierVO.setIsoutcheck(new UFBoolean("N"));
+			//VAT注册码N
+			supplierVO.setIsvat(new UFBoolean("N"));
+			//供应商名称
+			supplierVO.setName(name);
+			//调用编码规则接口获取供应商编码
+			IBillcodeManage iBillcodeManage = NCLocator.getInstance().lookup(IBillcodeManage.class);
+			supplierVO.setCode(iBillcodeManage.getPreBillCode_RequiresNew("supplier", grouppk, grouppk));
+			//国家/地区CN
+			supplierVO.setPk_country(GetDataUtil.getCountryzone("CN").getPk_country());
+			//注册资金币种CNY
+			supplierVO.setPk_currtype(GetDataUtil.getCurrtype("CNY").getPk_currtype());
+			//数据格式ZH-CN
+			supplierVO.setPk_format(GetDataUtil.getFormatDoc("ZH-CN").getPk_formatdoc());
+			//供应商基本分类
+			supplierVO.setPk_supplierclass(GetDataUtil.getSupplierclass(arys.getString("supplierclass")).getPk_supplierclass());
+			//时区
+			supplierVO.setPk_timezone(GetDataUtil.getTimezone("P0800").getPk_timezone());
+			//供应商类型
+			supplierVO.setSupprop(0);
+			//供应商状态
+			supplierVO.setSupstate(1);
+			ISupplierBaseInfoService iSupplierBaseInfoService = NCLocator.getInstance().lookup(ISupplierBaseInfoService.class);
+			SupplierVO supplierVOs = iSupplierBaseInfoService.insertSupplierVO(supplierVO, true);
+			return formatData(name,supplierVOs.getCode(),"2","");
+		}
+	}
+	
+	/*
+	 * 非空判断
+	 */
+	private void checkJson(JSONObject arys) throws Exception {
+		
+		StringBuffer mags = new StringBuffer();
+		
+		String group = "group";//集团编码
+		String name = "name";//供应商名称
+		String supplierclass = "supplierclass";//供应商基本分类
+		String creator = "creator";//创建人
+ 
+		String[] HeadKey = {group,name,supplierclass,creator};
+		
+		for (String as : HeadKey) {
+
+			if (arys.getString(as) == null || arys.getString(as).isEmpty()) {
+				mags.append("'" + as + "'");
+			}
+		}
+		
+		if (mags.length()!=0) {
+			throw new Exception("以下字段不可为空:"+mags);
+		}
+	}
+}

+ 82 - 0
baseapp/arap/src/private/nc/bs/servlet/service/BaseServlet.java

@@ -0,0 +1,82 @@
+package nc.bs.servlet.service;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+
+import org.codehaus.jettison.json.JSONException;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+
+
+/**
+ * 提供一些公共方法
+ * 具体业务请在实际服务类实现
+ */
+public class BaseServlet {
+
+	public static String STATUS_SUCCESS ="success";
+	public static String STATUS_FAILURE ="fail";
+
+	/**
+	 * 格式化传入的数据,JSON化在具体服务类实现
+	 * @param req
+	 * @param resp
+	 * @param 类名
+	 * @return
+	 * @throws ServletException
+	 * @throws IOException
+	 */
+	protected String buildJson(HttpServletRequest req,
+							   HttpServletResponse resp, String classname)
+			throws ServletException, IOException {
+		req.setCharacterEncoding("UTF-8");
+		/* 设置格式为text/json */
+		resp.setContentType("text/json");
+		/* 设置字符集为'UTF-8' */
+		resp.setCharacterEncoding("UTF-8");
+		String reqJsonData = null;
+		// 接收流
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				req.getInputStream(), "UTF-8"));
+		StringBuffer jsonStr = new StringBuffer();
+		try {
+			String line = "";
+			while ((line = reader.readLine()) != null) {
+				jsonStr.append(line);
+			}
+			if (jsonStr != null && !"".equals(jsonStr.toString())) {
+				reqJsonData = jsonStr.toString();
+//				PrLogger.error(new UFDateTime(System.currentTimeMillis()).toString()
+//						+ "客户端传入:" + classname + "~~" + reqJsonData);
+			} else {
+				throw new ServletException("传入的数据不合法!");
+			}
+		} catch (IOException e) {
+			throw new IOException("数据读取失败" + e.getMessage());
+		} finally {
+			reader.close();
+		}
+		return reqJsonData;
+	}
+
+
+
+	
+	protected static String formatData(String name, String code, String status, String message) {
+		JSONObject rs = new JSONObject();
+		rs.put("name", name);
+		rs.put("code", code);
+		rs.put("status", status);
+		rs.put("message", message);
+		return JSONObject.toJSONString(rs,SerializerFeature.WriteMapNullValue);
+	}
+
+}

+ 119 - 0
baseapp/arap/src/private/nc/bs/yinhe/plugin/GetDataUtil.java

@@ -0,0 +1,119 @@
+package nc.bs.yinhe.plugin;
+
+import nc.bs.framework.common.NCLocator;
+import nc.itf.uap.IUAPQueryBS;
+import nc.jdbc.framework.processor.BeanProcessor;
+import nc.vo.bd.countryzone.CountryZoneVO;
+import nc.vo.bd.currtype.CurrtypeVO;
+import nc.vo.bd.format.FormatDocVO;
+import nc.vo.bd.supplier.SupplierVO;
+import nc.vo.bd.supplier.supplierclass.SupplierclassVO;
+import nc.vo.bd.timezone.TimezoneVO;
+import nc.vo.org.GroupVO;
+import nc.vo.org.OrgVO;
+import nc.vo.sm.UserVO;
+import nccloud.jdbc.ColumnProcessor;
+
+/**
+ * 工具类
+ * 
+ * @author 隔壁老赵
+ *
+ */
+public class GetDataUtil {
+	
+	private static IUAPQueryBS iUAPQueryBS = (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+	
+	
+	
+	// 用户 (sm_user)
+	public static UserVO getUser(String parameters) throws Exception {
+		String sql = "select * From sm_user where  user_code='"+parameters+"' and nvl(dr,0)=0";
+		UserVO userVO = (UserVO) iUAPQueryBS.executeQuery(sql, new BeanProcessor(UserVO.class));
+		if (userVO ==null) {
+			throw new Exception("获取用户信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return userVO;
+	}
+	
+	// 获取集团信息(org_group)
+	public static GroupVO getGroup(String parameters) throws Exception {
+		String sql = "select * from org_group where code='"+parameters+"' and nvl(dr,0)=0";
+		GroupVO groupVO = (GroupVO) iUAPQueryBS.executeQuery(sql, new BeanProcessor(GroupVO.class));
+		if (groupVO == null) {
+			throw new Exception("获取集团信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return groupVO;
+	}
+	
+	// 获取组织编码 (org_orgs)
+	public static OrgVO getOrgs(String parameters) throws Exception {
+		String sql = "select * From org_orgs  where  code='"+parameters+"' and  nvl(dr,0)=0";
+		OrgVO orgVO =  (OrgVO) iUAPQueryBS.executeQuery(sql, new BeanProcessor(OrgVO.class));
+		if (orgVO == null) {
+			throw new Exception("获取组织信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return orgVO;
+	}
+	
+	// 国家地区 (bd_countryzone) 默认中国
+	public static CountryZoneVO getCountryzone(String parameters) throws Exception {
+		String sql = "select * from bd_countryzone  where  code='"+parameters+"'   and nvl(dr,0)=0;";
+		CountryZoneVO countryZoneVO = (CountryZoneVO) iUAPQueryBS.executeQuery(sql,new BeanProcessor(CountryZoneVO.class));
+		if (countryZoneVO == null) {
+			throw new Exception("获取国家地区信息失败,未找到与参数"+parameters+"有关的数据!");
+		}
+		return countryZoneVO;
+	}
+	
+	// 获取币种信息(bd_currtype)
+	public static CurrtypeVO getCurrtype(String parameters) throws Exception {
+		String sql = "select*From bd_currtype where  code='"+parameters+"' and nvl(dr,0)=0 ";
+		CurrtypeVO currtypeVO = (CurrtypeVO) iUAPQueryBS.executeQuery(sql,new BeanProcessor(CurrtypeVO.class));
+		if (currtypeVO == null) {
+			throw new Exception("获取币种信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return currtypeVO;
+	}
+	//数据格式(bd_formatdoc)
+	public static FormatDocVO getFormatDoc(String parameters) throws Exception {
+		String sql = "select * from bd_formatdoc where code = '"+parameters+"' and nvl(dr,0)=0 ";
+		FormatDocVO formatDocVO = (FormatDocVO) iUAPQueryBS.executeQuery(sql,new BeanProcessor(FormatDocVO.class));
+		if (formatDocVO == null) {
+			throw new Exception("获取数据格式信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return formatDocVO;
+	}
+	
+	//供应商基本分类(bd_supplierclass)
+	public static SupplierclassVO getSupplierclass(String parameters) throws Exception {
+		String sql = "select * from bd_supplierclass where code = '"+parameters+"' and enablestate = '2' and nvl(dr,0) = 0";
+		SupplierclassVO supplierclassVO = (SupplierclassVO) iUAPQueryBS.executeQuery(sql,new BeanProcessor(SupplierclassVO.class));
+		if (supplierclassVO == null) {
+			throw new Exception("获取供应商基本分类信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return supplierclassVO;
+	}
+	
+	//时区 (bd_timezone) 
+	public static TimezoneVO getTimezone(String parameters) throws Exception {
+		String sql = "select * from bd_timezone where  code ='"+parameters+"' and nvl(dr,0) = 0";
+		TimezoneVO timezoneVO = (TimezoneVO) iUAPQueryBS.executeQuery(sql,new BeanProcessor(TimezoneVO.class));
+		if (timezoneVO == null) {
+			throw new Exception("获取供应商基本分类信息失败,未找到与参数" + parameters + "有关的数据!");
+		}
+		return timezoneVO;
+	}
+	
+	public static String queyrFWName(String name) throws Exception {
+		String sql = "select code from bd_supplier where name='"+name+"' and nvl(dr,0) = 0";
+		SupplierVO  supplierVO  = (SupplierVO) iUAPQueryBS.executeQuery(sql,new BeanProcessor(SupplierVO.class));
+		if(supplierVO == null) {
+			return null;
+		}
+		return supplierVO.getCode();
+	}
+	
+	
+
+}

+ 8 - 0
baseapp/arap/src/public/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO

+ 8 - 0
baseapp/arap/src/test/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO

+ 1 - 0
baseapp/baseapp/classes/.gitignore

@@ -0,0 +1 @@
+/.gitkeep

BIN
baseapp/baseapp/classes/nc/bs/bd/baseservice/md/TreeBaseService.class


+ 8 - 0
baseapp/baseapp/resources/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO

+ 8 - 0
baseapp/baseapp/src/client/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO

+ 8 - 0
baseapp/baseapp/src/test/.gitkeep

@@ -0,0 +1,8 @@
+# .gitignore 
+
+# ignore all files in lib/
+
+# except for .gitkeep
+!.gitkeep
+# ignore TODO file in root directory,not subdir/TODO
+/TODO