Browse Source

预算重启接口

yaoyu 2 weeks ago
parent
commit
5e3acc23d0

+ 13 - 0
tbb/META-INF/budget.upm

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding='gb2312'?>
+<module name="tbb">
+	<public>
+	<component priority="0" singleton="true" remote="true" tx="NONE" supportAlias="true">
+	      <interface>nc.itf.tbb.IBudgetService</interface>
+	      <implementation>nc.impl.tbb.BudgetServiceImpl</implementation>
+	    </component>	
+	
+         <component name="ResetBudget" accessProtected="false"  remote="true" singleton="true" tx="NONE" supportAlias="true">
+          <implementation>nc.impl.tbb.ResetBudgetImpl</implementation>
+        </component>
+	</public>
+</module>

+ 32 - 0
tbb/tbb/src/private/nc/impl/tbb/BudgetServiceImpl.java

@@ -0,0 +1,32 @@
+package nc.impl.tbb;
+
+import java.util.List;
+import java.util.Map;
+
+import nc.bs.framework.common.NCLocator;
+import nc.itf.tbb.IBudgetService;
+import nc.itf.uap.IUAPQueryBS;
+import nc.jdbc.framework.processor.BeanProcessor;
+import nc.ms.tb.control.CtlSchemeCTL;
+import nc.ms.tb.rule.CtlSchemeServiceGetter;
+import nc.vo.tb.task.MdTask;
+
+public class BudgetServiceImpl implements IBudgetService{
+	IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+	@Override
+	public void reset_RequiresNew(String entityPk, String pk_year) throws Exception {
+		String sWhere_cube = "pk_plan in (SELECT pk_obj FROM tb_md_task WHERE planstatus <> '000' and versionstatus in ( '00', '08', '06' ) and pk_planent = '"+entityPk+"' and pk_year = '"+pk_year+"' and ( BUSISYSTEM = 'TB' ) ) and isstarted = 'Y' and pk_parent is not null";
+		Map<String, List<String>> ctlmap_Cube = CtlSchemeServiceGetter.getICtlScheme().queryCtrlSchemeSimply(sWhere_cube);
+		//ctlmap_Cube不等于0表示该控制方案已经停用不需要重新启用停用
+		if(ctlmap_Cube.size() != 0) {
+			//停用控制方案
+			CtlSchemeServiceGetter.getICtlScheme().deleteCtrlScheme(ctlmap_Cube);
+			//启用控制方案
+			String sql =  "SELECT * FROM tb_md_task WHERE planstatus <> '000' and versionstatus in ( '00', '08', '06' ) and pk_planent = '"+entityPk+"' and pk_year = '"+pk_year+"' and ( BUSISYSTEM = 'TB' )";
+			MdTask mdTask = (MdTask) iuap.executeQuery(sql, new BeanProcessor(MdTask.class));
+			CtlSchemeCTL.onUseAllCrelSchemeInClient(new MdTask[] {mdTask});
+		}
+		
+	}
+
+}

+ 103 - 0
tbb/tbb/src/private/nc/impl/tbb/ResetBudgetImpl.java

@@ -0,0 +1,103 @@
+package nc.impl.tbb;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.alibaba.fastjson.JSONArray;
+
+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.tbb.IBudgetService;
+import nc.itf.uap.IUAPQueryBS;
+import nc.jdbc.framework.processor.BeanProcessor;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.log.NcLog;
+import nc.ms.tb.control.CtlSchemeCTL;
+import nc.ms.tb.rule.CtlSchemeServiceGetter;
+import nc.vo.tb.task.MdTask;
+import net.sf.json.JSONObject;
+
+public class ResetBudgetImpl extends BaseServlet implements IHttpServletAdaptor{
+
+	@Override
+	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+		try {
+			IUAPQueryBS iuap = (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+			NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
+			InvocationInfoProxy.getInstance().setGroupId("0001A110000000000LO7");
+			String createStr = buildJson(req, resp, this.getClass().getName());
+			NcLog.info("预算重启开始:"+ createStr);
+			JSONObject json = JSONObject.fromObject(createStr);
+			
+			checkJson(json);
+			String code_entity = json.getString("code_entity");//责任主体
+			String pk_year = json.getString("pk_year");//会计年度
+			String entityPk = QueryOrgPk(code_entity);//责任主体pk
+			
+			//调用预算重启事务
+			IBudgetService service = NCLocator.getInstance().lookup(IBudgetService.class);
+			
+			service.reset_RequiresNew(entityPk, pk_year);
+			resp.getWriter().write(formatRSJsonData("成功", "", null).toString());
+			NcLog.info("预算重启结束");
+		} catch (Exception e) {
+			resp.getWriter().write(formatRSJsonData("失败",e.getMessage() == null ? "" : e.getMessage(),null).toString());
+			StringWriter stringWriter = new StringWriter();
+			e.printStackTrace(new PrintWriter(stringWriter));
+			//获取详细信息
+			String msg = stringWriter.getBuffer().toString();
+			NcLog.info("预算重启失败:"+ msg);
+		}
+	}
+	
+	
+	private void checkJson(JSONObject json) throws Exception {
+		
+		StringBuffer mags = new StringBuffer();
+		Boolean empty = true;
+		
+		String code_entity = "code_entity";
+		String pk_year = "pk_year";
+		
+		String[] HeadKey = {code_entity,pk_year};
+		
+		for (String as : HeadKey) {
+
+			if (json.getString(as).isEmpty()) {
+				empty = false;
+				mags.append("'" + as + "'");
+			}
+		}
+
+		if (!empty) {
+			throw new Exception("以下字段不可为空:"+mags);
+		}
+	}
+	
+	/**
+	 * 查询责任主体pk
+	 * @param code_entity
+	 * @return
+	 * @throws Exception
+	 */
+	public String QueryOrgPk(String code_entity) throws Exception{
+		IUAPQueryBS iuap = (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+		String qrysql = "select pk_org from org_orgs where code = '"+code_entity+"' and nvl(dr,0) = 0";
+		String pk_org = (String) iuap.executeQuery(qrysql, new ColumnProcessor());
+		if (pk_org == null) {
+			throw new Exception("获取责任主体信息失败,未找到与参数" + code_entity + "有关的数据!");
+		}
+		return pk_org;
+	}
+
+}

+ 6 - 0
tbb/tbb/src/public/nc/itf/tbb/IBudgetService.java

@@ -0,0 +1,6 @@
+package nc.itf.tbb;
+
+public interface IBudgetService {
+
+	public void reset_RequiresNew(String entityPk,String pk_year)throws Exception;
+}