Jelajahi Sumber

基点服务库内整理

xuchl 4 tahun lalu
induk
melakukan
d51a910192

+ 7 - 0
app/model/bank_arrange_detail/bank_arrange_detail.go

@@ -0,0 +1,7 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package bank_arrange_detail
+
+// Fill with you ideas below.

+ 99 - 0
app/model/bank_arrange_detail/bank_arrange_detail_entity.go

@@ -0,0 +1,99 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package bank_arrange_detail
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// Entity is the golang structure for table bank_arrange_detail.
+type Entity struct {
+    Id               int         `orm:"Id,primary"       json:"id"`                 //                                                                                                                                                              
+    ParentId         int         `orm:"ParentId"         json:"parent_id"`          // 库内整理主单ID                                                                                                                                               
+    BoxId            int         `orm:"BoxId"            json:"box_id"`             // 冻存盒表bank_box的Id                                                                                                                                         
+    SampleId         int         `orm:"SampleId"         json:"sample_id"`          // 样本表bank_sample的id                                                                                                                                        
+    BarCode          string      `orm:"BarCode"          json:"bar_code"`           // 唯一码,ArrangeType=1时,该字段为盒子编码,ArrangeType=2时,该字段为样本编码                                                                                 
+    TaskStatus       uint        `orm:"TaskStatus"       json:"task_status"`        // 任务执行状态(与main表一致) 4. 执行失败 5. 执行成功;7 驳回                                                                                                    
+    EquipmentId      int         `orm:"EquipmentId"      json:"equipment_id"`       // 容器ID                                                                                                                                                       
+    ShelfId          int         `orm:"ShelfId"          json:"shelf_id"`           // 冻存架Id                                                                                                                                                     
+    Position         string      `orm:"Position"         json:"position"`           // 所处位置;格式(x;y)x代表第几列 Y代表第几行,positionInfo中需要将Y转为对应字母值,再拼接X;ArrangeType=1时,表示位于架子上位置,为2时表示位于盒内的位置        
+    PositionInfo     string      `orm:"PositionInfo"     json:"position_info"`      // 列表中显示的位置信息,ArrangeType=1时,表示(容器+架子+position)例如:容器1-A1-A2,ArrangeType=2时,表示(容器+层+盒+position),例如:容器1-A1-A1-A2        
+    LastBoxId        int         `orm:"LastBoxId"        json:"last_box_id"`        // 整理前盒子Id,ArrangeType=2时,该字段不为空,表示样本再整理前存放的盒子id                                                                                    
+    LastShelfId      int         `orm:"LastShelfId"      json:"last_shelf_id"`      // 整理前冻存架Id                                                                                                                                               
+    LastPosition     string      `orm:"LastPosition"     json:"last_position"`      // 整理前所处位置;格式(x;y)x代表第几列 Y代表第几行,positionInfo中需要将Y转为对应字母值,再拼接X;ArrangeType=1时,表示位于架子上位置,为2时表示位于盒内的位置  
+    LastPositionInfo string      `orm:"LastPositionInfo" json:"last_position_info"` // 列表中显示的整理前的位置信息,ArrangeType=1时,表示(容器+分区+position),ArrangeType=2时,表示(容器+分区+盒位置+position)                                 
+    IsLocked         int         `orm:"IsLocked"         json:"is_locked"`          // 是否显示锁的标志(入库,出库审批过程中显示锁)                                                                                                               
+    CancelId         int         `orm:"CancelId"         json:"cancel_id"`          // 撤销人Id                                                                                                                                                     
+    CancelBy         string      `orm:"CancelBy"         json:"cancel_by"`          // 撤销人                                                                                                                                                       
+    Remark           string      `orm:"Remark"           json:"remark"`             // 备注                                                                                                                                                         
+    DetailStatus     int         `orm:"DetailStatus"     json:"detail_status"`      // 状态0:申请;2:已审核;1 提交待审核                                                                                                                          
+    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"`        //                                                                                                                                                              
+    ArrangeType      int         `orm:"ArrangeType"      json:"arrange_type"`       // 类型,1:盒子,2:样本                                                                                                                                         
+    Reason           int         `orm:"Reason"           json:"reason"`             // 原因明细,ID是字典明细                                                                                                                                       
+}
+
+// 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()
+}

+ 353 - 0
app/model/bank_arrange_detail/bank_arrange_detail_model.go

