|
@@ -2,13 +2,12 @@ package nc.pub.filesystem.newui;
|
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionEvent;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-
|
|
|
|
import javax.swing.AbstractAction;
|
|
import javax.swing.AbstractAction;
|
|
import javax.swing.Action;
|
|
import javax.swing.Action;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-
|
|
|
|
|
|
+import nc.itf.uap.IVOPersistence;
|
|
import nc.bs.framework.common.InvocationInfoProxy;
|
|
import nc.bs.framework.common.InvocationInfoProxy;
|
|
import nc.bs.framework.common.NCLocator;
|
|
import nc.bs.framework.common.NCLocator;
|
|
import nc.funcnode.ui.action.AbstractNCAction;
|
|
import nc.funcnode.ui.action.AbstractNCAction;
|
|
@@ -21,9 +20,16 @@ import nc.ui.ml.NCLangRes;
|
|
import nc.ui.pub.beans.MessageDialog;
|
|
import nc.ui.pub.beans.MessageDialog;
|
|
import nc.vo.bd.defdoc.DefdocVO;
|
|
import nc.vo.bd.defdoc.DefdocVO;
|
|
import nc.vo.pub.BusinessException;
|
|
import nc.vo.pub.BusinessException;
|
|
|
|
+import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 获取发票云发票
|
|
|
|
+ * @author y1456
|
|
|
|
+ *
|
|
|
|
+ */
|
|
public class ThSelectAction extends AbstractNCAction{
|
|
public class ThSelectAction extends AbstractNCAction{
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private IVOPersistence IVOPersistence = (IVOPersistence) NCLocator.getInstance().lookup(IVOPersistence.class);
|
|
private ThFileContentPanel parentpanel;
|
|
private ThFileContentPanel parentpanel;
|
|
private IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
|
|
private IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
|
|
|
|
|
|
@@ -37,10 +43,10 @@ public class ThSelectAction extends AbstractNCAction{
|
|
public void actionPerformed(ActionEvent actionevent) {
|
|
public void actionPerformed(ActionEvent actionevent) {
|
|
MessageDialog.showHintDlg(parentpanel, "提示","开始发票获取!");
|
|
MessageDialog.showHintDlg(parentpanel, "提示","开始发票获取!");
|
|
String vdef17 =(String) parentpanel.editor_.getBillCardPanel().getHeadItem("vdef17").getValueObject();//附件id
|
|
String vdef17 =(String) parentpanel.editor_.getBillCardPanel().getHeadItem("vdef17").getValueObject();//附件id
|
|
- String pk_org = (String) parentpanel.editor_.getBillCardPanel().getHeadItem("pk_org").getValueObject();
|
|
|
|
String pk_group = (String) parentpanel.editor_.getBillCardPanel().getHeadItem("pk_group").getValueObject();
|
|
String pk_group = (String) parentpanel.editor_.getBillCardPanel().getHeadItem("pk_group").getValueObject();
|
|
String billmaker = InvocationInfoProxy.getInstance().getUserId();
|
|
String billmaker = InvocationInfoProxy.getInstance().getUserId();
|
|
IThOcrService ocrservice=(IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
|
|
IThOcrService ocrservice=(IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
|
|
|
|
+
|
|
//获取token
|
|
//获取token
|
|
String token="";
|
|
String token="";
|
|
JSONObject json = null;
|
|
JSONObject json = null;
|
|
@@ -58,82 +64,63 @@ public class ThSelectAction extends AbstractNCAction{
|
|
MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
,"获取发票云发票:\n"+e.getMessage());
|
|
,"获取发票云发票:\n"+e.getMessage());
|
|
}
|
|
}
|
|
|
|
+ try {
|
|
|
|
+ //将该单据对应的老数据删除,赋值新数据
|
|
|
|
+ DeleteDOC(vdef17);
|
|
JSONObject data = json.getJSONObject("data");
|
|
JSONObject data = json.getJSONObject("data");
|
|
JSONArray infos = data.getJSONArray("infos");
|
|
JSONArray infos = data.getJSONArray("infos");
|
|
- for(int j = 0;j < infos.size();j++){
|
|
|
|
- JSONObject info = infos.getJSONObject(j);
|
|
|
|
- String memo = info.getString("number");//发票号
|
|
|
|
- String code = info.getString("number");//发票代码
|
|
|
|
- String fid = info.getString("fid");
|
|
|
|
- String ext = info.getString("ext");
|
|
|
|
- JSONObject extobj = JSONObject.parseObject(ext);
|
|
|
|
- String trate = extobj.getString("trate");//税率
|
|
|
|
- JSONObject modify_info = info.getJSONObject("modify_info");
|
|
|
|
- String name = modify_info.getString("fname");
|
|
|
|
- JSONObject comm_info = info.getJSONObject("comm_info");
|
|
|
|
- JSONObject pro = comm_info.getJSONObject("pro");
|
|
|
|
- String date = pro.getString("date");//发票日期
|
|
|
|
- String type = pro.getString("type");//发票类型
|
|
|
|
- String cname = pro.getString("cname");//发票类型名称
|
|
|
|
- JSONObject price = comm_info.getJSONObject("price");
|
|
|
|
- String amount = "";
|
|
|
|
- String total = "";
|
|
|
|
- String dtax = "";
|
|
|
|
- //专票带税额,不是专票无税金额=价税合计
|
|
|
|
- if(type.equals("1")||type.equals("28")||type.equals("32")){
|
|
|
|
- amount = price.getString("amount");//无税金额
|
|
|
|
- total = price.getString("total");//价税合计
|
|
|
|
- dtax = price.getString("dtax");//可抵扣税额
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- amount = price.getString("total");//无税金额
|
|
|
|
- total = amount;//价税合计
|
|
|
|
- dtax = "0";//可抵扣税额
|
|
|
|
- trate = "0";//非专票税率也为0
|
|
|
|
- }
|
|
|
|
- JSONObject buyer = comm_info.getJSONObject("buyer");
|
|
|
|
- String mnecode = buyer.getString("tcode");//购买方纳税人识别号
|
|
|
|
- String name2 = buyer.getString("company");//购买方公司名称
|
|
|
|
- JSONObject payer = comm_info.getJSONObject("payer");
|
|
|
|
- String name3 = payer.getString("tcode");//销售方纳税人识别号
|
|
|
|
- String name4 = payer.getString("company");//购买方公司名称
|
|
|
|
-
|
|
|
|
- IDefdocService idefservice = NCLocator.getInstance().lookup(IDefdocService.class);
|
|
|
|
-
|
|
|
|
- DefdocVO[] updatevos=QryDefdocvoInfo(code);
|
|
|
|
-
|
|
|
|
- if(updatevos.length>0){
|
|
|
|
- //自定义档案存在这个编码,走修改
|
|
|
|
- DefdocVO defvo =updatevos[0];
|
|
|
|
- //赋值
|
|
|
|
- defvo.setAttributeValue("name", memo);
|
|
|
|
- defvo.setAttributeValue("memo", name);
|
|
|
|
- defvo.setAttributeValue("mnecode", mnecode);
|
|
|
|
- defvo.setAttributeValue("name2", name2);
|
|
|
|
- defvo.setAttributeValue("name3", name3);
|
|
|
|
- defvo.setAttributeValue("name4", name4);
|
|
|
|
- defvo.setAttributeValue("name5", fid);
|
|
|
|
- defvo.setAttributeValue("name6", vdef17);
|
|
|
|
- defvo.setAttributeValue("shortname", amount);
|
|
|
|
- defvo.setAttributeValue("shortname2", total);
|
|
|
|
- defvo.setAttributeValue("shortname3", dtax);
|
|
|
|
- defvo.setAttributeValue("shortname4", date);
|
|
|
|
- defvo.setAttributeValue("shortname5", cname);
|
|
|
|
- defvo.setAttributeValue("shortname6", trate);
|
|
|
|
- defvo.setAttributeValue("enablestate", 2);
|
|
|
|
- try {
|
|
|
|
- idefservice.updateDefdocs(pk_group,updatevos);
|
|
|
|
- } catch (BusinessException e1) {
|
|
|
|
- MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
|
|
- ,"修改自定义档案数据:\n"+e1.getMessage());
|
|
|
|
- return;
|
|
|
|
|
|
+ //票夹不存在发票
|
|
|
|
+ if(infos != null) {
|
|
|
|
+ for(int j = 0;j < infos.size();j++){
|
|
|
|
+ JSONObject info = infos.getJSONObject(j);
|
|
|
|
+ String memo = info.getString("number");//发票号
|
|
|
|
+ String code = info.getString("number");//发票代码
|
|
|
|
+ String fid = info.getString("fid");
|
|
|
|
+ //特殊发票发票号和发票代码不存在
|
|
|
|
+ if(code == null || "".equals(code)) {
|
|
|
|
+ memo = "特殊发票"+fid;
|
|
|
|
+ code = fid;
|
|
|
|
+ }
|
|
|
|
+ String ext = info.getString("ext");
|
|
|
|
+ JSONObject extobj = JSONObject.parseObject(ext);
|
|
|
|
+ String trate = extobj.getString("trate");//税率
|
|
|
|
+ JSONObject modify_info = info.getJSONObject("modify_info");
|
|
|
|
+ String name = modify_info.getString("fname");
|
|
|
|
+ JSONObject comm_info = info.getJSONObject("comm_info");
|
|
|
|
+ JSONObject pro = comm_info.getJSONObject("pro");
|
|
|
|
+ String date = pro.getString("date");//发票日期
|
|
|
|
+ String type = pro.getString("type");//发票类型
|
|
|
|
+ String cname = pro.getString("cname");//发票类型名称
|
|
|
|
+ JSONObject price = comm_info.getJSONObject("price");
|
|
|
|
+ String amount = "";
|
|
|
|
+ String total = "";
|
|
|
|
+ String dtax = "";
|
|
|
|
+ //专票带税额,不是专票无税金额=价税合计
|
|
|
|
+ if(type.equals("1")||type.equals("28")||type.equals("32")){
|
|
|
|
+ amount = price.getString("amount");//无税金额
|
|
|
|
+ total = price.getString("total");//价税合计
|
|
|
|
+ dtax = price.getString("dtax");//可抵扣税额
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ else{
|
|
|
|
+ amount = price.getString("total");//无税金额
|
|
|
|
+ total = amount;//价税合计
|
|
|
|
+ dtax = "0";//可抵扣税额
|
|
|
|
+ trate = "0";//非专票税率也为0
|
|
|
|
+ }
|
|
|
|
+ JSONObject buyer = comm_info.getJSONObject("buyer");
|
|
|
|
+ String mnecode = buyer.getString("tcode");//购买方纳税人识别号
|
|
|
|
+ String name2 = buyer.getString("company");//购买方公司名称
|
|
|
|
+ JSONObject payer = comm_info.getJSONObject("payer");
|
|
|
|
+ String name3 = payer.getString("tcode");//销售方纳税人识别号
|
|
|
|
+ String name4 = payer.getString("company");//购买方公司名称
|
|
|
|
+
|
|
|
|
+ IDefdocService idefservice = NCLocator.getInstance().lookup(IDefdocService.class);
|
|
DefdocVO[] vos = new DefdocVO[1];
|
|
DefdocVO[] vos = new DefdocVO[1];
|
|
DefdocVO defvo = new DefdocVO();
|
|
DefdocVO defvo = new DefdocVO();
|
|
//赋值
|
|
//赋值
|
|
- defvo.setAttributeValue("code", code);
|
|
|
|
- defvo.setAttributeValue("name", memo);
|
|
|
|
|
|
+ //为避免自定义档案code,name重复,加上后缀作为区别,仅限发票云获取发票使用
|
|
|
|
+ defvo.setAttributeValue("code", code+"-"+System.currentTimeMillis());
|
|
|
|
+ defvo.setAttributeValue("name", memo+"-"+System.currentTimeMillis());
|
|
defvo.setAttributeValue("memo", name );
|
|
defvo.setAttributeValue("memo", name );
|
|
defvo.setAttributeValue("mnecode", mnecode);
|
|
defvo.setAttributeValue("mnecode", mnecode);
|
|
defvo.setAttributeValue("name2", name2);
|
|
defvo.setAttributeValue("name2", name2);
|
|
@@ -152,56 +139,55 @@ public class ThSelectAction extends AbstractNCAction{
|
|
defvo.setAttributeValue("shortname4", date);
|
|
defvo.setAttributeValue("shortname4", date);
|
|
defvo.setAttributeValue("shortname5", cname);
|
|
defvo.setAttributeValue("shortname5", cname);
|
|
defvo.setAttributeValue("shortname6", trate);
|
|
defvo.setAttributeValue("shortname6", trate);
|
|
|
|
+ defvo.setAttributeValue("enablestate", 2);
|
|
|
|
+ defvo.setAttributeValue("innercode", "1");
|
|
vos[0] = defvo;
|
|
vos[0] = defvo;
|
|
- try {
|
|
|
|
- idefservice.insertDefdocs(pk_group, vos);
|
|
|
|
- } catch (BusinessException e) {
|
|
|
|
- // TODO 自动生成的 catch 块
|
|
|
|
- MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
|
|
- ,"保存自定义档案数据:\n"+e.getMessage());
|
|
|
|
- return;
|
|
|
|
|
|
+ idefservice.insertDefdocs(pk_group, vos);
|
|
}
|
|
}
|
|
-
|
|
|
|
- MessageDialog.showHintDlg(parentpanel, "提示","获取成功!");
|
|
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // TODO 自动生成的 catch 块
|
|
|
|
+ MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
|
|
+ ,"保存自定义档案数据:\n"+e.getMessage());
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+ MessageDialog.showHintDlg(parentpanel, "提示","获取成功!");
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
- private DefdocVO[] QryDefdocvoInfo(String code){
|
|
|
|
- String sql = "select * from bd_defdoc where nvl(dr, 0) = 0 and pk_defdoclist="
|
|
|
|
- + "(select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0) and code='" + code + "' ";
|
|
|
|
- ArrayList<Object> arrayvos=null;
|
|
|
|
- try {
|
|
|
|
- arrayvos=(ArrayList<Object>) iuap.executeQuery(sql, new BeanListProcessor(DefdocVO.class));
|
|
|
|
- } catch (BusinessException e) {
|
|
|
|
- // TODO 自动生成的 catch 块
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ private DefdocVO[] QryDefdocvoInfo(String code) throws Exception{
|
|
|
|
+ String sql = "select * from bd_defdoc where nvl(dr, 0) = 0 and pk_defdoclist="
|
|
|
|
+ + "(select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0) and code='" + code + "' ";
|
|
|
|
+ ArrayList<Object> arrayvos=null;
|
|
|
|
+ arrayvos=(ArrayList<Object>) iuap.executeQuery(sql, new BeanListProcessor(DefdocVO.class));
|
|
|
|
|
|
- if (arrayvos==null||arrayvos.size()==0) {
|
|
|
|
- return new DefdocVO[0];
|
|
|
|
- }else {
|
|
|
|
- return arrayvos.toArray(new DefdocVO[0]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ if (arrayvos==null||arrayvos.size()==0) {
|
|
|
|
+ return new DefdocVO[0];
|
|
|
|
+ }else {
|
|
|
|
+ return arrayvos.toArray(new DefdocVO[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//查询自定义档案的pk
|
|
//查询自定义档案的pk
|
|
- private String QryOCRPk(){
|
|
|
|
|
|
+ private String QryOCRPk() throws Exception{
|
|
String sql = "select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0";
|
|
String sql = "select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0";
|
|
Object object = null;
|
|
Object object = null;
|
|
- try {
|
|
|
|
object = iuap.executeQuery(sql, new ColumnProcessor());
|
|
object = iuap.executeQuery(sql, new ColumnProcessor());
|
|
- } catch (BusinessException e) {
|
|
|
|
- // TODO 自动生成的 catch 块
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
if (object==null) {
|
|
if (object==null) {
|
|
return null;
|
|
return null;
|
|
}else {
|
|
}else {
|
|
return object.toString();
|
|
return object.toString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //将老数据删除
|
|
|
|
+ private void DeleteDOC(String vdef17) throws Exception {
|
|
|
|
+ SqlBuilder sql = new SqlBuilder();
|
|
|
|
+ sql.append(" name6 = '"+vdef17+"'");
|
|
|
|
+ sql.append(" AND innercode = '1'");
|
|
|
|
+ sql.append(" AND pk_defdoclist = ( SELECT pk_defdoclist FROM bd_defdoclist WHERE code = 'OCRTHNC' AND nvl( dr, 0 ) = 0 )");
|
|
|
|
+ IVOPersistence.deleteByClause(DefdocVO.class, sql.toString());
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|