Pārlūkot izejas kodu

开工计量单新增报错,合同计量单元导入修改结果提示,修改清单校验

qianxb 8 mēneši atpakaļ
vecāks
revīzija
cf186c5b43

+ 10 - 4
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MeterTreeController.java

@@ -625,6 +625,7 @@ public class MeterTreeController extends BladeController {
         if (StringUtils.isNotBlank(dto.getNodeCode())){
             long count = meterTreeContractService.count(new LambdaUpdateWrapper<MeterTreeContract>()
                     .eq(MeterTreeContract::getNodeCode, dto.getNodeCode())
+                    .eq(MeterTreeContract::getContractId,dto.getContractId())
                     .ne(MeterTreeContract::getId, dto.getId()));
             if (count > 0){
                 throw new ServiceException("修改失败,当前工程编号已经存在");
@@ -869,10 +870,15 @@ public class MeterTreeController extends BladeController {
 
     @PostMapping("/contract/import")
     @ApiOperationSupport(order = 33)
-    @ApiOperation(value = "合同段计量单元导入", notes = "传入当前选择的节点id,excel文件file")
-    public R<Object> contractTreeNodeImport(@RequestParam String id, MultipartFile file) {
-        if (ObjectUtil.isNotEmpty(id) && meterTreeContractService.contractTreeNodeImport2(id, file)) {
-            return R.success("操作成功");
+    @ApiOperation(value = "合同段计量单元导入", notes = "传入当前选择的节点id,导入类型type,excel文件file")
+    public R<String> contractTreeNodeImport(@RequestParam String id,Integer type, MultipartFile file) {
+        if (ObjectUtil.isNotEmpty(id) && type != null) {
+            if (type == 1){
+               return meterTreeContractService.contractTreeNodeImport1(id, file);
+            }else if (type == 2) {
+               return meterTreeContractService.contractTreeNodeImport2(id, file);
+
+            }
         }
         return R.fail("操作失败");
     }

+ 5 - 6
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/StartPayMeterFormController.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.meter.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
@@ -26,6 +27,8 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.meter.dto.StartPayMeterFormDTO;
 import org.springblade.meter.entity.MeterContractInfo;
+import org.springblade.meter.entity.MeterTreeContract;
+import org.springblade.meter.service.MeterTreeContractService;
 import org.springblade.meter.vo.StartPayMeterFormVO;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
@@ -60,12 +63,8 @@ public class StartPayMeterFormController extends BladeController {
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "开工预付款总额", notes = "传入contractId")
 	public R<BigDecimal> getStartAmount(Long contractId) {
-		List<MeterContractInfo> list = jdbcTemplate.queryForList("select dy_total_amount from s_meter_contract_info where contract_id = " + contractId, MeterContractInfo.class);
-		if (list.size() == 0){
-			return R.data(new BigDecimal(0));
-		}else {
-			return R.data(list.get(0).getDyTotalAmount());
-		}
+		BigDecimal big =  startPayMeterFormService.getStartAmount(contractId);
+		return R.data(big);
 	}
 
 

+ 4 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/StartPayMeterFormMapper.java

@@ -22,6 +22,8 @@ import org.springblade.meter.entity.StartPayMeterForm;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.springblade.meter.vo.StartPayMeterFormVO;
 
+import java.math.BigDecimal;
+
 /**
  * 开工预付款计量单 Mapper 接口
  *
@@ -34,4 +36,6 @@ public interface StartPayMeterFormMapper extends BaseMapper<StartPayMeterForm> {
     IPage<StartPayMeterFormVO> meterPage(IPage<StartPayMeterFormVO> page, @Param("contractId") Long contractId,@Param("meterPeriodId") Long meterPeriodId);
 
     StartPayMeterFormVO detail(@Param("id") Long id);
+
+    BigDecimal getStartAmount(@Param("contractId") Long contractId);
 }

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/StartPayMeterFormMapper.xml

@@ -39,6 +39,9 @@
         from s_start_pay_meter_form spmf
         where id = #{id}
     </select>
+    <select id="getStartAmount" resultType="java.math.BigDecimal">
+        select dy_total_amount from s_meter_contract_info where contract_id = #{contractId} and is_deleted = 0
+    </select>
 
 
 </mapper>

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IStartPayMeterFormService.java

@@ -23,6 +23,7 @@ import org.springblade.meter.entity.StartPayMeterForm;
 import org.springblade.core.mp.base.BaseService;
 import org.springblade.meter.vo.StartPayMeterFormVO;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -43,4 +44,6 @@ public interface IStartPayMeterFormService extends BaseService<StartPayMeterForm
     StartPayMeterFormVO detail(Long id);
 
     void delete(List<Long> ids);
+
+    BigDecimal getStartAmount(Long contractId);
 }

+ 4 - 2
blade-service/blade-meter/src/main/java/org/springblade/meter/service/MeterTreeContractService.java

@@ -1,6 +1,7 @@
 package org.springblade.meter.service;
 
 import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.tool.api.R;
 import org.springblade.meter.dto.MeterTreeContractSaveBatchDTO;
 import org.springblade.meter.entity.MeterTreeContract;
 import org.springblade.meter.entity.MeterTreeProject;
@@ -28,6 +29,7 @@ public interface MeterTreeContractService extends BaseService<MeterTreeContract>
     boolean contractTreeNodeImport(String id, MultipartFile file);
 
     //按照层级导入
-    boolean contractTreeNodeImport2(String id, MultipartFile file);
-
+    R<String> contractTreeNodeImport2(String id, MultipartFile file);
+    //只导入一层
+    R<String> contractTreeNodeImport1(String id, MultipartFile file);
 }

+ 36 - 9
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MeterTreeContractServiceImpl.java

@@ -11,6 +11,7 @@ import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.meter.dto.MeterTreeContractSaveBatchDTO;
@@ -971,7 +972,7 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean contractTreeNodeImport2(String id, MultipartFile file) {
+    public R<String> contractTreeNodeImport2(String id, MultipartFile file) {
         MeterTreeContract meterTreeContract = baseMapper.selectById(id);
         if (meterTreeContract.getAncestor().split(",").length > 5) {
             throw new ServiceException("只能从前五层节点开始导入,操作失败");
@@ -989,7 +990,20 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
         }
 
         /*解析excel*/
-        List<Map<String, String>> parseExcelFileToList = this.parseExcelFile(file);
+        List<Map<String, String>> parseExcelFileToList;
+        try {
+             parseExcelFileToList = this.parseExcelFile(file);
+        }catch (Exception e){
+            throw new ServiceException("excel解析失败,请检查格式:"+e.getMessage());
+        }
+        if (parseExcelFileToList.size() == 0){
+            throw new ServiceException("excel中未发现数据,请检查后再导入");
+        }
+        parseExcelFileToList.stream().forEach(l->{
+            if (StringUtils.isNotBlank(l.get("清单编号")) && StringUtils.isBlank(l.get("施工图数量"))){
+                throw new ServiceException("清单:"+l.get("清单编号")+"没有施工图数量,请填写后重新导入");
+            }
+        });
 
         /*节点新增*/
         List<MeterTreeContract> resultNodeListAdd = new LinkedList<>();
@@ -999,6 +1013,8 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
         List<InventoryFormMeter> resultFormListAdd = new LinkedList<>();
         /*清单中间数量修改*/
         List<InventoryFormMeter> resultFormListUpdate = new LinkedList<>();
+        /*合同清单变更后数量修改*/
+        List<ContractInventoryForm> InventoryFormListUpdate = new LinkedList<>();
 
         /*导入节点的子级信息*/
         //查询当前节点,有节点编号的所有子节点
@@ -1406,8 +1422,9 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
             }
         }
 
-        boolean var = false;
-
+        int addNode = 0;
+        int addForm = 0;
+        int updateForm = 0;
         /*节点*/
         if (resultNodeListAdd.size() > 0) {
             //判断要新增的数据中,清单编号是否已经存在
@@ -1419,13 +1436,13 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                 }
             }
             this.saveBatch(resultNodeListAdd, 1000);
-            var = true;
+            addNode = resultNodeListAdd.size();
         }
 
         /*清单中间新增*/
         if (resultFormListAdd.size() > 0) {
             inventoryFormMeterMapper.batchInsert(resultFormListAdd);
-            var = true;
+            addForm = resultFormListAdd.size();
         }
 
         /*清单中间数量修改*/
@@ -1443,7 +1460,7 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                         inventoryFormMeter.getChangeBuildPictureMoney(),
                         inventoryFormMeter.getId());
             }
