|
@@ -124,7 +124,10 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
//获取清单和分解信息
|
|
|
List<Long> longs = Func.toLongList(ids);
|
|
|
vos = baseMapper.getResolveFormInfo(contractId,nodeId,longs);
|
|
|
+ vos = vos.stream().filter(l-> !l.getAllMeterTotal().equals(l.getChangeTotal())).collect(Collectors.toList());
|
|
|
for (MeterInventoryVO vo : vos) {
|
|
|
+ //默认分解清单的比例为0
|
|
|
+ vo.setPayRatio(new BigDecimal(0));
|
|
|
//设置其他计量总数
|
|
|
vo.setOtherMeterTotal(vo.getAllMeterTotal().subtract(vo.getCurrentMeterTotal()));
|
|
|
//设置施工图数量是否大于合同数量
|
|
@@ -139,6 +142,21 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void add(MiddleMeterApplyDTO dto) {
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ //先保存附件,因为要判断是否关联
|
|
|
+ Integer isLinkData = 0;
|
|
|
+ List<AttachmentForm> fileList = dto.getFileList();
|
|
|
+ if (fileList != null && fileList.size() != 0) {
|
|
|
+ for (AttachmentForm file : fileList) {
|
|
|
+ if (isLinkData == 0 && file.getSelectId() != null){
|
|
|
+ isLinkData = 1;
|
|
|
+ }
|
|
|
+ file.setProjectId(dto.getProjectId());
|
|
|
+ file.setContractId(dto.getContractId());
|
|
|
+ file.setMasterId(id);
|
|
|
+ }
|
|
|
+ attachmentFormService.saveBatch(fileList);
|
|
|
+ }
|
|
|
//校验计量单元是否最底层节点
|
|
|
Integer count = baseMapper.getNodeChild(dto.getContractId(),dto.getContractUnitId());
|
|
|
if (count != 0){
|
|
@@ -157,10 +175,10 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
dto.setMeterNumber(this.getMeterNumber(dto));
|
|
|
//保存中间计量申请,设置计量金额为0,如果存在计量清单,则统计计量清单总金额
|
|
|
MiddleMeterApply apply = new MiddleMeterApply();
|
|
|
- Long id = SnowFlakeUtil.getId();
|
|
|
dto.setId(id);
|
|
|
BeanUtils.copyProperties(dto,apply);
|
|
|
apply.setMeterMoney(null);
|
|
|
+ apply.setIsLinkData(isLinkData);
|
|
|
//保存计量清单
|
|
|
List<MeterInventoryVO> formList = dto.getFormList();
|
|
|
if (formList.size() != 0){
|
|
@@ -198,14 +216,28 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
formApply.setCurrentPrice(l.getCurrentPrice());
|
|
|
formApply.setBuildPictureTotal(l.getResolveTotal());
|
|
|
formApply.setChangeBuildPictureTotal(l.getChangeTotal());
|
|
|
- if (l.getCurrentMeterTotal() != null && l.getCurrentPrice() != null && l.getUpPayRatio() != null) {
|
|
|
+ if (l.getCurrentMeterTotal() != null && l.getCurrentPrice() != null) {
|
|
|
formApply.setCurrentMeterTotal(l.getCurrentMeterTotal());
|
|
|
formApply.setCurrentMeterMoney(l.getCurrentPrice().multiply(l.getCurrentMeterTotal()));
|
|
|
- formApply.setPayMoney(formApply.getCurrentMeterMoney().multiply(l.getUpPayRatio().divide(new BigDecimal(100))));
|
|
|
+
|
|
|
}else {
|
|
|
- throw new ServiceException("单价和计量数量和支付比例不能为空");
|
|
|
+ throw new ServiceException("单价和计量数量不能为空");
|
|
|
}
|
|
|
- formApply.setUpPayRatio(l.getUpPayRatio());
|
|
|
+ //校验比例是否在范围之内
|
|
|
+ if (l.getUpPayRatio() == null || l.getPayRatio() == null){
|
|
|
+ throw new ServiceException("新增失败,支付比例不能为空");
|
|
|
+ }
|
|
|
+ if (apply.getIsLinkData() == 0) {
|
|
|
+ if (l.getPayRatio().compareTo(BigDecimal.ZERO) < 0 || l.getPayRatio().add(l.getOtherPayRatio()).compareTo(l.getUpPayRatio()) > 0) {
|
|
|
+ throw new ServiceException("新增失败,累计支付比例大于计量单元,计量单元比例:"+l.getUpPayRatio()+",其他期计量比例:"+l.getOtherPayRatio());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (l.getPayRatio().compareTo(BigDecimal.ZERO) < 0 || l.getPayRatio().add(l.getOtherPayRatio()).compareTo(new BigDecimal(100)) > 0) {
|
|
|
+ throw new ServiceException("新增失败,累计支付比例不能小于0大于100,其他期计量比例:"+l.getOtherPayRatio());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ formApply.setPayMoney(formApply.getCurrentMeterMoney().multiply(l.getUpPayRatio().divide(new BigDecimal(100))));
|
|
|
+ formApply.setPayRatio(l.getPayRatio());
|
|
|
return formApply;
|
|
|
}).collect(Collectors.toList());
|
|
|
for (InventoryFormApply formApply : formApplies) {
|
|
@@ -217,16 +249,6 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
throw new ServiceException("请添加需要计量的清单");
|
|
|
}
|
|
|
this.save(apply);
|
|
|
- //保存附件
|
|
|
- List<AttachmentForm> fileList = dto.getFileList();
|
|
|
- if (fileList != null && fileList.size() != 0) {
|
|
|
- for (AttachmentForm file : fileList) {
|
|
|
- file.setProjectId(dto.getProjectId());
|
|
|
- file.setContractId(dto.getContractId());
|
|
|
- file.setMasterId(id);
|
|
|
- }
|
|
|
- attachmentFormService.saveBatch(fileList);
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -300,6 +322,22 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void update2(MiddleMeterApplyDTO dto) {
|
|
|
+ //删除附件
|
|
|
+ attachmentFormService.deleteByMasterId(dto.getId());
|
|
|
+ //先保存附件,因为要判断是否关联
|
|
|
+ Integer isLinkData = 0;
|
|
|
+ List<AttachmentForm> fileList = dto.getFileList();
|
|
|
+ if (fileList != null && fileList.size() != 0) {
|
|
|
+ for (AttachmentForm file : fileList) {
|
|
|
+ if (isLinkData == 0 && file.getSelectId() != null){
|
|
|
+ isLinkData = 1;
|
|
|
+ }
|
|
|
+ file.setProjectId(dto.getProjectId());
|
|
|
+ file.setContractId(dto.getContractId());
|
|
|
+ file.setMasterId(dto.getId());
|
|
|
+ }
|
|
|
+ attachmentFormService.saveBatch(fileList);
|
|
|
+ }
|
|
|
//校验当前计量期是否已经上报
|
|
|
ContractMeterPeriod period = contractMeterPeriodService.getById(dto.getContractPeriodId());
|
|
|
if (period.getApproveStatus() != 0){
|
|
@@ -347,14 +385,27 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
formApply.setCurrentPrice(l.getCurrentPrice());
|
|
|
formApply.setBuildPictureTotal(l.getResolveTotal());
|
|
|
formApply.setChangeBuildPictureTotal(l.getChangeTotal());
|
|
|
- if (l.getCurrentMeterTotal() != null && l.getCurrentPrice() != null && l.getUpPayRatio() != null) {
|
|
|
+ if (l.getCurrentMeterTotal() != null && l.getCurrentPrice() != null) {
|
|
|
formApply.setCurrentMeterTotal(l.getCurrentMeterTotal());
|
|
|
formApply.setCurrentMeterMoney(l.getCurrentPrice().multiply(l.getCurrentMeterTotal()));
|
|
|
- formApply.setPayMoney(formApply.getCurrentMeterMoney().multiply(l.getUpPayRatio().divide(new BigDecimal(100))));
|
|
|
}else {
|
|
|
throw new ServiceException("单价和计量数量和支付比例不能为空");
|
|
|
}
|
|
|
- formApply.setUpPayRatio(l.getUpPayRatio());
|
|
|
+ //校验比例是否在范围之内
|
|
|
+ if (l.getUpPayRatio() == null || l.getPayRatio() == null){
|
|
|
+ throw new ServiceException("新增失败,支付比例不能为空");
|
|
|
+ }
|
|
|
+ if (apply.getIsLinkData() == 0) {
|
|
|
+ if (l.getPayRatio().compareTo(BigDecimal.ZERO) < 0 || l.getPayRatio().add(l.getOtherPayRatio()).compareTo(l.getUpPayRatio()) > 0) {
|
|
|
+ throw new ServiceException("新增失败,累计支付比例大于计量单元,计量单元比例:"+l.getUpPayRatio()+",其他期计量比例:"+l.getOtherPayRatio());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (l.getPayRatio().compareTo(BigDecimal.ZERO) < 0 || l.getPayRatio().add(l.getOtherPayRatio()).compareTo(new BigDecimal(100)) > 0) {
|
|
|
+ throw new ServiceException("新增失败,累计支付比例不能小于0大于100,其他期计量比例:"+l.getOtherPayRatio());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ formApply.setPayMoney(formApply.getCurrentMeterMoney().multiply(l.getUpPayRatio().divide(new BigDecimal(100))));
|
|
|
+ formApply.setPayRatio(l.getPayRatio());
|
|
|
return formApply;
|
|
|
}).collect(Collectors.toList());
|
|
|
for (InventoryFormApply formApply : formApplies) {
|
|
@@ -364,18 +415,6 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
|
|
|
inventoryFormApplyService.saveBatch(formApplies);
|
|
|
}
|
|
|
this.updateById(apply);
|
|
|
- //删除附件
|
|
|
- attachmentFormService.deleteByMasterId(dto.getId());
|
|
|
- //保存附件
|
|
|
- List<AttachmentForm> fileList = dto.getFileList();
|
|
|
- if (fileList != null && fileList.size() != 0) {
|
|
|
- for (AttachmentForm file : fileList) {
|
|
|
- file.setProjectId(dto.getProjectId());
|
|
|
- file.setContractId(dto.getContractId());
|
|
|
- file.setMasterId(dto.getId());
|
|
|
- }
|
|
|
- attachmentFormService.saveOrUpdateBatch(fileList);
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|