diff --git a/dao/base/TabColName.dao.go b/dao/base/TabColName.dao.go index 133c958..90070af 100644 --- a/dao/base/TabColName.dao.go +++ b/dao/base/TabColName.dao.go @@ -221,6 +221,7 @@ type TabColNameDAO interface { * ******************************************************************************/ UpdateWhere([]grmi.Predicate, *model.TabColName, ...string) error + OriginSelect(predicates []grmi.Predicate, orderByFields []grmi.Field) ([]model.TabColName, error) } /****************************************************************************** diff --git a/dao/base/implments/TabColName.dao.impl.go b/dao/base/implments/TabColName.dao.impl.go index ad3ab9a..7aaad97 100644 --- a/dao/base/implments/TabColName.dao.impl.go +++ b/dao/base/implments/TabColName.dao.impl.go @@ -307,3 +307,39 @@ func (impl *TabColNameDAOImplement) UpdateWhere(predicates []grmi.Predicate, ent } return nil } + +/****************************************************************************** + * + * @Reference LAPP_ACURA_MOM_BACKEND/dao/base/TabColNameDAO.OriginSelect + * + ******************************************************************************/ +func (impl *TabColNameDAOImplement) OriginSelect(predicates []grmi.Predicate, orderByFields []grmi.Field) ([]model.TabColName, error) { + + parameters := []interface{}{} + where := "1 = 1 " + + session := impl.session.Table(impl.meta.TableName) + if predicates != nil { + for _, predicate := range predicates { + where += predicate.Build() + parameters = append(parameters, predicate.Values...) + } + session = session.Where(where, parameters...) + } else { + session = session.Where(where, parameters...) + } + + if orderByFields != nil { + for _, field := range orderByFields { + session = session.OrderBy(field.ColumnName) + } + } + + data := make([]model.TabColName, 0, 10) + err := session.Find(&data) + if err != nil { + return nil, grmi.NewDataBaseError(err) + } + + return data, nil +} \ No newline at end of file diff --git a/dao/jit/PackOrderItemLst.dao.go b/dao/jit/PackOrderItemLst.dao.go index 203a580..4522415 100644 --- a/dao/jit/PackOrderItemLst.dao.go +++ b/dao/jit/PackOrderItemLst.dao.go @@ -317,6 +317,8 @@ type PackOrderItemLstDAO interface { * ******************************************************************************/ SelectListByOrders(serialOrderIds []string) ([]model.PackOrderItemLst, error) + // SelectNGPackOrderItem 查询指定产线上指定日期上的NG打包单 + SelectNGPackOrderItem(workLineId, day string) ([]model.PackOrderItemLst, error) } /****************************************************************************** diff --git a/dao/jit/implments/PackOrderItemLst.dao.impl.go b/dao/jit/implments/PackOrderItemLst.dao.impl.go index 76ae54d..aa98ea6 100644 --- a/dao/jit/implments/PackOrderItemLst.dao.impl.go +++ b/dao/jit/implments/PackOrderItemLst.dao.impl.go @@ -426,3 +426,21 @@ func (impl *PackOrderItemLstDAOImplement) SelectListByOrders(serialOrderIds []st return data, nil } + +// SelectNGPackOrderItem 查询指定产线上指定日期上的NG打包单 +func (impl *PackOrderItemLstDAOImplement) SelectNGPackOrderItem(workLineId, day string) ([]model.PackOrderItemLst, error) { + sql := `SELECT * FROM JIT_PackOrderItemLst +LEFT JOIN JIT_PackOrder ON JIT_PackOrderItemLst.PlantNr = JIT_PackOrder.PlantNr +AND JIT_PackOrderItemLst.PackOrderId = JIT_PackOrder.PackOrderId +LEFT JOIN OM_SerialOrder ON OM_SerialOrder.PlantNr = JIT_PackOrderItemLst.PlantNr +AND OM_SerialOrder.SerialOrderId = JIT_PackOrderItemLst.SerialOrderId +LEFT JOIN PLN_CustOrder ON OM_SerialOrder.PlantNr = PLN_CustOrder.PlantNr +AND OM_SerialOrder.CustOrderId = PLN_CustOrder.CustOrderId +WHERE + JIT_PackOrder.CtrlStr1 = ? +AND PLN_CustOrder.WorkLineId = ? AND +JIT_PackOrder.CloseTime >= ? ;` + data := make([]model.PackOrderItemLst, 0) + err := impl.session.Table(impl.meta.TableName).SQL(sql, model.PACK_QUALITY_NG, workLineId, day).Find(&data) + return data, err +} diff --git a/dao/pln/implments/ToyotaCalloff.dao.impl.go b/dao/pln/implments/ToyotaCalloff.dao.impl.go index e8b1138..d3c3588 100644 --- a/dao/pln/implments/ToyotaCalloff.dao.impl.go +++ b/dao/pln/implments/ToyotaCalloff.dao.impl.go @@ -306,7 +306,7 @@ func (impl *ToyotaCalloffDAOImplement) SelectAndPaging(paging *grmi.Paging, pred // } // } //} - orderBy := " order by " + meta.ToyotaCalloff_OrderTime.SortColumnName + " desc , " + meta.ToyotaCalloff_CheckSequence.SortColumnName + " asc " + orderBy := " order by " + meta.ToyotaCalloff_RecordId.SortColumnName + " desc " parameters = append(parameters, paging.Offset(), paging.Size) data := make([]model.ToyotaCalloff, 0, 10) where = " where " + where diff --git a/db/db.go b/db/db.go index 40d1665..d043000 100644 --- a/db/db.go +++ b/db/db.go @@ -47,6 +47,7 @@ func InitDb() error { fmt.Printf("err1 is %v", err) return err } + master.SetMaxOpenConns(20000) if err = master.Ping(); err != nil { return err } diff --git a/models/pln/ToyotaCalloff.model.go b/models/pln/ToyotaCalloff.model.go index 2c3c2f1..3d2f0ca 100644 --- a/models/pln/ToyotaCalloff.model.go +++ b/models/pln/ToyotaCalloff.model.go @@ -45,6 +45,19 @@ type ToyotaCalloff struct { CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"PLN_ToyotaCalloff-CreateTime"` } +// ToyotaCalloffExcel 导出到excel的结构体 +type ToyotaCalloffExcel struct { + PlantNr int `xorm:"pk int 'PlantNr'" json:"PLN_ToyotaCalloff-PlantNr"` + DemandId string `xorm:"pk nvarchar(40) 'DemandId'" json:"PLN_ToyotaCalloff-DemandId"` + SupplierCode string `xorm:"nvarchar(40) 'SupplierCode' not null" json:"PLN_ToyotaCalloff-SupplierCode"` + ProjectId string `xorm:"nvarchar(40) 'ProjectId' not null" json:"PLN_ToyotaCalloff-ProjectId"` + ProductFamilyId string `xorm:"nvarchar(40) 'ProductFamilyId' not null" json:"PLN_ToyotaCalloff-ProductFamilyId"` + TotalQty int `xorm:"int 'TotalQty' not null" json:"PLN_ToyotaCalloff-TotalQty"` + CheckSequence int `xorm:"int 'CheckSequence' not null" json:"PLN_ToyotaCalloff-CheckSequence"` + Parsed string `xorm:"int 'Parsed' not null" json:"PLN_ToyotaCalloff-Parsed"` + OrderTime string `xorm:"datetime 'OrderTime' not null" json:"PLN_ToyotaCalloff-OrderTime"` + OrderShift int `xorm:"int 'OrderShift' not null" json:"PLN_ToyotaCalloff-OrderShift"` +} /****************************************************************************** * * @Function Name : GetKey diff --git a/services/pln/implments/CustOrder.Dashborad.impl.go b/services/pln/implments/CustOrder.Dashborad.impl.go index b52b709..0226a0e 100644 --- a/services/pln/implments/CustOrder.Dashborad.impl.go +++ b/services/pln/implments/CustOrder.Dashborad.impl.go @@ -11,7 +11,6 @@ import ( "LAPP_ACURA_MOM_BACKEND/global" "LAPP_ACURA_MOM_BACKEND/grmi" baseMeta "LAPP_ACURA_MOM_BACKEND/meta/base" - jitMeta "LAPP_ACURA_MOM_BACKEND/meta/jit" meta "LAPP_ACURA_MOM_BACKEND/meta/pln" qmMeta "LAPP_ACURA_MOM_BACKEND/meta/qm" baseModel "LAPP_ACURA_MOM_BACKEND/models/base" @@ -55,11 +54,11 @@ func (impl *CustOrderServiceImplement) Dashboard(user *global.User, workLineId s if err != nil { return nil, err } - var personNum int //当班人数 - var timeBeat float64 //节拍 - var days int //展示天数 - var ippmTarge int //IPPM - var jPHPercent float64 //IPPM + var personNum int //当班人数 + var timeBeat float64 //节拍 + var days int //展示天数 + var ippmTarge int //IPPM + var jPHPercent float64 //IPPM for _, v := range dashlist { if v.ParamName == "TimeBeat" { timeBeat = utils.ValueToFloat(v.CharParam1, 0.0) @@ -343,7 +342,7 @@ func (impl *CustOrderServiceImplement) Dashboard(user *global.User, workLineId s wg.Done() // 操作完成,减少一个计数 }(&wg) go func(wg *sync.WaitGroup) { - DashboardData.DefectPackOrder, err6 = impl.SelectDefectPackOrder(user) + DashboardData.DefectPackOrder, err6 = impl.SelectDefectPackOrder(user, workLineId) wg.Done() // 操作完成,减少一个计数 }(&wg) @@ -675,7 +674,7 @@ func (impl *CustOrderServiceImplement) SelectDefectNumber(user *global.User, day productFamilyMap := make(map[string]int) now := time.Now() custOrderMap := make(map[string]*model.CustOrder) - for i := days-1; i >= 0; i-- { + for i := days - 1; i >= 0; i-- { var defectItem model.DefectItem day := now.AddDate(0, 0, -1*i).Format(grmi.DateOutFormat) start := day + " " + "00:00:00" @@ -1236,7 +1235,7 @@ func (impl *CustOrderServiceImplement) GetUsefulTime(start, end time.Time, timeL } //图例3 -func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHours []string, dayModel *baseModel.DayModel,jPHPercent float64, startDayTime time.Time, endDayTime time.Time, timeBeat float64, attendancePersonNum int, workLineId string) (model.PerDashboardData, error) { +func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHours []string, dayModel *baseModel.DayModel, jPHPercent float64, startDayTime time.Time, endDayTime time.Time, timeBeat float64, attendancePersonNum int, workLineId string) (model.PerDashboardData, error) { engine := db.Eloquent.Master() session := engine.NewSession() defer session.Close() @@ -1465,19 +1464,84 @@ func (impl *CustOrderServiceImplement) SelectAndonInfo(user *global.User) (int, } // SelectDefectPackOrder 查询打包不良数 -func (impl *CustOrderServiceImplement) SelectDefectPackOrder(user *global.User) (int, error) { +func (impl *CustOrderServiceImplement) SelectDefectPackOrder(user *global.User, workLineId string) (int, error) { engine := db.Eloquent.Master() session := engine.NewSession() defer session.Close() - packOrderDao := jitDal.NewPackOrderDAO(session, user.PlantNr, user.UserId) + //var num int + //packOrderDao := jitDal.NewPackOrderDAO(session, user.PlantNr, user.UserId) + //packOrderStatusDao := jitDal.NewPackOrderStatusDAO(session, user.PlantNr, user.UserId) + //custOrderDao := dal.NewCustOrderDAO(session, user.PlantNr, user.UserId) today := time.Now().Format(grmi.DateOutFormat) + " 00:00:00" - packOrderLi, err := packOrderDao.Select([]grmi.Predicate{ - jitMeta.PackOrder_CloseTime.NewPredicate(grmi.GreaterOrEqual, today), - jitMeta.PackOrder_CtrlStr1.NewPredicate(grmi.Equal, jitModel.PACK_QUALITY_NG), - }, nil) + //packOrderLi, err := packOrderDao.Select([]grmi.Predicate{ + // jitMeta.PackOrder_CloseTime.NewPredicate(grmi.GreaterOrEqual, today), + // jitMeta.PackOrder_CtrlStr1.NewPredicate(grmi.Equal, jitModel.PACK_QUALITY_NG), + //}, nil) + //if err != nil { + // return 0, grmi.NewBusinessError("查询打包数据失败, 错误:" + err.Error()) + //} + //packOrderIdLi := make([]interface{}, 0) + //for _, packOrder := range packOrderLi { + // packOrderIdLi = append(packOrderIdLi, packOrder.PackOrderId) + //} + //statusLi, err := packOrderStatusDao.Select([]grmi.Predicate{ + // jitMeta.PackOrderStatus_PackOrderId.NewPredicate(grmi.Include, packOrderIdLi...), + // jitMeta.PackOrderStatus_Status.NewPredicate(grmi.Equal, jitModel.PACK_STATUS_CLOSED), + //}, nil) + //if err != nil { + // return 0, grmi.NewBusinessError("查询打包数据失败, 错误:" + err.Error()) + //} + //packOrderIdLi = make([]interface{}, 0) + //for _, status := range statusLi { + // packOrderIdLi = append(packOrderIdLi, status.PackOrderId) + //} + packOrderItemDao := jitDal.NewPackOrderItemLstDAO(session, user.PlantNr, user.UserId) + //itemLi, err := packOrderItemDao.Select([]grmi.Predicate{ + // jitMeta.PackOrderItemLst_PackOrderId.NewPredicate(grmi.Include, packOrderIdLi...), + // jitMeta.PackOrderItemLst_Status.NewPredicate(grmi.Equal, jitModel.PACK_STATUS_CLOSED), + //}, []grmi.Field{jitMeta.PackOrderItemLst_PackOrderId}) + //packOrderSerialOrderMap := make(map[string][]interface{}) + //for _, item := range itemLi { + // if item.SerialOrderId != "" { + // continue + // } + // packOrderSerialOrderMap[item.PackOrderId] = append(packOrderSerialOrderMap[item.PackOrderId], item.SerialOrderId) + //} + //serialOrderDao := omDal.NewSerialOrderDAO(session, user.PlantNr, user.UserId) + //for _, serialOrderIdLi := range packOrderSerialOrderMap { + // serialOrderLi, err := serialOrderDao.Select([]grmi.Predicate{ + // omMeta.SerialOrder_SerialOrderId.NewPredicate(grmi.Include, serialOrderIdLi...), + // omMeta.SerialOrder_OrderType.NewPredicate(grmi.Equal, baseModel.ORDER_TYPE_SEQ), + // }, nil) + // if err != nil { + // return 0, grmi.NewBusinessError("查询工单失败,错误:" + err.Error()) + // } + // custOrderIdMap := make(map[string]interface{}) + // for _, serialOrder := range serialOrderLi { + // custOrderIdMap[serialOrder.CustOrderId] = nil + // } + // custOrderIdLi := make([]interface{}, 0, len(custOrderIdMap)) + // for custOrderId := range custOrderIdMap { + // custOrderIdLi = append(custOrderIdLi, custOrderId) + // } + // custOrderLi, err := custOrderDao.Select([]grmi.Predicate{ + // meta.CustOrder_CustOrderId.NewPredicate(grmi.Include, custOrderIdLi...), + // meta.CustOrder_WorkLineId.NewPredicate(grmi.Equal, workLineId), + // }, nil) + // if err != nil { + // return 0, grmi.NewBusinessError("查询订单失败,错误:" + err.Error()) + // } + // if len(custOrderLi) != 0 { + // num++ + // } + //} + itemLi, err := packOrderItemDao.SelectNGPackOrderItem(workLineId, today) if err != nil { return 0, grmi.NewBusinessError("查询打包数据失败, 错误:" + err.Error()) } - return len(packOrderLi), nil + packOrderMap := make(map[string]interface{}) + for _, item := range itemLi { + packOrderMap[item.PackOrderId] = nil + } + return len(packOrderMap), nil } - diff --git a/web/controllers/pln/ToyotaCalloff.rest.go b/web/controllers/pln/ToyotaCalloff.rest.go index 6727b12..d8ecc67 100644 --- a/web/controllers/pln/ToyotaCalloff.rest.go +++ b/web/controllers/pln/ToyotaCalloff.rest.go @@ -441,4 +441,22 @@ func RegisterAnalysisAgainToyotaCalloff(party router.Party, path string, method } supports.Ok(ctx, supports.OptionSuccess, nil) }) -} \ No newline at end of file +} + +func RegisterExportToyotaCalloff(party router.Party, path string, method func(*global.User, map[string]string) (string, error)) { + + party.Get(path, func(ctx iris.Context) { + user, ok := jwts.ParseToken(ctx) + if !ok { + supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil) + return + } + + result, err := method(user, ctx.URLParams()) + if err != nil { + supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) + return + } + supports.Ok(ctx, supports.OptionSuccess, result) + }) +} diff --git a/web/controllers/pln/pln.go b/web/controllers/pln/pln.go index 81973bd..a15fb53 100644 --- a/web/controllers/pln/pln.go +++ b/web/controllers/pln/pln.go @@ -340,6 +340,8 @@ func RegisterRoutes() { // RegisterUpdateToyotaCalloff(toyotacalloff, "/update", serviceOfToyotaCalloff.Update) // ToyotaCalloff 重新解析 RegisterAnalysisAgainToyotaCalloff(toyotacalloff, "/analysisagain", serviceOfToyotaCalloff.AnalysisAgain) + // ToyotaCalloff 导出页面数据 + RegisterExportToyotaCalloff(toyotacalloff, "/export", serviceOfToyotaCalloff.ExportPageData) // ToyotaCallOffErrorLst的路由组 toyotacallofferrorlst := party.Party("/toyotacallofferrorlst")