Procházet zdrojové kódy

样本来源导出

shihang před 6 roky
rodič
revize
0457d7815a

+ 167 - 0
src/dashoo.cn/backend/api/business/inspectionproject/inspectionproject.go

@@ -0,0 +1,167 @@
+package inspectionproject
+
+import (
+	"time"
+)
+
+type TestLaboratory struct {
+	Id         int    `xorm:"not null pk autoincr INT(10)"`
+	Laboratory string `xorm:"VARCHAR(50)"`
+}
+type TestList struct {
+	Id               int       `xorm:"not null pk autoincr INT(10)"`
+	LabId            int       `xorm:"INT(10)"` //实验室ID
+	TestName         string    `xorm:"VARCHAR(50)"`
+	Laboratory       string    `xorm:"VARCHAR(50)"`
+	Describe         string    `xorm:"VARCHAR(50)"`
+	EqptId           string    `xorm:"VARCHAR(50)"` //设备号
+	DataGatherItem   int       `xorm:"INT(10)"`     //数据采集类型;0:1次传输完成,1:多次传输完成
+	TATTime          int       `xorm:"INT(10)"`     //TAT时间,单位秒
+	TATTimeItem      int       `xorm:"INT(10)"`     //TAT时间类型;1:小时,2:天,3:周
+	TATTimeItemValue int       `xorm:"INT(10)"`     //TAT时间类型值(如5h:5)
+	CreateUserId     int       `xorm:"INT(10)"`
+	CreateBy         string    `xorm:"VARCHAR(255)"`
+	CreateOn         time.Time `xorm:"DATETIME created"`
+	ModifiedUserId   int       `xorm:"INT(10)"`
+	ModifiedBy       string    `xorm:"VARCHAR(255)"`
+	ModifiedOn       time.Time `xorm:"DATETIME updated"`
+}
+type TestItemsList struct {
+	Id                    int       `xorm:"not null pk autoincr INT(10)"`
+	TestListId            int       `xorm:"INT(10)"`
+	ItemName              string    `xorm:"VARCHAR(50)"`
+	Code                  string    `xorm:"VARCHAR(50)"` /*'代号',*/
+	InterfaceCode         string    `xorm:"VARCHAR(50)"` /*'接口代号',*/
+	Reference             string    `xorm:"VARCHAR(50)"` /*'参考值',*/
+	ReferenceItem         int       `xorm:"INT(10)"`     /*'参考值类型',*/
+	ReferenceLower        float32   `xorm:"float(11)"`   /*'参考值下限,>,>=,范围使用',',*/
+	ReferenceUpper        float32   `xorm:"float(11)"`   /*'参考值上限,<,<=,范围使用',*/
+	ReferenceEqual        string    `xorm:"VARCHAR(50)"` /*'参考值,=使用',*/
+	Unit                  string    `xorm:"VARCHAR(50)"`
+	ItemCategory          int       `xorm:"INT(10)"`     /*'项目类别',*/
+	PrintGroup            string    `xorm:"VARCHAR(50)"` /* '打印分组',*/
+	AdjustmentCoefficient float32   `xorm:"float(11)"`   /* '调整系数',*/
+	NumberDecimals        int       `xorm:"INT(10)"`     /*'小数位数',*/
+	ValueMethod           int       `xorm:"INT(10)"`     /* '取值方式,0:普通数据;1:计算公式',*/
+	CalcMethod            string    `xorm:"VARCHAR(50)"` /* '调整系数',*/
+	IsQC                  int       `xorm:"INT(10)"`     /*'质控项',*/
+	SortCode              int       `xorm:"INT(10)"`     /*'排序',*/
+	CreateUserId          int       `xorm:"INT(10)"`
+	CreateBy              string    `xorm:"VARCHAR(255)"`
+	CreateOn              time.Time `xorm:"DATETIME created"`
+	ModifiedUserId        int       `xorm:"INT(10)"`
+	ModifiedBy            string    `xorm:"VARCHAR(255)"`
+	ModifiedOn            time.Time `xorm:"DATETIME updated"`
+}
+type TestListDetail struct {
+	Id                int       `xorm:"not null pk autoincr INT(10)"`
+	TestListId        int       `xorm:"INT(10)"`
+	SampleTypeId      int       `xorm:"INT(10)"`
+	SampleType        string    `xorm:"VARCHAR(50)"`
+	TestTubeId        int       `xorm:"INT(10)"`
+	TestTube          string    `xorm:"VARCHAR(50)"` //试管
+	Size              int       `xorm:"INT(10)"`
+	Number            int       `xorm:"INT(10)"`     //管数
+	StorageConditions string    `xorm:"VARCHAR(50)"` //保存条件
+	CreateUserId      int       `xorm:"INT(10)"`
+	CreateBy          string    `xorm:"VARCHAR(255)"`
+	CreateOn          time.Time `xorm:"DATETIME created"`
+	ModifiedUserId    int       `xorm:"INT(10)"`
+	ModifiedBy        string    `xorm:"VARCHAR(255)"`
+	ModifiedOn        time.Time `xorm:"DATETIME updated"`
+}
+type TestPrintTemplate struct {
+	Id             int       `xorm:"not null pk autoincr INT(10)"`
+	OrgId          string    `xorm:"VARCHAR(50)"` //部门Id
+	TempName       string    `xorm:"VARCHAR(50)"` //模板名
+	FileName       string    `xorm:"VARCHAR(50)"` //模板文件
+	UseModule      int       `xorm:"INT(10)"`     //所属模块;1:实验室
+	Describe       string    `xorm:"INT(10)"`     //描述
+	CreateUserId   int       `xorm:"INT(10)"`
+	CreateBy       string    `xorm:"VARCHAR(255)"`
+	CreateOn       time.Time `xorm:"DATETIME created"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(255)"`
+	ModifiedOn     time.Time `xorm:"DATETIME updated"`
+}
+type TestDetail struct {
+	Id                int
+	LabId             int
+	TestName          string
+	Laboratory        string
+	Describe          string
+	EqptId            string
+	TestListId        int
+	SampleType        string
+	TestTube          string
+	Size              int
+	Number            int
+	StorageConditions string
+}
+type TestPackageCategory struct {
+	Id                int       `xorm:"not null pk autoincr INT(10)"`
+	ParentId          int       `xorm:"INT(10)"`
+	Code              string    `xorm:"VARCHAR(50)"`
+	FullName          string    `xorm:"VARCHAR(50)"` //
+	SortCode          int       `xorm:"INT(10)"`
+	Description       string    `xorm:"VARCHAR(50)"`
+	DeletionStateCode int       `xorm:"INT(10)"` //
+	Enabled           int       `xorm:"INT(10)"` //
+	CreateUserId      int       `xorm:"INT(10)"`
+	CreateBy          string    `xorm:"VARCHAR(255)"`
+	CreateOn          time.Time `xorm:"DATETIME created"`
+	ModifiedUserId    int       `xorm:"INT(10)"`
+	ModifiedBy        string    `xorm:"VARCHAR(255)"`
+	ModifiedOn        time.Time `xorm:"DATETIME updated"`
+}
+
+type TestPackageCategoryParent struct {
+	Id          int
+	ParentId    int
+	FullName    string
+	Description string
+	Createon    time.Time
+	Modifiedon  time.Time
+	Parentname  string
+}
+type TestPackage struct {
+	Id             int       `xorm:"<- not null pk autoincr INT(10)"`
+	PackageName    string    `xorm:"VARCHAR(50)"` //套餐名
+	PackageCode    string    `xorm:"VARCHAR(50)"` //套餐编号
+	CategoryId     int       `xorm:"INT(10)"`     //类型Id
+	CategoryName   string    `xorm:"VARCHAR(50)"` //类型名
+	Describe       string    `xorm:"VARCHAR(50)"` //描述
+	CreateUserId   string    `xorm:"VARCHAR(50)"`
+	CreateBy       string    `xorm:"VARCHAR(255)"`
+	CreateOn       time.Time `xorm:"DATETIME created"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(255)"`
+	ModifiedOn     time.Time `xorm:"DATETIME updated"`
+}
+
+type TestPackageItems struct {
+	Id             int       `xorm:"<- not null pk autoincr INT(10)"`
+	PackageId      int       `xorm:"INT(10)"` //套餐
+	TestListId     int       `xorm:"INT(10)"` //检测大项
+	ItemsListId    int       `xorm:"INT(10)"` //检测项目
+	SortCode       int       `xorm:"INT(10)"` //排序
+	CreateUserId   int       `xorm:"VARCHAR(50)"`
+	CreateBy       string    `xorm:"VARCHAR(255)"`
+	CreateOn       time.Time `xorm:"DATETIME created"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(255)"`
+	ModifiedOn     time.Time `xorm:"DATETIME updated"`
+}
+
+type SelectPackItemList struct {
+	ItemsListId int
+	ItemName    string
+}
+
+type HandServiceModel struct {
+	Id             int
+	TestName       string
+	DataGatherItem int
+	TATTime        int
+	CollectDate    time.Time
+}

