Commit c99b22a7f309ea00ad375f90a8eda3eed415f06a

Authored by yeqianyong
1 parent c49e5ca0

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

@@ -5,6 +5,8 @@ import com.lframework.starter.web.core.dto.BaseDto; @@ -5,6 +5,8 @@ import com.lframework.starter.web.core.dto.BaseDto;
5 import java.math.BigDecimal; 5 import java.math.BigDecimal;
6 import java.time.LocalDate; 6 import java.time.LocalDate;
7 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
  8 +import java.util.List;
  9 +
8 import com.baomidou.mybatisplus.annotation.FieldFill; 10 import com.baomidou.mybatisplus.annotation.FieldFill;
9 import com.lframework.starter.web.core.entity.BaseEntity; 11 import com.lframework.starter.web.core.entity.BaseEntity;
10 import com.baomidou.mybatisplus.annotation.TableField; 12 import com.baomidou.mybatisplus.annotation.TableField;
@@ -207,6 +209,13 @@ public class PurchaseOrderInfo extends BaseEntity implements BaseDto { @@ -207,6 +209,13 @@ public class PurchaseOrderInfo extends BaseEntity implements BaseDto {
207 private Boolean showExamine; 209 private Boolean showExamine;
208 210
209 /** 211 /**
  212 + * 订货单表物料行
  213 + * 非持久化字段
  214 + */
  215 + @TableField(exist = false)
  216 + private List<PurchaseOrderLine> purchaseOrderLineList;
  217 +
  218 + /**
210 * 创建人ID 219 * 创建人ID
211 */ 220 */
212 @TableField(fill = FieldFill.INSERT) 221 @TableField(fill = FieldFill.INSERT)
@@ -23,6 +23,7 @@ import com.lframework.starter.common.utils.Assert; @@ -23,6 +23,7 @@ import com.lframework.starter.common.utils.Assert;
23 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; 23 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
24 import com.lframework.xingyun.sc.entity.CustomerCredit; 24 import com.lframework.xingyun.sc.entity.CustomerCredit;
25 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo; 25 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  26 +import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
26 import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus; 27 import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus;
27 import com.lframework.xingyun.sc.mappers.PurchaseOrderInfoMapper; 28 import com.lframework.xingyun.sc.mappers.PurchaseOrderInfoMapper;
28 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 29 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
@@ -36,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional; @@ -36,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
36 import org.springframework.stereotype.Service; 37 import org.springframework.stereotype.Service;
37 38
38 import javax.annotation.Resource; 39 import javax.annotation.Resource;
  40 +import java.util.ArrayList;
  41 +import java.util.HashMap;
39 import java.util.List; 42 import java.util.List;
  43 +import java.util.Map;
40 import java.util.stream.Collectors; 44 import java.util.stream.Collectors;
41 45
42 @Service 46 @Service
@@ -99,8 +103,29 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -99,8 +103,29 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
99 103
100 @Override 104 @Override
101 public List<PurchaseOrderInfo> queryCanRevokeOrChangeList(QueryPurchaseOrderInfoVo vo) { 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 @Override 131 @Override
@@ -166,17 +166,22 @@ @@ -166,17 +166,22 @@
166 <if test="vo.workshopId != null and vo.workshopId != ''"> 166 <if test="vo.workshopId != null and vo.workshopId != ''">
167 AND tb.workshop_id = #{vo.workshopId} 167 AND tb.workshop_id = #{vo.workshopId}
168 </if> 168 </if>
169 - <if test="vo.queryType == 'REVOKE'"> 169 + <choose>
  170 + <when test="vo.queryType == 'REVOKE'">
170 AND (tb.revoke_status = '' OR tb.revoke_status = null OR tb.revoke_status='CANCEL' OR 171 AND (tb.revoke_status = '' OR tb.revoke_status = null OR tb.revoke_status='CANCEL' OR
171 tb.revoke_status='PARTIAL') 172 tb.revoke_status='PARTIAL')
172 AND (tb.status='ISSUED' OR tb.status='WAIT' OR tb.status='TRANSIT') 173 AND (tb.status='ISSUED' OR tb.status='WAIT' OR tb.status='TRANSIT')
173 AND tb.type ='PRODUCTION' 174 AND tb.type ='PRODUCTION'
174 - </if>  
175 - <if test="vo.queryType == 'CHANGE'"> 175 + </when>
  176 + <when test="vo.queryType == 'CHANGE'">
176 and tb.examine_status = 'PASS' 177 and tb.examine_status = 'PASS'
177 and tb.status != 'SHIPPED' 178 and tb.status != 'SHIPPED'
178 and tb.revoke_status != 'UNDOING' 179 and tb.revoke_status != 'UNDOING'
179 - </if> 180 + </when>
  181 + <otherwise>
  182 + AND 1 = 0 <!-- 确保查询不到任何数据 -->
  183 + </otherwise>
  184 + </choose>
180 </where> 185 </where>
181 ORDER BY tb.update_time DESC 186 ORDER BY tb.update_time DESC
182 </select> 187 </select>