|
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.business.entity.InformationQuery;
|
|
@@ -131,11 +132,46 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
if (StringUtils.isBlank(ids) || nodeId == null){
|
|
|
return vos;
|
|
|
}
|
|
|
- //获取清单和分解信息
|
|
|
+ //获取所以清单和分解信息
|
|
|
List<Long> longs = Func.toLongList(ids);
|
|
|
vos = baseMapper.getResolveFormInfo(contractId,nodeId,longs);
|
|
|
- vos = vos.stream().filter(l-> !l.getAllMeterTotal().equals(l.getChangeTotal()) && l.getChangeTotal().compareTo(BigDecimal.ZERO) != 0)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ if (vos.size() == 0){
|
|
|
+ return vos;
|
|
|
+ }
|
|
|
+ //获取节点信息
|
|
|
+ MeterTreeContract treeContract = meterTreeContractService.getById(nodeId);
|
|
|
+ //如果是自动计量节点,则直接使用后管设置的支付比例
|
|
|
+ if (treeContract.getIsAutoMeter() == 1){
|
|
|
+ MeterContractInfo one = meterContractInfoService.getOne(new LambdaQueryWrapper<MeterContractInfo>()
|
|
|
+ .eq(MeterContractInfo::getContractId, treeContract.getContractId()));
|
|
|
+ if (one == null || one.getMiddlePayRatio() == null){
|
|
|
+ throw new ServiceException("合同段未配置支付比例,新增自动计量节点的计量单,必须先设置支付比例");
|
|
|
+ }
|
|
|
+ vos.stream().forEach(l->l.setUpPayRatio(one.getMiddlePayRatio()));
|
|
|
+
|
|
|
+ }
|
|
|
+ //过滤没有计量数量的清单
|
|
|
+ vos = vos.stream().filter(l->{
|
|
|
+ //变更后数量不能为0
|
|
|
+ if (l.getChangeTotal().compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //有比例,则判断 当前已计量数量 是否大于等于 比例*变更后数量
|
|
|
+ if (l.getUpPayRatio() != null){
|
|
|
+ if (l.getAllMeterTotal().compareTo(l.getChangeTotal().multiply(l.getUpPayRatio()).divide(new BigDecimal(100))) >= 0){
|
|
|
+ return false;
|
|
|
+ }else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //没有比例,直接判断已计量数量是否大于等于变更后数量
|
|
|
+ if (l.getAllMeterTotal().compareTo(l.getChangeTotal()) >= 0){
|
|
|
+ return false;
|
|
|
+ }else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
for (MeterInventoryVO vo : vos) {
|
|
|
//如果合同计量单元填写了比例,则默认分解清单的比例为0
|
|
|
if (vo.getUpPayRatio() != null) {
|
|
@@ -145,7 +181,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
vo.setOtherMeterTotal(vo.getAllMeterTotal().subtract(vo.getCurrentMeterTotal()));
|
|
|
vo.setOtherPayRatio(vo.getOtherMeterTotal().divide(vo.getChangeTotal(), 4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2));
|
|
|
//设置施工图数量是否大于合同数量
|
|
|
- vo.setIsBuildThanContract(vo.getChangeTotal().compareTo(vo.getContractChangeAllTotal()) == 1?1:0);
|
|
|
+ vo.setIsBuildThanContract(vo.getChangeTotal().compareTo(vo.getContractChangeAllTotal()) == 1 ? 1 : 0);
|
|
|
}
|
|
|
return vos;
|
|
|
}
|
|
@@ -265,6 +301,19 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
throw new ServiceException("请添加需要计量的清单");
|
|
|
}
|
|
|
this.save(apply);
|
|
|
+ if (StringUtils.isNotBlank(apply.getCalculateFormula())) {
|
|
|
+ //如果存在计算式,每次同步修改所有期的当前节点计算式
|
|
|
+ this.update(new LambdaUpdateWrapper<MiddleMeterApply>()
|
|
|
+ .eq(MiddleMeterApply::getContractId,dto.getContractId())
|
|
|
+ .eq(MiddleMeterApply::getContractUnitId,dto.getContractUnitId())
|
|
|
+ .set(MiddleMeterApply::getCalculateFormula,dto.getCalculateFormula()));
|
|
|
+ //再同步修改合同计量单元当前节点的计算式
|
|
|
+ meterTreeContractService.update(new LambdaUpdateWrapper<MeterTreeContract>()
|
|
|
+ .eq(MeterTreeContract::getId,dto.getContractUnitId())
|
|
|
+ .set(MeterTreeContract::getCalculateFormula,dto.getCalculateFormula()));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -343,14 +392,16 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
throw new ServiceException("修改失败,不能删除所有计量清单");
|
|
|
}
|
|
|
//删除附件
|
|
|
+ int total = baseMapper.getWbsLinkFileTotal(dto.getContractId(),dto.getId());
|
|
|
attachmentFormService.deleteByMasterId(dto.getId());
|
|
|
//先保存附件,因为要判断是否关联
|
|
|
Integer isLinkData = 0;
|
|
|
+ Integer linkTotal = 0;
|
|
|
List<AttachmentForm> fileList = dto.getFileList();
|
|
|
if (fileList != null && fileList.size() != 0) {
|
|
|
for (AttachmentForm file : fileList) {
|
|
|
- if (isLinkData == 0 && file.getSelectId() != null){
|
|
|
- isLinkData = 1;
|
|
|
+ if (file.getSelectId() != null){
|
|
|
+ linkTotal++;
|
|
|
}
|
|
|
file.setProjectId(dto.getProjectId());
|
|
|
file.setContractId(dto.getContractId());
|
|
@@ -358,10 +409,21 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
}
|
|
|
attachmentFormService.saveBatch(fileList);
|
|
|
}
|
|
|
+ if (linkTotal > 0){
|
|
|
+ isLinkData = 1;
|
|
|
+ }
|
|
|
+ //获取计量单信息,判断是否为自动生成
|
|
|
+ MiddleMeterApply meterApply = this.getById(dto.getId());
|
|
|
+ //为自动生成,则获取附件的selectId逗号拼接,判断是否全部存在于当前附件
|
|
|
+ if (meterApply.getIsAutoBuild() == 1){
|
|
|
+ if (linkTotal != total){
|
|
|
+ throw new ServiceException("修改失败:不允许删除关联WBS节点的附件");
|
|
|
+ }
|
|
|
+ }
|
|
|
//校验当前计量期是否已经上报
|
|
|
ContractMeterPeriod period = contractMeterPeriodService.getById(dto.getContractPeriodId());
|
|
|
if (period.getApproveStatus() != 0){
|
|
|
- throw new ServiceException("修改失败,当前计量期已经上报或审批");
|
|
|
+ throw new ServiceException("修改失败:当前计量期已经上报或审批");
|
|
|
}
|
|
|
//保存中间计量申请,设置计量金额为0,如果存在计量清单,则统计计量清单总金额
|
|
|
MiddleMeterApply apply = new MiddleMeterApply();
|
|
@@ -438,6 +500,18 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
inventoryFormApplyService.saveBatch(formApplies);
|
|
|
}
|
|
|
this.updateById(apply);
|
|
|
+ if (StringUtils.isNotBlank(apply.getCalculateFormula())) {
|
|
|
+ //如果存在计算式,每次同步修改所有期的当前节点计算式
|
|
|
+ this.update(new LambdaUpdateWrapper<MiddleMeterApply>()
|
|
|
+ .eq(MiddleMeterApply::getContractId,dto.getContractId())
|
|
|
+ .eq(MiddleMeterApply::getContractUnitId,dto.getContractUnitId())
|
|
|
+ .set(MiddleMeterApply::getCalculateFormula,dto.getCalculateFormula()));
|
|
|
+ //再同步修改合同计量单元当前节点的计算式
|
|
|
+ meterTreeContractService.update(new LambdaUpdateWrapper<MeterTreeContract>()
|
|
|
+ .eq(MeterTreeContract::getId,dto.getContractUnitId())
|
|
|
+ .set(MeterTreeContract::getCalculateFormula,dto.getCalculateFormula()));
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -718,8 +792,10 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
}
|
|
|
List<String> list = vos.stream().map(l -> l.getId()+"").collect(Collectors.toList());
|
|
|
String join = String.join(",", list);
|
|
|
+ //获取符合条件的分解清单
|
|
|
voList = this.addResolveForm(apply.getContractId(), apply.getContractUnitId(), join);
|
|
|
if (voList.size() > 1){
|
|
|
+ //按照合同计量单元部位排序
|
|
|
Map<String, MeterInventoryVO> map = voList.stream().collect(Collectors.toMap(MeterInventoryVO::getFormNumber, l -> l));
|
|
|
List<String> list2 = inventoryFormService.getAllFormNumberBySort(apply.getContractId());
|
|
|
for (String s : map.keySet()) {
|
|
@@ -885,6 +961,16 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
if (apply == null){
|
|
|
throw new ServiceException("未找到中间计量申请信息");
|
|
|
}
|
|
|
+ //查询查询当前计量期信息
|
|
|
+ ContractMeterPeriod period = contractMeterPeriodService.getById(apply.getContractPeriodId());
|
|
|
+ if (period == null){
|
|
|
+ throw new ServiceException("未找到当前计量期信息");
|
|
|
+ }
|
|
|
+ //获取任务信息
|
|
|
+ Task task = baseMapper.getTaskInfo(apply.getContractId(),period.getId());
|
|
|
+ if (task == null){
|
|
|
+ throw new ServiceException("未找到任务信息");
|
|
|
+ }
|
|
|
//根据文件id,查询出queryInfo数据
|
|
|
if (StringUtils.isBlank(fileIds)){
|
|
|
throw new ServiceException("请选择关联资料");
|
|
@@ -1073,8 +1159,8 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
}
|
|
|
//末尾拼接所有WBS节点,所有计量节点
|
|
|
str.append(vo2.getLinkWbs()+",");
|
|
|
- str2.append(vo2.getId());
|
|
|
- str3.append(vo2.getLinkForm());
|
|
|
+ str2.append(vo2.getId()+",");
|
|
|
+ str3.append(vo2.getLinkForm()+",");
|
|
|
|
|
|
}
|
|
|
if (voList.size() == 0 || StringUtils.isBlank(str.toString()) || StringUtils.isBlank(str2.toString()) || StringUtils.isBlank(str3.toString())){
|
|
@@ -1111,7 +1197,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
//查询出当前计量期所有未删除的计量单,如果不为空,则过滤出最大后缀
|
|
|
List<MiddleMeterApply> applyList = this.list(new LambdaQueryWrapper<MiddleMeterApply>()
|
|
|
.eq(MiddleMeterApply::getContractId, contractId)
|
|
|
- .eq(MiddleMeterApply::getContractPeriodId, period));
|
|
|
+ .eq(MiddleMeterApply::getContractPeriodId, periodId));
|
|
|
//获取当前计量期所有已经计量的数量(),用于生成计量单编号
|
|
|
if (applyList.size() == 0){
|
|
|
count = 1;
|
|
@@ -1212,6 +1298,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
apply.setMeterMoney(total);
|
|
|
apply.setCalculateFormula(vo2.getCalculateFormula());
|
|
|
apply.setIsLinkData(1);
|
|
|
+ apply.setIsAutoBuild(1);
|
|
|
//添加到计量单集合
|
|
|
middleMeterApplyAdd.add(apply);
|
|
|
count++;
|