Quellcode durchsuchen

销售合同变更

18870042648 vor 2 Jahren
Ursprung
Commit
664b7b186d

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

@@ -1,2 +1 @@
-/.gitkeep
 /nc/

+ 113 - 69
ypff/ypff/src/private/nc/bs/yp/impl/ModifyMaintianImpl.java

@@ -4,6 +4,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import javax.servlet.ServletException;
@@ -18,7 +19,10 @@ import nc.bs.framework.common.NCLocator;
 import nc.bs.framework.server.ISecurityTokenCallback;
 import nc.bs.servlet.service.BaseServlet;
 import nc.bs.yp.plugin.GetBaseDAOUtil;
+import nc.itf.ct.saledaily.ISaledailyApprove;
+import nc.itf.ct.saledaily.ISaledailyMaintain;
 import nc.itf.uap.pf.IPFBusiAction;
+import nc.itf.uap.pf.IplatFormEntry;
 import nc.log.NcLog;
 import nc.md.persist.framework.IMDPersistenceQueryService;
 import nc.vo.bd.material.MaterialVO;
@@ -33,6 +37,7 @@ import nc.vo.ct.saledaily.entity.RecvPlanVO;
 import nc.vo.org.DeptVO;
 import nc.vo.org.GroupVO;
 import nc.vo.org.SalesOrgVO;
+import nc.vo.pub.VOStatus;
 import nc.vo.pub.lang.UFBoolean;
 import nc.vo.pub.lang.UFDate;
 import nc.vo.pub.lang.UFDateTime;
