|
@@ -1,280 +1,280 @@
|
|
|
-package nc.bs.yp.impl;
|
|
|
-
|
|
|
-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;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
-import org.geotools.xml.xLink.XLinkSchema.From;
|
|
|
-
|
|
|
-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.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;
|
|
|
-import nc.vo.ct.saledaily.entity.AggCtSaleVO;
|
|
|
-import nc.vo.ct.saledaily.entity.CtSaleBVO;
|
|
|
-import nc.vo.ct.saledaily.entity.CtSaleChangeVO;
|
|
|
-import nc.vo.ct.saledaily.entity.CtSaleExpVO;
|
|
|
-import nc.vo.ct.saledaily.entity.CtSaleMemoraVO;
|
|
|
-import nc.vo.ct.saledaily.entity.CtSaleTermVO;
|
|
|
-import nc.vo.ct.saledaily.entity.CtSaleVO;
|
|
|
-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;
|
|
|
-import nc.vo.pub.lang.UFDouble;
|
|
|
-import nc.vo.pub.workflownote.WorkflownoteVO;
|
|
|
-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 {
|
|
|
- InvocationInfoProxy.getInstance().setUserDataSource("sypnctest");
|
|
|
- try {
|
|
|
- String createStr = buildJson(req, resp, this.getClass().getName());
|
|
|
- JSONObject json = JSONObject.fromObject(createStr);
|
|
|
- NcLog.info("销售合同变更JSON:"+json);
|
|
|
- vbillcode = json.getString("vbillcode");
|
|
|
- collect(json);
|
|
|
- resp.getWriter().write(formatRSJsonData("0",vbillcode,"").toString());
|
|
|
- } catch (Exception e) {
|
|
|
- //前端控制台打印xml数据
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- 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(VOStatus.UPDATED);
|
|
|
-
|
|
|
- if (aggCtSaleVO.getChildren(CtSaleChangeVO.class)==null) {
|
|
|
- version = 0;
|
|
|
- }else {
|
|
|
- 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
|
|
|
- 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(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 = 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"))));
|
|
|
- //扣税类别
|
|
|
- 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(VOStatus.NEW);
|
|
|
-
|
|
|
- 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状态
|
|
|
-// ctSaleBVO.setStatus(1);
|
|
|
-//
|
|
|
-// aggCtSaleVO.getChildren(CtSaleBVO.class)[i] = ctSaleBVO;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- //创建数组长度+1加入变更记录
|
|
|
- CtSaleChangeVO[] CtSaleChangearrVO = new CtSaleChangeVO[version+1];
|
|
|
- for (int i = 0; i < version; i++) {
|
|
|
- CtSaleChangearrVO[i] = (CtSaleChangeVO) aggCtSaleVO.getChildren(CtSaleChangeVO.class)[i];
|
|
|
- }
|
|
|
- CtSaleChangearrVO[CtSaleChangearrVO.length-1] = ctSaleChangeVO;
|
|
|
- aggCtSaleVO.setChildren(CtSaleChangeVO.class, CtSaleChangearrVO);
|
|
|
- processAction(aggCtSaleVO);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public void processAction(AggCtSaleVO aggCtSaleVO) throws Exception{
|
|
|
-// 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);
|
|
|
- }
|
|
|
-}
|
|
|
+package nc.bs.yp.impl;
|
|
|
+
|
|
|
+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;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.geotools.xml.xLink.XLinkSchema.From;
|
|
|
+
|
|
|
+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.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;
|
|
|
+import nc.vo.ct.saledaily.entity.AggCtSaleVO;
|
|
|
+import nc.vo.ct.saledaily.entity.CtSaleBVO;
|
|
|
+import nc.vo.ct.saledaily.entity.CtSaleChangeVO;
|
|
|
+import nc.vo.ct.saledaily.entity.CtSaleExpVO;
|
|
|
+import nc.vo.ct.saledaily.entity.CtSaleMemoraVO;
|
|
|
+import nc.vo.ct.saledaily.entity.CtSaleTermVO;
|
|
|
+import nc.vo.ct.saledaily.entity.CtSaleVO;
|
|
|
+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;
|
|
|
+import nc.vo.pub.lang.UFDouble;
|
|
|
+import nc.vo.pub.workflownote.WorkflownoteVO;
|
|
|
+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 {
|
|
|
+ InvocationInfoProxy.getInstance().setUserDataSource("sypnctest");
|
|
|
+ try {
|
|
|
+ String createStr = buildJson(req, resp, this.getClass().getName());
|
|
|
+ JSONObject json = JSONObject.fromObject(createStr);
|
|
|
+ NcLog.info("销售合同变更JSON:"+json);
|
|
|
+ vbillcode = json.getString("vbillcode");
|
|
|
+ collect(json);
|
|
|
+ resp.getWriter().write(formatRSJsonData("0",vbillcode,"").toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ //前端控制台打印xml数据
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(VOStatus.UPDATED);
|
|
|
+
|
|
|
+ if (aggCtSaleVO.getChildren(CtSaleChangeVO.class)==null) {
|
|
|
+ version = 0;
|
|
|
+ }else {
|
|
|
+ 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
|
|
|
+ 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(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 = 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"))));
|
|
|
+ //扣税类别
|
|
|
+ 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("ntaxmny"))));
|
|
|
+ //备注
|
|
|
+ ctSaleBVO.setVmemo(JSONBody.getString("vmemo"));
|
|
|
+ //VO状态
|
|
|
+ ctSaleBVO.setStatus(VOStatus.NEW);
|
|
|
+
|
|
|
+ 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状态
|
|
|
+// ctSaleBVO.setStatus(1);
|
|
|
+//
|
|
|
+// aggCtSaleVO.getChildren(CtSaleBVO.class)[i] = ctSaleBVO;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ //创建数组长度+1加入变更记录
|
|
|
+ CtSaleChangeVO[] CtSaleChangearrVO = new CtSaleChangeVO[version+1];
|
|
|
+ for (int i = 0; i < version; i++) {
|
|
|
+ CtSaleChangearrVO[i] = (CtSaleChangeVO) aggCtSaleVO.getChildren(CtSaleChangeVO.class)[i];
|
|
|
+ }
|
|
|
+ CtSaleChangearrVO[CtSaleChangearrVO.length-1] = ctSaleChangeVO;
|
|
|
+ aggCtSaleVO.setChildren(CtSaleChangeVO.class, CtSaleChangearrVO);
|
|
|
+ processAction(aggCtSaleVO);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void processAction(AggCtSaleVO aggCtSaleVO) throws Exception{
|
|
|
+// 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);
|
|
|
+ }
|
|
|
+}
|