Преглед на файлове

补充建章采集的东西

1 преди 3 седмици
родител
ревизия
fc3e5cf58a
променени са 6 файла, в които са добавени 220 реда и са изтрити 1 реда
  1. 1 0
      common/common.go
  2. 47 0
      common/file.go
  3. 1 1
      common/models/invoice.go
  4. 20 0
      common/period.go
  5. 32 0
      common/utils.go
  6. 119 0
      common/variable/sb.go

+ 1 - 0
common/common.go

@@ -7,6 +7,7 @@ import (
 	"errors"
 	"git.listensoft.net/tool/jspkit/common/lxhttp"
 	"git.listensoft.net/tool/jspkit/common/models"
+
 	"git.listensoft.net/tool/jspkit/common/variable"
 	"git.listensoft.net/tool/jspkit/logger"
 	"git.listensoft.net/tool/jspkit/taxerr"

+ 47 - 0
common/file.go

@@ -0,0 +1,47 @@
+package common
+
+import (
+	"encoding/json"
+	"github.com/go-rod/rod/lib/utils"
+	"os"
+)
+
+// GetCollectPDFPath 生成一个采集用的pdf路径
+func GetCollectPDFPath(district, taxNo, taxTape string) (string, error) {
+	var err error
+	var path string
+	path = "./data/collection/" + district + "/"
+	if !PathExists(path) {
+		err = os.MkdirAll(path, os.ModePerm)
+	}
+	path = path + taxNo + "_" + taxTape + ".pdf"
+	return path, err
+}
+
+// PDFtoStrArrayPython pdf转二维数组 python服务
+func PDFtoStrArrayPython(path string) ([][]string, error) {
+	var code [][]string
+	files := map[string]string{
+		"file": path,
+	}
+	var bys []byte
+	var err error
+	pdfServers := []string{
+		`http://47.104.75.113:6000/pdfToText`,
+		`http://47.104.75.113:6000/pdfToText`,
+	}
+
+	for _, uri := range pdfServers {
+		bys, err = PostFile(uri, files, map[string]string{})
+		if err != nil {
+			utils.Sleep(10)
+			continue
+		}
+		break
+	}
+	if err != nil {
+		return code, err
+	}
+	json.Unmarshal(bys, &code)
+	return code, nil
+}

+ 1 - 1
common/models/invoice.go

@@ -1,4 +1,4 @@
-package model
+package models
 
 // InvoiceReply 普通发票
 type InvoiceReply struct {

+ 20 - 0
common/period.go

@@ -243,3 +243,23 @@ func GetPrevQuarterStartTimeAndEndTime(period string) (string, string) {
 	}
 	return quarterStart, quarterEnd
 }
+
+// 根据本账期查询上季度末账期 例如 201812 -> 201809
+func LastJiDu(startAccountPeriod string) string {
+	if len(startAccountPeriod) < 6 {
+		return ""
+	}
+	qian4 := startAccountPeriod[0 : len(startAccountPeriod)-2]
+	hou2 := startAccountPeriod[4 : len(startAccountPeriod)-0]
+	newPeriod := ""
+	if StrToInt(hou2) == 1 || StrToInt(hou2) == 2 || StrToInt(hou2) == 3 {
+		newPeriod = IntToStr(StrToInt(qian4)-1) + "12"
+	} else if StrToInt(hou2) == 4 || StrToInt(hou2) == 5 || StrToInt(hou2) == 6 {
+		newPeriod = IntToStr(StrToInt(qian4)-0) + "03"
+	} else if StrToInt(hou2) == 7 || StrToInt(hou2) == 8 || StrToInt(hou2) == 9 {
+		newPeriod = IntToStr(StrToInt(qian4)-0) + "06"
+	} else if StrToInt(hou2) == 10 || StrToInt(hou2) == 11 || StrToInt(hou2) == 12 {
+		newPeriod = IntToStr(StrToInt(qian4)-0) + "09"
+	}
+	return newPeriod
+}

+ 32 - 0
common/utils.go

@@ -3,15 +3,18 @@ package common
 import (
 	"crypto/md5"
 	"encoding/hex"
+	"encoding/json"
 	"fmt"
 	"git.listensoft.net/tool/jspkit/common/lxhttp"
 	"git.listensoft.net/tool/jspkit/common/variable"
+	"git.listensoft.net/tool/jspkit/logger"
 	"git.listensoft.net/tool/jspkit/taxerr"
 	"github.com/go-kratos/kratos/v2/log"
 	"github.com/tidwall/gjson"
 	"io"
 	"net/url"
 	"os"
+	"reflect"
 	"regexp"
 	"strings"
 )
@@ -146,3 +149,32 @@ func CheckEqmLive(tel string) bool {
 	}
 	return false
 }
