From 84bbab4689ea2690055ee89b4d5090ee74924309 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 15 七月 2024 14:35:12 +0800
Subject: [PATCH] 海康api
---
ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
index abc41bd..67a558c 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
@@ -1,5 +1,6 @@
package com.ycl.platform.service.impl;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
@@ -13,6 +14,7 @@
import com.ycl.platform.domain.vo.WorkOrderVO;
import com.ycl.platform.mapper.*;
import com.ycl.platform.service.NotifyService;
+import com.ycl.platform.service.WorkOrderAuditingRecordService;
import com.ycl.platform.service.WorkOrderService;
import com.ycl.system.Result;
import com.ycl.system.model.LoginUser;
@@ -28,10 +30,12 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@@ -51,6 +55,7 @@
private final YwUnitMapper ywUnitMapper;
private final YwPeopleMapper ywPeopleMapper;
private final WorkOrderAuditingRecordMapper workOrderAuditingRecordMapper;
+ private final WorkOrderAuditingRecordService workOrderAuditingRecordService;
private final WorkOrderYwConditionRecordMapper workOrderYwConditionRecordMapper;
private final NotifyService notifyService;
private final WorkOrderDistributeRecordMapper workOrderDistributeRecordMapper;
@@ -123,6 +128,49 @@
@Override
@Transactional(rollbackFor = Exception.class)
+ public Result batchAuditing(WorkOrderBatchAuditingForm form) {
+ // 鏍规嵁鏁呴殰绫诲瀷鑾峰彇鍒楄〃
+ List<WorkOrder> list = new LambdaQueryChainWrapper<>(baseMapper)
+ .in(WorkOrder::getStatus, WorkOrderStatusEnum.YW_HANDLE.getValue())
+ .eq(WorkOrder::getErrorType, form.getErrorType())
+ .select(WorkOrder::getId, WorkOrder::getUnitId, WorkOrder::getWorkOrderNo)
+ .list();
+ if (list.isEmpty()) {
+ return Result.error("娌℃湁宸ュ崟鍙互瀹℃牳");
+ }
+ List<Integer> ids = list.stream().map(WorkOrder::getId).collect(Collectors.toList());
+ // 宸ュ崟鐘舵��
+ LambdaUpdateWrapper<WorkOrder> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+ lambdaUpdateWrapper.in(WorkOrder::getId, ids);
+ lambdaUpdateWrapper.set(WorkOrder::getStatus, form.getAuditingResult());
+ baseMapper.update(lambdaUpdateWrapper);
+ // 娣诲姞澶氭潯瀹℃牳璁板綍
+ List<WorkOrderAuditingRecord> workOrderAuditingRecords = new ArrayList<>();
+ for (Integer id : ids) {
+ WorkOrderAuditingRecord workOrderAuditingRecord = new WorkOrderAuditingRecord();
+ workOrderAuditingRecord.setWorkOrderId(id);
+ workOrderAuditingRecord.setAuditingUser(SecurityUtils.getLoginUser().getUserId().intValue());
+ workOrderAuditingRecord.setResult(form.getAuditingResult().getDesc());
+ workOrderAuditingRecord.setRemark(form.getAuditingRemark());
+ workOrderAuditingRecords.add(workOrderAuditingRecord);
+ }
+ workOrderAuditingRecordService.saveBatch(workOrderAuditingRecords);
+ // 娣诲姞鏂伴�氱煡
+ List<Notify> notifies = new ArrayList<>();
+ for (WorkOrder workOrder : list) {
+ Notify notify = Notify.genEntityByUnit(NotifyTypeEnum.WORK_ORDER,
+ form.getAuditingResult().getDesc(),
+ workOrder.getUnitId(),
+ UrgentLevelEnum.WARNING,
+ workOrder.getWorkOrderNo());
+ notifies.add(notify);
+ }
+ notifyService.saveBatch(notifies);
+ return Result.ok("鎿嶄綔鎴愬姛");
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
public Result ywCondition(WorkOrderYWConditionForm form) {
WorkOrder workOrder = baseMapper.selectById(form.getId());
if (Objects.isNull(workOrder)) {
@@ -148,8 +196,7 @@
new LambdaQueryChainWrapper<>(workOrderYwConditionRecordMapper)
.eq(WorkOrderYwConditionRecord::getWorkOrderId, id)
.orderByAsc(WorkOrderYwConditionRecord::getCreateTime)
- .last("limit 1")
- .one());
+ .list());
}
@Override
@@ -220,8 +267,9 @@
@Override
public Result distributePage(DistributeWorkOrderQuery query) {
- List<WorkOrderVO> page = baseMapper.distributePage(query);
- return Result.ok().data(page).total(page.size());
+ IPage<WorkOrderVO> page = PageUtil.getPage(query, WorkOrderVO.class);
+ baseMapper.distributePage(page, query);
+ return Result.ok().data(page).total(page.getTotal());
}
@Override
--
Gitblit v1.8.0