Kaynağa Gözat

fix (库内整理, 入库, 出库)
1. 库内整理添加 logic_id ,去掉为0为空判断
2. 暂时注释掉 数据库自动备份
3. 库内整理的 结构体 改为 beego 框架的 xorm
4. 库内整理 添加 更新所有无样本的 盒子 为空盒
5. 取出待放回, 入库 更新剩余容量
6. 出库更新冻融次数

xuchl 4 yıl önce
ebeveyn
işleme
659ab03927

+ 0 - 97
app/model/bank_arrange_main/bank_arrange_main_entity.go

@@ -1,97 +0,0 @@
-// ==========================================================================
-// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
-// ==========================================================================
-
-package bank_arrange_main
-
-import (
-	"database/sql"
-	"github.com/gogf/gf/database/gdb"
-	"github.com/gogf/gf/os/gtime"
-)
-
-// Entity is the golang structure for table bank_arrange_main.
-type Entity struct {
-    Id             int         `orm:"Id,primary"     json:"id"`                //                                                                                                            
-    EntryNo        string      `orm:"EntryNo"        json:"entry_no"`          // 申请单号                                                                                                   
-    TaskType       int         `orm:"TaskType"       json:"task_type"`         // 入库申请类型: 1.基点自动化设备  2 非基点普通设备                                                          
-    Status         int         `orm:"Status"         json:"status"`            // 0:未提交;1:提交待审核;2:审核通过;3:审核不通过;   4:确认过                                          
-    OperationBy    string      `orm:"OperationBy"    json:"operation_by"`      // 申请人                                                                                                     
-    Section        string      `orm:"Section"        json:"section"`           // 领用部门                                                                                                   
-    EntryTime      *gtime.Time `orm:"EntryTime"      json:"entry_time"`        // 申请时间                                                                                                   
-    ConUserId      int         `orm:"ConUserId"      json:"con_user_id"`       // 审核人Id                                                                                                   
-    ConUserBy      string      `orm:"ConUserBy"      json:"con_user_by"`       // 审核人                                                                                                     
-    ConTime        *gtime.Time `orm:"ConTime"        json:"con_time"`          // 审核时间                                                                                                   
-    TaskStatus     int         `orm:"TaskStatus"     json:"task_status"`       // 任务执行状态 0 未执行 1. 任务已发送 2. 任务已接收 3. 任务激活 4. 执行失败 5. 任务成功 6. 执行中 7. 已驳回  
-    Remark         string      `orm:"Remark"         json:"remark"`            // 备注                                                                                                       
-    Exception      string      `orm:"Exception"      json:"exception"`         // 异常信息                                                                                                   
-    AuditorRemark  string      `orm:"AuditorRemark"  json:"auditor_remark"`    // 审核备注                                                                                                   
-    CreateOn       *gtime.Time `orm:"CreateOn"       json:"create_on"`         //                                                                                                            
-    CreateUserId   string      `orm:"CreateUserId"   json:"create_user_id"`    //                                                                                                            
-    CreateBy       string      `orm:"CreateBy"       json:"create_by"`         //                                                                                                            
-    ModifiedOn     *gtime.Time `orm:"ModifiedOn"     json:"modified_on"`       //                                                                                                            
-    ModifiedUserId string      `orm:"ModifiedUserId" json:"modified_user_id"`  //                                                                                                            
-    ModifiedBy     string      `orm:"ModifiedBy"     json:"modified_by"`       //                                                                                                            
-    Reason         int         `orm:"Reason"         json:"reason"`            // 原因,ID是字典明细                                                                                          
-    EquipmentId    int         `orm:"EquipmentId"    json:"equipment_id"`      // 设备id                                                                                                     
-    ShelfAndBoxIds string      `orm:"ShelfAndBoxIds" json:"shelf_and_box_ids"` // 选中的架子及盒子id                                                                                         
-    BoxCount       string      `orm:"BoxCount"       json:"box_count"`         // 整理盒子数量                                                                                               
-    SampleCount    string      `orm:"SampleCount"    json:"sample_count"`      // 整理样本数量                                                                                               
-}
-
-// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
-// the data and where attributes for empty values.
-// Deprecated.
-func (r *Entity) OmitEmpty() *arModel {
-	return Model.Data(r).OmitEmpty()
-}
-
-// Inserts does "INSERT...INTO..." statement for inserting current object into table.
-// Deprecated.
-func (r *Entity) Insert() (result sql.Result, err error) {
-	return Model.Data(r).Insert()
-}
-
-// InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
-// Deprecated.
-func (r *Entity) InsertIgnore() (result sql.Result, err error) {
-	return Model.Data(r).InsertIgnore()
-}
-
-// Replace does "REPLACE...INTO..." statement for inserting current object into table.
-// If there's already another same record in the table (it checks using primary key or unique index),
-// it deletes it and insert this one.
-// Deprecated.
-func (r *Entity) Replace() (result sql.Result, err error) {
-	return Model.Data(r).Replace()
-}
-
-// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
-// It updates the record if there's already another same record in the table
-// (it checks using primary key or unique index).
-// Deprecated.
-func (r *Entity) Save() (result sql.Result, err error) {
-	return Model.Data(r).Save()
-}
-
-// Update does "UPDATE...WHERE..." statement for updating current object from table.
-// It updates the record if there's already another same record in the table
-// (it checks using primary key or unique index).
-// Deprecated.
-func (r *Entity) Update() (result sql.Result, err error) {
-	where, args, err := gdb.GetWhereConditionOfStruct(r)
-	if err != nil {
-		return nil, err
-	}
-	return Model.Data(r).Where(where, args).Update()
-}
-
-// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
-// Deprecated.
-func (r *Entity) Delete() (result sql.Result, err error) {
-	where, args, err := gdb.GetWhereConditionOfStruct(r)
-	if err != nil {
-		return nil, err
-	}
-	return Model.Where(where, args).Delete()
-}

