作者 yangfu

feat:

1.生产信息查询、设备运行监控
... ... @@ -34,8 +34,10 @@ type SearchEmployeeAttendanceQuery struct {
SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 姓名
UserName string `cname:"姓名" json:"userName,omitempty"`
// 考勤状态 1.未审核 2:已审核 4.自动审核
AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 4.自动审核" json:"attendanceStatus,omitempty"`
// 考勤状态 1.未审核 2:已审核 3.自动审核
AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 3.自动审核" json:"attendanceStatus,omitempty"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType int `cname:"1:固定 2:派遣 3.临时" json:"employeeType,omitempty"`
// 开始时间
BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
... ...
... ... @@ -26,7 +26,7 @@ type SubmitProductRecordCommand struct {
// 员工Id 用户唯一标识
EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"`
// 物料ID
UnitConversionId int `cname:"物料ID" json:"unitConversionId" valid:"Required"`
UnitConversionId int `cname:"物料ID" json:"unitConversionId"`
// 重量
Weigh float64 `cname:"重量" json:"weigh" valid:"Required"`
}
... ...
... ... @@ -8,6 +8,8 @@ type EmployeeProductRecordDto struct {
// 生产工人
ProductWorker *domain.User `json:"productWorker,omitempty"`
*domain.WorkStation
// 上班班次 1:全天 2:白班 4:中班 8:夜班
WorkOn int `json:"workOn"`
// 生产日期
//ProductDate string `json:"productDate"`
// 计划的产品名称
... ... @@ -29,15 +31,19 @@ type EmployeeProductRecordDto struct {
// 合格率 百分比
QualificationRate int `json:"qualificationRate"`
// 考勤类型 1.正常 2.支援
ParticipateTypeDescription string `json:"participateTypeDescription,omitempty"`
ParticipateTypeDescription string `json:"participateTypeDescription"`
// 员工类型描述 1:固定 2:派遣 3.临时
EmployeeTypeDescription string `json:"employeeTypeDescription,omitempty"`
EmployeeTypeDescription string `json:"employeeTypeDescription"`
// 上班班次 1:全天 2:白班 4:中班 8:夜班
WorkOnDescription string `json:"workOnDescription,omitempty"`
}
func (d *EmployeeProductRecordDto) LoadDto(m *domain.EmployeeProductRecord, orgId int) *EmployeeProductRecordDto {
d.EmployeeProductRecordId = m.EmployeeProductRecordId
d.ProductWorker = m.ProductWorker
d.WorkStation = m.WorkStation
d.WorkOn = m.WorkOn
d.PlanProductName = m.ProductRecordInfo.PlanProductName
d.BatchNumber = m.ProductRecordInfo.BatchNumber
d.ParticipateType = m.ParticipateType
... ... @@ -47,6 +53,7 @@ func (d *EmployeeProductRecordDto) LoadDto(m *domain.EmployeeProductRecord, orgI
d.CreatedAt = m.CreatedAt.Format("2006-01-02")
d.ParticipateTypeDescription = domain.ParticipateTypeDescription(m.ParticipateType)
d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType)
d.WorkOnDescription = domain.WorkOnDescriptions(m.WorkOn)
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
... ...
... ... @@ -127,6 +127,16 @@ func (device *Device) Valid() error {
return nil
}
// 标记为生产设备
func (device *Device) MarkAsProductDevice() bool {
if device.Ext.DeviceExt.IsProductDevice == 1 {
return false
}
device.Ext.DeviceExt.IsProductDevice = 1
device.UpdatedAt = time.Now()
return true
}
// 导入设备数据体
type ImportDeviceItem struct {
// 设备编号
... ... @@ -183,3 +193,13 @@ func (item *ImportDeviceItem) Valid() error {
}
return nil
}
type Devices []*Device
func (devices Devices) ToMap() map[string]*Device {
var resp = make(map[string]*Device)
for _, v := range devices {
resp[v.DeviceCode] = v
}
return resp
}
... ...
... ... @@ -98,6 +98,11 @@ type DeviceRunningRecordInfo struct {
// 批次数据
// 生产计划ID
ProductPlanId int `json:"productPlanId,omitempty"`
// 设备名称
DeviceName string `json:"deviceName"`
// 组织名称
OrgName string `json:"orgName"`
}
func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo {
... ... @@ -155,6 +160,18 @@ func (d *DeviceRunningRecordInfo) ResetOEE(pu, qu float64) float64 {
return d.OEE
}
// 详细的小时设备数据
// 0:00 1
// 0:59 2
// 23:00 1
// 23:59 2
// [{"min":1,"time":"00:01","status":1}]
func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail() {
for i := 0; i < 24; i++ {
}
}
// 单个小时内的设备状态
type HourDeviceStatus struct {
// 时间窗口 1-60 代表时间段范围
... ...
... ... @@ -4,4 +4,6 @@ package domain
type DeviceExt struct {
// 生产单个产品的时间(单位:秒)
UnitProductionSecTime int `json:"unitProductionSecTime"`
// 是否是车间设备,如果这个设备有上报过数据,标记 1 默认0
IsProductDevice int `json:"isProductDevice"`
}
... ...
package domain
import "fmt"
import (
"fmt"
"strings"
)
const MaxQueryRow = 10000
... ... @@ -121,6 +124,11 @@ func WorkOnDescription(workOn int) []string {
return result
}
func WorkOnDescriptions(workOn int) string {
r := WorkOnDescription(workOn)
return strings.Join(r, ",")
}
func EmployeeTypeDescription(employeeType int) string {
if employeeType == 1 {
return "固定"
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"time"
)
type DeviceDailyRunningRecordDao struct {
transactionContext *pgTransaction.TransactionContext
}
func NewDeviceDailyRunningRecordDao(transactionContext *pgTransaction.TransactionContext) (*DeviceDailyRunningRecordDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &DeviceDailyRunningRecordDao{
transactionContext: transactionContext,
}, nil
}
}
// 时段产能
func (dao *DeviceDailyRunningRecordDao) TimeSectionRunningRecord(companyId, orgId, workshopId int, lineId int, sectionName string, beginTime time.Time, result interface{}) error {
tx := dao.transactionContext.PgTx
sql := fmt.Sprintf(`
WITH ts_product as(
select sum(a.weight) total,a.ts from (
select
cast(device_running_record_info->>'count' as DECIMAL) weight,
to_char(product_date at time ZONE 'Asia/shanghai', 'mm:dd') ts
from manufacture.device_daily_running_record
where
company_id = ?
and org_id = ?
and work_station->>'workshopId'='?'
and work_station->>'lineId'='?'
and work_station->>'sectionName'=?
and created_at >?
) a
group by a.ts
order by ts
)
-- select * from ts_product
, ts_product_list as (
select d.ts,ts_product.total from (
select to_char(c.ts::timestamp,'mm:dd') ts from (
select generate_series(now() - interval '6 day',now(),'1 day') ts
) c ) d left join ts_product on d.ts = ts_product.ts
)
SELECT ts, coalesce(total,0) total
from ts_product_list
`)
if _, err := tx.Query(result, sql, companyId, orgId, workshopId, lineId, sectionName, beginTime); err != nil {
return err
}
return nil
}
func (dao *DeviceDailyRunningRecordDao) WorkshopProductionEfficiencyStatistics(companyId, orgId, workshopId int, beginTime time.Time, result interface{}) error {
tx := dao.transactionContext.PgTx
sql := fmt.Sprintf(`
with device_running as(
select
cast(device_running_record_info->>'oee' as DECIMAL) oee,
cast(device_running_record_info->>'tu' as DECIMAL) tu,
cast(device_running_record_info->>'pu' as DECIMAL) pu,
cast(device_running_record_info->>'qu' as DECIMAL) qu
from manufacture.device_daily_running_record
where
company_id = ?
and org_id = ?
and work_station->>'workshopId'='?'
and created_at>=?
)
select round(avg(oee),1) oee,round(avg(tu),1) tu,round(avg(pu),1)pu, round(avg(qu),1) qu from device_running
`)
if _, err := tx.Query(result, sql, companyId, orgId, workshopId, beginTime); err != nil {
return err
}
return nil
}
... ...
... ... @@ -56,7 +56,7 @@ func (dao *ProductRecordDao) RecentUnApprovedProductRecord(fromLastHour int, rec
}
// 时段产能
func (dao *ProductRecordDao) TimeSectionProductRecord(companyId, orgId, workshopId int, lineId int, beginTime time.Time, result interface{}) error {
func (dao *ProductRecordDao) TimeSectionProductRecord(companyId, orgId, workshopId int, lineId int, sectionName string, beginTime time.Time, result interface{}) error {
tx := dao.transactionContext.PgTx
sql := fmt.Sprintf(`
... ... @@ -71,6 +71,7 @@ WITH ts_product as(
and org_id = ?
and work_station->>'workshopId'='?'
and work_station->>'lineId'='?'
and work_station->>'sectionName'=?
and product_record_type = 8
and created_at >?
) a
... ... @@ -92,7 +93,42 @@ WITH ts_product as(
SELECT ts, coalesce(total,0) total
from ts_product_list
`)
if _, err := tx.Query(result, sql, companyId, orgId, workshopId, lineId, beginTime); err != nil {
if _, err := tx.Query(result, sql, companyId, orgId, workshopId, lineId, sectionName, beginTime); err != nil {
return err
}
return nil
}
// 二级品比重
func (dao *ProductRecordDao) ProportionOfSecondLevelRecord(companyId, orgId, workshopId int, beginTime time.Time, result interface{}) error {
tx := dao.transactionContext.PgTx
sql := fmt.Sprintf(`
with item_product as (
select sum(a.weight) item_total,max(sname) sname from (
select cast(product_record_info->>'weigh' as DECIMAL) weight
,work_station->>'sectionName' sname
,work_station->>'workStationId' workStationId
from manufacture.product_records
where company_id = ?
and org_id = ?
and work_station->>'workshopId'='?'
and product_record_type = 8
and product_record_info->>'approveStatus'='2'
and created_at >=?
and work_station->>'sectionName' in ('打料','成型','穿串','包装')
) a
group by a.workStationId
)
--select * from item_product
,item_product_rate as(
select sname,round(item_total/(select sum(item_total) from item_product)*100, 0) as rate from item_product
)
--select * from item_product_rate
select a.sname, coalesce(b.rate,0) rate from (
select unnest(ARRAY ['打料','成型','穿串','包装']) sname
) a left join item_product_rate b on a.sname=b.sname`)
if _, err := tx.Query(result, sql, companyId, orgId, workshopId, beginTime); err != nil {
return err
}
return nil
... ...
... ... @@ -14,6 +14,18 @@ import (
const (
// 时段产能统计
HourProductiveStatistics = "HourProductiveStatistics"
// 产能对比
DailyProductiveStatistics = "DailyProductiveStatistics"
// 二级品比重
ProportionOfSecondLevelStatistics = "ProportionOfSecondLevelStatistics"
// 车间生产效率
WorkshopProductionEfficiencyStatistics = "WorkshopProductionEfficiencyStatistics"
// 设备运行统计
DeviceRunningStatistics = "DeviceRunningStatistics"
)
const (
SectionNameCCJ = "穿串"
)
type PGCommonStatisticsService struct {
... ... @@ -27,6 +39,18 @@ func (ptr *PGCommonStatisticsService) CommonStatistics(actionType string, queryO
case HourProductiveStatistics:
result, err = ptr.HourProductiveStatistics(queryOptions)
break
case DailyProductiveStatistics:
result, err = ptr.DailyProductiveStatistics(queryOptions)
break
case ProportionOfSecondLevelStatistics:
result, err = ptr.ProportionOfSecondLevelStatistics(queryOptions)
break
case WorkshopProductionEfficiencyStatistics:
result, err = ptr.WorkshopProductionEfficiencyStatistics(queryOptions)
break
case DeviceRunningStatistics:
result, err = ptr.DeviceRunningStatistics(queryOptions)
break
}
return result, err
}
... ... @@ -53,7 +77,7 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[
var response = make([]interface{}, 0)
for _, v := range workshop.GetProductLines(domain.NotDeleted) {
var result = make([]*record, 0)
if err := productRecordDao.TimeSectionProductRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, time.Now().Add(-time.Hour*5), &result); err != nil {
if err := productRecordDao.TimeSectionProductRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*5), &result); err != nil {
log.Logger.Error(err.Error())
continue
}
... ... @@ -88,6 +112,195 @@ func NewXYData(xData []string, values interface{}) interface{} {
}
}
// 时段产能-统计 (传串设备)
func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map[string]interface{}) (interface{}, error) {
var request = &HourProductiveStatisticsRequest{}
if err := utils.LoadQueryObject(queryOptions, request); err != nil {
return nil, err
}
workshopRepository, _ := repository.NewWorkshopRepository(ptr.transactionContext)
type record struct {
Ts string `json:"ts"`
Total float64 `json:"total"`
}
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
if err != nil || workshop == nil {
return nil, nil
}
productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext)
var response = make([]interface{}, 0)
for _, v := range workshop.GetProductLines(domain.NotDeleted) {
var result = make([]*record, 0)
if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*24*7), &result); err != nil {
log.Logger.Error(err.Error())
continue
}
var xData []string = make([]string, 0)
var values []interface{} = make([]interface{}, 0)
for _, r := range result {
xData = append(xData, r.Ts)
values = append(values, r.Total)
}
response = append(response, map[string]interface{}{
"lineName": v.LineName,
"data": NewXYData(xData, values),
})
}
return map[string]interface{}{
"recent_7_day": response,
}, nil
}
// 二级品占比
func (ptr *PGCommonStatisticsService) ProportionOfSecondLevelStatistics(queryOptions map[string]interface{}) (interface{}, error) {
var request = &HourProductiveStatisticsRequest{}
if err := utils.LoadQueryObject(queryOptions, request); err != nil {
return nil, err
}
workshopRepository, _ := repository.NewWorkshopRepository(ptr.transactionContext)
type record struct {
Sname string `json:"sname"`
Rate float64 `json:"rate"`
}
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
if err != nil || workshop == nil {
return nil, nil
}
productRecordDao, _ := dao.NewProductRecordDao(ptr.transactionContext)
var input = []struct {
name string
t time.Time
}{
{"today", utils.GetZeroTime(time.Now())},
{"current_week", utils.GetCurrentWeekFirstDay(time.Now())},
{"current_month", utils.GetCurrentMonthFirstDay(time.Now())},
}
var response = make(map[string]interface{})
for _, v := range input {
var result = make([]*record, 0)
if err := productRecordDao.ProportionOfSecondLevelRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.t, &result); err != nil {
log.Logger.Error(err.Error())
return nil, err
}
response[v.name] = result
}
return response, nil
}
// 车间生产效率统计
func (ptr *PGCommonStatisticsService) WorkshopProductionEfficiencyStatistics(queryOptions map[string]interface{}) (interface{}, error) {
var request = &HourProductiveStatisticsRequest{}
if err := utils.LoadQueryObject(queryOptions, request); err != nil {
return nil, err
}
workshopRepository, _ := repository.NewWorkshopRepository(ptr.transactionContext)
type record struct {
Oee float64 `json:"oee"`
Pu float64 `json:"pu"`
Tu float64 `json:"tu"`
Qu float64 `json:"qu"`
}
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
if err != nil || workshop == nil {
return nil, nil
}
productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext)
var input = []struct {
name string
t time.Time
}{
{"today", utils.GetZeroTime(time.Now())},
{"current_week", utils.GetCurrentWeekFirstDay(time.Now())},
{"current_month", utils.GetCurrentMonthFirstDay(time.Now())},
}
var response = make(map[string]interface{})
for _, v := range input {
var result = make([]*record, 0)
if err := productRecordDao.WorkshopProductionEfficiencyStatistics(request.CompanyId, request.OrgId, request.WorkshopId, v.t, &result); err != nil {
log.Logger.Error(err.Error())
return nil, err
}
response[v.name] = result
}
return response, nil
}
// 设备运行统计
func (ptr *PGCommonStatisticsService) DeviceRunningStatistics(queryOptions map[string]interface{}) (interface{}, error) {
var request = &DeviceRunningStatisticRequest{}
if err := utils.LoadQueryObject(queryOptions, request); err != nil {
return nil, err
}
workshopRepository, _ := repository.NewWorkshopRepository(ptr.transactionContext)
deviceRepository, _ := repository.NewDeviceRepository(ptr.transactionContext)
deviceRunningRecordRepository, _ := repository.NewDeviceDailyRunningRecordRepository(ptr.transactionContext)
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
if err != nil || workshop == nil {
return nil, nil
}
_, devices, err := deviceRepository.Find(map[string]interface{}{"companyId": request.CompanyId, "orgId": request.OrgId, "workshopId": request.WorkshopId, "lineId": request.LineId})
if err != nil {
return nil, err
}
var response = make([]interface{}, 0)
_, dailyRecords, err := deviceRunningRecordRepository.Find(map[string]interface{}{"companyId": request.CompanyId, "orgId": request.OrgId, "productDate": request.Date})
for i := 0; i < len(devices); i++ {
d := devices[i]
if d.Ext == nil || d.Ext.DeviceExt == nil || d.Ext.DeviceExt.IsProductDevice == 0 {
continue
}
var r *domain.DeviceDailyRunningRecord
item := make(map[string]interface{})
item["orgName"] = d.Ext.OrgName
if d.WorkStation != nil {
item["workshopName"] = d.WorkStation.WorkshopName
item["lineName"] = d.WorkStation.LineName
item["deviceName"] = d.DeviceName
item["oee"] = 0
item["status"] = []struct{}{}
}
for j := 0; j < len(dailyRecords); j++ {
if d.DeviceCode == dailyRecords[j].DeviceCode {
r = dailyRecords[j]
item["oee"] = r.DeviceRunningRecordInfo.OEE
break
}
}
if r != nil {
item["status"] = r.DeviceRunningRecordInfo.TimeLineDeviceStatus
}
response = append(response, item)
}
return map[string]interface{}{
"devices": response,
}, nil
}
type DeviceRunningStatisticRequest struct {
CompanyId int `json:"companyId" valid:"Required"`
OrgId int `json:"orgId" valid:"Required"`
WorkshopId int `json:"workshopId" valid:"Required"`
LineId int `json:"lineId""`
Date string `json:"date"`
}
func NewPGCommonStatisticsService(transactionContext *pgTransaction.TransactionContext) (*PGCommonStatisticsService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -36,7 +36,7 @@ type SubmitOptions struct {
// 员工Id 用户唯一标识
EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"`
// 物料ID
UnitConversionId int `cname:"物料ID" json:"unitConversionId" valid:"Required"`
UnitConversionId int `cname:"物料ID" json:"unitConversionId"`
// 重量
Weigh float64 `cname:"重量" json:"weigh" valid:"Required"`
}
... ... @@ -73,8 +73,10 @@ func (ptr *PGProductRecordService) SubmitProductRecord(productRecordType int, qu
if workshop, err = workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId}); err != nil {
return nil, err
}
if uc, err = unitConversionRepository.FindOne(map[string]interface{}{"unitConversionId": request.UnitConversionId}); err != nil {
return nil, err
if request.UnitConversionId > 0 {
if uc, err = unitConversionRepository.FindOne(map[string]interface{}{"unitConversionId": request.UnitConversionId}); err != nil {
return nil, err
}
}
if workstation, err = workshop.FindWorkStation(request.WorkshopId, request.LineId, request.SectionId); err != nil {
return nil, err
... ...
... ... @@ -248,6 +248,8 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId,
}
recordInfo := domain.NewDeviceRunningRecordInfo()
recordInfo.ProductPlanId = planId
recordInfo.DeviceName = device.DeviceName
recordInfo.OrgName = device.Ext.OrgName
record = &domain.DeviceDailyRunningRecord{
CompanyId: companyId,
OrgId: orgId,
... ... @@ -262,6 +264,13 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId,
if record, err = deviceDailyRunningRecordRepository.Save(record); err != nil {
return nil, err
}
if device.MarkAsProductDevice() {
deviceRepository, _ := repository.NewDeviceRepository(ptr.transactionContext)
if device, err = deviceRepository.Save(device); err != nil {
return nil, err
}
}
return record, nil
}
... ...
... ... @@ -143,6 +143,11 @@ func (repository *DeviceDailyRunningRecordRepository) Find(queryOptions map[stri
var deviceDailyRunningRecordModels []*models.DeviceDailyRunningRecord
deviceDailyRunningRecords := make([]*domain.DeviceDailyRunningRecord, 0)
query := sqlbuilder.BuildQuery(tx.Model(&deviceDailyRunningRecordModels), queryOptions)
query.SetWhereByQueryOption("company_id = ?", "companyId")
query.SetWhereByQueryOption("org_id = ?", "orgId")
if v, ok := queryOptions["productDate"]; ok && len(v.(string)) > 0 {
query.Where(`product_date = ?`, v)
}
query.SetOffsetAndLimit(20)
query.SetOrderDirect("device_daily_running_record_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
... ...
... ... @@ -188,6 +188,9 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin
if v, ok := queryOptions["signEndTime"]; ok && !((v.(time.Time)).IsZero()) {
query.Where("created_at<?", v.(time.Time))
}
if v, ok := queryOptions["employeeType"]; ok && (v.(int)) > 0 {
query.Where("product_worker->>'employeeType'='?'", v.(int))
}
query.SetOffsetAndLimit(domain.MaxQueryRow)
query.SetOrderDirect("product_attendance_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
... ...
... ... @@ -29,6 +29,24 @@ func GetNextMonthFirstDay(d time.Time) time.Time {
return GetZeroTime(d)
}
// GetNextMonthFirstDay 获取传入的时间所在月份的最后一天,即某月最后一天的23:59:59。如传入time.Now(), 返回当前月份的最后一天的23:59:59。
func GetCurrentMonthFirstDay(t time.Time) time.Time {
y, m, d := t.Date()
result := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
return result
}
func GetCurrentWeekFirstDay(t time.Time) time.Time {
d := t.Weekday()
result := GetZeroTime(t)
if d == time.Sunday {
result = result.Add(-time.Hour * 24 * 6)
} else {
result = result.Add(-time.Hour * 24 * (time.Duration(d) - 1))
}
return result
}
// GetZeroTime 获取某一天的0点时间
func GetZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, time.Local)
... ...
... ... @@ -9,4 +9,8 @@ func init() {
web.Router("/statistics", &controllers.StatisticsController{}, "Post:CommonStatisticsService")
c := &controllers.StatisticsController{}
web.Post("/statistics/hour-productive", c.CommonStatisticsHandler("HourProductiveStatistics"))
web.Post("/statistics/daily-productive-statistics", c.CommonStatisticsHandler("DailyProductiveStatistics"))
web.Post("/statistics/proportion-of-second-level-statistics", c.CommonStatisticsHandler("ProportionOfSecondLevelStatistics"))
web.Post("/statistics/workshop-production-efficiency-statistics", c.CommonStatisticsHandler("WorkshopProductionEfficiencyStatistics"))
web.Post("/statistics/device-running-statistics", c.CommonStatisticsHandler("DeviceRunningStatistics"))
}
... ...