| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- package limsindex
- import (
- "dashoo.cn/backend/api/business/limsdataentry"
- . "dashoo.cn/backend/api/mydb"
- "dashoo.cn/utils"
- "fmt"
- . "dashoo.cn/utils/db"
- "github.com/go-xorm/xorm"
- )
- type LimsIndexService struct {
- MyServiceBase
- }
- func GetLimsIndexService(xormEngine *xorm.Engine) *LimsIndexService {
- s := new(LimsIndexService)
- s.DBE = xormEngine
- return s
- }
- //待办事项
- func (s *LimsIndexService) GetDataEntryWait(tblentry, tblbalance, tblentrustmain string, order, where string) (limsdataentry.LimsDateEntryModel) {
- var err error
- //var total int64
- if order != "" {
- order = " order by " + order
- }
- //获取总记录数
- if where == "" {
- where = "1=1"
- }
- //sqlCount := " select count(*) from " + tblentry + " a left join " + tblbalance + " b on b.Id = a.TaskId left join " + tblentrustmain + " c on c.Id=b.EId where " + where
- var sql string
- sql = ` select b.EId,b.EntrustNo,b.SampleTestId,b.BalanceTime,b.BalanceStatus,b.EntrustType,b.EntrustTypeId,b.ProjectType,b.ProjectTypeId,b.DataEntryStatus,b.TestDetail,b.TestDetailId,b.DetectSample,b.DetectSampleId,b.DataDoc,b.DataDocId,b.EquipmentTypeId,b.EquipmentType,b.EquipmentId,b.Equipment,b.BalanceId,a.*,c.* from ` + tblentry + ` a
- left join ` + tblbalance + ` b on b.Id = a.TaskId
- left join ` + tblentrustmain + ` c on c.Id=b.EId
- where ` + where + order
- fmt.Println(sql)
- //List := make([]limsdataentry.LimsDateEntryModel, 0)
- var List limsdataentry.LimsDateEntryModel
- utils.DBE.Sql(sql).Get(&List)
- //resultsSlice, err := s.DBE.Query(sqlCount)
- LogError(err)
- //if len(resultsSlice) > 0 {
- // results := resultsSlice[0]
- // for _, value := range results {
- // total, err = strconv.ParseInt(string(value), 10, 64)
- // LogError(err)
- // break
- // }
- //}
- return List
- }
- //待办事项
- func (s *LimsIndexService) GetDataEntryWait2(tblcreatereport, tblentrustmain string, order, where string) (limsdataentry.LimsDateEntryModel) {
- var err error
- if order != "" {
- order = " order by " + order
- }
- //获取总记录数
- if where == "" {
- where = "1=1"
- }
- var sql string
- sql = ` SELECT e.EntrustNo,e.CustomerName,c.* from ` + tblcreatereport + ` c
- left join ` + tblentrustmain + ` e on c.EId = e.Id
- where ` + where + order
- fmt.Println(sql)
- var List limsdataentry.LimsDateEntryModel
- utils.DBE.Sql(sql).Get(&List)
- LogError(err)
- return List
- }
- // 按月份统计检测任务
- func (s *LimsIndexService) GetEntrustService(entrust string, where string) (list []EntrustDateModel) {
- sql := `select (year(CreateOn)) as YearName,(month(CreateOn)) as MonthName ,count(1) Num from ` + entrust + ` where ` + where + ` group by YearName,MonthName `
- s.DBE.Sql(sql).Find(&list)
- return
- }
- // 按月份统计数据录入
- func (s *LimsIndexService) GetDataService(dataentry string, where string) (list []EntrustDateModel) {
- sql := `select (year(CreateOn)) as YearName,(month(CreateOn)) as MonthName ,count(1) Num from ` + dataentry + ` where ` + where + ` group by YearName,MonthName `
- s.DBE.Sql(sql).Find(&list)
- return
- }
- // 统计每种检测报告使用次数
- func (s *LimsIndexService) GetProjectService(entrust string, where string) (list []GrophListModel) {
- sql := `select ProjectTypeId as MId,ProjectType as Name ,count(1) Num from ` + entrust + ` where ` + where + ` group by MId,Name order by Num desc limit 10`
- s.DBE.Sql(sql).Find(&list)
- return
- }
- // 统计每个设备使用次数
- func (s *LimsIndexService) GetInstrumentService(instrument string, where string) (list []GrophListModel) {
- sql := `select InstrumentId as MId,InstrumenName as Name ,count(1) Num from ` + instrument + ` where ` + where + ` group by MId,Name order by Num desc`
- s.DBE.Sql(sql).Find(&list)
- return
- }
- // 委托方统计
- func (s *LimsIndexService) GetCustomerService(customer string, entrust string, where string, wherenum string) (list []GrophListModel) {
- sql := `select * from (
- select a.Id as MId,a.CustomerName Name,count(1) Num from ` + customer + ` a
- left join ` + entrust + ` b on a.Id = b.CustomerId
- where ` + where + ` group by MId,Name) m where ` + wherenum + ` order by Num desc`
- s.DBE.Sql(sql).Find(&list)
- return
- }
|