|
@@ -16,17 +16,27 @@
|
|
|
*/
|
|
|
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 org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.meter.entity.ContractInventoryForm;
|
|
|
import org.springblade.meter.entity.ContractMaterial;
|
|
|
import org.springblade.meter.mapper.ContractMaterialMapper;
|
|
|
import org.springblade.meter.service.IContractMaterialService;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.meter.vo.ContractMaterialTreeVO;
|
|
|
import org.springblade.meter.vo.ContractMaterialVO;
|
|
|
+import org.springblade.meter.vo.ContractMaterialVO2;
|
|
|
+import org.springblade.meter.vo.SyncMaterialVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.function.Consumer;
|
|
|
|
|
|
/**
|
|
|
* 合同材料表 服务实现类
|
|
@@ -53,8 +63,8 @@ public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMateria
|
|
|
vo.setHasChild(false);
|
|
|
}else {
|
|
|
for (ContractMaterialVO materialVO : voList) {
|
|
|
- if (materialVO.getPrice() != null && materialVO.getAmount() != null){
|
|
|
- materialVO.setMeterMoney(materialVO.getPrice().multiply(materialVO.getAmount()));
|
|
|
+ if (materialVO.getPrice() != null){
|
|
|
+// materialVO.setMeterMoney(materialVO.getPrice().multiply(materialVO.getAmount()));
|
|
|
}
|
|
|
}
|
|
|
vo.setHasChild(true);
|
|
@@ -63,4 +73,74 @@ public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMateria
|
|
|
vos.add(vo);
|
|
|
return vos;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addOrUpdate(ContractMaterial contractMaterial) {
|
|
|
+ if (StringUtils.isBlank(contractMaterial.getMaterialNumber())){
|
|
|
+ throw new ServiceException("请填写材料编号");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(contractMaterial.getMaterialName())){
|
|
|
+ throw new ServiceException("请填写材料名称");
|
|
|
+ }
|
|
|
+ //校验是否存在当前材料编号和名称
|
|
|
+ LambdaQueryWrapper<ContractMaterial> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ wrapper1.eq(ContractMaterial::getContractId,contractMaterial.getContractId());
|
|
|
+ wrapper1.eq(ContractMaterial::getMaterialNumber,contractMaterial.getMaterialNumber());
|
|
|
+ LambdaQueryWrapper<ContractMaterial> wrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ wrapper2.eq(ContractMaterial::getContractId,contractMaterial.getContractId());
|
|
|
+ wrapper2.eq(ContractMaterial::getMaterialName,contractMaterial.getMaterialName());
|
|
|
+ if (contractMaterial.getId() != null){
|
|
|
+ wrapper1.ne(ContractMaterial::getId,contractMaterial.getId());
|
|
|
+ wrapper2.ne(ContractMaterial::getId,contractMaterial.getId());
|
|
|
+ }
|
|
|
+ List<ContractMaterial> list1 = this.list(wrapper1);
|
|
|
+ if (list1.size() > 0){
|
|
|
+ throw new ServiceException("当前合同段已存在此材料编号");
|
|
|
+ }
|
|
|
+ List<ContractMaterial> list2 = this.list(wrapper2);
|
|
|
+ if (list2.size() > 0){
|
|
|
+ throw new ServiceException("当前合同段已存在此材料名称");
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(contractMaterial);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<ContractMaterialVO2> page2(ContractMaterial material, Query query) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return iPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncMaterial(Long id,Long selectId) {
|
|
|
+ //获取当前材料
|
|
|
+ ContractMaterial thisData = this.getById(id);
|
|
|
+ //获取选择的材料
|
|
|
+ ContractMaterial selectData = this.getById(selectId);
|
|
|
+ if (!thisData.getMaterialNumber().equals(selectData.getMaterialNumber())){
|
|
|
+ throw new ServiceException("数据错误,材料编号不同,请联系管理员");
|
|
|
+ }
|
|
|
+ thisData.setMaterialName(selectData.getMaterialName());
|
|
|
+ thisData.setSpecification(selectData.getSpecification());
|
|
|
+ thisData.setUnit(selectData.getUnit());
|
|
|
+ thisData.setPrice(selectData.getPrice());
|
|
|
+ thisData.setWastageRatio(selectData.getWastageRatio());
|
|
|
+ thisData.setQuotaRatio(selectData.getQuotaRatio());
|
|
|
+ thisData.setOwnerRatio(selectData.getOwnerRatio());
|
|
|
+ thisData.setDeductionRatio(selectData.getDeductionRatio());
|
|
|
+ this.updateById(thisData);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SyncMaterialVO> getSyncData(ContractMaterial material) {
|
|
|
+ return baseMapper.getSyncData(material);
|
|
|
+ }
|
|
|
}
|