@@ -42,76 +47,77 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
 public class ModifyMaintianImpl extends BaseServlet implements IHttpServletAdaptor{
-	//请求唯一标识
+	//璇锋眰鍞�竴鏍囪瘑
 	private String vbillcode = "";
 	
+	@SuppressWarnings("restriction")
 	@Override
 	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 		try {
 			String createStr = buildJson(req, resp, this.getClass().getName());
 			JSONObject json = JSONObject.fromObject(createStr);
-			NcLog.info("销售合同变更JSON:"+json);
+			NcLog.info("閿€鍞�悎鍚屽彉鏇碕SON:"+json);
 			vbillcode = json.getString("vbillcode");
 			collect(json);
 			resp.getWriter().write(formatRSJsonData("0",vbillcode,"").toString());
 		} catch (Exception e) {
-			//前端控制台打印xml数据
+			//鍓嶇�鎺у埗鍙版墦鍗皒ml鏁版嵁
 			resp.getWriter().write(formatRSJsonData("1",vbillcode,e.getMessage()==null?e.toString():e.getMessage()).toString());
 			StringWriter stringWriter = new StringWriter();
 			e.printStackTrace(new PrintWriter(stringWriter));
-			//获取详细信息
+			//鑾峰彇璇︾粏淇℃伅
 			String msg=stringWriter.getBuffer().toString();
-			NcLog.info("销售合同变更:"+msg);
+			NcLog.info("閿€鍞�悎鍚屽彉鏇�:"+msg);
 		}
 		
 	}
 
 	public void collect(JSONObject json) throws Exception {
 		
-		//版本号
+		//鐗堟湰鍙�
 		int version;
 		
-		//合同条款
+		//鍚堝悓鏉℃�
 		CtSaleTermVO ctSaleTermVO = new CtSaleTermVO();
 		List<CtSaleTermVO> ctSaleTermListVO = new ArrayList<CtSaleTermVO>();
-		//合同费用
+		//鍚堝悓璐圭敤
 		CtSaleExpVO ctSaleExpVO = new CtSaleExpVO();
 		List<CtSaleExpVO> ctSaleExpListVO = new ArrayList<CtSaleExpVO>();
-		//合同大事记
+		//鍚堝悓澶т簨璁�
 		CtSaleMemoraVO ctSaleMemoraVO = new CtSaleMemoraVO();
 		List<CtSaleMemoraVO> ctSaleMemoraListVO = new ArrayList<CtSaleMemoraVO>();
-		//集团
+		//闆嗗洟
      	GroupVO groupVo = GetBaseDAOUtil.getGroup(json.getString("groupCode"));
      	NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
      	
-     	//线程设置集团主键
+     	//绾跨▼璁剧疆闆嗗洟涓婚敭
         InvocationInfoProxy.getInstance().setGroupId(groupVo.getPk_group());
-     	//组织
+     	//缁勭粐
         SalesOrgVO salesOrgVO = GetBaseDAOUtil.getSalesOrg(json.getString("pk_org"));
         String sm_userpk = GetBaseDAOUtil.getUser(json.getString("billmaker")).getCuserid();
-        //用户主键
+        //鐢ㄦ埛涓婚敭
         InvocationInfoProxy.getInstance().setUserId(sm_userpk);
 
 		IMDPersistenceQueryService service=NCLocator.getInstance().lookup(IMDPersistenceQueryService.class);
 		AggCtSaleVO aggCtSaleVO = (AggCtSaleVO) service.queryBillOfNCObjectByPKWithDR(AggCtSaleVO.class,GetBaseDAOUtil.GetVOID("ct_sale",json.getString("vbillcode")),true).getContainmentObject();
-		//主表
+		//涓昏〃
 		CtSaleVO ctSaleVO = aggCtSaleVO.getParentVO();
-		//计划生效日期
+		//璁″垝鐢熸晥鏃ユ湡
 		ctSaleVO.setValdate(new UFDate(json.getString("valdate")));
-		//计划终止日期
+		//璁″垝缁堟�鏃ユ湡
 		ctSaleVO.setInvallidate(new UFDate(json.getString("invallidate")));
 		if(!"".equals(json.getString("depid"))) {
 			DeptVO deptVO = GetBaseDAOUtil.getDept(json.getString("depid"),salesOrgVO.getPk_salesorg());
-			//部门最新版本
+			//閮ㄩ棬鏈€鏂扮増鏈�
 			ctSaleVO.setDepid(deptVO.getPk_dept());
-			//部门
+			//閮ㄩ棬
 			ctSaleVO.setDepid_v(deptVO.getPk_vid());
 		}
 		
-		//销售员
+		//閿€鍞�憳
 		ctSaleVO.setPersonnelid("".equals(json.getString("personnelid")) ? null :  GetBaseDAOUtil.getPsndoc(json.getString("personnelid"),salesOrgVO.getPk_salesorg()).getPk_psndoc());
-		//主表vo状态
-		aggCtSaleVO.getParent().setStatus(1);
+		//涓昏〃vo鐘舵€�
+		aggCtSaleVO.getParent().setStatus(VOStatus.UPDATED);
 		
 		if (aggCtSaleVO.getChildren(CtSaleChangeVO.class)==null) {
 			version = 0;
@@ -119,102 +125,139 @@ public class ModifyMaintianImpl extends BaseServlet implements IHttpServletAdapt
 			version = aggCtSaleVO.getChildren(CtSaleChangeVO.class).length;
 		}
 		 
-		//变更历史
+		//鍙樻洿鍘嗗彶
 		CtSaleChangeVO ctSaleChangeVO = new CtSaleChangeVO();
-		//主表主键
+		//涓昏〃涓婚敭
 		ctSaleChangeVO.setPk_ct_sale(aggCtSaleVO.getParent().getAttributeValue("pk_ct_sale").toString());
-		//集团主键
+		//闆嗗洟涓婚敭
 		ctSaleChangeVO.setPk_group(groupVo.getPk_group());
-		//组织最新版本
+		//缁勭粐鏈€鏂扮増鏈�
 		ctSaleChangeVO.setPk_org(salesOrgVO.getPk_org());
-		//组织
+		//缁勭粐
 		ctSaleChangeVO.setPk_org_v(salesOrgVO.getPk_vid());
-		//版本号数组+1
+		//鐗堟湰鍙锋暟缁�+1
 		ctSaleChangeVO.setVchangecode(new UFDouble(version+1));
-		//变更日期
+		//鍙樻洿鏃ユ湡
 		ctSaleChangeVO.setVchgdate(new UFDate(json.getString("vchgdate")));
-		//变更人
+		//鍙樻洿浜�
 		ctSaleChangeVO.setVchgpsn(sm_userpk);
-		//变更原因
+		//鍙樻洿鍘熷洜
 		ctSaleChangeVO.setVchgreason(json.getString("vchgreason"));
-		//vo状态
-		ctSaleChangeVO.setStatus(2);
+		//vo鐘舵€�
+		ctSaleChangeVO.setStatus(VOStatus.NEW);
 		
 		
 		JSONArray datas =  json.getJSONArray("ct_sale_b");
+		
+		for(CtSaleBVO bvo : aggCtSaleVO.getCtSaleBVO()) {
+			bvo.setStatus(3);
+		}
+		
+		ArrayList<CtSaleBVO> newAssetList = new ArrayList<CtSaleBVO>();
+		newAssetList.addAll(Arrays.asList(aggCtSaleVO.getCtSaleBVO()));
+		CtSaleBVO ctSaleBVOss = (CtSaleBVO) aggCtSaleVO.getChildren(CtSaleBVO.class)[0];
+		
 		for (int i = 0; i < datas.size(); i++) {
 			JSONObject JSONBody = (JSONObject) datas.get(i);
-			//合同基本子表
-			CtSaleBVO ctSaleBVO = (CtSaleBVO) aggCtSaleVO.getChildren(CtSaleBVO.class)[i];
-			//集团
+			//鍚堝悓鍩烘湰瀛愯〃
+			CtSaleBVO ctSaleBVO = new CtSaleBVO();
+			//涓昏〃涓婚敭
+			ctSaleBVO.setPk_ct_sale(aggCtSaleVO.getParent().getAttributeValue("pk_ct_sale").toString());
+			//璐㈠姟缁勭粐
+			ctSaleBVO.setPk_financeorg(GetBaseDAOUtil.GetFinanceorg("SYP"));
+			//璐㈠姟缁勭粐鏈€鏂�
+			ctSaleBVO.setPk_financeorg_v(GetBaseDAOUtil.GetFinanceorg_v("SYP"));
+			//闆嗗洟
 			ctSaleBVO.setPk_group(groupVo.getPk_group());
-			//组织最新版本
+			//缁勭粐鏈€鏂扮増鏈�
 			ctSaleBVO.setPk_org(salesOrgVO.getPk_org());
-			//组织
+			//缁勭粐
 			ctSaleBVO.setPk_org_v(salesOrgVO.getPk_vid());
-			//行号
+			//琛屽彿
 			ctSaleBVO.setCrowno(JSONBody.getString("crowno"));
 			MaterialVO materialVO = GetBaseDAOUtil.getMaterial(JSONBody.getString("pk_material"));
-			//物料
+			//鐗╂枡
 			ctSaleBVO.setPk_material(materialVO.getPk_material());
-			//物料最新版本
+			//鐗╂枡鏈€鏂扮増鏈�
 			ctSaleBVO.setPk_srcmaterial(materialVO.getPk_source());
-			//单位
+			//鍗曚綅
 			ctSaleBVO.setCastunitid("".equals(JSONBody.getString("castunitid")) ? null : GetBaseDAOUtil.getMeasdo(JSONBody.getString("castunitid")).getPk_measdoc());
-			//主单位
+			//涓诲崟浣�
 			ctSaleBVO.setCunitid("".equals(JSONBody.getString("cunitid")) ? null : GetBaseDAOUtil.getMeasdo(JSONBody.getString("cunitid")).getPk_measdoc());
-			//换算率
+			//鎹㈢畻鐜�
 			ctSaleBVO.setVchangerate("1");
-			//数量
+			//鏁伴噺
 			ctSaleBVO.setNastnum(new UFDouble(JSONBody.getString("nnum")));
-			//主数量
+			//涓绘暟閲�
 			ctSaleBVO.setNnum(new UFDouble(JSONBody.getString("nnum")));
-			//税率
+			//绋庣巼
 			ctSaleBVO.setNtaxrate(new UFDouble(JSONBody.getString("ntaxrate")));
-			//本位币含税单价
+			//鏈�綅甯佸惈绋庡崟浠�
 			ctSaleBVO.setNgtaxprice(new UFDouble(JSONBody.getString("norigtaxprice")));
-			//主含税单价
+			//涓诲惈绋庡崟浠�
 			ctSaleBVO.setNorigtaxprice(new UFDouble(JSONBody.getString("norigtaxprice")));
-			//报价含税单价
+//			//涓绘棤绋庡崟浠�
+			ctSaleBVO.setNorigprice((new UFDouble(JSONBody.getString("norigtaxprice"))));//
+//			//鎶ヤ环鏃犵◣鍗曚环
+			ctSaleBVO.setNqtorigprice((new UFDouble(JSONBody.getString("norigtaxprice"))));//
+			//鎶ヤ环鍚�◣鍗曚环
 			ctSaleBVO.setNqtorigtaxprice((new UFDouble(JSONBody.getString("norigtaxprice"))));
-			//报价本币含税单价
+			//鎶ヤ环鏈�竵鍚�◣鍗曚环
 			ctSaleBVO.setNqttaxprice((new UFDouble(JSONBody.getString("norigtaxprice"))));
-			//本币无税金额
+			//鏈�竵鏃犵◣閲戦�
 			ctSaleBVO.setNmny((new UFDouble(JSONBody.getString("norigmny"))));
-			//无税金额
+			//鏃犵◣閲戦�
 			ctSaleBVO.setNorigmny((new UFDouble(JSONBody.getString("norigmny"))));
-			//税额
+			//绋庨�
 			ctSaleBVO.setNtax((new UFDouble(JSONBody.getString("ntax"))));
-			//备注
+			//鎵g◣绫诲埆
+			ctSaleBVO.setFtaxtypeflag(1);//
+			//绋庣爜
+			ctSaleBVO.setCtaxcodeid(GetBaseDAOUtil.GetTaxcode(JSONBody.getString("ctaxcode")));//
+			//鍙戣揣鍦板尯/鍥藉�
+			ctSaleBVO.setCrececountryid(GetBaseDAOUtil.GetCountry(JSONBody.getString("crececountryid")));//
+			//鏀惰揣鍦板尯/鍥藉�
+			ctSaleBVO.setCsendcountryid(GetBaseDAOUtil.GetCountry(JSONBody.getString("csendcountryid")));//
+			//鎶ョ◣璐у湴鍖�/鍥藉�
+			ctSaleBVO.setCtaxcountryid(GetBaseDAOUtil.GetCountry(JSONBody.getString("ctaxcountryid")));//
+			//璐�攢绫诲瀷
+			ctSaleBVO.setFbuysellflag(3);//
+			//浠风◣鍚堣�
+			ctSaleBVO.setNorigtaxmny((new UFDouble(JSONBody.getString("norigmny"))));//
+			//澶囨敞
 			ctSaleBVO.setVmemo(JSONBody.getString("vmemo"));
-			//vo状态
-			ctSaleBVO.setStatus(1);
+			//VO鐘舵€�
+			ctSaleBVO.setStatus(VOStatus.NEW);
 			
-			aggCtSaleVO.getChildren(CtSaleBVO.class)[i] = ctSaleBVO;
+			newAssetList.add(ctSaleBVO);
 		}
 		
+		CtSaleBVO[] ctSaleBVOs = newAssetList.toArray(new CtSaleBVO[] {});
+		
+		aggCtSaleVO.setChildren(CtSaleBVO.class,ctSaleBVOs);
+		
 //		List<CtSaleBVO> ctSaleBListVOList = new ArrayList<CtSaleBVO>();
 //		for (int i = 0; i < aggCtSaleVO.getChildren(CtSaleBVO.class).length; i++) {
-//			//合同基本子表
+//			//鍚堝悓鍩烘湰瀛愯〃
 //			CtSaleBVO ctSaleBVO = (CtSaleBVO) aggCtSaleVO.getChildren(CtSaleBVO.class)[i];
-//			//集团
+//			//闆嗗洟
 //			ctSaleBVO.setPk_group(groupVo.getPk_group());
-//			//组织最新版本
+//			//缁勭粐鏈€鏂扮増鏈�
 //			ctSaleBVO.setPk_org(salesOrgVO.getPk_org());
-//			//组织
+//			//缁勭粐
 //			ctSaleBVO.setPk_org_v(salesOrgVO.getPk_vid());
-//			//行号
+//			//琛屽彿
 //			ctSaleBVO.setCrowno(crowno);
-//			//主数量
+//			//涓绘暟閲�
 //			ctSaleBVO.setNnum(new UFDouble(2));
-//			//vo状态
+//			//vo鐘舵€�
 //			ctSaleBVO.setStatus(1);
 //			
 //			aggCtSaleVO.getChildren(CtSaleBVO.class)[i] = ctSaleBVO;
 //		}
 		
 		
-		//创建数组长度+1加入变更记录
+		//鍒涘缓鏁扮粍闀垮害+1鍔犲叆鍙樻洿璁板綍
 		CtSaleChangeVO[] CtSaleChangearrVO = new CtSaleChangeVO[version+1];
 		for (int i = 0; i < version; i++) {
 			CtSaleChangearrVO[i] = (CtSaleChangeVO) aggCtSaleVO.getChildren(CtSaleChangeVO.class)[i];
@@ -227,9 +270,10 @@ public class ModifyMaintianImpl extends BaseServlet implements IHttpServletAdapt
 	
 	
 	public void processAction(AggCtSaleVO aggCtSaleVO) throws Exception{
-		WorkflownoteVO Workflownote = new WorkflownoteVO();
-		IPFBusiAction ipf = NCLocator.getInstance().lookup(IPFBusiAction.class);
-		//调用变更单据动作
-		ipf.processAction("MODIFY", "Z3", Workflownote, aggCtSaleVO, null, null);
+//		WorkflownoteVO Workflownote = new WorkflownoteVO();
+//		IPFBusiAction ipf = NCLocator.getInstance().lookup(IPFBusiAction.class);
+//		//璋冪敤鍙樻洿鍗曟嵁鍔ㄤ綔
+//		ipf.processAction("SAVEBASE", "Z3", Workflownote, aggCtSaleVO, null, null);
+		NCLocator.getInstance().lookup(IplatFormEntry.class).processAction("SAVEBASE",aggCtSaleVO.getParentVO().getVtrantypecode(),null,aggCtSaleVO,null,null);
 	}
 }

+ 40 - 0
ypff/ypff/src/private/nc/bs/yp/plugin/GetBaseDAOUtil.java

@@ -161,5 +161,45 @@ public class GetBaseDAOUtil {
 		}
 		return pk_ct_sale;
 	}
