|
@@ -21,7 +21,7 @@ func GetSelectService(xormEngine *xorm.Engine) *SelectService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, supplierCertTableName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
|
|
func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, supplierCertTableName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
|
|
|
- OilSupplierFileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where,having, CerSubName string, Ids string, NeedFileType string) (total int64) {
|
|
|
|
|
|
|
+ OilSupplierFileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where, having, CerSubName string, Ids string, NeedFileType string) (total int64) {
|
|
|
|
|
|
|
|
//获取总记录数
|
|
//获取总记录数
|
|
|
/*sqlCount := `select count(*) from (`
|
|
/*sqlCount := `select count(*) from (`
|
|
@@ -69,6 +69,50 @@ func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, sup
|
|
|
}
|
|
}
|
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
|
|
|
|
|
|
|
+ sqlCount := "SELECT FOUND_ROWS() as total"
|
|
|
|
|
+
|
|
|
|
|
+ var totalResult TotalResult
|
|
|
|
|
+ session := s.DBE.NewSession()
|
|
|
|
|
+ session.Begin()
|
|
|
|
|
+ session.SQL(sql).Find(entitiesPtr)
|
|
|
|
|
+ session.SQL(sqlCount).Get(&totalResult)
|
|
|
|
|
+ session.Commit()
|
|
|
|
|
+ total = totalResult.Total
|
|
|
|
|
+
|
|
|
|
|
+ return total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (s *SelectService) GetMyPagingEntitiesWithOrderBytblForExport(supplierTableName, supplierCertTableName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
|
|
|
|
|
+ OilSupplierFileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where, having, CerSubName string, Ids string, NeedFileType string) (total int64) {
|
|
|
|
|
+
|
|
|
|
|
+ // TODO 推荐单位不从供方注册表取
|
|
|
|
|
+ var sql string
|
|
|
|
|
+ sql = `select SQL_CALC_FOUND_ROWS a.Id,a.SupplierName,b.AccessCardNo, a.OldSupplierName, b.SupplierTypeCode, b.CreateOn as CreateOn, `
|
|
|
|
|
+ sql += `a.LegalPerson,a.RegCapital,a.Mobile,b.AuditDate,b.ApplyTime,b.EffectEndTime,b.InFlag,a.ContactName,a.CommercialNo, `
|
|
|
|
|
+ sql += `a.DepositBank,a.HseTraining,a.CompanyType,a.SetupTime,a.Address,a.Province,a.City,a.Street, a.Grade, a.OperType, `
|
|
|
|
|
+ sql += `a.LinkAddress,a.LinkProvince,a.LinkCity,a.LinkStreet,a.BusinessScope, `
|
|
|
|
|
+ sql += `b.InStyle, b.Id CertId, f.FullName, b.RecUnitName as CheckUnitName, b.Remark `
|
|
|
|
|
+ sql += `,group_concat(distinct e.NeedFileType) NeedFileType `
|
|
|
|
|
+ sql += `from ` + supplierTableName + ` a `
|
|
|
|
|
+ sql += `left join ` + supplierCertTableName + ` b on b.SupplierId = a.Id `
|
|
|
|
|
+ sql += `left join Base_Organize f on f.Id = b.ThirdAudit `
|
|
|
|
|
+ // sql += `left join OilCorporateInfo g on g.CommercialNo = a.CommercialNo `
|
|
|
|
|
+ // sql += `left join ` + OilInfoChangeName + ` c on c.SupplierId = a.Id `
|
|
|
|
|
+ sql += `left join ` + OilSupplierFileName + ` e on e.SupplierId = a.Id `
|
|
|
|
|
+
|
|
|
|
|
+ sql += `where ` + where
|
|
|
|
|
+
|
|
|
|
|
+ if CerSubName != "" && Ids != "" {
|
|
|
|
|
+ sql += " and b.Id in (" + Ids + ")"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sql += ` group by a.Id,b.Id ` + having
|
|
|
|
|
+ if asc {
|
|
|
|
|
+ sql += ` order by ` + orderby + ` ASC `
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sql += ` order by ` + orderby + ` DESC `
|
|
|
|
|
+ }
|
|
|
|
|
+ sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
|
|
|
|
|
sqlCount := "SELECT FOUND_ROWS() as total"
|
|
sqlCount := "SELECT FOUND_ROWS() as total"
|
|
|
|
|
|
|
@@ -83,13 +127,12 @@ func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, sup
|
|
|
return total
|
|
return total
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *SelectService) GetUp( supplierCertTableName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
|
|
|
|
|
|
|
+func (s *SelectService) GetUp(supplierCertTableName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
|
|
|
var resultsSlice []map[string][]byte
|
|
var resultsSlice []map[string][]byte
|
|
|
|
|
|
|
|
-
|
|
|
|
|
var sql string
|
|
var sql string
|
|
|
sql = ` select (select FullName from Base_Organize where Id = a.CommitComId) FullName,max(a.CommitComId) CommitComId,a.SupplierTypeName,`
|
|
sql = ` select (select FullName from Base_Organize where Id = a.CommitComId) FullName,max(a.CommitComId) CommitComId,a.SupplierTypeName,`
|
|
|
- sql +=` count(a.Status>=6 or null ) HeGe,count(a.Status=-5 or null ) BuHeGe,count(a.Status=-5 or null ) + count(a.Status>=6 or null ) ZongShu,GROUP_CONCAT(a.BackReason SEPARATOR ';') Reason `
|
|
|
|
|
|
|
+ sql += ` count(a.Status>=6 or null ) HeGe,count(a.Status=-5 or null ) BuHeGe,count(a.Status=-5 or null ) + count(a.Status>=6 or null ) ZongShu,GROUP_CONCAT(a.BackReason SEPARATOR ';') Reason `
|
|
|
sql += ` from ` + supplierCertTableName + ` a `
|
|
sql += ` from ` + supplierCertTableName + ` a `
|
|
|
sql += ` where a.CommitComId is not null and a.CommitComId!="" and a.CommitComId!=0 ` + where
|
|
sql += ` where a.CommitComId is not null and a.CommitComId!="" and a.CommitComId!=0 ` + where
|
|
|
sql += ` group by FullName,SupplierTypeName `
|
|
sql += ` group by FullName,SupplierTypeName `
|
|
@@ -100,13 +143,11 @@ func (s *SelectService) GetUp( supplierCertTableName string, pageIndex, itemsPer
|
|
|
sql += ` order by ` + orderby + ` DESC `
|
|
sql += ` order by ` + orderby + ` DESC `
|
|
|
}
|
|
}
|
|
|
//获取总记录数
|
|
//获取总记录数
|
|
|
- sqlCount := `select count(*) from (` + sql+ `) a `
|
|
|
|
|
|
|
+ sqlCount := `select count(*) from (` + sql + `) a `
|
|
|
|
|
|
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
s.DBE.SQL(sql).Find(entitiesPtr)
|
|
s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
resultsSlice, _ = s.DBE.Query(sqlCount)
|
|
resultsSlice, _ = s.DBE.Query(sqlCount)
|
|
|
|
|
|
|
|
if len(resultsSlice) > 0 {
|
|
if len(resultsSlice) > 0 {
|
|
@@ -119,59 +160,60 @@ func (s *SelectService) GetUp( supplierCertTableName string, pageIndex, itemsPer
|
|
|
|
|
|
|
|
return total
|
|
return total
|
|
|
}
|
|
}
|
|
|
-func (s *SelectService) GetTotalInMonth( orderby string, asc bool, entitiesTotal interface{}, where string) (total int64) {
|
|
|
|
|
|
|
+func (s *SelectService) GetTotalInMonth(orderby string, asc bool, entitiesTotal interface{}, where string) (total int64) {
|
|
|
var resultsSlice []map[string][]byte
|
|
var resultsSlice []map[string][]byte
|
|
|
endtime, _ := strconv.Atoi(where)
|
|
endtime, _ := strconv.Atoi(where)
|
|
|
if endtime == 0 {
|
|
if endtime == 0 {
|
|
|
endtime = 5000
|
|
endtime = 5000
|
|
|
- }else {
|
|
|
|
|
- endtime = endtime+1}
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ endtime = endtime + 1
|
|
|
|
|
+ }
|
|
|
timedone := strconv.Itoa(endtime)
|
|
timedone := strconv.Itoa(endtime)
|
|
|
var sql string
|
|
var sql string
|
|
|
sql = `(SELECT AnnualAudit.Month,AnnualAudit,Store,Append,InfoChange,CatalogSelf,CatalogWin,CatalogTrade,CatalogComp,CatalogSpe FROM(
|
|
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
|
|
SELECT b.Month,a.AnnualAudit from (select extract(month from ApplyTime) time ,COUNT(*) AnnualAudit
|
|
|
from OilAnnualAudit
|
|
from OilAnnualAudit
|
|
|
- WHERE ApplyTime >= '` + where +`' AND ApplyTime < '` + timedone +`' AND Status = '11'
|
|
|
|
|
|
|
+ WHERE ApplyTime >= '` + where + `' AND ApplyTime < '` + timedone + `' AND Status = '11'
|
|
|
group by extract(month from ApplyTime)) a
|
|
group by extract(month from ApplyTime)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) AnnualAudit
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) AnnualAudit
|
|
|
LEFT JOIN (SELECT b.Month,a.Store from (select extract(month from StorageOn) time ,COUNT(*) Store
|
|
LEFT JOIN (SELECT b.Month,a.Store from (select extract(month from StorageOn) time ,COUNT(*) Store
|
|
|
from OilSupplierCert
|
|
from OilSupplierCert
|
|
|
- WHERE StorageOn >= '` + where +`' AND StorageOn < '` + timedone +`' AND InFlag = '1'
|
|
|
|
|
|
|
+ WHERE StorageOn >= '` + where + `' AND StorageOn < '` + timedone + `' AND InFlag = '1'
|
|
|
group by extract(month from StorageOn)) a
|
|
group by extract(month from StorageOn)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) Store ON AnnualAudit.Month = Store.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.Append from (select extract(month from ApplyDate) time ,COUNT(*) Append
|
|
|
from OilSupplierCertAppend
|
|
from OilSupplierCertAppend
|
|
|
- WHERE ApplyDate >= '` + where +`' AND ApplyDate < '` + timedone +`' AND Status = '11'
|
|
|
|
|
|
|
+ WHERE ApplyDate >= '` + where + `' AND ApplyDate < '` + timedone + `' AND Status = '11'
|
|
|
group by extract(month from ApplyDate)) a
|
|
group by extract(month from ApplyDate)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) Append ON AnnualAudit.Month = Append.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.InfoChange from (select extract(month from CreateOn) time ,COUNT(*) InfoChange
|
|
|
from OilInfoChange
|
|
from OilInfoChange
|
|
|
- WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND Status = '11'
|
|
|
|
|
|
|
+ WHERE CreateOn >= '` + where + `' AND CreateOn < '` + timedone + `' AND Status = '11'
|
|
|
group by extract(month from CreateOn)) a
|
|
group by extract(month from CreateOn)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) InfoChange ON AnnualAudit.Month = InfoChange.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.CatalogSelf from (select extract(month from CreateOn) time ,COUNT(*) CatalogSelf
|
|
|
from OilCatalog
|
|
from OilCatalog
|
|
|
- WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=1
|
|
|
|
|
|
|
+ WHERE CreateOn >= '` + where + `' AND CreateOn < '` + timedone + `' AND CatalogType=1
|
|
|
group by extract(month from CreateOn)) a
|
|
group by extract(month from CreateOn)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogSelf ON AnnualAudit.Month = CatalogSelf.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.CatalogWin from (select extract(month from CreateOn) time ,COUNT(*) CatalogWin
|
|
|
from OilCatalog
|
|
from OilCatalog
|
|
|
- WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=2
|
|
|
|
|
|
|
+ WHERE CreateOn >= '` + where + `' AND CreateOn < '` + timedone + `' AND CatalogType=2
|
|
|
group by extract(month from CreateOn)) a
|
|
group by extract(month from CreateOn)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogWin ON AnnualAudit.Month = CatalogWin.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.CatalogTrade from (select extract(month from CreateOn) time ,COUNT(*) CatalogTrade
|
|
|
from OilCatalog
|
|
from OilCatalog
|
|
|
- WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=3
|
|
|
|
|
|
|
+ WHERE CreateOn >= '` + where + `' AND CreateOn < '` + timedone + `' AND CatalogType=3
|
|
|
group by extract(month from CreateOn)) a
|
|
group by extract(month from CreateOn)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogTrade ON AnnualAudit.Month = CatalogTrade.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.CatalogComp from (select extract(month from CreateOn) time ,COUNT(*) CatalogComp
|
|
|
from OilCatalog
|
|
from OilCatalog
|
|
|
- WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=4
|
|
|
|
|
|
|
+ WHERE CreateOn >= '` + where + `' AND CreateOn < '` + timedone + `' AND CatalogType=4
|
|
|
group by extract(month from CreateOn)) a
|
|
group by extract(month from CreateOn)) a
|
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogComp ON AnnualAudit.Month = CatalogComp.Month
|
|
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
|
|
LEFT JOIN (SELECT b.Month,a.CatalogSpe from (select extract(month from CreateOn) time ,COUNT(*) CatalogSpe
|
|
|
from OilCatalog
|
|
from OilCatalog
|
|
|
- WHERE CreateOn >= '` + where +`' AND CreateOn < '` + timedone +`' AND CatalogType=5
|
|
|
|
|
|
|
+ WHERE CreateOn >= '` + where + `' AND CreateOn < '` + timedone + `' AND CatalogType=5
|
|
|
group by extract(month from CreateOn)) a
|
|
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) `
|
|
RIGHT JOIN OilCountMonth b ON b.Month = a.time) CatalogSpe ON AnnualAudit.Month = CatalogSpe.Month ORDER BY AnnualAudit.Month) `
|
|
|
|
|
|
|
@@ -194,9 +236,9 @@ LEFT JOIN (SELECT b.Month,a.CatalogSpe from (select extract(month from CreateOn
|
|
|
|
|
|
|
|
//获取公司信息和准入范围
|
|
//获取公司信息和准入范围
|
|
|
|
|
|
|
|
-func (s *SelectService) GetInfoByCompId(where string,entitiesPtr interface{}) (total int64) {
|
|
|
|
|
|
|
+func (s *SelectService) GetInfoByCompId(where string, entitiesPtr interface{}) (total int64) {
|
|
|
var sql string
|
|
var sql string
|
|
|
- sql = `SELECT a.* from OilSupplier a `+ where
|
|
|
|
|
|
|
+ sql = `SELECT a.* from OilSupplier a ` + where
|
|
|
|
|
|
|
|
var totalResult TotalResult
|
|
var totalResult TotalResult
|
|
|
session := s.DBE.NewSession()
|
|
session := s.DBE.NewSession()
|
|
@@ -209,10 +251,10 @@ func (s *SelectService) GetInfoByCompId(where string,entitiesPtr interface{}) (t
|
|
|
return total
|
|
return total
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *SelectService) Getoilsuppliercertsub( tableName, where string, entitiesPtr interface{}) error {
|
|
|
|
|
|
|
+func (s *SelectService) Getoilsuppliercertsub(tableName, where string, entitiesPtr interface{}) error {
|
|
|
var sql string
|
|
var sql string
|
|
|
- sql = `SELECT a.* from `+ tableName +` a `+ where
|
|
|
|
|
|
|
+ sql = `SELECT a.* from ` + tableName + ` a ` + where
|
|
|
|
|
|
|
|
err := s.DBE.SQL(sql).Find(entitiesPtr)
|
|
err := s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
return err
|
|
return err
|
|
|
-}
|
|
|
|
|
|
|
+}
|