YYC
2026-02-12 660e6bab9482c3a6400ee0d39d56d254b6da945f
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.fzzy.igds.app.v1.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.fzzy.common.constant.RespCodeEnum;
import com.fzzy.igds.app.v1.constant.PhoneConstant;
import com.fzzy.igds.app.v1.data.AuthUser;
import com.fzzy.igds.app.v1.data.ParamDepot;
import com.fzzy.igds.app.v1.data.PhoneRequest;
import com.fzzy.igds.app.v1.data.PhoneResponse;
import com.fzzy.igds.app.v1.dto.PQuantityDto;
import com.fzzy.igds.app.v1.service.PhoneService;
import com.fzzy.igds.app.v1.util.PhoneRespUtil;
import com.fzzy.igds.constant.DepotType;
import com.fzzy.igds.domain.Depot;
import com.fzzy.igds.domain.Quantity;
import com.fzzy.igds.service.DepotService;
import com.fzzy.igds.service.QuantityService;
import com.fzzy.igds.service.SysDeptService;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.core.domain.entity.SysDept;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Author: YYC
 * @Description: 料位总览-料位列表
 * @DateTime: 2026-1-12 14:43
 **/
@Service
public class ServiceImpl5206 implements PhoneService {
 
    @Resource
    private DepotService depotService;
    @Resource
    private QuantityService quantityService;
    @Autowired
    private SysDeptService deptService;
 
    @Override
    public String getInterfaceId() {
        return PhoneConstant.API_PHONE_5206;
    }
 
    @Override
    public PhoneResponse<Object> execute(PhoneRequest<JSONObject> req, AuthUser authUser) throws Exception {
 
        ParamDepot param = JSONObject.parseObject(req.getData().toString(), ParamDepot.class);
        if (null == param) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "参数有误,请重试!!");
        }
        //参数验证
        if (StringUtils.isEmpty(param.getDeptId())) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "参数有误,请重试!!");
        }
 
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(authUser.getDeptId());
        }
        //获取所有筒仓及浅圆仓
        List<Depot> depotList = depotService.getCacheDepotList(ContextUtil.getCompanyId(), param.getDeptId());
        if (null == depotList || depotList.isEmpty()) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "未查到信息!!");
        }
 
        List<PQuantityDto> list = new ArrayList<>();
        List<Quantity> quantityList;
        PQuantityDto quantity;
        SysDept dept;
        for (Depot depot : depotList) {
            if (DepotType.TYPE_02.getCode().equals(depot.getDepotType()) || DepotType.TYPE_04.getCode().equals(depot.getDepotType())) {
                quantityList = quantityService.getQuantityList(depot.getId(), 1);
                quantity = new PQuantityDto();
                if (null == quantityList || quantityList.isEmpty()) {
                    quantity.setDepotId(depot.getId());
                } else {
                    BeanUtils.copyProperties(quantityList.get(0), quantity);
                    dept = deptService.getCacheDept(depot.getCompanyId(), depot.getDeptId());
                    quantity.setDepotData(depot);
                    quantity.setDeptName(dept.getDeptName());
                    list.add(quantity);
                }
 
            }
        }
 
        return PhoneRespUtil.success(list, req);
    }
}