|
@@ -38,7 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -66,6 +68,10 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
//变更令与合同清单中间表
|
|
|
private final IChangeTokenInventoryService changeTokenInventoryService;
|
|
|
|
|
|
+ //合同计量单元与清单中间表
|
|
|
+
|
|
|
+ private final IInventoryFormMeterService inventoryFormMeterService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 一键生成零号变更 统计每个清单节点当前分解量,设置进清单的划分数量
|
|
@@ -118,7 +124,10 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
BeanUtils.copyProperties(dto,form);
|
|
|
//保存部位
|
|
|
List<ChangeNodeVO> nodeList = dto.getNodeList();
|
|
|
+ List<ChangeFormVO2> formList = new ArrayList<>();
|
|
|
+ Map<Long, ChangeNodeVO> voMap = new HashMap<>();
|
|
|
if (nodeList.size() != 0){
|
|
|
+ voMap = nodeList.stream().collect(Collectors.toMap(l -> l.getId(), l -> l));
|
|
|
List<ChangeTokenMeter> meterList = nodeList.stream().map(l -> {
|
|
|
ChangeTokenMeter meter = new ChangeTokenMeter();
|
|
|
meter.setProjectId(dto.getProjectId());
|
|
@@ -126,12 +135,15 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
meter.setChangeTokenId(id);
|
|
|
meter.setContractMeterId(l.getId());
|
|
|
meter.setContractPicture(l.getContractPicture());
|
|
|
+ List<ChangeFormVO2> list = l.getFormList();
|
|
|
+ if (list != null && list.size() != 0){
|
|
|
+ formList.addAll(list);
|
|
|
+ }
|
|
|
return meter;
|
|
|
}).collect(Collectors.toList());
|
|
|
changeTokenMeterService.saveBatch(meterList);
|
|
|
}
|
|
|
//保存清单,并计算总变更金额设置进变更令
|
|
|
- List<ChangeFormVO2> formList = dto.getFormList();
|
|
|
if (formList.size() != 0){
|
|
|
List<ChangeTokenInventory> inventoryList = new ArrayList<>();
|
|
|
BigDecimal big = new BigDecimal(0);
|
|
@@ -143,6 +155,23 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
inventory.setContractFormId(vo2.getId());
|
|
|
inventory.setChangeBeforeTotal(vo2.getContractTotal());
|
|
|
inventory.setChangeTotal(vo2.getCurrentChangeTotal());
|
|
|
+ if (vo2.getContractMeterId() == null){
|
|
|
+ throw new ServiceException("未找到清单("+vo2.getFormName()+")的部位id");
|
|
|
+ }
|
|
|
+ //如果是负变更,判断当前节点下是否存在当前清单
|
|
|
+ if (vo2.getCurrentChangeTotal() < 0){
|
|
|
+ //获取当前节点下当前清单的分解信息
|
|
|
+ InventoryFormMeter meter = inventoryFormMeterService.getOne(new LambdaQueryWrapper<InventoryFormMeter>()
|
|
|
+ .eq(InventoryFormMeter::getContractFormId, vo2.getId())
|
|
|
+ .eq(InventoryFormMeter::getContractMeterId, vo2.getContractMeterId()));
|
|
|
+ if (meter == null || (meter.getBuildPictureTotal()+vo2.getCurrentChangeTotal() < 0)){
|
|
|
+ throw new ServiceException(voMap.get(vo2.getContractMeterId()).getNodeName()+"部位下,未找到清单("+vo2.getFormName()+")的分解信息,不能负变更");
|
|
|
+ }
|
|
|
+ }else if (vo2.getCurrentChangeTotal() == 0){
|
|
|
+ throw new ServiceException(voMap.get(vo2.getContractMeterId()).getNodeName()+"部位下,清单("+vo2.getFormName()+")的变更数量为0,请确认后再提交");
|
|
|
+ }
|
|
|
+ //设置节点id
|
|
|
+ inventory.setContractMeterId(vo2.getContractMeterId());
|
|
|
//计算变更后
|
|
|
inventory.setChangeAfterTotal(inventory.getChangeBeforeTotal() + inventory.getChangeTotal());
|
|
|
inventory.setChangeBeforeMoney(vo2.getContractMoney());
|
|
@@ -202,13 +231,21 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
* 新增-确认选择清单
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ChangeFormVO2> selectForm(Long contractId,String ids) {
|
|
|
+ public List<ChangeFormVO2> selectForm(Long contractId,Long nodeId,String ids) {
|
|
|
List<ChangeFormVO2> vos = new ArrayList<>();
|
|
|
if (StringUtils.isBlank(ids)){
|
|
|
return vos;
|
|
|
}
|
|
|
List<Long> longs = Func.toLongList(ids);
|
|
|
- vos = baseMapper.selectForm(contractId,longs);
|
|
|
+ vos = baseMapper.selectForm(contractId,longs,nodeId);
|
|
|
+ for (ChangeFormVO2 vo : vos) {
|
|
|
+ vo.setContractMeterId(nodeId);
|
|
|
+ vo.setCurrentChangeTotal(0);
|
|
|
+ vo.setChangeTotal(vo.getContractTotal());
|
|
|
+ vo.setContractMoney(vo.getCurrentPrice().multiply(new BigDecimal(vo.getContractTotal())));
|
|
|
+ vo.setCurrentChangeMoney(new BigDecimal(0));
|
|
|
+ vo.setChangeMoney(vo.getContractMoney());
|
|
|
+ }
|
|
|
return vos;
|
|
|
}
|
|
|
|
|
@@ -223,7 +260,7 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
}
|
|
|
List<Long> longs = Func.toLongList(ids);
|
|
|
//暂时使用循环单条查询
|
|
|
- vos = baseMapper.getChangeNode(contractId,longs);
|
|
|
+ vos = baseMapper.getChangeNode(contractId,longs,ids);
|
|
|
for (ChangeNodeVO vo : vos) {
|
|
|
vo.setNodeUrl(middleMeterApplyService.getNodeDivide(vo.getId()));
|
|
|
}
|
|
@@ -242,7 +279,10 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
List<ChangeNodeVO> nodeList = dto.getNodeList();
|
|
|
//删除当前变更令下的部位
|
|
|
changeTokenMeterService.deleteByTokenId(dto.getId());
|
|
|
+ List<ChangeFormVO2> formList = new ArrayList<>();
|
|
|
+ Map<Long, ChangeNodeVO> voMap = new HashMap<>();
|
|
|
if (nodeList.size() != 0){
|
|
|
+ voMap = nodeList.stream().collect(Collectors.toMap(l -> l.getId(), l -> l));
|
|
|
List<ChangeTokenMeter> meterList = nodeList.stream().map(l -> {
|
|
|
ChangeTokenMeter meter = new ChangeTokenMeter();
|
|
|
meter.setProjectId(dto.getProjectId());
|
|
@@ -255,7 +295,6 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
changeTokenMeterService.saveBatch(meterList);
|
|
|
}
|
|
|
//保存清单,并计算总变更金额设置进变更令
|
|
|
- List<ChangeFormVO2> formList = dto.getFormList();
|
|
|
//删除当前变更令下的清单
|
|
|
changeTokenInventoryService.deleteByTokenId(dto.getId());
|
|
|
if (formList.size() != 0){
|
|
@@ -269,6 +308,21 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
inventory.setContractFormId(vo2.getId());
|
|
|
inventory.setChangeBeforeTotal(vo2.getContractTotal());
|
|
|
inventory.setChangeTotal(vo2.getCurrentChangeTotal());
|
|
|
+ if (vo2.getContractMeterId() == null){
|
|
|
+ throw new ServiceException("未找到清单("+vo2.getFormName()+")的部位id");
|
|
|
+ }
|
|
|
+ //如果是负变更,判断当前节点下是否存在当前清单
|
|
|
+ if (vo2.getCurrentChangeTotal() < 0){
|
|
|
+ //获取当前节点下当前清单的分解信息
|
|
|
+ InventoryFormMeter meter = inventoryFormMeterService.getOne(new LambdaQueryWrapper<InventoryFormMeter>()
|
|
|
+ .eq(InventoryFormMeter::getContractFormId, vo2.getId())
|
|
|
+ .eq(InventoryFormMeter::getContractMeterId, vo2.getContractMeterId()));
|
|
|
+ if (meter == null || (meter.getBuildPictureTotal()+vo2.getCurrentChangeTotal() < 0)){
|
|
|
+ throw new ServiceException(voMap.get(vo2.getContractMeterId()).getNodeName()+"部位下,未找到清单("+vo2.getFormName()+")的分解信息,不能负变更");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置节点id
|
|
|
+ inventory.setContractMeterId(vo2.getContractMeterId());
|
|
|
//计算变更后
|
|
|
inventory.setChangeAfterTotal(inventory.getChangeBeforeTotal() + inventory.getChangeTotal());
|
|
|
inventory.setChangeBeforeMoney(vo2.getContractMoney());
|
|
@@ -307,14 +361,23 @@ public class ChangeTokenFormServiceImpl extends BaseServiceImpl<ChangeTokenFormM
|
|
|
//查询节点信息
|
|
|
List<ChangeNodeVO> nodeList = baseMapper.getNodeList(vo.getContractId(),vo.getId());
|
|
|
if (nodeList.size() != 0) {
|
|
|
- for (ChangeNodeVO nodeVO : nodeList) {
|
|
|
- nodeVO.setNodeUrl(middleMeterApplyService.getNodeDivide(nodeVO.getId()));
|
|
|
+ //查询出当前变更令下所有清单信息
|
|
|
+ List<ChangeFormVO2> formList = baseMapper.getFormList(vo.getContractId(),vo.getId());
|
|
|
+ if (formList.size() != 0) {
|
|
|
+ //按照部位分组
|
|
|
+ Map<Long, List<ChangeFormVO2>> map = formList.stream().collect(Collectors.groupingBy(ChangeFormVO2::getContractMeterId));
|
|
|
+ for (ChangeNodeVO nodeVO : nodeList) {
|
|
|
+ List<ChangeFormVO2> vo2s = map.get(nodeVO.getId());
|
|
|
+ nodeVO.setFormList(vo2s);
|
|
|
+ nodeVO.setNodeUrl(middleMeterApplyService.getNodeDivide(nodeVO.getId()));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (ChangeNodeVO nodeVO : nodeList) {
|
|
|
+ nodeVO.setNodeUrl(middleMeterApplyService.getNodeDivide(nodeVO.getId()));
|
|
|
+ }
|
|
|
}
|
|
|
vo.setNodeList(nodeList);
|
|
|
}
|
|
|
- //查询清单信息
|
|
|
- List<ChangeFormVO2> formList = baseMapper.getFormList(vo.getContractId(),vo.getId());
|
|
|
- vo.setFormList(formList);
|
|
|
//查询附件信息
|
|
|
List<AttachmentForm> list = attachmentFormService.list(new LambdaQueryWrapper<AttachmentForm>()
|
|
|
.eq(AttachmentForm::getContractId, vo.getContractId())
|