Browse Source

人类样本导出

shiyi 6 years ago
parent
commit
8af4318237

+ 45 - 0
src/dashoo.cn/backend/api/business/samplesinfo/samplesinfoService.go

@@ -128,6 +128,51 @@ func (s *SamplesInfoService) GetPagingEntitiesWithTb(acccode string, pageIndex,
 	return total, List
 }
 
+func (s *SamplesInfoService) GetPagingEntitiesWithDonorsTb(acccode string, pageIndex, itemsPerPage int64, tbldonor, order, where string) (int64, []SamplesInfoList) {
+	var err error
+	var total int64
+	if order != "" {
+		order = " order by " + order
+	}
+	//获取总记录数
+	if where == "" {
+		where = "1=1"
+	}
+	tbldetail := acccode + SamplesDetailtbName
+	tblmain := acccode + SamplesMaintbName
+	groupdetail := acccode + GroupDetailName
+
+	sqlCount := " select count(*) from " + tbldetail + " a  left join " + tblmain + " b on a.SampleCode = b.SampleCode left join " + tbldonor + " c on b.SourceId = c.Id left join Shelf d on a.ShelfId=d.Id left join Box e on a.BoxId=e.Id left join Equipment f on a.EquipmentId=f.Id left join " + groupdetail + " g on g.SampleId=a.Id where " + where
+
+	fmt.Println(sqlCount)
+	var sql string
+
+	sql = ` select a.*,b.*,c.*,d.XStation ShelfX,d.YStation ShelfY,d.Code ShelfCode,e.XStation BoxX,e.YStation BoxY,e.Code BoxCode,f.Id Eid,f.Name EName,f.Code ECode,g.GroupId,g.GroupName from ` + tbldetail + ` a 
+	left join ` + tblmain + ` b on a.SampleCode = b.SampleCode  
+	left join ` + tbldonor + ` c on b.SourceId = c.Id 
+	left join Shelf d on a.ShelfId=d.Id 
+	left join Box e on a.BoxId=e.Id 
+	left join Equipment f on a.EquipmentId=f.Id 
+	left join ` + groupdetail + ` g on g.SampleId=a.Id 
+	where ` + where + order + `
+		 limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage) + ""
+	fmt.Println(sql)
+	List := make([]SamplesInfoList, 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 *SamplesInfoService) GetPagingEntitiesSearch(acccode string, page, size string, order, where string) (int64, []SamplesInfoList) {
 	var err error

+ 48 - 0
src/dashoo.cn/backend/api/controllers/samplesinfo/samplesinput.go

@@ -2278,6 +2278,54 @@ func (this *SamplesinputController) Listajax() {
 	this.ServeJSON()
 }
 
+// @Title 获取预录入列表
+// @Description get SampleType by token
+// @Success 200 {object} sampletype.SampleType
+// @router /getlistdonors [get]
+func (this *SamplesinputController) ListDonors() {
+	page := this.GetPageInfoForm()
+	barcode := this.GetString("barcode")
+	samplecode := this.GetString("samplecode")
+	name := this.GetString("name")
+	operator := this.GetString("operator")
+	sampletype := this.GetString("sampletype")
+	ReceiveDate := this.GetString("ReceiveDate")
+
+	where := " IState in (2,3,4,7,8) and DeletionStateCode=0  "
+	if barcode != "" {
+		where = where + " and a.BarCode like '%" + barcode + "%' "
+	}
+	if samplecode != "" {
+		where = where + " and a.SampleCode like '%" + samplecode + "%' "
+	}
+	if name != "" {
+		where = where + " and b.Name like '%" + name + "%' "
+	}
+	if operator != "" {
+		where = where + " and a.CreateBy like '%" + operator + "%' "
+	}
+	if sampletype != "" {
+		where = where + " and b.SampleType = '" + sampletype + "' "
+	}
+	if ReceiveDate != "" {
+		dates := strings.Split(ReceiveDate, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and ReceiveDate>='" + minDate + "' and ReceiveDate<='" + maxDate + "'"
+		}
+	}
+	svc := samplesinfo.GetSamplesInfoService(utils.DBE)
+	var samplespre []samplesinfo.SamplesInfoList
+	total, samplespre := svc.GetPagingEntitiesWithDonorsTb(this.User.AccCode, page.CurrentPage, page.Size, this.User.AccCode+DonorstbName, "a.Id desc", where)
+
+	var datainfo DataInfo
+	datainfo.Items = samplespre
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
 // @Title 获取搜索模版列表
 // @Description get SampleType by token
 // @Success 200 {object} sampletype.SampleType

+ 1 - 1
src/dashoo.cn/frontend_web/src/components/samples/preoperation.vue

@@ -182,7 +182,7 @@
           _currentPage: this.currentPage,
           _size: this.pagesize,
         }
-        this.$axios.get('sampleinput/getlistajax', {
+        this.$axios.get('sampleinput/getlistdonors', {
             params
           })
           .then(res => {