@@ -0,0 +1,353 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package bank_arrange_detail
+
+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_detail operations.
+type arModel struct {
+	gmvc.M
+}
+
+var (
+	// Table is the table name of bank_arrange_detail.
+	Table = "bank_arrange_detail"
+	// Model is the model object of bank_arrange_detail.
+	Model = &arModel{g.DB("default").Model(Table).Safe()}
+	// Columns defines and stores column names for table bank_arrange_detail.
+	Columns = struct {
+		Id                string //                                                                                                                                                              
+        ParentId          string // 库内整理主单ID                                                                                                                                               
+        BoxId             string // 冻存盒表bank_box的Id                                                                                                                                         
+        SampleId          string // 样本表bank_sample的id                                                                                                                                        
+        BarCode           string // 唯一码,ArrangeType=1时,该字段为盒子编码,ArrangeType=2时,该字段为样本编码                                                                                 
+        TaskStatus        string // 任务执行状态(与main表一致) 4. 执行失败 5. 执行成功;7 驳回                                                                                                    
+        EquipmentId       string // 容器ID                                                                                                                                                       
+        ShelfId           string // 冻存架Id                                                                                                                                                     
+        Position          string // 所处位置;格式(x;y)x代表第几列 Y代表第几行,positionInfo中需要将Y转为对应字母值,再拼接X;ArrangeType=1时,表示位于架子上位置,为2时表示位于盒内的位置        
+        PositionInfo      string // 列表中显示的位置信息,ArrangeType=1时,表示(容器+架子+position)例如:容器1-A1-A2,ArrangeType=2时,表示(容器+层+盒+position),例如:容器1-A1-A1-A2        
+        LastBoxId         string // 整理前盒子Id,ArrangeType=2时,该字段不为空,表示样本再整理前存放的盒子id                                                                                    
+        LastShelfId       string // 整理前冻存架Id                                                                                                                                               
+        LastPosition      string // 整理前所处位置;格式(x;y)x代表第几列 Y代表第几行,positionInfo中需要将Y转为对应字母值,再拼接X;ArrangeType=1时,表示位于架子上位置,为2时表示位于盒内的位置  
+        LastPositionInfo  string // 列表中显示的整理前的位置信息,ArrangeType=1时,表示(容器+分区+position),ArrangeType=2时,表示(容器+分区+盒位置+position)                                 
+        IsLocked          string // 是否显示锁的标志(入库,出库审批过程中显示锁)                                                                                                               
+        CancelId          string // 撤销人Id                                                                                                                                                     
+        CancelBy          string // 撤销人                                                                                                                                                       
+        Remark            string // 备注                                                                                                                                                         
+        DetailStatus      string // 状态0:申请;2:已审核;1 提交待审核                                                                                                                          
+        CreateOn          string //                                                                                                                                                              
+        CreateUserId      string //                                                                                                                                                              
+        CreateBy          string //                                                                                                                                                              
+        ModifiedOn        string //                                                                                                                                                              
+        ModifiedUserId    string //                                                                                                                                                              
+        ModifiedBy        string //                                                                                                                                                              
+        ArrangeType       string // 类型,1:盒子,2:样本                                                                                                                                         
+        Reason            string // 原因明细,ID是字典明细
+	}{
+		Id:               "Id",                
+        ParentId:         "ParentId",          
+        BoxId:            "BoxId",             
+        SampleId:         "SampleId",          
+        BarCode:          "BarCode",           
+        TaskStatus:       "TaskStatus",        
+        EquipmentId:      "EquipmentId",       
+        ShelfId:          "ShelfId",           
+        Position:         "Position",          
+        PositionInfo:     "PositionInfo",      
+        LastBoxId:        "LastBoxId",         
+        LastShelfId:      "LastShelfId",       
+        LastPosition:     "LastPosition",      
+        LastPositionInfo: "LastPositionInfo",  
+        IsLocked:         "IsLocked",          
+        CancelId:         "CancelId",          
+        CancelBy:         "CancelBy",          
+        Remark:           "Remark",            
+        DetailStatus:     "DetailStatus",      
+        CreateOn:         "CreateOn",          
+        CreateUserId:     "CreateUserId",      
+        CreateBy:         "CreateBy",          
+        ModifiedOn:       "ModifiedOn",        
+        ModifiedUserId:   "ModifiedUserId",    
+        ModifiedBy:       "ModifiedBy",        
+        ArrangeType:      "ArrangeType",       
+        Reason:           "Reason",
+	}
+)
+
+// 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()}
+}

+ 7 - 0
app/model/bank_arrange_main/bank_arrange_main.go

@@ -0,0 +1,7 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package bank_arrange_main
+
+// Fill with you ideas below.

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

@@ -0,0 +1,97 @@
+// ==========================================================================
+// 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()
+}

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

@@ -0,0 +1,349 @@
+// ==========================================================================
+// 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()}
+}

+ 164 - 0
src/dashoo.cn/genepoint_srv/business/arrangeService/arrange.go

