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
90
91
92
93
94
95
package com.ld.igds.phone35.service.impl;
 
import com.alibaba.fastjson.JSONObject;
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.manager.InoutManager;
import com.ld.igds.inout.service.InoutService;
import com.ld.igds.models.InoutRecord;
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.Phone35InoutCommonParam;
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.BeanUtils;
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 czt
 * @date 2023-03-14 10:30
 */
@Service
public class Phone35ServiceImpl5207 implements Phone35Service {
 
    @Autowired
    private InoutService inoutService;
    @Autowired
    private InoutManager inoutManager;
    @Autowired
    private HPhoneServiceImpl hPhoneService;
 
    @Override
    public String getInterfaceId() {
        return Phone35Constant.API_PHONE_5205;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(Phone35Request<JSONObject> req, Phone35AuthUser phone35AuthUser)
            throws Exception {
 
        //转化为对象
        Phone35InoutCommonParam param = JSONObject.parseObject(req.getData().toString(), Phone35InoutCommonParam.class);
        if (null == param) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "参数有误,请重试!!");
        }
        //参数验证
        if (StringUtils.isEmpty(param.getDeptId())) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "参数有误,请重试!!");
        }
 
        //值仓提交前,再次确认当前流水是否为值仓流程
        InoutRecord record = hPhoneService.getInoutRecord(phone35AuthUser.getCompanyId(), phone35AuthUser.getDeptId(), param.getId(), null);
        if(!InoutConstant.PROGRESS_HANDLE.equals(record.getProgress())){
            return PhoneRespUtil.error(RespCodeEnum.CODE_1111, "该单子不在值仓状态,不能进行值仓提交!");
        }
 
        InoutData data = new InoutData();
        BeanUtils.copyProperties(record, data);
        if(param.getType().equals(Phone35Constant.PHONE_INOUT_START)){
            //值仓开始提交,只更新值仓开始时间
            String msg = inoutService.updateData(data);
            return PhoneRespUtil.success(null, req, msg);
        }else{
            //值仓结束提交,需更新流程状态、值仓结束时间、值仓人、值仓扣重等
            data.setDeHandle(param.getDeHandle());
            data.setHandleUser(phone35AuthUser.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);
            //TODO 设置水印
            data.setFiles(files);
            //进行下一流程更新
            PageResponse<InoutData> stringPageResponse = inoutManager.inNextStep(data);
 
            return PhoneRespUtil.success(stringPageResponse.getData(), req);
        }
    }
}