+ 0 - 349
app/model/bank_arrange_main/bank_arrange_main_model.go

@@ -1,349 +0,0 @@
-// ==========================================================================
-// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
-// ==========================================================================
-
-package bank_arrange_main
-
-import (
-	"context"
-	"database/sql"
-	"github.com/gogf/gf/database/gdb"
-	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/frame/gmvc"
-	"time"
-)
-
-// arModel is a active record design model for table bank_arrange_main operations.
-type arModel struct {
-	gmvc.M
-}
-
-var (
-	// Table is the table name of bank_arrange_main.
-	Table = "bank_arrange_main"
-	// Model is the model object of bank_arrange_main.
-	Model = &arModel{g.DB("default").Model(Table).Safe()}
-	// Columns defines and stores column names for table bank_arrange_main.
-	Columns = struct {
-		Id              string //                                                                                                            
-        EntryNo         string // 申请单号                                                                                                   
-        TaskType        string // 入库申请类型: 1.基点自动化设备  2 非基点普通设备                                                          
-        Status          string // 0:未提交;1:提交待审核;2:审核通过;3:审核不通过;   4:确认过                                          
-        OperationBy     string // 申请人                                                                                                     
-        Section         string // 领用部门                                                                                                   
-        EntryTime       string // 申请时间                                                                                                   
-        ConUserId       string // 审核人Id                                                                                                   
-        ConUserBy       string // 审核人                                                                                                     
-        ConTime         string // 审核时间                                                                                                   
-        TaskStatus      string // 任务执行状态 0 未执行 1. 任务已发送 2. 任务已接收 3. 任务激活 4. 执行失败 5. 任务成功 6. 执行中 7. 已驳回  
-        Remark          string // 备注                                                                                                       
-        Exception       string // 异常信息                                                                                                   
-        AuditorRemark   string // 审核备注                                                                                                   
-        CreateOn        string //                                                                                                            
-        CreateUserId    string //                                                                                                            
-        CreateBy        string //                                                                                                            
-        ModifiedOn      string //                                                                                                            
-        ModifiedUserId  string //                                                                                                            
-        ModifiedBy      string //                                                                                                            
-        Reason          string // 原因,ID是字典明细                                                                                          
-        EquipmentId     string // 设备id                                                                                                     
-        ShelfAndBoxIds  string // 选中的架子及盒子id                                                                                         
-        BoxCount        string // 整理盒子数量                                                                                               
-        SampleCount     string // 整理样本数量
-	}{
-		Id:             "Id",              
-        EntryNo:        "EntryNo",         
-        TaskType:       "TaskType",        
-        Status:         "Status",          
-        OperationBy:    "OperationBy",     
-        Section:        "Section",         
-        EntryTime:      "EntryTime",       
-        ConUserId:      "ConUserId",       
-        ConUserBy:      "ConUserBy",       
-        ConTime:        "ConTime",         
-        TaskStatus:     "TaskStatus",      
-        Remark:         "Remark",          
-        Exception:      "Exception",       
-        AuditorRemark:  "AuditorRemark",   
-        CreateOn:       "CreateOn",        
-        CreateUserId:   "CreateUserId",    
-        CreateBy:       "CreateBy",        
-        ModifiedOn:     "ModifiedOn",      
-        ModifiedUserId: "ModifiedUserId",  
-        ModifiedBy:     "ModifiedBy",      
-        Reason:         "Reason",          
-        EquipmentId:    "EquipmentId",     
-        ShelfAndBoxIds: "ShelfAndBoxIds",  
-        BoxCount:       "BoxCount",        
-        SampleCount:    "SampleCount",
-	}
-)
-
-// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
-// of current DB object and with given context in it.
-// Note that this returned DB object can be used only once, so do not assign it to
-// a global or package variable for long using.
-func (m *arModel) Ctx(ctx context.Context) *arModel {
-	return &arModel{m.M.Ctx(ctx)}
-}
-
-// As sets an alias name for current table.
-func (m *arModel) As(as string) *arModel {
-	return &arModel{m.M.As(as)}
-}
-
-// TX sets the transaction for current operation.
-func (m *arModel) TX(tx *gdb.TX) *arModel {
-	return &arModel{m.M.TX(tx)}
-}
-
-// Master marks the following operation on master node.
-func (m *arModel) Master() *arModel {
-	return &arModel{m.M.Master()}
-}
-
-// Slave marks the following operation on slave node.
-// Note that it makes sense only if there's any slave node configured.
-func (m *arModel) Slave() *arModel {
-	return &arModel{m.M.Slave()}
-}
-
-// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
-// The parameter <table> can be joined table and its joined condition,
-// and also with its alias name, like:
-// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
-// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
-func (m *arModel) LeftJoin(table ...string) *arModel {
-	return &arModel{m.M.LeftJoin(table ...)}
-}
-
-// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
-// The parameter <table> can be joined table and its joined condition,
-// and also with its alias name, like:
-// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
-// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
-func (m *arModel) RightJoin(table ...string) *arModel {
-	return &arModel{m.M.RightJoin(table ...)}
-}
-
-// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
-// The parameter <table> can be joined table and its joined condition,
-// and also with its alias name, like:
-// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
-// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
-func (m *arModel) InnerJoin(table ...string) *arModel {
-	return &arModel{m.M.InnerJoin(table ...)}
-}
-
-// Fields sets the operation fields of the model, multiple fields joined using char ','.
-func (m *arModel) Fields(fieldNamesOrMapStruct ...interface{}) *arModel {
-	return &arModel{m.M.Fields(fieldNamesOrMapStruct...)}
-}
-
-// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
-func (m *arModel) FieldsEx(fieldNamesOrMapStruct ...interface{}) *arModel {
-	return &arModel{m.M.FieldsEx(fieldNamesOrMapStruct...)}
-}
-
-// Option sets the extra operation option for the model.
-func (m *arModel) Option(option int) *arModel {
-	return &arModel{m.M.Option(option)}
-}
-
-// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
-// the data and where attributes for empty values.
-func (m *arModel) OmitEmpty() *arModel {
-	return &arModel{m.M.OmitEmpty()}
-}
-
-// Filter marks filtering the fields which does not exist in the fields of the operated table.
-func (m *arModel) Filter() *arModel {
-	return &arModel{m.M.Filter()}
-}
-
-// Where sets the condition statement for the model. The parameter <where> can be type of
-// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
-// multiple conditions will be joined into where statement using "AND".
-// Eg:
-// Where("uid=10000")
-// Where("uid", 10000)
-// Where("money>? AND name like ?", 99999, "vip_%")
-// Where("uid", 1).Where("name", "john")
-// Where("status IN (?)", g.Slice{1,2,3})
-// Where("age IN(?,?)", 18, 50)
-// Where(User{ Id : 1, UserName : "john"})
-func (m *arModel) Where(where interface{}, args ...interface{}) *arModel {
-	return &arModel{m.M.Where(where, args...)}
-}
-
-// WherePri does the same logic as Model.Where except that if the parameter <where>
-// is a single condition like int/string/float/slice, it treats the condition as the primary
-// key value. That is, if primary key is "id" and given <where> parameter as "123", the
-// WherePri function treats the condition as "id=123", but Model.Where treats the condition
-// as string "123".
-func (m *arModel) WherePri(where interface{}, args ...interface{}) *arModel {
-	return &arModel{m.M.WherePri(where, args...)}
-}
-
-// And adds "AND" condition to the where statement.
-func (m *arModel) And(where interface{}, args ...interface{}) *arModel {
-	return &arModel{m.M.And(where, args...)}
-}
-
-// Or adds "OR" condition to the where statement.
-func (m *arModel) Or(where interface{}, args ...interface{}) *arModel {
-	return &arModel{m.M.Or(where, args...)}
-}
-
-// Group sets the "GROUP BY" statement for the model.
-func (m *arModel) Group(groupBy string) *arModel {
-	return &arModel{m.M.Group(groupBy)}
-}
-
-// Order sets the "ORDER BY" statement for the model.
-func (m *arModel) Order(orderBy ...string) *arModel {
-	return &arModel{m.M.Order(orderBy...)}
-}
-
-// Limit sets the "LIMIT" statement for the model.
-// The parameter <limit> can be either one or two number, if passed two number is passed,
-// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
-// statement.
-func (m *arModel) Limit(limit ...int) *arModel {
-	return &arModel{m.M.Limit(limit...)}
-}
-
-// Offset sets the "OFFSET" statement for the model.
-// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
-func (m *arModel) Offset(offset int) *arModel {
-	return &arModel{m.M.Offset(offset)}
-}
-
-// Page sets the paging number for the model.
-// The parameter <page> is started from 1 for paging.
-// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
-func (m *arModel) Page(page, limit int) *arModel {
-	return &arModel{m.M.Page(page, limit)}
-}
-
-// Batch sets the batch operation number for the model.
-func (m *arModel) Batch(batch int) *arModel {
-	return &arModel{m.M.Batch(batch)}
-}
-
-// Cache sets the cache feature for the model. It caches the result of the sql, which means
-// if there's another same sql request, it just reads and returns the result from cache, it
-// but not committed and executed into the database.
-//
-// If the parameter <duration> < 0, which means it clear the cache with given <name>.
-// If the parameter <duration> = 0, which means it never expires.
-// If the parameter <duration> > 0, which means it expires after <duration>.
-//
-// The optional parameter <name> is used to bind a name to the cache, which means you can later
-// control the cache like changing the <duration> or clearing the cache with specified <name>.
-//
-// Note that, the cache feature is disabled if the model is operating on a transaction.
-func (m *arModel) Cache(duration time.Duration, name ...string) *arModel {
-	return &arModel{m.M.Cache(duration, name...)}
-}
-
-// Data sets the operation data for the model.
-// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
-// Eg:
-// Data("uid=10000")
-// Data("uid", 10000)
-// Data(g.Map{"uid": 10000, "name":"john"})
-// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
-func (m *arModel) Data(data ...interface{}) *arModel {
-	return &arModel{m.M.Data(data...)}
-}
-
-// All does "SELECT FROM ..." statement for the model.
-// It retrieves the records from table and returns the result as []*Entity.
-// It returns nil if there's no record retrieved with the given conditions from table.
-//
-// The optional parameter <where> is the same as the parameter of Model.Where function,
-// see Model.Where.
-func (m *arModel) All(where ...interface{}) ([]*Entity, error) {
-	all, err := m.M.All(where...)
-	if err != nil {
-		return nil, err
-	}
-	var entities []*Entity
-	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
-		return nil, err
-	}
-	return entities, nil
-}
-
-// One retrieves one record from table and returns the result as *Entity.
-// It returns nil if there's no record retrieved with the given conditions from table.
-//
-// The optional parameter <where> is the same as the parameter of Model.Where function,
-// see Model.Where.
-func (m *arModel) One(where ...interface{}) (*Entity, error) {
-	one, err := m.M.One(where...)
-	if err != nil {
-		return nil, err
-	}
-	var entity *Entity
-	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
-		return nil, err
-	}
-	return entity, nil
-}
-
-// FindOne retrieves and returns a single Record by Model.WherePri and Model.One.
-// Also see Model.WherePri and Model.One.
-func (m *arModel) FindOne(where ...interface{}) (*Entity, error) {
-	one, err := m.M.FindOne(where...)
-	if err != nil {
-		return nil, err
-	}
-	var entity *Entity
-	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
-		return nil, err
-	}
-	return entity, nil
-}
-
-// FindAll retrieves and returns Result by by Model.WherePri and Model.All.
-// Also see Model.WherePri and Model.All.
-func (m *arModel) FindAll(where ...interface{}) ([]*Entity, error) {
-	all, err := m.M.FindAll(where...)
-	if err != nil {
-		return nil, err
-	}
-	var entities []*Entity
-	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
-		return nil, err
-	}
-	return entities, nil
-}
-
-// Chunk iterates the table with given size and callback function.
-func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error) bool) {
-	m.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*Entity
-		err = result.Structs(&entities)
-		if err == sql.ErrNoRows {
-			return false
-		}
-		return callback(entities, err)
-	})
-}
-
-// LockUpdate sets the lock for update for current operation.
-func (m *arModel) LockUpdate() *arModel {
-	return &arModel{m.M.LockUpdate()}
-}
-
-// LockShared sets the lock in share mode for current operation.
-func (m *arModel) LockShared() *arModel {
-	return &arModel{m.M.LockShared()}
-}
-
-// Unscoped enables/disables the soft deleting feature.
-func (m *arModel) Unscoped() *arModel {
-	return &arModel{m.M.Unscoped()}
-}