@@ -0,0 +1,164 @@
+package arrangeService
+
+import "github.com/gogf/gf/os/gtime"
+
+const UNEXECUTED = 0
+const SENT = 1
+const ACCEPT = 2
+const ACTIVE = 3
+const FAILED = 4
+const SUCCESS = 5
+const RUNNING = 6
+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"   ` // 整理样本数量
+}
+
+type Bank_Arrange_Detail struct {
+	Id               int         `json:"Id"      ` //
+	ParentId         int         `json:"ParentId"        ` // 库内整理主单ID
+	BoxId            int         `json:"BoxId"           ` // 冻存盒表bank_box的Id
+	SampleId         int         `json:"SampleId"        ` // 样本表bank_sample的id
+	BarCode          string      `json:"BarCode"         ` // 唯一码,ArrangeType=1时,该字段为盒子编码,ArrangeType=2时,该字段为样本编码
+	TaskStatus       uint        `json:"TaskStatus"      ` // 任务执行状态(与main表一致) 4. 执行失败 5. 执行成功;7 驳回
+	EquipmentId      int         `json:"EquipmentId"     ` // 容器ID
+	ShelfId          int         `json:"ShelfId"         ` // 冻存架Id
+	Position         string      `json:"Position"        ` // 所处位置;格式(x;y)x代表第几列 Y代表第几行,positionInfo中需要将Y转为对应字母值,再拼接X;ArrangeType=1时,表示位于架子上位置,为2时表示位于盒内的位置
+	PositionInfo     string      `json:"PositionInfo"    ` // 列表中显示的位置信息,ArrangeType=1时,表示(容器+架子+position)例如:容器1-A1-A2,ArrangeType=2时,表示(容器+层+盒+position),例如:容器1-A1-A1-A2
+	LastBoxId        int         `json:"LastBoxId"       ` // 整理前盒子Id,ArrangeType=2时,该字段不为空,表示样本再整理前存放的盒子id
+	LastShelfId      int         `json:"LastShelfId"     ` // 整理前冻存架Id
+	LastPosition     string      `json:"LastPosition"    ` // 整理前所处位置;格式(x;y)x代表第几列 Y代表第几行,positionInfo中需要将Y转为对应字母值,再拼接X;ArrangeType=1时,表示位于架子上位置,为2时表示位于盒内的位置
+	LastPositionInfo string      `json:"LastPositionInfo"` // 列表中显示的整理前的位置信息,ArrangeType=1时,表示(容器+分区+position),ArrangeType=2时,表示(容器+分区+盒位置+position)
+	IsLocked         int         `json:"IsLocked"        ` // 是否显示锁的标志(入库,出库审批过程中显示锁)
+	CancelId         int         `json:"CancelId"        ` // 撤销人Id
+	CancelBy         string      `json:"CancelBy"        ` // 撤销人
+	Remark           string      `json:"Remark"          ` // 备注
+	DetailStatus     int         `json:"DetailStatus"    ` // 状态0:申请;2:已审核;1 提交待审核
+	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"      ` //
+	ArrangeType      int         `json:"ArrangeType"     ` // 类型,1:盒子,2:样本
+	Reason           int         `json:"Reason"          ` // 原因明细,ID是字典明细
+}
+
+type Id struct {
+	Id int
+}
+
+// 相应报文实体
+type ResponseEntity struct {
+	Response string       `json:"response"`
+	Result   int          `json:"result"`
+	Time     string       `json:"time"`
+	Data     ResponseData `json:"data,omitempty"`
+}
+
+type ResponseData struct {
+	Type           string        `json:"type,omitempty"`
+	Is_end         bool          `json:"is_end,omitempty"`
+	Task_id        string        `json:"task_id,omitempty"`
+	Execution_time int           `json:"execution_time,omitempty"`
+	Exceptions     []Exception   `json:"exceptions,omitempty"`
+	Actual_data    []Actual_data `json:"actual_data,omitempty"`
+	Abnormal_data  Abmormal_data `json:"abnormal_data,omitempty"`
+	causes         Cause		 `json:"causes,omitempty"`
+	Status         int           `json:"status,omitempty"`
+	Key            string        `json:"key,omitempty"`
+	Task_msg       []interface{} `json:"task_msg,omitempty"`
+}
+
+type Abmormal_data struct {
+	Racks []Racks	`json:"racks,omitempty"`
+	Tubes []Tubes	`json:"tubes,omitempty"`
+}
+
+type Exception struct {
+	Cu    int   `json:"cu"`
+	Codes []int `json:"codes,omitempty"`
+}
+
+type Cause struct {
+	Cu     int `json:"cu"`
+	Reason int `json:"reason"`
+}
+
+type Actual_data struct {
+	Rack   int64      `json:"rack,omitempty"`
+	RackId string     `json:"rack_id,omitempty"`
+	Target Target   `json:"target,omitempty"`
+	Tube   int64      `json:"tube,omitempty"`
+	Tubes  []Tube `json:"tubes,omitempty"`
+}
+
+type Target 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"`
+	Ee      int    `json:"ee,omitempty"`
+	Rack_id string `json:"rack_id,omitempty"`
+}
+
+type Tube struct {
+	Id string `json:"id"`
+	No int  `json:"no"`
+}
+
+type Tubes struct {
+	Exceptions []int `json:"exceptions"`
+	Id         string  `json:"id"`
+	Tube       int   `json:"tube"`
+}
+
+type Racks struct {
+	Exceptions []int `json:"exceptions"`
+	Rack       int   `json:"rack"`
+	RackId     string  `json:"rack_id"`
+}
+
+type Equipment struct {
+	Name string
+}
+// 盒子规格信息
+type Box struct {
+	Id  int    // 盒子id
+	RowNum int          //盒子行数
+	ColumnNum int		// 盒子列数
+}
+// 冻存架信息
+type Shelf struct {
+	EquipmentId  int // 设备id
+	Id int // 冻存架id
+	XStation   int   // 位置 X代表第几列
+	YStation   int    // 位置 Y代表第几行
+}

+ 389 - 0
src/dashoo.cn/genepoint_srv/business/arrangeService/arrangeService.go

