|
|
@ -211,54 +211,59 @@ func (t *PmWo) SelectPmWoAll(nowdate string) ([]PmWoDate, error) { |
|
|
|
} |
|
|
|
|
|
|
|
//分页
|
|
|
|
func (t *PmWo) GetPage(pageSize int, pageIndex int, searchtime string, duehourinterval int) ([]PmWoService, int, error) { |
|
|
|
func (t *PmWo) GetPage(pageSize int, pageIndex int, searchtime string, mainttype string) ([]PmWoService, int, error) { |
|
|
|
data := make([]PmWoService, 0) |
|
|
|
|
|
|
|
e := db.Eloquent.Master() |
|
|
|
where := `from pm_wo left join pm_service on pm_wo.finr = pm_service.finr and pm_wo.mainservicenr = pm_service.mainserviceid` |
|
|
|
where += " where pm_wo.finr = ? " |
|
|
|
parameters := []interface{}{t.Finr} |
|
|
|
table := e.Table(t.TableName()).Where("pm_wo.finr = ? ", t.Finr) |
|
|
|
query := e.Table(t.TableName()).Where("pm_wo.finr = ? ", t.Finr) |
|
|
|
query = query.Join("LEFT", "pm_service", "pm_wo.finr = pm_service.finr and pm_wo.mainservicenr = pm_service.mainserviceid").Join("LEFT", "pm_asset", "pm_wo.finr = pm_asset.finr and pm_wo.assetid = pm_asset.assetid") |
|
|
|
table = table.Join("LEFT", "pm_service", "pm_wo.finr = pm_service.finr and pm_wo.mainservicenr = pm_service.mainserviceid").Join("LEFT", "pm_asset", "pm_wo.finr = pm_asset.finr and pm_wo.assetid = pm_asset.assetid") |
|
|
|
query := e.Table(t.TableName()) |
|
|
|
table = table.Join("LEFT", "pm_service", "pm_wo.finr = pm_service.finr and pm_wo.mainservicenr = pm_service.mainserviceid") |
|
|
|
|
|
|
|
|
|
|
|
if !utils.ValueIsEmpty(searchtime) { |
|
|
|
searchtimes := strings.Split(searchtime, "-") |
|
|
|
table = table.And("pm_wo.credatuz >= ?", searchtimes[0]) |
|
|
|
table = table.And("pm_wo.credatuz <= ?", searchtimes[1]) |
|
|
|
query = query.And("pm_wo.credatuz >= ?", searchtimes[0]) |
|
|
|
query = query.And("pm_wo.credatuz <= ?", searchtimes[1]) |
|
|
|
where += " and pm_wo.credatuz >= ? " |
|
|
|
where += " and pm_wo.credatuz <= ? " |
|
|
|
parameters = append(parameters, searchtimes[0], searchtimes[1]) |
|
|
|
} |
|
|
|
if t.Assetid > 0 { |
|
|
|
table = table.And("pm_wo.assetid = ?", t.Assetid) |
|
|
|
query = query.And("pm_wo.assetid = ?", t.Assetid) |
|
|
|
|
|
|
|
where += " and pm_wo.assetid = ? " |
|
|
|
parameters = append(parameters, t.Assetid) |
|
|
|
} |
|
|
|
if t.Status == 80 { |
|
|
|
table = table.And("pm_wo.status = 80") |
|
|
|
query = query.And("pm_wo.status = 80") |
|
|
|
where += " and pm_wo.status = 80 " |
|
|
|
|
|
|
|
} else { |
|
|
|
statusLi := []int{26, 40} |
|
|
|
table = table.In("pm_wo.status", statusLi) |
|
|
|
query = query.In("pm_wo.status", statusLi) |
|
|
|
} |
|
|
|
if duehourinterval != 0 { |
|
|
|
table = table.Where("pm_service.duedateinterval = ?", duehourinterval) |
|
|
|
query = query.Where("pm_service.duedateinterval = ?", duehourinterval) |
|
|
|
where += " and pm_wo.status in (26, 40) " |
|
|
|
} |
|
|
|
if !utils.ValueIsEmpty(t.Descr) { |
|
|
|
descr := "%" + t.Descr + "%" |
|
|
|
table = table.And("pm_asset.descr like ?", descr) |
|
|
|
query = query.And("pm_asset.descr like ?", descr) |
|
|
|
if mainttype != "" { |
|
|
|
table = table.Where("pm_wo.mainttype = ?", mainttype) |
|
|
|
where += " and pm_wo.mainttype = ? " |
|
|
|
parameters = append(parameters, mainttype) |
|
|
|
} |
|
|
|
orderBy := " order by pm_wo.finr " |
|
|
|
offset := (pageIndex - 1) * pageSize |
|
|
|
|
|
|
|
err := query.Limit(pageSize, offset).Find(&data) |
|
|
|
querySql := `select pm_wo.*,pm_service.* ` + where + orderBy +" offset ? row fetch next ? row only" |
|
|
|
parameters = append(parameters, offset, pageSize) |
|
|
|
err := query.SQL(querySql, parameters...).Find(&data) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("err:", err) |
|
|
|
return data, 0, err |
|
|
|
} |
|
|
|
|
|
|
|
pcount := new(PmWoService) |
|
|
|
count, err := table.Count(pcount) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("err2:", err) |
|
|
|
return data, 0, err |
|
|
|
} |
|
|
|
now := time.Now() |
|
|
|