Commit a5987b6677ff8bedbde3749996bb2ad76dfdd48f

Authored by yeqianyong
2 parents d9823f41 efb98464

Merge remote-tracking branch 'origin/master_0929' into master_0929

@@ -37,18 +37,36 @@ public class GetReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> { @@ -37,18 +37,36 @@ public class GetReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
37 private String workshopId; 37 private String workshopId;
38 38
39 /** 39 /**
  40 + * 分厂名称
  41 + */
  42 + @ApiModelProperty("分厂名称")
  43 + private String workshopName;
  44 +
  45 + /**
40 * 办事处 46 * 办事处
41 */ 47 */
42 @ApiModelProperty("办事处") 48 @ApiModelProperty("办事处")
43 private String deptId; 49 private String deptId;
44 50
45 /** 51 /**
  52 + * 办事处名称
  53 + */
  54 + @ApiModelProperty("办事处名称")
  55 + private String deptName;
  56 +
  57 + /**
46 * 购货单位 58 * 购货单位
47 */ 59 */
48 @ApiModelProperty("购货单位") 60 @ApiModelProperty("购货单位")
49 private String customerId; 61 private String customerId;
50 62
51 /** 63 /**
  64 + * 购货单位名称
  65 + */
  66 + @ApiModelProperty("购货单位名称")
  67 + private String customerName;
  68 +
  69 + /**
52 * 原计划发货日期 70 * 原计划发货日期
53 */ 71 */
54 @ApiModelProperty("原计划发货日期") 72 @ApiModelProperty("原计划发货日期")
@@ -62,6 +80,24 @@ public class GetReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> { @@ -62,6 +80,24 @@ public class GetReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
62 private String purchaseOrderId; 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 @ApiModelProperty("补货单物料行") 103 @ApiModelProperty("补货单物料行")
@@ -8,7 +8,6 @@ import io.swagger.annotations.ApiModelProperty; @@ -8,7 +8,6 @@ import io.swagger.annotations.ApiModelProperty;
8 import lombok.Data; 8 import lombok.Data;
9 9
10 import java.time.LocalDate; 10 import java.time.LocalDate;
11 -import java.time.LocalDateTime;  
12 11
13 /** 12 /**
14 * <p> 13 * <p>
@@ -37,18 +36,36 @@ public class QueryReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> { @@ -37,18 +36,36 @@ public class QueryReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
37 private String workshopId; 36 private String workshopId;
38 37
39 /** 38 /**
  39 + * 分厂名称
  40 + */
  41 + @ApiModelProperty("分厂名称")
  42 + private String workshopName;
  43 +
  44 + /**
40 * 办事处 45 * 办事处
41 */ 46 */
42 @ApiModelProperty("办事处") 47 @ApiModelProperty("办事处")
43 private String deptId; 48 private String deptId;
44 49
45 /** 50 /**
  51 + * 办事处名称
  52 + */
  53 + @ApiModelProperty("办事处名称")
  54 + private String deptName;
  55 +
  56 + /**
46 * 购货单位 57 * 购货单位
47 */ 58 */
48 @ApiModelProperty("购货单位") 59 @ApiModelProperty("购货单位")
49 private String customerId; 60 private String customerId;
50 61
51 /** 62 /**
  63 + * 购货单位名称
  64 + */
  65 + @ApiModelProperty("购货单位名称")
  66 + private String customerName;
  67 +
  68 + /**
52 * 原计划发货日期 69 * 原计划发货日期
53 */ 70 */
54 @ApiModelProperty("原计划发货日期") 71 @ApiModelProperty("原计划发货日期")
@@ -62,11 +79,23 @@ public class QueryReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> { @@ -62,11 +79,23 @@ public class QueryReplenishmentOrderBo extends BaseBo<ReplenishmentOrder> {
62 private String status; 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 public QueryReplenishmentOrderBo() { 100 public QueryReplenishmentOrderBo() {
72 101
1 package com.lframework.xingyun.sc.controller.purchase; 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 import com.lframework.starter.common.exceptions.impl.DefaultClientException; 5 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
4 import com.lframework.starter.common.utils.CollectionUtil; 6 import com.lframework.starter.common.utils.CollectionUtil;
5 import com.lframework.starter.web.core.annotations.security.HasPermission; 7 import com.lframework.starter.web.core.annotations.security.HasPermission;
@@ -8,9 +10,22 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; @@ -8,9 +10,22 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
8 import com.lframework.starter.web.core.components.resp.PageResult; 10 import com.lframework.starter.web.core.components.resp.PageResult;
9 import com.lframework.starter.web.core.controller.DefaultBaseController; 11 import com.lframework.starter.web.core.controller.DefaultBaseController;
10 import com.lframework.starter.web.core.utils.PageResultUtil; 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 import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderBo; 21 import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderBo;
  22 +import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderLineBo;
12 import com.lframework.xingyun.sc.bo.purchase.QueryReplenishmentOrderBo; 23 import com.lframework.xingyun.sc.bo.purchase.QueryReplenishmentOrderBo;
  24 +import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
13 import com.lframework.xingyun.sc.entity.ReplenishmentOrder; 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 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService; 29 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService;
15 import com.lframework.xingyun.sc.vo.purchase.CreateReplenishmentOrderVo; 30 import com.lframework.xingyun.sc.vo.purchase.CreateReplenishmentOrderVo;
16 import com.lframework.xingyun.sc.vo.purchase.QueryReplenishmentOrderVo; 31 import com.lframework.xingyun.sc.vo.purchase.QueryReplenishmentOrderVo;
@@ -18,13 +33,18 @@ import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo; @@ -18,13 +33,18 @@ import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo;
18 import io.swagger.annotations.Api; 33 import io.swagger.annotations.Api;
19 import io.swagger.annotations.ApiImplicitParam; 34 import io.swagger.annotations.ApiImplicitParam;
20 import io.swagger.annotations.ApiOperation; 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 import org.springframework.validation.annotation.Validated; 38 import org.springframework.validation.annotation.Validated;
23 import org.springframework.web.bind.annotation.*; 39 import org.springframework.web.bind.annotation.*;
24 40
  41 +import javax.annotation.Resource;
25 import javax.validation.Valid; 42 import javax.validation.Valid;
26 import javax.validation.constraints.NotBlank; 43 import javax.validation.constraints.NotBlank;
  44 +import java.util.ArrayList;
27 import java.util.List; 45 import java.util.List;
  46 +import java.util.Map;
  47 +import java.util.function.Function;
28 import java.util.stream.Collectors; 48 import java.util.stream.Collectors;
29 49
30 /** 50 /**
@@ -33,11 +53,26 @@ import java.util.stream.Collectors; @@ -33,11 +53,26 @@ import java.util.stream.Collectors;
33 @Api(tags = "补货单") 53 @Api(tags = "补货单")
34 @Validated 54 @Validated
35 @RestController 55 @RestController
36 -@RequestMapping("/purchase/replenishmentorder") 56 +@RequestMapping("/purchase/replenishmentOrder")
37 public class ReplenishmentOrderController extends DefaultBaseController { 57 public class ReplenishmentOrderController extends DefaultBaseController {
38 58
39 - @Autowired 59 + @Resource
40 private ReplenishmentOrderService replenishmentOrderService; 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,7 +91,55 @@ public class ReplenishmentOrderController extends DefaultBaseController {
56 results = datas.stream().map(QueryReplenishmentOrderBo::new).collect(Collectors.toList()); 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,7 +157,32 @@ public class ReplenishmentOrderController extends DefaultBaseController {
74 } 157 }
75 158
76 GetReplenishmentOrderBo result = new GetReplenishmentOrderBo(data); 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 return InvokeResultBuilder.success(result); 186 return InvokeResultBuilder.success(result);
79 } 187 }
80 188
@@ -100,7 +100,13 @@ public class ReplenishmentOrder extends BaseEntity implements BaseDto { @@ -100,7 +100,13 @@ public class ReplenishmentOrder extends BaseEntity implements BaseDto {
100 private LocalDateTime updateTime; 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 @TableField(exist = false) 111 @TableField(exist = false)
106 private Boolean showExamine; 112 private Boolean showExamine;
@@ -63,12 +63,11 @@ public class ReplenishmentOrderServiceImpl extends BaseMpServiceImpl<Replenishme @@ -63,12 +63,11 @@ public class ReplenishmentOrderServiceImpl extends BaseMpServiceImpl<Replenishme
63 if (CollectionUtils.isNotEmpty(datas)) { 63 if (CollectionUtils.isNotEmpty(datas)) {
64 // 获取当前人员的待办任务数据 64 // 获取当前人员的待办任务数据
65 List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId()); 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 return PageResultUtil.convert(new PageInfo<>(datas)); 73 return PageResultUtil.convert(new PageInfo<>(datas));