czt
2025-06-11 283da741b2429cf5a53786e5ee1b5528b757fdf6
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
package com.fzzy.igds.dzhwk.v1.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.fzzy.igds.dzhwk.domain.Depot;
import com.fzzy.igds.dzhwk.v1.ApiV1Service;
import com.fzzy.igds.dzhwk.v1.dto.ApiV1Data1005;
import com.fzzy.igds.dzhwk.v1.dto.ApiV1ReqDto;
import com.fzzy.igds.sys.DepotService;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @Description 解析货位信息
 * @Author CZT
 * @Date 2025/6/04 18:50
 */
@Slf4j
@Service
public class ApiV1ServiceImpl1005 implements ApiV1Service {
 
    @Resource
    private DepotService depotService;
 
    @Override
    public String getInterfaceId() {
        return "1005";
    }
 
    @Override
    public void analysis(String dataStr, ApiV1ReqDto configData) {
 
        List<ApiV1Data1005> list = JSONObject.parseArray(dataStr, ApiV1Data1005.class);
        if (null == list || list.isEmpty()) {
            log.error("-----未获取到货位信息,不解析---------");
            return;
        }
        try {
            Depot depot;
            for (ApiV1Data1005 apiData : list) {
 
                depot = depotService.getCacheDepot(configData.getSign(), apiData.getHwdm());
                if (null == depot) {
                    depot = new Depot();
                }
 
                depot.setId(apiData.getHwdm());
                depot.setName(apiData.getHwmc());
 
                depot.setCompanyId(configData.getSign());
                depot.setDeptId(configData.getDeptId());
                depot.setBuildingId(apiData.getAjdm().substring(0, 25));
                depot.setGranaryId(apiData.getAjdm());
                depot.setStorageMax(apiData.getHwrl());
                depot.setStoreKeeperName(apiData.getBgy());
                depot.setFoodVariety(apiData.getLspzdm());
                depot.setFoodType(apiData.getLsxzdm());
                depot.setFoodLevel(apiData.getLsdjdm());
                depot.setFoodYear(apiData.getShnd());
                depot.setFoodLocation(apiData.getCd());
                depot.setDepotStatus(apiData.getHwzt());
                if (StringUtils.isNotEmpty(apiData.getRcsj())) {
                    depot.setStoreDate(DateUtils.parseDate(apiData.getRcsj(), "yyyy-MM-dd HH:mm:ss"));
                }
                if (StringUtils.isNotEmpty(apiData.getZhgxsj())) {
                    depot.setUpdateTime(DateUtils.parseDate(apiData.getZhgxsj(), "yyyy-MM-dd HH:mm:ss"));
                }
                depot.setStorageReal(apiData.getSjsl());
                depotService.saveDepot(depot);
            }
        } catch (Exception e) {
            log.error("-----解析失败={}---------", e);
        }
 
    }
}