diff --git a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirm.jsp b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirm.jsp index c77c6c6dd..76734becd 100644 --- a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirm.jsp +++ b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirm.jsp @@ -49,8 +49,10 @@ +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmInfo.jsp b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmInfo.jsp new file mode 100644 index 000000000..2e4bb5f0a --- /dev/null +++ b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmInfo.jsp @@ -0,0 +1,30 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><% + /* + Author: undefined 2018-08-06 + Content: 示例详情页面 + History Log: + */ + String sPrevUrl = CurPage.getParameter("PrevUrl"); + if(sPrevUrl == null) sPrevUrl = ""; + + String sTempletNo = "InvoiceConfirmInfo";//--模板号-- + ASObjectModel doTemp = new ASObjectModel(sTempletNo); + //doTemp.setColTips("", "测试"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request); + dwTemp.Style = "2";//freeform + //dwTemp.ReadOnly = "-2";//只读模式 + dwTemp.genHTMLObjectWindow(CurPage.getParameter("ID")); + + String sButtons[][] = { + {"true","All","Button","保存","保存所有修改","as_save(0)","","","",""}, + {String.valueOf(!com.amarsoft.are.lang.StringX.isSpace(sPrevUrl)),"All","Button","返回","返回列表","returnList()","","","",""} + }; + sButtonPosition = "south"; +%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp new file mode 100644 index 000000000..62730665b --- /dev/null +++ b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp @@ -0,0 +1,68 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2018-08-06 + Content: + History Log: + */ + ASObjectModel doTemp = new ASObjectModel("InvoiceConfirmList"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(10); + dwTemp.genHTMLObjectWindow(""); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, + {"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, + {"true","","Button","查询","查询","selectInvoice()","","","","",""} + //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Core/InvoiceManager/TablesXML/ConfirmInvoice/invoice_confirm.xml b/WebContent/Tenwa/Core/InvoiceManager/TablesXML/ConfirmInvoice/invoice_confirm.xml index 1882cded3..f87ec60f4 100644 --- a/WebContent/Tenwa/Core/InvoiceManager/TablesXML/ConfirmInvoice/invoice_confirm.xml +++ b/WebContent/Tenwa/Core/InvoiceManager/TablesXML/ConfirmInvoice/invoice_confirm.xml @@ -9,8 +9,8 @@ diff --git a/WebContent/WEB-INF/etc/a3web.xml b/WebContent/WEB-INF/etc/a3web.xml index ae0405103..7a38cbc4c 100644 --- a/WebContent/WEB-INF/etc/a3web.xml +++ b/WebContent/WEB-INF/etc/a3web.xml @@ -79,8 +79,8 @@ BusinessDueBill - http://localhost:8080/report - http://localhost:8080/report + http://47.93.34.101/report + http://47.93.34.101/report true @@ -117,4 +117,9 @@ http://172.16.20.242:65188 30000 + + http://fpfw2.aiee.fun:8899/fpfw2/api/kpbusiness + 77c61651-f40e-4536-9991-bba64bd3521e + 3060109010000000000 + E:\\pdf \ No newline at end of file diff --git a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml index 141efbf9e..2c370a692 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml @@ -3362,15 +3362,17 @@ - - + + - - + + - + + + diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 88795bbd0..3f967d082 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -178,6 +178,10 @@ FileTemplateViewServlet com.amarsoft.filetemplate.servlet.FileTemplateViewServlet + + InvoiceDownloadServlet + com.tenwa.app.invoice.servlet.InvoiceDownloadServlet + DocDownloadServlet com.tenwa.doc.servlet.DocDownloadServlet @@ -262,6 +266,10 @@ FileTemplateViewServlet /servlet/view/fileTemplateView + + InvoiceDownloadServlet + /servlet/view/invoiceDownloadServlet + DocDownloadServlet /servlet/view/docDownloadServlet diff --git a/src_invoice/com/tenwa/app/invoice/action/InvoiceRequest.java b/src_invoice/com/tenwa/app/invoice/action/InvoiceRequest.java new file mode 100644 index 000000000..43a822254 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/action/InvoiceRequest.java @@ -0,0 +1,183 @@ +package com.tenwa.app.invoice.action; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import com.alibaba.fastjson.JSONObject; +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.JBOException; +import com.amarsoft.awe.Configure; +import com.tenwa.app.invoice.data.ResponseEnum; +import com.tenwa.app.invoice.pojo.ResultPojo; +import com.tenwa.app.invoice.request.InvoiceRequestBase; +import com.tenwa.app.invoice.request.InvoiceRequestBody; +import com.tenwa.app.invoice.request.InvoiceRequestFyxm; +import com.tenwa.app.invoice.request.InvoiceRequestGroup; +import com.tenwa.app.invoice.request.InvoiceRequestHead; +import com.tenwa.app.invoice.request.InvoiceRequestInput; +import com.tenwa.app.invoice.utils.JaxbUtil; +import com.tenwa.app.invoice.utils.PasswordGenerateUtil; +import com.tenwa.app.invoice.utils.ResultUtil; + +public class InvoiceRequest { + + private String url ="" ; + private String appId="" ; + private String fplxdm="026"; + + public InvoiceRequest(String fplxdm) { + this.fplxdm = fplxdm; + } + public InvoiceRequest() { + } + public ResultPojo send(BizObject confirmBizObject,List confirmDetailList) throws JBOException{ + Configure config = Configure.getInstance(); + try { + url = config.getConfigure("INVOICE_URL") ; + appId = config.getConfigure("INVOICE_APPID") ; + } catch (Exception e) { + e.printStackTrace(); + return ResultUtil.error("读取a3web的开票接口配置文件失败"); + } + + InvoiceRequestBase base = new InvoiceRequestBase(); + + base.setComment("发票开具"); + base.setId("FPKJ"); + base.setVersion("2.0"); + + InvoiceRequestHead head = new InvoiceRequestHead(); + head.setAppid(this.appId); + head.setSid(confirmBizObject.getAttribute("sid").toString()); + base.setHead(head); + + InvoiceRequestBody body = new InvoiceRequestBody(); + + InvoiceRequestInput input = new InvoiceRequestInput(); + input.setFplxdm(this.fplxdm); + input.setKplx("0"); + input.setTspz("00"); + input.setXhdwdzdh(confirmBizObject.getAttribute("xhdwdzdh").toString()); + input.setXhdwyhzh(confirmBizObject.getAttribute("Xhdwyhzh").toString()); + input.setGhdwsbh(confirmBizObject.getAttribute("ghdwsbh").toString()); + input.setGhdwmc(confirmBizObject.getAttribute("ghdwmc").toString()); + input.setGhdwdzdh(confirmBizObject.getAttribute("ghdwdzdh").toString()); + input.setGhdwyhzh(confirmBizObject.getAttribute("ghdwyhzh").toString()); + input.setHsslbs("0"); + input.setZhsl(confirmBizObject.getAttribute("zhsl").toString()); + input.setHjje(confirmBizObject.getAttribute("hjje").toString()); + input.setHjse(confirmBizObject.getAttribute("hjse").toString()); + input.setJshj(confirmBizObject.getAttribute("jshj").toString()); + input.setBz(""); + input.setSkr(""); + input.setFhr(""); + input.setKpr(confirmBizObject.getAttribute("kpr").toString()); + input.setZyspmc(confirmBizObject.getAttribute("zyspmc").toString()); + input.setSpsm(""); + input.setSsyf(""); + input.setTzdbh(""); + input.setYfpdm(""); + input.setYfphm(""); + input.setGMF_DZYX(""); + input.setGMF_SJHM(confirmBizObject.getAttribute("GMF_SJHM").toString()); + input.setGMF_OPENID(""); + + InvoiceRequestFyxm fyxm = new InvoiceRequestFyxm(); + + List groupList = new ArrayList(); + int index=1; + for(BizObject confirmDetailBizObject :confirmDetailList){ + InvoiceRequestGroup group = new InvoiceRequestGroup(); + group.setXh(String.valueOf(index)); + group.setFphxz(confirmDetailBizObject.getAttribute("fphxz").toString()); + group.setSpmc(confirmDetailBizObject.getAttribute("spmc").toString()); + group.setSpsm(confirmDetailBizObject.getAttribute("spsm").toString()); + group.setGgxh(confirmDetailBizObject.getAttribute("ggxh").toString()); + group.setDw(confirmDetailBizObject.getAttribute("dw").toString()); + group.setSpsl(confirmDetailBizObject.getAttribute("spsl").toString()); + group.setDj(confirmDetailBizObject.getAttribute("dj").toString()); + group.setJe(confirmDetailBizObject.getAttribute("je").toString()); + group.setSl(confirmDetailBizObject.getAttribute("sl").toString()); + group.setSe(confirmDetailBizObject.getAttribute("Se").toString()); + group.setHsbz(confirmDetailBizObject.getAttribute("hsbz").toString()); + group.setSpbm(confirmDetailBizObject.getAttribute("spbm").toString()); + group.setZxbm(confirmDetailBizObject.getAttribute("zxbm").toString()); + group.setYhzcbs(confirmDetailBizObject.getAttribute("yhzcbs").toString()); + group.setSlbs(confirmDetailBizObject.getAttribute("slbs").toString()); + group.setZzstsgl(confirmDetailBizObject.getAttribute("zzstsgl").toString()); + + groupList.add(group); + ++index; + } + + + fyxm.setGroupList(groupList); + fyxm.setCount(String.valueOf( groupList.size() )); + input.setFyxm(fyxm); + + + body.setYylxdm("1"); + body.setInput(input); + base.setBody(body); + + String xml = JaxbUtil.convertToXml(base); + System.out.println(xml); + ResultPojo result= doPost(xml); + + return result; + //return ResultUtil.error("ERROR[01]"); + } + + public ResultPojo findResult(String sid) throws JBOException{ + Configure config = Configure.getInstance(); + try { + url = config.getConfigure("INVOICE_URL") ; + appId = config.getConfigure("INVOICE_APPID") ; + } catch (Exception e) { + e.printStackTrace(); + return ResultUtil.error("读取a3web的开票接口配置文件失败"); + } + + InvoiceRequestBase invoiceRequestBase = new InvoiceRequestBase(); + InvoiceRequestHead invoiceRequestHead = new InvoiceRequestHead(); + invoiceRequestHead.setAppid(this.appId); + invoiceRequestHead.setSid(sid); + + invoiceRequestBase.setHead(invoiceRequestHead); + invoiceRequestBase.setComment("查询开票结果"); + invoiceRequestBase.setId("CXKPJG"); + invoiceRequestBase.setVersion("1.0"); + + String xml = JaxbUtil.convertToXml(invoiceRequestBase); + ResultPojo result = doPost(xml); + return result; + } + public ResultPojo doPost(String xml){ + HttpHeaders httpHeaders = new HttpHeaders(); + MultiValueMap param = new LinkedMultiValueMap<>(); + httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + param.add("bw",xml) ; + RestTemplate restTemplate = new RestTemplate(); + HttpEntity> entity = new HttpEntity<>(param, httpHeaders); + ResponseEntity response = null ; + try { + response = restTemplate.exchange(this.url, HttpMethod.POST, entity, String.class); + }catch (Exception e){ + return ResultUtil.error(ResponseEnum.NETWORK.getMsg()); + } + System.out.println(response.getBody()); + InvoiceRequestBase r = JaxbUtil.converyToJavaBean(response.getBody(), InvoiceRequestBase.class); + return ResultUtil.success(r); + } + + +} diff --git a/src_invoice/com/tenwa/app/invoice/data/ResponseEnum.java b/src_invoice/com/tenwa/app/invoice/data/ResponseEnum.java new file mode 100644 index 000000000..c18726449 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/data/ResponseEnum.java @@ -0,0 +1,38 @@ +package com.tenwa.app.invoice.data; + +public enum ResponseEnum { + + SUCCESS(0,"成功"), + NETWORK(-3,"网络出错"), + ERROR(-1,"失败"); + + + + private Integer code ; + private String msg; + + + ResponseEnum() { + } + + ResponseEnum(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/exception/InvoiceException.java b/src_invoice/com/tenwa/app/invoice/exception/InvoiceException.java new file mode 100644 index 000000000..7585559fc --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/exception/InvoiceException.java @@ -0,0 +1,40 @@ +package com.tenwa.app.invoice.exception; + +public class InvoiceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Integer errorCode ; + private String errorMsg ; + + public Integer getErrorCode() { + return errorCode; + } + + public void setErrorCode(Integer errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public InvoiceException(String errorMsg) { + super(errorMsg); + this.errorMsg = errorMsg ; + } + public InvoiceException(Integer errorCode , String errorMsg) { + super(errorMsg); + this.errorCode = errorCode ; + this.errorMsg = errorMsg ; + } + + + +} diff --git a/src_invoice/com/tenwa/app/invoice/pojo/ResultPojo.java b/src_invoice/com/tenwa/app/invoice/pojo/ResultPojo.java new file mode 100644 index 000000000..78d08dd55 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/pojo/ResultPojo.java @@ -0,0 +1,31 @@ +package com.tenwa.app.invoice.pojo; + +public class ResultPojo { + private Integer code; + private String msg ; + private Object data; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestBase.java b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestBase.java new file mode 100644 index 000000000..4a41d60c7 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestBase.java @@ -0,0 +1,61 @@ +package com.tenwa.app.invoice.request; + + +import javax.xml.bind.annotation.*; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "business") +public class InvoiceRequestBase { + + @XmlAttribute + private String comment ; + @XmlAttribute + private String id ; + @XmlAttribute + private String version ; + + @XmlElement + private InvoiceRequestHead head ; + @XmlElement + private InvoiceRequestBody body ; + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public InvoiceRequestHead getHead() { + return head; + } + + public void setHead(InvoiceRequestHead head) { + this.head = head; + } + + public InvoiceRequestBody getBody() { + return body; + } + + public void setBody(InvoiceRequestBody body) { + this.body = body; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestBody.java b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestBody.java new file mode 100644 index 000000000..c317dd77a --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestBody.java @@ -0,0 +1,134 @@ +package com.tenwa.app.invoice.request; + + +import javax.xml.bind.annotation.*; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "body") +public class InvoiceRequestBody { + @XmlElement + private String returncode ; + @XmlElement + private String returnmsg ; + @XmlElement + private String fplxdm ; + @XmlElement + private String fpdm ; + @XmlElement + private String fphm ; + @XmlElement + private String kprq ; + @XmlElement + private String hjje ; + @XmlElement + private String skm ; + @XmlElement + private String jym ; + @XmlElement + private String pdfurl ; + + + + @XmlAttribute + private String yylxdm ; + + @XmlElement + private InvoiceRequestInput input ; + + public String getYylxdm() { + return yylxdm; + } + + public void setYylxdm(String yylxdm) { + this.yylxdm = yylxdm; + } + + public InvoiceRequestInput getInput() { + return input; + } + + public void setInput(InvoiceRequestInput input) { + this.input = input; + } + + public String getReturncode() { + return returncode; + } + + public void setReturncode(String returncode) { + this.returncode = returncode; + } + + public String getReturnmsg() { + return returnmsg; + } + + public void setReturnmsg(String returnmsg) { + this.returnmsg = returnmsg; + } + + public String getFplxdm() { + return fplxdm; + } + + public void setFplxdm(String fplxdm) { + this.fplxdm = fplxdm; + } + + public String getFpdm() { + return fpdm; + } + + public void setFpdm(String fpdm) { + this.fpdm = fpdm; + } + + public String getFphm() { + return fphm; + } + + public void setFphm(String fphm) { + this.fphm = fphm; + } + + public String getKprq() { + return kprq; + } + + public void setKprq(String kprq) { + this.kprq = kprq; + } + + public String getHjje() { + return hjje; + } + + public void setHjje(String hjje) { + this.hjje = hjje; + } + + public String getSkm() { + return skm; + } + + public void setSkm(String skm) { + this.skm = skm; + } + + public String getJym() { + return jym; + } + + public void setJym(String jym) { + this.jym = jym; + } + + public String getPdfurl() { + return pdfurl; + } + + public void setPdfurl(String pdfurl) { + this.pdfurl = pdfurl; + } + +} diff --git a/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestFyxm.java b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestFyxm.java new file mode 100644 index 000000000..3bab3f0fb --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestFyxm.java @@ -0,0 +1,31 @@ +package com.tenwa.app.invoice.request; + + +import javax.xml.bind.annotation.*; +import java.util.List; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "fyxm") +public class InvoiceRequestFyxm { + @XmlAttribute + private String count ; + + @XmlElement(name="group") + private List groupList ; + + public String getCount() { + return count; + } + + public void setCount(String count) { + this.count = count; + } + + public List getGroupList() { + return groupList; + } + + public void setGroupList(List groupList) { + this.groupList = groupList; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestGroup.java b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestGroup.java new file mode 100644 index 000000000..11dce0f89 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestGroup.java @@ -0,0 +1,181 @@ +package com.tenwa.app.invoice.request; + + +import javax.xml.bind.annotation.*; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "group") +public class InvoiceRequestGroup { + @XmlAttribute + private String xh ; + + @XmlElement + private String fphxz; + @XmlElement + private String spmc; + @XmlElement + private String spsm; + @XmlElement + private String ggxh; + @XmlElement + private String dw; + @XmlElement + private String spsl; + @XmlElement + private String dj; + @XmlElement + private String je; + @XmlElement + private String sl; + @XmlElement + private String se; + @XmlElement + private String hsbz; + @XmlElement + private String spbm; + @XmlElement + private String zxbm; + @XmlElement + private String yhzcbs; + @XmlElement + private String slbs; + @XmlElement + private String zzstsgl; + + + public String getXh() { + return xh; + } + + public void setXh(String xh) { + this.xh = xh; + } + + public String getFphxz() { + return fphxz; + } + + public void setFphxz(String fphxz) { + this.fphxz = fphxz; + } + + public String getSpmc() { + return spmc; + } + + public void setSpmc(String spmc) { + this.spmc = spmc; + } + + public String getSpsm() { + return spsm; + } + + public void setSpsm(String spsm) { + this.spsm = spsm; + } + + public String getGgxh() { + return ggxh; + } + + public void setGgxh(String ggxh) { + this.ggxh = ggxh; + } + + public String getDw() { + return dw; + } + + public void setDw(String dw) { + this.dw = dw; + } + + public String getSpsl() { + return spsl; + } + + public void setSpsl(String spsl) { + this.spsl = spsl; + } + + public String getDj() { + return dj; + } + + public void setDj(String dj) { + this.dj = dj; + } + + public String getJe() { + return je; + } + + public void setJe(String je) { + this.je = je; + } + + public String getSl() { + return sl; + } + + public void setSl(String sl) { + this.sl = sl; + } + + public String getSe() { + return se; + } + + public void setSe(String se) { + this.se = se; + } + + public String getHsbz() { + return hsbz; + } + + public void setHsbz(String hsbz) { + this.hsbz = hsbz; + } + + public String getSpbm() { + return spbm; + } + + public void setSpbm(String spbm) { + this.spbm = spbm; + } + + public String getZxbm() { + return zxbm; + } + + public void setZxbm(String zxbm) { + this.zxbm = zxbm; + } + + public String getYhzcbs() { + return yhzcbs; + } + + public void setYhzcbs(String yhzcbs) { + this.yhzcbs = yhzcbs; + } + + public String getSlbs() { + return slbs; + } + + public void setSlbs(String slbs) { + this.slbs = slbs; + } + + public String getZzstsgl() { + return zzstsgl; + } + + public void setZzstsgl(String zzstsgl) { + this.zzstsgl = zzstsgl; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestHead.java b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestHead.java new file mode 100644 index 000000000..36f046ec0 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestHead.java @@ -0,0 +1,32 @@ +package com.tenwa.app.invoice.request; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "head") +public class InvoiceRequestHead { + @XmlElement + private String appid ; + @XmlElement + private String sid ; + + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestInput.java b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestInput.java new file mode 100644 index 000000000..3ee30f3b2 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/request/InvoiceRequestInput.java @@ -0,0 +1,307 @@ +package com.tenwa.app.invoice.request; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "input") +public class InvoiceRequestInput { + @XmlElement + private String fplxdm ; + @XmlElement + private String kplx ; + @XmlElement + private String tspz ; + @XmlElement + private String xhdwdzdh ; + @XmlElement + private String xhdwyhzh ; + @XmlElement + private String ghdwsbh ; + @XmlElement + private String ghdwmc ; + @XmlElement + private String ghdwdzdh ; + @XmlElement + private String ghdwyhzh ; + @XmlElement + private String hsslbs ; + + + @XmlElement + private InvoiceRequestFyxm fyxm ; + + + @XmlElement + private String zhsl ; + @XmlElement + private String isMutiRate; + @XmlElement + private String hjje ; + @XmlElement + private String hjse ; + @XmlElement + private String jshj ; + @XmlElement + private String bz ; + @XmlElement + private String skr ; + @XmlElement + private String fhr ; + @XmlElement + private String kpr ; + @XmlElement + private String zyspmc ; + @XmlElement + private String spsm ; + @XmlElement + private String ssyf ; + @XmlElement + private String tzdbh ; + @XmlElement + private String yfpdm ; + @XmlElement + private String yfphm ; + @XmlElement + private String GMF_DZYX ; + @XmlElement + private String GMF_SJHM ; + @XmlElement + private String GMF_OPENID ; + + + public String getFplxdm() { + return fplxdm; + } + + public void setFplxdm(String fplxdm) { + this.fplxdm = fplxdm; + } + + public String getKplx() { + return kplx; + } + + public void setKplx(String kplx) { + this.kplx = kplx; + } + + public String getTspz() { + return tspz; + } + + public void setTspz(String tspz) { + this.tspz = tspz; + } + + public String getXhdwdzdh() { + return xhdwdzdh; + } + + public void setXhdwdzdh(String xhdwdzdh) { + this.xhdwdzdh = xhdwdzdh; + } + + public String getXhdwyhzh() { + return xhdwyhzh; + } + + public void setXhdwyhzh(String xhdwyhzh) { + this.xhdwyhzh = xhdwyhzh; + } + + public String getGhdwsbh() { + return ghdwsbh; + } + + public void setGhdwsbh(String ghdwsbh) { + this.ghdwsbh = ghdwsbh; + } + + public String getGhdwmc() { + return ghdwmc; + } + + public void setGhdwmc(String ghdwmc) { + this.ghdwmc = ghdwmc; + } + + public String getGhdwdzdh() { + return ghdwdzdh; + } + + public void setGhdwdzdh(String ghdwdzdh) { + this.ghdwdzdh = ghdwdzdh; + } + + public String getGhdwyhzh() { + return ghdwyhzh; + } + + public void setGhdwyhzh(String ghdwyhzh) { + this.ghdwyhzh = ghdwyhzh; + } + + public String getHsslbs() { + return hsslbs; + } + + public void setHsslbs(String hsslbs) { + this.hsslbs = hsslbs; + } + + public InvoiceRequestFyxm getFyxm() { + return fyxm; + } + + public void setFyxm(InvoiceRequestFyxm fyxm) { + this.fyxm = fyxm; + } + + public String getZhsl() { + return zhsl; + } + + public void setZhsl(String zhsl) { + this.zhsl = zhsl; + } + + public String getIsMutiRate() { + return isMutiRate; + } + + public void setIsMutiRate(String isMutiRate) { + this.isMutiRate = isMutiRate; + } + + public String getHjje() { + return hjje; + } + + public void setHjje(String hjje) { + this.hjje = hjje; + } + + public String getHjse() { + return hjse; + } + + public void setHjse(String hjse) { + this.hjse = hjse; + } + + public String getJshj() { + return jshj; + } + + public void setJshj(String jshj) { + this.jshj = jshj; + } + + public String getBz() { + return bz; + } + + public void setBz(String bz) { + this.bz = bz; + } + + public String getSkr() { + return skr; + } + + public void setSkr(String skr) { + this.skr = skr; + } + + public String getFhr() { + return fhr; + } + + public void setFhr(String fhr) { + this.fhr = fhr; + } + + public String getKpr() { + return kpr; + } + + public void setKpr(String kpr) { + this.kpr = kpr; + } + + public String getZyspmc() { + return zyspmc; + } + + public void setZyspmc(String zyspmc) { + this.zyspmc = zyspmc; + } + + public String getSpsm() { + return spsm; + } + + public void setSpsm(String spsm) { + this.spsm = spsm; + } + + public String getSsyf() { + return ssyf; + } + + public void setSsyf(String ssyf) { + this.ssyf = ssyf; + } + + public String getTzdbh() { + return tzdbh; + } + + public void setTzdbh(String tzdbh) { + this.tzdbh = tzdbh; + } + + public String getYfpdm() { + return yfpdm; + } + + public void setYfpdm(String yfpdm) { + this.yfpdm = yfpdm; + } + + public String getYfphm() { + return yfphm; + } + + public void setYfphm(String yfphm) { + this.yfphm = yfphm; + } + + public String getGMF_DZYX() { + return GMF_DZYX; + } + + public void setGMF_DZYX(String GMF_DZYX) { + this.GMF_DZYX = GMF_DZYX; + } + + public String getGMF_SJHM() { + return GMF_SJHM; + } + + public void setGMF_SJHM(String GMF_SJHM) { + this.GMF_SJHM = GMF_SJHM; + } + + public String getGMF_OPENID() { + return GMF_OPENID; + } + + public void setGMF_OPENID(String GMF_OPENID) { + this.GMF_OPENID = GMF_OPENID; + } +} diff --git a/src_invoice/com/tenwa/app/invoice/servlet/InvoiceDownloadServlet.java b/src_invoice/com/tenwa/app/invoice/servlet/InvoiceDownloadServlet.java new file mode 100644 index 000000000..2e841a64b --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/servlet/InvoiceDownloadServlet.java @@ -0,0 +1,66 @@ +package com.tenwa.app.invoice.servlet; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URLDecoder; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import com.amarsoft.are.ARE; +import com.amarsoft.are.util.DataConvert; +import com.amarsoft.awe.Configure; +import com.tenwa.util.SecurityUtil; + +public class InvoiceDownloadServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + public InvoiceDownloadServlet() { + super(); + } + + @Override + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + try { + HttpSession session = request.getSession(true); + if ((session == null) || (session.getAttributeNames() == null)) { + throw new Exception("------Timeout------"); + } + Configure CurConfig = Configure.getInstance(session.getServletContext()); + if (CurConfig == null) { + throw new ServletException("读取配置文件错误!请检查配置文件。"); + } + String localFile = CurConfig.getConfigure("INVOICE_LOCAL_PATH"); + String path = DataConvert.toString(request.getParameter("path")); + path = SecurityUtil.detrypt(path, "invoice"); + localFile = localFile + path; + + File file = new File(localFile); + if (!file.exists()) + throw new Exception("文件不存在"); + SimpleDateFormat dateFormat = new SimpleDateFormat("YYYYMMddHHmmss"); + String filename = dateFormat.format(new Date()) + ".pdf"; + response.setContentType(getServletContext().getMimeType(filename)); + response.setHeader("Content-Disposition", "attachment;filename=" + filename); + InputStream in = new FileInputStream(localFile); + OutputStream out = response.getOutputStream(); + int b; + while ((b = in.read()) != -1) { + out.write(b); + } + in.close(); + out.close(); + } catch (Exception e) { + ARE.getLog().error("AttachmentView SQL Error:", e); + } + } +} diff --git a/src_invoice/com/tenwa/app/invoice/utils/DownloadPdfUtil.java b/src_invoice/com/tenwa/app/invoice/utils/DownloadPdfUtil.java new file mode 100644 index 000000000..875eaebaa --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/utils/DownloadPdfUtil.java @@ -0,0 +1,59 @@ +package com.tenwa.app.invoice.utils; + +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import java.io.*; +import java.net.URI; + +public class DownloadPdfUtil { + public static void go(String url,String localUrl) throws Exception { + + RestTemplate restTemplate = new RestTemplate(); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + + URI uri = builder.build(true).toUri(); + + String filePath = localUrl ; + File file = new File(filePath); + File parentFile = file.getParentFile(); + if(!parentFile.exists()){ + parentFile.mkdirs(); + } + InputStream inputStream = null; + OutputStream outputStream = null; + + + try { + HttpHeaders headers = new HttpHeaders(); + ResponseEntity response = restTemplate.exchange(uri, HttpMethod.GET, new HttpEntity(headers), byte[].class); + byte[] result = response.getBody(); + inputStream = new ByteArrayInputStream(result); + + outputStream = new FileOutputStream(new File(filePath)); + + int len = 0; + byte[] buf = new byte[1024]; + while ((len = inputStream.read(buf, 0, 1024)) != -1) { + outputStream.write(buf, 0, len); + } + outputStream.flush(); + } catch (Exception e) { + e.printStackTrace(); + throw new Exception(e); + } finally { + try { + if (inputStream != null) inputStream.close(); + if (outputStream != null) outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + throw new IOException(e); + } + } + } +} diff --git a/src_invoice/com/tenwa/app/invoice/utils/JaxbUtil.java b/src_invoice/com/tenwa/app/invoice/utils/JaxbUtil.java new file mode 100644 index 000000000..00769a9a9 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/utils/JaxbUtil.java @@ -0,0 +1,63 @@ +package com.tenwa.app.invoice.utils; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import java.io.StringReader; +import java.io.StringWriter; + +/** + * Jaxb2工具籿 * @author zhuc + * @create 2013-3-29 下午2:40:14 + */ +public class JaxbUtil { + /** + * JavaBean转换成xml + * 默认编码UTF-8 + * @param obj + * @param writer + * @return + */ + public static String convertToXml(Object obj) { + return convertToXml(obj, "UTF-8"); + } + /** + * JavaBean转换成xml + * @param obj + * @param encoding + * @return + */ + public static String convertToXml(Object obj, String encoding) { + String result = null; + try { + JAXBContext context = JAXBContext.newInstance(obj.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); + StringWriter writer = new StringWriter(); + marshaller.marshal(obj, writer); + result = writer.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + /** + * xml转换成JavaBean + * @param xml + * @param c + * @return + */ + @SuppressWarnings("unchecked") + public static T converyToJavaBean(String xml, Class c) { + T t = null; + try { + JAXBContext context = JAXBContext.newInstance(c); + Unmarshaller unmarshaller = context.createUnmarshaller(); + t = (T) unmarshaller.unmarshal(new StringReader(xml)); + } catch (Exception e) { + e.printStackTrace(); + } + return t; + } +} \ No newline at end of file diff --git a/src_invoice/com/tenwa/app/invoice/utils/MathUtil.java b/src_invoice/com/tenwa/app/invoice/utils/MathUtil.java new file mode 100644 index 000000000..08649f3ea --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/utils/MathUtil.java @@ -0,0 +1,61 @@ +package com.tenwa.app.invoice.utils; + +import java.math.BigDecimal; + +public class MathUtil { + + /** + * 加法运算 + * @param m1 + * @param m2 + * @return + */ + public static double add(double m1, double m2) { + BigDecimal p1 = new BigDecimal(Double.toString(m1)); + BigDecimal p2 = new BigDecimal(Double.toString(m2)); + return p1.add(p2).doubleValue(); + } + + /** + * 减法运算 + * @param m1 + * @param m2 + * @return + */ + public static double sub(double m1, double m2) { + BigDecimal p1 = new BigDecimal(Double.toString(m1)); + BigDecimal p2 = new BigDecimal(Double.toString(m2)); + return p1.subtract(p2).doubleValue(); + } + + /** + * 乘法运算 + * @param m1 + * @param m2 + * @return + */ + public static double mul(double m1, double m2) { + BigDecimal p1 = new BigDecimal(Double.toString(m1)); + BigDecimal p2 = new BigDecimal(Double.toString(m2)); + return p1.multiply(p2).doubleValue(); + } + + + /** + * 除法运算 + * @param m1 + * @param m2 + * @param scale + * @return + */ + public static double div(double m1, double m2, int scale) { + if (scale < 0) { + throw new IllegalArgumentException("Parameter error"); + } + BigDecimal p1 = new BigDecimal(Double.toString(m1)); + BigDecimal p2 = new BigDecimal(Double.toString(m2)); + return p1.divide(p2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + +} diff --git a/src_invoice/com/tenwa/app/invoice/utils/Num2ChineseUtil.java b/src_invoice/com/tenwa/app/invoice/utils/Num2ChineseUtil.java new file mode 100644 index 000000000..0da5f397e --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/utils/Num2ChineseUtil.java @@ -0,0 +1,24 @@ +package com.tenwa.app.invoice.utils; + +public class Num2ChineseUtil { + public static String format(String string) { + String[] s1 = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; + String[] s2 = { "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千" }; + + String result = ""; + + int n = string.length(); + for (int i = 0; i < n; i++) { + + int num = string.charAt(i) - '0'; + + if (i != n - 1 && num != 0) { + result += s1[num] + s2[n - 2 - i]; + } else { + result += s1[num]; + } + } + return "第"+result+"期"; + + } +} diff --git a/src_invoice/com/tenwa/app/invoice/utils/PasswordGenerateUtil.java b/src_invoice/com/tenwa/app/invoice/utils/PasswordGenerateUtil.java new file mode 100644 index 000000000..67adeed5e --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/utils/PasswordGenerateUtil.java @@ -0,0 +1,114 @@ +package com.tenwa.app.invoice.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +public class PasswordGenerateUtil { + /** + * 密码类型枚举 + * @author ASUS + */ + public static enum TYPE { + /** + * 字符型 + */ + LETTER, + /** + * 大写字符型 + */ + CAPITAL, + /** + * 数字型 + */ + NUMBER, + /** + * 符号型 + */ + SIGN, + /** + * 大+小字符 型 + */ + LETTER_CAPITAL, + /** + * 小字符+数字 型 + */ + LETTER_NUMBER, + /** + * 大+小字符+数字 型 + */ + LETTER_CAPITAL_NUMBER, + /** + * 大+小字符+数字+符号 型 + */ + LETTER_CAPITAL_NUMBER_SIGN + } + + private static String[] lowercase = { + "a","b","c","d","e","f","g","h","i","j","k", + "l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; + + private static String[] capital = { + "A","B","C","D","E","F","G","H","I","J","K", + "L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; + + private static String[] number = { + "1","2","3","4","5","6","7","8","9","0"}; + + private static String[] sign = { + "~","!","@","#","$","%","^","&","*","(",")","_","+","`","-","=", + "{","}","|",":","\"","<",">","?", + "[","]","\\",";","'",",",".","/"}; + + /** + * 静态随机数 + */ + private static Random random = new Random(); + + /** + * 获取随机组合码 + * @param num 位数 + * @param type 类型 + * @type + *
字符型 LETTER, + *
大写字符型 CAPITAL, + *
数字型 NUMBER, + *
符号型 SIGN, + *
大+小字符型 LETTER_CAPITAL, + *
小字符+数字 型 LETTER_NUMBER, + *
大+小字符+数字 型 LETTER_CAPITAL_NUMBER, + *
大+小字符+数字+符号 型 LETTER_CAPITAL_NUMBER_SIGN + */ + public static String getRandom(int num,TYPE type){ + ArrayList temp = new ArrayList(); + StringBuffer code = new StringBuffer(); + if(type == TYPE.LETTER){ + temp.addAll(Arrays.asList(lowercase)); + }else if(type == TYPE.CAPITAL){ + temp.addAll(Arrays.asList(capital)); + }else if(type == TYPE.NUMBER){ + temp.addAll(Arrays.asList(number)); + }else if(type == TYPE.SIGN){ + temp.addAll(Arrays.asList(sign)); + }else if(type == TYPE.LETTER_CAPITAL){ + temp.addAll(Arrays.asList(lowercase)); + temp.addAll(Arrays.asList(capital)); + }else if(type == TYPE.LETTER_NUMBER){ + temp.addAll(Arrays.asList(lowercase)); + temp.addAll(Arrays.asList(number)); + }else if(type == TYPE.LETTER_CAPITAL_NUMBER){ + temp.addAll(Arrays.asList(lowercase)); + temp.addAll(Arrays.asList(capital)); + temp.addAll(Arrays.asList(number)); + }else if(type == TYPE.LETTER_CAPITAL_NUMBER_SIGN){ + temp.addAll(Arrays.asList(lowercase)); + temp.addAll(Arrays.asList(capital)); + temp.addAll(Arrays.asList(number)); + temp.addAll(Arrays.asList(sign)); + } + for (int i = 0; i < num; i++) { + code.append(temp.get(random.nextInt(temp.size()))); + } + return code.toString(); + } +} diff --git a/src_invoice/com/tenwa/app/invoice/utils/ResultUtil.java b/src_invoice/com/tenwa/app/invoice/utils/ResultUtil.java new file mode 100644 index 000000000..53764da22 --- /dev/null +++ b/src_invoice/com/tenwa/app/invoice/utils/ResultUtil.java @@ -0,0 +1,47 @@ +package com.tenwa.app.invoice.utils; + + +import com.tenwa.app.invoice.data.ResponseEnum; +import com.tenwa.app.invoice.pojo.ResultPojo; + +public class ResultUtil { + public static ResultPojo success(Object data){ + ResultPojo resultPojo = new ResultPojo(); + resultPojo.setCode(ResponseEnum.SUCCESS.getCode()); + resultPojo.setMsg(ResponseEnum.SUCCESS.getMsg()); + resultPojo.setData(data); + return resultPojo; + } + public static ResultPojo success(){ + ResultPojo resultPojo = new ResultPojo(); + resultPojo.setCode(ResponseEnum.SUCCESS.getCode()); + resultPojo.setMsg(ResponseEnum.SUCCESS.getMsg()); + resultPojo.setData(null); + return resultPojo; + } + public static ResultPojo error(String msg){ + ResultPojo resultPojo = new ResultPojo(); + resultPojo.setCode(ResponseEnum.ERROR.getCode()); + resultPojo.setMsg(msg); + resultPojo.setData(null); + return resultPojo; + } + public static ResultPojo error(ResponseEnum responseEnum){ + ResultPojo resultPojo = new ResultPojo(); + resultPojo.setCode(responseEnum.getCode()); + resultPojo.setMsg(responseEnum.getMsg()); + resultPojo.setData(null); + return resultPojo; + } + public static ResultPojo error(){ + ResultPojo resultPojo = new ResultPojo(); + resultPojo.setCode(ResponseEnum.ERROR.getCode()); + resultPojo.setMsg(ResponseEnum.ERROR.getMsg()); + resultPojo.setData(null); + return resultPojo; + } + + + + +} diff --git a/src_tenwa/com/tenwa/lease/app/invoicemanager/InvoiceManagerController.java b/src_tenwa/com/tenwa/lease/app/invoicemanager/InvoiceManagerController.java index ba7376936..02a4d2b41 100644 --- a/src_tenwa/com/tenwa/lease/app/invoicemanager/InvoiceManagerController.java +++ b/src_tenwa/com/tenwa/lease/app/invoicemanager/InvoiceManagerController.java @@ -1,30 +1,73 @@ package com.tenwa.lease.app.invoicemanager; +import java.io.File; import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; import jbo.app.tenwa.calc.LC_CALC_CONDITION; import jbo.app.tenwa.calc.LC_FUND_INCOME; import jbo.app.tenwa.calc.LC_FUND_PLAN; import jbo.app.tenwa.calc.LC_RENT_INCOME; import jbo.app.tenwa.calc.LC_RENT_PLAN; +import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM; +import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM_DETAIL; +import jbo.app.tenwa.calc.LI_INVOICE_RESULT; +import jbo.app.tenwa.calc.VI_LI_INVOICE; +import jbo.app.tenwa.customer.CUSTOMER_COMPANY; +import jbo.app.tenwa.customer.CUSTOMER_PERSON; +import jbo.awe.USER_INFO; import jbo.com.tenwa.entity.comm.invoice.LI_FUND_INVOICE_DOWNLOAD_INFO; import jbo.com.tenwa.entity.comm.invoice.LI_FUND_INVOICE_INFO; import jbo.com.tenwa.entity.comm.invoice.LI_RENT_INVOICE_DOWNLOAD_INFO; import jbo.com.tenwa.entity.comm.invoice.LI_RENT_INVOICE_INFO; import jbo.com.tenwa.entity.comm.invoice.LI_TAX_FUND_UPLOAD_INFO; import jbo.com.tenwa.entity.comm.invoice.LI_TAX_RENT_UPLOAD_INFO; +import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT; +import jbo.com.tenwa.entity.comm.own.OWN_INFO; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INVOICE_TYPE; +import org.apache.commons.lang.StringUtils; +import org.bouncycastle.util.encoders.Base64Encoder; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import com.alibaba.fastjson.util.Base64; import com.amarsoft.app.lc.util.DateAssistant; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectKey; import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.Configure; +import com.tenwa.app.invoice.action.InvoiceRequest; +import com.tenwa.app.invoice.data.ResponseEnum; +import com.tenwa.app.invoice.pojo.ResultPojo; +import com.tenwa.app.invoice.request.InvoiceRequestBase; +import com.tenwa.app.invoice.request.InvoiceRequestHead; +import com.tenwa.app.invoice.utils.DownloadPdfUtil; +import com.tenwa.app.invoice.utils.JaxbUtil; +import com.tenwa.app.invoice.utils.MathUtil; +import com.tenwa.app.invoice.utils.Num2ChineseUtil; +import com.tenwa.app.invoice.utils.PasswordGenerateUtil; +import com.tenwa.app.invoice.utils.ResultUtil; import com.tenwa.flow.action.comm.BaseTable; +import com.tenwa.util.SecurityUtil; import com.tenwa.util.SerialNumberUtil; + /** * @author admin * @@ -42,6 +85,31 @@ public class InvoiceManagerController extends BaseTable{ private String ContractId; private String ContractInvoiceStatus; private String ReceiptList; + private String sid; + private String url = "http://fpfw2.aiee.fun:8899/fpfw2/api/kpbusiness"; + private String appId = "77c61651-f40e-4536-9991-bba64bd3521e"; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + public String getSid() { + return sid; + } + public void setSid(String sid) { + this.sid = sid; + } public String getInvoiceStatus() { return InvoiceStatus; } @@ -402,13 +470,14 @@ public class InvoiceManagerController extends BaseTable{ } return "操作成功!"; } + /** * 确认开票申请 * @param tx * @return * @throws Exception */ - public String confirmInvoice(JBOTransaction tx) throws Exception{ + public String confirmInvoiceBak(JBOTransaction tx) throws Exception{ BizObjectManager lridiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_DOWNLOAD_INFO.CLASS_NAME); BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME); BizObjectManager lfidiManager = JBOFactory.getBizObjectManager(LI_FUND_INVOICE_DOWNLOAD_INFO.CLASS_NAME); @@ -473,6 +542,394 @@ public class InvoiceManagerController extends BaseTable{ } return "操作成功!"; } + + + + /** + * 确认开票申请 + * @param tx + * @return + * @throws Exception + */ + public String confirmInvoice(JBOTransaction tx) throws Exception{ + + BizObjectManager ownAccountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME); + BizObject ownAccount = ownAccountManager.createQuery("state_=:state and acc_type=:acc_type and money_type=:money_type and account_type=:account_type") + .setParameter("state", "0010").setParameter("acc_type", "0010") + .setParameter("money_type", "01").setParameter("account_type", "invoice").getSingleResult(false); + if(ownAccount==null){ + return "您的本方银行账户为空!"; + } + + String[] planIncomeIds = PlanIncomeList.split("@"); + List planIncomeIdList = new ArrayList(); + for(int i=0;i checkInvoiceList= (List)invoiceManager.createQuery("SELECT DISTINCT O.customername,O.customer_id FROM O WHERE O.id IN ("+planIncomeIdStr+")").getResultList(false); + if(checkInvoiceList!=null &&checkInvoiceList.size()>1){ + return "选择的不是同一个客户!"; + }else if(checkInvoiceList!=null &&checkInvoiceList.size()==1){ + customerid = checkInvoiceList.get(0).getAttribute("customer_id").toString(); + customerName = checkInvoiceList.get(0).getAttribute("customername").toString(); + }else{ + return "ERROR[02]"; + } + + String confirmId=UUID.randomUUID().toString().replaceAll("-", ""); + Double hjje =0.00; + Double hjse = 0.00; + Double jshj = 0.00; + List confirmDetailList = new ArrayList(); + + DecimalFormat df2 = new DecimalFormat(".00"); + DecimalFormat df6 = new DecimalFormat(".000000"); + + BizObjectManager invoiceFundManager = JBOFactory.getBizObjectManager(LI_FUND_INVOICE_INFO.CLASS_NAME); + BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME); + Double sl = 0.06; + for(int i=0;i0){ + BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME); + tx.join(confirmManager); + BizObject confirmBizObject = confirmManager.newObject(); + + String ownId = ownAccount.getAttribute("own_id").toString(); + BizObjectManager ownInfoManager = JBOFactory.getBizObjectManager(OWN_INFO.CLASS_NAME); + BizObject ownInfo = ownInfoManager.createQuery("OWN_NUMBER=:OWN_NUMBER").setParameter("OWN_NUMBER", ownId).getSingleResult(false); + String xhdwdzdh = ownInfo.getAttribute("LEASE_TEL").toString(); + + BizObjectManager customerPersonManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME); + BizObjectManager customerCompanyManager = JBOFactory.getBizObjectManager(CUSTOMER_COMPANY.CLASS_NAME); + + BizObject customerPerson = customerPersonManager.createQuery("SELECT o.certid,caa.fulladdress,o.mobile,ca.acc_number,ca.bank_name from o JOIN jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca ON ca.customerid=o.customerid JOIN jbo.app.tenwa.customer.CUSTOMER_ADDRESS caa ON caa.customerid=ca.customerid where o.customerid=:customerid") + .setParameter("customerid", customerid).getSingleResult(false); + + BizObject customerCompany = customerCompanyManager.createQuery("customerid=:customerid").setParameter("customerid", customerid).getSingleResult(false); + String companyTel=""; + if(customerCompany!=null){ + companyTel = customerCompany.getAttribute("company_tel").toString(); + } + String certid=""; + String fulladdress=""; + String mobile=""; + String acc_number=""; + String bank_name=""; + String acc_bank=""; + String address_tel=""; + if(customerPerson!=null){ + certid=customerPerson.getAttribute("certid").toString(); + fulladdress=customerPerson.getAttribute("fulladdress").toString(); + mobile=customerPerson.getAttribute("mobile").toString(); + acc_number=customerPerson.getAttribute("acc_number").toString(); + bank_name=customerPerson.getAttribute("bank_name").toString(); + + acc_bank = "["+bank_name+"]["+acc_number+"]"; + address_tel = "["+mobile+"]["+fulladdress+"]"; + + } + BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME); + BizObject contractInfo = contractInfoManager.createQuery("SELECT o.leas_form,lul.customer_id FROM o JOIN jbo.com.tenwa.lease.comm.LB_UNION_LESSEE lul ON o.id=lul.contract_id WHERE lul.customer_id=:customerid").setParameter("customerid",customerid).getSingleResult(false); + String leas_form = contractInfo.getAttribute("leas_form").toString(); + + + BizObjectManager userInfoManager = JBOFactory.getBizObjectManager(USER_INFO.CLASS_NAME); + BizObject userInfo = userInfoManager.createQuery("userid=:userid").setParameter("userid", CurUserID).getSingleResult(false); + String username=userInfo.getAttribute("username").toString(); + + confirmBizObject.setAttributeValue("id", confirmId); + confirmBizObject.setAttributeValue("sid", PasswordGenerateUtil.getRandom(64, PasswordGenerateUtil.TYPE.LETTER_CAPITAL)); + confirmBizObject.setAttributeValue("yylxdm", "1"); + confirmBizObject.setAttributeValue("fplxdm", "026"); + confirmBizObject.setAttributeValue("kplx", "0"); + confirmBizObject.setAttributeValue("tspz", "00"); + confirmBizObject.setAttributeValue("xhdwdzdh", xhdwdzdh); + confirmBizObject.setAttributeValue("xhdwyhzh", ownAccount.getAttribute("acc_number").toString()); + confirmBizObject.setAttributeValue("ghdwsbh", certid); + confirmBizObject.setAttributeValue("ghdwmc", customerName); + confirmBizObject.setAttributeValue("ghdwdzdh", address_tel); + confirmBizObject.setAttributeValue("ghdwyhzh", acc_bank); + confirmBizObject.setAttributeValue("hsslbs", "0"); + confirmBizObject.setAttributeValue("zhsl", ""); + confirmBizObject.setAttributeValue("hjje", hjje); + confirmBizObject.setAttributeValue("hjse", hjse); + confirmBizObject.setAttributeValue("jshj", MathUtil.add( hjje,hjse )); + confirmBizObject.setAttributeValue("fhr", ""); + confirmBizObject.setAttributeValue("kpr", username); + confirmBizObject.setAttributeValue("zyspmc", ""); + confirmBizObject.setAttributeValue("spsm", ""); + confirmBizObject.setAttributeValue("ssyf", ""); + confirmBizObject.setAttributeValue("tzdbh", ""); + confirmBizObject.setAttributeValue("yfpdm", ""); + confirmBizObject.setAttributeValue("yfphm", ""); + confirmBizObject.setAttributeValue("GMF_DZYX", ""); + if(leas_form=="01"){ + confirmBizObject.setAttributeValue("GMF_SJHM", companyTel); + }else{ + confirmBizObject.setAttributeValue("GMF_SJHM", mobile); + } + confirmBizObject.setAttributeValue("GMF_OPENID", ""); + + + confirmBizObject = this.initTabeUserInfo(confirmBizObject); + confirmManager.saveObject(confirmBizObject); + InvoiceRequest invoiceRequest = new InvoiceRequest(); + + ResultPojo result = invoiceRequest.send(confirmBizObject,confirmDetailList); + if(result.getCode()==0){ + InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData(); + String returncode = responseBase.getBody().getReturncode(); + String returnmsg = responseBase.getBody().getReturnmsg(); + + System.out.println("[OK][returncode]=>>>"+returncode); + System.out.println("[OK][returnmsg]=>>>"+returnmsg); + if("0".equals(returncode)){ + System.out.println("[OK][SUCCESS]"); + for(BizObject confirmDetailBizObject : confirmDetailList){ + String invoiceId = confirmDetailBizObject.getAttribute("invoice_id").toString(); + String invoice_type = confirmDetailBizObject.getAttribute("invoice_type").toString(); + if("fund".equals(invoice_type)){ + //invoiceFundManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate(); + }else{ + //invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate(); + } + } + return "开票申请成功"; + }else{ + return returnmsg; + } + }else{ + System.out.println("[FAIL]=>>>"+result.getMsg()); + return result.getMsg(); + } + + }else{ + return "操作失败!"; + } + } + public String selectConfirm(JBOTransaction tx) throws JBOException{ + + Configure config = Configure.getInstance(); + String INVOICE_LOCAL_PATH=""; + try { + INVOICE_LOCAL_PATH = config.getConfigure("INVOICE_LOCAL_PATH"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "a3web->[INVOICE_LOCAL_PATH]不存在"; + } + + String sid = this.getSid(); + InvoiceRequestBase invoiceRequestBase = new InvoiceRequestBase(); + InvoiceRequestHead invoiceRequestHead = new InvoiceRequestHead(); + invoiceRequestHead.setAppid(this.appId); + invoiceRequestHead.setSid(sid); + + invoiceRequestBase.setHead(invoiceRequestHead); + invoiceRequestBase.setComment("查询开票结果"); + invoiceRequestBase.setId("CXKPJG"); + invoiceRequestBase.setVersion("1.0"); + + String xml = JaxbUtil.convertToXml(invoiceRequestBase); + ResultPojo result = doPost(xml); + + BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME); + BizObject confirm = confirmManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false); + String invoice_confirm_id = confirm.getAttribute("id").toString(); + String id=UUID.randomUUID().toString().replaceAll("-", ""); + if(result.getCode()==0){ + InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData(); + String returncode = responseBase.getBody().getReturncode(); + String returnmsg = responseBase.getBody().getReturnmsg(); + + String fplxdm = responseBase.getBody().getFplxdm(); + String fpdm = responseBase.getBody().getFpdm(); + String fphm = responseBase.getBody().getFphm(); + String kprq = responseBase.getBody().getKprq(); + String hjje = responseBase.getBody().getHjje(); + String skm = responseBase.getBody().getSkm(); + String jym = responseBase.getBody().getJym(); + String pdfurl = ""; + String localFile = ""; + String path=""; + if("0".equals(returncode)){ + pdfurl = responseBase.getBody().getPdfurl(); + SimpleDateFormat dateFormat = new SimpleDateFormat("YYYYMMdd"); + String ydm = dateFormat.format(new Date()); + + path = File.separator + ydm.substring(0, 4)+File.separator + ydm.substring(4, 6)+File.separator + ydm.substring(6, 8); + path = path+File.separator+PasswordGenerateUtil.getRandom(50, PasswordGenerateUtil.TYPE.LETTER_CAPITAL)+".pdf"; + localFile = INVOICE_LOCAL_PATH+path; + try { + DownloadPdfUtil.go(pdfurl,localFile); + } catch (Exception e) { + e.printStackTrace(); + return "下载PDF失败"; + } + } + try { + path = SecurityUtil.encrypt(path, "invoice"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + BizObjectManager confirmResultManager = JBOFactory.getBizObjectManager(LI_INVOICE_RESULT.CLASS_NAME); + BizObject confirmResult = confirmResultManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false); + if(confirmResult==null){ + BizObject confirmResultNew = confirmResultManager.newObject(); + confirmResultNew.setAttributeValue("ID",id); + confirmResultNew.setAttributeValue("sid",sid); + confirmResultNew.setAttributeValue("fplxdm",fplxdm); + confirmResultNew.setAttributeValue("fpdm",fpdm ); + confirmResultNew.setAttributeValue("fphm",fphm); + confirmResultNew.setAttributeValue("kprq",kprq); + confirmResultNew.setAttributeValue("hjje",hjje); + confirmResultNew.setAttributeValue("skm",skm); + confirmResultNew.setAttributeValue("jym",jym); + confirmResultNew.setAttributeValue("pdfurl",pdfurl); + confirmResultNew.setAttributeValue("localFile",path ); + confirmResultNew.setAttributeValue("returncode",returncode); + confirmResultNew.setAttributeValue("returnmsg",returnmsg); + confirmResultManager.saveObject(confirmResultNew); + }else{ + confirmResultManager.createQuery("update o set fplxdm=:fplxdm,fpdm=:fpdm,fphm=:fphm,kprq=:kprq,hjje=:hjje,skm=:skm,jym=:jym,pdfurl=:pdfurl,localFile=:localFile,returncode=:returncode,returnmsg=:returnmsg where sid=:sid ") + .setParameter("sid",sid).setParameter("fplxdm","fplxdm") + .setParameter("fpdm",fpdm).setParameter("fphm","fphm") + .setParameter("kprq",kprq).setParameter("hjje","hjje") + .setParameter("skm",skm).setParameter("jym","jym") + .setParameter("pdfurl",pdfurl).setParameter("localFile","localFile") + .setParameter("returncode",returncode).setParameter("returnmsg","returnmsg") + .executeUpdate(); + + } + System.out.println("[OK][returncode]=>>>"+returncode); + System.out.println("[OK][returnmsg]=>>>"+returnmsg); + if("0".equals(returncode)){ + /*System.out.println("[OK][SUCCESS]"); + BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME); + BizObject confirmDetail = confirmDetailManager.createQuery("invoice_confirm_id=:invoice_confirm_id").setParameter("invoice_confirm_id", invoice_confirm_id).getSingleResult(false); + String invoiceId = confirmDetail.getAttribute("invoice_id").toString(); + String invoice_type = confirmDetail.getAttribute("invoice_type").toString(); + if("fund".equals(invoice_type)){ + //invoiceFundManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","5").executeUpdate(); + }else{ + //invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","5").executeUpdate(); + } + */ + return "开票申请成功"; + }else{ + return returnmsg; + } + }else{ + System.out.println("[FAIL]=>>>"+result.getMsg()); + return result.getMsg(); + } + /* + if(result.getCode().toString()!="0"){ + return "查询失败"; + } + + System.out.println("result=>>>"+JSONObject.toJSONString(result)); + showResult(result); + return "查询成功";*/ + + + } + public ResultPojo doPost(String xml){ + HttpHeaders httpHeaders = new HttpHeaders(); + MultiValueMap param = new LinkedMultiValueMap<>(); + httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + param.add("bw",xml) ; + RestTemplate restTemplate = new RestTemplate(); + HttpEntity> entity = new HttpEntity<>(param, httpHeaders); + ResponseEntity response = null ; + try { + response = restTemplate.exchange(this.url, HttpMethod.POST, entity, String.class); + }catch (Exception e){ + return ResultUtil.error(ResponseEnum.NETWORK.getMsg()); + } + System.out.println(response.getBody()); + InvoiceRequestBase r = JaxbUtil.converyToJavaBean(response.getBody(), InvoiceRequestBase.class); + return ResultUtil.success(r); + } + private void showResult(ResultPojo result) { + if(result.getCode()==0){ + InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData(); + String returncode = responseBase.getBody().getReturncode(); + String returnmsg = responseBase.getBody().getReturnmsg(); + + System.out.println("[OK][returncode]=>>>"+returncode); + System.out.println("[OK][returnmsg]=>>>"+returnmsg); + if("0".equals(returncode)){ + System.out.println("[OK][SUCCESS]"); + } + }else{ + System.out.println("[FAIL]=>>>"+result.getMsg()); + } + } /** * 退回开票申请 * @param tx