This commit is contained in:
aespin 2024-10-08 13:22:23 +02:00
parent 529751ae38
commit fbc6a18b0e
6 changed files with 47 additions and 14 deletions

View File

@ -13,12 +13,12 @@ func Dates(dr string) (start, finish time.Time, err error) {
inicio = strings.TrimSpace(inicio) inicio = strings.TrimSpace(inicio)
final = strings.TrimSpace(final) final = strings.TrimSpace(final)
// parse start date // parse start date
start, err = time.Parse("02/01/2006 15:04", inicio) start, err = time.ParseInLocation("02/01/2006 15:04", inicio, time.Local)
if err != nil { if err != nil {
return time.Time{}, time.Time{}, err return time.Time{}, time.Time{}, err
} }
// parse finish date // parse finish date
finish, err = time.Parse("02/01/2006 15:04", final) finish, err = time.ParseInLocation("02/01/2006 15:04", final, time.Local)
if err != nil { if err != nil {
return time.Time{}, time.Time{}, err return time.Time{}, time.Time{}, err
} }

View File

@ -23,7 +23,7 @@ type Storager interface {
Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error) Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error)
ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (barcodes []types.Barcode, err error) ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (barcodes []types.Barcode, err error)
Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error) Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error)
ListBundle(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (bundles []types.BundleData, err error) ListBundle(ctx context.Context, lb types.LoadingBed, inicio, final time.Time, confirmed bool) (bundles []types.BundleData, err error)
} }
type storage struct { type storage struct {
@ -32,13 +32,13 @@ type storage struct {
} }
// ListBundle implements Storager. // ListBundle implements Storager.
func (s *storage) ListBundle(ctx context.Context, lb types.LoadingBed, inicio time.Time, final time.Time) (bundles []types.BundleData, err error) { func (s *storage) ListBundle(ctx context.Context, lb types.LoadingBed, inicio time.Time, final time.Time, confirmed bool) (bundles []types.BundleData, err error) {
if lb == types.ALL { if lb == types.ALL {
if err := s.db.Where("created_at >= ? and created_at < ?", inicio, final).Find(&bundles).WithContext(ctx).Error; err != nil { if err := s.db.Where("created_at >= ? and created_at < ? and confirmed = ?", inicio, final, confirmed).Find(&bundles).WithContext(ctx).Error; err != nil {
return nil, err return nil, err
} }
} else { } else {
if err := s.db.Where("loading_bed = ? and created_at >= ? and created_at < ?", lb, inicio, final).Find(&bundles).WithContext(ctx).Error; err != nil { if err := s.db.Where("substr(nromatricula,1,3)=? and created_at >= ? and created_at < ? and confirmed = ?", types.MapQueryBed[lb], inicio, final, confirmed).Find(&bundles).WithContext(ctx).Error; err != nil {
return nil, err return nil, err
} }
} }

View File

@ -18,12 +18,13 @@
<body> <body>
<div class="notification is-link banner"> <div class="notification is-link banner">
<p> <p>FALCON
<figure class="image is-64x64"> <figure class="image is-64x64">
<img src="/assets/img/falcon-transparent-white.png" alt="white falcon" /> <img src="/assets/img/falcon-transparent-white.png" alt="white falcon" />
</figure> </figure>
FALCON</p> </p>
</div> </div>
{{ template "body" . }} {{ template "body" . }}
</body> </body>

View File

@ -79,6 +79,19 @@
</div> </div>
</div> </div>
</div> </div>
<div class="panel-block">
<div class="field">
<label class="label">Selección</label>
<div class="control">
<p class="control has-icons-left">
<label class="checkbox">
<input type="checkbox" name="confirmed" id="confirmed"/>
Confirmado
</label>
</p>
</div>
</div>
</div>
<div class="panel-block"> <div class="panel-block">
<div class="buttons"> <div class="buttons">
<button type="submit" class="button is-link is-outlined"> <button type="submit" class="button is-link is-outlined">
@ -104,7 +117,6 @@
<th><abbr title="Unidad de almacén">UA</abbr></th> <th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th> <th>PO</th>
<th>CO</th> <th>CO</th>
<th>Colada</th>
<th>Calidad</th> <th>Calidad</th>
<th>Código SAP</th> <th>Código SAP</th>
<th>Producto</th> <th>Producto</th>
@ -113,6 +125,7 @@
<th><abbr title="Paquete confirmado">Conf.</abbr></th> <th><abbr title="Paquete confirmado">Conf.</abbr></th>
<th><abbr title="Nivel 3">N3</abbr></th> <th><abbr title="Nivel 3">N3</abbr></th>
<th>SAP</th> <th>SAP</th>
<th>Fecha</th>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
@ -120,7 +133,6 @@
<th><abbr title="Unidad de almacén">UA</abbr></th> <th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th> <th>PO</th>
<th>CO</th> <th>CO</th>
<th>Colada</th>
<th>Calidad</th> <th>Calidad</th>
<th>Código SAP</th> <th>Código SAP</th>
<th>Producto</th> <th>Producto</th>
@ -129,6 +141,7 @@
<th><abbr title="Paquete confirmado">Conf.</abbr></th> <th><abbr title="Paquete confirmado">Conf.</abbr></th>
<th><abbr title="Nivel 3">N3</abbr></th> <th><abbr title="Nivel 3">N3</abbr></th>
<th>SAP</th> <th>SAP</th>
<th>Fecha</th>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
@ -137,15 +150,15 @@
<td><a href="">{{ .Nromatricula }}</a></td> <td><a href="">{{ .Nromatricula }}</a></td>
<td><a href="">{{ .Po }}</a></td> <td><a href="">{{ .Po }}</a></td>
<td><a href="">{{ .Co }}</a></td> <td><a href="">{{ .Co }}</a></td>
<td>{{ .Colada }}</td>
<td>{{ .Calidad }}</td> <td>{{ .Calidad }}</td>
<td>{{ .Matnr }}</td> <td>{{ .Matnr }}</td>
<td>{{ .SeccionTipo }}</td> <td>{{ .SeccionTipo }}</td>
<td>{{ .PaquetePeso }}</td> <td>{{ .PaquetePeso }}</td>
<td>{{ .FormatDesvio }}</td> <td>{{ .FormatDesvio }}</td>
<td>{{ .L3Sended }}</td> <td>{{if .L3Sended }} Sí {{ else }} No {{ end }}</td>
<td>{{ .Confirmed }}</td> <td>{{if .Confirmed }} Sí {{ else }} No {{ end }}</td>
<td>{{ .SAP }}</td> <td>{{if .SAP }} Sí {{ else }} No {{ end }}</td>
<td>{{ .FormatCreatedAt }}</td>
</tr> </tr>
{{ end }} {{ end }}
</tbody> </tbody>

View File

@ -28,6 +28,11 @@ var MapFormatBed = map[LoadingBed]string{
ALL: "TODOS", ALL: "TODOS",
} }
var MapQueryBed = map[LoadingBed]string{
ATA12: "940",
ATA345: "945",
}
type Barcode struct { type Barcode struct {
Barcode string `gorm:"primaryKey"` Barcode string `gorm:"primaryKey"`
LoadingBed LoadingBed LoadingBed LoadingBed

View File

@ -73,3 +73,17 @@ func (BundleData) TableName() string {
func (b *BundleData) FormatDesvio() string { func (b *BundleData) FormatDesvio() string {
return fmt.Sprintf("%.3f", b.Desvio) return fmt.Sprintf("%.3f", b.Desvio)
} }
func (b *BundleData) FormatSerie() string {
if b.Serie == 1 {
return "AUTO"
} else if b.Serie == 9 {
return "REPT."
} else {
return "MANUAL"
}
}
func (b *BundleData) FormatCreatedAt() string {
return b.CreatedAt.Format("02/01/2006 15:04:03")
}