|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.annotation.RepeatSubmit;
|
|
|
|
import com.glxp.api.annotation.RepeatSubmit;
|
|
|
|
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
@ -16,20 +17,28 @@ import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
import com.glxp.api.entity.purchase.*;
|
|
|
|
import com.glxp.api.entity.purchase.*;
|
|
|
|
import com.glxp.api.req.purchase.*;
|
|
|
|
import com.glxp.api.req.purchase.PostPurDeliveryRequest;
|
|
|
|
|
|
|
|
import com.glxp.api.req.purchase.PurDeliveryRequest;
|
|
|
|
|
|
|
|
import com.glxp.api.req.purchase.PurOrderDetailRequest;
|
|
|
|
|
|
|
|
import com.glxp.api.req.purchase.ReviewDeliveryOrderRequest;
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
|
|
|
import com.glxp.api.res.purchase.PurDeliveryAcceptOrderResponse;
|
|
|
|
import com.glxp.api.res.purchase.PurDeliveryDetailResponse;
|
|
|
|
import com.glxp.api.res.purchase.PurDeliveryDetailResponse;
|
|
|
|
import com.glxp.api.res.purchase.PurDeliveryResponse;
|
|
|
|
import com.glxp.api.res.purchase.PurDeliveryResponse;
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
|
|
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
|
|
|
|
import com.glxp.api.service.purchase.PurDeliveryCodeService;
|
|
|
|
import com.glxp.api.service.purchase.PurDeliveryDetailService;
|
|
|
|
import com.glxp.api.service.purchase.PurDeliveryDetailService;
|
|
|
|
import com.glxp.api.service.purchase.PurDeliveryService;
|
|
|
|
import com.glxp.api.service.purchase.PurDeliveryService;
|
|
|
|
import com.glxp.api.service.purchase.PurOrderDetailService;
|
|
|
|
import com.glxp.api.service.purchase.PurOrderDetailService;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
|
|
|
import com.glxp.api.util.RedisUtil;
|
|
|
|
|
|
|
|
import com.glxp.api.util.udi.UdiCalCountUtil;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@ -38,7 +47,10 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Validated
|
|
|
|
@Validated
|
|
|
@ -46,13 +58,10 @@ import java.util.stream.Collectors;
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
public class PurDeliveryController extends BaseController {
|
|
|
|
public class PurDeliveryController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
PurDeliveryService purDeliveryService;
|
|
|
|
PurDeliveryService purDeliveryService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
PurDeliveryDetailService purDeliveryDetailService;
|
|
|
|
PurDeliveryDetailService purDeliveryDetailService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
CustomerService customerService;
|
|
|
|
CustomerService customerService;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -63,6 +72,14 @@ public class PurDeliveryController extends BaseController {
|
|
|
|
IoOrderDetailBizService ioOrderDetailBizService;
|
|
|
|
IoOrderDetailBizService ioOrderDetailBizService;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private PurDeliveryCodeService purDeliveryCodeService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private UdiRelevanceService udiRelevanceService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private UdiCalCountUtil calCountUtil;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 新增到货单
|
|
|
|
* 新增到货单
|
|
|
@ -228,6 +245,127 @@ public class PurDeliveryController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 拉取审核单据详情
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param purOrderDetailRequest
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GetMapping("/purchase/delivery/list/getAcceptOrder")
|
|
|
|
|
|
|
|
public BaseResponse getAcceptOrder(PurOrderDetailRequest purOrderDetailRequest) {
|
|
|
|
|
|
|
|
if (null == purOrderDetailRequest && StrUtil.isBlank(purOrderDetailRequest.getOrderIdFk())) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PurDeliveryAcceptOrderResponse response = new PurDeliveryAcceptOrderResponse();
|
|
|
|
|
|
|
|
response.setBillNo(purOrderDetailRequest.getBillNo());
|
|
|
|
|
|
|
|
List<PurDeliveryDetailResponse> list = redisUtil.getList(ConstantStatus.REDIS_DELIVERY_BILLNO + purOrderDetailRequest.getBillNo(), PurDeliveryDetailResponse.class);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
|
|
|
response.setOrderDetails(list);
|
|
|
|
|
|
|
|
response.setExitAccept(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
List<PurDeliveryDetailResponse> deliveryDetailResponses = purDeliveryDetailService.joinQueryList(purOrderDetailRequest);
|
|
|
|
|
|
|
|
response.setOrderDetails(deliveryDetailResponses);
|
|
|
|
|
|
|
|
response.setExitAccept(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultVOUtils.success(response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 送货单验收扫码接口
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param acceptOrderResponse
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping("/purchase/delivery/list/acceptAddCode")
|
|
|
|
|
|
|
|
public BaseResponse acceptAddCode(@RequestBody PurDeliveryAcceptOrderResponse acceptOrderResponse) {
|
|
|
|
|
|
|
|
PurDeliveryEntity purDeliveryEntity = purDeliveryService.findByBillNo(acceptOrderResponse.getBillNo());
|
|
|
|
|
|
|
|
if (null == purDeliveryEntity) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(500, "此送货单不存在!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<PurDeliveryCodeEntity> codeList;
|
|
|
|
|
|
|
|
List<PurDeliveryCodeEntity> codeEntityList = redisUtil.getList(ConstantStatus.REDIS_DELIVERY_CODES + acceptOrderResponse.getBillNo(), PurDeliveryCodeEntity.class);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(codeEntityList)) {
|
|
|
|
|
|
|
|
codeList = purDeliveryCodeService.findByOrderId(acceptOrderResponse.getBillNo());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
codeList = codeEntityList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String relId = udiRelevanceService.getRelIdByUdiCode(acceptOrderResponse.getCode());
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(relId)) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(500, "非此单UDI码");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
int status = purDeliveryCodeService.isExist(acceptOrderResponse.getOrderIdFk(), relId);
|
|
|
|
|
|
|
|
if (status == Constant.CHECK_NULL) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(500, "非此单UDI码");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PurDeliveryDetailResponse> orderDetails = acceptOrderResponse.getOrderDetails();
|
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(acceptOrderResponse.getCode()) && CollUtil.isNotEmpty(orderDetails)) {
|
|
|
|
|
|
|
|
boolean isExist = false;
|
|
|
|
|
|
|
|
for (PurDeliveryDetailResponse orderDetail : orderDetails) {
|
|
|
|
|
|
|
|
if (orderDetail.getProductId().equals(relId)) {
|
|
|
|
|
|
|
|
orderDetail.setAcceptCount(orderDetail.getAcceptCount() + calCountUtil.getActCountByRelId(relId));
|
|
|
|
|
|
|
|
if (orderDetail.getAcceptCount() > orderDetail.getCount()) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(500, "数量溢出!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
purDeliveryCodeService.addCode(acceptOrderResponse.getBillNo(), orderDetail, acceptOrderResponse.getCode());
|
|
|
|
|
|
|
|
isExist = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isExist) {
|
|
|
|
|
|
|
|
redisUtil.set(ConstantStatus.REDIS_DELIVERY_BILLNO + acceptOrderResponse.getBillNo(), acceptOrderResponse);
|
|
|
|
|
|
|
|
redisUtil.set(ConstantStatus.REDIS_DELIVERY_CODES + acceptOrderResponse.getBillNo(), codeList);
|
|
|
|
|
|
|
|
acceptOrderResponse.setOrderDetails(orderDetails);
|
|
|
|
|
|
|
|
if (purOrderDetailService.vailFinish(orderDetails)) {
|
|
|
|
|
|
|
|
acceptOrderResponse.setFinishAccept(true);
|
|
|
|
|
|
|
|
return ResultVOUtils.success(acceptOrderResponse);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResultVOUtils.success(acceptOrderResponse);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultVOUtils.error(500, "非此单UDI码!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 送货单 - 重新验收接口
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param acceptOrderResponse
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping("/purchase/delivery/list/acceptClear")
|
|
|
|
|
|
|
|
public BaseResponse acceptClear(@RequestBody PurDeliveryAcceptOrderResponse acceptOrderResponse) {
|
|
|
|
|
|
|
|
String billNo = acceptOrderResponse.getBillNo();
|
|
|
|
|
|
|
|
redisUtil.del(ConstantStatus.REDIS_DELIVERY_BILLNO + billNo);
|
|
|
|
|
|
|
|
redisUtil.del(ConstantStatus.REDIS_DELIVERY_CODES + billNo);
|
|
|
|
|
|
|
|
PurOrderDetailRequest purOrderDetailRequest = new PurOrderDetailRequest();
|
|
|
|
|
|
|
|
purOrderDetailRequest.setOrderIdFk(acceptOrderResponse.getOrderIdFk());
|
|
|
|
|
|
|
|
List<PurDeliveryDetailResponse> deliveryDetailResponses = purDeliveryDetailService.joinQueryList(purOrderDetailRequest);
|
|
|
|
|
|
|
|
acceptOrderResponse.setOrderDetails(deliveryDetailResponses);
|
|
|
|
|
|
|
|
return ResultVOUtils.success(acceptOrderResponse);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 完成验收接口
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param reviewFinishRequest
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping("/purchase/delivery/list/updateStatus")
|
|
|
|
|
|
|
|
public BaseResponse updateStatus(@RequestBody ReviewDeliveryOrderRequest reviewFinishRequest) {
|
|
|
|
|
|
|
|
if (null == reviewFinishRequest && StrUtil.isBlank(reviewFinishRequest.getBillNo())) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!reviewFinishRequest.isFinishAccept()) {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(500, "未完成验收");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PurDeliveryEntity purDeliveryEntity = purDeliveryService.findByBillNo(reviewFinishRequest.getBillNo());
|
|
|
|
|
|
|
|
return purDeliveryService.updateReview(purDeliveryEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 添加产品到采购单里面
|
|
|
|
* 添加产品到采购单里面
|
|
|
@ -310,8 +448,6 @@ public class PurDeliveryController extends BaseController {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping("/purchase/delivery/addPlanDetailAndOrder")
|
|
|
|
@PostMapping("/purchase/delivery/addPlanDetailAndOrder")
|
|
|
|
public BaseResponse addPlanDetailAndOrder(@RequestBody PurDeliveryRequest purDeliveryRequest) {
|
|
|
|
public BaseResponse addPlanDetailAndOrder(@RequestBody PurDeliveryRequest purDeliveryRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purDeliveryRequest.getPurOrderId() + "");
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purDeliveryRequest.getPurOrderId() + "");
|
|
|
|
List<PurDeliveryDetailEntity> purDeliveryDetailEntities = purOrderDetailEntities.stream()
|
|
|
|
List<PurDeliveryDetailEntity> purDeliveryDetailEntities = purOrderDetailEntities.stream()
|
|
|
|
.map(e -> {
|
|
|
|
.map(e -> {
|
|
|
@ -327,7 +463,6 @@ public class PurDeliveryController extends BaseController {
|
|
|
|
if (falg) {
|
|
|
|
if (falg) {
|
|
|
|
//查询申购单
|
|
|
|
//查询申购单
|
|
|
|
return ResultVOUtils.success("添加成功");
|
|
|
|
return ResultVOUtils.success("添加成功");
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return ResultVOUtils.success("添加失败");
|
|
|
|
return ResultVOUtils.success("添加失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|