+ 30 - 27
src/dashoo.cn/genepoint_srv/business/arrangeService/arrange.go

@@ -1,6 +1,9 @@
 package arrangeService
 
-import "github.com/gogf/gf/os/gtime"
+import (
+	"github.com/gogf/gf/os/gtime"
+	"time"
+)
 
 const UNEXECUTED = 0
 const SENT = 1
@@ -13,31 +16,31 @@ const REJECT = 7
 
 
 type Bank_Arrange_Main struct {
-	Id             int         `json:"Id"    ` //
-	EntryNo        string      `json:"EntryNo"       ` // 申请单号
-	TaskType       int         `json:"TaskType"      ` // 入库申请类型: 1.基点自动化设备  2 非基点普通设备
-	Status         int         `json:"Status"        ` // 0:未提交;1:提交待审核;2:审核通过;3:审核不通过;   4:确认过
-	OperationBy    string      `json:"OperationBy"   ` // 申请人
-	Section        string      `json:"Section"       ` // 领用部门
-	EntryTime      *gtime.Time `json:"EntryTime"     ` // 申请时间
-	ConUserId      int         `json:"ConUserId"     ` // 审核人Id
-	ConUserBy      string      `json:"ConUserBy"     ` // 审核人
-	ConTime        *gtime.Time `json:"ConTime"       ` // 审核时间
-	TaskStatus     int         `json:"TaskStatus"    ` // 任务执行状态 0 未执行 1. 任务已发送 2. 任务已接收 3. 任务激活 4. 执行失败 5. 任务成功 6. 执行中 7. 已驳回
-	Remark         string      `json:"Remark"        ` // 备注
-	Exception      string      `json:"Exception"     ` // 异常信息
-	AuditorRemark  string      `json:"AuditorRemark" ` // 审核备注
-	CreateOn       *gtime.Time `json:"CreateOn"      ` //
-	CreateUserId   string      `json:"CreateUserId"  ` //
-	CreateBy       string      `json:"CreateBy"      ` //
-	ModifiedOn     *gtime.Time `json:"ModifiedOn"    ` //
-	ModifiedUserId string      `json:"ModifiedUserId"` //
-	ModifiedBy     string      `json:"ModifiedBy"    ` //
-	Reason         int         `json:"Reason"        ` // 原因,ID是字典明细
-	EquipmentId    int         `json:"EquipmentId"   ` // 容器ID
-	ShelfAndBoxIds string      `json:"ShelfAndBoxIds"` // 选中的架子及盒子id
-	BoxCount       string      `json:"BoxCount"      ` // 整理盒子数量
-	SampleCount    string      `json:"SampleCount"   ` // 整理样本数量
+	Id             int         `xorm:"int(10)"     json:"id"`                //
+	EntryNo        string      `xorm:"VARCHAR(50)"        json:"entry_no"`          // 申请单号
+	TaskType       int         `xorm:"int(10)"      json:"task_type"`         // 入库申请类型: 1.基点自动化设备  2 非基点普通设备
+	Status         int         `xorm:"int(10)"         json:"status"`            // 0:未提交;1:提交待审核;2:审核通过;3:审核不通过;   4:确认过
+	OperationBy    string     `xorm:"VARCHAR(50)"    json:"operation_by"`      // 申请人
+	Section        string      `xorm:"VARCHAR(50)"       json:"section"`           // 领用部门
+	EntryTime      time.Time `xorm:"DATETIME"      json:"entry_time"`        // 申请时间
+	ConUserId      int         `xorm:"int(10)"      json:"con_user_id"`       // 审核人Id
+	ConUserBy      string      `xorm:"VARCHAR(50)"      json:"con_user_by"`       // 审核人
+	ConTime        time.Time `xorm:"DATETIME"        json:"con_time"`          // 审核时间
+	TaskStatus     int         `xorm:"int(10)"     json:"task_status"`       // 任务执行状态 0 未执行 1. 任务已发送 2. 任务已接收 3. 任务激活 4. 执行失败 5. 任务成功 6. 执行中 7. 已驳回
+	Remark         string      `xorm:"VARCHAR(50)"         json:"remark"`            // 备注
+	Exception      string      `xorm:"VARCHAR(50)"     json:"exception"`         // 异常信息
+	AuditorRemark  string      `xorm:"VARCHAR(50)"  json:"auditor_remark"`    // 审核备注
+	CreateOn       time.Time `xorm:"DATETIME created"       json:"create_on"`         //
+	CreateUserId   string      `xorm:"VARCHAR(50)"   json:"create_user_id"`    //
+	CreateBy       string      `xorm:"VARCHAR(50)"     json:"create_by"`         //
+	ModifiedOn     time.Time `xorm:"DATETIME""     json:"modified_on"`       //
+	ModifiedUserId string      `xorm:"VARCHAR(50)" json:"modified_user_id"`  //
+	ModifiedBy     string      `xorm:"VARCHAR(50)"     json:"modified_by"`       //
+	Reason         int        `xorm:"int(10)"         json:"reason"`            // 原因,ID是字典明细
+	EquipmentId    int         `xorm:"int(10)"    json:"equipment_id"`      // 设备id
+	ShelfAndBoxIds string      `xorm:"VARCHAR(50)" json:"shelf_and_box_ids"` // 选中的架子及盒子id
+	BoxCount       string      `xorm:"VARCHAR(50)"       json:"box_count"`         // 整理盒子数量
+	SampleCount    string      `xorm:"VARCHAR(50)"   json:"sample_count"`      // 整理样本数量
 }
 
 type Bank_Arrange_Detail struct {
@@ -161,4 +164,4 @@ type Shelf struct {
 	Id int // 冻存架id
 	XStation   int   // 位置 X代表第几列
 	YStation   int    // 位置 Y代表第几行
-}
+}

