Kaynağa Gözat

前后:集中评审改为后端导出

dubch 4 yıl önce
ebeveyn
işleme
9a65c6a8e4

+ 42 - 0
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplier.go

@@ -358,6 +358,48 @@ type OilSupplierView1 struct {
 	Remark1           string    `xorm:"VARCHAR(255)"`
 }
 
+type OilSupplierExport struct {
+	Id               int //Oilsupplier表id
+	CertId           int
+	SupplierName     string    //企业名称
+	SupplierTypeCode string    //准入类别编号
+	Grade            string    //级别
+	OperType         string    //供应商类型
+	LegalPerson      string    //法定代表人姓名
+	RegCapital       float64   //注册资本
+	Mobile           string    //移动电话
+	AuditDate        time.Time //最后一次年审
+	ApplyTime        time.Time //申请时间
+	EffectEndTime    time.Time //有效期至
+	InFlag           string    //状态
+	ContactName      string    //联系人姓名
+	CommercialNo     string    //统一社会信用代码
+	DepositBank      string    //开户银行
+	HseTraining      string    //是否需要进行HSE审查培训
+	CompanyType      string    //公司类型
+	SetupTime        time.Time //成立时间
+	Address          string    //注册详细地址
+	Province         string    //注册省
+	City             string    //注册市
+	Street           string    //注册区
+	LinkAddress      string    //通信详细地址
+	LinkProvince     string    //通信地址省
+	LinkCity         string    //通信地址市
+	LinkStreet       string    //通信地址区
+	BusinessScope    string    //营业范围
+	NeedFileType     string    //资质
+	CerSubName       string    //准入范围
+	InStyle          string    //准入方式
+	FullName         string    //专业科室审批
+	CheckUnitName    string    //推荐单位
+	CreateOn         time.Time //申请时间
+	Remark           string
+	RecUnitName           string
+	SupplierTypeName           string
+	Currency           string
+	SubName           string
+}
+
 type OilSupplierSelect struct {
 	Id               int //Oilsupplier表id
 	CertId           int

+ 15 - 0
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierService.go

@@ -206,6 +206,21 @@ func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl3(supplierTableNam
 
 	return total
 }
+func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytblExport(supplierTableName, supplierCertTableName string, entitiesPtr interface{}, where string) {
+	var sql string
+	sql = `select a.*,b.Id as CertId, b.SupplierTypeName, b.InFlag, b.ApplyTime,b.EffectEndTime, `
+	sql += ` b.Status, `
+	sql += ` o.FullName, `
+	sql += ` b.RecUnitName, `
+	sql += ` GROUP_CONCAT(c.Name) as SubName `
+	sql += ` from ` + supplierTableName + ` a `
+	sql += ` left join ` + supplierCertTableName + " b on b.SupplierId = a.Id"
+	sql += ` left join Base_Organize o on o.Id = b.ThirdAudit `
+	sql += ` left join OilSupplierCertSub c on c.SupplierCertId = b.Id`
+	sql += ` where ` + where
+	sql += ` GROUP BY a.Id,b.Id order by b.Id desc`
+	s.DBE.SQL(sql).Find(entitiesPtr)
+}
 
 func (s *OilSupplierService) CheckRepeatApplyInfo(supplierTableName, supplierCertTableName, typeCode, SupplierName, CommercialNo, OrganCode, BankAccount, CompanyUrl string, entitiesPtr interface{}) {
 

+ 238 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -11,6 +11,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/tableheader"
 	"dashoo.cn/backend/api/business/register"
 	"dashoo.cn/business3/parameter"
+	. "github.com/linxGnu/goseaweedfs"
 	"encoding/json"
 	"fmt"
 	"github.com/tealeg/xlsx"
@@ -746,6 +747,243 @@ func (this *OilSupplierController) GetJZPSJoinCertEntityList() {
 	this.ServeJSON()
 }
 
+// @Title 集中评审列表导出
+// @Description get user by token
+// @Success 200 {object} []supplier.OilSupplier
+// @router /jzpsListExport [get]
+func (this *OilSupplierController) JzpsListExport() {
+
+	where := " 1=1 "
+	SupplierName := this.GetString("SupplierName")
+	SupplierTypeName := this.GetString("SupplierTypeName")
+	CreateOn := this.GetString("CreateOn")
+	SupplierTypeCode := this.GetString("SupplierTypeCode")
+	OperType := this.GetString("OperType")
+	SpecTypeCode := this.GetString("SpecTypeCode")
+	Country := this.GetString("Country")
+	InStyle := this.GetString("InStyle")
+	MgrUnit := this.GetString("MgrUnit")
+	PACNumber := this.GetString("PACNumber")
+	CommercialNo := this.GetString("CommercialNo")
+	Province := this.GetString("Province")
+	City := this.GetString("City")
+	Street := this.GetString("Street")
+	Address := this.GetString("Address")
+	LinkProvince := this.GetString("LinkProvince")
+	LinkCity := this.GetString("LinkCity")
+	LinkStreet := this.GetString("LinkStreet")
+	LinkAddress := this.GetString("LinkAddress")
+	LegalPerson := this.GetString("LegalPerson")
+	ContactName := this.GetString("ContactName")
+	CompanyType := this.GetString("CompanyType")
+	SetupTime := this.GetString("SetupTime")
+	RegCapital1 := this.GetString("RegCapital1")
+	RegCapital2 := this.GetString("RegCapital2")
+	BusinessScope := this.GetString("BusinessScope")
+	RecUnitName := this.GetString("RecUnitName")
+	RecUnitId := this.GetString("RecUnitId")
+	ThirdAudit := this.GetString("ThirdAudit")
+
+	if SupplierName != "" {
+		where = where + " and a.SupplierName like '%" + SupplierName + "%'"
+	}
+	if SupplierTypeName != "" {
+		where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
+	}
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
+		}
+	}
+	if SupplierTypeCode != "" {
+		where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
+	}
+	if OperType != "" {
+		where = where + " and a.OperType like '%" + OperType + "%'"
+	}
+	if SpecTypeCode != "" {
+		where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
+	}
+	if Country != "" {
+		where = where + " and a.Country like '%" + Country + "%'"
+	}
+	if InStyle != "" {
+		where = where + " and b.InStyle ='" + InStyle + "'"
+	}
+	if MgrUnit != "" {
+		where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
+	}
+	if PACNumber != "" {
+		where = where + " and a.PACNumber ='" + PACNumber + "'"
+	}
+	if CommercialNo != "" {
+		where = where + " and a.CommercialNo ='" + CommercialNo + "'"
+	}
+	if Province != "" {
+		where = where + " and a.Province ='" + Province + "'"
+	}
+	if City != "" {
+		where = where + " and a.City ='" + City + "'"
+	}
+	if Street != "" {
+		where = where + " and a.Street ='" + Street + "'"
+	}
+	if Address != "" {
+		where = where + " and a.Address ='" + Address + "'"
+	}
+	if LinkProvince != "" {
+		where = where + " and a.LinkProvince ='" + LinkProvince + "'"
+	}
+	if LinkCity != "" {
+		where = where + " and a.LinkCity ='" + LinkCity + "'"
+	}
+	if LinkStreet != "" {
+		where = where + " and a.LinkStreet ='" + LinkStreet + "'"
+	}
+	if LinkAddress != "" {
+		where = where + " and a.LinkAddress ='" + LinkAddress + "'"
+	}
+	if LegalPerson != "" {
+		where = where + " and a.LegalPerson ='" + LegalPerson + "'"
+	}
+	if ContactName != "" {
+		where = where + " and a.ContactName ='" + ContactName + "'"
+	}
+	if CompanyType != "" {
+		where = where + " and a.CompanyType like '%" + CompanyType + "%'"
+	}
+	if SetupTime != "" {
+		where = where + " and a.SetupTime ='" + SetupTime + "'"
+	}
+	//注册资金范围
+	if RegCapital1 != "" {
+		where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
+	}
+	if RegCapital2 != "" {
+		where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
+	}
+	if BusinessScope != "" {
+		where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
+	}
+
+	if RecUnitName != "" {
+		where = where + " and b.RecUnitName like '%" + RecUnitName + "%'"
+	}
+
+	if RecUnitId != "" {
+		where = where + " and b.RecUnitId = '" + RecUnitId + "' "
+	}
+
+	if ThirdAudit != "" {
+		where = where + " and b.ThirdAudit = '" + ThirdAudit + "' "
+	}
+
+	status := this.GetString("Status")
+	if status != "" {
+		where = where + " and b.Status='" + status + "'"
+	}
+
+	//企业用户必须加创建人条件
+	if this.User.IsCompanyUser == 1 {
+		where = where + " and a.CreateUserId = '" + this.User.Id + "'"
+	} else {
+		//超级管理员和有查看所有数据权限的用户不加条件
+		svcPerm := permission.GetPermissionService(utils.DBE)
+		isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
+		if !svcPerm.IsAdmin(this.User.Id) && !isauth {
+			//根据工作流查找
+			//集中评审相关人可看数据
+			actisvc := workflow.GetActivitiService(utils.DBE)
+			//找出待办任务===准入
+			var certIdList string
+			ids := actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
+			if len(strings.Trim(ids, ",")) > 0 {
+				certIdList += strings.Trim(ids, ",") + ","
+			}
+
+			certIdList = strings.Trim(certIdList, ",")
+			certIdarr := strings.Split(certIdList, ",")
+			for i, item := range certIdarr {
+				idx := strings.Index(item, "-")
+				if idx >= 0 {
+					certIdarr[i] = strings.Split(item, "-")[0]
+				}
+			}
+			certIdList = strings.Join(certIdarr, ",")
+
+			if certIdList != "" {
+				where += " and ( b.Id in (" + certIdList + ")" + " or a.CreateUserId = '" + this.User.Id + "')"
+			} else {
+				where = where + " and a.CreateUserId = '" + this.User.Id + "'"
+			}
+		}
+	}
+
+	svc := supplier.GetOilSupplierService(utils.DBE)
+	var list []supplier.OilSupplierExport
+	svc.GetMyPagingEntitiesWithOrderBytblExport(OilSupplierName, OilSupplierCertName, &list, where)
+
+	fileTitle := "集中评审"
+	showColumnArr := "序号,审核状态,审核处室,推荐单位,准入类别,企业名称,法人,工商注册号,注册资本,币种,公司类型,成立时间,手机号,准入范围"
+
+	f := xlsx.NewFile()
+	sheet, _ := f.AddSheet(fileTitle)
+	cellName := strings.Split(showColumnArr, ",")
+	row := sheet.AddRow()
+	row.WriteSlice(&cellName, -1)
+
+	for idx, item := range list {
+		var certSubList []suppliercertsub.OilSupplierCertSub
+		svc.GetEntitysByWhere(OilSupplierCertSubName, "SupplierCertId = " + strconv.Itoa(item.CertId), &certSubList)
+		subName := ""
+		for _,certSub := range certSubList{
+			subName += "," + certSub.Name
+		}
+		regCapital := strconv.FormatFloat(item.RegCapital, 'f', 2, 64)
+		currency := "人民币"
+		if item.Currency == "人民币元" {
+			currency = "人民币"
+		}
+		if item.Currency == "JPY" {
+			currency = "日元"
+		}
+		if item.Currency == "USD" {
+			currency = "美元"
+		}
+		if item.Currency == "EUR" {
+			currency = "欧元"
+		}
+		dataString := strconv.Itoa(idx+1) + "+待集中评审+" + item.FullName + "+" + item.RecUnitName + "+" + item.SupplierTypeName + "+" + item.SupplierName + "+" + item.LegalPerson + "+" + item.CommercialNo + "+" +
+			regCapital  + "+" + currency  + "+" + item.CompanyType  + "+" + utils.ToStr(item.SetupTime.Format("2006-01-02")) + "+" + item.Mobile + "+" + strings.TrimLeft(subName, ",")
+		cellName := strings.Split(dataString, "+")
+		row := sheet.AddRow()
+		row.WriteSlice(&cellName, -1)
+	}
+	for c, cl := 0, len(sheet.Cols); c < cl; c++ {
+		sheet.Cols[c].Width = 30
+	}
+	dir := "static/file/excel/report/" + this.GetAccode()
+	SaveDirectory(dir)
+	path := dir + "/" + utils.TimeFormat(time.Now(), "20060102") + fileTitle + ".xlsx"
+	f.Save(path)
+	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(path, "", "")
+
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(path)
+	fmt.Println("==retDocWatermarkUrl==", retDocUrl)
+	this.Data["json"] = retDocUrl
+	this.ServeJSON()
+}
+
 // @Title 企业入库列表
 // @Description get user by token
 // @Success 200 {object} []supplier.OilSupplier

