|
|
@@ -112,3 +112,122 @@ func (s *SelectService) GetUp( supplierCertTableName string, pageIndex, itemsPer
|
|
|
|
|
|
return total
|
|
|
}
|
|
|
+func (s *SelectService) GetTotalInMonth( orderby string, asc bool, entitiesTotal interface{}, where string) (total int64) {
|
|
|
+ var resultsSlice []map[string][]byte
|
|
|
+ endtime, _ := strconv.Atoi(where)
|
|
|
+ if endtime == 0 {
|
|
|
+ endtime = 5000
|
|
|
+ }else {
|
|
|
+ endtime = endtime+1}
|
|
|
+ timedone := strconv.Itoa(endtime)
|
|
|
+ var sql string
|
|
|
+ sql = `(SELECT AnnualAudit.Month,AnnualAudit,Store,Append,InfoChange,CatalogSelf,CatalogWin,CatalogTrade,CatalogComp,CatalogSpe FROM(
|
|
|
+SELECT b.Month,a.AnnualAudit from (select extract(month from ApplyTime) time ,COUNT(*) AnnualAudit
|
|
|
+ from OilAnnualAudit
|
|
|
+ WHERE ApplyTime >= '` + where +`' AND ApplyTime < '` + timedone +`' AND Status = '11'
|
|
|
+ group by extract(month from ApplyTime)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) AnnualAudit
|
|
|
+LEFT JOIN (SELECT b.Month,a.Store from (select extract(month from ApplyTime) time ,COUNT(*) Store
|
|
|
+ from OilSupplierCert
|
|
|
+ WHERE ApplyTime >= '` + where +`' AND ApplyTime < '` + timedone +`' AND InFlag = '1'
|
|
|
+ group by extract(month from ApplyTime)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) Store ON AnnualAudit.Month = Store.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.Append from (select extract(month from ApplyDate) time ,COUNT(*) Append
|
|
|
+ from OilSupplierCertAppend
|
|
|
+ WHERE ApplyDate >= '` + where +`' AND ApplyDate < '` + timedone +`' AND Status = '11'
|
|
|
+ group by extract(month from ApplyDate)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) Append ON AnnualAudit.Month = Append.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.InfoChange from (select extract(month from CreateOn) time ,COUNT(*) InfoChange
|
|
|
+ from OilInfoChange
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND Status = '11'
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) InfoChange ON AnnualAudit.Month = InfoChange.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogSelf from (select extract(month from CreateOn) time ,COUNT(*) CatalogSelf
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=1
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogSelf ON AnnualAudit.Month = CatalogSelf.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogWin from (select extract(month from CreateOn) time ,COUNT(*) CatalogWin
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=2
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogWin ON AnnualAudit.Month = CatalogWin.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogTrade from (select extract(month from CreateOn) time ,COUNT(*) CatalogTrade
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=3
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogTrade ON AnnualAudit.Month = CatalogTrade.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogComp from (select extract(month from CreateOn) time ,COUNT(*) CatalogComp
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=4
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogComp ON AnnualAudit.Month = CatalogComp.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogSpe from (select extract(month from CreateOn) time ,COUNT(*) CatalogSpe
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=4
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogSpe ON AnnualAudit.Month = CatalogSpe.Month ORDER BY AnnualAudit.Month)
|
|
|
+ union ALL
|
|
|
+ select '合计',sum(AnnualAudit),sum(Store),sum(Append),sum(InfoChange),sum(CatalogSelf),sum(CatalogWin),sum(CatalogTrade),sum(CatalogComp),sum(CatalogSpe) from (SELECT AnnualAudit.Month,AnnualAudit,Store,Append,InfoChange,CatalogSelf,CatalogWin,CatalogTrade,CatalogComp,CatalogSpe FROM(
|
|
|
+SELECT b.Month,a.AnnualAudit from (select extract(month from ApplyTime) time ,COUNT(*) AnnualAudit
|
|
|
+ from OilAnnualAudit
|
|
|
+ WHERE ApplyTime >= '` + where +`' AND ApplyTime < '` + timedone +`' AND Status = '11'
|
|
|
+ group by extract(month from ApplyTime)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) AnnualAudit
|
|
|
+LEFT JOIN (SELECT b.Month,a.Store from (select extract(month from ApplyTime) time ,COUNT(*) Store
|
|
|
+ from OilSupplierCert
|
|
|
+ WHERE ApplyTime >= '` + where +`' AND ApplyTime < '` + timedone +`' AND InFlag = '1'
|
|
|
+ group by extract(month from ApplyTime)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) Store ON AnnualAudit.Month = Store.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.Append from (select extract(month from ApplyDate) time ,COUNT(*) Append
|
|
|
+ from OilSupplierCertAppend
|
|
|
+ WHERE ApplyDate >= '` + where +`' AND ApplyDate < '` + timedone +`' AND Status = '11'
|
|
|
+ group by extract(month from ApplyDate)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) Append ON AnnualAudit.Month = Append.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.InfoChange from (select extract(month from CreateOn) time ,COUNT(*) InfoChange
|
|
|
+ from OilInfoChange
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND Status = '11'
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) InfoChange ON AnnualAudit.Month = InfoChange.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogSelf from (select extract(month from CreateOn) time ,COUNT(*) CatalogSelf
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=1
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogSelf ON AnnualAudit.Month = CatalogSelf.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogWin from (select extract(month from CreateOn) time ,COUNT(*) CatalogWin
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=2
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogWin ON AnnualAudit.Month = CatalogWin.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogTrade from (select extract(month from CreateOn) time ,COUNT(*) CatalogTrade
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=3
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogTrade ON AnnualAudit.Month = CatalogTrade.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogComp from (select extract(month from CreateOn) time ,COUNT(*) CatalogComp
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=4
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogComp ON AnnualAudit.Month = CatalogComp.Month
|
|
|
+LEFT JOIN (SELECT b.Month,a.CatalogSpe from (select extract(month from CreateOn) time ,COUNT(*) CatalogSpe
|
|
|
+ from OilCatalog
|
|
|
+ WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=4
|
|
|
+ group by extract(month from CreateOn)) a
|
|
|
+ RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogSpe ON AnnualAudit.Month = CatalogSpe.Month) countTotal`
|
|
|
+
|
|
|
+ //if asc {
|
|
|
+ // sql += ` order by ` + orderby + ` ASC `
|
|
|
+ //} else {
|
|
|
+ // sql += ` order by ` + orderby + ` DESC `
|
|
|
+ //}
|
|
|
+ s.DBE.SQL(sql).Find(entitiesTotal)
|
|
|
+ if len(resultsSlice) > 0 {
|
|
|
+ results := resultsSlice[0]
|
|
|
+ for _, value := range results {
|
|
|
+ total, _ = strconv.ParseInt(string(value), 10, 64)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return total
|
|
|
+}
|