jiazx0107@163.com
2023-06-08 08cea428e888b6fdd2a3c3783e87e4f828385783
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
package com.ld.igds.phone.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.inout.manager.InoutManager;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.data.PageResponse;
import com.ld.igds.file.dto.FileData;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.mapper.InoutRecordMapper;
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.param.ParamInoutHandle;
import com.ld.igds.phone.param.PhoneRequest;
import com.ld.igds.phone.service.PhoneService;
import com.ld.igds.phone.util.PhoneRespUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 出库值仓提交接口实现
 *
 * @author chen
 */
@Service
public class ServiceImpl5207 implements PhoneService {
 
    @Autowired
    private InoutService inoutService;
    @Autowired
    private InoutManager inoutManager;
    @Autowired
    private InoutRecordMapper inoutMapper;
 
    @Override
    public String getInterfaceId() {
        return PhoneConstant.API_PHONE_5207;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(PhoneRequest<JSONObject> req, AuthUser authUser)
            throws Exception {
 
        //转化为对象
        ParamInoutHandle param = JSONObject.parseObject(req.getData().toString(), ParamInoutHandle.class);
        //查询单子信息
        InoutParam inoutParam = new InoutParam();
        inoutParam.setId(param.getId());
        inoutParam.setCompanyId(authUser.getCompanyId());
        InoutData data = inoutMapper.inoutQueryById(inoutParam);
 
        //判断单子是否在值仓流程
        if(!data.getProgress().equals(InoutConstant.PROGRESS_HANDLE)){
            return PhoneRespUtil.error(RespCodeEnum.CODE_2000,"该单子不在值仓状态,不能进行值仓提交!");
        }
 
        if(param.getType().equals(PhoneConstant.PHONE_INOUT_START)){
            //值仓开始提交,只更新值仓开始时间
            String msg = inoutService.updateData(data);
            return PhoneRespUtil.success(msg, req);
        }else{
            //值仓结束提交,需更新流程状态、值仓结束时间、值仓人、值仓扣重等
            data.setDeHandle(param.getDeHandle());
            data.setHandleUser(authUser.getCname());
            //设置值仓图片信息
            List<FileData> files = new ArrayList<>();
            FileData fileData1 = new FileData();
            FileData fileData2 = new FileData();
            fileData1.setFileName(param.getFileName1());
            fileData2.setFileName(param.getFileName2());
            files.add(fileData1);
            files.add(fileData2);
            data.setFiles(files);
            //进行下一流程更新
            PageResponse<InoutData> stringPageResponse = inoutManager.inNextStep(data);
 
            return PhoneRespUtil.success(stringPageResponse.getData(), req);
        }
 
    }
}