pancy před 2 roky
revize
3a2dd6ba69

+ 19 - 0
tbb/.classpath

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="tbb/classes" path="tbb/src/public"/>
+	<classpathentry kind="src" output="tbb/classes" path="tbb/src/client"/>
+	<classpathentry kind="src" output="tbb/classes" path="tbb/src/private"/>
+	<classpathentry kind="src" output="tbb/classes" path="tbb/src/test"/>
+	<classpathentry kind="src" output="tbb/classes" path="tbb/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"/>
+	<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="output" path="bin"/>
+</classpath>

+ 25 - 0
tbb/.project

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>tbb</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.yonyou.studio.udt.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>com.yonyou.studio.udt.core.nature</nature>
+		<nature>com.yonyou.studio.ria.core.ModuleProjectNature</nature>
+		<nature>com.yonyou.studio.ria.core.BizCompProjectNature</nature>
+	</natures>
+</projectDescription>

+ 7 - 0
tbb/META-INF/module.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="gb2312"?>
+<module name="tbb">
+    <public>
+    </public>
+    <private>
+    </private>
+</module>

+ 8 - 0
tbb/META-INF/service.upm

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding='gb2312'?>
+<module name="tbb">
+    <public>
+ 	   <component name="ModifyBudget" accessProtected="false"  remote="true" singleton="true" tx="NONE" supportAlias="true">
+       <implementation>nc.bs.tbb.servlet.ModifyBudgetServlet</implementation>
+ 	   </component>
+    </public>	
+</module>

+ 23 - 0
tbb/bin/.project

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>tbb</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.yonyou.studio.udt.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>com.yonyou.studio.udt.core.nature</nature>
+	</natures>
+</projectDescription>

+ 7 - 0
tbb/bin/META-INF/module.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="gb2312"?>
+<module name="tbb">
+    <public>
+    </public>
+    <private>
+    </private>
+</module>

+ 21 - 0
tbb/manifest.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Manifest>
+  <BusinessComponet name="tbb" dispname="tbb">
+    <public>
+      <src name="src/public"/>
+    </public>
+    <client>
+      <src name="src/client"/>
+    </client>
+    <private>
+      <src name="src/private"/>
+    </private>
+    <test>
+      <src name="src/test"/>
+    </test>
+    <resource>
+      <src name="resources"/>
+    </resource>
+    <funnodes/>
+  </BusinessComponet>
+</Manifest>

binární
tbb/tbb/classes/nc/bs/servlet/service/BaseServlet.class


binární
tbb/tbb/classes/nc/bs/tbb/servlet/ModifyBudgetServlet.class


+ 1 - 0
tbb/tbb/classes/xhcl.gitkeep

@@ -0,0 +1 @@
+ユシホサキ�

+ 1 - 0
tbb/tbb/src/client/xhcl.gitkeep

@@ -0,0 +1 @@
+ユシホサキ�

+ 263 - 0
tbb/tbb/src/private/nc/bs/tbb/servlet/ModifyBudgetServlet.java