+ 34 - 10
src/dashoo.cn/genepoint_srv/business/arrangeService/arrangeService.go

@@ -36,8 +36,8 @@ func GetArrangeService(xormEngine *xorm.Engine) *ArrangeService {
  * @Author 徐春林
  * @Description // 查询库内整理申请人
  * @Date 15:41 2021/3/30
- * @Param 
- * @return 
+ * @Param
+ * @return
  **/
 // 获取申请单创建人
 func (this *ArrangeService) GetOperUser(EntryNo string) (user string) {
@@ -139,9 +139,11 @@ func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, messa
 		var tubes = value.Tubes
 		fmt.Println("样本位置信息:", tubes)
 		//新增方法 更新位置信息
-		this.UpdatePosition(Rack_id, tubes, res)
+		this.UpdatePosition(taskId,Rack_id, tubes, res)
 	}
 	if isEnd {
+		// 根据盒子中样本数量更新样本信息
+		this.GetAllBox(taskId)
 		err = this.StatusModifyWithDetail(taskId)
 	}
 	return err
@@ -231,7 +233,7 @@ func (this *ArrangeService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
  * @Param
  * @return
  **/
-func (this *ArrangeService) UpdatePosition(rack_id string, tubes []Tube, entity ResponseEntity) {
+func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube, entity ResponseEntity) {
 	// 根据返回的报文中的盒子标识,获取盒子类型
 	sql := "select Id,RowNum,ColumnNum from bank_box where Barcode ='" + rack_id + "'"
 	var box Box
@@ -259,7 +261,7 @@ func (this *ArrangeService) UpdatePosition(rack_id string, tubes []Tube, entity
 		sql = "update bank_sample set BoxId = '" + utils.ToStr(box.Id) + "',Position = '" + utils.ToStr(box_y) + ";" + utils.ToStr(box_x) + "' ,PositionInfo  = concat( REVERSE(SUBSTR(REVERSE(PositionInfo) FROM INSTR(REVERSE(PositionInfo),'-')+1)),'-" + position + "' ) where barcode ='" + id + "' "
 		//执行sql 更新位置和坐标信息
 		this.DBE.Exec(sql)
-		this.UpdateDetail(id, entity, rack_id)
+		this.UpdateDetail(id, entity, rack_id,taskId)
 	}
 }
 
@@ -270,10 +272,10 @@ func (this *ArrangeService) UpdatePosition(rack_id string, tubes []Tube, entity
  * @Param
  * @return
  **/
-func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity, rack_id string) {
+func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity, rack_id,taskId string) {
 
 	glog.Info("修改detail:", entity)
-
+	arrangeMain := this.GetArrangeMain(taskId)
 	var shelf Shelf
 	var equipmentid string
 	var ShelfId string
@@ -292,8 +294,13 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 			ShelfId = strconv.Itoa(shelf.Id)
 			sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where barcode ='" + BarCode + "' "
 			this.DBE.Exec(sql)
+			updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + BarCode + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
+			this.DBE.Exec(updatesql)
+			updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  barcode = '" + BarCode + "' and task_id = '"+taskId+"'"
+			this.DBE.Exec(updTaskSql)
 		}
 
+
 	}
 }
 