+ 7 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/supplier.js

@@ -20,6 +20,13 @@ export default {
       params: params
     })
   },
+  jZPSListExport (CreateOn, params, myAxios) {
+    return myAxios({
+      url: '/supplier/jzpsListExport?CreateOn=' + CreateOn,
+      method: 'GET',
+      params: params
+    })
+  },
   getStoreList (CreateOn, params, myAxios) {
     return myAxios({
       url: '/supplier/storelist?CreateOn=' + CreateOn,

+ 41 - 2
src/dashoo.cn/frontend_web/src/pages/oilsupplier/supplierps/index.vue

@@ -51,7 +51,7 @@
             </el-dropdown>
           </el-form-item>
           <el-form-item>
-            <el-button type="primary" size="mini" @click="exportExcel">导出</el-button>
+            <el-button type="primary" size="mini" @click="exportExcel" :loading="exportLoading">导出</el-button>
           </el-form-item>
         </el-form>
       </div>
@@ -334,6 +334,7 @@
       return {
         tableLoading: false,
         dialogVisible: false,
+        exportLoading: false,
         AllBusDeptList: [],
         // 列表数据
         entityList: [],
@@ -557,7 +558,7 @@
       },
 
       // 列表打印导出功能
-      exportExcel () {
+      exportExcel1 () {
         /* generate workbook object from table */
         let table = document.querySelector('#rebateSetTable').cloneNode(true) // 克隆备份(原table不动)
         // 因为element-ui的表格的fixed属性导致多出一个table,会下载重复内容,这里删除掉
@@ -583,6 +584,44 @@
         }
         return wbout
       },
+      exportExcel () {
+        this.exportLoading = true
+        // 分页及列表条件
+        let params = {
+          SupplierTypeName: '',
+          Status: '5'
+        }
+        let myCreateOn = []
+        // 解析时间
+        if (this.CreateOn != null && this.CreateOn.length == 2) {
+          this.CreateOn[1].setHours(23)
+          this.CreateOn[1].setMinutes(59)
+          this.CreateOn[1].setSeconds(59)
+          myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
+          myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
+        }
+        // 查询条件
+        Object.assign(params, this.searchForm)
+        // 访问接口
+        api.jZPSListExport(myCreateOn.join(','), params, this.$axios).then(res => {
+          this.$message({
+            type: 'success',
+            message: '导出成功!'
+          })
+          let docUrl = res.data
+          // 内网服务器专用
+          if (process.client && docUrl.indexOf('upfile') === 0) {
+            const myDomain = window.location.host
+            location.href = 'http://' + myDomain + '/' + docUrl
+          } else {
+            location.href = 'http://' + docUrl
+          }
+          this.exportLoading = false
+        }).catch(err => {
+          console.error(err)
+          this.exportLoading = false
+        })
+      },
       searchCommand (command) {
         if (command === 'search') {
           this.dialogVisible = true