@@ -0,0 +1,389 @@
+/**
+ * @Author $
+ * @Date $ $
+ * @Note
+ **/
+package arrangeService
+
+import (
+	"dashoo.cn/utils"
+	"encoding/json"
+	"fmt"
+	"github.com/Unknwon/com"
+	"github.com/go-xorm/xorm"
+	. "dashoo.cn/utils/db"
+	"github.com/gogf/gf/os/glog"
+	"strconv"
+	"strings"
+)
+
+type ArrangeService struct {
+	ServiceBase
+}
+
+const TABLE_ARRANGE_MAIN = "bank_arrange_main"
+const TABLE_ARRANGE_DETAIL = "bank_arrange_detail"
+const TABLE_TAST = "sample_storage_task"
+const TABLE_BOX = "bank_box"
+
+func GetArrangeService(xormEngine *xorm.Engine) *ArrangeService {
+	s := new(ArrangeService)
+	s.DBE = xormEngine
+	return s
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 查询库内整理申请人
+ * @Date 15:41 2021/3/30
+ * @Param 
+ * @return 
+ **/
+// 获取申请单创建人
+func (this *ArrangeService) GetOperUser(EntryNo string) (user string) {
+
+	// 获取当前任务的操作人
+	sql := " select  a.UserName from base_user a left join bank_arrange_main b  on a.id = b.CreateUserId  where b.EntryNo ='" + EntryNo + "' "
+	this.DBE.SQL(sql).Get(&user)
+	return user
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 修改 整理单主表信息
+ * @Date 15:45 2021/3/30
+ * @Param
+ * @return
+ **/
+// 修改出入库单状态
+func (this *ArrangeService) ArrangeMainStatusModify(statusCode int, entryNo string) error {
+	set := ""
+	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5 || statusCode == 6 {
+		set = "  ,exception='' "
+	}
+
+	sql := "UPDATE " + TABLE_ARRANGE_MAIN + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' " + set + "  WHERE entryno = '" + entryNo + "'"
+	_, err := this.DBE.Exec(sql)
+	return err
+}
+
+/**
+ * @Author EDZ
+ * @Description // 修改整理单详情表信息
+ * @Date 15:45 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) ArrangeDetailStatusModify(statusCode int, entryNo string) error {
+	//获取出入库单Id
+	getId := "SELECT id FROM " + TABLE_ARRANGE_MAIN+ " WHERE entryno = '" + entryNo + "'"
+	var idList []Id
+	err := this.DBE.SQL(getId).Find(&idList)
+	//批量更新全部成功或失败的任务样本状态
+	sql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "' and taskstatus !=5"
+	_, err = this.DBE.Exec(sql)
+
+	return err
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 保存整理单异常信息
+ * @Date 17:08 2021/3/30
+ * @Param
+ * @return
+ **/
+//保存异常信息
+func (this *ArrangeService) SaveArrangeExcepMsg(msg, entryNo string) error {
+	sql := "UPDATE " + TABLE_ARRANGE_MAIN + " SET exception = '" + msg + "' WHERE entryno = '" + entryNo + "'"
+	_, err := this.DBE.Exec(sql)
+	return err
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 根据库内整理任务结果, 成功或部分成功更新数据
+ * @Date 17:23 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, message []byte) error {
+	var res ResponseEntity
+	err := json.Unmarshal(message, &res)
+	if err != nil {
+		fmt.Println(err)
+	}
+	taskId := strings.Split(res.Data.Task_id, "@")[0]
+	isEnd := res.Data.Is_end
+
+	// 判断是否全部成功, 更新失败的任务状态
+	this.GetAbnormalDataAndUpdate(taskId,res)
+	// 先更新盒子的原位置
+	err = this.UpdateBoxInfoCK(res)
+	if err != nil {
+		return err
+	}
+
+	// 获取返回数据中的 盒子信息
+	err = this.UpdateBoxInfo(res)
+	if err != nil {
+		return err
+	}
+
+	// 获取盒子下的 样本信息
+	for _, value := range res.Data.Actual_data {
+		//获取报文中的 盒子信息
+		var Rack_id string = value.Target.Rack_id
+		fmt.Println("冻存盒盒子编号:", Rack_id)
+		// 获取报文中的 位置信息和 样本编码
+		var tubes = value.Tubes
+		fmt.Println("样本位置信息:", tubes)
+		//新增方法 更新位置信息
+		this.UpdatePosition(Rack_id, tubes, res)
+	}
+	if isEnd {
+		err = this.StatusModifyWithDetail(taskId)
+	}
+	return err
+}
+
+
+/**
+ * @Author 徐春林
+ * @Description // 获取整理成功的 盒子信息并保存
+ * @Date 18:36 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
+	//1.  获取当前返回的  冻存架信息,
+	var shelf Shelf
+
+	glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
+
+	// 循环处理返回的数据,如果出现多盒存入的分批处理
+
+	for i := range entity.Data.Actual_data {
+
+		glog.Info("操作地  ", i, "  条数据")
+
+		boxBarcode := entity.Data.Actual_data[i].RackId // 冻存盒编号
+		Cu := entity.Data.Actual_data[i].Target.Cu       // 设备编号
+		Ltu := entity.Data.Actual_data[i].Target.Ltu     //
+		Unit := entity.Data.Actual_data[i].Target.Unit
+		Pos := entity.Data.Actual_data[i].Target.Pos
+		Group := entity.Data.Actual_data[i].Target.Group
+
+		fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
+
+		sql := "select b.id EquipmentId,a.id,a.XStation,a.YStation from bank_shelf a left join bank_equipment b  on a.EquipmentId = b.id  where  b.cu = '" + utils.ToStr(Cu) + "' " +
+			"and  a.Ltu = '" + utils.ToStr(Ltu) + "' and a.Unit ='" + utils.ToStr(Unit) + "' and a.Group ='" + utils.ToStr(Group) + "'"
+
+		this.DBE.SQL(sql).Get(&shelf)
+		fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
+
+		//  更新盒所在的冻存架的信息  计算位置信息,并更新
+		// 临时处理逻辑,默认 pos 为 盒子的  XStation
+		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',YStation =1 ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0  where Barcode ='" + boxBarcode + "' ")
+		// 更新 当前冰箱冻存盒容量 信息
+		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
+
+	}
+	return err
+
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 更新盒子的 位置为空, 架子的容量
+ * @Date 18:58 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
+	//1.  获取当前返回的  冻存架信息,
+	var shelf Shelf
+
+	// 循环处理返回的数据,如果出现多盒存入的分批处理
+	for i := range entity.Data.Actual_data {
+		boxBarcode := entity.Data.Actual_data[i].RackId // 冻存盒编号
+		Pos := entity.Data.Actual_data[i].Target.Pos
+
+		sql := " select shelfId , EquipmentId from bank_box where code = '" + boxBarcode + "'"
+
+		this.DBE.SQL(sql).Get(&shelf)
+		fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
+
+		//  更新盒所在的冻存架的信息  计算位置信息,并更新
+		// 临时处理逻辑,默认 pos 为 盒子的  XStation
+		_, 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) + "")
+	}
+	return err
+
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 获取返回结果中的样本信息
+ * @Date 19:10 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) UpdatePosition(rack_id string, tubes []Tube, entity ResponseEntity) {
+	// 根据返回的报文中的盒子标识,获取盒子类型
+	sql := "select Id,RowNum,ColumnNum from bank_box where Barcode ='" + rack_id + "'"
+	var box Box
+	this.DBE.SQL(sql).Get(&box)
+	RowNum := box.RowNum
+	ColumnNum := box.ColumnNum
+	glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum)
+	for i := 0; i < len(tubes); i++ {
+		no := tubes[i].No
+		id := tubes[i].Id
+		glog.Info("样本在盒子中的位置:", no, ";样本条码: ", id)
+		//计算管子在盒子中的坐标
+		var box_x, box_y int
+
+		if no%ColumnNum == 0 { // 如果 取余数为0 则 证明该数是能被  10 整除的数  为该行 最后一个孔位
+			box_y = ColumnNum
+			box_x = no / ColumnNum
+		} else {
+			box_y = no % ColumnNum
+			box_x = (no / ColumnNum) + 1
+		}
+
+		glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)
+		var position = utils.NumberToLetter(box_x) + utils.ToStr(box_y)
+		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)
+	}
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 更新样本的容器, 架信息
+ * @Date 19:32 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity, rack_id string) {
+
+	glog.Info("修改detail:", entity)
+
+	var shelf Shelf
+	var equipmentid string
+	var ShelfId string
+	for i := range entity.Data.Actual_data {
+		Cu := entity.Data.Actual_data[i].Target.Cu   // 设备编号
+		Ltu := entity.Data.Actual_data[i].Target.Ltu //
+		Unit := entity.Data.Actual_data[i].Target.Unit
+		Group := entity.Data.Actual_data[i].Target.Group
+
+		//当  检测到数据 与当前操作盒子的数据一直时,更新  detail   和sample 信息
+		if entity.Data.Actual_data[i].Target.Rack_id == rack_id {
+			sql := "select b.id EquipmentId,a.id,a.XStation,a.YStation from bank_shelf a left join bank_equipment b  on a.EquipmentId = b.id  where  b.cu = '" + utils.ToStr(Cu) + "' " +
+				"and  a.Ltu = '" + utils.ToStr(Ltu) + "' and a.Unit ='" + utils.ToStr(Unit) + "' and a.Group ='" + utils.ToStr(Group) + "'"
+			this.DBE.SQL(sql).Get(&shelf)
+			equipmentid = strconv.Itoa(shelf.EquipmentId)
+			ShelfId = strconv.Itoa(shelf.Id)
+			sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where barcode ='" + BarCode + "' "
+			this.DBE.Exec(sql)
+		}
+
+	}
+}
+
+/**
+ * @Author 徐春林
+ * @Description // end 时更新
+ * @Date 19:36 2021/3/30
+ * @Param
+ * @return
+ **/
+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) + ")"
+
+	var total int
+	//_, err := this.DBE.Exec(sql)
+	this.DBE.SQL(sql).Get(&total)
+
+	//total ,_ := result.RowsAffected()
+	fmt.Println("数量:", total)
+
+	// 存在未执行成功的子任务
+	if total > 0 {
+		status = FAILED
+	}
+
+	// 更新申请主表状态
+	updApplySql := "UPDATE " + TABLE_ARRANGE_MAIN + " SET taskstatus = '" + strconv.Itoa(status) + "' WHERE entryno = '" + task_id + "'"
+	_, err := this.DBE.Exec(updApplySql)
+	return err
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 获取异常信息, 更新任务状态
+ * @Date 20:08 2021/3/30
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) GetAbnormalDataAndUpdate(taskId string, entity ResponseEntity) {
+	//获取反馈报文中的所有异常样本Id列表
+	racks := entity.Data.Abnormal_data.Racks
+	arrangeMain := this.GetArrangeMain(taskId)
+	var shelf Shelf
+	if len(racks) > 0  {
+		for _, v := range racks {
+			// 根据盒编码,任务编码查询 任务信息,任务存在更新状态
+			sql := "SELECT count(*) FROM `" + TABLE_TAST + " WHERE task_id = '" + taskId + "' and BoxBarCode = '" + v.RackId + "'"
+
+			var total int
+			this.DBE.SQL(sql).Get(&total)
+			fmt.Println("盒任务数量:", total)
+			// 存在未执行成功的子任务
+			if total > 0 {
+				// 更新任务明细信息
+				updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE BoxBarCode = '" +  v.RackId + "' AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
+				this.DBE.Exec(updatesql)
+				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  BoxBarCode = '" +  v.RackId + "' and task_id = '" + taskId + "'"
+				this.DBE.Exec(updTaskSql)
+				continue
+			}
+			// 不存在根据盒编码查询盒当前的架编码
+			shelfIdsql := "SELECT ShelfId as Id FROM `" + TABLE_BOX + " WHERE Barcode = '" + v.RackId + "'"
+
+			this.DBE.SQL(shelfIdsql).Get(&shelf)
+			fmt.Println("盒的冻存架Id:", shelf.Id)
+
+			// 根据架编码,任务Id 查询 任务信息, 任务存在更新状态
+			// 更新任务明细信息
+			updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE ShelfId = " +strconv.Itoa( shelf.Id)+ " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
+			this.DBE.Exec(updatesql)
+
+			// 更新任务状态
+			updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  ShelfId = " +strconv.Itoa( shelf.Id)+ "and task_id = '" + taskId + "'"
+			this.DBE.Exec(updTaskSql)
+		}
+	}
+}
+
+/**
+ * @Author 徐春林
+ * @Description // 获取整理主单信息
+ * @Date 9:42 2021/3/31
+ * @Param
+ * @return
+ **/
+func (this *ArrangeService) GetArrangeMain(entryNo string) Bank_Arrange_Main {
+	where := "entryNo = '" + entryNo + "'"
+	var entity Bank_Arrange_Main
+	this.GetEntity(&entity, where)
+	return entity
+}

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