-            var = true;
+            updateForm = resultFormListUpdate.size();
         }
 
         /*节点金额修改*/
@@ -1475,10 +1492,20 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                             moneyChangeAll,
                             treeContractId);
                 }
-                var = true;
             }
         }
-        return true;
+        return R.success("成功导入:节点("+addNode+")个,"+"新增清单("+addForm+")条,"+"修改清单("+updateForm+")条.");
+    }
+
+    /**
+     * 只导入一层
+     * @param id
+     * @param file
+     * @return
+     */
+    @Override
+    public R<String> contractTreeNodeImport1(String id, MultipartFile file) {
+        return null;
     }
 
     /**

+ 16 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/StartPayMeterFormServiceImpl.java

@@ -23,8 +23,10 @@ import lombok.AllArgsConstructor;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
 import org.springblade.meter.dto.StartPayMeterFormDTO;
 import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.MeterContractInfo;
 import org.springblade.meter.entity.MeterPeriod;
 import org.springblade.meter.entity.StartPayMeterForm;
 import org.springblade.meter.mapper.StartPayMeterFormMapper;
@@ -36,6 +38,7 @@ import org.springblade.meter.vo.StartPayMeterFormVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -143,4 +146,17 @@ public class StartPayMeterFormServiceImpl extends BaseServiceImpl<StartPayMeterF
             this.removeById(id);
         }
     }
+
+    /**
+     * 开工预付款总额
+     */
+    @Override
+    public BigDecimal getStartAmount(Long contractId) {
+        BigDecimal big = baseMapper.getStartAmount(contractId);
+        if (big == null){
+            return BigDecimal.ZERO;
+        }else {
+            return big;
+        }
+    }
 }