|
|
@@ -897,7 +897,7 @@ func (this *SelectController) GetTotalList() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
-// @Title 导出营业执照
|
|
|
+// @Title 导出资质图片
|
|
|
// @Description
|
|
|
// @Success 200 {object}
|
|
|
// @router /getallbusinesslicense [get]
|
|
|
@@ -911,7 +911,7 @@ func (this *SelectController) GetAllBusinessLicense() {
|
|
|
where := "1=1"
|
|
|
svc.GetEntities(&supplierList, where)
|
|
|
_dir := utils.Cfg.MustValue("file", "tmplateDir") + needFileType
|
|
|
- downFileUrl := "http://10.76.248.23"
|
|
|
+ downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
|
|
|
for _,item := range supplierList {
|
|
|
var supplierFile supplierfile.OilSupplierFile
|
|
|
where := "SupplierId=" + strconv.Itoa(item.Id) + " and NeedFileType='" + needFileType + "'"
|
|
|
@@ -946,7 +946,7 @@ func (this *SelectController) GetAllBusinessLicense() {
|
|
|
|
|
|
}
|
|
|
os.Remove(destZip)
|
|
|
- os.Remove(_dir)
|
|
|
+ os.RemoveAll(_dir)
|
|
|
var errinfo ErrorDataInfo
|
|
|
errinfo.Code = 0
|
|
|
errinfo.Item = retDocUrl
|
|
|
@@ -955,6 +955,80 @@ func (this *SelectController) GetAllBusinessLicense() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// @Title 导出企业资质图片
|
|
|
+// @Description
|
|
|
+// @Success 200 {object}
|
|
|
+// @router /getallbusinesslicensebyid [get]
|
|
|
+func (this *SelectController) GetBusinessLicenseById() {
|
|
|
+
|
|
|
+ SupplierId := this.GetString("SupplierId")
|
|
|
+ SupplierName := this.GetString("SupplierName")
|
|
|
+ SupplierTypeCode := this.GetString("SupTypeCode")
|
|
|
+
|
|
|
+ svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+
|
|
|
+ _dir := utils.Cfg.MustValue("file", "tmplateDir") + SupplierName
|
|
|
+ downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
|
|
|
+ var supplierFile []supplierfile.OilSupplierFile
|
|
|
+ where := "SupplierId=" + SupplierId
|
|
|
+ svc.GetEntities(&supplierFile, where)
|
|
|
+
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if len(supplierFile) == 0 {
|
|
|
+ errinfo.Code = -1
|
|
|
+ errinfo.Message = "该公司没有可导出的资质!"
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+ for _,item := range supplierFile {
|
|
|
+ fileArr := strings.Split(item.FileName, ".")
|
|
|
+ fileUrl := strings.Split(item.FileUrl, "|")
|
|
|
+ if len(fileUrl) == 2 && len(fileArr) == 2 {
|
|
|
+ utils.DownloadFile( downFileUrl + fileUrl[0], item.NeedFileType + "." + fileArr[1] , _dir)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip")
|
|
|
+
|
|
|
+ f1,_ := os.Open(_dir)
|
|
|
+ var files = []*os.File{f1}
|
|
|
+ if SupplierTypeCode == "01" {
|
|
|
+ SupplierTypeCode = "WZ"
|
|
|
+ } else if SupplierTypeCode == "02" {
|
|
|
+ SupplierTypeCode = "JS"
|
|
|
+ } else if SupplierTypeCode == "03" {
|
|
|
+ SupplierTypeCode = "JF"
|
|
|
+ } else {
|
|
|
+ SupplierTypeCode = ""
|
|
|
+ }
|
|
|
+ destZipName := SupplierName + time.Now().Format("2006-01-02") + SupplierTypeCode
|
|
|
+ destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
|
|
|
+ err := Compress(files, destZip)
|
|
|
+
|
|
|
+ retDocUrl := ""
|
|
|
+ if err == nil {
|
|
|
+ var sw *Seaweed
|
|
|
+ var filer []string
|
|
|
+ if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
|
|
|
+ filer = []string{_filer}
|
|
|
+ }
|
|
|
+ sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
|
|
|
+ _, _, fID, _ := sw.UploadFile(destZip, "", "")
|
|
|
+ retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
|
|
|
+
|
|
|
+ }
|
|
|
+ err = os.RemoveAll(destZip)
|
|
|
+ fmt.Println(err)
|
|
|
+ err = os.RemoveAll(_dir)
|
|
|
+ fmt.Println(err)
|
|
|
+
|
|
|
+ errinfo.Code = 0
|
|
|
+ errinfo.Item = retDocUrl
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
func Compress(files []*os.File, dest string) error {
|
|
|
d, _ := os.Create(dest)
|
|
|
defer d.Close()
|