Bladeren bron

后:首页统计接口;hse导出60改23

wd 4 jaren geleden
bovenliggende
commit
30f0c0f2bf

+ 19 - 20
src/dashoo.cn/backend/api/business/oilrtx/RtxService.go

@@ -6,7 +6,6 @@ import (
 	"io/ioutil"
 	"log"
 	"net/http"
-	"net/url"
 	"strconv"
 	"strings"
 	"time"
@@ -183,30 +182,30 @@ func (s *RtxService) HandleSendMsg(username string, tomobile string, message str
 
 func (s *RtxService) HandlePtrLogin(username string, password string, BaseUser string) int {
 
-	//client := &http.Client{}
-	//var ptrUser PtrUser
-	//
-	//ptrUser.UserName = username
-	//ptrUser.PassWord = password
-	//
-	//reqJson, err := json.Marshal(ptrUser)
-	//params := string(reqJson)
-	//
-	//ptrUrl := utils.Cfg.MustValue("PtrUrl", "ptrUrl")
-	//
-	//req, err := http.NewRequest("post", ptrUrl, strings.NewReader(params))
-	//req.Header.Add("Content-Type", "application/json")
-	////req.Header.Add("X-Token", "HJpczmIJr9z26t9KcV0i1OsBE9RXFeuyhuN9MdV+Ts/FlUjCgDOxaaubo9DkF91t+X2MCxBqX6s=")
+	client := &http.Client{}
+	var ptrUser PtrUser
+
+	ptrUser.UserName = username
+	ptrUser.PassWord = password
 
-	//resp, err := client.Do(req)
+	reqJson, err := json.Marshal(ptrUser)
+	params := string(reqJson)
 
 	ptrUrl := utils.Cfg.MustValue("PtrUrl", "ptrUrl")
 
-	v := make(url.Values)
-	v.Add("UserName", username)
-	v.Add("PassWord", password)
+	req, err := http.NewRequest("post", ptrUrl, strings.NewReader(params))
+	req.Header.Add("Content-Type", "application/json")
+	////req.Header.Add("X-Token", "HJpczmIJr9z26t9KcV0i1OsBE9RXFeuyhuN9MdV+Ts/FlUjCgDOxaaubo9DkF91t+X2MCxBqX6s=")
+
+	resp, err := client.Do(req)
 
-	resp, err := http.PostForm(ptrUrl, v)
+	//ptrUrl := utils.Cfg.MustValue("PtrUrl", "ptrUrl")
+	//
+	//v := make(url.Values)
+	//v.Add("UserName", username)
+	//v.Add("PassWord", password)
+	//
+	//resp, err := http.PostForm(ptrUrl, v)
 
 	if err != nil {
 		log.Println("err= ", err)

+ 31 - 6
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplier.go

@@ -396,10 +396,10 @@ type OilSupplierExport struct {
 	CheckUnitName    string    //推荐单位
 	CreateOn         time.Time //申请时间
 	Remark           string
-	RecUnitName           string
-	SupplierTypeName           string
-	Currency           string
-	SubName           string
+	RecUnitName      string
+	SupplierTypeName string
+	Currency         string
+	SubName          string
 }
 
 type OilSupplierSelect struct {
@@ -463,8 +463,8 @@ type OilSupplierSelect2 struct {
 	Street           string    //注册区
 	InStyle          string    //准入方式
 	InFlag           string    //状态
-	FileList []supplierfile.OilSupplierFileSelect
-	SubList []suppliercertsub.OilSupplierCertSubSelect
+	FileList         []supplierfile.OilSupplierFileSelect
+	SubList          []suppliercertsub.OilSupplierCertSubSelect
 }
 
 type OilSupplierContrast struct {
@@ -738,6 +738,31 @@ type OilSupplierOldName struct {
 	ModifiedBy     string    `xorm:"VARCHAR(50)"`
 }
 
+type StatisticalNum struct {
+	GoodsNum           int
+	TecNum             int
+	BasNum             int
+	ReviewNum          int
+	TenderNum          int
+	StrategicNum       int
+	OneLevelGoodsNum   int
+	TwoLevelMakeNum    int
+	TwoLevelNotMakeNum int
+	RegCapitalSmall    int
+	RegCapital2        int
+	RegCapital3        int
+	RegCapital4        int
+	RegCapitalBig      int
+}
+
+type TodoNum struct {
+	SupplierNum   int
+	AppendNum     int
+	AnnualNum     int
+	InfoChangeNum int
+	EvaluationNum int
+}
+
 const (
 	// 管理单位
 	MGRUNIT           string = "大港油田分公司"

+ 347 - 3
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -1,15 +1,24 @@
 package oilsupplier
 
 import (
+	"dashoo.cn/backend/api/business/invoiceinfo"
+	"dashoo.cn/backend/api/business/oilcontract/contract"
+	"dashoo.cn/backend/api/business/oilcontract/contractReview"
+	"dashoo.cn/backend/api/business/oilcontract/contractSumScore"
 	"dashoo.cn/backend/api/business/oilsupplier/annualaudit"
 	BlackList "dashoo.cn/backend/api/business/oilsupplier/blacklist"
+	"dashoo.cn/backend/api/business/oilsupplier/infochange"
+	"dashoo.cn/backend/api/business/oilsupplier/oilcatalog"
+	"dashoo.cn/backend/api/business/oilsupplier/oilcatalogsub"
 	"dashoo.cn/backend/api/business/oilsupplier/qualchange"
+	"dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
 	"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
 	"dashoo.cn/backend/api/business/oilsupplier/supplierscenefile"
 	"dashoo.cn/backend/api/business/oilsupplier/tableheader"
 	"dashoo.cn/backend/api/business/register"
+	"dashoo.cn/backend/api/business/todolist"
 	"dashoo.cn/business3/parameter"
 	"encoding/json"
 	"fmt"
@@ -4299,11 +4308,11 @@ func (this *OilSupplierController) RecoverCertSub() {
 		log.Println("共查询到准入条数:", len(allCertList))
 		for _, certEntity := range allCertList {
 			var certSub []suppliercertsub.OilSupplierCertSub
-			where1 := "SupplierTypeCode = '" +  certEntity.SupplierTypeCode + "' and SupplierCertId = " + strconv.Itoa(certEntity.Id)
+			where1 := "SupplierTypeCode = '" + certEntity.SupplierTypeCode + "' and SupplierCertId = " + strconv.Itoa(certEntity.Id)
 			certService.GetEntitysByWhere("OilSupplierCertSub2", where1, &certSub)
 			for _, sub := range certSub {
 				var certSubEntity suppliercertsub.OilSupplierCertSub
-				where2 := "SupplierTypeCode = '" +  certEntity.SupplierTypeCode + "' and SupplierCertId = " + strconv.Itoa(certEntity.Id) + " and Name = '" + sub.Name + "'"
+				where2 := "SupplierTypeCode = '" + certEntity.SupplierTypeCode + "' and SupplierCertId = " + strconv.Itoa(certEntity.Id) + " and Name = '" + sub.Name + "'"
 				certService.GetEntityByWhere("OilSupplierCertSub", where2, &certSubEntity)
 				if certSubEntity.Id == 0 {
 					// 插入
@@ -4313,4 +4322,339 @@ func (this *OilSupplierController) RecoverCertSub() {
 		}
 	}
 	log.Println("结束")
-}
+}
+
+// @Title 首页统计饼图
+// @Description 首页统计饼图
+// @Success 200 {object}
+// @router /statisticalNum [get]
+func (this *OilSupplierController) StatisticalNum() {
+	certService := suppliercert.GetOilSupplierCertService(utils.DBE)
+	var statisticalNum supplier.StatisticalNum
+	var supplierGoods []suppliercert.OilSupplierCert
+	certService.GetEntitysByWhere(OilSupplierCertName, "SupplierTypeCode = '01'", &supplierGoods)
+	statisticalNum.GoodsNum = len(supplierGoods)
+
+	var supplierBas []suppliercert.OilSupplierCert
+	certService.GetEntitysByWhere(OilSupplierCertName, "SupplierTypeCode = '02'", &supplierBas)
+	statisticalNum.BasNum = len(supplierBas)
+
+	var supplierTec []suppliercert.OilSupplierCert
+	certService.GetEntitysByWhere(OilSupplierCertName, "SupplierTypeCode = '03'", &supplierTec)
+	statisticalNum.TecNum = len(supplierTec)
+
+	var supplierReview []suppliercert.OilSupplierCert
+	certService.GetEntitysByWhere(OilSupplierCertName, "InStyle = 1", &supplierReview)
+	statisticalNum.ReviewNum = len(supplierReview)
+
+	var supplierTender []suppliercert.OilSupplierCert
+	certService.GetEntitysByWhere(OilSupplierCertName, "InStyle = 6", &supplierTender)
+	statisticalNum.TenderNum = len(supplierTender)
+
+	var supplierStrategic []suppliercert.OilSupplierCert
+	certService.GetEntitysByWhere(OilSupplierCertName, "InStyle = 4", &supplierStrategic)
+	statisticalNum.StrategicNum = len(supplierStrategic)
+
+	var OneLevelGoodsNum []supplier.OilSupplier
+	svc := supplier.GetOilSupplierService(utils.DBE)
+	total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 10, 1, "a.Id", false, &OneLevelGoodsNum, "a.Grade = '1' and b.SupplierTypeCode = '01'")
+	statisticalNum.OneLevelGoodsNum = int(total)
+
+	var TwoLevelMakeNum []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "Grade = '2' and OperType = '制造商'", &TwoLevelMakeNum)
+	statisticalNum.TwoLevelMakeNum = len(TwoLevelMakeNum)
+
+	var TwoLevelNotMakeNum []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "Grade = '2' and (OperType = '贸易商' or OperType = '代理商')", &TwoLevelNotMakeNum)
+	statisticalNum.TwoLevelNotMakeNum = len(TwoLevelNotMakeNum)
+
+	var RegCapitalSmall []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "RegCapital < 500", &RegCapitalSmall)
+	statisticalNum.RegCapitalSmall = len(RegCapitalSmall)
+
+	var RegCapital2 []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "RegCapital >= 500 and RegCapital < 1000", &RegCapital2)
+	statisticalNum.RegCapital2 = len(RegCapital2)
+
+	var RegCapital3 []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "RegCapital >= 1000 and RegCapital < 2000", &RegCapital3)
+	statisticalNum.RegCapital3 = len(RegCapital3)
+
+	var RegCapital4 []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "RegCapital >= 2000 and RegCapital < 5000", &RegCapital4)
+	statisticalNum.RegCapital4 = len(RegCapital4)
+
+	var RegCapitalBig []supplier.OilSupplier
+	certService.GetEntitysByWhere(OilSupplierName, "RegCapital >= 5000", &RegCapitalBig)
+	statisticalNum.RegCapitalBig = len(RegCapitalBig)
+
+	this.Data["json"] = &statisticalNum
+	this.ServeJSON()
+}
+
+// @Title 首页统计待办
+// @Description 首页统计图标
+// @Success 200 {object}
+// @router /todoNum [get]
+func (this *OilSupplierController) TodoNum() {
+	var todo supplier.TodoNum
+	todo.SupplierNum = this.GetTodoNum("1")
+	todo.AppendNum = this.GetTodoNum("2")
+	todo.AnnualNum = this.GetTodoNum("3")
+	todo.InfoChangeNum = this.GetTodoNum("4")
+	todo.EvaluationNum = this.GetTodoNum("10") // 业绩评价
+
+	this.Data["json"] = &todo
+	this.ServeJSON()
+}
+
+func (this *OilSupplierController) GetTodoNum(stype string) int {
+	wfNames := ""
+	//wfNames = workflow.OIL_ENUSER_SUPPLIER_APPLY  + "," + workflow.OIL_ENUSER_APPEND_APPLY + "," + workflow.OIL_INFO_CHANGE + "," + workflow.OIL_AUDIT_APPLY + "," + workflow.OIL_SUPPLIER_VERIFY+ "," + workflow.OIL_DAILY_CONTRACT_EVALUATION+ "," + workflow.OIL_ANNUAL_CONTRACT_EVALUATION+ "," + workflow.OIL_Catalog+ "," + workflow.OIL_REGISTER_APPLY
+	if stype == "1" {
+		wfNames = workflow.OIL_ENUSER_SUPPLIER_APPLY
+	} else if stype == "2" {
+		wfNames = workflow.OIL_ENUSER_APPEND_APPLY
+	} else if stype == "3" {
+		wfNames = workflow.OIL_AUDIT_APPLY
+	} else if stype == "4" {
+		wfNames = workflow.OIL_INFO_CHANGE
+	} else if stype == "5" {
+		wfNames = workflow.OIL_REGISTER_APPLY
+	} else if stype == "7" {
+		// wfNames = workflow.OIL_SUPPLIER_INSTORE
+	} else if stype == "8" {
+		wfNames = workflow.OIL_SUPPLIER_VERIFY
+	} else if stype == "9" {
+		wfNames = workflow.OIL_Catalog
+	} else if stype == "10" {
+		wfNames = workflow.OIL_DAILY_CONTRACT_EVALUATION
+	} else if stype == "11" {
+		wfNames = workflow.OIL_ANNUAL_CONTRACT_EVALUATION
+	} else if stype == "12" {
+		wfNames = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS
+	}
+	var todoliststemp []todolist.TodoList
+
+	var pagingResult workflow.ActiMyPagingResultVM
+	var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
+	actisvc := workflow.GetActivitiService(utils.DBE)
+
+	pagingResult = actisvc.GetMyAllTypePagingTasksWithTime(this.User.Id, 1000, 1, wfNames, "", "")
+	myTasksRetWithTimes = pagingResult.TaskList
+
+	var jzpsCount int64 = 0 // 准入集中评审的数量
+	for _, item := range myTasksRetWithTimes {
+		wfName := strings.Split(item.ProcessDefinitionId, ":")[0]
+		if (item.TaskName == "集中评审") && (wfName == workflow.OIL_ENUSER_SUPPLIER_APPLY) {
+			jzpsCount++
+		}
+	}
+	pagingResult.Total = pagingResult.Total - jzpsCount
+	//取出各种类型的ID
+	for _, item := range myTasksRetWithTimes {
+		idx := strings.Index(item.BusinessKey, "-")
+		id := item.BusinessKey
+		if idx >= 0 {
+			id = strings.Split(item.BusinessKey, "-")[0]
+		}
+		//工作流名称
+		has := false
+		wfName := strings.Split(item.ProcessDefinitionId, ":")[0] //如:oil_enuser_supplier_apply:2:2543
+		if wfName == workflow.OIL_ENUSER_SUPPLIER_APPLY {
+			if item.TaskName == "集中评审" {
+				// 集中评审不显示在待办列表
+				continue
+			}
+			//准入
+			where := " 1=1 "
+			where = where + " and b.Id = '" + id + "'"
+			var todo todolist.TodoList
+			svc := supplier.GetOilSupplierService(utils.DBE)
+			has = svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, where)
+			if has {
+				todo.Type = todolist.SUPPLIER
+				todo.UserName = this.User.Realname
+				todo.CreateTime = item.CreateTime
+				todo.TaskName = item.TaskName
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_ENUSER_APPEND_APPLY {
+			//增项
+			where := " 1=1 "
+			where = where + " and b.Id = '" + id + "'"
+			var todo todolist.TodoList
+			var certAppend suppliercertappend.OilSupplierCertAppend
+			svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
+			has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, where)
+			svcapp.GetEntityById(id, &certAppend)
+			if has {
+				todo.Id = certAppend.Id
+				todo.SupplierId = strconv.Itoa(certAppend.SupplierId)
+				todo.CertId = strconv.Itoa(certAppend.SupplierCertId)
+				todo.Type = todolist.CERTAPPEND
+				todo.TaskName = item.TaskName
+				todo.UserName = this.User.Realname
+				todo.CreateTime = item.CreateTime
+				todoliststemp = append(todoliststemp, todo)
+			}
+
+		} else if wfName == workflow.OIL_AUDIT_APPLY {
+			//年审
+			var todo todolist.TodoList
+			var listannu annualaudit.OilAnnualAudit
+			svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
+			has = svc.GetEntityById(id, &listannu)
+			if has {
+				todo.Id = listannu.Id
+				todo.SupplierId = strconv.Itoa(listannu.SupplierId)
+				todo.Type = todolist.ANNUALAUDIT
+				todo.SupplierName = listannu.SupplierName
+				todo.UserName = this.User.Realname
+				todo.TaskName = item.TaskName
+				todo.SupplierTypeCode = listannu.SupplierTypeName
+				todo.Step = strconv.Itoa(listannu.Step)
+				todo.Status = listannu.Status
+				todo.CertId = strconv.Itoa(listannu.CerId)
+				todo.CreateTime = item.CreateTime
+				todoliststemp = append(todoliststemp, todo)
+			}
+
+		} else if wfName == workflow.OIL_INFO_CHANGE {
+			//资质变更
+			var todo todolist.TodoList
+			var listInfo infochange.OilInfoChange
+			svc := infochange.GetInfoChangeService(utils.DBE)
+			has = svc.GetEntityById(id, &listInfo)
+			if has {
+				todo.Id = listInfo.Id
+				todo.Type = todolist.INFOCHANGE
+				todo.SupplierId = strconv.Itoa(listInfo.SupplierId)
+				todo.SupplierName = listInfo.SupplierName
+				todo.UserName = this.User.Realname
+				todo.TaskName = item.TaskName
+				todo.SupplierTypeCode = todolist.INFOCHANGE // listInfo.SupplierTypeName
+				todo.Status = listInfo.Status
+				todo.CreateTime = item.CreateTime
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_REGISTER_APPLY {
+			//企业用户注册
+			var todo todolist.TodoList
+			regsvc := register.GetOilCorporateInfoService(utils.DBE)
+			var listinfo register.OilCorporateInfo
+			has = regsvc.GetEntityById(id, &listinfo)
+			if has {
+				todo.Id = listinfo.Id
+				todo.Type = todolist.REGISTER
+				todo.SupplierName = listinfo.SupplierName
+				todo.UserName = this.User.Realname
+				todo.TaskName = item.TaskName
+				todo.SupplierTypeCode = todolist.REGISTER
+				todo.Status = strconv.Itoa(listinfo.CheckStatus)
+				todo.CreateTime = item.CreateTime
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_SUPPLIER_VERIFY {
+			//待开发票
+			var todo todolist.TodoList
+			regsvc := invoiceinfo.GetInvoiceService(utils.DBE)
+			var listinfo invoiceinfo.OilInvoiceInfo
+			has = regsvc.GetEntityById(id, &listinfo)
+			if has {
+				todo.Id = listinfo.Id
+				todo.Type = todolist.INVOICE
+				todo.SupplierName = listinfo.SupplierName
+				todo.UserName = this.User.Realname
+				todo.TaskName = item.TaskName
+				todo.SupplierTypeCode = todolist.INVOICE
+				todo.Status = "未开"
+				todo.CreateTime = item.CreateTime
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_Catalog {
+			// 目录审批
+			var todo todolist.TodoList
+			regsvc := invoiceinfo.GetInvoiceService(utils.DBE)
+			var listinfo oilcatalogsub.OilCatalogSub
+			has = regsvc.GetEntityById(id, &listinfo)
+			if has {
+				var list oilcatalog.OilCatalog
+				regsvc.GetEntity(&list, "SubId="+strconv.Itoa(listinfo.Id))
+				todo.Id = listinfo.Id
+				todo.Type = todolist.INCOME
+				todo.SupplierName = list.CompanyName
+				todo.UserName = this.User.Realname
+				todo.TaskName = item.TaskName
+				if listinfo.Type == "6" {
+					todo.SupplierTypeCode = todolist.INCOME + "-6"
+				} else if listinfo.Type == "7" {
+					todo.SupplierTypeCode = todolist.INCOME + "-7"
+				}
+				todo.Status = listinfo.Status
+				todo.CreateTime = item.CreateTime
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_DAILY_CONTRACT_EVALUATION {
+			// 合同日常评审
+			var todo todolist.TodoList
+			conRev := contractReview.GetOilContractReviewService(utils.DBE)
+			var contractReviewEntity contractReview.OilContractReview
+			has = conRev.GetEntityById(id, &contractReviewEntity)
+			contractSvc := contract.GetOilContractService(utils.DBE)
+			var contractEntity contract.OilContract
+			contractSvc.GetEntityById(contractReviewEntity.ContractId, &contractEntity)
+			if has {
+				todo.Id = contractReviewEntity.Id
+				todo.Type = todolist.DAILY
+				todo.TaskName = item.TaskName
+				todo.UserName = this.User.Realname
+				todo.CreateTime = item.CreateTime
+				todo.SupplierTypeCode = contractEntity.ContractClass
+				todo.SupplierName = contractEntity.SupplierName
+				todo.Status = contractReviewEntity.Status
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_ANNUAL_CONTRACT_EVALUATION {
+			// 合同年度评审
+			var todo todolist.TodoList
+			conRev := contractSumScore.GetOilContractSumScoreService(utils.DBE)
+			var contractSumEntity contractSumScore.OilContractSumScore
+			has = conRev.GetEntityById(id, &contractSumEntity)
+
+			if has {
+				todo.Id = contractSumEntity.Id
+				todo.Type = todolist.ANNUAL
+				todo.TaskName = item.TaskName
+				todo.UserName = this.User.Realname
+				todo.CreateTime = item.CreateTime
+				todo.SupplierTypeCode = contractSumEntity.ContractClass
+				todo.SupplierName = contractSumEntity.SupplierName
+				todo.Status = contractSumEntity.Status
+				todoliststemp = append(todoliststemp, todo)
+			}
+		} else if wfName == workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS {
+			// 专业处室提交的合同日常评审
+			var todo todolist.TodoList
+			conRev := contractReview.GetOilContractReviewService(utils.DBE)
+			var contractReviewEntity contractReview.OilContractReview
+			has = conRev.GetEntityById(id, &contractReviewEntity)
+			contractSvc := contract.GetOilContractService(utils.DBE)
+			var contractEntity contract.OilContract
+			contractSvc.GetEntityById(contractReviewEntity.ContractId, &contractEntity)
+			if has {
+				todo.Id = contractReviewEntity.Id
+				todo.Type = todolist.DAILY_BUSINESS
+				todo.TaskName = item.TaskName
+				todo.UserName = this.User.Realname
+				todo.CreateTime = item.CreateTime
+				todo.SupplierTypeCode = contractEntity.ContractClass
+				todo.SupplierName = contractEntity.SupplierName
+				todo.Status = contractReviewEntity.Status
+				todoliststemp = append(todoliststemp, todo)
+			}
+		}
+	}
+
+	return int(pagingResult.Total)
+}