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_5207; } @SuppressWarnings("unchecked") @Override public PhoneResponse execute(Phone35Request 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 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 stringPageResponse = inoutManager.submitHandle(data); //进行下一流程更新 // PageResponse stringPageResponse = inoutManager.inNextStep(data); return PhoneRespUtil.success(stringPageResponse.getData(), req); } } }