+	
+	//税码
+	public static String GetTaxcode(String str2) throws Exception {
+		String sql = "select pk_taxcode from bd_taxcode where code ='"+str2+"' and nvl(dr, 0)=0";
+		String pk_ct_sale = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
+		if(pk_ct_sale == null) {
+			throw new Exception("获取税码失败,未找到与参数" + str2 + "有关的数据!");
+		}
+		return pk_ct_sale;
+	}
+	
+	//地区/国家
+	public static String GetCountry(String str2) throws Exception {
+		String sql = "select pk_country from bd_countryzone where code ='"+str2+"' and nvl(dr, 0)=0";
+		String pk_ct_sale = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
+		if(pk_ct_sale == null) {
+			throw new Exception("获取地区/国家失败,未找到与参数" + str2 + "有关的数据!");
+		}
+		return pk_ct_sale;
+	}
+	
+	//财务组织最新
+	public static String GetFinanceorg_v(String str2) throws Exception {
+		String sql = "select pk_vid from org_financeorg_v where code ='"+str2+"' and nvl(dr, 0)=0";
+		String pk_ct_sale = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
+		if(pk_ct_sale == null) {
+			throw new Exception("获取财务组织失败,未找到与参数" + str2 + "有关的数据!");
+		}
+		return pk_ct_sale;
+	}
+	
+	//财务组织
+	public static String GetFinanceorg(String str2) throws Exception {
+		String sql = "select pk_financeorg from org_financeorg where code ='"+str2+"' and nvl(dr, 0)=0";
+		String pk_ct_sale = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
+		if(pk_ct_sale == null) {
+			throw new Exception("获取财务组织失败,未找到与参数" + str2 + "有关的数据!");
+		}
+		return pk_ct_sale;
+	}
 
 }