Commit efb984645625881491a554f721052302a27857e5

Authored by 杨鸣坤
1 parent 0c26f571

楚江ERP:补货单接口完善

... ... @@ -37,18 +37,36 @@ public class GetReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
37 37 private String workshopId;
38 38
39 39 /**
  40 + * 分厂名称
  41 + */
  42 + @ApiModelProperty("分厂名称")
  43 + private String workshopName;
  44 +
  45 + /**
40 46 * 办事处
41 47 */
42 48 @ApiModelProperty("办事处")
43 49 private String deptId;
44 50
45 51 /**
  52 + * 办事处名称
  53 + */
  54 + @ApiModelProperty("办事处名称")
  55 + private String deptName;
  56 +
  57 + /**
46 58 * 购货单位
47 59 */
48 60 @ApiModelProperty("购货单位")
49 61 private String customerId;
50 62
51 63 /**
  64 + * 购货单位名称
  65 + */
  66 + @ApiModelProperty("购货单位名称")
  67 + private String customerName;
  68 +
  69 + /**
52 70 * 原计划发货日期
53 71 */
54 72 @ApiModelProperty("原计划发货日期")
... ... @@ -62,6 +80,24 @@ public class GetReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
62 80 private String purchaseOrderId;
63 81
64 82 /**
  83 + * 订货单名称
  84 + */
  85 + @ApiModelProperty("订货单名称")
  86 + private String purchaseOrderName;
  87 +
  88 + /**
  89 + * 状态
  90 + */
  91 + @ApiModelProperty("状态")
  92 + private String status;
  93 +
  94 + /**
  95 + * 状态名称
  96 + */
  97 + @ApiModelProperty("状态名称")
  98 + private String statusName;
  99 +
  100 + /**
65 101 * 补货单物料行
66 102 */
67 103 @ApiModelProperty("补货单物料行")
... ...
... ... @@ -8,7 +8,6 @@ import io.swagger.annotations.ApiModelProperty;
8 8 import lombok.Data;
9 9
10 10 import java.time.LocalDate;
11   -import java.time.LocalDateTime;
12 11
13 12 /**
14 13 * <p>
... ... @@ -37,18 +36,36 @@ public class QueryReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
37 36 private String workshopId;
38 37
39 38 /**
  39 + * 分厂名称
  40 + */
  41 + @ApiModelProperty("分厂名称")
  42 + private String workshopName;
  43 +
  44 + /**
40 45 * 办事处
41 46 */
42 47 @ApiModelProperty("办事处")
43 48 private String deptId;
44 49
45 50 /**
  51 + * 办事处名称
  52 + */
  53 + @ApiModelProperty("办事处名称")
  54 + private String deptName;
  55 +
  56 + /**
46 57 * 购货单位
47 58 */
48 59 @ApiModelProperty("购货单位")
49 60 private String customerId;
50 61
51 62 /**
  63 + * 购货单位名称
  64 + */
  65 + @ApiModelProperty("购货单位名称")
  66 + private String customerName;
  67 +
  68 + /**
52 69 * 原计划发货日期
53 70 */
54 71 @ApiModelProperty("原计划发货日期")
... ... @@ -62,11 +79,23 @@ public class QueryReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
62 79 private String status;
63 80
64 81 /**
65   - * 创建时间
  82 + * 状态名称
  83 + */
  84 + @ApiModelProperty("状态名称")
  85 + private String statusName;
  86 +
  87 + /**
  88 + * 申请日期
  89 + */
  90 + @ApiModelProperty("申请日期")
  91 + @JsonFormat(pattern = StringPool.DATE_PATTERN)
  92 + private LocalDate applicationDate;
  93 +
  94 + /**
  95 + * 是否展示审核按钮(非持久化字段)
66 96 */
67   - @ApiModelProperty("创建时间")
68   - @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
69   - private LocalDateTime createTime;
  97 + @ApiModelProperty("是否展示审核按钮(非持久化字段)")
  98 + private Boolean showExamine;
