Commit c99b22a7f309ea00ad375f90a8eda3eed415f06a

Authored by yeqianyong
1 parent c49e5ca0

楚江ERP-查询可撤销或变更的订货单数据接口调整

... ... @@ -5,6 +5,8 @@ import com.lframework.starter.web.core.dto.BaseDto;
5 5 import java.math.BigDecimal;
6 6 import java.time.LocalDate;
7 7 import java.time.LocalDateTime;
  8 +import java.util.List;
  9 +
8 10 import com.baomidou.mybatisplus.annotation.FieldFill;
9 11 import com.lframework.starter.web.core.entity.BaseEntity;
10 12 import com.baomidou.mybatisplus.annotation.TableField;
... ... @@ -207,6 +209,13 @@ public class PurchaseOrderInfo extends BaseEntity implements BaseDto {
207 209 private Boolean showExamine;
208 210
209 211 /**
  212 + * 订货单表物料行
  213 + * 非持久化字段
  214 + */
  215 + @TableField(exist = false)
  216 + private List<PurchaseOrderLine> purchaseOrderLineList;
  217 +
  218 + /**
210 219 * 创建人ID
211 220 */
212 221 @TableField(fill = FieldFill.INSERT)
... ...
... ... @@ -23,6 +23,7 @@ import com.lframework.starter.common.utils.Assert;
23 23 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
24 24 import com.lframework.xingyun.sc.entity.CustomerCredit;
25 25 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  26 +import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
26 27 import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus;
27 28 import com.lframework.xingyun.sc.mappers.PurchaseOrderInfoMapper;
28 29 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
... ... @@ -36,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
36 37 import org.springframework.stereotype.Service;
37 38
38 39 import javax.annotation.Resource;
  40 +import java.util.ArrayList;
  41 +import java.util.HashMap;
39 42 import java.util.List;
  43 +import java.util.Map;
40 44 import java.util.stream.Collectors;
41 45
42 46 @Service
... ... @@ -99,8 +103,29 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
99 103
100 104 @Override
101 105 public List<PurchaseOrderInfo> queryCanRevokeOrChangeList(QueryPurchaseOrderInfoVo vo) {
  106 + List<PurchaseOrderInfo> orderInfoList = getBaseMapper().queryCanRevokeOrChangeList(vo);
  107 + if (CollectionUtils.isEmpty(orderInfoList)) {
  108 + return new ArrayList<>();
  109 + }
  110 + List<String> orderIds = orderInfoList.stream().map(PurchaseOrderInfo::getId).distinct().collect(Collectors.toList());
  111 + // 获取物料行数据
  112 + List<PurchaseOrderLine> orderLineList = purchaseOrderLineService.listByOrderIds(orderIds);
  113 + if (CollectionUtils.isEmpty(orderLineList)) {
  114 + return orderInfoList;
  115 + }
  116 + Map<String, List<PurchaseOrderLine>> orderLineMap = new HashMap<>();
  117 + for (PurchaseOrderLine orderLine : orderLineList) {
  118 + String orderId = orderLine.getPurchaseOrderId();
  119 + List<PurchaseOrderLine> list = orderLineMap.computeIfAbsent(orderId, k -> new ArrayList<>());
  120 + list.add(orderLine);
  121 + }
  122 + for (PurchaseOrderInfo purchaseOrderInfo : orderInfoList) {
  123 + String orderId = purchaseOrderInfo.getId();
  124 + List<PurchaseOrderLine> lineList = orderLineMap.get(orderId);
  125 + purchaseOrderInfo.setPurchaseOrderLineList(lineList);
  126 + }
102 127
103   - return getBaseMapper().queryCanRevokeOrChangeList(vo);
  128 + return orderInfoList;
104 129 }
105 130
106 131 @Override
... ...
... ... @@ -166,17 +166,22 @@
166 166 <if test="vo.workshopId != null and vo.workshopId != ''">
167 167 AND tb.workshop_id = #{vo.workshopId}
168 168 </if>
169   - <if test="vo.queryType == 'REVOKE'">
  169 + <choose>
  170 + <when test="vo.queryType == 'REVOKE'">
170 171 AND (tb.revoke_status = '' OR tb.revoke_status = null OR tb.revoke_status='CANCEL' OR
171 172 tb.revoke_status='PARTIAL')
172 173 AND (tb.status='ISSUED' OR tb.status='WAIT' OR tb.status='TRANSIT')
173 174 AND tb.type ='PRODUCTION'
174   - </if>
175   - <if test="vo.queryType == 'CHANGE'">
  175 + </when>
  176 + <when test="vo.queryType == 'CHANGE'">
176 177 and tb.examine_status = 'PASS'
177 178 and tb.status != 'SHIPPED'
178 179 and tb.revoke_status != 'UNDOING'
179   - </if>
  180 + </when>
  181 + <otherwise>
  182 + AND 1 = 0 <!-- 确保查询不到任何数据 -->
  183 + </otherwise>
  184 + </choose>
180 185 </where>
181 186 ORDER BY tb.update_time DESC
182 187 </select>
... ...