@@ -307,7 +314,7 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 func (this *ArrangeService) StatusModifyWithDetail(task_id string) error {
 	status := SUCCESS
 	// 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
-	sql := "SELECT count(*) FROM `" + TABLE_ARRANGE_DETAIL + "` a  JOIN `" + TABLE_ARRANGE_MAIN + "` b ON a.parentid = b.Id WHERE ( a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS) + ")"
+	sql := "SELECT count(*) FROM `" + TABLE_ARRANGE_DETAIL + "` a  JOIN `" + TABLE_ARRANGE_MAIN + "` b ON a.parentid = b.Id WHERE (b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS) + ")"
 
 	var total int
 	//_, err := this.DBE.Exec(sql)
@@ -384,6 +391,23 @@ func (this *ArrangeService) GetAbnormalDataAndUpdate(taskId string, entity Respo
 func (this *ArrangeService) GetArrangeMain(entryNo string) Bank_Arrange_Main {
 	where := "entryNo = '" + entryNo + "'"
 	var entity Bank_Arrange_Main
-	this.GetEntity(&entity, where)
+	sql := "SELECT * FROM bank_arrange_main WHERE " + where
+	//results, err := this.DBE.Query(sql)
+	//fmt.Println(results)
+	_,err := this.DBE.SQL(sql).Get(&entity)
+	fmt.Println("执行错误:", err)
 	return entity
-}
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 获取整理范围的所有盒子, 根据盒子中样本数 更新空盒状态
+ * @Date 9:42 2021/3/31
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) GetAllBox(taskId string)  {
+	arrangeMain := this.GetArrangeMain(taskId)
+	sql := "update bank_box a set a.IsEmpty = (case when (select count(b.Id) from bank_sample b where a.Id = b.BoxId) > 0 then 0 else 1 end) where a.EquipmentId = '"+utils.ToStr(arrangeMain.EquipmentId)+"'"
+	this.DBE.Exec(sql)
+}

