|
@@ -19,12 +19,18 @@ package org.springblade.meter.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.meter.entity.ContractInventoryForm;
|
|
|
import org.springblade.meter.entity.ContractMaterial;
|
|
|
+import org.springblade.meter.entity.ContractMaterialAdjust;
|
|
|
+import org.springblade.meter.entity.ContractMaterialPrice;
|
|
|
import org.springblade.meter.mapper.ContractMaterialMapper;
|
|
|
+import org.springblade.meter.service.IContractMaterialAdjustService;
|
|
|
+import org.springblade.meter.service.IContractMaterialPriceService;
|
|
|
import org.springblade.meter.service.IContractMaterialService;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.meter.vo.ContractMaterialTreeVO;
|
|
@@ -32,6 +38,7 @@ import org.springblade.meter.vo.ContractMaterialVO;
|
|
|
import org.springblade.meter.vo.ContractMaterialVO2;
|
|
|
import org.springblade.meter.vo.SyncMaterialVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
@@ -45,8 +52,14 @@ import java.util.function.Consumer;
|
|
|
* @since 2023-11-29
|
|
|
*/
|
|
|
@Service
|
|
|
+@AllArgsConstructor
|
|
|
public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMaterialMapper, ContractMaterial> implements IContractMaterialService {
|
|
|
|
|
|
+ private final IContractMaterialAdjustService adjustService;
|
|
|
+
|
|
|
+ private final IContractMaterialPriceService priceService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 材料树 合同材料表
|
|
@@ -90,6 +103,13 @@ public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMateria
|
|
|
wrapper2.eq(ContractMaterial::getContractId,contractMaterial.getContractId());
|
|
|
wrapper2.eq(ContractMaterial::getMaterialName,contractMaterial.getMaterialName());
|
|
|
if (contractMaterial.getId() != null){
|
|
|
+ //如果存在id,还要校验是否已经被调差
|
|
|
+ List<ContractMaterialAdjust> list = adjustService.list(new LambdaQueryWrapper<ContractMaterialAdjust>()
|
|
|
+ .eq(ContractMaterialAdjust::getContractId, contractMaterial.getContractId())
|
|
|
+ .eq(ContractMaterialAdjust::getContractMaterialId, contractMaterial.getId()));
|
|
|
+ if (list.size() > 0){
|
|
|
+ throw new ServiceException("当前材料已经被调差,不能被修改");
|
|
|
+ }
|
|
|
wrapper1.ne(ContractMaterial::getId,contractMaterial.getId());
|
|
|
wrapper2.ne(ContractMaterial::getId,contractMaterial.getId());
|
|
|
}
|
|
@@ -109,10 +129,13 @@ public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMateria
|
|
|
IPage<ContractMaterialVO2> iPage = new Page<>(query.getCurrent(),query.getSize());
|
|
|
iPage = baseMapper.page2(iPage,material);
|
|
|
iPage.getRecords().stream().forEach(l->{
|
|
|
- if (l.getAdjustTotal() == 0 && l.getOtherTotal() > 0){
|
|
|
- l.setIsSync(1);
|
|
|
- }else {
|
|
|
- l.setIsSync(0);
|
|
|
+ l.setIsSync(0);
|
|
|
+ l.setIsUpdateOrDelete(0);
|
|
|
+ if (l.getAdjustTotal() == 0){
|
|
|
+ l.setIsUpdateOrDelete(1);
|
|
|
+ if (l.getOtherTotal() > 0){
|
|
|
+ l.setIsSync(1);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
return iPage;
|
|
@@ -143,4 +166,26 @@ public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMateria
|
|
|
public List<SyncMaterialVO> getSyncData(ContractMaterial material) {
|
|
|
return baseMapper.getSyncData(material);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void delete(String ids) {
|
|
|
+ if (StringUtils.isBlank(ids)){
|
|
|
+ throw new ServiceException("请先选择要删除的数据");
|
|
|
+ }
|
|
|
+ List<Long> list = Func.toLongList(ids);
|
|
|
+ //如果存在id,还要校验是否已经被调差
|
|
|
+ List<ContractMaterialAdjust> adjusts = adjustService.list(new LambdaQueryWrapper<ContractMaterialAdjust>()
|
|
|
+ .in(ContractMaterialAdjust::getContractMaterialId, list));
|
|
|
+ if (adjusts.size() > 0){
|
|
|
+ throw new ServiceException("材料已经被调差,不能被修改");
|
|
|
+ }
|
|
|
+ //删除实时价格
|
|
|
+ priceService.remove(new LambdaQueryWrapper<ContractMaterialPrice>()
|
|
|
+ .in(ContractMaterialPrice::getContractMaterialId,list));
|
|
|
+ //删除调差系数
|
|
|
+
|
|
|
+ //删除材料信息
|
|
|
+ this.removeBatchByIds(list);
|
|
|
+ }
|
|
|
}
|