@@ -0,0 +1,263 @@
+package nc.bs.tbb.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import nc.bs.dao.BaseDAO;
+import nc.bs.dao.DAOException;
+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.servlet.service.BaseServlet;
+import nc.itf.uap.IUAPQueryBS;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.vo.pub.BusinessException;
+import nc.vo.pub.lang.UFDouble;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+public class ModifyBudgetServlet extends BaseServlet implements IHttpServletAdaptor{
+
+	BaseDAO basedao = new BaseDAO();
+	IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+	String kyye = "CORPYS0000";//可用余额编码
+	String ysze = "CORPYS0003";//预算总额编码
+	String sjsy = "Actual";//实际使用数编码
+	String yzs = "PreActual";//预占数编码
+	String yss = "Budget";//预算数编码
+	
+	@Override
+	public void doAction(HttpServletRequest req, HttpServletResponse resp)
+			throws ServletException, IOException {
+		// TODO 自动生成的方法存根
+		NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
+		
+		try {
+			String createStr = buildJson(req, resp, this.getClass().getName());
+			JSONObject json = JSONObject.fromObject(createStr);
+			String checkresult = checkJson(json);
+			if(checkresult != null){
+				resp.getWriter().write(formatRSJsonData("失败",
+						checkresult,"").toString());
+				return;
+			}
+			JSONArray bodyArray = json.getJSONArray("result");
+			JSONArray result = new JSONArray();
+			for (Object Object : bodyArray) {
+				JSONObject bodyObject = JSONObject.fromObject(Object);
+				String objcode = QueryModelCode(bodyObject.getString("objname"));//应用模型编码
+				String code_entity = bodyObject.getString("code_entity");//责任主体
+				String pk_year = bodyObject.getString("pk_year");//会计年度
+				String code_measure = QueryMeasureCode(bodyObject.getString("code_measure"));//预算编码
+				String code_version = QueryVersionCode(bodyObject.getString("code_version"));//预算版本
+				UFDouble value = new UFDouble(bodyObject.getString("value"));//预算总额
+				UFDouble actualUse = new UFDouble(QueryNmny(objcode,code_entity,pk_year,code_measure,code_version,sjsy));//本年度实际使用数
+				UFDouble pupremny = new UFDouble(QueryNmny(objcode,code_entity,pk_year,code_measure,code_version,yzs));//预占数
+				//预算总额-本年度实际使用数-预占数<0抛异常
+				if(value.sub(actualUse).sub(pupremny).compareTo(UFDouble.ZERO_DBL)<0){
+					result.add(formatRSJsonData("失败",
+							bodyObject.getString("objname")+pk_year+"年"+bodyObject.getString("code_measure")+"可用额度不足,请检查","").toString());
+				}
+				else{
+					Object ndyspk = QueryPk(objcode,code_entity,pk_year,code_measure,code_version,yss);//预算数pk
+					if(ndyspk != null){
+						//修改本年度预算数
+						UpdateSql(objcode,value.toString(),ndyspk.toString());
+					}
+					Object yszepk = QueryPk(objcode,code_entity,pk_year,code_measure,code_version,ysze);//预算总额pk
+					if(yszepk != null){
+						//修改预算总额
+						UpdateSql(objcode,value.toString(),yszepk.toString());
+					}
+					Object kyyepk = QueryPk(objcode,code_entity,pk_year,code_measure,code_version,kyye);//可用余额pk
+					if(kyyepk != null){
+						//修改可用余额
+						UpdateSql(objcode,value.sub(actualUse).sub(pupremny).toString(),kyyepk.toString());
+					}
+					result.add(formatRSJsonData("成功",
+						     "",bodyObject.getString("objname")+pk_year+"年"+bodyObject.getString("code_measure")+"预算修改成功").toString());
+				}
+			}
+			resp.getWriter().write(result.toString());
+		} catch (Exception e) {
+			// TODO 自动生成的 catch 块
+			e.printStackTrace();
+		}//非空判断
+	}
+
+	/*
+	 * 非空判断
+	 */
+	private String checkJson(JSONObject json) throws Exception {
+		
+		StringBuffer mags = new StringBuffer();
+		Boolean empty = true;
+		
+		String body = "result";//表体
+		
+		if (json.getJSONArray(body)==null) {
+			empty = false;
+			mags.append("表体不存在! ");
+		}
+		
+		JSONArray oprepObjectBs = json.getJSONArray("result");
+		
+		if (oprepObjectBs == null || oprepObjectBs.size() == 0) {
+			return "表体内容不可为空!";
+		}
+		
+		String objname = "objname";//应用模型
+		String code_entity = "code_entity";//责任主体
+		String pk_year = "pk_year";//会计年份
+		String code_measure = "code_measure";//预算编码
+		String code_version = "code_version";//预算版本
+
+		String value = "value";//预算额度
+		
+		for(int i = 0; i < oprepObjectBs.size(); i++) {
+			
+			JSONObject oprepJsonObjectB = oprepObjectBs.getJSONObject(i);
+			String[] BodyKey = {objname,code_entity,pk_year,code_measure,code_version,value};
+			int num = i+1;
+			
+			mags.append("第"+num+"块表体:{");
+			for (String as : BodyKey) {
+
+				if (oprepJsonObjectB.getString(as).isEmpty()) {
+					empty = false;
+					mags.append("'" + as + "' ");
+				}
+			}
+			mags.append("}");
+		}
+		
+		if (!empty) {
+			return "以下字段不可为空:"+mags;
+		}
+		return null;
+	}
+
+	/**
+	 * 修改预算额度
+	 * @param objcode
+	 * @param value
+	 * @param pk
+	 * @throws DAOException
+	 */
+	public void UpdateSql(String objcode,String value,String pk) throws DAOException{
+		String sql = "update tb_cube_"+objcode+" set value = '"+value+"' where pk_obj = '"+pk+"'";
+		basedao.executeUpdate(sql);
+		
+	}
+	
+	/**
+	 * 查询pk
+	 * @param objcode
+	 * @param code_entity
+	 * @param pk_year
+	 * @param code_measure
+	 * @param code_version
+	 * @param code_mvtype
+	 * @return
+	 */
+	public String QueryPk(String objcode,String code_entity,String pk_year,String code_measure,String code_version,String code_mvtype){
+		String qrysql = "select pk_obj from tb_cube_"+objcode+" where code_entity = '"+code_entity+"' and pk_year = '"+pk_year+"' and code_measure = '"+code_measure+"'  and code_version = '"+code_version+"' and code_mvtype = '"+code_mvtype+"'";
+		Object object = "";
+		try {
+			object = iuap.executeQuery(qrysql, new ColumnProcessor());
+		} catch (BusinessException e) {
+			// TODO 自动生成的 catch 块
+			e.printStackTrace();
+		}
+		if (object==null) {
+			return null;
+		}else {
+			return object.toString();
+		}
+	}
+	
+	/**
+	 * 查询金额
+	 * @param objcode
+	 * @param code_entity
+	 * @param pk_year
+	 * @param code_measure
+	 * @param code_version
+	 * @param code_mvtype
+	 * @return
+	 */
+	public String QueryNmny(String objcode,String code_entity,String pk_year,String code_measure,String code_version,String code_mvtype){
+		String qrysql = "select value from tb_cube_"+objcode+" where code_entity = '"+code_entity+"' and pk_year = '"+pk_year+"' and code_measure = '"+code_measure+"'  and code_version = '"+code_version+"' and code_mvtype = '"+code_mvtype+"'";
+		Object object = "";
+		try {
+			object = iuap.executeQuery(qrysql, new ColumnProcessor());
+		} catch (BusinessException e) {
+			// TODO 自动生成的 catch 块
+			e.printStackTrace();
+		}
+		if (object==null) {
+			return "0";
+		}else {
+			return object.toString();
+		}
+	}
+	
+	
+	
+	/**
+	 * 查询应用模型编码
+	 * @param objname
+	 * @return
+	 * @throws BusinessException
+	 */
+	public String QueryModelCode(String objname) throws BusinessException{
+		String qrysql = "select objcode from tb_cubedef where objname = '"+objname+"' and nvl(dr,0) = 0";
+		Object object;
+		object = iuap.executeQuery(qrysql, new ColumnProcessor());
+		if (object==null) {
+			return null;
+		}else {
+			return object.toString();
+		}
+	}
+	
+	
+	/**
+	 * 查询预算编码
+	 * @param code_measure
+	 * @return
+	 * @throws BusinessException
+	 */
+	public String QueryMeasureCode(String code_measure) throws BusinessException{
+		String qrysql = "select code from bd_inoutbusiclass where name = '"+code_measure+"' and nvl(dr,0) = 0";
+		Object object;
+		object = iuap.executeQuery(qrysql, new ColumnProcessor());
+		if (object==null) {
+			return null;
+		}else {
+			return object.toString();
+		}
+	}
+	
+	
+	/**
+	 * 查询版本编码
+	 * @param code_version
+	 * @return
+	 * @throws BusinessException
+	 */
+	public String QueryVersionCode(String code_version) throws BusinessException{
+		String qrysql = "select objcode from tb_version where objname = '"+code_version+"' and nvl(dr,0) = 0";
+		Object object;
+		object = iuap.executeQuery(qrysql, new ColumnProcessor());
+		if (object==null) {
+			return null;
+		}else {
+			return object.toString();
+		}
+	}
+}

+ 85 - 0
tbb/tbb/src/public/nc/bs/servlet/service/BaseServlet.java

@@ -0,0 +1,85 @@
+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 uap.json.JSONObject;
+
+/**
+ * 提供一些公共方法
+ * 具体业务请在实际服务类实现
+ */
+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;
+	}
+
+
+
+	/**
+	 * 格式返回json数据
+	 *
+	 * @return
+	 * @throws JSONException
+	 * @throws Exception
+	 */
+	public static JSONObject formatRSJsonData(String status,String error,String message){
+		JSONObject rs = new JSONObject();
+		rs.put("status", status);
+		rs.put("message", message);
+		rs.put("error", error);
+		return rs;
+	}
+	
+}