新增设备
This commit is contained in:
@ -21,7 +21,7 @@ public class DeviceForm {
|
||||
private Long assignId;
|
||||
|
||||
@Schema(title = "设备类型")
|
||||
private Long deviceType;
|
||||
private Long deviceTypeId;
|
||||
|
||||
@Schema(title = "客户号")
|
||||
private Long customerId;
|
||||
|
@ -15,6 +15,9 @@ import java.util.Set;
|
||||
@Data
|
||||
public class DeviceTypeQueryCriteria extends BaseEntity implements Serializable {
|
||||
|
||||
@Schema(name = "设备类型id")
|
||||
private Long deviceTypeId;
|
||||
|
||||
@Schema(name = "型号名称")
|
||||
private String typeName;
|
||||
|
||||
|
@ -9,10 +9,13 @@ import com.fuyuanshen.common.core.utils.PageUtil;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.equipment.constants.DeviceConstants;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -43,6 +46,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final DeviceTypeMapper deviceTypeMapper;
|
||||
|
||||
|
||||
/**
|
||||
@ -56,7 +60,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
@Override
|
||||
public PageResult<Device> queryAll(DeviceQueryCriteria criteria, Page<Object> page) throws IOException {
|
||||
|
||||
criteria.setCustomerId(LoginHelper.getUserId());
|
||||
// criteria.setCustomerId(LoginHelper.getUserId());
|
||||
criteria.setCurrentOwnerId(LoginHelper.getUserId());
|
||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||
|
||||
List<Device> records = devices.getRecords();
|
||||
@ -91,10 +96,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addDevice(DeviceForm deviceForm) throws Exception {
|
||||
|
||||
// 获取当前登录用户信息
|
||||
// LoginUser user = LoginHelper.getLoginUser();
|
||||
|
||||
DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria();
|
||||
queryCriteria.setDeviceTypeId(deviceForm.getId());
|
||||
queryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||
List<DeviceType> deviceTypes = deviceTypeMapper.findAll(queryCriteria);
|
||||
if (deviceTypes.isEmpty()) {
|
||||
throw new Exception("设备类型不存在!!!");
|
||||
}
|
||||
|
||||
// 保存图片并获取URL
|
||||
String imageUrl = saveDeviceImage(deviceForm.getFile(), deviceForm.getDeviceName());
|
||||
@ -103,6 +111,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
// 转换对象并插入数据库
|
||||
Device device = new Device();
|
||||
device.setCurrentOwnerId(LoginHelper.getUserId());
|
||||
BeanUtil.copyProperties(deviceForm, device, true);
|
||||
|
||||
deviceMapper.insert(device);
|
||||
@ -110,8 +119,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新设备信息
|
||||
*
|
||||
@ -216,6 +223,4 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -42,11 +42,8 @@
|
||||
d.id,d.device_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
||||
d.update_time, d.device_type, d.remark, d.binding_status,t.type_name
|
||||
-- da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
||||
-- da.assigned_at AS create_time , da.assigner_name AS create_by , da.id AS assignId
|
||||
from device d
|
||||
FROM device d
|
||||
LEFT JOIN device_type t ON d.device_type = t.id
|
||||
-- LEFT JOIN device_assignments da ON da.device_id = d.id
|
||||
<where>
|
||||
<!-- 时间范围等其他条件保持原样 -->
|
||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||
@ -62,28 +59,18 @@
|
||||
and d.device_type = #{criteria.deviceType}
|
||||
</if>
|
||||
<if test="criteria.deviceStatus != null">
|
||||
-- and da.active = #{criteria.deviceStatus}
|
||||
-- and da.active = #{criteria.deviceStatus}
|
||||
</if>
|
||||
<if test="criteria.currentOwnerId != null">
|
||||
d.current_owner_id = #{criteria.currentOwnerId}
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
|
||||
<if test="criteria.tenantId != null">
|
||||
AND tenant_id = #{criteria.tenantId}
|
||||
</if>
|
||||
|
||||
<!-- 下面这两个条件只需满足一个 -->
|
||||
<!-- <if test="criteria.customerId != null"> -->
|
||||
<!-- AND ( -->
|
||||
<!-- tenant_id = #{criteria.tenantId} -->
|
||||
<!-- OR d.customer_id = #{criteria.customerId} -->
|
||||
<!-- ) -->
|
||||
<!-- </if> -->
|
||||
<!-- <if test="criteria.customerId == null"> -->
|
||||
<!-- AND tenant_id = #{criteria.tenantId} -->
|
||||
<!-- </if> -->
|
||||
</where>
|
||||
-- ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="findAll1" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
|
@ -28,6 +28,9 @@
|
||||
<if test="criteria.typeName != null and criteria.typeName.trim() != ''">
|
||||
and dt.type_name like concat('%', TRIM(#{criteria.typeName}), '%')
|
||||
</if>
|
||||
<if test="criteria.deviceTypeId != null">
|
||||
and dt.id = #{criteria.deviceTypeId}
|
||||
</if>
|
||||
<if test="criteria.customerId != null">
|
||||
and dt.owner_customer_id = #{criteria.customerId}
|
||||
</if>
|
||||
|
Reference in New Issue
Block a user