CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
package com.ld.igds.phone35.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.io.constant.OrderRespEnum;
import com.ld.igds.io.response.PestResponse;
import com.ld.igds.pest.dto.PestParam;
import com.ld.igds.pest.manager.PestManager;
import com.ld.igds.phone35.constant.Phone35Constant;
import com.ld.igds.phone35.dto.Phone35AuthUser;
import com.ld.igds.phone35.dto.PhoneResponse;
import com.ld.igds.phone35.param.Phone35DepotCommonParam;
import com.ld.igds.phone35.param.Phone35Request;
import com.ld.igds.phone35.service.Phone35Service;
import com.ld.igds.phone35.util.PhoneRespUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
/**
 * 粮情展示-虫害采集接口实现
 *
 * @author chen
 */
@Service
public class Phone35ServiceImpl5307 implements Phone35Service {
 
    @Autowired
    private PestManager pestManager;
 
    @Override
    public String getInterfaceId() {
        return Phone35Constant.API_PHONE_5307;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(Phone35Request<JSONObject> req, Phone35AuthUser phone35AuthUser)
            throws Exception {
        //转化对象
        Phone35DepotCommonParam param = JSONObject.parseObject(req.getData().toString(), Phone35DepotCommonParam.class);
        if (null == param) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "参数有误,请重试!!");
        }
        //参数验证
        if (StringUtils.isEmpty(param.getDeptId()) || StringUtils.isEmpty(param.getDepotId())) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "参数有误,请重试!!");
        }
        PestParam pestParam = new PestParam();
        pestParam.setCompanyId(phone35AuthUser.getCompanyId());
        pestParam.setDepotId(param.getDepotId());
 
        PestResponse pestResponse = pestManager.checkPest(pestParam);
 
        if(OrderRespEnum.ORDER_ERROR.getCode().equals(pestResponse.getCode())){
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111,pestResponse.getMsg());
        }else {
            return PhoneRespUtil.success(pestResponse.getMsg(), req);
        }
    }
}