|
|
@@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -90,6 +91,11 @@ public class contractServiceImpl extends ServiceImpl<ContractMapper, ContractEnt
|
|
|
contractEntity.setInternalCompanyName(interName);
|
|
|
|
|
|
contractEntity.setContractStatus("0");
|
|
|
+ if(contractDto.getExpiringDate() !=null){
|
|
|
+ LocalDateTime shouldPostponedDate =this.saveShouldPostponedDate(contractDto);
|
|
|
+ contractEntity.setShouldPostponedDate(shouldPostponedDate);
|
|
|
+ }
|
|
|
+
|
|
|
baseMapper.insert(contractEntity);
|
|
|
if (contractDto.getSupplierIdList() != null) {
|
|
|
contractSupplierService.saveAndUpdate(supplierIdList, contractEntity.getId());
|
|
|
@@ -112,6 +118,12 @@ public class contractServiceImpl extends ServiceImpl<ContractMapper, ContractEnt
|
|
|
String interName = this.getNameInv(contractDto.getInternalCompanyId());
|
|
|
contractEntity.setInternalCompanyName(interName);
|
|
|
}
|
|
|
+
|
|
|
+ if(contractDto.getExpiringDate() !=null){
|
|
|
+ LocalDateTime shouldPostponedDate =this.saveShouldPostponedDate(contractDto);
|
|
|
+ contractEntity.setShouldPostponedDate(shouldPostponedDate);
|
|
|
+ }
|
|
|
+
|
|
|
baseMapper.updateById(contractEntity);
|
|
|
if (contractDto.getSupplierIdList() != null && !contractDto.getSupplierIdList().isEmpty()) {
|
|
|
contractSupplierService.saveAndUpdate(contractDto.getSupplierIdList(), contractEntity.getId());
|
|
|
@@ -123,6 +135,30 @@ public class contractServiceImpl extends ServiceImpl<ContractMapper, ContractEnt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private LocalDateTime saveShouldPostponedDate(ContractDto contractDto) {
|
|
|
+ LocalDateTime expiringDateNew =null;
|
|
|
+ String yearTime = contractDto.getYearTime();
|
|
|
+ String monthTime = contractDto.getMonthTime();
|
|
|
+ String dayTime = contractDto.getDayTime();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ LocalDateTime expiringDate = contractDto.getExpiringDate();
|
|
|
+ if(StringUtils.isNotEmpty(yearTime)){
|
|
|
+ expiringDateNew=expiringDate.plusYears(Integer.parseInt(yearTime));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(monthTime)){
|
|
|
+
|
|
|
+ expiringDateNew=expiringDate.plusMonths(Integer.parseInt(monthTime));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(dayTime)){
|
|
|
+ expiringDateNew=expiringDate.plusDays(Integer.parseInt(dayTime));
|
|
|
+
|
|
|
+ }
|
|
|
+ return expiringDateNew;
|
|
|
+ }
|
|
|
+
|
|
|
private String getNameInv(String externalCompaniesId) {
|
|
|
QueryWrapper<InvAccount> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("account_id", externalCompaniesId);
|
|
|
@@ -395,7 +431,7 @@ public class contractServiceImpl extends ServiceImpl<ContractMapper, ContractEnt
|
|
|
} else {
|
|
|
int i = Integer.parseInt(contractCodeCopy.get("contractCode").toString());
|
|
|
i = i + 1;
|
|
|
- return contractCode + i;
|
|
|
+ return contractCode + "-"+i;
|
|
|
|
|
|
}
|
|
|
}
|