shiyunteng
6 天以前 fc8c86e7a365d5c6bdc37c2b05b9f83115ac2bc3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.by4cloud.platformx.device.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.device.constant.CommonStatusContant;
import com.by4cloud.platformx.device.entity.Device;
import com.by4cloud.platformx.device.entity.DeviceInventory;
import com.by4cloud.platformx.device.entity.InventoryFlowWater;
import com.by4cloud.platformx.device.entity.vo.InventoryDetailVo;
import com.by4cloud.platformx.device.mapper.DeviceInventoryMapper;
import com.by4cloud.platformx.device.mapper.DeviceMapper;
import com.by4cloud.platformx.device.mapper.InventoryFlowWaterMapper;
import com.by4cloud.platformx.device.service.DeviceInventoryService;
import com.by4cloud.platformx.device.service.InventoryFlowWaterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
/**
 * 库存
 *
 * @author pig
 * @date 2025-03-13 10:22:39
 */
@Service
@AllArgsConstructor
public class DeviceInventoryServiceImpl extends ServiceImpl<DeviceInventoryMapper, DeviceInventory> implements DeviceInventoryService {
 
    private final InventoryFlowWaterMapper flowWaterMapper;
    private final DeviceMapper deviceMapper;
 
    @Override
    public R getReleaseDetail(Long id) {
        InventoryDetailVo detailVo = baseMapper.getReleaseDetail(id);
        return R.ok(detailVo);
    }
 
    @Override
    public R returnDevice(Long id) {
        DeviceInventory inventory = baseMapper.selectById(id);
        inventory.setInventoryStatus(CommonStatusContant.DEVICE_INVENTORY_USABLE);
        baseMapper.updateById(inventory);
        //库存流水记录
        InventoryFlowWater flowWater = new InventoryFlowWater();
        flowWater.setDeviceId(inventory.getDeviceId());
        Device device = deviceMapper.selectById(inventory.getDeviceId());
        if (device!=null){
            flowWater.setClassId(device.getClassId());
        }
        flowWater.setInventoryId(inventory.getId());
        flowWater.setSerialNo(inventory.getSerialNo());
        flowWater.setOperateType(CommonStatusContant.DEVICE_INVENTORY_FLOW_WATER_IN);
        flowWaterMapper.insert(flowWater);
        return R.ok();
    }
}