作者 yangfu

fix:1.称重系统用户查询修改

... ... @@ -30,7 +30,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error {
transactionContext.RollbackTransaction()
}()
log.Logger.Info("【定时刷新设备每日运行记录】 启动")
log.Logger.Debug("【定时刷新设备每日运行记录】 启动")
deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0)
// 获取redis里当天的记录
span := time.Duration(20)
... ... @@ -43,7 +43,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error {
for _, v := range records {
if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) {
log.Logger.Info(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt))
log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt))
continue
}
... ... @@ -53,7 +53,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error {
log.Logger.Error(err.Error())
continue
} else {
log.Logger.Info(fmt.Sprintf("【定时刷新设备每日运行记录】 刷新记录 %v", v))
log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 刷新记录 %v", v))
}
}
... ...
... ... @@ -26,7 +26,7 @@ type UpdateDeviceCommand struct {
// 工段ID
SectionId int `cname:"工段ID" json:"sectionId"`
// 品牌
Brand string `cname:"品牌" json:"brand" valid:"Required"`
Brand string `cname:"品牌" json:"brand"`
// 设备状态 1:正常 2:封存 3:报废
DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"`
// 风险等级 1:高 2:中 3:低
... ...
package dto
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
)
... ... @@ -24,7 +25,7 @@ type DeviceDto struct {
// 所属位置
*domain.WorkStation
// 生产单个产品的时间(单位:秒)
UnitProductionSecTime int `json:"unitProductionSecTime"`
UnitProductionSecTime string `json:"unitProductionSecTime"`
// 组织名称
OrgName string `json:"orgName"`
... ... @@ -47,7 +48,9 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto {
d.OrgName = m.Ext.OrgName
}
if m.Ext != nil && m.Ext.DeviceExt != nil {
d.UnitProductionSecTime = m.Ext.DeviceExt.UnitProductionSecTime
if m.Ext.DeviceExt.UnitProductionSecTime > 0 {
d.UnitProductionSecTime = fmt.Sprintf("%v", m.Ext.DeviceExt.UnitProductionSecTime)
}
}
return d
}
... ...
... ... @@ -71,6 +71,26 @@ func (d *ProductGroupEmployeesDtos) LoadDto(groups ...*domain.ProductGroup) {
}
}
func (d *ProductGroupEmployeesDtos) LoadDtoV2(list ...*domain.ProductAttendanceRecord) {
var mapUser = make(map[int]int)
for _, v := range list {
item := &ProductGroupEmployeesDto{}
item.UserId = v.ProductWorker.UserId
item.UserName = v.ProductWorker.UserName
item.ProductGroupId = 0
item.GroupName = ""
if len(item.UserName) > 0 {
item.UserNamePinyin = converter.ToPinYin(item.UserName, "")
}
if _, ok := mapUser[item.UserId]; ok {
continue
} else {
mapUser[item.UserId] = item.UserId
}
d.Append(item)
}
}
func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos {
return &ProductGroupEmployeesDtos{
Result: make([]*ProductGroupEmployeesDto, 0),
... ...
... ... @@ -395,9 +395,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper
transactionContext.RollbackTransaction()
}()
//workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId)
queryOptions := utils.ObjectToMap(cmd)
//queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, "")
var productGroupRepository domain.ProductGroupRepository
productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0)
... ... @@ -422,6 +420,41 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper
}, nil
}
// 返回在当前工段上打卡的所有用户
func (productGroupService *ProductGroupService) SearchProductGroupEmployeesV2(operateInfo *domain.OperateInfo, cmd *query.SearchProductGroupEmployeesQuery) (int64, interface{}, error) {
if err := cmd.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
queryOptions := utils.ObjectToMap(cmd)
queryOptions["signBeginTime"] = utils.GetZeroTime(time.Now())
var attendanceRecordRepository domain.ProductAttendanceRecordRepository
attendanceRecordRepository, _, _ = factory.FastPgAttendance(transactionContext, 0)
_, productGroups, err := attendanceRecordRepository.Find(queryOptions)
if err != nil {
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var results = dto.NewProductGroupEmployeesDtos()
results.LoadDtoV2(productGroups...)
sort.Stable(results)
if err := transactionContext.CommitTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return int64(len(results.Result)), map[string]interface{}{
"employees": results.Result,
}, nil
}
// 返回生产班组服务列表
func (productGroupService *ProductGroupService) GetSignEmployee(cmd *query.GetSignInEmployeeQuery) (interface{}, error) {
if err := cmd.ValidateQuery(); err != nil {
... ...
... ... @@ -17,7 +17,7 @@ func (ptr *PGApproveAttendanceRecordsService) BatchApproveAttendanceRecords(opt
var productAttendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext)
var attendance *domain.ProductAttendanceRecord
var err error
log.Logger.Info("【自动审核考勤记录任务】 启动")
log.Logger.Debug("【自动审核考勤记录任务】 启动")
var user *domain.User = &domain.User{}
userService := NewUserService()
if approveUserId > 0 {
... ...
... ... @@ -167,7 +167,7 @@ func (ptr *PGProductRecordService) BatchApprove(list []*domain.ProductRecord, ap
var productRecordRepository, _ = repository.NewProductRecordRepository(ptr.transactionContext)
var record *domain.ProductRecord
var err error
log.Logger.Info("【自动审核二级品记录任务】 启动")
log.Logger.Debug("【自动审核二级品记录任务】 启动")
var user *domain.User = &domain.User{}
userService := NewUserService()
if approveUserId > 0 {
... ...
... ... @@ -166,6 +166,9 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin
query := sqlbuilder.BuildQuery(tx.Model(&productAttendanceRecordModels), queryOptions)
query.SetWhereByQueryOption("company_id = ?", "companyId")
query.SetWhereByQueryOption("org_id = ?", "orgId")
query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId")
query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId")
query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId")
query.SetWhereByQueryOption("attendance_status & ? >0", "attendanceStatus")
if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 {
query.Where(`org_id in (?)`, pg.In(v))
... ...
... ... @@ -86,7 +86,7 @@ func (controller *ProductGroupController) SearchProductGroupEmployees() {
operateInfo := ParseOperateInfo(controller.BaseController)
cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
_, data, err := productGroupService.SearchProductGroupEmployees(operateInfo, cmd)
_, data, err := productGroupService.SearchProductGroupEmployeesV2(operateInfo, cmd)
controller.Response(data, err)
}
... ...