| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package samplessource
- import (
- //"fmt"
- "strconv"
- . "dashoo.cn/backend/api/mydb"
- "dashoo.cn/utils"
- . "dashoo.cn/utils/db"
- "github.com/go-xorm/xorm"
- )
- type SamplesSourceService struct {
- MyServiceBase
- }
- func GetSamplesSourceService(xormEngine *xorm.Engine) *SamplesSourceService {
- s := new(SamplesSourceService)
- s.DBE = xormEngine
- return s
- }
- //获取扩展字段列
- func (s *SamplesSourceService) QueryZBackList(acccode string) []String_Id {
- List := make([]String_Id, 0)
- sql := "select distinct FieldName Id from DonorsNoteItem where FieldNo>10 and AccCode ='" + acccode + "' order by Id "
- utils.DBE.Sql(sql).Find(&List)
- return List
- }
- //判断委托单号是否存在,返回总数
- func (s *SamplesSourceService) GetInnerNo(maintable string, where string) int64 {
- var sql string
- var total int64
- sql = `select count(*) from ` + maintable + ` where ` + where
- resultsSlice, err := s.DBE.Query(sql)
- 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 total
- }
- //获取样本来源信息用于导出
- func (s *SamplesSourceService) GetSampleSourceInfo(donors, testmain, donorsdetail, where string) []DonorsInfoWithDetail {
- if where == "" {
- where = " 1=1 "
- }
- var sql string
- sql = `select * from ( select a.AccCode,a.Id,a.IdCard,a.InnerNo,a.Name,a.Sex,a.CompanyName,a.Duty,a.Birthday,a.Age,a.Telephone,a.Email,a.Nation,a.HomeAddress,a.IllnessName,a.Remark, b.InspectionNum, group_concat(c.PathologicalNum) as PathologicalNum
- from ` + donors + ` a
- left join ` + testmain + ` b on a.Id=b.SourceId
- left join ` + donorsdetail + ` c on c.ParentId=a.Id
- where ` + where + ` group by a.Id,a.IdCard,a.Name,b.InspectionNum) as m `
- List := make([]DonorsInfoWithDetail, 0)
- utils.DBE.Sql(sql).Find(&List)
- return List
- }
|