|
@@ -0,0 +1,165 @@
|
|
|
+package org.springblade.manager.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import javassist.runtime.DotClass;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.common.utils.ForestNodeMergerEx;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.excel.util.ExcelUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.constant.BladeConstant;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
|
|
|
+import org.springblade.manager.dto.ArchiveTreeDTO;
|
|
|
+import org.springblade.manager.dto.ArchiveTreeSortDTO;
|
|
|
+import org.springblade.manager.dto.MoistureContentDTO;
|
|
|
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
|
|
|
+import org.springblade.manager.entity.ArchiveTree;
|
|
|
+import org.springblade.manager.entity.MixProportionInfo;
|
|
|
+import org.springblade.manager.entity.ProjectInfo;
|
|
|
+import org.springblade.manager.excel.MixProportionInfoExcel;
|
|
|
+import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
|
|
|
+import org.springblade.manager.mapper.ArchiveTreeMapper;
|
|
|
+import org.springblade.manager.mapper.MixProportionInfoMapper;
|
|
|
+import org.springblade.manager.service.*;
|
|
|
+import org.springblade.manager.utils.DiffListUtil;
|
|
|
+import org.springblade.manager.utils.ForestNodeMerger;
|
|
|
+import org.springblade.manager.vo.ArchiveTreeAutoRuleVO;
|
|
|
+import org.springblade.manager.vo.ArchiveTreeVO2;
|
|
|
+import org.springblade.manager.vo.WbsTreeVO2;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class MixProportionInfoServiceImpl extends BaseServiceImpl<MixProportionInfoMapper, MixProportionInfo> implements IMixProportionInfoService {
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<MixProportionInfo> designStrengthList(String searchValue,Long contractId) {
|
|
|
+ return baseMapper.designStrengthList(searchValue,contractId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer compareInfo(Set<String> number, Set<String> strength, Long contractId) {
|
|
|
+ return baseMapper.compareInfo(number,strength,contractId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R importMixProportionInfo(MultipartFile file, Long projectId, Long contractId) {
|
|
|
+ List<MixProportionInfoExcel> list = ExcelUtil.read(file, MixProportionInfoExcel.class);
|
|
|
+ if(list!=null && list.size()>=1){
|
|
|
+ Set<String> number = new HashSet<>();
|
|
|
+ Set<String> strength = new HashSet<>();
|
|
|
+ //校验数据
|
|
|
+ for (MixProportionInfoExcel excel : list) {
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotBlank(excel.getReportNumber())){
|
|
|
+ number.add(excel.getReportNumber());
|
|
|
+ }else {
|
|
|
+ throw new ServiceException("文件中缺少配合比报告编号,请修改后重新导入");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(excel.getDesignStrength())){
|
|
|
+ strength.add(excel.getDesignStrength());
|
|
|
+ }else {
|
|
|
+ throw new ServiceException("文件中缺少设计强度,请修改后重新导入");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (number.size() != list.size()){
|
|
|
+ throw new ServiceException("文件中配合比报告编号重复,请修改后重新导入");
|
|
|
+ }
|
|
|
+ if (strength.size() != list.size()){
|
|
|
+ throw new ServiceException("文件中设计强度重复,请修改后重新导入");
|
|
|
+ }
|
|
|
+ //判断是否存在相同的配合比编号,和设计强度
|
|
|
+ Integer infos = this.compareInfo(number,strength,contractId);
|
|
|
+ if (infos != 0){
|
|
|
+ throw new ServiceException("文件数据与现有数据重复,请修改后重新导入");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MixProportionInfo> vos = list.stream().map(f -> {
|
|
|
+ MixProportionInfo tag = new MixProportionInfo();
|
|
|
+ BeanUtil.copy(f,tag);
|
|
|
+ tag.setProjectId(projectId);
|
|
|
+ tag.setContractId(contractId);
|
|
|
+ return tag;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ this.saveBatch(vos);
|
|
|
+ return R.success("导入成功");
|
|
|
+ }else {
|
|
|
+ return R.fail("没有一条数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算含水率
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R calculateWater(MoistureContentDTO dto) {
|
|
|
+ //获取位置前缀后缀
|
|
|
+ String prefix= dto.getKey().replaceAll("__[\\d_]+", "");
|
|
|
+ String suffix = dto.getKey().replaceAll("key_\\d+__", "");
|
|
|
+ String[] split = suffix.split("_");
|
|
|
+ String s1 = split[0];
|
|
|
+ Integer s2 = Integer.parseInt(split[1]);
|
|
|
+ //结果集
|
|
|
+ Map<String,BigDecimal> map = new HashMap<>();
|
|
|
+ //获取配合比信息
|
|
|
+ MixProportionInfo info = this.getById(dto.getMixProportionId());
|
|
|
+ if (info == null){
|
|
|
+ throw new ServiceException("获取配合比信息失败");
|
|
|
+ }
|
|
|
+ //含水量计算
|
|
|
+ //黄砂
|
|
|
+ BigDecimal sand = dto.getSand().divide(new BigDecimal(100)).multiply(info.getSand());
|
|
|
+ //碎石1
|
|
|
+ BigDecimal macadamOne = dto.getMacadamOne().divide(new BigDecimal(100)).multiply(info.getMacadamOne());
|
|
|
+ //碎石2
|
|
|
+ BigDecimal macadamTwo = dto.getMacadamTwo().divide(new BigDecimal(100)).multiply(info.getMacadamTwo());
|
|
|
+ //碎石3
|
|
|
+ BigDecimal macadamThree = dto.getMacadamThree().divide(new BigDecimal(100)).multiply(info.getMacadamThree());
|
|
|
+
|
|
|
+ //施工配合比计算
|
|
|
+ //水泥
|
|
|
+ BigDecimal cement = info.getCement();
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2),cement);
|
|
|
+ //黄砂
|
|
|
+ BigDecimal sand2 = info.getSand().add(sand);
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+1),sand2);
|
|
|
+ //碎石1
|
|
|
+ BigDecimal macadamOne2 = info.getMacadamOne().add(macadamOne);
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+2),macadamOne2);
|
|
|
+ //碎石2
|
|
|
+ BigDecimal macadamTwo2 = info.getMacadamTwo().add(macadamTwo);
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+3),macadamTwo2);
|
|
|
+ //碎石3
|
|
|
+ BigDecimal macadamThree2 = info.getMacadamThree().add(macadamThree);
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+4),macadamThree2);
|
|
|
+ //水
|
|
|
+ BigDecimal water = info.getWater().subtract(sand).subtract(macadamOne).subtract(macadamTwo).subtract(macadamThree);
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+5),water);
|
|
|
+ //掺加剂
|
|
|
+ BigDecimal admixture = info.getAdmixture();
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+6),admixture);
|
|
|
+ //粉煤灰
|
|
|
+ BigDecimal coalAsh = info.getCoalAsh();
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+7),coalAsh);
|
|
|
+ //矿渣粉
|
|
|
+ BigDecimal slagPowder = info.getSlagPowder();
|
|
|
+ map.put(prefix + "__" +s1 + "_" +(s2+8),slagPowder);
|
|
|
+ return R.data(map);
|
|
|
+ }
|
|
|
+}
|