Ver Fonte

工单管理

wangxingcheng há 3 anos atrás
pai
commit
7603c6a713

+ 4 - 0
opms_parent/app/dao/cust/internal/cust_customer.go

@@ -63,6 +63,8 @@ var (
 			Id:           "id",
 			CustCode:     "cust_code",
 			CustName:     "cust_name",
+			CustIndustry: "cust_industry",
+			CustLevel:    "cust_level",
 			AbbrName:     "abbr_name",
 			CustLocation: "cust_location",
 			CustAddress:  "cust_address",
@@ -97,6 +99,8 @@ func NewCustCustomerDao(tenant string) CustCustomerDao {
 			CustName:     "cust_name",
 			AbbrName:     "abbr_name",
 			CustLocation: "cust_location",
+			CustIndustry: "cust_industry",
+			CustLevel:    "cust_level",
 			CustAddress:  "cust_address",
 			CustStatus:   "cust_status",
 			IsPublic:     "is_public",

+ 451 - 0
opms_parent/app/dao/work/internal/work_order.go

@@ -0,0 +1,451 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"time"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+
+	model "dashoo.cn/micro/app/model/work"
+)
+
+// WorkOrderDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type WorkOrderDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns workOrderColumns
+}
+
+// WorkOrderColumns defines and stores column names for table work_order.
+type workOrderColumns struct {
+	Id             string // 主键
+	OrderTypeId    string // 工单类型
+	OrderTypeDesc  string // 工单类型描述
+	OrderStatus    string // 工单状态(10发起20审批中30审批通过40审批拒绝50关闭)
+	WorkflowId     string // 关联工作流
+	FormId         string // 关联表单
+	FormData       string // 表单信息
+	AssignUserId   string // 分派人员ID
+	AssignUserName string // 分派人员姓名
+	Feedback       string // 反馈信息
+	File           string // 相关文件
+	Remark         string // 备注
+	CreatedBy      string // 创建者
+	CreatedName    string // 创建人
+	CreatedTime    string // 创建时间
+	UpdatedBy      string // 更新者
+	UpdatedName    string // 更新人
+	UpdatedTime    string // 更新时间
+	DeletedTime    string // 删除时间
+}
+
+var (
+	// WorkOrder is globally public accessible object for table work_order operations.
+	WorkOrder = WorkOrderDao{
+		M:     g.DB("default").Model("work_order").Safe(),
+		DB:    g.DB("default"),
+		Table: "work_order",
+		Columns: workOrderColumns{
+			Id:             "id",
+			OrderTypeId:    "order_type_id",
+			OrderTypeDesc:  "order_type_desc",
+			OrderStatus:    "order_status",
+			WorkflowId:     "workflow_id",
+			FormId:         "form_id",
+			FormData:       "form_data",
+			AssignUserId:   "assign_user_id",
+			AssignUserName: "assign_user_name",
+			Feedback:       "feedback",
+			File:           "file",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
+		},
+	}
+)
+
+func NewWorkOrderDao(tenant string) WorkOrderDao {
+	var dao WorkOrderDao
+	dao = WorkOrderDao{
+		M:     g.DB(tenant).Model("work_order").Safe(),
+		DB:    g.DB(tenant),
+		Table: "work_order",
+		Columns: workOrderColumns{
+			Id:             "id",
+			OrderTypeId:    "order_type_id",
+			OrderTypeDesc:  "order_type_desc",
+			OrderStatus:    "order_status",
+			WorkflowId:     "workflow_id",
+			FormId:         "form_id",
+			FormData:       "form_data",
+			AssignUserId:   "assign_user_id",
+			AssignUserName: "assign_user_name",
+			Feedback:       "feedback",
+			File:           "file",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
+		},
+	}
+	return dao
+}
+
+// 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 (d *WorkOrderDao) Ctx(ctx context.Context) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *WorkOrderDao) As(as string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *WorkOrderDao) TX(tx *gdb.TX) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *WorkOrderDao) Master() *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *WorkOrderDao) Slave() *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *WorkOrderDao) Args(args ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Args(args...)}
+}
+
+// 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 (d *WorkOrderDao) LeftJoin(table ...string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) RightJoin(table ...string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) InnerJoin(table ...string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *WorkOrderDao) Fields(fieldNamesOrMapStruct ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *WorkOrderDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *WorkOrderDao) Option(option int) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *WorkOrderDao) OmitEmpty() *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *WorkOrderDao) Filter() *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) Where(where interface{}, args ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.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 M.Where treats the condition
+// as string "123".
+func (d *WorkOrderDao) WherePri(where interface{}, args ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *WorkOrderDao) And(where interface{}, args ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *WorkOrderDao) Or(where interface{}, args ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *WorkOrderDao) Group(groupBy string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *WorkOrderDao) Order(orderBy ...string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) Limit(limit ...int) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *WorkOrderDao) Offset(offset int) *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) Page(page, limit int) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *WorkOrderDao) Batch(batch int) *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) Cache(duration time.Duration, name ...string) *WorkOrderDao {
+	return &WorkOrderDao{M: d.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 (d *WorkOrderDao) Data(data ...interface{}) *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.WorkOrder.
+// 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 M.Where function,
+// see M.Where.
+func (d *WorkOrderDao) All(where ...interface{}) ([]*model.WorkOrder, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.WorkOrder
+	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 *model.WorkOrder.
+// 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 M.Where function,
+// see M.Where.
+func (d *WorkOrderDao) One(where ...interface{}) (*model.WorkOrder, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.WorkOrder
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *WorkOrderDao) FindOne(where ...interface{}) (*model.WorkOrder, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.WorkOrder
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *WorkOrderDao) FindAll(where ...interface{}) ([]*model.WorkOrder, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.WorkOrder
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *WorkOrderDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *WorkOrderDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *WorkOrderDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *WorkOrderDao) Chunk(limit int, callback func(entities []*model.WorkOrder, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.WorkOrder
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *WorkOrderDao) LockUpdate() *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *WorkOrderDao) LockShared() *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *WorkOrderDao) Unscoped() *WorkOrderDao {
+	return &WorkOrderDao{M: d.M.Unscoped()}
+}

+ 430 - 0
opms_parent/app/dao/work/internal/work_order_type.go

@@ -0,0 +1,430 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"time"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+
+	model "dashoo.cn/micro/app/model/work"
+)
+
+// WorkOrderTypeDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type WorkOrderTypeDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns workOrderTypeColumns
+}
+
+// WorkOrderTypeColumns defines and stores column names for table work_order_type.
+type workOrderTypeColumns struct {
+	Id          string // 主键
+	Desc        string // 描述
+	WorkflowId  string // 关联流程
+	FormId      string // 关联表单
+	Remark      string // 备注
+	CreatedBy   string // 创建者
+	CreatedName string // 创建人
+	CreatedTime string // 创建时间
+	UpdatedBy   string // 更新者
+	UpdatedName string // 更新人
+	UpdatedTime string // 更新时间
+	DeletedTime string // 删除时间
+}
+
+var (
+	// WorkOrderType is globally public accessible object for table work_order_type operations.
+	WorkOrderType = WorkOrderTypeDao{
+		M:     g.DB("default").Model("work_order_type").Safe(),
+		DB:    g.DB("default"),
+		Table: "work_order_type",
+		Columns: workOrderTypeColumns{
+			Id:          "id",
+			Desc:        "desc",
+			WorkflowId:  "workflow_id",
+			FormId:      "form_id",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+)
+
+func NewWorkOrderTypeDao(tenant string) WorkOrderTypeDao {
+	var dao WorkOrderTypeDao
+	dao = WorkOrderTypeDao{
+		M:     g.DB(tenant).Model("work_order_type").Safe(),
+		DB:    g.DB(tenant),
+		Table: "work_order_type",
+		Columns: workOrderTypeColumns{
+			Id:          "id",
+			Desc:        "desc",
+			WorkflowId:  "workflow_id",
+			FormId:      "form_id",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+	return dao
+}
+
+// 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 (d *WorkOrderTypeDao) Ctx(ctx context.Context) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *WorkOrderTypeDao) As(as string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *WorkOrderTypeDao) TX(tx *gdb.TX) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *WorkOrderTypeDao) Master() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *WorkOrderTypeDao) Slave() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *WorkOrderTypeDao) Args(args ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Args(args...)}
+}
+
+// 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 (d *WorkOrderTypeDao) LeftJoin(table ...string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) RightJoin(table ...string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) InnerJoin(table ...string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *WorkOrderTypeDao) Fields(fieldNamesOrMapStruct ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *WorkOrderTypeDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *WorkOrderTypeDao) Option(option int) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *WorkOrderTypeDao) OmitEmpty() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *WorkOrderTypeDao) Filter() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) Where(where interface{}, args ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.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 M.Where treats the condition
+// as string "123".
+func (d *WorkOrderTypeDao) WherePri(where interface{}, args ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *WorkOrderTypeDao) And(where interface{}, args ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *WorkOrderTypeDao) Or(where interface{}, args ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *WorkOrderTypeDao) Group(groupBy string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *WorkOrderTypeDao) Order(orderBy ...string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) Limit(limit ...int) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *WorkOrderTypeDao) Offset(offset int) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) Page(page, limit int) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *WorkOrderTypeDao) Batch(batch int) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) Cache(duration time.Duration, name ...string) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.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 (d *WorkOrderTypeDao) Data(data ...interface{}) *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.WorkOrderType.
+// 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 M.Where function,
+// see M.Where.
+func (d *WorkOrderTypeDao) All(where ...interface{}) ([]*model.WorkOrderType, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.WorkOrderType
+	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 *model.WorkOrderType.
+// 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 M.Where function,
+// see M.Where.
+func (d *WorkOrderTypeDao) One(where ...interface{}) (*model.WorkOrderType, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.WorkOrderType
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *WorkOrderTypeDao) FindOne(where ...interface{}) (*model.WorkOrderType, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.WorkOrderType
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *WorkOrderTypeDao) FindAll(where ...interface{}) ([]*model.WorkOrderType, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.WorkOrderType
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *WorkOrderTypeDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *WorkOrderTypeDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *WorkOrderTypeDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *WorkOrderTypeDao) Chunk(limit int, callback func(entities []*model.WorkOrderType, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.WorkOrderType
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *WorkOrderTypeDao) LockUpdate() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *WorkOrderTypeDao) LockShared() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *WorkOrderTypeDao) Unscoped() *WorkOrderTypeDao {
+	return &WorkOrderTypeDao{M: d.M.Unscoped()}
+}

