|
|
package com.glxp.api.controller.inout;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
import com.glxp.api.annotation.Log;
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
import com.glxp.api.constant.BusinessType;
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
import com.glxp.api.controller.BaseController;
|
|
|
import com.glxp.api.entity.auth.AuthAdmin;
|
|
|
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
|
|
|
import com.glxp.api.entity.basic.EntrustReceEntity;
|
|
|
import com.glxp.api.entity.inout.IoCodeEntity;
|
|
|
import com.glxp.api.entity.inout.IoCodeTempEntity;
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
import com.glxp.api.http.sync.SpGetHttpClient;
|
|
|
import com.glxp.api.req.inout.*;
|
|
|
import com.glxp.api.res.inout.AcceptOrderResponse;
|
|
|
import com.glxp.api.res.inout.IoCodeResponse;
|
|
|
import com.glxp.api.res.inout.IoOrderDetailResultResponse;
|
|
|
import com.glxp.api.res.inout.IoOrderResponse;
|
|
|
import com.glxp.api.res.sync.SpsSyncOrderResponse;
|
|
|
import com.glxp.api.service.auth.AuthAdminService;
|
|
|
import com.glxp.api.service.auth.InvBusUserService;
|
|
|
import com.glxp.api.service.basic.EntrustReceService;
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
import com.glxp.api.service.sync.HeartService;
|
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
|
import com.glxp.api.util.*;
|
|
|
import com.glxp.api.util.udi.UdiCalCountUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
|
|
|
//单据验收
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
public class IoOrderReviewController extends BaseController {
|
|
|
|
|
|
@Resource
|
|
|
private RedisUtil redisUtil;
|
|
|
@Resource
|
|
|
private IoOrderDetailResultService orderDetailResultService;
|
|
|
@Resource
|
|
|
IoOrderService orderService;
|
|
|
@Resource
|
|
|
IoCheckInoutService ioCheckInoutService;
|
|
|
@Resource
|
|
|
IoCodeService codeService;
|
|
|
@Resource
|
|
|
IoCodeTempService codeTempService;
|
|
|
@Resource
|
|
|
UdiCalCountUtil calCountUtil;
|
|
|
@Resource
|
|
|
AuthAdminService authAdminService;
|
|
|
@Resource
|
|
|
EntrustReceService entrustReceService;
|
|
|
@Resource
|
|
|
IBasicBussinessTypeService basicBussinessTypeService;
|
|
|
@Resource
|
|
|
GennerOrderUtils gennerOrderUtils;
|
|
|
@Resource
|
|
|
IoAddInoutService addInoutService;
|
|
|
@Resource
|
|
|
HeartService heartService;
|
|
|
@Resource
|
|
|
SpGetHttpClient spGetHttp;
|
|
|
@Resource
|
|
|
InvBusUserService invBusUserService;
|
|
|
|
|
|
|
|
|
//获取验收单据业务详情
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/stock/order/accept/getOrder")
|
|
|
public BaseResponse getAcceptOrder(String billNo) {
|
|
|
if (StrUtil.isBlank(billNo)) {
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
}
|
|
|
AcceptOrderResponse acceptOrderEntity = new AcceptOrderResponse();
|
|
|
acceptOrderEntity.setBillNo(billNo);
|
|
|
List<IoOrderDetailResultResponse> datas = (List<IoOrderDetailResultResponse>) redisUtil.get(ConstantStatus.REDIS_BILLNO + billNo);
|
|
|
if (CollUtil.isNotEmpty(datas)) {
|
|
|
acceptOrderEntity.setOrderDetailEntities(datas);
|
|
|
acceptOrderEntity.setExitAccept(true);
|
|
|
} else {
|
|
|
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
|
|
|
filterOrderDetailResultRequest.setOrderIdFk(billNo);
|
|
|
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
|
|
|
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
|
|
|
acceptOrderEntity.setExitAccept(false);
|
|
|
}
|
|
|
return ResultVOUtils.success(acceptOrderEntity);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取验收单据业务详情
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/stock/order/accept/getStatus")
|
|
|
public BaseResponse getStatus(String billNo) {
|
|
|
if (StrUtil.isBlank(billNo)) {
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
}
|
|
|
AcceptOrderResponse acceptOrderEntity = new AcceptOrderResponse();
|
|
|
acceptOrderEntity.setBillNo(billNo);
|
|
|
List<IoOrderDetailResultResponse> datas = (List<IoOrderDetailResultResponse>) redisUtil.get(ConstantStatus.REDIS_BILLNO + billNo);
|
|
|
if (CollUtil.isNotEmpty(datas)) {
|
|
|
boolean isFinish = vailFinish(datas);
|
|
|
if (isFinish)
|
|
|
return ResultVOUtils.success("单据已验收完成");
|
|
|
else
|
|
|
return ResultVOUtils.error(500, "单据未验收完成");
|
|
|
} else {
|
|
|
return ResultVOUtils.error(500, "单据未验收完成");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//前端二次审核
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/spms/inout/order/web/updateStatus")
|
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
|
public BaseResponse webUpdateStatus(@RequestBody ReviewFinishRequest updateExportStatusRequest,
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
}
|
|
|
IoOrderEntity orderEntity = orderService.findByBillNo(updateExportStatusRequest.getOrderId());
|
|
|
if (orderEntity == null) {
|
|
|
return ResultVOUtils.error(500, "未找到该业务单据");
|
|
|
}
|
|
|
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_REW) {
|
|
|
if (updateExportStatusRequest.isEntrust()) {
|
|
|
EntrustReceEntity entrustReceEntity = entrustReceService.findByUnique(orderEntity.getAction(), getUserId());
|
|
|
if (entrustReceEntity != null && StrUtil.isNotEmpty(entrustReceEntity.getEntrustAction())) {
|
|
|
transferOrder(orderEntity, entrustReceEntity);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (orderEntity.getFromType() == ConstantStatus.FROM_UDISP)
|
|
|
spGetHttp.reviewOrder(updateExportStatusRequest, getUserId() + "");
|
|
|
return updateReview(getUser(), orderEntity);
|
|
|
} else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
|
|
|
return thirdUpdateReview(getUser(), orderEntity);
|
|
|
} else {
|
|
|
return ResultVOUtils.error(500, "当前单据状态非处于审核状态!");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//前端第三次验收
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/spms/inout/order/third/updateStatus")
|
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public BaseResponse thirdUpdateStatus(@RequestBody ReviewFinishRequest updateExportStatusRequest,
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
}
|
|
|
IoOrderEntity orderEntity = orderService.findByBillNo(updateExportStatusRequest.getOrderId());
|
|
|
if (updateExportStatusRequest.isEntrust()) {
|
|
|
EntrustReceEntity entrustReceEntity = entrustReceService.findByUnique(orderEntity.getAction(), getUserId());
|
|
|
if (entrustReceEntity != null && StrUtil.isNotEmpty(entrustReceEntity.getEntrustAction())) {
|
|
|
transferOrder(orderEntity, entrustReceEntity);
|
|
|
}
|
|
|
}
|
|
|
if (orderEntity == null) {
|
|
|
return ResultVOUtils.error(500, "未找到该业务单据");
|
|
|
}
|
|
|
return thirdUpdateReview(getUser(), orderEntity);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 前端扫码验收
|
|
|
*
|
|
|
* @param acceptOrderEntity
|
|
|
* @return
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/udiwms/stock/order/accept/addCode")
|
|
|
public BaseResponse acceptAddCode(@RequestBody AcceptOrderResponse acceptOrderEntity) {
|
|
|
|
|
|
IoOrderEntity stockOrderEntity = orderService.findByBillNo(acceptOrderEntity.getBillNo());
|
|
|
|
|
|
List<IoCodeEntity> codeList;
|
|
|
List<IoCodeEntity> codeEntityList = (List<IoCodeEntity>) redisUtil.get(ConstantStatus.REDIS_BILLNO_CODES + acceptOrderEntity.getBillNo());
|
|
|
if (CollUtil.isEmpty(codeEntityList)) {
|
|
|
codeList = codeService.findByOrderId(stockOrderEntity.getBillNo());
|
|
|
} else {
|
|
|
codeList = codeEntityList;
|
|
|
}
|
|
|
IoCodeEntity codeEntity = isExit(codeList, acceptOrderEntity.getCode());
|
|
|
if (codeEntity == null) {
|
|
|
return ResultVOUtils.error(500, "非此单UDI码!");
|
|
|
}
|
|
|
|
|
|
int status = checkCodeExit(codeEntity.getCode(), codeList);
|
|
|
if (status == Constant.CHECK_REPEAT) {
|
|
|
return ResultVOUtils.error(500, "重复扫码!");
|
|
|
} else if (status == Constant.CHECK_NULL) {
|
|
|
return ResultVOUtils.error(500, "非此单UDI码!");
|
|
|
}
|
|
|
|
|
|
List<IoOrderDetailResultResponse> orderDetailResultResponses = acceptOrderEntity.getOrderDetailEntities();
|
|
|
if (StrUtil.isNotEmpty(acceptOrderEntity.getCode()) && CollUtil.isNotEmpty(orderDetailResultResponses)) {
|
|
|
boolean isExit = false;
|
|
|
for (IoOrderDetailResultResponse orderDetailResultResponse : orderDetailResultResponses) {
|
|
|
if (orderDetailResultResponse.getBindRlFk().longValue() == codeEntity.getRelId().longValue() &&
|
|
|
StrUtil.trimToEmpty(orderDetailResultResponse.getBatchNo()).equals(StrUtil.trimToEmpty(codeEntity.getBatchNo()))) {
|
|
|
orderDetailResultResponse.setAcceptCount(orderDetailResultResponse.getAcceptCount() + calCountUtil.getActCount(codeEntity.getNameCode()));
|
|
|
if (orderDetailResultResponse.getAcceptCount() > orderDetailResultResponse.getCount()) {
|
|
|
return ResultVOUtils.error(500, "数量溢出!");
|
|
|
}
|
|
|
isExit = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExit) {
|
|
|
redisUtil.set(ConstantStatus.REDIS_BILLNO + acceptOrderEntity.getBillNo(), orderDetailResultResponses);
|
|
|
redisUtil.set(ConstantStatus.REDIS_BILLNO_CODES + acceptOrderEntity.getBillNo(), codeList);
|
|
|
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
|
|
|
if (vailFinish(orderDetailResultResponses)) {
|
|
|
acceptOrderEntity.setFinishAccept(true);
|
|
|
return ResultVOUtils.success(acceptOrderEntity);
|
|
|
}
|
|
|
return ResultVOUtils.success(acceptOrderEntity);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return ResultVOUtils.error(500, "非此单条码!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 手持终端验收完成后,更新订单状态
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/spms/inout/order/check/updateStatus")
|
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
|
public BaseResponse updateStatus(@RequestBody UpdateExportStatusRequest updateExportStatusRequest,
|
|
|
BindingResult bindingResult) {
|
|
|
AuthAdmin authAdmin = null;
|
|
|
if (StrUtil.isNotEmpty(updateExportStatusRequest.getWmsUserId())) {
|
|
|
authAdmin = authAdminService.findById(Long.parseLong(updateExportStatusRequest.getWmsUserId()));
|
|
|
} else
|
|
|
authAdmin = getUser();
|
|
|
IoOrderEntity orderEntity = orderService.findByBillNo(updateExportStatusRequest.getOrderId());
|
|
|
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
|
|
|
return ResultVOUtils.error(500, "单据已验收!");
|
|
|
}
|
|
|
if (updateExportStatusRequest.isEntrust() && updateExportStatusRequest.getEntrustId() != null) {
|
|
|
EntrustReceEntity entrustReceEntity = entrustReceService.findById(updateExportStatusRequest.getEntrustId());
|
|
|
if (entrustReceEntity == null) {
|
|
|
return ResultVOUtils.error(500, "无验收权限!");
|
|
|
} else {
|
|
|
|
|
|
if (orderEntity.getFromType().intValue() != ConstantStatus.FROM_CHANGE && orderEntity.getFromType().intValue() != ConstantStatus.FROM_PEACE_CHANGE) {
|
|
|
if (StrUtil.isNotEmpty(entrustReceEntity.getEntrustAction())) {
|
|
|
transferOrder(orderEntity, entrustReceEntity);
|
|
|
}
|
|
|
}
|
|
|
if (!entrustReceEntity.getFinishRece()) {
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO + orderEntity.getBillNo());
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
|
|
|
return ResultVOUtils.success("验收成功!");
|
|
|
} else {
|
|
|
return updateReview(authAdmin, orderEntity);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
return updateReview(authAdmin, orderEntity);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public void transferOrder(IoOrderEntity orderEntity, EntrustReceEntity entrustReceEntity) {
|
|
|
List<IoCodeEntity> warehouseEntities = codeService.findByOrderId(orderEntity.getBillNo());
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(entrustReceEntity.getEntrustAction());
|
|
|
IoOrderEntity supplementOrder = new IoOrderEntity();
|
|
|
BeanUtil.copyProperties(orderEntity, supplementOrder);
|
|
|
//生成补单单号
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
String supplementOrderNo = orderNo;
|
|
|
supplementOrder.setOriginUllageSupNo(orderEntity.getBillNo());
|
|
|
supplementOrder.setBillNo(supplementOrderNo);
|
|
|
supplementOrder.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); //设置导出状态为未导出
|
|
|
supplementOrder.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
|
supplementOrder.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
//修改往来单位及当前库存号
|
|
|
supplementOrder.setFromCorp(null);
|
|
|
supplementOrder.setFromDeptCode(orderEntity.getDeptCode());
|
|
|
supplementOrder.setFromInvCode(orderEntity.getInvCode());
|
|
|
supplementOrder.setDeptCode(entrustReceEntity.getEntrustDept());
|
|
|
supplementOrder.setInvCode(entrustReceEntity.getEntrustInv());
|
|
|
supplementOrder.setFromType(ConstantStatus.FROM_REVIEW);
|
|
|
supplementOrder.setMainAction(bussinessTypeEntity.getMainAction());
|
|
|
supplementOrder.setAction(bussinessTypeEntity.getAction());
|
|
|
orderEntity.setBusType(bussinessTypeEntity.getBusType());
|
|
|
//复制码表
|
|
|
List<IoCodeTempEntity> supplementCodes = new ArrayList<>();
|
|
|
warehouseEntities.forEach(
|
|
|
code -> {
|
|
|
IoCodeTempEntity supplementCode = new IoCodeTempEntity();
|
|
|
BeanUtil.copyProperties(code, supplementCode);
|
|
|
supplementCode.setInvCode(supplementOrder.getInvCode());
|
|
|
supplementCode.setDeptCode(supplementOrder.getDeptCode());
|
|
|
supplementCode.setOrderId(supplementOrderNo);
|
|
|
//查询补单设置
|
|
|
supplementCode.setAction(bussinessTypeEntity.getAction());
|
|
|
supplementCode.setMainAction(bussinessTypeEntity.getMainAction());
|
|
|
supplementCode.setId(null);
|
|
|
supplementCodes.add(supplementCode);
|
|
|
|
|
|
}
|
|
|
);
|
|
|
//更新数据
|
|
|
orderService.insertOrder(supplementOrder);
|
|
|
orderEntity.setUllageSupNo(supplementOrder.getBillNo());
|
|
|
orderService.update(orderEntity);
|
|
|
codeTempService.insertBatch(supplementCodes);
|
|
|
// for (IoCodeTempEntity codeTempEntity : supplementCodes) {
|
|
|
// addInoutService.genOrderDetailCode(supplementOrder, codeTempEntity);
|
|
|
// }
|
|
|
addInoutService.dealProcess(supplementOrder);
|
|
|
if (!ioCheckInoutService.checkManual(supplementOrder.getBillNo())) {
|
|
|
ioCheckInoutService.check(supplementOrder.getBillNo());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public int checkCodeExit(String code, List<IoCodeEntity> codesList) {
|
|
|
if (StrUtil.isNotEmpty(code)) {
|
|
|
code = code.replace("\r\n", "");
|
|
|
}
|
|
|
if (code.endsWith("\u001D")) {
|
|
|
code = code.replace("\u001D", "");
|
|
|
}
|
|
|
for (IoCodeEntity checkOrderCodesBean : codesList) {
|
|
|
String checkCode = checkOrderCodesBean.getCode();
|
|
|
if (checkCode.endsWith("\u001D")) {
|
|
|
checkCode = checkCode.replace("\u001D", "");
|
|
|
}
|
|
|
if (checkCode.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) {
|
|
|
// if (IntUtil.value(checkOrderCodesBean.getStatus()) == Constant.DB_CHECK_ED
|
|
|
// && IntUtil.value(checkOrderCodesBean.getReCount()) == checkOrderCodesBean.getScanCount()) {
|
|
|
// return Constant.CHECK_REPEAT;
|
|
|
// }
|
|
|
if (StrUtil.isNotEmpty(checkOrderCodesBean.getSerialNo())) {
|
|
|
if (checkOrderCodesBean.getScanCount() > 0) {
|
|
|
return Constant.CHECK_REPEAT;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int curCount = checkOrderCodesBean.getScanCount() + calCountUtil.getActCount(checkOrderCodesBean.getNameCode());
|
|
|
if (curCount == IntUtil.value(checkOrderCodesBean.getReCount())) {
|
|
|
checkOrderCodesBean.setStatus(Constant.DB_CHECK_ED);
|
|
|
}
|
|
|
checkOrderCodesBean.setScanCount(curCount);
|
|
|
return Constant.CHECK_EXIT;
|
|
|
}
|
|
|
}
|
|
|
return Constant.CHECK_NULL;
|
|
|
}
|
|
|
|
|
|
public IoCodeEntity isExit(List<IoCodeEntity> codeList, String code) {
|
|
|
if (CollUtil.isNotEmpty(codeList)) {
|
|
|
if (StrUtil.isNotEmpty(code)) {
|
|
|
code = code.replace("\r\n", "");
|
|
|
}
|
|
|
if (code.endsWith("\u001D")) {
|
|
|
code = code.replace("\u001D", "");
|
|
|
}
|
|
|
for (IoCodeEntity codeEntity : codeList) {
|
|
|
String checkCode = codeEntity.getCode();
|
|
|
if (checkCode.endsWith("\u001D")) {
|
|
|
checkCode = checkCode.replace("\u001D", "");
|
|
|
}
|
|
|
if (checkCode.equals(code)) {
|
|
|
return codeEntity;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
public boolean vailFinish(List<IoOrderDetailResultResponse> orderDetailResultResponses) {
|
|
|
if (CollUtil.isNotEmpty(orderDetailResultResponses)) {
|
|
|
for (IoOrderDetailResultResponse stockOrderDetailEntity : orderDetailResultResponses) {
|
|
|
if (stockOrderDetailEntity.getCount() != stockOrderDetailEntity.getAcceptCount()) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/udiwms/stock/order/acceptClear")
|
|
|
public BaseResponse acceptClear(@RequestBody AcceptOrderResponse acceptOrderEntity) {
|
|
|
String billNo = acceptOrderEntity.getBillNo();
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO + billNo);
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + billNo);
|
|
|
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
|
|
|
filterOrderDetailResultRequest.setOrderIdFk(billNo);
|
|
|
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
|
|
|
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
|
|
|
return ResultVOUtils.success(acceptOrderEntity);
|
|
|
}
|
|
|
|
|
|
|
|
|
public BaseResponse updateReview(AuthAdmin authAdmin, IoOrderEntity orderEntity) {
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_AUDITED);
|
|
|
orderEntity.setReviewUser(authAdmin.getId() + "");
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
orderEntity.setAuditTime(new Date());
|
|
|
orderService.update(orderEntity);
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO + orderEntity.getBillNo());
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
|
|
|
//验收完成->进入流程
|
|
|
ioCheckInoutService.checkSecond(orderEntity);
|
|
|
|
|
|
|
|
|
return ResultVOUtils.success("更新成功");
|
|
|
}
|
|
|
|
|
|
//前端第二次次验收
|
|
|
public BaseResponse thirdUpdateReview(AuthAdmin authAdmin, IoOrderEntity orderEntity) {
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK_REW);
|
|
|
orderEntity.setCheckUser(authAdmin.getId() + "");
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
orderEntity.setCheckTime(new Date());
|
|
|
orderEntity.setDeliveryStatus(ConstantStatus.ORDER_DELIVERY_STATUS_ED);
|
|
|
orderService.update(orderEntity);
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO + orderEntity.getBillNo());
|
|
|
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
|
|
|
//验收完成->进入流程
|
|
|
ioCheckInoutService.checkThird(orderEntity);
|
|
|
|
|
|
|
|
|
return ResultVOUtils.success("更新成功");
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 新增扫码验收单,本地不存在拉去自助平台待验收单
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/udiwms/order/reviewSpms")
|
|
|
public BaseResponse reviewSpms(@RequestBody ReviewSpmsRequest reviewSpmsRequest) {
|
|
|
|
|
|
String billNo = reviewSpmsRequest.getBillNo();
|
|
|
if (StrUtil.isEmpty(reviewSpmsRequest.getBillNo())) {
|
|
|
return ResultVOUtils.error(999, "请输入单据号!");
|
|
|
}
|
|
|
AcceptOrderResponse acceptOrderEntity = new AcceptOrderResponse();
|
|
|
Long userId = getUserId();
|
|
|
String errMsg = checkReviewAuth(billNo, userId + "");
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
if (errMsg.equals("委托验收")) {
|
|
|
acceptOrderEntity.setEntrust(true);
|
|
|
} else
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
}
|
|
|
|
|
|
acceptOrderEntity.setBillNo(billNo);
|
|
|
List<IoOrderDetailResultResponse> datas = (List<IoOrderDetailResultResponse>) redisUtil.get(ConstantStatus.REDIS_BILLNO + billNo);
|
|
|
IoOrderResponse orderResponse;
|
|
|
if (CollUtil.isNotEmpty(datas)) {
|
|
|
orderResponse = orderService.findGroupBillNo(billNo);
|
|
|
acceptOrderEntity.setOrderDetailEntities(datas);
|
|
|
acceptOrderEntity.setOrderEntity(orderResponse);
|
|
|
acceptOrderEntity.setExitAccept(true);
|
|
|
} else {
|
|
|
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
|
|
|
filterOrderDetailResultRequest.setOrderIdFk(billNo);
|
|
|
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
|
|
|
//本地已存在,则直接返回
|
|
|
if (CollUtil.isNotEmpty(orderDetailResultResponses)) {
|
|
|
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
|
|
|
orderResponse = orderService.findGroupBillNo(billNo);
|
|
|
acceptOrderEntity.setOrderEntity(orderResponse);
|
|
|
acceptOrderEntity.setExitAccept(false);
|
|
|
} else {
|
|
|
//获取自助平台待审核单据,并插入到数据库
|
|
|
BaseResponse<SpsSyncOrderResponse> baseResponse = spGetHttp.getReviewOrder(reviewSpmsRequest, userId + "");
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
SpsSyncOrderResponse spsSyncOrderResponse = baseResponse.getData();
|
|
|
List<IoOrderEntity> orderEntities = spsSyncOrderResponse.getOrderEntities();
|
|
|
if (CollUtil.isNotEmpty(orderEntities)) {
|
|
|
IoOrderEntity orderEntity;
|
|
|
orderEntity = orderEntities.get(0);
|
|
|
orderEntity.setUpdateTime(null);
|
|
|
orderEntity.setFromType(ConstantStatus.FROM_UDISP);
|
|
|
orderEntity.setReviewSp(true);
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
|
|
|
IoOrderEntity temp = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
if (temp == null) {
|
|
|
orderEntity.setId(null);
|
|
|
orderService.insertOrder(orderEntity);
|
|
|
heartService.insetOrderDb(spsSyncOrderResponse, orderEntity);
|
|
|
orderEntity = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
addInoutService.dealProcess(orderEntity);
|
|
|
orderEntity = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
if (orderEntity.getStatus() != ConstantStatus.ORDER_STATS_ERROR && !ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
}
|
|
|
}
|
|
|
FilterOrderDetailResultRequest tempRequest = new FilterOrderDetailResultRequest();
|
|
|
tempRequest.setOrderIdFk(billNo);
|
|
|
List<IoOrderDetailResultResponse> detailResultResponses = orderDetailResultService.filterList(tempRequest);
|
|
|
if (CollUtil.isNotEmpty(detailResultResponses)) {
|
|
|
acceptOrderEntity.setOrderDetailEntities(detailResultResponses);
|
|
|
acceptOrderEntity.setExitAccept(false);
|
|
|
orderResponse = orderService.findGroupBillNo(billNo);
|
|
|
acceptOrderEntity.setOrderEntity(orderResponse);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
return ResultVOUtils.error(500, baseResponse.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return ResultVOUtils.success(acceptOrderEntity);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 校验用户是否验收权限
|
|
|
*
|
|
|
* @param orderId
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
private String checkReviewAuth(String orderId, String userId) {
|
|
|
IoOrderEntity orderEntity = orderService.findByBillNo(orderId);
|
|
|
if (orderEntity == null) {
|
|
|
ReviewSpmsRequest reviewSpmsRequest = new ReviewSpmsRequest();
|
|
|
reviewSpmsRequest.setBillNo(orderId);
|
|
|
BaseResponse<IoOrderEntity> response = spGetHttp.getSimpleOrder(reviewSpmsRequest, userId);
|
|
|
if (response.getCode() == 20000 && response.getData() != null) {
|
|
|
orderEntity = response.getData();
|
|
|
} else {
|
|
|
return "单据不存在!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_CHECK_REW && orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
|
|
|
return "单据非未验收状态,无法审核!";
|
|
|
}
|
|
|
if (!invBusUserService.exitBus(userId, orderEntity.getAction())) {
|
|
|
EntrustReceEntity entrustReceEntity = entrustReceService.findByUnique(orderEntity.getAction(), Long.parseLong(userId));
|
|
|
if (entrustReceEntity == null) {
|
|
|
return "无验收权限!";
|
|
|
} else {
|
|
|
return "委托验收";
|
|
|
}
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//pda获取核对单据
|
|
|
|
|
|
/**
|
|
|
* PDA获取待核对单据
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/pda/order/check/getOrder")
|
|
|
public BaseResponse getPdaCheckOrder(PdaCheckRequest pdaCheckRequest) {
|
|
|
IoOrderResponse orderEntity = orderService.findGroupBillNo(pdaCheckRequest.getBillNo());
|
|
|
if (orderEntity == null) {
|
|
|
return ResultVOUtils.error(500, "单据不存在!");
|
|
|
}
|
|
|
boolean isExit = invBusUserService.exitBus(getUserId() + "", pdaCheckRequest.getAction());
|
|
|
if (!isExit) {
|
|
|
return ResultVOUtils.error(500, "无验收权限!");
|
|
|
}
|
|
|
return ResultVOUtils.success(orderEntity);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* PDA获取待核对单据-单据详情
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/pda/order/check/getOrderDetail")
|
|
|
public BaseResponse getPdaCheckOrderDetail(PdaCheckRequest pdaCheckRequest) {
|
|
|
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
|
|
|
filterOrderDetailResultRequest.setOrderIdFk(pdaCheckRequest.getBillNo());
|
|
|
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
|
|
|
return ResultVOUtils.success(orderDetailResultResponses);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* PDA获取待核对单据-单据条码明细
|
|
|
*/
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/pda/order/check/getCodes")
|
|
|
public BaseResponse getPdaCheckOrderCodes(PdaCheckRequest pdaCheckRequest) {
|
|
|
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
|
|
|
filterOrderDetailResultRequest.setOrderIdFk(pdaCheckRequest.getBillNo());
|
|
|
FilterCodeRequest filterCodeRequest = new FilterCodeRequest();
|
|
|
filterCodeRequest.setOrderId(pdaCheckRequest.getBillNo());
|
|
|
List<IoCodeResponse> codeResponses = codeService.filterList(filterCodeRequest);
|
|
|
return ResultVOUtils.success(codeResponses);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|