jiazx0107@163.com
2023-06-21 d320b9ae40b3dfc1942ea484c8893ba1404c73ec
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
package com.ld.igds.phone.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.service.InoutService;
import com.ld.igds.phone.constant.PhoneConstant;
import com.ld.igds.phone.dto.AuthUser;
import com.ld.igds.phone.dto.PhoneResponse;
import com.ld.igds.phone.mapper.PhoneCommonMapper;
import com.ld.igds.phone.param.ParamInout;
import com.ld.igds.phone.param.PhoneRequest;
import com.ld.igds.phone.service.PhoneService;
import com.ld.igds.phone.util.PhoneRespUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
/**
 * 入库登记接口
 *
 * @author chen
 */
@Service
public class ServiceImpl5209 implements PhoneService {
 
    @Autowired
    private InoutService inoutService;
    @Autowired
    private PhoneCommonMapper phoneCommonMapper;
 
    @Override
    public String getInterfaceId() {
        return PhoneConstant.API_PHONE_5209;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(PhoneRequest<JSONObject> req, AuthUser authUser)
            throws Exception {
 
        //转化为对象
        ParamInout param = JSONObject.parseObject(req.getData().toString(), ParamInout.class);
        //验证当前车牌和一卡通号是否有未完成状态
        param.setCompanyId(authUser.getCompanyId());
        int i;
        if(StringUtils.isEmpty(param.getIntelCard())){
            i = phoneCommonMapper.validateByPlateNum(param);
        }else {
            i = phoneCommonMapper.validateByInterCard(param);
        }
        if(i>0){
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "当前卡或者车辆出入库未完成!");
        }
 
        InoutData data = new InoutData();
        data.setUserName(param.getUserName());
        data.setUserId(param.getUserId());
        data.setUserContact(param.getUserContact());
        data.setPlateNum(param.getPlateNum());
        data.setType(InoutConstant.TYPE_IN);
        data.setCompanyId(param.getCompanyId());
        data.setRegisterTime(new Date());
        data.setRegisterUser(authUser.getCname());
        data.setProgress(InoutConstant.PROGRESS_WEIGHT_FULL);
        //设置部门信息
        data.setDeptId(authUser.getDeptId());
 
        String msg = inoutService.insertData(data);
        if(null != msg){
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, msg);
        }
        return PhoneRespUtil.success("登记成功!", req);
    }
}