+ 36 - 0
opms_parent/app/dao/work/work_order_dynamics.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package work
+
+import (
+	"dashoo.cn/micro/app/dao/work/internal"
+)
+
+// workOrderDynamicsDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type workOrderDynamicsDao struct {
+	internal.WorkOrderDynamicsDao
+}
+
+var (
+	// WorkOrderDynamics is globally public accessible object for table work_order_dynamics operations.
+	WorkOrderDynamics = workOrderDynamicsDao{
+		internal.WorkOrderDynamics,
+	}
+)
+
+type WorkOrderDynamicsDao struct {
+	internal.WorkOrderDynamicsDao
+}
+
+func NewWorkOrderDynamicsDao(tenant string) *WorkOrderDynamicsDao {
+	dao := internal.NewWorkOrderDynamicsDao(tenant)
+	return &WorkOrderDynamicsDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 18 - 18
opms_parent/app/handler/cust/customer.go

@@ -7,7 +7,6 @@ import (
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/net/ghttp"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
 	"github.com/gogf/gf/util/gvalid"
@@ -294,20 +293,21 @@ func (c *CustomerHeader) WriteCustLog(ctx context.Context, custType string, cust
 	CustomerService.OperationLog(ctx, custId, custDynameics)
 }
 
-func (c *CustomerHeader) DeriveList(ctx context.Context, req *model.CustCustomerSearchReq, rsp *comm_def.CommonMsg) error {
-	//s := g.Server()
-	customerServer, err := server.NewCustomerService(ctx)
-	if err != nil {
-		g.Log().Error(err)
-		return gerror.New("系统异常,请重新尝试")
-	}
-	g.Server()
-	r := new(ghttp.Request)
-	buffer, _ := customerServer.Derive(req)
-	fileName := gconv.String(gtime.Now()) + ".csv"
-	r.Response.Header().Set("Content-Type", "text/csv")
-	r.Response.Header().Set("Content-Disposition", "attachment;filename="+fileName)
-	r.Response.Write(buffer.Bytes())
-
-	return nil
-}
+//func (c *CustomerHeader) DeriveList(ctx context.Context, req *model.CustCustomerExport, rsp *comm_def.CommonMsg) error {
+//	//s := g.Server()
+//	customerServer, err := server.NewCustomerService(ctx)
+//	if err != nil {
+//		g.Log().Error(err)
+//		return gerror.New("系统异常,请重新尝试")
+//	}
+//	//g.Server()
+//	//r := new(ghttp.Request)
+//	buffer, _ := customerServer.Derive(req)
+//	//fileName := gconv.String(gtime.Now()) + ".csv"
+//	//r.Response.Header().Set("Content-Type", "text/csv")
+//	//r.Response.Header().Set("Content-Disposition", "attachment;filename="+fileName)
+//	//r.Response.Write(buffer.Bytes())
+//
+//	rsp.Data = g.Map{"list": buffer}
+//	return nil
+//}

+ 39 - 0
opms_parent/app/handler/work/workorder.go

@@ -0,0 +1,39 @@
+package work
+
+import (
+	"context"
+
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/opms_libary/myerrors"
+	"github.com/gogf/gf/frame/g"
+
+	model "dashoo.cn/micro/app/model/work"
+	server "dashoo.cn/micro/app/service/work"
+)
+
+type WorkOrderHandler struct{}
+
+//工单列表
+func (w *WorkOrderHandler) GetList(ctx context.Context, req *model.WorkOrderSearchReq, rsp *comm_def.CommonMsg) error {
+
+	orderServer, err := server.NewOrderService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	total, list, err := orderServer.GetList(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	rsp.Data = g.Map{"list": list, "total": total}
+	return nil
+
+}
+
+//新增工单
+//func (w *WorkOrderHandler) Create(ctx context.Context, req *model., rsp *comm_def.CommonMsg) error {
+//	return nil
+//
+//}

+ 14 - 0
opms_parent/app/model/cust/cust_customer.go

@@ -26,6 +26,20 @@ type CustCustomerSearchReq struct {
 	request.PageReq
 }
 
+//导出参数
+
+type CustCustomerExport struct {
+	CustCustomerSearchReq *CustCustomerSearchReq
+	Columns               []string `json:"columns"` // 导出列
+	request.PageReq
+}
+
+//导出字节流
+
+type CustExport struct {
+	Content []byte `json:"content"` // 导出数据流
+}
+
 // 添加客户信息表
 type AddCustCustomerReq struct {
 	Cust *Customer

+ 3 - 3
opms_parent/app/service/base/base_distributor.go

@@ -36,13 +36,13 @@ func (d *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
 	distributorModel := d.Dao.M
 	distributorModel = distributorModel.Where(d.Dao.Columns.DeletedTime + " is null")
 	if req.DistCode != "" {
-		distributorModel = distributorModel.Where(d.Dao.Columns.DistCode+"like ?", "%"+req.DistCode+"%")
+		distributorModel = distributorModel.Where(d.Dao.Columns.DistCode+" like ?", "%"+req.DistCode+"%")
 	}
 	if req.DistName != "" {
-		distributorModel = distributorModel.Where(d.Dao.Columns.DistName+"like ?", "%"+req.DistName+"%")
+		distributorModel = distributorModel.Where(d.Dao.Columns.DistName+" like ?", "%"+req.DistName+"%")
 	}
 	if req.BelongSale != "" {
-		distributorModel = distributorModel.Where(d.Dao.Columns.BelongSale+"like ?", "%"+req.BelongSale+"%")
+		distributorModel = distributorModel.Where(d.Dao.Columns.BelongSale+" like ?", "%"+req.BelongSale+"%")
 	}
 	if req.ProvinceId > 0 {
 		distributorModel = distributorModel.Where(d.Dao.Columns.ProvinceId+" in (?)", req.ProvinceId)

+ 73 - 55
opms_parent/app/service/cust/cust_customer.go

@@ -3,12 +3,11 @@ package cust
 import (
 	"bytes"
 	"context"
-	"encoding/csv"
 	"math"
-	"sort"
 	"strconv"
 	"time"
 
+	"github.com/360EntSecGroup-Skylar/excelize"
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
@@ -22,8 +21,6 @@ import (
 
 const TIME_LAYOUT = "2006-01-02 15:04:05"
 
-var derivetable = []string{"客户编码", "客户名称", "助记名", "所在地区", "客户行业", "客户行业", "客户状态", "最后跟进时间", "创建人", "创建时间"}
-
 type CustomerService struct {
 	*service.ContextService
 	Dao         *cust.CustCustomerDao
@@ -56,44 +53,70 @@ func NewCustomerService(ctx context.Context) (svc *CustomerService, err error) {
 }
 
 //导出数据
-func (c *CustomerService) Derive(req *model.CustCustomerSearchReq) (bytesBuffer *bytes.Buffer, err error) {
-	//file, err := os.Create("cust_list.csv")
-	//g.Log().Info("xxxx", "cust_list")
-	//if err != nil {
-	//	fmt.Println("open file is failed, err: ", err)
-	//}
-	req.TargetType = "11"
-	_, data, _ := c.GetList(req)
-	// 延迟关闭
-	//buffer := &bytes.Buffer{}
-	bytesBuffer = &bytes.Buffer{}
-	bytesBuffer.WriteString("xEFxBBxBF")
-	//defer file.Close()
-	//// 写入UTF-8 BOM,防止中文乱码
-	//	buffer.WriteString("\xEF\xBB\xBF")
-	w := csv.NewWriter(bytesBuffer)
-	// 写入数据
-	w.Write(derivetable)
-	w.Flush()
-	// Map写入
-	m := make(map[int][]string)
-	for k, v := range data {
-		m[k] = []string{v.CustCode, v.CustName, v.AbbrName, v.CustLocation, v.CustIndustry, v.CustLevel, v.CustStatus,
-			gconv.String(v.FollowUpDate), v.CreatedName, gconv.String(v.CreatedTime)}
-	}
-	// 按照key排序
-	var keys []int
-	for k := range m {
-		keys = append(keys, k)
-	}
-	sort.Ints(keys)
-	for _, key := range keys {
-		w.Write(m[key])
-		// 刷新缓冲
-	}
-	w.Flush()
+func (c *CustomerService) Derive(req *model.CustCustomerExport) (content *model.CustExport, err error) {
+	var con model.CustExport
+	req.CustCustomerSearchReq.TargetType = "11"
+	total, data, err := c.GetList(req.CustCustomerSearchReq)
+	if err != nil {
+		return
+	}
+	f := excelize.NewFile()
+	index := f.NewSheet("Sheet1")
+	for index, item := range req.Columns {
+		sheetPosition := service.Div(index+1) + "1"
+		f.SetCellValue("Sheet1", sheetPosition, item)
+	}
+	if total > 0 {
+
+		for ck, item := range data {
+			for index, v := range req.Columns {
+				if v == "经销商编码" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustCode)
+				}
+				if v == "经销商名称" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustName)
+				}
+				//if v == "" {
+				//	f.SetCe
+				//}
+			}
 
-	return
+		}
+
+	}
+	f.SetActiveSheet(index)
+
+	var buffer *bytes.Buffer
+	buffer, _ = f.WriteToBuffer()
+	con.Content = buffer.Bytes()
+
+	return &con, err
+
+	//bytesBuffer = &bytes.Buffer{}
+	//bytesBuffer.WriteString("xEFxBBxBF")
+	//
+	//w := csv.NewWriter(bytesBuffer)
+	//// 写入数据
+	//w.Write(derivetable)
+	//w.Flush()
+	//// Map写入
+	//m := make(map[int][]string)
+	//for k, v := range data {
+	//	m[k] = []string{v.CustCode, v.CustName, v.AbbrName, v.CustLocation, v.CustIndustry, v.CustLevel, v.CustStatus,
+	//		gconv.String(v.FollowUpDate), v.CreatedName, gconv.String(v.CreatedTime)}
+	//}
+	//// 按照key排序
+	//var keys []int
+	//for k := range m {
+	//	keys = append(keys, k)
+	//}
+	//sort.Ints(keys)
+	//for _, key := range keys {
+	//	w.Write(m[key])
+	//	// 刷新缓冲
+	//}
+	//w.Flush()
+	//return
 }
 
 //创建客户
@@ -199,9 +222,10 @@ func (c *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
 	}
 	//客户级别
 	if req.CustLevel != "" {
+		g.Log().Info("level", req.CustLevel)
 		Model = Model.Where(c.Dao.Columns.CustLevel, req.CustLevel)
 	}
-	total, err = Model.Fields().Count()
+	total, err = Model.Count()
 	if err != nil {
 		g.Log().Error(err)
 		err = gerror.New("获取总行数失败")
@@ -363,40 +387,34 @@ func (c *CustomerService) CustAbstract(id int64) (followInfo *model.Follow, err
 	followInfo.FollowCount = count
 	//
 	find, err := custModel.Fields(c.Dao.Columns.FollowUpDate).Where(c.Dao.Columns.Id, id).FindOne()
+	g.Log().Info("find", find)
 
 	if err != nil {
 		g.Log().Error(err)
 		return nil, gerror.New("获取用户数据失败")
 	}
-	if find.IsEmpty() {
+
+	findOne := find.Map()
+	if findOne["follow_up_date"] == "" {
 		followInfo.NotFollowDay = 0
+		return
 	}
-	findOne := find.Map()
-	//followDate, err := Model.Fields("max(next_time) as next_time").Where(c.FollowDao.Columns.CustId, id).Where(c.FollowDao.Columns.FollowDate, findOne["follow_up_date"]).FindOne()
-	//if followDate.IsEmpty() {
-	//	followInfo.NotFollowDay = 0
-	//}
-	//followNextTime := followDate.Map()
-	//next_time := gconv.String(followNextTime["next_time"])
 	upDate := gconv.String(findOne["follow_up_date"])
 	follow_up, err1 := time.Parse(TIME_LAYOUT, upDate)
 	now := gtime.Now()
 	follow_next, err2 := time.Parse(TIME_LAYOUT, gconv.String(now))
 	if err1 != nil || err2 != nil {
 		followInfo.NotFollowDay = 0
+		return
 	}
 	poor := follow_next.Sub(follow_up)
-	g.Log().Info("xxxxfdsaf", poor)
+	g.Log().Info("xxxxfdsaf", follow_up)
 	hours := float64(poor.Hours() / 24)
 	if hours < 0 {
 		followInfo.NotFollowDay = 0
 	} else {
 		followInfo.NotFollowDay = int(math.Floor(hours))
 	}
-
-	//g.Log().Info("findOne_time", findOne["follow_up_date"])
-	//g.Log().Info("next_time", next_time)
-	//g.Log().Info("ceil", math.Ceil(hours))
 	return
 }
 

+ 58 - 0
opms_parent/app/service/work/work_order.go

@@ -0,0 +1,58 @@
+package work
+
+import (
+	"context"
+
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+
+	"dashoo.cn/micro/app/dao/work"
+	model "dashoo.cn/micro/app/model/work"
+	"dashoo.cn/micro/app/service"
+)
+
+type OrderService struct {
+	*service.ContextService
+	Dao *work.WorkOrderDao
+}
+
+//工单状态
+//10发起20审批中30审批通过40审批拒绝50关闭
+var MapStatus = map[string]string{"10": "发起", "20": "审批中", "30": "审批通过", "40": "审批拒绝", "50": "关闭"}
+
+func NewOrderService(ctx context.Context) (svc *OrderService, err error) {
+	svc = new(OrderService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = work.NewWorkOrderDao(svc.Tenant)
+	return svc, nil
+}
+
+//列表
+func (w *OrderService) GetList(req *model.WorkOrderSearchReq) (total int, OrderList []*model.WorkOrderList, err error) {
+	Model := w.Dao.M
+	Model.Where(w.Dao.Columns.DeletedTime + " is null ")
+	//工单类型
+	if req.OrderTypeId != 0 {
+		Model.Where(w.Dao.Columns.OrderTypeId, req.OrderTypeId)
+	}
+	//工单状态
+	if req.OrderStatus != "" {
+		Model.Where(w.Dao.Columns.OrderStatus, req.OrderStatus)
+	}
+	total, err = Model.Fields().Count()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取总行数失败")
+		return
+	}
+	if req.PageNum == 0 {
+		req.PageNum = 1
+	}
+	err = Model.Page(req.PageNum, req.PageSize).Order("id desc").Scan(&OrderList)
+	for _, v := range OrderList {
+		v.OrderStatus = MapStatus[v.OrderStatus]
+	}
+	return
+}