Showing
1 changed file
with
43 additions
and
0 deletions
| @@ -20,6 +20,7 @@ import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService; | @@ -20,6 +20,7 @@ import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService; | ||
| 20 | import com.lframework.xingyun.sc.events.quotation.CommonChangedEvent; | 20 | import com.lframework.xingyun.sc.events.quotation.CommonChangedEvent; |
| 21 | import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; | 21 | import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; |
| 22 | import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProjectQuote; | 22 | import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProjectQuote; |
| 23 | +import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectQuoteMapper; | ||
| 23 | import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectMapper; | 24 | import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectMapper; |
| 24 | import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectQuoteService; | 25 | import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectQuoteService; |
| 25 | import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectService; | 26 | import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectService; |
| @@ -56,12 +57,20 @@ public class SupplierQuotationProjectServiceImpl | @@ -56,12 +57,20 @@ public class SupplierQuotationProjectServiceImpl | ||
| 56 | private static final String STATUS_COMPLETED_CN = "COMPLETED"; | 57 | private static final String STATUS_COMPLETED_CN = "COMPLETED"; |
| 57 | //已中止 | 58 | //已中止 |
| 58 | private static final String STATUS_ABORTED_CN = "ABORTED"; | 59 | private static final String STATUS_ABORTED_CN = "ABORTED"; |
| 60 | + //中标 | ||
| 61 | + private static final String BID_STATUS_WIN = "WIN"; | ||
| 62 | + //未中标 | ||
| 63 | + private static final String BID_STATUS_LOSE = "LOSE"; | ||
| 64 | + //废标 | ||
| 65 | + private static final String BID_STATUS_ABORT = "ABORT"; | ||
| 59 | 66 | ||
| 60 | @Resource | 67 | @Resource |
| 61 | private BreedRelationshipService breedRelationshipService; | 68 | private BreedRelationshipService breedRelationshipService; |
| 62 | @Resource | 69 | @Resource |
| 63 | private SupplierQuotationProjectQuoteService supplierQuotationProjectQuoteService; | 70 | private SupplierQuotationProjectQuoteService supplierQuotationProjectQuoteService; |
| 64 | @Resource | 71 | @Resource |
| 72 | + private SupplierQuotationProjectQuoteMapper supplierQuotationProjectQuoteMapper; | ||
| 73 | + @Resource | ||
| 65 | private ApplicationEventPublisher applicationEventPublisher; | 74 | private ApplicationEventPublisher applicationEventPublisher; |
| 66 | 75 | ||
| 67 | @Override | 76 | @Override |
| @@ -198,6 +207,13 @@ public class SupplierQuotationProjectServiceImpl | @@ -198,6 +207,13 @@ public class SupplierQuotationProjectServiceImpl | ||
| 198 | throw new DefaultClientException("供应商报价项目不存在!"); | 207 | throw new DefaultClientException("供应商报价项目不存在!"); |
| 199 | } | 208 | } |
| 200 | 209 | ||
| 210 | + if (STATUS_ABORTED_CN.equals(status)) { | ||
| 211 | + validateProjectCanAbort(id); | ||
| 212 | + updateProjectQuoteStatusToAbort(id); | ||
| 213 | + } else if (STATUS_COMPLETED_CN.equals(status)) { | ||
| 214 | + updateProjectQuoteStatusToLoseWhenCompleted(id); | ||
| 215 | + } | ||
| 216 | + | ||
| 201 | LambdaUpdateWrapper<SupplierQuotationProject> updateWrapper = Wrappers.lambdaUpdate(SupplierQuotationProject.class) | 217 | LambdaUpdateWrapper<SupplierQuotationProject> updateWrapper = Wrappers.lambdaUpdate(SupplierQuotationProject.class) |
| 202 | .set(SupplierQuotationProject::getStatus, status) | 218 | .set(SupplierQuotationProject::getStatus, status) |
| 203 | .eq(SupplierQuotationProject::getId, id); | 219 | .eq(SupplierQuotationProject::getId, id); |
| @@ -297,5 +313,32 @@ public class SupplierQuotationProjectServiceImpl | @@ -297,5 +313,32 @@ public class SupplierQuotationProjectServiceImpl | ||
| 297 | applicationEventPublisher.publishEvent(new CommonChangedEvent(this, id, eventType)); | 313 | applicationEventPublisher.publishEvent(new CommonChangedEvent(this, id, eventType)); |
| 298 | } | 314 | } |
| 299 | 315 | ||
| 316 | + private void validateProjectCanAbort(String projectId) { | ||
| 317 | + Integer winCount = supplierQuotationProjectQuoteMapper.selectCount( | ||
| 318 | + Wrappers.lambdaQuery(SupplierQuotationProjectQuote.class) | ||
| 319 | + .eq(SupplierQuotationProjectQuote::getProjectId, projectId) | ||
| 320 | + .eq(SupplierQuotationProjectQuote::getBidStatus, BID_STATUS_WIN)); | ||
| 321 | + if (winCount != null && winCount > 0) { | ||
| 322 | + throw new DefaultClientException("项目中存在已成交的供应商报价,不允许中止!"); | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + private void updateProjectQuoteStatusToAbort(String projectId) { | ||
| 327 | + supplierQuotationProjectQuoteMapper.update(null, | ||
| 328 | + Wrappers.lambdaUpdate(SupplierQuotationProjectQuote.class) | ||
| 329 | + .set(SupplierQuotationProjectQuote::getBidStatus, BID_STATUS_ABORT) | ||
| 330 | + .eq(SupplierQuotationProjectQuote::getProjectId, projectId)); | ||
| 331 | + } | ||
| 332 | + | ||
| 333 | + private void updateProjectQuoteStatusToLoseWhenCompleted(String projectId) { | ||
| 334 | + supplierQuotationProjectQuoteMapper.update(null, | ||
| 335 | + Wrappers.lambdaUpdate(SupplierQuotationProjectQuote.class) | ||
| 336 | + .set(SupplierQuotationProjectQuote::getBidStatus, BID_STATUS_LOSE) | ||
| 337 | + .eq(SupplierQuotationProjectQuote::getProjectId, projectId) | ||
| 338 | + .and(wrapper -> wrapper.isNull(SupplierQuotationProjectQuote::getBidStatus) | ||
| 339 | + .or() | ||
| 340 | + .ne(SupplierQuotationProjectQuote::getBidStatus, BID_STATUS_WIN))); | ||
| 341 | + } | ||
| 342 | + | ||
| 300 | } | 343 | } |
| 301 | 344 |