@@ -302,4 +302,17 @@ type Shelf struct {
 	YStation   int    // 位置 Y代表第几行
 }
 
+// 自动库内整理结构体
+type Arrange struct {
+	Logic_id int	`json:"logic_id,omitempty"`
+	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"`
+}

+ 38 - 2
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -2,6 +2,7 @@ package converseService
 
 import (
 	"crypto/md5"
+	"dashoo.cn/genepoint_srv/business/arrangeService"
 	"fmt"
 	"github.com/Unknwon/com"
 	"github.com/gogf/gf/os/glog"
@@ -35,6 +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
 
 type ConverseService struct {
 	ServiceBase
@@ -200,6 +202,10 @@ func (this *ConverseService) GenerateRequestEntity(taskType int, task_id, user s
 		break
 	case 7:
 		requestName = "task_change"
+		break
+	case 9:
+		// add by 徐春林 添加库内整理任务
+		requestName = "moving"
 	}
 	utc := time.Now().UTC().Format(time.RFC3339)
 	var data RequestData
@@ -236,6 +242,9 @@ func (this *ConverseService) HandleTaskDetail(taskType int, entity *RequestEntit
 		break
 	case 7: // 任务变更通知
 		handleTaskChange(entity, detail)
+		break
+	case 9: // add by 徐春林 添加库内整理任务 手动库内整理
+		handleArrange(entity, detail)
 	}
 }
 
@@ -402,6 +411,27 @@ func handleQueryTube(entity *RequestEntity, detail *Sample_Storage_Task) {
 	entity.Data.Tube_id = detail.BarCode
 }
 
+/**
+ * @Author 徐春林
+ * @Description // 手动选择位置 库内整理
+ * @Date 20:01 2021/3/29
+ * @Param
+ * @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
+	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
+
+	entity.Data.Task_data = one
+}
 // 查询申请单详情下状态,存在一条子任务失败的情况,则整个申请单状态为失败
 func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 	status := SUCCESS
@@ -1126,12 +1156,18 @@ func RecordDeviceData(list []List_Data) {
 }
 
 // 更新异常信息
-func (s *ConverseService) SaveErrInfo(err, taskid string) {
+func (s *ConverseService) SaveErrInfo(err, taskid string,reqType string) {
 	// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
 	// 请求发送失败
 
 	svc := GetConverseService(utils.DBE)
+	// add by 徐春林 库内整理错误信息保存
+	asvc := arrangeService.GetArrangeService(utils.DBE)
 
 	svc.SaveTaskExcepMsg(err, taskid)
-	svc.SaveSampleExcepMsg(err, taskid)
+	if reqType == "moving" {
+		asvc.SaveArrangeExcepMsg(err, taskid)
+	} else {
+		svc.SaveSampleExcepMsg(err, taskid)
+	}
 }

+ 69 - 29
src/dashoo.cn/genepoint_srv/controllers/converse/converse.go

@@ -10,6 +10,7 @@ import (
 	// "github.com/astaxie/beego"
 	"github.com/gorilla/websocket"
 
+	arrangeService "dashoo.cn/genepoint_srv/business/arrangeService"
 	. "dashoo.cn/genepoint_srv/business/converseService"
 	"dashoo.cn/utils"
 )
@@ -22,6 +23,7 @@ type ConverseController struct {
 func (this *ConverseController) SearchDatabase() map[string]*RequestEntity {
 	log.Println("组装请求数据报文开始---")
 	svc := GetConverseService(utils.DBE)
+	asvc := arrangeService.GetArrangeService(utils.DBE)
 	tasks := svc.ScanNewTaskDetail()
 	// tasks := svc.GetNewTaskBasic()
 	var reqMap = make(map[string]*RequestEntity)
@@ -38,8 +40,13 @@ func (this *ConverseController) SearchDatabase() map[string]*RequestEntity {
 	for _, value := range tasks {
 		var time int64 = time.Now().Unix()
 
-		user := svc.GetOperUser(value.Task_id)
-
+		// add by 徐春林 如果是 库内整理任务, 需要关联新的表查询数据
+		var user string
+		if value.Task_type == 9 {
+			user = asvc.GetOperUser(value.Task_id)
+		} else {
+			user = svc.GetOperUser(value.Task_id)
+		}
 		taskid := value.Task_id + "@" + strconv.FormatInt(time, 10)
 	//	log.Println("taskid:", taskid)
 
@@ -94,27 +101,42 @@ func (this *ConverseController) StatusModifyWithDetail(task_id string) error {
 }
 
 // 修改任务状态码
-func (this *ConverseController) StatusModify(statusCode int, task_id string) error {
+func (this *ConverseController) StatusModify(statusCode int, task_id string,reqType string) error {
 	svc := GetConverseService(utils.DBE)
+	asvc := arrangeService.GetArrangeService(utils.DBE)
 	//修改任务表任务状态
 	err := svc.TaskStatusModify(statusCode, task_id)
 	if err != nil {
 		return err
 	}
-	//修改出入库任务状态
-	err = svc.SampleApplyStatusModify(statusCode, task_id)
-	if err != nil {
-		return err
-	}
 
-	// 2020/12/18 卢传敏新增,修复多条报文返回的问题,同时处理 任务中样本的状态和任务状态不一致的问题
-	// 根据任务报文返回的执行状态 修改出入库单中的 样本的任务状态
-	// 状态码不为成功/失败(成功/失败状态会根据响应报文单独处理状态更改),则批量更新样本申请表状态
-	if statusCode != SUCCESS && statusCode != FAILED {
-		err = svc.SampleApplyDetailStatusModify(statusCode, task_id)
+	if reqType == "moving" {
+		err = asvc.ArrangeMainStatusModify(statusCode, task_id)
+		if err != nil {
+			return err
+		}
+		if statusCode != SUCCESS && statusCode != FAILED {
+			err = asvc.ArrangeDetailStatusModify(statusCode, task_id)
+			if err != nil {
+				return err
+			}
+		}
+	} else {
+		//修改出入库任务状态
+		err = svc.SampleApplyStatusModify(statusCode, task_id)
 		if err != nil {
 			return err
 		}
+
+		// 2020/12/18 卢传敏新增,修复多条报文返回的问题,同时处理 任务中样本的状态和任务状态不一致的问题
+		// 根据任务报文返回的执行状态 修改出入库单中的 样本的任务状态
+		// 状态码不为成功/失败(成功/失败状态会根据响应报文单独处理状态更改),则批量更新样本申请表状态
+		if statusCode != SUCCESS && statusCode != FAILED {
+			err = svc.SampleApplyDetailStatusModify(statusCode, task_id)
+			if err != nil {
+				return err
+			}
+		}
 	}
 
 	//if statusCode == SUCCESS || statusCode == REJECT {
@@ -172,37 +194,43 @@ func (this *ConverseController) HandleMessage(n int, message []byte) {
 
 			//若非正常结束,保存异常信息
 			if taskType == "abnormal_end" {
-				this.SaveExcepMsg(res, taskId)
+				this.SaveExcepMsg(res, taskId, resp)
 			}
-			//处理任务下申请
-			svc := GetConverseService(utils.DBE)
-			svc.ModifySampleStatusByApplyMainInfo(taskId, resp, res)
-
-			// 所有入库单下子任务已完成,根据样本申请状态(有一个不为成功则更新为失败状态)更新申请单,任务状态
-			if isEnd {
-				err = this.StatusModifyWithDetail(taskId)
+			// add by 徐春林 库内整理任务需要单独处理
+			if resp == "moving"{
+				asvc := arrangeService.GetArrangeService(utils.DBE)
+				err = asvc.UpdateArrangeRes(taskId,resp,message)
+			} else {
+				//处理任务下申请
+				svc := GetConverseService(utils.DBE)
+				svc.ModifySampleStatusByApplyMainInfo(taskId, resp, res)
+
+				// 所有入库单下子任务已完成,根据样本申请状态(有一个不为成功则更新为失败状态)更新申请单,任务状态
+				if isEnd {
+					err = this.StatusModifyWithDetail(taskId)
+				}
 			}
 
 			//this.SampleAllStatusModify(res,SUCCESS)
 		} else if taskType == "task_activate" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]激活>>>>>>>>>>")
 			if res.Data.Status == 3 {
-				err = this.StatusModify(REJECT, taskId)
+				err = this.StatusModify(REJECT, taskId,resp)
 			} else {
-				err = this.StatusModify(ACTIVE, taskId)
+				err = this.StatusModify(ACTIVE, taskId, resp)
 			}
 		} else if taskType == "accept" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]接受>>>>>>>>>>")
-			err = this.StatusModify(ACCEPT, taskId)
+			err = this.StatusModify(ACCEPT, taskId, resp)
 		} else if taskType == "running" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]执行中>>>>>>>>>>")
-			err = this.StatusModify(RUNNING, taskId)
+			err = this.StatusModify(RUNNING, taskId, resp)
 		}
 	} else if result == 300 && taskType == "reject" {
 		log.Println("----------任务[" + taskId + "]任务拒绝----------")
 		//保存异常信息
-		this.SaveExcepMsg(res, taskId)
-		err = this.StatusModify(REJECT, taskId)
+		this.SaveExcepMsg(res, taskId, resp)
+		err = this.StatusModify(REJECT, taskId, resp)
 		// 判断如果为盒操作, 需要将 盒解锁, 重新执行时再上锁
 		if resp == "rack_storing" || resp == "rack_retrieving" {
 			err = this.UpdateBoxIsLocked(taskId)
@@ -223,7 +251,7 @@ func (this *ConverseController) UpdateBoxIsLocked(taskId string) error{
 }
 
 //保存异常信息
-func (this *ConverseController) SaveExcepMsg(res ResponseEntity, taskId string) {
+func (this *ConverseController) SaveExcepMsg(res ResponseEntity, taskId ,reqType string) {
 	svc := GetConverseService(utils.DBE)
 	//causeByte,_ := json.Marshal(res.Data.Causes)
 	//causeMsg := string(causeByte)
@@ -231,6 +259,7 @@ func (this *ConverseController) SaveExcepMsg(res ResponseEntity, taskId string)
 	exceptMsg := svc.HandleExceptions(res.Data.Exceptions)
 	//abnormalByte,_ := json.Marshal(res.Data.Abnormal_data)
 	//abnormalMsg := string(abnormalByte)
+	asvc := arrangeService.GetArrangeService(utils.DBE)
 
 	var totalMsg string
 	if causeMsg != "" && exceptMsg == "" {
@@ -243,11 +272,22 @@ func (this *ConverseController) SaveExcepMsg(res ResponseEntity, taskId string)
 
 	if totalMsg != "" {
 		svc.SaveTaskExcepMsg(totalMsg, taskId)
+		// add by 徐春林 库内整理错误信息保存
 		svc.SaveSampleExcepMsg(totalMsg, taskId)
+		if reqType == "moving" {
+			asvc.SaveArrangeExcepMsg(totalMsg, taskId)
+		} else {
+			svc.SaveSampleExcepMsg(totalMsg, taskId)
+		}
 	} else {
 		//任务再次执行成功时,删除已有的异常信息
 		svc.SaveTaskExcepMsg(" ", taskId)
-		svc.SaveSampleExcepMsg(" ", taskId)
+		// add by 徐春林 库内整理错误信息保存
+		if reqType == "moving" {
+			asvc.SaveArrangeExcepMsg(" ", taskId)
+		} else {
+			svc.SaveSampleExcepMsg(" ", taskId)
+		}
 	}
 }
 

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

@@ -140,7 +140,7 @@ func main() {
 		}
 		// label:
 	}
-
+	// 备份数据库 定时任务
 	log.Println("===============Service_down===============")
 	//conn.Close()
 }
@@ -288,9 +288,9 @@ func ListenToSendMsg() {
 		if err != nil {
 			log.Println("read err:", err)
 			// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
-			for taskid, _ := range reqMap {
-				err = ctrl.StatusModify(converseService.FAILED, taskid)
-				svc.SaveErrInfo(err.Error(), taskid)
+			for taskid, reqEntity := range reqMap {
+				err = ctrl.StatusModify(converseService.FAILED, taskid,reqEntity.Request)
+				svc.SaveErrInfo(err.Error(), taskid,reqEntity.Request)
 			}
 		}
 		// 发送消息
@@ -305,14 +305,14 @@ func ListenToSendMsg() {
 			if err1 != nil {
 				log.Println("请求发送失败")
 				// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
-				err1 = ctrl.StatusModify(converseService.FAILED, taskid)
+				err1 = ctrl.StatusModify(converseService.FAILED, taskid,reqEntity.Request)
 				// 跟新异常信息
 				totalMsg := "请求发送失败"
-				svc.SaveErrInfo(totalMsg, taskid)
+				svc.SaveErrInfo(totalMsg, taskid,reqEntity.Request)
 
 			} else {
 				// 发送成功,修改状态
-				err1 = ctrl.StatusModify(converseService.SENT, taskid)
+				err1 = ctrl.StatusModify(converseService.SENT, taskid,reqEntity.Request)
 			}
 		}
 	})