|
|
|
@ -10,6 +10,8 @@ import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.controller.BaseController;
|
|
|
|
|
import com.glxp.api.entity.auth.InvWarehouseEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
@ -22,6 +24,7 @@ import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.purchase.PurArrivalDetailResponse;
|
|
|
|
|
import com.glxp.api.res.purchase.PurArrivalResponse;
|
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
|
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
|
import com.glxp.api.service.purchase.PurArrivalDetailService;
|
|
|
|
@ -47,7 +50,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Validated
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@RestController
|
|
|
|
|
public class PurArrivalController {
|
|
|
|
|
public class PurArrivalController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@ -65,6 +68,8 @@ public class PurArrivalController {
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailBizService ioOrderDetailBizService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增到货单
|
|
|
|
@ -74,7 +79,7 @@ public class PurArrivalController {
|
|
|
|
|
@PostMapping("/purchase/arrival/postOrder")
|
|
|
|
|
public BaseResponse postOrder(@RequestBody PostPurArrivalRequest purArrivalRequest) {
|
|
|
|
|
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
Long userId = getUserId();
|
|
|
|
|
PurArrivalEntity purArrivalEntity = purArrivalRequest.getPurArrivalEntity();
|
|
|
|
|
|
|
|
|
|
purArrivalEntity.setCreateUser(userId + "");
|
|
|
|
@ -82,12 +87,13 @@ public class PurArrivalController {
|
|
|
|
|
purArrivalEntity.setUpdateTime(new Date());
|
|
|
|
|
purArrivalEntity.setUpdateUser(userId + "");
|
|
|
|
|
purArrivalEntity.setStatus(purArrivalRequest.getEditStatus()); //草稿状态
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(purArrivalEntity.getInvCode());
|
|
|
|
|
purArrivalEntity.setDeptCode(invWarehouseEntity.getParentId());
|
|
|
|
|
|
|
|
|
|
if (purArrivalRequest.getType() != null) {
|
|
|
|
|
String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.SH_ORDER, "yyyyMMdd"));
|
|
|
|
|
String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.DH_ORDER, "yyyyMMdd"));
|
|
|
|
|
purArrivalEntity.setBillNo(billNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (purArrivalEntity.getId() == null) {
|
|
|
|
|
purArrivalService.insert(purArrivalEntity);
|
|
|
|
|
} else {
|
|
|
|
@ -154,13 +160,16 @@ public class PurArrivalController {
|
|
|
|
|
String billNo = "";
|
|
|
|
|
List<PurArrivalDetailEntity> purOrderDetailEntities = purArrivalDetailService.findByOrderId(purArrivalEntity.getId() + "");
|
|
|
|
|
|
|
|
|
|
//对计划单里面的供应商进行分组
|
|
|
|
|
Map<String, List<PurArrivalDetailEntity>> map = purOrderDetailEntities.stream().collect(Collectors.groupingBy(PurArrivalDetailEntity::getSupId));
|
|
|
|
|
|
|
|
|
|
if (postPurArrivalRequest.getEditStatus() == ConstantStatus.APPLY_AUDIT_ED) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(purOrderDetailEntities) && postPurArrivalRequest.isAutoPurchase() == true
|
|
|
|
|
&& StrUtil.isNotEmpty(postPurArrivalRequest.getTargetSubInv()) && StrUtil.isNotEmpty(postPurArrivalRequest.getTargetBillAction())) {
|
|
|
|
|
//对计划单里面的供应商进行分组
|
|
|
|
|
Map<String, List<PurArrivalDetailEntity>> map = purOrderDetailEntities.stream().collect(Collectors.groupingBy(PurArrivalDetailEntity::getSupId));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<PurArrivalDetailEntity>> m : map.entrySet()) {
|
|
|
|
|
//生产单据表信息
|
|
|
|
|