+ 284 - 0
src/dashoo.cn/backend/api/business/inspectionproject/inspectionprojectService.go

@@ -0,0 +1,284 @@
+package inspectionproject
+
+import (
+	"strconv"
+
+	. "dashoo.cn/backend/api/mydb"
+	"dashoo.cn/utils"
+	. "dashoo.cn/utils/db"
+	"github.com/go-xorm/xorm"
+)
+
+type InspectionprojectService struct {
+	MyServiceBase
+}
+
+func GetInspectionprojectService(xormEngine *xorm.Engine) *InspectionprojectService {
+	s := new(InspectionprojectService)
+	s.DBE = xormEngine
+	return s
+}
+
+//根据ID查数据
+func (s *InspectionprojectService) QueryinspectionEntity(tablename string, where string) []TestItemsList {
+	var err error
+	var sql string
+	if where == "" {
+		where = " 1=1 "
+	}
+	sql = `select * from  ` + tablename + `  where  ` + where
+	List := make([]TestItemsList, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+	return List
+}
+
+//根据实验室检验查询质控项
+func (s *InspectionprojectService) QueryQCEntity(maintable string, branchtable string, where string) []TestItemsList {
+	var err error
+	var sql string
+	sql = `select * from  ` + maintable + ` where TestListId=(select Id from ` + branchtable + ` where ` + where + `) and IsQC=1 `
+	List := make([]TestItemsList, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+	return List
+}
+
+//根据检验ID 查询质控项
+func (s *InspectionprojectService) QueryQCEntityByTestId(maintable string, where string) []TestItemsList {
+	var err error
+	var sql string
+	sql = `select * from  ` + maintable + ` where ` + where + ` and IsQC=1 `
+	List := make([]TestItemsList, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+	return List
+}
+
+//主表数据展示
+func (s *InspectionprojectService) GetPaginginspviewlist(tablename string, where string) []TestList {
+	var err error
+	if where == "" {
+		where = " 1=1 "
+	}
+	var sql string
+	sql = `select * from ` + tablename + ` where ` + where
+
+	List := make([]TestList, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+
+	return List
+}
+
+//主表数据展示
+func (s *InspectionprojectService) QueryTableEntity(tablename string, where string) (entity TestList) {
+	sql := `select * from ` + tablename + ` where ` + where
+	s.DBE.Sql(sql).Get(&entity)
+	return
+}
+
+//检验详情数据展示
+func (s *InspectionprojectService) GetTestDetailviewlist(tablename string, where string) []TestListDetail {
+	var err error
+	if where == "" {
+		where = " 1=1 "
+	}
+	var sql string
+	sql = `select * from ` + tablename + ` where ` + where
+
+	List := make([]TestListDetail, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+
+	return List
+}
+
+//套餐项目数据分组展示
+func (s *InspectionprojectService) GetTestviewlistGroupby(tablename string, group string, where string) []TestPackageItems {
+	var err error
+	var sql string
+	sql = `select * from ` + tablename + ` where ` + where
+	if group != "" {
+		sql = sql + ` group by ` + group
+	}
+	List := make([]TestPackageItems, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+
+	return List
+}
+
+//更新质控项设置
+func (s *InspectionprojectService) UpdateTestItemsList(tablename string, arr_id string, where string) error {
+	sql := " update " + tablename + " set IsQC =0 where " + where
+	if arr_id == "" {
+		_, err1 := s.DBE.Exec(sql)
+		return err1
+	}
+	sql2 := " update " + tablename + " set IsQC =1 where Id in (" + arr_id + ") and " + where
+	_, _ = s.DBE.Exec(sql)
+	_, err := s.DBE.Exec(sql2)
+	return err
+}
+
+func (s *InspectionprojectService) InsertQualityControl(tablename string, arr_id []string, TestId string, SortCode string, where string) error {
+	var total int64
+	for i := 0; i < len(arr_id); i++ {
+		sqlCount := " select count(*) from " + tablename + " where " + where + " and ItemId=" + arr_id[i]
+		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
+			}
+		}
+		if total == 0 {
+			sql := " INSERT INTO " + tablename + " (TestId,ItemId,SortCode) VALUES (" + TestId + "," + arr_id[i] + "," + SortCode + ") "
+			_, err := s.DBE.Exec(sql)
+			if err != nil {
+				return err
+			}
+		}
+	}
+	return nil
+}
+
+func (s *InspectionprojectService) GetPagingWithSortCode(order string, acccode string, entitiesPtr interface{}, where string) (total int64) {
+	var err error
+	var resultsSlice []map[string][]byte
+	//获取表名
+	tableName := acccode + GetTableName(entitiesPtr)
+	if len(where) == 0 {
+		src := `select * from ` + tableName + ` order by ` + order
+		utils.DBE.Sql(src).Find(entitiesPtr)
+		//获取总记录数
+		sql := "SELECT COUNT(*) AS total FROM " + tableName
+		resultsSlice, err = s.DBE.Query(sql)
+		LogError(err)
+
+	} else {
+		src := `select * from ` + tableName + ` where ` + where + ` order by ` + order
+		utils.DBE.Sql(src).Find(entitiesPtr)
+		sql := "SELECT COUNT(*) AS total FROM " + tableName + " 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 *InspectionprojectService) InspectionDetail(maintable string, branchtable string, where string) []TestDetail {
+	var err error
+	if where == "" {
+		where = " 1=1 "
+	}
+	var sql string
+	sql = `select b.*,a.TestName from ` + maintable + ` a left join ` + branchtable + ` b on a.Id=b.TestListId where ` + where
+	List := make([]TestDetail, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+	return List
+}
+
+func (s *InspectionprojectService) GetpackagecategoryListandparentname(tablename string, pageIndex, itemsPerPage int64, order, searchstring string) (int64, []TestPackageCategoryParent) {
+	var err error
+	var total int64
+	//获取总记录数
+	sqlCount := "select  count(*)  from " + tablename + " a where " + searchstring + " "
+	var sql, limitstr string = "", ""
+	if pageIndex > 0 {
+		limitstr = ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
+	}
+	sql = `select a.*,b.FullName Parentname from ` + tablename + ` a
+		left join ` + tablename + ` b on a.ParentId=b.Id
+		where ` + searchstring + ` order by ` + order + limitstr
+	List := make([]TestPackageCategoryParent, 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 *InspectionprojectService) GetAllParentByTopId(topid string) string {
+	mod := new(Id_Str)
+	s.DBE.Sql(`select fun_gettestpackcategoryparentlist ('` + topid + `') as Id`).Get(mod)
+	return mod.Id
+}
+
+//服务-根据BarCode获取DataGatherItem
+func (s *InspectionprojectService) GetDatagatherBycode(infotable, listtable, sampletable, barcode string) []HandServiceModel {
+	var sql string
+	sql = `SELECT b.Id,b.TestName,b.DataGatherItem,c.CollectDate,a.TATTime from  ` + infotable + ` a 
+		left join ` + listtable + ` b on a.TestListId = b.Id 
+		left join ` + sampletable + ` c on a.SampleCode = c.SampleCode
+		where a.BarCode =  '` + barcode + `'`
+	List := make([]HandServiceModel, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	return List
+}
+
+//根据实验室检验查询质控项
+func (s *InspectionprojectService) QuerySelectPackItemlist(packageitemtable, itemslisttable string, where string) []SelectPackItemList {
+	var err error
+	var sql string
+	sql = `select a.ItemsListId,b.ItemName from ` + packageitemtable + ` a
+        left join ` + itemslisttable + ` b on a.ItemsListId=b.Id where ` + where
+	List := make([]SelectPackItemList, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+	return List
+}
+
+//检验套餐包下拉框显示
+func (s *InspectionprojectService) GetTestPackageviewlist(packagetable string, packageitems string, where string) []TestPackage {
+	var err error
+	if where == "" {
+		where = " 1=1 "
+	}
+	var sql string
+	sql = `select a.* from ` + packagetable + ` a left join ` + packageitems + ` b on a.Id=b.PackageId where ` + where + ` group by a.Id `
+
+	List := make([]TestPackage, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+
+	return List
+}
+
+//查询检验套餐包
+func (s *InspectionprojectService) GetAllPackageviewlist(packagetable string, where string) []TestPackage {
+	var err error
+	if where == "" {
+		where = " 1=1 "
+	}
+	var sql string
+	sql = `select * from ` + packagetable + ` where ` + where
+
+	List := make([]TestPackage, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	LogError(err)
+
+	return List
+}

+ 31 - 0
src/dashoo.cn/backend/api/business/samplessource/samplessource.go

@@ -172,3 +172,34 @@ type Microbial struct {
 	DiagnosticTime_int int64     `xorm:"-"` //诊断时间int格式
 	Birthday_int       int64     `xorm:"-"` //生日int格式
 }
+
+type DonorsInfoWithDetail struct {
+	Id              int
+	AccCode         string
+	Name            string
+	IdCard          string
+	Sex             int
+	Age             int
+	Birthday        time.Time
+	Nation          string
+	InnerNo         string
+	Telephone       string
+	Email           string
+	Mobile          string
+	MaritalStatus   int
+	IllnessName     string
+	Duty            string
+	CompanyName     string
+	HomeAddress     string
+	Remark          string
+	SourceId        int
+	InspectionNum   string
+	ParentId        int
+	PathologicalNum string
+	CreateUserId    int
+	CreateBy        string
+	CreateOn        time.Time
+	ModifiedUserId  int
+	ModifiedBy      string
+	ModifiedOn      time.Time
+}

+ 16 - 0
src/dashoo.cn/backend/api/business/samplessource/samplessourceService.go

@@ -45,3 +45,19 @@ func (s *SamplesSourceService) GetInnerNo(maintable string, where string) int64
 	}
 	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
+}

+ 1230 - 0
src/dashoo.cn/backend/api/controllers/biobank/inspection.go

@@ -0,0 +1,1230 @@
+package biobank
+
+import (
+	"encoding/json"
+	"strings"
+
+	"dashoo.cn/backend/api/business/inspectionproject"
+	"dashoo.cn/backend/api/business/organize"
+	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/utils"
+)
+
+// Operations about Users
+type InspectionController struct {
+	BaseController
+}
+
+// 检测套餐model
+type Packagemodel struct {
+	Itemlist       []string `json:"itemlist"`
+	SelectPacktype string   `json:"selectpacktype"`
+}
+
+// TestListIdmodel
+type TestListIdModel struct {
+	TestListId int
+}
+
+// @Title  根据ID查检验项目明细
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inspectiondelte/:Id [get]
+func (this *InspectionController) Inspectiondelte() {
+	Id := this.Ctx.Input.Param(":Id")
+	where := " TestListId=" + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	list := svc.QueryinspectionEntity(this.User.AccCode+TestItemsListName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 根据用户AccCode get检验主表
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inspectionviewlist [get]
+func (this *InspectionController) Inspectionviewlist() {
+	page := this.GetPageInfoForm()
+	searchkey := this.GetString("searchkey")
+	var list []inspectionproject.TestList
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	if searchkey != "" {
+		where = where + " and (TestName like '%" + searchkey + "%')"
+	}
+	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, "Id ", true, &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加检验项目
+// @Description 新增检验项目
+// @Param	body	body	business.device.DeviceChannels	"检验项目信息"
+// @Success	200	{object} controllers.Request
+// @router / [post]
+func (this *InspectionController) AddPost() {
+	var testlistentity inspectionproject.TestList
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.CreateBy = this.User.Realname
+	testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+TestListName, &testlistentity)
+	var errinfo ErrorInfo
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title  get主表详情
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inspectiondetail [get]
+func (this *InspectionController) InspectionDetailviewlist() {
+	TestName := this.GetString("TestName")
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " a.TestName='" + TestName + "' "
+	list := svc.InspectionDetail(this.User.AccCode+TestItemsListName, this.User.AccCode+TestListDetailName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 查询所有质控项
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inquireallqc [get]
+func (this *InspectionController) InquireAllQC() {
+	where := " IsQC=1 "
+	testlistid := this.GetString("testlistid")
+	if testlistid != "" {
+		where += " and TestListId = " + testlistid
+	}
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	list := svc.QueryinspectionEntity(this.User.AccCode+TestItemsListName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /inspdelete/:Id [delete]
+func (this *InspectionController) Inspdelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+TestListName, where)
+	where2 := " TestListId = " + Id
+	err2 := svc.DeleteEntityBytbl(this.User.AccCode+TestItemsListName, where2)
+	if err == nil && err2 == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 根据用户AccCode编辑检验项目
+// @Description 编辑检验项目
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /edititem [put]
+func (this *InspectionController) EditItem() {
+	TestListId := this.GetString("TestListId")
+	var errinfo ErrorInfo
+	if TestListId == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	var model inspectionproject.TestItemsList
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " TestListId= " + TestListId
+	//	arr := strings.Join(model.Sensors, ",")
+	err := svc.UpdateTestItemsList(this.User.AccCode+TestItemsListName, "", where)
+
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title  get主表
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /allinspectionviewlist [get]
+func (this *InspectionController) AllInspectionviewlist() {
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	list := make([]inspectionproject.TestList, 0)
+	total := svc.GetPagingWithSortCode("LabId desc", this.User.AccCode, &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title  根据检验ID 查询质控项
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /labtestqc/:id [get]
+func (this *InspectionController) LabTestQC() {
+	id := this.Ctx.Input.Param(":id")
+	where := " TestListId= " + id + " "
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	list := svc.QueryQCEntityByTestId(this.User.AccCode+TestItemsListName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 根据实验室ID get检验
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /gettestbylabid/:LabId [get]
+func (this *InspectionController) GetTestByLabId() {
+	LabId := this.Ctx.Input.Param(":LabId")
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " LabId= " + LabId
+	list := svc.GetPaginginspviewlist(this.User.AccCode+TestListName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 查询所有实验室
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getlaboratorys [get]
+func (this *InspectionController) Getlaboratorys() {
+	where := " 1=1 "
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	var list []inspectionproject.TestLaboratory
+	svc.GetEntitysByWhere(this.User.AccCode+TestLaboratoryName, where, &list)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 获取编辑时的样本类型信息
+// @Description 获取编辑时的样本类型信息
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getmodel/:id [get]
+func (this *InspectionController) GetModel() {
+	id := this.Ctx.Input.Param(":id")
+	var model inspectionproject.TestList
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+TestListName, id, &model) //修改时获取列表
+	this.Data["json"] = &model
+	this.ServeJSON()
+}
+
+// @Title 编辑检测项目
+// @Description 编辑检测项目
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /:id [put]
+func (this *InspectionController) EditPost() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model inspectionproject.TestList
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var entityempty inspectionproject.TestList
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验-" + model.TestName
+	var cols []string = []string{"TestName", "Laboratory", "Describe", "LabId", "DataGatherItem", "TATTimeItem", "TATTimeItemValue", "TATTime"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestListName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "检验项目")
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 添加检验项目
+// @Description 新增检验项目
+// @Param	body	body	business.device.DeviceChannels	"检验项目信息"
+// @Success	200	{object} controllers.Request
+// @router /testItemslist [post]
+func (this *InspectionController) AddPostdetail() {
+	var testlistentity inspectionproject.TestItemsList
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.CreateBy = this.User.Realname
+	testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+TestItemsListName, &testlistentity)
+	var errinfo ErrorInfo
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取编辑时的样本类型信息
+// @Description 获取编辑时的样本类型信息
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getdetails/:id [get]
+func (this *InspectionController) Getdetails() {
+	id := this.Ctx.Input.Param(":id")
+	var model inspectionproject.TestItemsList
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+TestItemsListName, id, &model) //修改时获取列表
+	this.Data["json"] = &model
+	this.ServeJSON()
+}
+
+// @Title 编辑检测项目
+// @Description 编辑检测项目
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /testItemslist/:id [put]
+func (this *InspectionController) EditPostdetail() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model inspectionproject.TestItemsList
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var entityempty inspectionproject.TestItemsList
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验-" + model.ItemName
+	var cols []string = []string{"Code", "ItemName", "Reference", "Unit", "InterfaceCode", "AdjustmentCoefficient", "NumberDecimals", "ItemCategory", "ReferenceLower", "ReferenceUpper", "ReferenceItem", "TestListId", "ModifiedBy", "ModifiedUserId", "IsQC", "ValueMethod", "CalcMethod"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestItemsListName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "检验项目")
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /detailsdelete/:Id [delete]
+func (this *InspectionController) Detailsdelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+TestItemsListName, where)
+	where2 := " TestListId = " + Id
+	err2 := svc.DeleteEntityBytbl(this.User.AccCode+TestItemsListName, where2)
+	if err == nil && err2 == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 编辑检测项目
+// @Description 编辑检测项目
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /setdetailisqc/:id [put]
+func (this *InspectionController) Setdetailisqc() {
+	id := this.Ctx.Input.Param(":id")
+	isqc := this.GetString("isqc")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model inspectionproject.TestItemsList
+	var entityempty inspectionproject.TestItemsList
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	model.IsQC, _ = utils.StrTo(isqc).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验项状态设置-" + this.GetString("name")
+	var cols []string = []string{"IsQC", "ModifiedBy", "ModifiedUserId"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestItemsListName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "检验项目")
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title  根据ID查试管
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inspectiontesttube/:Id [get]
+func (this *InspectionController) Inspectiontesttube() {
+	Id := this.Ctx.Input.Param(":Id")
+	where := " TestListId=" + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	var list []inspectionproject.TestListDetail
+	svc.GetEntitysByOrderbyWhere(this.User.AccCode+TestListDetailName, where, "Id desc", &list)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加试管类型
+// @Description 新增试管类型
+// @Param	body	body	business.device.DeviceChannels	"试管类型"
+// @Success	200	{object} controllers.Request
+// @router /testtubeadd [post]
+func (this *InspectionController) Testtubeadd() {
+	var testlistentity inspectionproject.TestListDetail
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.CreateBy = this.User.Realname
+	testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+TestListDetailName, &testlistentity)
+	var errinfo ErrorInfo
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取编辑时的样本类型信息
+// @Description 获取编辑时的试管类型信息
+// @Success 200 {object} business.device.DeviceChannels
+// @router /gettesttube/:id [get]
+func (this *InspectionController) Gettesttube() {
+	id := this.Ctx.Input.Param(":id")
+	var model inspectionproject.TestListDetail
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+TestListDetailName, id, &model) //修改时获取列表
+	var datainfo DataInfo
+	datainfo.Items = model
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 编辑试管信息
+// @Description 编辑试管信息
+// @Param	id	path	string	true		"需要修改的试管信息"
+// @Param	body	body	business.device.DeviceChannels	"试管信息"
+// @Success	200	{object} controllers.Request
+// @router /testtubeedit/:id [put]
+func (this *InspectionController) Testtubeedit() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model inspectionproject.TestListDetail
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var entityempty inspectionproject.TestListDetail
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验-" + model.TestTube
+	var cols []string = []string{"SampleType", "TestTube", "Size", "Number", "StorageConditions", "TestListId", "SampleTypeId", "TestTubeId"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestListDetailName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "试管信息")
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /testtubedelete/:Id [delete]
+func (this *InspectionController) Testtubedelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+TestListDetailName, where)
+	where2 := " TestListId = " + Id
+	err2 := svc.DeleteEntityBytbl(this.User.AccCode+TestListDetailName, where2)
+	if err == nil && err2 == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 根据用户AccCode get检验主表
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inspectiontestprinttemplate [get]
+func (this *InspectionController) Inspectiontestprinttemplate() {
+	page := this.GetPageInfoForm()
+	searchkey := this.GetString("searchkey")
+	var list []inspectionproject.TestPrintTemplate
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	if searchkey != "" {
+		where = where + " and (TempName like '%" + searchkey + "%')"
+	}
+	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, "Id", true, &list, where)
+	//根据组织ID查询父级并输出
+	svv := organize.GetOrganizeService(utils.DBE)
+	var i int
+	var listtotal int
+	var length int
+	length = len(list)
+	if length < int(page.Size) {
+		listtotal = length
+	} else {
+		listtotal = int(page.Size)
+	}
+	for i = 0; i < listtotal; i++ {
+		var hoapital = ""
+		model := svv.GetAllParentByTopAccCode(list[i].OrgId, this.User.AccCode)
+		arr := strings.Split(model, ",")
+		for j := len(arr) - 4; j >= 0; j-- {
+			if j == 0 {
+				where := " Id= " + arr[j]
+				entity := svv.QueryEntity(where)
+				hoapital += entity.Fullname
+			} else {
+				where := " Id= " + arr[j]
+				entity := svv.QueryEntity(where)
+				hoapital += entity.Fullname + "/"
+			}
+		}
+		list[i].OrgId = hoapital
+	}
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加打印模板
+// @Description 新增打印模板
+// @Param	body	body	business.device.DeviceChannels	"打印模板"
+// @Success	200	{object} controllers.Request
+// @router /testprinttemplateadd [post]
+func (this *InspectionController) Testprinttemplateadd() {
+	var testlistentity inspectionproject.TestPrintTemplate
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.CreateBy = this.User.Realname
+	testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+TestPrintTemplateName, &testlistentity)
+	var errinfo ErrorInfo
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取编辑时的打印模板信息
+// @Description 获取编辑时的打印模板信息
+// @Success 200 {object} business.device.DeviceChannels
+// @router /gettestprinttemplate/:id [get]
+func (this *InspectionController) Gettestprinttemplate() {
+	id := this.Ctx.Input.Param(":id")
+	var model inspectionproject.TestPrintTemplate
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+TestPrintTemplateName, id, &model) //修改时获取列表
+	this.Data["json"] = &model
+	this.ServeJSON()
+}
+
+// @Title 获取编辑时的打印模板信息
+// @Description 获取编辑时的打印模板信息
+// @Success 200 {object} business.device.DeviceChannels
+// @router /gettemplate/:id [get]
+func (this *InspectionController) Gettemplate() {
+	id := this.Ctx.Input.Param(":id")
+	var model inspectionproject.TestPrintTemplate
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+TestPrintTemplateName, id, &model) //修改时获取列表
+	this.Data["json"] = &model
+	this.ServeJSON()
+}
+
+// @Title 编辑打印模板
+// @Description 编辑打印模板
+// @Param	id	path	string	true		"需要修改的打印模板"
+// @Param	body	body	business.device.DeviceChannels	"打印模板"
+// @Success	200	{object} controllers.Request
+// @router /testprinttemplateedit/:id [put]
+func (this *InspectionController) Testprinttemplateedit() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model inspectionproject.TestPrintTemplate
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var entityempty inspectionproject.TestPrintTemplate
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验-" + model.TempName
+	var cols []string = []string{"Id", "OrgId", "TempName", "FileName", "UseModule", "Describe"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestPrintTemplateName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "打印模板")
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 删除单条信息打印模板
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /testprinttemplatedelete/:Id [delete]
+func (this *InspectionController) Testprinttemplatedelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+TestPrintTemplateName, where)
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 根据用户AccCode get检验主表
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /inspectionpackagecategory [get]
+func (this *InspectionController) Inspectionpackagecategory() {
+	page := this.GetPageInfoForm()
+	searchkey := this.GetString("keyword")
+	// var list []inspectionproject.TestPackageCategory
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	if searchkey != "" {
+		where = where + " and (a.FullName like '%" + searchkey + "%')"
+	}
+	parentid := this.GetString("parentId")
+	if parentid != "" {
+		where = where + " and (a.ParentId = " + parentid + " or a.Id = " + parentid + ")"
+	}
+	total, list := svc.GetpackagecategoryListandparentname(this.User.AccCode+TestPackageCategoryName, page.CurrentPage, page.Size, "Id desc", where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加检验套餐
+// @Description 新增检验套餐
+// @Param	body	body	business.device.DeviceChannels	"检验套餐"
+// @Success	200	{object} controllers.Request
+// @router /packagecategoryadd [post]
+func (this *InspectionController) Packagecategoryadd() {
+	var testlistentity inspectionproject.TestPackageCategory
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.CreateBy = this.User.Realname
+	testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+TestPackageCategoryName, &testlistentity)
+	var errinfo ErrorInfo
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 删除单条信息检验套餐
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /packagecategorydelete/:Id [delete]
+func (this *InspectionController) Packagecategorydelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+TestPackageCategoryName, where)
+
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 报警器列表
+// @Description 设备列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /inspectionpackagecategoryall [get]
+func (this *InspectionController) Inspectionpackagecategoryall() {
+	var list []inspectionproject.TestPackageCategory
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	svc.GetEntitysByOrderbyWhere(this.User.AccCode+TestPackageCategoryName, where, "Id desc", &list)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 编辑检验套餐
+// @Description 编辑检验套餐
+// @Param	id	path	string	true		"需要修改的检验套餐"
+// @Param	body	body	business.device.DeviceChannels	"检验套餐"
+// @Success	200	{object} controllers.Request
+// @router /packagecategoryedit/:id [put]
+func (this *InspectionController) Packagecategoryedit() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model inspectionproject.TestPackageCategory
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var entityempty inspectionproject.TestPackageCategory
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验-" + model.FullName
+	var cols []string = []string{"Id", "ParentId", "FullName", "Describe"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestPackageCategoryName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "检验套餐")
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取父集列表
+// @Description 获取父集列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /packagecategoryparentlist/:id [get]
+func (this *InspectionController) Packagecategoryparentlist() {
+	id := this.Ctx.Input.Param(":id")
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	var errinfo ErrorInfo
+	errinfo.Message = svc.GetAllParentByTopId(id)
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+// @Title 根据用户AccCode get检验主表
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /packagesettinglist [get]
+func (this *InspectionController) Packagesettinglist() {
+	page := this.GetPageInfoForm()
+	searchkey := this.GetString("searchkey")
+	var list []inspectionproject.TestPackage
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	if searchkey != "" {
+		where = where + " and (PackageName like '%" + searchkey + "%')"
+	}
+	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, "Id", false, &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 根据项目Id查找包含项目的套餐
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getpackagebytestid/:TestListId [get]
+func (this *InspectionController) GetPackageByTestId() {
+	TestListId := this.Ctx.Input.Param(":TestListId")
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " b.TestListId= " + TestListId
+	list := svc.GetTestPackageviewlist(this.User.AccCode+TestPackageName, this.User.AccCode+TestPackageItemsName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 查询所有套餐
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getallpackage [get]
+func (this *InspectionController) GetAllPackage() {
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	where := " 1=1 "
+	list := svc.GetAllPackageviewlist(this.User.AccCode+TestPackageName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 查询所有质控项
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getCategoryName [get]
+func (this *InspectionController) GetCategoryName() {
+	where := " 1=1 "
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	var list []inspectionproject.TestPackage
+	svc.GetEntitysByWhere(this.User.AccCode+TestPackageName, where, &list)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 查询所有质控项
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getIteamName [get]
+func (this *InspectionController) GetIteamName() {
+	where := " 1=1 "
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	var list []inspectionproject.TestItemsList
+	svc.GetEntitysByWhere(this.User.AccCode+TestItemsListName, where, &list)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加检验套餐
+// @Description 新增检验套餐
+// @Param	body	body	business.device.DeviceChannels	"检验套餐"
+// @Success	200	{object} controllers.Request
+// @router /packagesettingadd [post]
+func (this *InspectionController) Packagesettingadd() {
+	var testlistentity inspectionproject.TestPackage
+	var uimodel Packagemodel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	json.Unmarshal(jsonblob, &uimodel)
+
+	testlistentity.CreateBy = this.User.Realname
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	var errinfo ErrorInfo
+	// 生成套餐
+	if uimodel.SelectPacktype == "1" {
+		_, err := svc.InsertEntityBytbl(this.User.AccCode+TestPackageName, &testlistentity)
+
+		if err == nil {
+
+			for _, itemid := range uimodel.Itemlist {
+				itemid = strings.Split(itemid, ",")[0]
+				var testpackitementity inspectionproject.TestPackageItems
+				testpackitementity.PackageId = testlistentity.Id
+				testpackitementity.ItemsListId, _ = utils.StrTo(itemid).Int()
+				var testlistmodel TestListIdModel
+				svc.GetEntityByWhere(this.User.AccCode+TestItemsListName, "Id = "+utils.ToStr(testpackitementity.ItemsListId), &testlistmodel)
+				testpackitementity.TestListId = testlistmodel.TestListId
+
+				svc.InsertEntityBytbl(this.User.AccCode+TestPackageItemsName, &testpackitementity)
+			}
+
+			errinfo.Message = "操作成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		} else {
+			errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	} else if uimodel.SelectPacktype == "2" { // 生成单个套餐
+
+		for _, itemid := range uimodel.Itemlist {
+
+			testlistentity.PackageName = strings.Split(itemid, ",")[1]
+			_, err := svc.InsertEntityBytbl(this.User.AccCode+TestPackageName, &testlistentity)
+
+			if err == nil {
+
+				itemid = strings.Split(itemid, ",")[0]
+				var testpackitementity inspectionproject.TestPackageItems
+				testpackitementity.PackageId = testlistentity.Id
+				testpackitementity.ItemsListId, _ = utils.StrTo(itemid).Int()
+				var testlistmodel TestListIdModel
+				svc.GetEntityByWhere(this.User.AccCode+TestItemsListName, "Id = "+utils.ToStr(testpackitementity.ItemsListId), &testlistmodel)
+				testpackitementity.TestListId = testlistmodel.TestListId
+
+				svc.InsertEntityBytbl(this.User.AccCode+TestPackageItemsName, &testpackitementity)
+			}
+
+		}
+
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+
+	}
+
+}
+
+// @Title  根据ID查检验项目明细
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getIteamNames/:Id [get]
+func (this *InspectionController) GetIteamNames() {
+	Id := this.Ctx.Input.Param(":Id")
+	where := " TestListId=" + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	list := svc.QueryinspectionEntity(this.User.AccCode+TestItemsListName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /packagesettingdelete/:Id [delete]
+func (this *InspectionController) Packagesettingdelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+TestPackageName, where)
+
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取编辑时的
+// @Description 获取编辑时的检验套餐类型
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getpackage/:id [get]
+func (this *InspectionController) Getpackage() {
+	id := this.Ctx.Input.Param(":id")
+	var model inspectionproject.TestPackage
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+TestPackageName, id, &model) //修改时获取列表
+	this.Data["json"] = &model
+	this.ServeJSON()
+
+}
+
+// @Title  根据ID查检验项目明细
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getpackageId/:Id [get]
+func (this *InspectionController) GetpackageId() {
+	Id := this.Ctx.Input.Param(":Id")
+	where := " a.PackageId=" + Id
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+	list := svc.QuerySelectPackItemlist(this.User.AccCode+TestPackageItemsName, this.User.AccCode+TestItemsListName, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 编辑套餐检验
+// @Description 编辑套餐检验
+// @Param	id	path	string	true		"需要修改的套餐检验"
+// @Param	body	body	business.device.DeviceChannels	"套餐检验"
+// @Success	200	{object} controllers.Request
+// @router /packagesettingedit/:id [put]
+func (this *InspectionController) Packagesettingedit() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var uimodel Packagemodel
+	var model inspectionproject.TestPackage
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	json.Unmarshal(jsonblob, &uimodel)
+	var entityempty inspectionproject.TestPackage
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+
+	opdesc := "检验-" + model.PackageName
+	var cols []string = []string{"PackageName", "CategoryId", "CategoryName", "Describe", "PackageCode"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+TestPackageName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "试管信息")
+
+	if err == nil {
+
+		var errinfo ErrorInfo
+		if id == "" {
+			errinfo.Message = "操作失败!请求信息不完整"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
+		where := " PackageId= " + id
+		svc := inspectionproject.GetInspectionprojectService(utils.DBE)
+		err := svc.DeleteEntityBytbl(this.User.AccCode+TestPackageItemsName, where)
+
+		if err == nil {
+			for _, itemid := range uimodel.Itemlist {
+
+				itemid = strings.Split(itemid, ",")[0]
+
+				var testpackitementity inspectionproject.TestPackageItems
+				testpackitementity.PackageId, _ = utils.StrTo(id).Int()
+
+				testpackitementity.ItemsListId, _ = utils.StrTo(itemid).Int()
+				var testlistmodel TestListIdModel
+
+				svc.GetEntityByWhere(this.User.AccCode+TestItemsListName, "id = "+utils.ToStr(testpackitementity.ItemsListId), &testlistmodel)
+				testpackitementity.TestListId = testlistmodel.TestListId
+
+				svc.InsertEntityBytbl(this.User.AccCode+TestPackageItemsName, &testpackitementity)
+			}
+
+			errinfo.Message = "操作成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+
+		}
+
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}

+ 66 - 1
src/dashoo.cn/backend/api/controllers/biobank/samplessource.go

@@ -4,10 +4,12 @@ package biobank
 import (
 	"encoding/json"
 	//"fmt"
-
+	"strconv"
 	"strings"
 	"time"
 
+	"github.com/tealeg/xlsx"
+
 	"dashoo.cn/backend/api/business/donorsinfo"
 	"dashoo.cn/backend/api/business/equipment"
 	"dashoo.cn/backend/api/business/samplesfileinfo"
@@ -900,3 +902,66 @@ func (this *SamplesSourceController) Getdevicesamples() {
 	this.Data["json"] = &datainfo
 	this.ServeJSON()
 }
+
+// @Title get 样本采集导出
+// @Description get SampleType by token
+// @Success 200 {object} sampletype.SampleType
+// @router /exportexcel [get]
+func (this *SamplesSourceController) ListToExcel() {
+	var title []string
+	titlestring := "监护人姓名,身份证号,性别,年龄,出生日期,民族,样本条码,联系号码,邮箱,婚姻状况,所患疾病,职业,工作单位,家庭住址,备注信息,检验单号,病理号,"
+	title = strings.Split(titlestring, ",")
+	where := " 1=1 "
+	svc := samplessource.GetSamplesSourceService(utils.DBE)
+	datas := svc.GetSampleSourceInfo(this.User.AccCode+DonorstbName, this.User.AccCode+SampleTestMainName, this.User.AccCode+DonorsDetailName, where)
+	f := xlsx.NewFile()
+	this.DaySaveXlsxExport("样本来源导出信息", title, datas, f)
+
+	SaveDirectory("static/file/excel/report/" + this.GetAccode())
+	f.Save("static/file/excel/report/" + this.GetAccode() + "/" + utils.TimeFormat(time.Now(), "200612") + "样本来源导出信息.xlsx")
+	this.Ctx.WriteString("/static/file/excel/report/" + this.GetAccode() + "/" + utils.TimeFormat(time.Now(), "200612") + "样本来源导出信息.xlsx")
+}
+
+func (this *SamplesSourceController) DaySaveXlsxExport(name string, title []string, datas []samplessource.DonorsInfoWithDetail, f *xlsx.File) {
+	sheet, _ := f.AddSheet(name)
+	rowhead := sheet.AddRow()
+	rowhead.WriteSlice(&title, -1)
+
+	for _, v := range datas {
+
+		strsex := ""
+		if v.Sex == 0 {
+			strsex = "男"
+		} else if v.Sex == 1 {
+			strsex = "女"
+		} else {
+			strsex = ""
+		}
+		strmarital := ""
+		if v.MaritalStatus == 0 {
+			strmarital = "未婚"
+		} else if v.MaritalStatus == 1 {
+			strmarital = "已婚"
+		} else if v.MaritalStatus == 2 {
+			strmarital = "未知"
+		} else {
+			strmarital = ""
+		}
+
+		datastring := v.Name + "," + v.IdCard + "," + strsex + "," + strconv.Itoa(v.Age) + "," + utils.ToStr(v.Birthday.Format("2006-01-02")) + "," + v.Nation + "," + v.InnerNo + "," + v.Telephone + "," + v.Email + "," + strmarital + "," + v.IllnessName + "," + v.Duty + "," + v.CompanyName + "," + v.HomeAddress + "," + v.Remark + "," + v.InspectionNum + "," + v.PathologicalNum
+		cellname := strings.Split(datastring, ",")
+		row := sheet.AddRow()
+		row.WriteSlice(&cellname, -1)
+	}
+	sheet.Cols[1].Width = 20
+	sheet.Cols[4].Width = 20
+	sheet.Cols[6].Width = 20
+	sheet.Cols[7].Width = 15
+	sheet.Cols[8].Width = 20
+	sheet.Cols[12].Width = 20
+	sheet.Cols[13].Width = 50
+	sheet.Cols[14].Width = 30
+	sheet.Cols[15].Width = 20
+	sheet.Cols[16].Width = 20
+	sheet.Cols[17].Width = 20
+}

+ 5 - 0
src/dashoo.cn/backend/api/routers/router.go

@@ -298,6 +298,11 @@ func init() {
 				&biobank.SamplesSourceController{},
 			),
 		),
+		beego.NSNamespace("/inspection",
+			beego.NSInclude(
+				&biobank.InspectionController{},
+			),
+		),
 		beego.NSNamespace("/sampletest",
 			beego.NSInclude(
 				&biobank.SampleTestController{},

binární
src/dashoo.cn/backend/api/static/file/excel/report/srNA2/2019326样本来源导出信息.xlsx


+ 2 - 1
src/dashoo.cn/frontend_web/nuxt.config.ignore.js

@@ -141,7 +141,8 @@ module.exports = {
   */
   env: {
     appclient: 'biobank', //因顿LIMS:lims,样本库:biobank,细胞制备:cellbank,样本搜索判断,登录跳转判断
-    imgserverhost: 'http://52.80.133.197:9081', // BioBank服务地址,图片上传文件
+    imgserverhost: 'http://localhost:9081',
+    //imgserverhost: 'http://52.80.133.197:9081', // BioBank服务地址,图片上传文件
     upfilehost: 'http://weed1.labsop.cn:9333/dir/assign', // 附件上传
   },
   ignore: [

+ 2 - 2
src/dashoo.cn/frontend_web/nuxt.config.js

@@ -159,8 +159,8 @@ module.exports = {
   },
 
   axios: {
-    baseURL: '//localhost:9081/api/' // 本机开发使用
-    // baseURL: '//52.80.133.197:9081/api/' // BioBank on AWS发布使用
+    // baseURL: '//localhost:9081/api/' // 本机开发使用
+    baseURL: '//52.80.133.197:9081/api/' // BioBank on AWS发布使用
     // baseURL: '//188.188.30.89:9081/api/' //临沂使用
     // baseURL: '//api09.labsop.cn/api/'
     // baseURL: '//192.168.0.211:10091/api/' // 花生所系统

+ 41 - 8
src/dashoo.cn/frontend_web/src/pages/biobank/source/index.vue

@@ -10,6 +10,8 @@
           <el-breadcrumb-item>样本来源</el-breadcrumb-item>
         </el-breadcrumb>
         <span style="float: right;">
+          <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="exportExcel">导出
+          </el-button>
           <router-link :to="'/biobank/source/addsource/operation'">
             <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">添加</el-button>
           </router-link>
@@ -32,14 +34,15 @@
           </el-form-item>
         </el-form>
       </div>
-      
+
       <el-table :data="donorsList" border style="width: 100%" height="calc(100vh - 230px)" @sort-change="orderby">
         <el-table-column label="操作" width="80" align="center" fixed>
           <template slot-scope="scope">
             <router-link :to="'/biobank/source/'+scope.row.Id+'/operation'">
               <el-button type="text" title="编辑" size="small" icon="el-icon-edit"></el-button>
             </router-link>
-            <el-button size="small" type="text" icon="el-icon-delete" style="margin-left:3px;" title="删除" @click="delSamplesSource(scope.row)"></el-button>
+            <el-button size="small" type="text" icon="el-icon-delete" style="margin-left:3px;" title="删除"
+              @click="delSamplesSource(scope.row)"></el-button>
             <router-link :to="'/biobank/source/'+ scope.row.Id + '/sourceinfo'">
               <el-button size="small" title="详情" type="text" style="margin-left:3px;">
                 <i class="icon icon-eye"></i>
@@ -47,7 +50,8 @@
             </router-link>
           </template>
         </el-table-column>
-        <el-table-column prop="Name" sortable min-width="80" label="姓名" align="center" show-overflow-tooltip></el-table-column>
+        <el-table-column prop="Name" sortable min-width="80" label="姓名" align="center" show-overflow-tooltip>
+        </el-table-column>
         <el-table-column prop="InnerNo" sortable align="center" :label="(acc==='srNA2')?'样本条码':'内部编码'" min-width="100"
           show-overflow-tooltip></el-table-column>
         <el-table-column prop="Sex" sortable align="center" label="性别" min-width="60" show-overflow-tooltip>
@@ -56,7 +60,8 @@
             <el-tag v-if="scope.row.Sex === 1">女</el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="Telephone" sortable min-width="90" label="联系号码" align="center" show-overflow-tooltip></el-table-column>
+        <el-table-column prop="Telephone" sortable min-width="90" label="联系号码" align="center" show-overflow-tooltip>
+        </el-table-column>
         <!-- <el-table-column prop="CreateBy" sortable label="录入人" min-width="80" align="center" show-overflow-tooltip></el-table-column> -->
         <el-table-column prop="CreateOn" sortable label="操作时间" align="center" show-overflow-tooltip min-width="170">
           <template slot-scope="scope">
@@ -65,7 +70,8 @@
         </el-table-column>
       </el-table>
       <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
-        :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="currentItemCount">
+        :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper"
+        :total="currentItemCount">
       </el-pagination>
     </el-card>
 
@@ -79,7 +85,8 @@
           </el-col>
           <el-col :span="12">
             <el-form-item :label="(acc==='srNA2')?'样本条码':'内部编码'">
-              <el-input size="mini" v-model="searchform.innerno" style="width:100%" :placeholder="(acc==='srNA2')?'请输入样本条码':'请输入内部编码'"></el-input>
+              <el-input size="mini" v-model="searchform.innerno" style="width:100%"
+                :placeholder="(acc==='srNA2')?'请输入样本条码':'请输入内部编码'"></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -94,12 +101,14 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="开始日期">
-              <el-date-picker size="mini" style="width: 220px" v-model="searchform.starttime" type="date" placeholder="选择日期"></el-date-picker>
+              <el-date-picker size="mini" style="width: 220px" v-model="searchform.starttime" type="date"
+                placeholder="选择日期"></el-date-picker>
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="结束日期">
-              <el-date-picker size="mini" style="width: 220px" v-model="searchform.endtime" type="date" placeholder="选择日期"></el-date-picker>
+              <el-date-picker size="mini" style="width: 220px" v-model="searchform.endtime" type="date"
+                placeholder="选择日期"></el-date-picker>
             </el-form-item>
           </el-col>
         </el-row>
@@ -152,6 +161,7 @@
     },
     created() {
       this.initdata()
+      this.filehost = process.env.imgserverhost
       this.acc = this.authUser.Profile.AccCode
       //this.getuserlist()
     },
@@ -218,6 +228,29 @@
             .catch(() => {})
         }).catch(() => {})
       },
+      exportExcel() {
+        let _this = this
+        _this.$confirm("此操作将导出所有数据, 是否继续?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: 'info'
+        }).then(() => {
+          _this.exportloading = true
+          _this.$axios.get('/samplessource/exportexcel', {})
+            .then(res => {
+              _this.exportloading = false
+              window.location = this.filehost + res.data
+            })
+            .catch(err => {
+              _this.$message({
+                type: 'warning',
+                message: '导出数据出错,请重新操作!'
+              })
+              _this.exportloading = false
+              console.error(err)
+            })
+        }).catch(() => {})
+      },
       //列表排序功能
       orderby(column) {
         if (column.order == 'ascending') {