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
56
package com.by4cloud.platformx.device.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.DeviceInventory;
import com.by4cloud.platformx.device.entity.ResidualRecycle;
import com.by4cloud.platformx.device.mapper.DeviceInventoryMapper;
import com.by4cloud.platformx.device.mapper.ResidualRecycleMapper;
import com.by4cloud.platformx.device.service.ResidualRecycleService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
 * 残体回收
 *
 * @author syt
 * @date 2025-04-23 10:28:34
 */
@Service
@AllArgsConstructor
public class ResidualRecycleServiceImpl extends ServiceImpl<ResidualRecycleMapper, ResidualRecycle> implements ResidualRecycleService {
 
    private final DeviceInventoryMapper inventoryMapper;
 
    @Override
    public R approvedById(Long id) {
        ResidualRecycle residualRecycle = baseMapper.selectById(id);
        residualRecycle.setStatus(CommonStatusContant.RESIDUAL_RECYCLE_STATUS_HANDLING);
        baseMapper.updateById(residualRecycle);
        return R.ok();
    }
 
    @Override
    public R updateByIdNew(ResidualRecycle residualRecycle) {
        if (residualRecycle.getStatus()==CommonStatusContant.RESIDUAL_RECYCLE_STATUS_HANDLING){
            residualRecycle.setStatus(CommonStatusContant.RESIDUAL_RECYCLE_STATUS_COMPLETE);
            QueryWrapper<DeviceInventory> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("device_id",residualRecycle.getDeviceId());
            queryWrapper.eq("serial_no",residualRecycle.getSerialNo());
            DeviceInventory inventory = inventoryMapper.selectOne(queryWrapper);
            if (inventory!=null){
                if (residualRecycle.getHandleMethod()==CommonStatusContant.RESIDUAL_RECYCLE_METHOD_DISASSEMBE_RECYCLE||
                        residualRecycle.getHandleMethod()==CommonStatusContant.RESIDUAL_RECYCLE_METHOD_TRANSFER_PROFESSIONAL_INSTITUTION){
                    inventory.setInventoryStatus(CommonStatusContant.DEVICE_INVENTORY_RECYCLE);
                    inventoryMapper.updateById(inventory);
                }else if (residualRecycle.getHandleMethod()==CommonStatusContant.RESIDUAL_RECYCLE_METHOD_CYCLE_RENTING){
                    inventory.setInventoryStatus(CommonStatusContant.DEVICE_INVENTORY_USABLE);
                    inventoryMapper.updateById(inventory);
                }
            }
        }
        baseMapper.updateById(residualRecycle);
        return R.ok();
    }
}