作者 yangfu

feat: 版本 1.0.3

- 工时优化
- 撤回生产记录
... ... @@ -5,3 +5,24 @@ create UNIQUE INDEX idx_unq_product_material_group_company_id_org_id_material_gr
-- 表product_material 增加唯一索引 idx_unq_product_material_company_id_material_number
create UNIQUE INDEX idx_unq_product_material_company_id_material_number on manufacture.product_material using btree(company_id,material_number,deleted_at);
-- 菜单脚本
INSERT INTO "users"."menu"("menu_id", "parent_id", "menu_name", "code", "access_code", "menu_type", "icon", "sort", "remark", "category", "parent_path", "is_publish", "enable_status", "link") VALUES (269, 175, '物料信息', 'BUSINESS_ALLIED-MANUFACTURING_BASIC_MATERIAL', '', 'menu', 'https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220302/object/1646211608_CH2pTwT56j6TXfRdYhGxBfKRNFfpzWKE.png', 3, '', '7', '38,174,175', 1, 0, NULL);
INSERT INTO "users"."menu"("menu_id", "parent_id", "menu_name", "code", "access_code", "menu_type", "icon", "sort", "remark", "category", "parent_path", "is_publish", "enable_status", "link") VALUES (270, 269, '删除', 'BUSINESS_ALLIED-MANUFACTURING_BASIC_MATERIAL_DEL', '', 'button', '', 1, '', '7', '38,174,175,269', 1, 2, NULL);
INSERT INTO "users"."menu"("menu_id", "parent_id", "menu_name", "code", "access_code", "menu_type", "icon", "sort", "remark", "category", "parent_path", "is_publish", "enable_status", "link") VALUES (271, 269, '新增', 'BUSINESS_ALLIED-MANUFACTURING_BASIC_MATERIAL_ADD', '', 'button', '', 1, '', '7', '38,174,175,269', 1, 2, NULL);
INSERT INTO "users"."menu"("menu_id", "parent_id", "menu_name", "code", "access_code", "menu_type", "icon", "sort", "remark", "category", "parent_path", "is_publish", "enable_status", "link") VALUES (272, 269, '编辑', 'BUSINESS_ALLIED-MANUFACTURING_BASIC_MATERIAL_EDIT', '', 'button', '', 1, '', '7', '38,174,175,269', 1, 2, NULL);
INSERT INTO "users"."menu"("menu_id", "parent_id", "menu_name", "code", "access_code", "menu_type", "icon", "sort", "remark", "category", "parent_path", "is_publish", "enable_status", "link") VALUES (273, 269, '查看', 'BUSINESS_ALLIED-MANUFACTURING_BASIC_MATERIAL_VIEW', '', 'button', '', 1, '', '7', '38,174,175,269', 1, 2, NULL);
UPDATE "users"."menu" SET "parent_id" = 175, "menu_name" = '产品管理', "code" = 'BUSINESS_ALLIED-MANUFACTURING_BASIC_PRODUCT', "access_code" = '', "menu_type" = 'menu', "icon" = 'https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220302/object/1646211429_wMrRfxYMyhBySwWkysZaXBbfDapSppBs.png', "sort" = 4, "remark" = '', "category" = '7', "parent_path" = '38,174,175', "is_publish" = 1, "enable_status" = 0, "link" = NULL WHERE "menu_id" = 186;
UPDATE "users"."menu" SET "parent_id" = 175, "menu_name" = '设备档案', "code" = 'BUSINESS_ALLIED-MANUFACTURING_BASIC_DEVICE', "access_code" = '', "menu_type" = 'menu', "icon" = 'https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220302/object/1646211439_WaAKb65X7wX2zjsMExDyy56XRnTRAmPD.png', "sort" = 5, "remark" = '', "category" = '7', "parent_path" = '38,174,175', "is_publish" = 1, "enable_status" = 0, "link" = NULL WHERE "menu_id" = 193;
UPDATE "users"."menu" SET "parent_id" = 175, "menu_name" = '工厂日历', "code" = 'BUSINESS_ALLIED-MANUFACTURING_BASIC_CALENDAR', "access_code" = '', "menu_type" = 'menu', "icon" = 'https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220302/object/1646211448_GBY3HhbPpNnNpnGPWGE6wETW6F6THfr4.png', "sort" = 6, "remark" = '', "category" = '7', "parent_path" = '38,174,175', "is_publish" = 1, "enable_status" = 0, "link" = NULL WHERE "menu_id" = 199;
UPDATE "users"."menu" SET "parent_id" = 175, "menu_name" = '单位换算', "code" = 'BUSINESS_ALLIED-MANUFACTURING_BASIC_UNIT-CONVERSION', "access_code" = '', "menu_type" = 'menu', "icon" = 'https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220302/object/1646211456_cKxKHHXHQnM3e7RZNxdkZ3n7ZXJjdKba.png', "sort" = 7, "remark" = '', "category" = '7', "parent_path" = '38,174,175', "is_publish" = 1, "enable_status" = 0, "link" = NULL WHERE "menu_id" = 203;
\ No newline at end of file
... ...
... ... @@ -130,8 +130,8 @@ func (productMaterialGroupService *ProductMaterialGroupService) ListProductMater
}
// 移除物料分组服务
func (productMaterialGroupService *ProductMaterialGroupService) RemoveProductMaterialGroup(removeProductMaterialGroupCommand *command.RemoveProductMaterialGroupCommand) (interface{}, error) {
if err := removeProductMaterialGroupCommand.ValidateCommand(); err != nil {
func (productMaterialGroupService *ProductMaterialGroupService) RemoveProductMaterialGroup(operateInfo *domain.OperateInfo, cmd *command.RemoveProductMaterialGroupCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -144,29 +144,37 @@ func (productMaterialGroupService *ProductMaterialGroupService) RemoveProductMat
defer func() {
transactionContext.RollbackTransaction()
}()
var productMaterialGroupRepository domain.ProductMaterialGroupRepository
if value, err := factory.CreateProductMaterialGroupRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
materialService, _ := domainService.NewPGMaterialService(transactionContext.(*pgTransaction.TransactionContext))
_, ids, err := materialService.AllMaterialGroupChild(operateInfo, cmd.ProductMaterialGroupId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productMaterialGroupRepository = value
}
productMaterialGroup, err := productMaterialGroupRepository.FindOne(map[string]interface{}{"productMaterialGroupId": removeProductMaterialGroupCommand.ProductMaterialGroupId})
if len(ids) == 0 {
return nil, nil
}
productMaterialRepository, _, _ := factory.FastProductMaterial(transactionContext, 0)
count, _, err := productMaterialRepository.Find(map[string]interface{}{"productMaterialGroupIds": ids, "limit": 1})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if productMaterialGroup == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("已删除 %s", string(removeProductMaterialGroupCommand.ProductMaterialGroupId)))
if count >= 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请处理当前分组下存在的物料信息")
}
if productMaterialGroup, err := productMaterialGroupRepository.Remove(productMaterialGroup); err != nil {
for _, id := range ids {
productMaterialGroupRepository, productMaterialGroup, err := factory.FastProductMaterialGroup(transactionContext, id)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
}
if _, err = productMaterialGroupRepository.Remove(productMaterialGroup); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return productMaterialGroup, nil
}
return nil, nil
}
// 更新物料分组服务
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type CancelProductRecordCommand struct {
// 生产记录ID
ProductRecordId int `cname:"生产记录ID" json:"productRecordId" valid:"Required"`
}
func (cancelProductRecordCommand *CancelProductRecordCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (cancelProductRecordCommand *CancelProductRecordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cancelProductRecordCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(cancelProductRecordCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package dto
import (
"github.com/linmadan/egglib-go/utils/xtime"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
)
// HistoryProductRecord 历史生成记录
type HistoryProductRecord struct {
// 生产记录ID
ProductRecordId int `json:"productRecordId,omitempty"`
// 批号
BatchNumber string `json:"batchNumber,omitempty"`
// 计划的产品名称
PlanProductName string `json:"planProductName,omitempty"`
// 创建时间
CreatedAt string `json:"createdAt,omitempty"`
// 生产记录类型:1:领料 2:退料 4:称重 8:二级品称重
ProductRecordType int `json:"productRecordType"`
// 生产工人
ProductWorker *domain.User `json:"productWorker,omitempty"`
// 产能 - 审核前
Weight float64 `json:"weight"`
// 状态 1:未审核 2:已审核 3:已撤回 4:已记录
Status int `json:"status"`
}
func (d *HistoryProductRecord) LoadDto(m *domain.ProductRecord) *HistoryProductRecord {
d.ProductRecordId = m.ProductRecordId
d.ProductWorker = m.ProductWorker
d.Weight = utils.Round(m.ProductRecordInfo.WeighBefore, 1)
d.Status = m.ProductRecordInfo.ApproveStatus
d.PlanProductName = m.ProductRecordInfo.PlanProductName
d.BatchNumber = m.ProductRecordInfo.BatchNumber
d.CreatedAt = m.CreatedAt.Local().Format("2006-01-02 15:04:05")
d.ProductRecordType = m.ProductRecordType
if m.ProductRecordType != domain.RecordTypeSecondLevelWeigh && m.ProductRecordInfo.ApproveStatus == domain.ProductRecordNotApprove && !xtime.BeginningOfDay().Equal(xtime.New(m.CreatedAt).BeginningOfDay()) {
d.Status = domain.ProductRecordLogged
}
return d
}
... ...
package query
import (
"fmt"
"github.com/linmadan/egglib-go/utils/xtime"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
"reflect"
"strings"
"time"
"github.com/beego/beego/v2/core/validation"
)
type HistoryProductRecordQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset"`
// 查询限制
Limit int `cname:"查询限制" json:"limit"`
// 当前公司
CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"`
// 当前登录的组织
OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"`
// 匹配多个组织
InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty"`
// 页码
PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
// 页数
PageSize int `cname:"页数" json:"pageSize,omitempty"`
// 车间名称
//WorkshopName string `cname:"车间名称" json:"workshopName"`
// 批号
//BatchNumber string `cname:"批号" json:"batchNumber"`
// 姓名
//UserName string `cname:"姓名" json:"userName"`
// 生产记录类型:1:领料 2:退料 4:称重 8:二级品称重
ProductRecordType int `cname:"生产记录类型:1:领料 2:退料 4:称重 8:二级品称重" json:"productRecordType"`
// 生产线名称
//LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 工段名称
//SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 员工类型 1:固定 2:派遣 3.临时
//EmployeeType int `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
// 开始时间
//BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
//EndTime string `cname:"结束时间" json:"endTime"`
// 上一次记录ID
LastProductRecordId int `cname:"上一次记录ID" json:"lastProductRecordId"`
// 日期
Date string `cname:"日期" json:"date"`
// 生产员工ID
ProductWorkerId int `cname:"生产员工ID" json:"productWorkerId"`
// 状态 0:全部 1:未审核 2:已审核 3:已撤回 4:已记录
Status int `cname:"状态" json:"status"`
// 开始时间
ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"`
// 结束时间
ProductEndTime time.Time `cname:"结束时间" json:"productEndTime"`
}
func (cmd *HistoryProductRecordQuery) Valid(validation *validation.Validation) {
cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize)
//var err error
//if len(cmd.BeginTime) > 0 {
// if cmd.ProductBeginTime, err = time.Parse("2006-01-02 15:04:05", cmd.BeginTime); err != nil {
// log.Logger.Error(err.Error())
// validation.Error("开始时间有误")
// return
// }
//}
//if len(cmd.EndTime) > 0 {
// if cmd.ProductEndTime, err = time.Parse("2006-01-02 15:04:05", cmd.EndTime); err != nil {
// log.Logger.Error(err.Error())
// validation.Error("结束时间有误")
// return
// }
// if cmd.ProductEndTime.Equal(cmd.ProductBeginTime) {
// cmd.ProductEndTime = cmd.ProductEndTime.Add(time.Hour * 24)
// }
//}
if len(cmd.Date) > 0 {
t, err := xtime.Parse(cmd.Date)
if err != nil {
log.Logger.Error(err.Error())
validation.Error("日期有误")
return
}
cmd.ProductBeginTime = t
cmd.ProductEndTime = t.AddDate(0, 0, 1)
}
if cmd.Status == domain.ProductRecordLogged {
cmd.Status = domain.ProductRecordNotApprove
if len(cmd.Date) == 0 && xtime.IsZero(cmd.ProductEndTime) {
cmd.ProductEndTime = xtime.BeginningOfDay()
}
}
}
func (cmd *HistoryProductRecordQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(cmd).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -274,6 +274,41 @@ func (productRecordService *ProductRecordService) SearchProductRecord(operateInf
return count, result, nil
}
// 返回生产记录服务列表
func (productRecordService *ProductRecordService) HistoryProductRecord(operateInfo *domain.OperateInfo, query *query.HistoryProductRecordQuery) (int64, interface{}, error) {
if err := query.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var productRecordRepository domain.ProductRecordRepository
productRecordRepository, _, _ = factory.FastPgProductRecord(transactionContext, 0)
count, productRecords, err := productRecordRepository.Find(utils.ObjectToMap(query))
if err != nil {
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var result = make([]*dto.HistoryProductRecord, 0)
for i := range productRecords {
item := productRecords[i]
newItem := &dto.HistoryProductRecord{}
newItem.LoadDto(item)
result = append(result, newItem)
}
return count, result, nil
}
// 生产记录统计
func (productRecordService *ProductRecordService) ProductRecordStatics(cmd *command.ProductRecordStaticsCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ... @@ -308,6 +343,33 @@ func (productRecordService *ProductRecordService) ProductRecordStatics(cmd *comm
return nil, nil
}
// 生产记录审核
func (productRecordService *ProductRecordService) CancelProductRecord(cmd *command.CancelProductRecordCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
svr, err := domainService.NewPGProductRecordService(transactionContext.(*pgTransaction.TransactionContext))
if _, err = svr.Cancel(cmd.ProductRecordId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct{}{}, nil
}
func NewProductRecordService(options map[string]interface{}) *ProductRecordService {
newProductRecordService := &ProductRecordService{}
return newProductRecordService
... ...
... ... @@ -80,15 +80,32 @@ func (productAttendanceRecord *ProductAttendanceRecord) ComputeWorkTimeBefore(pr
if !productAttendanceRecord.SignOut.After(productAttendanceRecord.SignIn) {
return 0
}
wt := utils.Round(productAttendanceRecord.SignOut.Sub(productAttendanceRecord.SignIn).Hours(), 1)
wt := utils.Round(productAttendanceRecord.SignOut.Sub(productAttendanceRecord.SignIn).Hours(), 2)
if productCalendar == nil {
return wt
return roundWorkTime(wt)
}
wt = wt - productAttendanceRecord.AttendanceBreakTime(productCalendar)
if wt < 0 {
return 0
}
return wt
return roundWorkTime(wt)
}
// roundWorkTime 工时取整[0:0.167]=> 0 \ [0.167,0.667]=> 0.5 \ [0.667,1]=>1
// 10/60 = 0.167 40/60 = 0.667
func roundWorkTime(wt float64) float64 {
i := float64(int(wt))
f := wt - i
if f < 0.167 {
return i
}
if f >= 0.167 && f < 0.667 {
return i + 0.5
}
if f >= 0.667 {
return i + 1
}
return i
}
func (productAttendanceRecord *ProductAttendanceRecord) SetProductTimeByProductCalendar(productCalendar *ProductCalendar) error {
... ...
... ... @@ -17,6 +17,8 @@ const (
const (
ProductRecordNotApprove = 1 // 未审核
ProductRecordApproved = 2 // 已审核
ProductRecordWithdraw = 3 // 已撤回
ProductRecordLogged = 4 // 已记录
)
// 生产记录
... ... @@ -82,6 +84,21 @@ func (productRecord *ProductRecord) Approve(approveUser *User, weighAfter float6
return nil
}
func (productRecord *ProductRecord) Cancel() error {
if productRecord.ProductRecordInfo.ApproveStatus == ProductRecordApproved {
return errors.New("已审核")
}
if productRecord.ProductRecordInfo.ApproveStatus == ProductRecordWithdraw {
return errors.New("已撤销")
}
//if xtime.BeforeEqual(productRecord.CreatedAt, xtime.BeginningOfDay()) {
// return errors.New("已记录")
//}
productRecord.ProductRecordInfo.ApproveStatus = ProductRecordWithdraw
productRecord.UpdatedAt = time.Now()
return nil
}
func TaskKeyPatternProductRecordStatics() string {
return fmt.Sprintf("%v:task:product-record:statics", constant.CACHE_PREFIX)
}
... ...
... ... @@ -101,8 +101,8 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[
endTime = time.Now()
)
if !xtime.IsZero(request.Date.Time()) && !request.Date.Time().Equal(beginTime) {
beginTime = request.Date.Time().AddDate(0, 0, -1)
endTime = request.Date.Time()
beginTime = request.Date.Time()
endTime = request.Date.Time().AddDate(0, 0, 1)
}
for _, v := range workshop.GetProductLines(domain.NotDeleted) {
var result = make([]*record, 0)
... ...
... ... @@ -180,6 +180,30 @@ func (ptr *PGProductRecordService) Approve(productRecordId int, approveUserId in
return struct{}{}, nil
}
// Approve 审核生产记录 (二级品审核)
func (ptr *PGProductRecordService) Cancel(productRecordId int) (interface{}, error) {
productRecordRepository, err := repository.NewProductRecordRepository(ptr.transactionContext)
var productRecord *domain.ProductRecord
productRecord, err = productRecordRepository.FindOne(map[string]interface{}{"productRecordId": productRecordId})
if err != nil {
return nil, err
}
if err = productRecord.Cancel(); err != nil {
return nil, err
}
if _, err = productRecordRepository.Save(productRecord); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 发送Job
productRecord.ProductRecordInfo.Weigh = -productRecord.ProductRecordInfo.Weigh
if err = SendProductRecordStaticsJob(productRecord); err != nil {
return nil, err
}
return struct{}{}, nil
}
func (ptr *PGProductRecordService) BatchApprove(list []*domain.ProductRecord, approveUserId int, weight float64, status int) (interface{}, error) {
var productRecordRepository, _ = repository.NewProductRecordRepository(ptr.transactionContext)
var record *domain.ProductRecord
... ...
... ... @@ -164,7 +164,7 @@ func (repository *ProductMaterialRepository) Find(queryOptions map[string]interf
query.Where("material_name like ?", fmt.Sprintf("%%%v%%", v))
}
if v, ok := queryOptions["materialCategory"]; ok && v != "" {
query.Where(fmt.Sprintf(`material_category->>'category' like '%%%v%%'`, v))
query.Where(fmt.Sprintf(`material_category->>'category' = '%v'`, v))
}
if v, ok := queryOptions["materialNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("material_number in (?)", pg.In(v))
... ...
... ... @@ -180,6 +180,12 @@ func (repository *ProductRecordRepository) Find(queryOptions map[string]interfac
if v, ok := queryOptions["productPlanId"]; ok && v.(int) > 0 {
query.Where(fmt.Sprintf(`product_record_info->>'productPlanId' = '%v'`, v))
}
if v, ok := queryOptions["status"]; ok && v.(int) > 0 {
query.Where(fmt.Sprintf(`product_record_info->>'approveStatus' = '%v'`, v))
}
if v, ok := queryOptions["lastProductRecordId"]; ok && v.(int) > 0 {
query.Where(`product_record_id < ?`, v)
}
query.SetOffsetAndLimit(domain.MaxQueryRow)
query.SetOrderDirect("product_record_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
... ...
... ... @@ -48,7 +48,8 @@ func (controller *ProductMaterialGroupController) RemoveProductMaterialGroup() {
controller.Unmarshal(removeProductMaterialGroupCommand)
productMaterialGroupId, _ := controller.GetInt(":productMaterialGroupId")
removeProductMaterialGroupCommand.ProductMaterialGroupId = productMaterialGroupId
data, err := productMaterialGroupService.RemoveProductMaterialGroup(removeProductMaterialGroupCommand)
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productMaterialGroupService.RemoveProductMaterialGroup(operateInfo, removeProductMaterialGroupCommand)
controller.Response(data, err)
}
... ...
... ... @@ -84,6 +84,26 @@ func (controller *ProductRecordController) SearchProductRecord() {
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *ProductRecordController) History() {
productPlanService := service.NewProductRecordService(nil)
cmd := &query.HistoryProductRecordQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := productPlanService.HistoryProductRecord(ParseOperateInfo(controller.BaseController), cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *ProductRecordController) CancelProductRecord() {
productRecordService := service.NewProductRecordService(nil)
cmd := &command.CancelProductRecordCommand{}
controller.Unmarshal(cmd)
data, err := productRecordService.CancelProductRecord(cmd)
controller.Response(data, err)
}
func (controller *ProductRecordController) SearchEmployeeProductRecord() {
productPlanService := service.NewProductRecordService(nil)
cmd := &query.SearchEmployeeProductRecordQuery{}
... ...
... ... @@ -14,6 +14,8 @@ func init() {
web.Router("/product-records/approve", &controllers.ProductRecordController{}, "Post:ApproveProductRecord")
web.Router("/product-records/search", &controllers.ProductRecordController{}, "Post:SearchProductRecord")
web.Router("/product-records/second-level-record/search", &controllers.ProductRecordController{}, "Post:SearchProductRecord")
web.Router("/product-records/history", &controllers.ProductRecordController{}, "Post:History")
web.Router("/product-records/cancel", &controllers.ProductRecordController{}, "Post:CancelProductRecord")
web.Router("/product-records/employee-productive/search", &controllers.ProductRecordController{}, "Post:SearchEmployeeProductRecord")
web.Router("/product-records/workshop-productive/search", &controllers.ProductRecordController{}, "Post:SearchWorkshopProductRecord")
}
... ...