|
@@ -0,0 +1,78 @@
|
|
|
+package com.fjhx.oa.service.device.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.oa.entity.device.dto.DeviceRepairDto;
|
|
|
+import com.fjhx.oa.entity.device.dto.DeviceRepairSelectDto;
|
|
|
+import com.fjhx.oa.entity.device.po.DeviceRepair;
|
|
|
+import com.fjhx.oa.entity.device.vo.DeviceRepairVo;
|
|
|
+import com.fjhx.oa.mapper.device.DeviceRepairMapper;
|
|
|
+import com.fjhx.oa.service.device.DeviceRepairService;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 设备维修 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-06-24
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class DeviceRepairServiceImpl extends ServiceImpl<DeviceRepairMapper, DeviceRepair> implements DeviceRepairService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<DeviceRepairVo> getPage(DeviceRepairSelectDto dto) {
|
|
|
+ IWrapper<DeviceRepair> wrapper = getWrapper();
|
|
|
+
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField("dr.device_model"),
|
|
|
+ new SqlField("dr.parts_name"),
|
|
|
+ new SqlField("dr.factory_name"),
|
|
|
+ new SqlField("dr.scheme_remark"),
|
|
|
+ new SqlField("dr.amount")
|
|
|
+ );
|
|
|
+
|
|
|
+ wrapper.orderByDesc("dr", DeviceRepair::getId);
|
|
|
+ Page<DeviceRepairVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DeviceRepairVo detail(Long id) {
|
|
|
+ DeviceRepairVo result = BeanUtil.toBean(this.getById(id), DeviceRepairVo.class);
|
|
|
+ result.setFileList(ObsFileUtil.getFileMap(Collections.singletonList(id)).getOrDefault(id, new ArrayList<>()));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void add(DeviceRepairDto dto) {
|
|
|
+ this.save(dto);
|
|
|
+ ObsFileUtil.saveFile(dto.getFileList(), dto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void edit(DeviceRepairDto dto) {
|
|
|
+ this.updateById(dto);
|
|
|
+ ObsFileUtil.editFile(dto.getFileList(), dto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ ObsFileUtil.removeFile(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|