| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- package samplesapply
- import (
- "dashoo.cn/backend/api/controllers"
- "fmt"
- "strconv"
- . "dashoo.cn/backend/api/mydb"
- "dashoo.cn/utils"
- . "dashoo.cn/utils/db"
- "github.com/go-xorm/xorm"
- )
- type SamplesApplyService struct {
- MyServiceBase
- }
- func GetSamplesApplyService(xormEngine *xorm.Engine) *SamplesApplyService {
- s := new(SamplesApplyService)
- s.DBE = xormEngine
- return s
- }
- //关联容器获取存储位置
- func (s *SamplesApplyService) GetApplySamplesDetail(acccode string, pageIndex, itemsPerPage int64, order, where string) (int64, []Applydetailmodel) {
- var err error
- var total int64
- if order != "" {
- order = " order by " + order
- }
- //获取总记录数
- if where == "" {
- where = "1=1"
- }
- tbldetail := acccode + "SamplesApplyDetail"
- mainsam := acccode + "SamplesMain"
- sqlCount := " select count(*) from " + tbldetail + " where " + where
- fmt.Println(sqlCount)
- var sql string
- sql = ` select a.*,b.Code ECode,c.YStation ShelfY,d.XStation BoxX,d.YStation BoxY,e.SourceId,e.SourceName from ` + tbldetail + ` a
- left join Equipment b on a.EquipmentId = b.Id
- left join Shelf c on a.ShelfId = c.Id
- left join Box d on a.BoxId = d.Id
- left join ` + mainsam + ` e on e.SampleCode = a.SampleCode
- where ` + where + order + `
- limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage) + ""
- fmt.Println(sql)
- List := make([]Applydetailmodel, 0)
- utils.DBE.Sql(sql).Find(&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 total, List
- }
- func (s *SamplesApplyService) QueryApplySamplesDetail(acccode ,entryno string) ([]Applydetailmodel) {
- var err error
- var where string
- if where == "" {
- where = "1=1"
- }
- var sql string
- sql="SELECT t1.* FROM smkfjSamplesApplyDetail t1 , smkfjSamplesApply t2 WHERE t1.parentid=t2.id AND t2.entryno='"+entryno+"'"
- List := make([]Applydetailmodel, 0)
- utils.DBE.Sql(sql).Find(&List)
- LogError(err)
- return List
- }
- // 获取分页列表
- func (s *SamplesApplyService) GetApplyViewtList(pageIndex, itemsPerPage int64, applytable string, order, where string) (int64, []SamplesApply) {
- var err error
- var total int64
- //获取总记录数
- sqlCount := `select count(*) from ` + applytable + ` where ` + where
- var sql, limitstr string = "", ""
- if pageIndex > 0 {
- limitstr = ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
- }
- sql = `select * from ` + applytable + ` where ` + where + ` order by ` + order + limitstr
- List := make([]SamplesApply, 0)
- utils.DBE.Sql(sql).Find(&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
- }
- }
- fmt.Println("-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0", List)
- return total, List
- }
- func (s *SamplesApplyService) QuerySampleApplyDetailByBarCode(acccode string ,barcode string ) (entity SamplesApplyDetail){
- tableName:=acccode+controllers.SamplesApplyDetailName
- sql:="select a.* from "+tableName+" a where a.barcode= '"+barcode+"'"
- utils.DBE.Sql(sql).Get(&entity)
- return
- }
- func (s *SamplesApplyService) QuerySampleDetailByBarCode(acccode string ,barcode string ) (entity SamplesApplyDetail){
- tableName:=acccode+controllers.SamplesApplyDetailName
- sql:="select a.* from "+tableName+" a where a.barcode= '"+barcode+"'"
- utils.DBE.Sql(sql).Get(&entity)
- return
- }
|