wip
This commit is contained in:
parent
265505d25d
commit
899309853c
@ -1,6 +1,3 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
setTimeout(function () {
|
|
||||||
console.log("refresh");
|
|
||||||
location.reload();
|
|
||||||
}, 10 * 1000);
|
|
||||||
});
|
});
|
||||||
|
33
handlers/co.go
Normal file
33
handlers/co.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.espin.casa/albert/cml04-falcon-printer/storage"
|
||||||
|
"github.com/julienschmidt/httprouter"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListCustomerOrderHandler(storage storage.Storager) httprouter.Handle {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
// get po
|
||||||
|
po := ps.ByName("po")
|
||||||
|
iPo, _ := strconv.Atoi(po)
|
||||||
|
// get production orders
|
||||||
|
cos, err := storage.ListCostumerOrders(r.Context(), iPo)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// create view
|
||||||
|
view := &PageView{
|
||||||
|
CustomerOrders: cos,
|
||||||
|
}
|
||||||
|
t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
|
||||||
|
if err := t.Execute(w, view); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,16 +5,28 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.espin.casa/albert/cml04-falcon-printer/storage"
|
"git.espin.casa/albert/cml04-falcon-printer/storage"
|
||||||
|
"git.espin.casa/albert/cml04-falcon-printer/types"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PageView struct {
|
type PageView struct {
|
||||||
|
ProductionOrders []*types.ProductionOrder
|
||||||
|
CustomerOrders []*types.CustomerOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
func IndexHandler(storage storage.Storager) httprouter.Handle {
|
func IndexHandler(storage storage.Storager) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
// get production orders
|
||||||
|
pos, err := storage.ListProductionOrders(r.Context(), 40)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
// create view
|
// create view
|
||||||
view := &PageView{}
|
view := &PageView{
|
||||||
|
ProductionOrders: pos,
|
||||||
|
CustomerOrders: nil,
|
||||||
|
}
|
||||||
t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
|
t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
|
||||||
if err := t.Execute(w, view); err != nil {
|
if err := t.Execute(w, view); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -8,4 +8,5 @@ import (
|
|||||||
|
|
||||||
func CreateRoutes(r *httprouter.Router, storage storage.Storager) {
|
func CreateRoutes(r *httprouter.Router, storage storage.Storager) {
|
||||||
r.GET("/", handlers.IndexHandler(storage))
|
r.GET("/", handlers.IndexHandler(storage))
|
||||||
|
r.GET("/cos/:po", handlers.ListCustomerOrderHandler(storage))
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,43 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"git.espin.casa/albert/cml04-falcon-printer/types"
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Storager interface{}
|
type Storager interface {
|
||||||
|
ListProductionOrders(ctx context.Context, limit int) ([]*types.ProductionOrder, error)
|
||||||
|
ListCostumerOrders(ctx context.Context, po int) ([]*types.CustomerOrder, error)
|
||||||
|
}
|
||||||
|
|
||||||
type storage struct {
|
type storage struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
mux sync.RWMutex
|
mux sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListCostumerOrders implements Storager.
|
||||||
|
func (s *storage) ListCostumerOrders(ctx context.Context, po int) ([]*types.CustomerOrder, error) {
|
||||||
|
cos := []*types.CustomerOrder{}
|
||||||
|
if err := s.db.WithContext(ctx).Order("c_order_no desc").Where("p_order_no = ?,po").Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cos, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListProductionOrders implements Storager.
|
||||||
|
func (s *storage) ListProductionOrders(ctx context.Context, limit int) ([]*types.ProductionOrder, error) {
|
||||||
|
pos := []*types.ProductionOrder{}
|
||||||
|
if err := s.db.WithContext(ctx).Order("created_at,p_order_no desc").Limit(limit).Find(&pos).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return pos, nil
|
||||||
|
}
|
||||||
|
|
||||||
type DBConfig struct {
|
type DBConfig struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
<label class="label">Orden Fabricación
|
<label class="label">Orden Fabricación
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
<select id="po" name="po">
|
<select id="po" name="po">
|
||||||
<option>Select dropdown</option>
|
{{ range .ProductionOrders}}
|
||||||
<option>With options</option>
|
<option value="{{ .POrderNo }}">{{ .POrderNo }}</option>
|
||||||
|
{{ end }}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
@ -23,10 +24,13 @@
|
|||||||
<div class="panel-block">
|
<div class="panel-block">
|
||||||
<label class="label">Orden Cliente
|
<label class="label">Orden Cliente
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
|
{{ if .CustomerOrders}}
|
||||||
|
{{ range .CustomerOrders}}
|
||||||
<select id="co" name="co">
|
<select id="co" name="co">
|
||||||
<option>Select dropdown</option>
|
<option value="{{ .COrderNo }}">{{ .COrderNo }}</option>
|
||||||
<option>With options</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
87
types/co.go
Normal file
87
types/co.go
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CustomerOrder struct {
|
||||||
|
Inst string `json:"INST"`
|
||||||
|
DateTime string `json:"DATE_TIME"`
|
||||||
|
COrderNo int `json:"C_ORDER_NO" gorm:"primarykey;autoIncrement:false"`
|
||||||
|
POrderNo int `json:"P_ORDER_NO" gorm:"index"`
|
||||||
|
SchedulNo int `json:"SCHEDUL_NO"`
|
||||||
|
OrdWeight string `json:"ORD_WEIGHT"`
|
||||||
|
OrdLen string `json:"ORD_LEN"`
|
||||||
|
OrLenTU string `json:"OR_LEN_T_U"`
|
||||||
|
OrLenTL string `json:"OR_LEN_T_L"`
|
||||||
|
PackType int `json:"PACK_TYPE"`
|
||||||
|
SectLayer int `json:"SECT_LAYER"`
|
||||||
|
LayerPack int `json:"LAYER_PACK"`
|
||||||
|
SecLastL int `json:"SEC_LAST_L"`
|
||||||
|
TotalSect int `json:"TOTAL_SECT"`
|
||||||
|
PackWidth int `json:"PACK_WIDTH"`
|
||||||
|
PackHigh int `json:"PACK_HIGH"`
|
||||||
|
OutpTolU int `json:"OUTP_TOL_U"`
|
||||||
|
OutpTolD int `json:"OUTP_TOL_D"`
|
||||||
|
LogoCode int `json:"LOGO_CODE"`
|
||||||
|
SecondLab string `json:"SECOND_LAB"`
|
||||||
|
PaintText string `json:"PAINT_TEXT"`
|
||||||
|
AddLabel1 string `json:"ADD_LABEL1"`
|
||||||
|
AddLabel2 string `json:"ADD_LABEL2"`
|
||||||
|
AddLabel3 string `json:"ADD_LABEL3"`
|
||||||
|
MaterCode string `json:"MATER_CODE"`
|
||||||
|
ProduDate int `json:"PRODU_DATE"`
|
||||||
|
LangLabel string `json:"LANG_LABEL"`
|
||||||
|
Warehouse string `json:"WAREHOUSE"`
|
||||||
|
Location string `json:"LOCATION"`
|
||||||
|
Marking string `json:"MARKING"`
|
||||||
|
DisForwar string `json:"DIS_FORWAR"`
|
||||||
|
NumTies int `json:"NUM_TIES"`
|
||||||
|
DisTies string `json:"DIS_TIES"`
|
||||||
|
DisMachin string `json:"DIS_MACHIN"`
|
||||||
|
Vbeln string `json:"VBELN"`
|
||||||
|
Posnr string `json:"POSNR"`
|
||||||
|
CoType string `json:"CO_TYPE"`
|
||||||
|
LoadBed int `json:"LOAD_BED"`
|
||||||
|
SecNum int `json:"SEC_NUM"`
|
||||||
|
Numpal int `json:"NUMPAL"`
|
||||||
|
Numbul string `json:"NUMBUL"`
|
||||||
|
Marfab int `json:"MARFAB"`
|
||||||
|
Sortb string `json:"SORTB"`
|
||||||
|
Strol1 int `json:"STROL1"`
|
||||||
|
Strol2 string `json:"STROL2"`
|
||||||
|
Strol3 int `json:"STROL3"`
|
||||||
|
Strol4 int `json:"STROL4"`
|
||||||
|
Strol5 int `json:"STROL5"`
|
||||||
|
Strol6 int `json:"STROL6"`
|
||||||
|
Strol7 int `json:"STROL7"`
|
||||||
|
Strol8 int `json:"STROL8"`
|
||||||
|
Strol9 int `json:"STROL9"`
|
||||||
|
Strol10 int `json:"STROL10"`
|
||||||
|
Strol11 int `json:"STROL11"`
|
||||||
|
Strol12 int `json:"STROL12"`
|
||||||
|
Strol13 int `json:"STROL13"`
|
||||||
|
Strol14 int `json:"STROL14"`
|
||||||
|
Strol15 int `json:"STROL15"`
|
||||||
|
Strol16 string `json:"STROL16"`
|
||||||
|
Strol17 string `json:"STROL17"`
|
||||||
|
Strol18 string `json:"STROL18"`
|
||||||
|
Strol19 string `json:"STROL19"`
|
||||||
|
Strol20 string `json:"STROL20"`
|
||||||
|
Strol21 string `json:"STROL21"`
|
||||||
|
Strol22 string `json:"STROL22"`
|
||||||
|
Strol23 string `json:"STROL23"`
|
||||||
|
Strol24 string `json:"STROL24"`
|
||||||
|
Strol25 string `json:"STROL25"`
|
||||||
|
Strol26 string `json:"STROL26"`
|
||||||
|
Strol27 string `json:"STROL27"`
|
||||||
|
CreatedAt time.Time `gorm:"->;<-:create" json:"createdat,omitempty"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (CustomerOrder) TableName() string {
|
||||||
|
return "sap_co"
|
||||||
|
}
|
78
types/po.go
Normal file
78
types/po.go
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProductionOrder struct {
|
||||||
|
Inst string `json:"INST"`
|
||||||
|
DateTime string `json:"DATE_TIME"`
|
||||||
|
POrderNo int `json:"P_ORDER_NO" gorm:"primarykey;autoIncrement:false"`
|
||||||
|
SchedulNo int `json:"SCHEDUL_NO"`
|
||||||
|
SeqNumber int `json:"SEQ_NUMBER"`
|
||||||
|
PptimeWfc string `json:"PPTIME_WFC"`
|
||||||
|
PptimeMsc string `json:"PPTIME_MSC"`
|
||||||
|
SteelGrad string `json:"STEEL_GRAD"`
|
||||||
|
ITemp string `json:"I_TEMP"`
|
||||||
|
IHeight string `json:"I_HEIGHT"`
|
||||||
|
IWidth string `json:"I_WIDTH"`
|
||||||
|
ISection string `json:"I_SECTION"`
|
||||||
|
HeatingSt int `json:"HEATING_ST"`
|
||||||
|
FTarTemp string `json:"F_TAR_TEMP"`
|
||||||
|
FSection string `json:"F_SECTION"`
|
||||||
|
FSectType string `json:"F_SECT_TYPE"`
|
||||||
|
TotWeight string `json:"TOT_WEIGHT"`
|
||||||
|
TBeamBla int `json:"T_BEAM_BLA"`
|
||||||
|
TCustOrd int `json:"T_CUST_ORD"`
|
||||||
|
TestLen int `json:"TEST_LEN"`
|
||||||
|
PostFlag string `json:"POST_FLAG"`
|
||||||
|
ModuloX string `json:"MODULO_X"`
|
||||||
|
OvWTolU string `json:"OV_W_TOL_U"`
|
||||||
|
OvWTolL string `json:"OV_W_TOL_L"`
|
||||||
|
OvHTolU string `json:"OV_H_TOL_U"`
|
||||||
|
OvHTolL string `json:"OV_H_TOL_L"`
|
||||||
|
WeTTolU string `json:"WE_T_TOL_U"`
|
||||||
|
WeTTolL string `json:"WE_T_TOL_L"`
|
||||||
|
WeHTolU string `json:"WE_H_TOL_U"`
|
||||||
|
WeHTolL string `json:"WE_H_TOL_L"`
|
||||||
|
FlWDsU string `json:"FL_W_DS_U"`
|
||||||
|
FlWDsL string `json:"FL_W_DS_L"`
|
||||||
|
FlWOsU string `json:"FL_W_OS_U"`
|
||||||
|
FlWOsL string `json:"FL_W_OS_L"`
|
||||||
|
WeMetTU string `json:"WE_MET_T_U"`
|
||||||
|
WeMetTL string `json:"WE_MET_T_L"`
|
||||||
|
WeCenTol string `json:"WE_CEN_TOL"`
|
||||||
|
WeSquTol string `json:"WE_SQU_TOL"`
|
||||||
|
FlParTol string `json:"FL_PAR_TOL"`
|
||||||
|
BdRollID string `json:"BD_ROLL_ID"`
|
||||||
|
UrRollID string `json:"UR_ROLL_ID"`
|
||||||
|
EdRollID string `json:"ED_ROLL_ID"`
|
||||||
|
UfRollID string `json:"UF_ROLL_ID"`
|
||||||
|
SmRollID string `json:"SM_ROLL_ID"`
|
||||||
|
Grupo6 string `json:"GRUPO6"`
|
||||||
|
StName string `json:"ST_NAME"`
|
||||||
|
StWeighM string `json:"ST_WEIGH_M"`
|
||||||
|
StLen1 string `json:"ST_LEN_1"`
|
||||||
|
StLen2 string `json:"ST_LEN_2"`
|
||||||
|
StLen3 string `json:"ST_LEN_3"`
|
||||||
|
StLen4 string `json:"ST_LEN_4"`
|
||||||
|
StLen5 string `json:"ST_LEN_5"`
|
||||||
|
StLen6 string `json:"ST_LEN_6"`
|
||||||
|
StLen7 string `json:"ST_LEN_7"`
|
||||||
|
StLen8 string `json:"ST_LEN_8"`
|
||||||
|
StLen9 string `json:"ST_LEN_9"`
|
||||||
|
StLen10 string `json:"ST_LEN_10"`
|
||||||
|
StLen11 string `json:"ST_LEN_11"`
|
||||||
|
StLen12 string `json:"ST_LEN_12"`
|
||||||
|
Marfab int `json:"MARFAB"`
|
||||||
|
Sortb string `json:"SORTB"`
|
||||||
|
CreatedAt time.Time `gorm:"->;<-:create" json:"createdat,omitempty"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ProductionOrder) TableName() string {
|
||||||
|
return "sap_po"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user