作者 yangfu

fix:

1. 增加配置 产品类型列表 MANUFACTURE_PRODUCT_TYPE
2. 工时管理状态查询异常修改
3. 考勤统计修改
... ... @@ -49,10 +49,10 @@ func (crontabService *CrontabService) initTask() {
autoFlushDeviceDailyRunningRecordOEE := task.NewTask("定时刷新设备每日运行记录-OEE", "0 */10 * * * *", AutoFlushDeviceDailyRunningRecordOEE)
task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecordOEE)
autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-15/3 * * *", AutoWorkshopPlanCompletionRecord)
autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-17/1 * * *", AutoWorkshopPlanCompletionRecord)
task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord)
autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/3 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次
autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/1 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次
task.AddTask("autoTodayWorkshopPlanCompletionRecord", autoTodayWorkshopPlanCompletionRecord)
syncProductPlan := task.NewTask("定时同步车间计划", "0 */5 * * * *", SyncProductPlan)
... ...
... ... @@ -12,7 +12,7 @@ var (
// 生产制造 - 称重系统 - 默认组织
MANUFACTURE_DEFAULT_ORGID = 1
// 产品类型列表
MANUFACTURE_PRODUCT_TYPE = "0502010004ST,0502010004ST"
MANUFACTURE_PRODUCT_TYPE = "0502010004ST,0504010004ST"
MapProductType = make(map[int]string)
)
... ...
... ... @@ -214,13 +214,13 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string
if com&index > 0 {
val |= 2
}
if val == 1 || val == 0 {
if val == 1 {
return 1 //故障
}
if val == 3 {
return 2 //正常
}
if val == 2 {
if val == 2 || val == 0 {
return 3 //停机
}
return 3 // 停机
... ... @@ -233,12 +233,12 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string
if hds, ok = d.TimeLineDeviceStatus[fmt.Sprintf("%v", i)]; !ok {
hds = &HourDeviceStatus{Window: DefaultTimeWindow}
}
if i == 0 {
status = computeStatus(hds.Up, hds.Com, index) // 状态初始化
}
if end >= endTime {
break
}
if i == 0 {
status = computeStatus(hds.Up, hds.Com, index) // 状态初始化
}
if hds.Up == 0 && hds.Com == 0 {
end += 60 / hds.Window
continue
... ...
package domain
import "time"
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"time"
)
const (
ParticipateNormal = 1 // 正常
... ... @@ -97,7 +100,7 @@ func (employeeProductRecord *EmployeeProductRecord) UpdateProductWeigh(weigh flo
// 产能
func (employeeProductRecord *EmployeeProductRecord) RealProductWeigh() float64 {
// 产能 = 总投入量 - 本阶段二级品重量 - 其他上级二级品重量
return employeeProductRecord.ProductWeigh - employeeProductRecord.SecondLevelWeigh - employeeProductRecord.ProductRecordInfo.OtherSecondLevelWeigh()
return utils.Round(employeeProductRecord.ProductWeigh-employeeProductRecord.SecondLevelWeigh-employeeProductRecord.ProductRecordInfo.OtherSecondLevelWeigh(), 1)
}
// 合格率
... ... @@ -106,6 +109,6 @@ func (employeeProductRecord *EmployeeProductRecord) QualificationRate() int {
if realProductWeigh == 0 {
return 0
}
result := int(realProductWeigh * 100 / employeeProductRecord.ProductWeigh)
result := int(realProductWeigh * 100 / utils.Round(employeeProductRecord.ProductWeigh, 1))
return result
}
... ...
... ... @@ -25,7 +25,7 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
record *domain.ProductAttendanceRecord
//workStationId string //具体工位
workStation *domain.WorkStation
attendanceType int = domain.ParticipateNormal
attendanceType int = domain.ParticipateSupport
worker *domain.User
org *domain.Org
)
... ... @@ -59,15 +59,14 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
}
groupMembers, groupMembersKeyFunc := FindGroupMembers(productGroupRepository, cid, oid, workStation.WorkStationId)
if v, ok := groupMembers[groupMembersKeyFunc(worker.UserId)]; !ok {
attendanceType = domain.ParticipateSupport
} else {
if v, ok := groupMembers[groupMembersKeyFunc(worker.UserId)]; ok {
attendanceType = domain.ParticipateNormal
groupId = v.GroupId
groupName = v.GroupName
}
beginTime := utils.GetZeroTime(report.ActionTime)
endTime := report.ActionTime
endTime := time.Now()
_, records, _ := attendanceRecordDao.WorkerAttendanceRecords(cid, oid, worker.UserId, "", beginTime, endTime)
for i := 0; i < len(records); i++ {
r := records[i]
... ... @@ -106,6 +105,12 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
log.Logger.Debug(fmt.Sprintf("【考勤汇报】 已存在同一时间段的考勤记录 考勤ID:%v 用户:%v 打卡时间:%v", r.ProductAttendanceId, worker.UserId, report.ActionTime))
return struct{}{}, nil
}
if r.WorkStation.WorkStationId == workStation.WorkStationId && utils.TimeAfterEqual(r.SignOut.Add(time.Minute*5), report.ActionTime) {
isSignIn = false
record = r
log.Logger.Debug(fmt.Sprintf("【考勤汇报】 已存在同一时间段的考勤记录,小于离岗时间5min 考勤ID:%v 用户:%v 打卡时间:%v", r.ProductAttendanceId, worker.UserId, report.ActionTime))
break
}
continue
}
// 存在未结束的打卡记录
... ...
... ... @@ -78,8 +78,8 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d
// 封箱机、串串机需要定位到批次
if record.DeviceType == domain.DeviceTypeFengXiangJi || record.DeviceType == domain.DeviceTypeChuanChuanJi {
//datetime, _ = time.Parse("2006-01-02 15:04:05", deviceRunningData.Date)
if plan, err = ptr.findDeviceProductPlan(companyId, orgId, workStation.WorkStationId, utils.GetZeroTimeWithLocal(deviceRunningData.CollectionTime, time.UTC), deviceRunningData.ProductType); err != nil {
datetime, _ := time.ParseInLocation("2006-01-02", deviceRunningData.Date, time.Local)
if plan, err = ptr.findDeviceProductPlan(companyId, orgId, workStation.WorkStationId, utils.GetZeroTimeWithLocal(datetime, time.UTC), deviceRunningData.ProductType); err != nil {
log.Logger.Error(err.Error(), map[string]interface{}{"workstation": workStation, "product_code": deviceRunningData.ProductType})
} else {
planId = plan.PlanDispatchRecordExt.ProductPlanId
... ... @@ -91,7 +91,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d
if _, err = deviceRunningRecordRepository.Save(deviceRunningRecord); err != nil {
return nil, err
}
// 2.保存设备生产记录
// 2.保存设备生产记录 (统计车间、员工产能)
if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil {
productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan)
... ...
... ... @@ -169,7 +169,7 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin
query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId")
query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId")
query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId")
query.SetWhereByQueryOption("attendance_status & ? >0", "attendanceStatus")
query.SetWhereByQueryOption("attendance_status = ?", "attendanceStatus")
if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 {
query.Where(`org_id in (?)`, pg.In(v))
}
... ...
... ... @@ -35,7 +35,7 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) {
return
}
for key, item := range payload {
if key == "WorkShop" {
if key == "WorkShop" || key == "UpTime" {
continue
}
mBytes, err := json.Marshal(item)
... ... @@ -145,10 +145,10 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) {
}
}
//TODO:日志先注释
log.Logger.Info("MQTT", map[string]interface{}{
"Topic": message.Topic(),
"MessageId": message.MessageID(),
"Message": payload,
})
//log.Logger.Info("MQTT", map[string]interface{}{
// "Topic": message.Topic(),
// "MessageId": message.MessageID(),
// "Message": payload,
//})
}
}
... ...