+ 7 - 7
src/dashoo.cn/genepoint_srv/business/converseService/converse.go

@@ -163,7 +163,7 @@ type OutSingle struct {
 	Tube       int    `json:"tube,omitempty"`
 	Id         string `json:"id,omitempty"`
 	Rack_id    string `json:"rack_id,omitempty"`
-	Source     Source `json:"source,omitempty"`
+	//Source     Source `json:"source,omitempty"`
 	//Target     Target `json:"target,omitempty"`
 	Tubes      []Tube `json:"tubes"`
 	Exceptions []int  `json:"exceptions,omitempty"`
@@ -304,15 +304,15 @@ type Shelf struct {
 
 // 自动库内整理结构体
 type Arrange struct {
-	Logic_id int	`json:"logic_id,omitempty"`
+	Logic_id int `json:"logic_id"`
 	Position Position	`json:"position,omitempty"`
 }
 
 // 整理范围结构体
 type Position struct {
-	Cu int	`json:"cu,omitempty"`
-	Ltu int	`json:"ltu,omitempty"`
-	Group int	`json:"group,omitempty"`
-	Unit int	`json:"unit,omitempty"`
-	Pos int	`json:"pos,omitempty"`
+	Cu int	`json:"cu"`
+	Ltu int	`json:"ltu"`
+	Group int	`json:"group"`
+	Unit int	`json:"unit"`
+	Pos int	`json:"pos"`
 }

+ 57 - 13
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -36,7 +36,7 @@ const STATUS_UNLOCK = "0"
 const RK_PASS = "2"
 const CK_PASS_ONHOLD = "3" //保留位置
 const CK_PASS_DONE = "4"   //已归档
-const LOGIC_ID = 0   // 逻辑分区Id
+const LOGIC_ID = "0"   // 逻辑分区Id
 
 type ConverseService struct {
 	ServiceBase
@@ -419,25 +419,40 @@ func handleQueryTube(entity *RequestEntity, detail *Sample_Storage_Task) {
  * @return
  **/
 func handleArrange (entity *RequestEntity, detail *Sample_Storage_Task) {
-	var one Arrange
+
 	if entity.Data.Operation_mode == "" {
 		entity.Data.Operation_mode = detail.OperaMode
 	}
-	one.Logic_id = LOGIC_ID // 当前逻辑分区设置为 0
+
+	position := Position{
+		Cu: detail.Cu,
+		Ltu:  detail.Ltu,
+		Group:  detail.Group,
+		Unit:  detail.Unit,
+		Pos:  detail.Pos,
+	}
+	one := Arrange{
+		Logic_id: 0,
+		Position:  position,
+	}
+	var ones []Arrange
+	ones = append(ones,one )
+	/*var one Arrange
+	one.Logic_id = 0 // 当前逻辑分区设置为 0
 	one.Position.Cu = detail.Cu
 	one.Position.Ltu = detail.Ltu
 	one.Position.Group = detail.Group
 	one.Position.Unit = detail.Unit
-	one.Position.Pos = detail.Pos
+	one.Position.Pos = detail.Pos*/
 
-	entity.Data.Task_data = one
+	entity.Data.Task_data = ones
 }
 // 查询申请单详情下状态,存在一条子任务失败的情况,则整个申请单状态为失败
 func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 	status := SUCCESS
 	// 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
 
-	sql := "SELECT count(*) FROM `" + TABLE_APPLY_DETAIL + "` a  JOIN `" + TABLE_SAMPLE_APPLY + "` b ON a.parentid = b.Id WHERE ( a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS) + ")"
+	sql := "SELECT count(*) FROM `" + TABLE_APPLY_DETAIL + "` a  JOIN `" + TABLE_SAMPLE_APPLY + "` b ON a.parentid = b.Id WHERE (b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS) + ")"
 
 	//total, err := this.DBE.Table(TABLE_APPLY_DETAIL ).Join("", TABLE_SAMPLE_APPLY ,"a.parentid = b.Id").Where(" a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS)).Count()
 	//if err != nil && err != sql.ErrNoRows {
@@ -590,13 +605,22 @@ func (this *ConverseService) handleSampleSuccess(idsStr string, response string,
 
 //入库成功, 修改样本数据库状态信息
 func (this *ConverseService) sampleRKSuccessDBModify(idsStr string, parentId int) error {
+	fmt.Println("开始更新样本入库信息, 包括更新容量,状态, 锁定状态")
+	// add by 徐春林  基点入库成功, 根据样本入库详情表中 更新 样本的 剩余容量
+	var list []Bank_Apply_Detail
+	// add by 徐春林 20211224 添加主单Id 作为条件
+	err := this.DBE.Where("barcode IN (" + idsStr + ")  and ParentId = '" + strconv.Itoa(parentId)+"'").Find(&list)
+	for _, one := range list {
+		fmt.Println("更新入库容量:", one.BarCode)
+		sql := "UPDATE " + TABLE_SAMPLE + " a SET Capacity = (SELECT Capacity from " + TABLE_APPLY_DETAIL + " b where b.BarCode = '" + one.BarCode + "' and b.ParentId = '" + strconv.Itoa(parentId) + "' ) Where barcode = '" + one.BarCode + "'"
+		_, err = this.DBE.Exec(sql)
+	}
 	updatesql := "UPDATE " + TABLE_APPLY_DETAIL + " SET IsLocked = '" + STATUS_UNLOCK + "', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode IN (" + idsStr + ")" + " AND parentid = '" + strconv.Itoa(parentId) + "'"
 	// 更新样本状态解锁,原盒子id置为0
 	updatesql2 := "UPDATE " + TABLE_SAMPLE + " SET IsLocked = '" + STATUS_UNLOCK + "', IState = '" + RK_PASS + "',SourceBoxId = 0 WHERE barcode IN (" + idsStr + ")"
 
 	//更新每个样本的孔位信息
-
-	_, err := this.DBE.Exec(updatesql)
+	_, err = this.DBE.Exec(updatesql)
 	_, err = this.DBE.Exec(updatesql2)
 	return err
 }
@@ -606,16 +630,23 @@ func (this *ConverseService) sampleCKSuccessDBModify(idsStr string, parentId int
 	var list []Bank_Apply_Detail
 	var onHold []string
 	var done []string
-	err := this.DBE.Where("barcode IN (" + idsStr + ")").Find(&list)
+	// add by 徐春林 20211224 添加主单Id 作为条件
+	err := this.DBE.Where("barcode IN (" + idsStr + ")   and ParentId = '" + strconv.Itoa(parentId)+"'").Find(&list)
 	for _, one := range list {
+		// add by 徐春林
+		beforeSql := "UPDATE "+TABLE_SAMPLE+" a SET FreezingNum = (SELECT FreezingNum from "+TABLE_APPLY_DETAIL+" b where b.BarCode = '"+one.BarCode+"' and b.ParentId = '"+ strconv.Itoa(parentId)+"' ) Where barcode = '"+one.BarCode+"'"
+		_,err =this.DBE.Exec(beforeSql)
 		if strconv.Itoa(one.RecoveryId) == CK_PASS_ONHOLD {
+			// 查询样本出库详情, 更新 样本冻融次数信息
 			onHold = append(onHold, one.BarCode)
 		} else if strconv.Itoa(one.RecoveryId) == CK_PASS_DONE {
+			// 查询样本出库详情, 更新 样本冻融次数信息
 			done = append(done, one.BarCode)
 		}
 	}
-
-	sql := "UPDATE " + TABLE_SAMPLE + " SET istate = '" + CK_PASS_ONHOLD + "', islocked = '" + STATUS_UNLOCK + "' WHERE barcode IN ('" + strings.Join(onHold, "','") + "')"
+	// 基点出库取出待放回, 清空样本位置信息, 但是状态保留为 取出待放回
+	// sql := "UPDATE " + TABLE_SAMPLE + " SET istate = '" + CK_PASS_ONHOLD + "', islocked = '" + STATUS_UNLOCK + "' WHERE barcode IN ('" + strings.Join(onHold, "','") + "')"
+	sql := "UPDATE " + TABLE_SAMPLE + " SET istate = '" + CK_PASS_ONHOLD + "', islocked = '" + STATUS_UNLOCK + "',equipmentid = '0', shelfid = '0',boxid= '0', position = '', positioninfo = '' WHERE barcode IN ('" + strings.Join(onHold, "','") + "')"
 	sql2 := "UPDATE " + TABLE_SAMPLE + " SET istate = '" + CK_PASS_DONE + "', islocked = '" + STATUS_UNLOCK + "', equipmentid = '0', shelfid = '0',boxid= '0', position = '', positioninfo = '' WHERE barcode IN ('" + strings.Join(done, "','") + "')"
 	sql3 := "UPDATE " + TABLE_APPLY_DETAIL + " SET IsLocked = '" + STATUS_UNLOCK + "', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode IN (" + idsStr + ")" + " AND parentid = '" + strconv.Itoa(parentId) + "'"
 	_, err = this.DBE.Exec(sql)
@@ -669,6 +700,8 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 		taskType = "tube_retrieving"
 		//operaIds, abnormalIds = this.getAllSampleIdsFromResEntity(entity)
 		operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
+		// 管出库需要 更新 转运空盒 为 源盒
+		this.UpdateBoxInfoCK(entity,applyMain.Id)
 	}
 
 	// 此处判断,如果是冻存盒整盒入库,需要更新盒子位置信息  盒  冻存盒当前的 所在的冻存架的id
@@ -776,6 +809,7 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int)
 	// 循环处理返回的数据,如果出现多盒存入的分批处理
 
 	for i := range entity.Data.Actual_data {
+		TaskId := entity.Data.Task_id
 		boxBarcode := entity.Data.Actual_data[i].Rack_id // 冻存盒编号
 		//Cu := entity.Data.Actual_data[i].source.Cu			// 设备编号
 		//Ltu := entity.Data.Actual_data[i].source.Ltu		//
@@ -798,7 +832,17 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int)
 		_, err = this.DBE.Exec("update bank_box set EquipmentId=null,shelfId=null,XStation =null,YStation =null,IsLocked = 0  where Barcode ='" + boxBarcode + "' ")
 		// 更新 当前冰箱冻存盒容量 信息
 		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -2 where shelfId =" + utils.ToStr(shelf.Id) + "")
-
+		updatesql := "UPDATE " + TABLE_DETAIL + " SET taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE parentid = '" + strconv.Itoa(parentId) + "'"
+		_,err = this.DBE.Exec(updatesql)
+		if err != nil {
+			return err
+		}
+		// 更新任务状态
+		updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  BoxBarcode = '" + boxBarcode + "' and task_id = '"+TaskId+"'"
+		_,err =this.DBE.Exec(updTaskSql)
+		if err != nil {
+			return err
+		}
 	}
 
 	err = this.UpdateBoxAbnormalInfo(entity,parentId)
@@ -820,7 +864,7 @@ func (this *ConverseService) UpdateBoxIsLocked(taskId string) (err error) {
 
 	 err = this.DBE.SQL(sql).Find(&task)
 
-	_, err = this.DBE.Exec("update bank_box set IsLocked = 0  where BoxBarcode ='" + task.BoxId + "' ")
+	_, err = this.DBE.Exec("update bank_box set IsLocked = 0  where Barcode ='" + task.BoxId + "' ")
 	return err
 }
 

+ 1 - 1
src/dashoo.cn/genepoint_srv/main.go

@@ -78,7 +78,7 @@ func main() {
 	go ClearSuccessfulTask()
 
 	// 备份数据库 定时任务
-	go BackupDatabase()
+	//go BackupDatabase()
 
 	// 监听收到的信号
 	interrupt := make(chan os.Signal, 1)