|
|
@@ -202,4 +202,96 @@ func (s *OilAnnualAuditService) GetProcessInfoWithOrderBytbl(oilAnnualAuditName
|
|
|
}
|
|
|
|
|
|
return total
|
|
|
+}
|
|
|
+
|
|
|
+func (s *OilAnnualAuditService) GetProcessInfoAllWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string, where1 string, where2 string, where3 string) {
|
|
|
+ //var resultsSlice []map[string][]byte
|
|
|
+
|
|
|
+ //获取总记录数
|
|
|
+ //sqlCount := `select count(*) from ` + oilAnnualAuditName + ` a `
|
|
|
+ //sqlCount += ` LEFT JOIN Base_User u ON a.CreateUserId = u.Id`
|
|
|
+ //sqlCount += ` Left join OilSupplier s on a.SupplierId = s.Id
|
|
|
+ // left join Base_User uu on s.CreateUserId = uu.Id
|
|
|
+ // left join OilCorporateInfo c on s.CreateUserId = c.UserId`
|
|
|
+ //sqlCount += ` where ` + where
|
|
|
+
|
|
|
+ var sql string
|
|
|
+ sql = `select a.SupplierName, b.Id,`
|
|
|
+ sql += ` b.Status, b.SupplierTypeCode, `
|
|
|
+ sql += ` b.WorkflowId, b.ProcessKey, '1' as Type,`
|
|
|
+ sql += ` b.CreateOn, b.AccessCardNo, b.ModifiedOn As AddinTime,`
|
|
|
+ sql += ` u.Realname as ContactName,`
|
|
|
+ sql += ` u.Telephone as Mobile,`
|
|
|
+ sql += ` org.FullName As RecUnitName`
|
|
|
+ sql += ` from OilSupplier a `
|
|
|
+ sql += ` left join OilSupplierCert b on b.SupplierId = a.Id`
|
|
|
+ sql += ` Left join Base_User u on a.CreateUserId = u.Id `
|
|
|
+ sql += ` LEFT JOIN Base_Organize org ON b.CommitComId = org.Id`
|
|
|
+ sql += ` where ` + where1
|
|
|
+ sql += ` union `
|
|
|
+
|
|
|
+ sql += `select a.SupplierName, a.Id, `
|
|
|
+ sql += ` a.Status, a.AppendType SupplierTypeCode, `
|
|
|
+ sql += ` a.WorkflowId, a.ProcessKey, '2' as Type, a.CreateOn, a.AccessCardNo, a.ModifiedOn as AddinTime, u.Realname AS ContactName, u.Telephone AS Mobile,`
|
|
|
+ sql += ` case when uu.IsCompanyUser = 1 then c.CheckUnitName
|
|
|
+ when uu.IsCompanyUser = 0 then uu.Unit
|
|
|
+ else ''
|
|
|
+ end As RecUnitName `
|
|
|
+ sql += ` from OilSupplierCertAppend a `
|
|
|
+ sql += ` LEFT JOIN Base_User u ON a.CreateUserId = u.Id`
|
|
|
+ sql += ` Left join OilSupplier s on a.SupplierId = s.Id
|
|
|
+ left join Base_User uu on s.CreateUserId = uu.Id
|
|
|
+ left join OilCorporateInfo c on s.CreateUserId = c.UserId`
|
|
|
+ sql += ` where ` + where2
|
|
|
+ sql += ` union `
|
|
|
+
|
|
|
+ sql += `select a.SupplierName, a.Id, `
|
|
|
+ sql += ` a.Status, a.SupplierTypeName SupplierTypeCode, `
|
|
|
+ sql += ` a.WorkflowId, a.ProcessKey, '3' as Type, a.CreateOn, a.AccessCardNo, a.ModifiedOn as AddinTime, u.Realname AS ContactName, u.Telephone AS Mobile,`
|
|
|
+ sql += ` CASE WHEN uu.IsCompanyUser = 1 THEN c.CheckUnitName
|
|
|
+ WHEN uu.IsCompanyUser = 0 THEN uu.Unit
|
|
|
+ ELSE ''
|
|
|
+ END AS RecUnitName`
|
|
|
+ sql += ` from OilAnnualAudit a `
|
|
|
+ sql += ` LEFT JOIN Base_User u ON a.CreateUserId = u.Id`
|
|
|
+ sql += ` Left join OilSupplier s on a.SupplierId = s.Id
|
|
|
+ left join Base_User uu on s.CreateUserId = uu.Id
|
|
|
+ left join OilCorporateInfo c on s.CreateUserId = c.UserId`
|
|
|
+ sql += ` where ` + where3
|
|
|
+ sql += ` union `
|
|
|
+
|
|
|
+ sql += `select a.SupplierName, a.Id, `
|
|
|
+ sql += ` a.Status,a.SupplierTypeCode, `
|
|
|
+ sql += ` a.WorkflowId, a.ProcessKey, '4' as Type, a.CreateOn, a.AccessCardNo, a.ModifiedOn as AddinTime, u.Realname AS ContactName, u.Telephone AS Mobile, `
|
|
|
+ sql += ` CASE WHEN uu.IsCompanyUser = 1 THEN c.CheckUnitName
|
|
|
+ WHEN uu.IsCompanyUser = 0 THEN uu.Unit
|
|
|
+ ELSE ''
|
|
|
+ END AS RecUnitName`
|
|
|
+ sql += ` from OilInfoChange a `
|
|
|
+ sql += ` LEFT JOIN Base_User u ON a.CreateUserId = u.Id`
|
|
|
+ sql += ` Left join OilSupplier s on a.SupplierId = s.Id
|
|
|
+ left join Base_User uu on s.CreateUserId = uu.Id
|
|
|
+ left join OilCorporateInfo c on s.CreateUserId = c.UserId `
|
|
|
+ sql += ` where ` + where
|
|
|
+ if asc {
|
|
|
+ sql += ` order by ` + orderby + ` ASC `
|
|
|
+ } else {
|
|
|
+ sql += ` order by ` + orderby + ` DESC `
|
|
|
+ }
|
|
|
+ if (pageIndex != 0 && itemsPerPage !=0) {
|
|
|
+ sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
+ }
|
|
|
+ s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
+
|
|
|
+ //resultsSlice, _ = s.DBE.Query(sqlCount)
|
|
|
+
|
|
|
+ //if len(resultsSlice) > 0 {
|
|
|
+ // results := resultsSlice[0]
|
|
|
+ // for _, value := range results {
|
|
|
+ // total, _ = strconv.ParseInt(string(value), 10, 64)
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //return total
|
|
|
}
|