|
|
|
@ -1,16 +1,18 @@
|
|
|
|
|
package com.glxp.api.controller.purchase;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
|
import com.glxp.api.annotation.RepeatSubmit;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.entity.purchase.PurApplyEntity;
|
|
|
|
|
import com.glxp.api.entity.purchase.PurOrderDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.purchase.PurOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.purchase.PurPlanDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicCorpEntity;
|
|
|
|
|
import com.glxp.api.entity.inv.InvProductDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.purchase.*;
|
|
|
|
|
import com.glxp.api.req.inv.FilterInvProductDetailRequest;
|
|
|
|
|
import com.glxp.api.req.purchase.PostPurOrderRequest;
|
|
|
|
|
import com.glxp.api.req.purchase.PurOrderDetailRequest;
|
|
|
|
|
import com.glxp.api.req.purchase.PurOrderRequest;
|
|
|
|
@ -33,10 +35,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -81,7 +80,7 @@ public class PurOrderController {
|
|
|
|
|
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
PurOrderEntity purOrderEntity = postPurOrderRequest.getPurOrderEntity();
|
|
|
|
|
|
|
|
|
|
Long id=purOrderEntity.getId();
|
|
|
|
|
purOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
purOrderEntity.setCreateTime(new Date());
|
|
|
|
|
purOrderEntity.setUpdateTime(new Date());
|
|
|
|
@ -96,7 +95,29 @@ public class PurOrderController {
|
|
|
|
|
if (purOrderEntity.getId() == null) {
|
|
|
|
|
purOrderService.insert(purOrderEntity);
|
|
|
|
|
} else {
|
|
|
|
|
purOrderService.update(purOrderEntity);
|
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntityList = purOrderDetailService.findByOrderId(purOrderEntity.getId() + "");
|
|
|
|
|
//判断是不是存在同一个供应商产品
|
|
|
|
|
Map<String, List<PurOrderDetailEntity>> purOrderDetailMap = purOrderDetailEntityList.stream().collect(Collectors.groupingBy(PurOrderDetailEntity::getSupId));
|
|
|
|
|
if (purOrderDetailMap.size() > 1) {
|
|
|
|
|
for (String key : purOrderDetailMap.keySet()) {
|
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailMap.get(key);
|
|
|
|
|
PurOrderEntity purOrderEntity1 = new PurOrderEntity();
|
|
|
|
|
purOrderEntity1 = purOrderEntity;
|
|
|
|
|
purOrderEntity1.setId(null);
|
|
|
|
|
purOrderEntity1.setSupId(key);
|
|
|
|
|
purOrderEntity1.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
|
|
|
|
|
purOrderService.insert(purOrderEntity1);
|
|
|
|
|
for (PurOrderDetailEntity purOrderDetailEntity : purOrderDetailEntities) {
|
|
|
|
|
purOrderDetailEntity.setId(null);
|
|
|
|
|
purOrderDetailEntity.setOrderIdFk(purOrderEntity1.getId() + "");
|
|
|
|
|
}
|
|
|
|
|
purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailMap.get(key));
|
|
|
|
|
}
|
|
|
|
|
purOrderService.deleteById(id);
|
|
|
|
|
purOrderDetailService.deleteByOrderId(id + "");
|
|
|
|
|
} else {
|
|
|
|
|
purOrderService.update(purOrderEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
@ -367,6 +388,11 @@ public class PurOrderController {
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
@PostMapping("/purchase/order/updateDetail")
|
|
|
|
|
public BaseResponse detailEdit(@RequestBody PurOrderDetailEntity purOrderDetailEntity) {
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(purOrderDetailEntity.getSupId())) {
|
|
|
|
|
purOrderDetailEntity.setSupId(purOrderDetailEntity.getSupName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
purOrderDetailService.update(purOrderDetailEntity);
|
|
|
|
|
return ResultVOUtils.success("修改成功");
|
|
|
|
|
}
|
|
|
|
@ -384,4 +410,17 @@ public class PurOrderController {
|
|
|
|
|
return ResultVOUtils.success("删除成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询产品供应商
|
|
|
|
|
*
|
|
|
|
|
* @param purOrderDetailEntity
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/purchase/order/filterSupList")
|
|
|
|
|
public BaseResponse filterSupList(@RequestBody PurOrderDetailEntity purOrderDetailEntity) {
|
|
|
|
|
|
|
|
|
|
List<BasicCorpEntity> selectsupList = purOrderDetailService.selectsupList(purOrderDetailEntity);
|
|
|
|
|
return ResultVOUtils.success(selectsupList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|