70 99
71 100 public QueryReplenishmentOrderBo() {
72 101
... ...
1 1 package com.lframework.xingyun.sc.controller.purchase;
2 2
  3 +import com.baomidou.mybatisplus.core.conditions.Wrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
3 5 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
4 6 import com.lframework.starter.common.utils.CollectionUtil;
5 7 import com.lframework.starter.web.core.annotations.security.HasPermission;
... ... @@ -8,9 +10,22 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
8 10 import com.lframework.starter.web.core.components.resp.PageResult;
9 11 import com.lframework.starter.web.core.controller.DefaultBaseController;
10 12 import com.lframework.starter.web.core.utils.PageResultUtil;
  13 +import com.lframework.starter.web.inner.entity.SysDataDicItem;
  14 +import com.lframework.starter.web.inner.entity.SysDept;
  15 +import com.lframework.starter.web.inner.service.system.SysDataDicItemService;
  16 +import com.lframework.starter.web.inner.service.system.SysDeptService;
  17 +import com.lframework.xingyun.basedata.entity.Customer;
  18 +import com.lframework.xingyun.basedata.entity.Workshop;
  19 +import com.lframework.xingyun.basedata.service.customer.CustomerService;
  20 +import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
11 21 import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderBo;
  22 +import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderLineBo;
12 23 import com.lframework.xingyun.sc.bo.purchase.QueryReplenishmentOrderBo;
  24 +import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
13 25 import com.lframework.xingyun.sc.entity.ReplenishmentOrder;
  26 +import com.lframework.xingyun.sc.entity.ReplenishmentOrderLine;
  27 +import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
  28 +import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderLineService;
14 29 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService;
15 30 import com.lframework.xingyun.sc.vo.purchase.CreateReplenishmentOrderVo;
16 31 import com.lframework.xingyun.sc.vo.purchase.QueryReplenishmentOrderVo;
... ... @@ -18,13 +33,18 @@ import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo;
18 33 import io.swagger.annotations.Api;
19 34 import io.swagger.annotations.ApiImplicitParam;
20 35 import io.swagger.annotations.ApiOperation;
21   -import org.springframework.beans.factory.annotation.Autowired;
  36 +import org.apache.commons.collections4.CollectionUtils;
  37 +import org.apache.commons.lang3.StringUtils;
22 38 import org.springframework.validation.annotation.Validated;
23 39 import org.springframework.web.bind.annotation.*;
24 40
  41 +import javax.annotation.Resource;
25 42 import javax.validation.Valid;
26 43 import javax.validation.constraints.NotBlank;
  44 +import java.util.ArrayList;
27 45 import java.util.List;
  46 +import java.util.Map;
  47 +import java.util.function.Function;
28 48 import java.util.stream.Collectors;
29 49
30 50 /**
... ... @@ -33,11 +53,26 @@ import java.util.stream.Collectors;
33 53 @Api(tags = "补货单")
34 54 @Validated
35 55 @RestController
36   -@RequestMapping("/purchase/replenishmentorder")
  56 +@RequestMapping("/purchase/replenishmentOrder")
37 57 public class ReplenishmentOrderController extends DefaultBaseController {
38 58
39   - @Autowired
  59 + @Resource
40 60 private ReplenishmentOrderService replenishmentOrderService;
  61 + @Resource
  62 + private SysDeptService sysDeptService;
  63 + @Resource
  64 + private CustomerService customerService;
  65 + @Resource
  66 + private SysDataDicItemService sysDataDicItemService;
  67 + @Resource
  68 + private WorkshopService workshopService;
  69 + @Resource
  70 + private PurchaseOrderInfoService purchaseOrderInfoService;
  71 + @Resource
  72 + private ReplenishmentOrderLineService replenishmentOrderLineService;
  73 +
  74 +
  75 + public static final String AUDIT_STATUS_DIC_CODE = "AUDIT_STATUS"; // 审核状态
41 76
42 77 /**
43 78 * 查询列表
... ... @@ -56,7 +91,55 @@ public class ReplenishmentOrderController extends DefaultBaseController {
56 91 results = datas.stream().map(QueryReplenishmentOrderBo::new).collect(Collectors.toList());
57 92 }
58 93
59   - return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
  94 + PageResult<QueryReplenishmentOrderBo> boPageResult = PageResultUtil.rebuild(pageResult, results);
  95 + if (CollectionUtils.isEmpty(boPageResult.getDatas())) {
  96 + return InvokeResultBuilder.success(boPageResult);
  97 + }
  98 +
  99 + List<QueryReplenishmentOrderBo> boList = boPageResult.getDatas();
  100 + List<String> deptIdList = boList.stream().map(QueryReplenishmentOrderBo::getDeptId).collect(Collectors.toList());
  101 + Map<String, SysDept> sysDeptMap = CollectionUtils.emptyIfNull(sysDeptService.listByIds(deptIdList))
  102 + .stream()
  103 + .collect(Collectors.toMap(SysDept::getId, Function.identity()));
  104 + List<String> workshopIdList = boList.stream().map(QueryReplenishmentOrderBo::getWorkshopId).collect(Collectors.toList());
  105 + Map<String, Workshop> workshopMap = CollectionUtils.emptyIfNull(workshopService.listByIds(workshopIdList))
  106 + .stream()
  107 + .collect(Collectors.toMap(Workshop::getId, Function.identity()));
  108 + List<String> customerIdList = boList.stream().map(QueryReplenishmentOrderBo::getCustomerId).collect(Collectors.toList());
  109 + Map<String, Customer> customerMap = CollectionUtils.emptyIfNull(customerService.listByIds(customerIdList))
  110 + .stream()
  111 + .collect(Collectors.toMap(Customer::getId, Function.identity()));
  112 + List<SysDataDicItem> sysDataDicItemList = sysDataDicItemService.findByDicCode(AUDIT_STATUS_DIC_CODE);
  113 + Map<String, String> auditCodeAndNameMap = CollectionUtils.emptyIfNull(sysDataDicItemList)
  114 + .stream()
  115 + .collect(Collectors.toMap(SysDataDicItem::getCode, SysDataDicItem::getName));
  116 + boList.forEach(queryReplenishmentOrderBo -> {
  117 + if (queryReplenishmentOrderBo == null) {
  118 + return;
  119 + }
  120 +
  121 + if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getDeptId())) {
  122 + SysDept sysDept = sysDeptMap.get(queryReplenishmentOrderBo.getDeptId());
  123 + queryReplenishmentOrderBo.setDeptName(sysDept == null ? "" : sysDept.getName());
  124 + }
  125 +
  126 + if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getCustomerId())) {
  127 + Customer customer = customerMap.get(queryReplenishmentOrderBo.getCustomerId());
  128 + queryReplenishmentOrderBo.setCustomerName(customer == null ? "" : customer.getName());
  129 + }
  130 +
  131 + if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getWorkshopId())) {
  132 + Workshop workshop = workshopMap.get(queryReplenishmentOrderBo.getWorkshopId());
  133 + queryReplenishmentOrderBo.setWorkshopName(workshop == null ? "" : workshop.getName());
  134 + }
  135 +
  136 + if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getStatus())) {
  137 + queryReplenishmentOrderBo.setStatusName(auditCodeAndNameMap.get(queryReplenishmentOrderBo.getStatus()));
  138 + }
  139 + });
  140 +
  141 + boPageResult.setDatas(boList);
  142 + return InvokeResultBuilder.success(boPageResult);
60 143 }
61 144
62 145 /**
... ... @@ -74,7 +157,32 @@ public class ReplenishmentOrderController extends DefaultBaseController {
74 157 }
75 158
76 159 GetReplenishmentOrderBo result = new GetReplenishmentOrderBo(data);
  160 + SysDept sysDept = sysDeptService.findById(data.getDeptId());
  161 + result.setDeptName(sysDept == null ? "" : sysDept.getName());
  162 + Workshop workshop = workshopService.findById(data.getWorkshopId());
  163 + result.setWorkshopName(workshop == null ? "" : workshop.getName());
  164 + Customer customer = customerService.findById(data.getCustomerId());
  165 + result.setCustomerName(customer == null ? "" : customer.getName());
  166 + SysDataDicItem sysDataDicItem = sysDataDicItemService.findByCode(AUDIT_STATUS_DIC_CODE, data.getStatus());
  167 + result.setStatusName(sysDataDicItem == null ? "" : sysDataDicItem.getName());
  168 + PurchaseOrderInfo purchaseOrderInfo = purchaseOrderInfoService.findById(data.getPurchaseOrderId());
  169 + result.setPurchaseOrderName(purchaseOrderInfo == null ? "" : purchaseOrderInfo.getOrderNo());
  170 +
  171 + Wrapper<ReplenishmentOrderLine> lineWrapper = Wrappers.lambdaQuery(ReplenishmentOrderLine.class)
  172 + .eq(ReplenishmentOrderLine::getReplenishmentOrderId, id)
  173 + .orderByAsc(ReplenishmentOrderLine::getShowOrder);
  174 + List<ReplenishmentOrderLine> replenishmentOrderLineList = replenishmentOrderLineService.list(lineWrapper);
  175 + if (CollectionUtils.isEmpty(replenishmentOrderLineList)) {
  176 + throw new DefaultClientException("补货单物料行为空!");
  177 + }
  178 +
  179 + List<GetReplenishmentOrderLineBo> lineBoList = new ArrayList<>(replenishmentOrderLineList.size());
  180 + replenishmentOrderLineList.forEach(replenishmentOrderLine -> {
  181 + GetReplenishmentOrderLineBo replenishmentOrderLineBo = new GetReplenishmentOrderLineBo(replenishmentOrderLine);
  182 + lineBoList.add(replenishmentOrderLineBo);
  183 + });
77 184
  185 + result.setReplenishmentOrderLineList(lineBoList);
78 186 return InvokeResultBuilder.success(result);
79 187 }
80 188
... ...
... ... @@ -100,7 +100,13 @@ public class ReplenishmentOrder extends BaseEntity implements BaseDto {
100 100 private LocalDateTime updateTime;
101 101
102 102 /**
103   - * 是否展示正式合同审核按钮(非持久化字段)
  103 + * 申请日期
  104 + */
  105 + @TableField(exist = false)
  106 + private LocalDate applicationDate;
  107 +
  108 + /**
  109 + * 是否展示审核按钮(非持久化字段)
104 110 */
105 111 @TableField(exist = false)
106 112 private Boolean showExamine;
... ...
... ... @@ -63,12 +63,11 @@ public class ReplenishmentOrderServiceImpl extends BaseMpServiceImpl<Replenishme
63 63 if (CollectionUtils.isNotEmpty(datas)) {
64 64 // 获取当前人员的待办任务数据
65 65 List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
66   - if (CollectionUtils.isNotEmpty(flowTaskList)) {
67   - List<String> businessIds = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
68   - datas.forEach(replenishmentOrder -> {
69   - replenishmentOrder.setShowExamine(businessIds.contains(replenishmentOrder.getId()));
70   - });
71   - }
  66 + List<String> businessIds = CollectionUtils.emptyIfNull(flowTaskList).stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  67 + datas.forEach(replenishmentOrder -> {
  68 + replenishmentOrder.setShowExamine(businessIds.contains(replenishmentOrder.getId()));
  69 + replenishmentOrder.setApplicationDate(replenishmentOrder.getCreateTime().toLocalDate());
  70 + });
72 71 }
73 72
74 73 return PageResultUtil.convert(new PageInfo<>(datas));
... ...