feat:设备管理流程类功能开发

This commit is contained in:
FCL
2026-01-29 15:25:45 +08:00
parent 675e1fe850
commit 2111c8b3ad
11 changed files with 143 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.qms.resource.device.controller.admin;
import com.alibaba.fastjson.JSONObject;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplySaveReqVO;
@@ -66,6 +67,19 @@ public class DeviceApplyController extends AbstractFileUploadController implemen
return deviceApplyService.saveDeviceApply(createReqVO);
}
@RequestMapping("/addDetail")
@Operation(summary = "增加明细")
public CommonResult<Boolean> addDetail(@RequestBody JSONObject param) {
return deviceApplyService.addDetail(param);
}
@RequestMapping("/removeDetail")
@Operation(summary = "删除明细")
public CommonResult<Boolean> removeDetail(@RequestBody JSONObject param) {
return deviceApplyService.removeDetail(param);
}
@PutMapping("/update")
@Operation(summary = "更新设备通用流程,验收、降级、停用、报废、还原、启用")
// @PreAuthorize("@ss.hasPermission('qms:device-apply:update')")
@@ -101,7 +115,7 @@ public class DeviceApplyController extends AbstractFileUploadController implemen
return success(BeanUtils.toBean(deviceApply, DeviceApplyRespVO.class));
}
@GetMapping("/page")
@GetMapping("/list")
@Operation(summary = "获得设备通用流程,验收、降级、停用、报废、还原、启用分页")
public CommonResult<PageResult<DeviceApplyRespVO>> getDeviceApplyPage(@Valid DeviceApplyPageReqVO pageReqVO) {
PageResult<DeviceApplyDO> pageResult = deviceApplyService.getDeviceApplyPage(pageReqVO);

View File

@@ -1,8 +1,7 @@
package com.zt.plat.module.qms.resource.device.controller.admin;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailRespVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailSaveReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.*;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDO;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -55,6 +54,13 @@ public class DeviceApplyDetailController extends AbstractFileUploadController im
@Resource
private DeviceApplyDetailService deviceApplyDetailService;
@GetMapping("/list")
@Operation(summary = "获得设备通用流程分页")
public CommonResult<List<DeviceApplyDetailRespVO>> list(DeviceApplyDetailPageReqVO reqVO) {
List<DeviceApplyDetailDO> list = deviceApplyDetailService.selectList(reqVO);
return success(BeanUtils.toBean(list, DeviceApplyDetailRespVO.class));
}
@PostMapping("/create")
@Operation(summary = "创建设备通用流程明细")
@PreAuthorize("@ss.hasPermission('qms:device-apply-detail:create')")

View File

@@ -55,14 +55,14 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@PostMapping("/create")
@Operation(summary = "创建设备通用流程配置")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:create')")
// @PreAuthorize("@ss.hasPermission('qms:device-config-flow:create')")
public CommonResult<DeviceConfigFlowRespVO> createDeviceConfigFlow(@Valid @RequestBody DeviceConfigFlowSaveReqVO createReqVO) {
return success(deviceConfigFlowService.createDeviceConfigFlow(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新设备通用流程配置")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:update')")
// @PreAuthorize("@ss.hasPermission('qms:device-config-flow:update')")
public CommonResult<Boolean> updateDeviceConfigFlow(@Valid @RequestBody DeviceConfigFlowSaveReqVO updateReqVO) {
deviceConfigFlowService.updateDeviceConfigFlow(updateReqVO);
return success(true);
@@ -71,7 +71,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@DeleteMapping("/delete")
@Operation(summary = "删除设备通用流程配置")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')")
// @PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')")
public CommonResult<Boolean> deleteDeviceConfigFlow(@RequestParam("id") Long id) {
deviceConfigFlowService.deleteDeviceConfigFlow(id);
return success(true);
@@ -80,7 +80,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除设备通用流程配置")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')")
// @PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')")
public CommonResult<Boolean> deleteDeviceConfigFlowList(@RequestBody BatchDeleteReqVO req) {
deviceConfigFlowService.deleteDeviceConfigFlowListByIds(req.getIds());
return success(true);
@@ -89,7 +89,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@GetMapping("/get")
@Operation(summary = "获得设备通用流程配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:query')")
// @PreAuthorize("@ss.hasPermission('qms:device-config-flow:query')")
public CommonResult<DeviceConfigFlowRespVO> getDeviceConfigFlow(@RequestParam("id") Long id) {
DeviceConfigFlowDO deviceConfigFlow = deviceConfigFlowService.getDeviceConfigFlow(id);
return success(BeanUtils.toBean(deviceConfigFlow, DeviceConfigFlowRespVO.class));
@@ -104,7 +104,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@GetMapping("/export-excel")
@Operation(summary = "导出设备通用流程配置 Excel")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:export')")
// @PreAuthorize("@ss.hasPermission('qms:device-config-flow:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportDeviceConfigFlowExcel(@Valid DeviceConfigFlowPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {

View File

@@ -35,4 +35,7 @@ public class DeviceApplyDetailPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
//扩展字段
@Schema(description = "设备id列表")
private List<Long> deviceInfoIdList;
}

View File

@@ -7,6 +7,8 @@ import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDetailDO
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 设备通用流程明细 Mapper
*
@@ -27,4 +29,18 @@ public interface DeviceApplyDetailMapper extends BaseMapperX<DeviceApplyDetailDO
.orderByDesc(DeviceApplyDetailDO::getId));
}
default List<DeviceApplyDetailDO> selectList(DeviceApplyDetailPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DeviceApplyDetailDO>()
.eqIfPresent(DeviceApplyDetailDO::getApplyId, reqVO.getApplyId())
.eqIfPresent(DeviceApplyDetailDO::getDeviceInfomationId, reqVO.getDeviceInfomationId())
.inIfPresent(DeviceApplyDetailDO::getDeviceInfomationId, reqVO.getDeviceInfoIdList())
.eqIfPresent(DeviceApplyDetailDO::getDeviceBorrowDetailId, reqVO.getDeviceBorrowDetailId())
.eqIfPresent(DeviceApplyDetailDO::getFormData, reqVO.getFormData())
.eqIfPresent(DeviceApplyDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
.eqIfPresent(DeviceApplyDetailDO::getRemark, reqVO.getRemark())
.betweenIfPresent(DeviceApplyDetailDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DeviceApplyDetailDO::getId));
}
}

View File

@@ -16,6 +16,10 @@ import com.zt.plat.framework.common.pojo.PageResult;
*/
public interface DeviceApplyDetailService {
List<DeviceApplyDetailDO> selectList(DeviceApplyDetailPageReqVO reqVO);
void insertBatch(List<DeviceApplyDetailDO> list);
/**
* 创建设备通用流程明细
*

View File

@@ -6,6 +6,7 @@ import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailRes
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailSaveReqVO;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.*;
@@ -32,6 +33,17 @@ public class DeviceApplyDetailServiceImpl implements DeviceApplyDetailService {
@Resource
private DeviceApplyDetailMapper deviceApplyDetailMapper;
@Override
public List<DeviceApplyDetailDO> selectList(DeviceApplyDetailPageReqVO reqVO) {
return deviceApplyDetailMapper.selectList(reqVO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void insertBatch(List<DeviceApplyDetailDO> list) {
deviceApplyDetailMapper.insertBatch(list);
}
@Override
public DeviceApplyDetailRespVO createDeviceApplyDetail(DeviceApplyDetailSaveReqVO createReqVO) {
// 插入

View File

@@ -2,6 +2,7 @@ package com.zt.plat.module.qms.resource.device.service;
import java.util.*;
import com.alibaba.fastjson.JSONObject;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO;
@@ -28,6 +29,12 @@ public interface DeviceApplyService {
//创建临时数据
CommonResult<DeviceApplyRespVO> createTempData(@Valid DeviceApplySaveReqVO createReqVO);
//增加明细
CommonResult<Boolean> addDetail(JSONObject param);
//删除明细
CommonResult<Boolean> removeDetail(JSONObject param);
CommonResult<Boolean> saveDeviceApply(@Valid DeviceApplySaveReqVO updateReqVO);
/**

View File

@@ -13,10 +13,13 @@ import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
import com.zt.plat.module.qms.common.data.service.DataCollectionService;
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplySaveReqVO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDetailDO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigFlowDO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfomationDO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
@@ -27,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDO;
import com.zt.plat.framework.common.pojo.PageResult;
@@ -50,6 +54,8 @@ public class DeviceApplyServiceImpl implements DeviceApplyService {
@Resource private DeviceApplyMapper deviceApplyMapper;
@Resource private DeviceConfigFlowService deviceConfigFlowService;
@Resource private DeviceInfomationService deviceInfomationService;
@Resource private DeviceApplyDetailService deviceApplyDetailService;
@Resource private DataCollectionService dataCollectionService;
@Resource private DataTemplateService dataTemplateService;
@@ -96,6 +102,55 @@ public class DeviceApplyServiceImpl implements DeviceApplyService {
return CommonResult.success(BeanUtils.toBean(deviceApply, DeviceApplyRespVO.class));
}
//增加明细
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult<Boolean> addDetail(JSONObject param) {
String deviceIds = param.getString("deviceIds");
String applyId = param.getString("applyId");
if(ObjectUtils.isEmpty(deviceIds))
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "请选择设备");
if(ObjectUtils.isEmpty(applyId))
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "缺少申请id参数请刷新后重试");
List<DeviceInfomationDO> deviceList = deviceInfomationService.getListByIds(deviceIds);
if(deviceList.isEmpty())
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "设备不存在");
List<Long> deviceInfoIdList = new ArrayList<>();
for (DeviceInfomationDO device : deviceList) {
deviceInfoIdList.add(device.getId());
}
//查询已有明细,避免重复添加
DeviceApplyDetailPageReqVO detailPageReqVO = new DeviceApplyDetailPageReqVO();
detailPageReqVO.setApplyId(Long.valueOf(applyId));
detailPageReqVO.setDeviceInfoIdList(deviceInfoIdList);
List<DeviceApplyDetailDO> detailList = deviceApplyDetailService.selectList(detailPageReqVO);
//过滤已添加设备
List<DeviceInfomationDO> addDeviceList = deviceList.stream().filter(device ->
detailList.stream().noneMatch(detail -> detail.getDeviceInfomationId().equals(device.getId()))).toList();
List<DeviceApplyDetailDO> detailDOList = new ArrayList<>();
for (DeviceInfomationDO device : addDeviceList) {
DeviceApplyDetailDO detail = new DeviceApplyDetailDO();
detail.setApplyId(Long.valueOf(applyId));
detail.setDeviceInfomationId(device.getId());
detailDOList.add(detail);
}
deviceApplyDetailService.insertBatch(detailDOList);
return CommonResult.success(true);
}
@Override
public CommonResult<Boolean> removeDetail(JSONObject param) {
String detailIds = param.getString("detailIds");
if(ObjectUtils.isEmpty(detailIds))
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "请选择需要删除的明细数据");
List<Long> detailIdList = Arrays.stream(detailIds.split(",")).map(Long::valueOf).toList();
deviceApplyDetailService.deleteDeviceApplyDetailListByIds(detailIdList);
return CommonResult.success(true);
}
//保存
@Override
@Transactional(rollbackFor = Exception.class)

View File

@@ -27,6 +27,7 @@ public interface DeviceInfomationService {
DeviceInfomationDO getByCode(String code);
List<DeviceInfomationDO> getListByProductIdList(List<Long> productIds);
List<DeviceInfomationDO> getListByIds(String ids);
List<Long> getIdListByProductIdList(List<Long> productIds);
@@ -47,11 +48,7 @@ public interface DeviceInfomationService {
// CommonResult<Boolean> updateDeviceAcceptFlag(Long deviceId, String acceptFlag);
// CommonResult<Boolean> updateDeviceLendFlag(Long deviceId, Integer lendFlag);
void updateBatch(List<DeviceInfomationDO> updateList);
/**
* 创建设备-设备信息

View File

@@ -25,9 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
@@ -201,6 +199,11 @@ public class DeviceInfomationServiceImpl implements DeviceInfomationService {
deviceInfomationMapper.update(updateWrapper);
}
@Override
public void updateBatch(List<DeviceInfomationDO> updateList) {
deviceInfomationMapper.updateBatch(updateList);
}
@Override
public DeviceInfomationDO getByCode(String code) {
LambdaQueryWrapper<DeviceInfomationDO> query = new LambdaQueryWrapper<>();
@@ -215,6 +218,14 @@ public class DeviceInfomationServiceImpl implements DeviceInfomationService {
return deviceInfomationMapper.selectList(query);
}
@Override
public List<DeviceInfomationDO> getListByIds(String ids) {
if(ObjectUtils.isEmpty(ids))
return Collections.emptyList();
List< Long> idsList = Arrays.asList(ids.split(",")).stream().map(Long::parseLong).toList();
return deviceInfomationMapper.selectByIds(idsList);
}
@Override
public List<Long> getIdListByProductIdList(List<Long> productIds) {
List<DeviceInfomationDO> list = getListByProductIdList(productIds);