Ver código fonte

后端: 上报情况

baichengfei 4 anos atrás
pai
commit
7985d1bac8

+ 28 - 25
src/dashoo.cn/backend/api/business/oilcontract/contract/contract.go

@@ -76,25 +76,25 @@ type OilContract struct {
 	ImportSupplierName   string    `json:"ImportSupplierName" xorm:"comment('导入公司名') VARCHAR(255) 'ImportSupplierName'"`
 	IsYear               int       `json:"IsYear" xorm:"comment('0未跨年,1跨年') int(2) 'IsYear'"`
 	ImportSecondUnit     string    `json:"ImportSecondUnit" xorm:"comment('导入二级单位') VARCHAR(255) 'ImportSecondUnit'"`
-	ClassName     	 	 string    `json:"ClassName" xorm:"comment('类别') VARCHAR(255) 'ClassName'"`
-	SecondUnitName     	 string    `json:"SecondUnitName" xorm:"comment('二级单位名') VARCHAR(255) 'SecondUnitName'"`
+	ClassName            string    `json:"ClassName" xorm:"comment('类别') VARCHAR(255) 'ClassName'"`
+	SecondUnitName       string    `json:"SecondUnitName" xorm:"comment('二级单位名') VARCHAR(255) 'SecondUnitName'"`
 }
 type OilContractMoney struct {
-	Id                   int       `json:"Id" xorm:"not null pk autoincr INT(11) 'Id'"`
-	ContractId           int       `json:"ContractId" xorm:"default 0 comment('合同ID') INT(11) 'ContractId'"`
-	Year         		 string    `json:"Year" xorm:"comment('年份') VARCHAR(50) 'Year'"`
-	Money          		 string    `json:"Money" xorm:"comment('当年结算金额') VARCHAR(255) 'Money'"`
-	CreateOn             time.Time `json:"CreateOn" xorm:"DATETIME 'CreateOn'"`
-	CreateUserId         int       `json:"CreateUserId" xorm:"INT(11) 'CreateUserId'"`
-	CreateBy             string    `json:"CreateBy" xorm:"VARCHAR(50) 'CreateBy'"`
-	ModifiedOn           time.Time `json:"ModifiedOn" xorm:"DATETIME 'ModifiedOn'"`
-	ModifiedUserId       int       `json:"ModifiedUserId" xorm:"INT(11) 'ModifiedUserId'"`
-	ModifiedBy           string    `json:"ModifiedBy" xorm:"default '1' VARCHAR(50) 'ModifiedBy'"`
+	Id             int       `json:"Id" xorm:"not null pk autoincr INT(11) 'Id'"`
+	ContractId     int       `json:"ContractId" xorm:"default 0 comment('合同ID') INT(11) 'ContractId'"`
+	Year           string    `json:"Year" xorm:"comment('年份') VARCHAR(50) 'Year'"`
+	Money          string    `json:"Money" xorm:"comment('当年结算金额') VARCHAR(255) 'Money'"`
+	CreateOn       time.Time `json:"CreateOn" xorm:"DATETIME 'CreateOn'"`
+	CreateUserId   int       `json:"CreateUserId" xorm:"INT(11) 'CreateUserId'"`
+	CreateBy       string    `json:"CreateBy" xorm:"VARCHAR(50) 'CreateBy'"`
+	ModifiedOn     time.Time `json:"ModifiedOn" xorm:"DATETIME 'ModifiedOn'"`
+	ModifiedUserId int       `json:"ModifiedUserId" xorm:"INT(11) 'ModifiedUserId'"`
+	ModifiedBy     string    `json:"ModifiedBy" xorm:"default '1' VARCHAR(50) 'ModifiedBy'"`
 }
 
 type OilContractMoney1 struct {
-	Year         		 string    `json:"Year" xorm:"comment('年份') VARCHAR(50) 'Year'"`
-	Money          		 string    `json:"Money" xorm:"comment('当年结算金额') VARCHAR(255) 'Money'"`
+	Year  string `json:"Year" xorm:"comment('年份') VARCHAR(50) 'Year'"`
+	Money string `json:"Money" xorm:"comment('当年结算金额') VARCHAR(255) 'Money'"`
 }
 
 type OilContractItems struct {
@@ -102,18 +102,21 @@ type OilContractItems struct {
 }
 
 type HandOnStatisticsEntity struct {
-	SecondUnit		string
-	ContractNum		int
-	HasNum			int
+	SecondUnit  string
+	ContractNum int
+	HasNum      int
+	FinishNum   int
+	ReportedNum int
+	UnReportNum int
 }
 
 type HandOnStatisticsQuery struct {
-	PageIndex		int64
-	ItemsPerPage 	int64
-	Order 			string
-	Prop 			string
-	Asc 			string
-	SecondUnit		string
-	YearNum			int
-	SupplierType	string
+	PageIndex    int64
+	ItemsPerPage int64
+	Order        string
+	Prop         string
+	Asc          string
+	SecondUnit   string
+	YearNum      int
+	SupplierType string
 }

+ 19 - 12
src/dashoo.cn/backend/api/business/oilcontract/contract/contractService.go

@@ -16,16 +16,23 @@ func GetOilContractService(xormEngine *xorm.Engine) *OilContractService {
 	return s
 }
 
-func (s *OilContractService) GetHandOnStatisticsList (queryParam HandOnStatisticsQuery, entitiesPtr interface{}) (total int64) {
-	if queryParam.PageIndex < 1 { queryParam.PageIndex = 1 }
-	if queryParam.ItemsPerPage < 1 { queryParam.ItemsPerPage = 10 }
+func (s *OilContractService) GetHandOnStatisticsList(queryParam HandOnStatisticsQuery, entitiesPtr interface{}) (total int64) {
+	if queryParam.PageIndex < 1 {
+		queryParam.PageIndex = 1
+	}
+	if queryParam.ItemsPerPage < 1 {
+		queryParam.ItemsPerPage = 10
+	}
 	// var resultsSlice []map[string][]byte
 	/*sqlCount := "SELECT COUNT(*) " +
-		         " FROM OilContract a " +
-		         " LEFT JOIN OilContractReview b ON b.ContractId=a.Id " +
-		         " GROUP BY a.SecondUnit "*/
-
-	sql := "SELECT c.FullName as SecondUnit, COUNT(DISTINCT a.Id) AS ContractNum,  COUNT(DISTINCT b.ContractId) AS HasNum " +
+	  " FROM OilContract a " +
+	  " LEFT JOIN OilContractReview b ON b.ContractId=a.Id " +
+	  " GROUP BY a.SecondUnit "*/
+
+	sql := "SELECT c.FullName as SecondUnit, COUNT(DISTINCT a.Id) AS ContractNum,  COUNT(DISTINCT b.ContractId) AS HasNum, " +
+		" COUNT(DISTINCT IF(b.Status = 8, b.ContractId, null)) AS FinishNum, " +
+		" COUNT(DISTINCT IF(b.Status > 2, b.ContractId, null)) AS ReportedNum, " +
+		" (COUNT(DISTINCT a.Id) - COUNT(DISTINCT IF(b.Status > 2, b.ContractId, NULL))) AS UnReportNum " +
 		" FROM OilContract a " +
 		" LEFT JOIN OilContractReview b ON a.Id = b.ContractId " +
 		" LEFT JOIN Base_Organize c on SecondUnit = c.Id"
@@ -43,11 +50,11 @@ func (s *OilContractService) GetHandOnStatisticsList (queryParam HandOnStatistic
 	}
 
 	if queryParam.Order != "" {
-		sql += " ORDER BY " + queryParam.Prop  + " " + queryParam.Order
+		sql += " ORDER BY " + queryParam.Prop + " " + queryParam.Order
 	}
 
-	startLimit := int((queryParam.PageIndex-1) * queryParam.ItemsPerPage)
-	endLimit := int((queryParam.PageIndex) * queryParam.ItemsPerPage)
+	startLimit := 0
+	endLimit := 10000
 	var totalCnt int64
 	totalCnt, _ = s.DBE.SQL(sql).Limit(startLimit, endLimit).FindAndCount(entitiesPtr)
 
@@ -69,4 +76,4 @@ func (s *OilContractService) GetList(entitiesPtr interface{}, where string) {
 	sql += ` where ` + where
 
 	s.DBE.SQL(sql).Find(entitiesPtr)
-}
+}

+ 11 - 10
src/dashoo.cn/backend/api/controllers/oilcontract/contract.go

@@ -824,7 +824,7 @@ func (this *OilContractController) ImportUpdate() {
 		_, err = utils.DBE.Query(sql)
 	}
 	if Column == "ContractNo" {
-		svc.GetEntityByWhere("OilContract", "ContractNo = '" + Value + "' and Id != " + Id, &con)
+		svc.GetEntityByWhere("OilContract", "ContractNo = '"+Value+"' and Id != "+Id, &con)
 		if Value == "" {
 			errinfo.Message = "修改失败!合同编号不能为空"
 			errinfo.Code = -1
@@ -972,7 +972,7 @@ func (this *OilContractController) AddEntity() {
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
 	model.SecondUnit = this.User.UnitId
 	var org organize.Base_Organize
-	svc.GetEntityByWhere("Base_Organize", "Id = " + strconv.Itoa(this.User.UnitId), &org)
+	svc.GetEntityByWhere("Base_Organize", "Id = "+strconv.Itoa(this.User.UnitId), &org)
 	if org.Id > 0 {
 		model.SecondUnitName = org.Fullname
 	}
@@ -1196,8 +1196,8 @@ func (this *OilContractController) UpdateEntity() {
 	}
 	date := time.Now().Format("2006-01-02")
 	date1 := model.EndDate.Format("2006-01-02")
-	if date >= date1 && model.IsYear == 1{
-		model.YearDate = model.EndDate.AddDate(1,0,0)
+	if date >= date1 && model.IsYear == 1 {
+		model.YearDate = model.EndDate.AddDate(1, 0, 0)
 	}
 
 	err := svc.UpdateEntityBytbl(OilContractName, id, &model, cols)
@@ -1298,7 +1298,7 @@ func (this *OilContractController) CountMoney() {
 
 	var model contract.OilContractMoney
 	svc := contract.GetOilContractService(utils.DBE)
-	svc.GetSum1(&model, "ContractId = " + Id + " and Year != '"+time.Now().Format("2006")+"'")
+	svc.GetSum1(&model, "ContractId = "+Id+" and Year != '"+time.Now().Format("2006")+"'")
 	this.Data["json"] = &model
 	this.ServeJSON()
 }
@@ -1321,7 +1321,7 @@ func (this *OilContractController) YearList() {
 
 	var model []contract.OilContractMoney1
 	svc := contract.GetOilContractService(utils.DBE)
-	svc.GetList(&model, "ContractId = " + Id)
+	svc.GetList(&model, "ContractId = "+Id)
 	this.Data["json"] = &model
 	this.ServeJSON()
 }
@@ -1332,7 +1332,8 @@ func (this *OilContractController) YearList() {
 // @router /need-eva-list [get]
 func (this *OilContractController) GetNeedEvaList() {
 	var list []contract.OilContract
-	sql := ` select a.* from OilContract a left join OilContractReview b on b.ContractId=a.Id where a.SecondUnit=` + strconv.Itoa(this.User.UnitId) + ` and (b.Status=0 or b.Status=NULL)  `
+	// TODO 加年度
+	sql := ` select a.* from OilContract a left join OilContractReview b on b.ContractId=a.Id where a.ImportStatus > 0 and a.SecondUnit=` + strconv.Itoa(this.User.UnitId) + ` and (b.Status < 0 or b.Status=NULL)  `
 	utils.DBE.Sql(sql).Find(&list)
 
 	var dataInfo DataInfo
@@ -1387,7 +1388,7 @@ func (this *OilContractController) UpdateUnitName() {
 	UnitId := this.GetString("UnitId")
 	ContractId := this.GetString("ContractId")
 	var errinfo ErrorInfo
-	if Id == "" || UnitId == ""{
+	if Id == "" || UnitId == "" {
 		errinfo.Message = "操作失败!请求信息不完整"
 		errinfo.Code = -2
 		this.Data["json"] = &errinfo
@@ -1398,9 +1399,9 @@ func (this *OilContractController) UpdateUnitName() {
 	var model contract.OilContract
 	svc := contract.GetOilContractService(utils.DBE)
 	var org organize.Base_Organize
-	svc.GetEntityByWhere("Base_Organize", "Id = " + UnitId, &org)
+	svc.GetEntityByWhere("Base_Organize", "Id = "+UnitId, &org)
 
-	model.SecondUnit ,_= strconv.Atoi(UnitId)
+	model.SecondUnit, _ = strconv.Atoi(UnitId)
 	model.SecondUnitName = org.Fullname
 	where := "SecondUnit = " + Id
 	if ContractId != "" {