|
@@ -3,6 +3,8 @@ package nc.impl.th;
|
|
|
import java.io.IOException;
|
|
|
import java.io.PrintWriter;
|
|
|
import java.io.StringWriter;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -13,9 +15,12 @@ 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.pu.m25.IInvoiceApprove;
|
|
|
import nc.itf.pu.m25.IInvoiceMaintain;
|
|
|
import nc.itf.uap.IUAPQueryBS;
|
|
|
+import nc.itf.uap.pf.IPFBusiAction;
|
|
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
|
|
+import nc.log.NcLog;
|
|
|
import nc.vo.pu.m25.entity.InvoiceHeaderVO;
|
|
|
import nc.vo.pu.m25.entity.InvoiceItemVO;
|
|
|
import nc.vo.pu.m25.entity.InvoiceVO;
|
|
@@ -23,6 +28,7 @@ import nc.vo.pub.BusinessException;
|
|
|
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;
|
|
|
|
|
@@ -32,10 +38,11 @@ public class InvoiceAddImpl extends BaseServlet implements IHttpServletAdaptor {
|
|
|
@Override
|
|
|
public void doAction(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
|
|
|
try {
|
|
|
- InvocationInfoProxy.getInstance().setUserDataSource("NC20230301");
|
|
|
+ InvocationInfoProxy.getInstance().setUserDataSource("NC6337");
|
|
|
NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
|
|
|
String createStr = buildJson(req, resp, this.getClass().getName());
|
|
|
JSONObject json = JSONObject.fromObject(createStr);
|
|
|
+ NcLog.info(json.toString());
|
|
|
String vbillcode = "";
|
|
|
vbillcode = json.getString("vbillcode");
|
|
|
checkJson(json);//非空判断
|
|
@@ -64,14 +71,14 @@ public class InvoiceAddImpl extends BaseServlet implements IHttpServletAdaptor {
|
|
|
parentVO.setDbilldate(new UFDate(json.getString("dbilldate")));//发票日期
|
|
|
parentVO.setPk_supplier(SqlexecuteQuery("pk_supplier", "bd_supplier", "code", json.getString("pk_supplier")));//供应商
|
|
|
parentVO.setPk_bankaccbas(SqlexecuteQuery("pk_bankaccsub", "bd_bankaccsub", "accnum", json.getString("pk_bankaccbas")));//银行账户
|
|
|
- parentVO.setPk_bizpsn(SqlexecuteQuery("pk_psndoc", "bd_psndoc", "pk_psndoc", json.getString("pk_bizpsn")));//采购员
|
|
|
+ parentVO.setPk_bizpsn(SqlexecuteQuery("pk_psndoc", "sm_user", "cuserid", json.getString("pk_bizpsn")));//采购员
|
|
|
parentVO.setPk_dept_v(SqlexecuteQuery("pk_vid", "org_dept_v", "code", json.getString("pk_dept_v")));//采购部门
|
|
|
parentVO.setPk_busitype(SqlexecuteQuery("pk_busitype", "bd_busitype", "busicode", json.getString("pk_busitype")));//业务流程
|
|
|
parentVO.setPk_stockorg_v(SqlexecuteQuery("pk_vid", "org_stockorg_v", "code", json.getString("pk_stockorg_v")));//库存组织
|
|
|
parentVO.setPk_paytosupplier(SqlexecuteQuery("pk_supplier", "bd_supplier", "code", json.getString("pk_paytosupplier")));//付款单位
|
|
|
parentVO.setNtotalastnum(new UFDouble(json.getString("ntotalastnum")));//总数量
|
|
|
parentVO.setNtotalorigmny(new UFDouble(json.getString("ntotalorigmny")));//价税合计
|
|
|
- parentVO.setFtaxtypeflagh(0);//整单扣税类别(1=应税外加,0=应税内含)
|
|
|
+ parentVO.setFtaxtypeflagh(Integer.parseInt(json.getString("ftaxtypeflagh")));//整单扣税类别(1=应税外加,0=应税内含)
|
|
|
parentVO.setVmemo(json.getString("vmemo"));//备注
|
|
|
parentVO.setDarrivedate(new UFDate(json.getString("darrivedate")));//票到日期
|
|
|
parentVO.setCcurrencyid(SqlexecuteQuery("pk_currtype", "bd_currtype", "code", json.getString("ccurrencyid")));//本币币种
|
|
@@ -115,7 +122,7 @@ public class InvoiceAddImpl extends BaseServlet implements IHttpServletAdaptor {
|
|
|
invoiceItemVO.setPk_apfinanceorg_v(SqlexecuteQuery("pk_vid", "org_financeorg_v", "code", bodyObject.getString("pk_apfinanceorg_v")));//应付财务组织
|
|
|
invoiceItemVO.setVmemob(bodyObject.getString("vmemob"));//备注
|
|
|
invoiceItemVO.setFrowtype(0);//行类型(0=货物行,1=折扣行,2=劳务行,3=零数量行)
|
|
|
- invoiceItemVO.setFtaxtypeflag(1);//扣税类别(1=应税外加,0=应税内含)
|
|
|
+ invoiceItemVO.setFtaxtypeflag(Integer.parseInt(json.getString("ftaxtypeflagh")));//扣税类别(1=应税外加,0=应税内含)
|
|
|
invoiceItemVO.setVchangerate("1/1");//换算率
|
|
|
invoiceItemVO.setVbdef16(bodyObject.getString("vbdef16"));
|
|
|
|
|
@@ -126,10 +133,18 @@ public class InvoiceAddImpl extends BaseServlet implements IHttpServletAdaptor {
|
|
|
i++;
|
|
|
}
|
|
|
aggvo.setChildrenVO(childrenVO);
|
|
|
-
|
|
|
- IInvoiceMaintain iInvoiceMaintain=(IInvoiceMaintain)NCLocator.getInstance().lookup(IInvoiceMaintain.class);
|
|
|
- iInvoiceMaintain.insert(aggvos, null);
|
|
|
-
|
|
|
+ // 线程设置业务日期
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Object dateTimeString = parentVO.getDbilldate();
|
|
|
+ if(dateTimeString != null) {
|
|
|
+ Date date = format.parse(dateTimeString.toString());
|
|
|
+ long timestamp = date.getTime();
|
|
|
+ InvocationInfoProxy.getInstance().setBizDateTime(timestamp);
|
|
|
+ }
|
|
|
+ IInvoiceMaintain iInvoiceMaintain = (IInvoiceMaintain)NCLocator.getInstance().lookup(IInvoiceMaintain.class);
|
|
|
+ InvoiceVO[] invoiceVO = iInvoiceMaintain.insert(aggvos, null);
|
|
|
+ IPFBusiAction service = NCLocator.getInstance().lookup(IPFBusiAction.class);
|
|
|
+ service.processAction("APPROVE","21", null, invoiceVO[0], null, null);
|
|
|
out.print(formatRSJsonData("成功","",vbillcode));
|
|
|
} catch (Exception e) {
|
|
|
resp.getWriter().write(formatRSJsonData("失败", e.getMessage().toString(), "").toString());
|
|
@@ -137,6 +152,7 @@ public class InvoiceAddImpl extends BaseServlet implements IHttpServletAdaptor {
|
|
|
e.printStackTrace(new PrintWriter(stringWriter));
|
|
|
// 获取详细信息
|
|
|
String msg = stringWriter.getBuffer().toString();
|
|
|
+ NcLog.info(msg);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -206,32 +222,22 @@ public class InvoiceAddImpl extends BaseServlet implements IHttpServletAdaptor {
|
|
|
private String SqlexecuteQuery(String out,String table,String key,String value) throws Exception {
|
|
|
String sql = "select "+out+" from "+table+" where "+key+" = '"+value+"' and nvl(dr,0)=0";
|
|
|
Object object;
|
|
|
- try {
|
|
|
object = iuap.executeQuery(sql, new ColumnProcessor());
|
|
|
if (object==null) {
|
|
|
throw new Exception("未查询到数据!请检查编码"+value+"是否正确!");
|
|
|
}
|
|
|
return object.toString();
|
|
|
- } catch (BusinessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return e.getMessage();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
|
private String SqlexecuteQuery2(String out,String table,String key,String value) throws Exception {
|
|
|
String sql = "select "+out+" from "+table+" where "+key+" = '"+value+"' and nvl(dr,0)=0 and enablestate = '2'";
|
|
|
Object object;
|
|
|
- try {
|
|
|
object = iuap.executeQuery(sql, new ColumnProcessor());
|
|
|
if (object==null) {
|
|
|
throw new Exception("未查询到数据!请检查编码"+value+"是否正确!");
|
|
|
}
|
|
|
return object.toString();
|
|
|
- } catch (BusinessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return e.getMessage();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
}
|