+
+func GetData(key variable.SbKey, data string, target interface{}) bool {
+	str := gjson.Get(data, string(key)).String()
+	if err := MapToStruct(str, target); err != nil {
+		logger.Info(err)
+		return false
+	}
+	return true
+}
+
+// target 传指针
+func MapToStruct(source interface{}, target interface{}) error {
+	resByre := []byte("")
+	var resByteErr error
+	if reflect.TypeOf(source).String() == "string" {
+		str := source.(string)
+		resByre = []byte(str)
+	} else {
+		resByre, resByteErr = json.Marshal(source)
+		if resByteErr != nil {
+			return resByteErr
+		}
+	}
+	err := json.Unmarshal(resByre, target)
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 119 - 0
common/variable/sb.go

@@ -0,0 +1,119 @@
+package variable
+
+import "time"
+
+type SbKey string
+
+const (
+	//申报相关
+	GsVat             SbKey = "gsVat"              //一般纳税人增值税
+	GsVatAttach1      SbKey = "gsVatAttach1"       //附表1
+	GsVatAttach2      SbKey = "gsVatAttach2"       //附表2
+	GsVatAttach3      SbKey = "gsVatAttach3"       //附表3
+	GsVatAttach4      SbKey = "gsVatAttach4"       //附表4
+	GsVatAttach5      SbKey = "gsVatAttach5"       //附表5 附加税
+	GsVatAttach5Qt    SbKey = "gsVatAttach5Qt"     //附加税其他
+	GsVatJsxm         SbKey = "gsVatJsxm"          //减税
+	GsVatBc           SbKey = "gsVatBc"            //补充申报表
+	GsVatNcp          SbKey = "gsVatNcp"           //农产品
+	GsVatNcpHzb       SbKey = "gsVatNcpHzb"        //农产品汇总表
+	GsVatQt           SbKey = "gsVatQt"            //增值税其他
+	GsTaxCpygsl       SbKey = "gsTaxCpygsl"        //成品油购数量明细表
+	GsTaxCpygxc       SbKey = "gsTaxCpygxc"        //成品油购销存
+	GsTaxJyzyjyxx     SbKey = "gsTaxJyzyjyxx"      //加油站月份加油信息明细
+	GsTaxJyzysx       SbKey = "gsTaxJyzysx"        //加油站月销售油品汇总表
+	GsSmallVat        SbKey = "gsSmallVat"         //小规模纳税人增值税
+	GsSmallVatAttach  SbKey = "gsSmallVatAttached" //小规模增值税附表
+	GsSmallVatAttach5 SbKey = "gsVatAttach5"
+	GsSmallVatReduce  SbKey = "gsSmallVatReduce"
+	GsSmallVatFb4     SbKey = "gsSmallVatFb4"
+	GsSmallVatFb5     SbKey = "gsSmallVatFb5"
+	GsSmallVatFb6     SbKey = "gsSmallVatFb6"
+	GsSmallVatFb7     SbKey = "gsSmallVatFb7"
+	GsVatFjs          SbKey = "gsVatFjs"
+	GsVatNcpZjxs      SbKey = "gsVatNcpZjxs"
+
+	GsTaxDqde       SbKey = "gsTaxDqde"
+	GsTaxQuarter    SbKey = "gsTaxQuarter"
+	GsTaxQuarterB   SbKey = "gsTaxQuarterB"
+	GsTaxQuarterFb1 SbKey = "gsTaxQuarterFb1"
+	GsTaxQuarterFb2 SbKey = "gsTaxQuarterFb2"
+	GsTaxQuarterFb3 SbKey = "gsTaxQuarterFb3"
+	GsA201020       SbKey = "gsA201020"
+	GsOther         SbKey = "gsOther" //弥补年度亏损
+
+	GsDeed    SbKey = "gsDeed"    //行为税
+	GsDeedYhs SbKey = "gsDeedYhs" //行为税 印花税
+	GsDeedZys SbKey = "gsDeedZys" //行为税 印花税
+	GsDeedTds SbKey = "gsDeedTds" //行为税 印花税
+	GsLjcl    SbKey = "gsLjcl"
+
+	GsSbXfs     SbKey = "gsXfs"     //消费税
+	GsSbXfsMain SbKey = "gsXfsMain" //消费税主表
+	GsSbXfsItem SbKey = "gsXfsItem" //消费税附加资料(一)
+	GsSbXfsFjs  SbKey = "gsXfsFjs"  //消费税附加税
+	GsSbXfsJm   SbKey = "gsXfsJm"   //消费税
+
+	KjZcfz     SbKey = "kjZcfz"
+	KjLrb      SbKey = "kjLrb"
+	KjLrbMonth SbKey = "kjLrbMonth"
+	KjXjllbJb  SbKey = "kjXjllbJb"
+
+	GsSl              SbKey = "gsSl"              //水利建设专项
+	GsQtsr            SbKey = "gsQtsr"            //其他收入
+	GsCbj             SbKey = "gsCbj"             //残保金
+	GsWhsyjsfsbbygz   SbKey = "gsWhsyjsfsbbygz"   //文化事业建设
+	GsWhsyjsfsbbygzFb SbKey = "gsWhsyjsfsbbygzFb" //文化事业建设
+	//扣款相关
+	GsVatAmount           SbKey = "gsVatAmount"           //增值税税款
+	GsSmallVatAmount      SbKey = "gsSmallVatAmount"      //小规模增值税税款
+	GsFjsAmount           SbKey = "gsFjsAmount"           //附加税税款
+	GsDeedAmount          SbKey = "gsDeedAmount"          //财产行为税税款
+	GsTaxQuarterAmount    SbKey = "gsTaxQuarterAmount"    //企业所得税税款
+	GsWhsyjsfsbbygzAmount SbKey = "gsWhsyjsfsbbygzAmount" //文化建设事业费 税款
+	GsQtsrAmount          SbKey = "gsQtsrAmount"          //其他收入 税款
+	GsLjclAmount          SbKey = "gsLjclAmount"          //垃圾处理  税款 江苏用
+	GsSlAmount            SbKey = "gsSlAmount"            //水利 税款 内蒙用
+	GsXfsAmount           SbKey = "gsXfsAmount"           //消费税 税款
+	GsCbjAmount           SbKey = "gsCbjAmount"           //残保金 税款
+	//税种
+	GsTaxCategory SbKey = "gsTaxCategory" //税种
+
+	//注册信息
+	GsRegInfo SbKey = "gsRegInfo"
+
+	// 汇算清缴
+	A000000    SbKey = "a000000"
+	A000000Gd  SbKey = "a000000Gd"
+	A100000    SbKey = "a100000"
+	A100000Fb1 SbKey = "a100000_fb1"
+	A100000Fb2 SbKey = "a100000_fb2"
+	A101010    SbKey = "a101010"
+	A102010    SbKey = "a102010"
+	A104000    SbKey = "a104000"
+	A105000    SbKey = "a105000"
+	A105050    SbKey = "a105050"
+	A105060    SbKey = "a105060"
+	A105080    SbKey = "a105080"
+	A106000    SbKey = "a106000"
+	A107010    SbKey = "a107010"
+	A107040    SbKey = "a107040"
+	//财报年报
+	YearLrb   SbKey = "lrb"
+	YearXjllb SbKey = "xjllb"
+	YearZcfz  SbKey = "zcfz"
+	//涉税机构人员添加
+	Ssjgpeopel SbKey = "list"
+)
+
+type GsXfsMain struct {
+	AddFlag     bool      `json:"addFlag"`
+	CreatedAt   time.Time `json:"createdAt"`
+	GsMainID    int       `json:"gsMainId"`
+	ID          int       `json:"id"`
+	Name        string    `json:"name"`
+	PeriodTotal string    `json:"periodTotal"`
+	Type        string    `json:"type"`
+	UpdatedAt   time.Time `json:"updatedAt"`
+	YearTotal   string    `json:"yearTotal"`
+}