Browse Source

Merge remote-tracking branch 'origin/master' into master

yangyj 7 months ago
parent
commit
9b00df1d80
24 changed files with 844 additions and 20 deletions
  1. 11 5
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterial.java
  2. 85 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java
  3. 61 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialPrice.java
  4. 65 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialValidity.java
  5. 6 6
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialVO.java
  6. 49 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialVO2.java
  7. 20 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/SyncMaterialVO.java
  8. 35 6
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialController.java
  9. 35 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.java
  10. 7 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.xml
  11. 7 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialMapper.java
  12. 14 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialMapper.xml
  13. 35 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialPriceMapper.java
  14. 7 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialPriceMapper.xml
  15. 35 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.java
  16. 8 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.xml
  17. 34 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialAdjustService.java
  18. 34 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialPriceService.java
  19. 14 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialService.java
  20. 34 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialValidityService.java
  21. 40 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java
  22. 41 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialPriceServiceImpl.java
  23. 127 2
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialServiceImpl.java
  24. 40 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialValidityServiceImpl.java

+ 11 - 5
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterial.java

@@ -74,11 +74,17 @@ public class ContractMaterial extends BaseEntity {
      */
     @ApiModelProperty(value = "单价")
     private BigDecimal price;
-    /**
-     * 数量
-     */
-    @ApiModelProperty(value = "数量")
-    private BigDecimal amount;
 
+    @ApiModelProperty(value = "材料损耗率")
+    private BigDecimal wastageRatio;
+
+    @ApiModelProperty(value = "调差限额百分比")
+    private BigDecimal quotaRatio;
+
+    @ApiModelProperty(value = "业主收益/承担百分比")
+    private BigDecimal ownerRatio;
+
+    @ApiModelProperty(value = "材料总和抵扣率")
+    private BigDecimal deductionRatio;
 
 }

+ 85 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java

@@ -0,0 +1,85 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 合同材料表实体类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+@TableName("s_contract_material_adjust")
+@EqualsAndHashCode(callSuper = true)
+public class ContractMaterialAdjust extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 项目id
+     */
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+    /**
+     * 合同段id
+     */
+    @ApiModelProperty(value = "合同段id")
+    private Long contractId;
+
+    @ApiModelProperty(value = "合同材料id")
+    private Long contractMaterialId;
+
+    @ApiModelProperty(value = "合同计量期id(调差期)")
+    private Long contractPeriodId;
+
+    @ApiModelProperty(value = "调差月份")
+    private LocalDate adjustMonth;
+
+    @ApiModelProperty(value = "材料名称")
+    private String materialName;
+
+    @ApiModelProperty(value = "材料基准价格")
+    private BigDecimal materialPrice;
+
+    @ApiModelProperty(value = "实时价格id")
+    private Long currentPriceId;
+
+    @ApiModelProperty(value = "实时价格")
+    private BigDecimal currentPrice;
+
+    @ApiModelProperty(value = "价差幅度,百分比")
+    private BigDecimal rangePriceRatio;
+
+    @ApiModelProperty(value = "材料数量")
+    private BigDecimal materialTotal;
+
+    @ApiModelProperty(value = "调差金额")
+    private BigDecimal adjustMoney;
+
+    @ApiModelProperty(value = "调差计算式")
+    private String adjustCalculation;
+
+}

+ 61 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialPrice.java

@@ -0,0 +1,61 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 合同材料表实体类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+@TableName("s_contract_material_price")
+@EqualsAndHashCode(callSuper = true)
+public class ContractMaterialPrice extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 项目id
+     */
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+    /**
+     * 合同段id
+     */
+    @ApiModelProperty(value = "合同段id")
+    private Long contractId;
+
+    @ApiModelProperty(value = "材料价格有效期id")
+    private Long materialValidityId;
+
+    @ApiModelProperty(value = "合同材料id")
+    private Long contractMaterialId;
+
+    @ApiModelProperty(value = "实时单价")
+    private BigDecimal currentPrice;
+
+}

+ 65 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialValidity.java

@@ -0,0 +1,65 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 合同材料表实体类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+@TableName("s_contract_material_validity")
+@EqualsAndHashCode(callSuper = true)
+public class ContractMaterialValidity extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 项目id
+     */
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+    /**
+     * 合同段id
+     */
+    @ApiModelProperty(value = "合同段id")
+    private Long contractId;
+
+    @ApiModelProperty(value = "父id")
+    private Long parentId;
+
+    @ApiModelProperty(value = "开始日期")
+    private LocalDate startDate;
+
+    @ApiModelProperty(value = "结束日期")
+    private LocalDate endDate;
+
+    @ApiModelProperty(value = "节点名称")
+    private String nodeName;
+
+
+}

+ 6 - 6
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialVO.java

@@ -34,14 +34,14 @@ import java.math.BigDecimal;
 public class ContractMaterialVO extends ContractMaterial {
 	private static final long serialVersionUID = 1L;
 
-	@ApiModelProperty(value = "节点名称")
-	private String nodeName;
+	@ApiModelProperty(value = "项目id")
+	private Long projectId;
 
-	@ApiModelProperty(value = "ture有子节点,false没有子节点")
-	private Boolean hasChild;
+	@ApiModelProperty(value = "合同段id")
+	private Long contractId;
 
-	@ApiModelProperty(value = "计量金额")
-	private BigDecimal meterMoney;
+	@ApiModelProperty(value = "材料编号")
+	private String materialNumber;
 
 
 }

+ 49 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialVO2.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.ContractMaterial;
+
+import java.math.BigDecimal;
+
+/**
+ * 合同材料分页
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ContractMaterialVO2 extends ContractMaterial {
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty(value = "其他合同段数量")
+	private Integer otherTotal;
+
+	@ApiModelProperty(value = "被调差数量")
+	private Integer adjustTotal;
+
+	@ApiModelProperty(value = "是否可以同步,0否1是")
+	private Integer isSync;
+
+	@ApiModelProperty(value = "是否可以修改和删除,0否1是")
+	private Integer isUpdateOrDelete;
+
+}

+ 20 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/SyncMaterialVO.java

@@ -0,0 +1,20 @@
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.ContractMaterial;
+
+/**
+ * @Param   同步材料
+ * @Author wangwl
+ * @Date 2024/4/19 10:52
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SyncMaterialVO  extends ContractMaterial {
+
+    @ApiModelProperty(value = "数据来源(合同段名称)")
+    private String contractName;
+
+}

+ 35 - 6
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialController.java

@@ -26,6 +26,8 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.meter.vo.ContractMaterialTreeVO;
+import org.springblade.meter.vo.ContractMaterialVO2;
+import org.springblade.meter.vo.SyncMaterialVO;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -57,7 +59,8 @@ public class ContractMaterialController extends BladeController {
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "新增或修改", notes = "传入contractMaterial")
 	public R submit(@Valid @RequestBody ContractMaterial contractMaterial) {
-		return R.status(contractMaterialService.saveOrUpdate(contractMaterial));
+		contractMaterialService.addOrUpdate(contractMaterial);
+		return R.success("操作成功");
 	}
 
 	/**
@@ -72,27 +75,53 @@ public class ContractMaterialController extends BladeController {
 			@ApiImplicitParam(name = "current", value = "当前页", required = true),
 			@ApiImplicitParam(name = "size", value = "每页数量", required = true)
 	})
-	public R<IPage<ContractMaterial>> list(ContractMaterial contractMaterial, Query query) {
-		IPage<ContractMaterial> pages = contractMaterialService.page(Condition.getPage(query), Condition.getQueryWrapper(contractMaterial));
+	public R<IPage<ContractMaterialVO2>> list(ContractMaterial material, Query query) {
+		IPage<ContractMaterialVO2> pages = contractMaterialService.page2(material,query);
 		return R.data(pages);
 	}
 
+	@GetMapping("/getSyncData")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "获取同步数据", notes = "传入项目id合同段id和材料编号")
+	@ApiImplicitParams(value = {
+			@ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+			@ApiImplicitParam(name = "contractId", value = "合同id", required = true),
+			@ApiImplicitParam(name = "materialNumber", value = "材料编号", required = true),
+	})
+	public R<List<SyncMaterialVO>> getSyncData(ContractMaterial material) {
+		List<SyncMaterialVO> list = contractMaterialService.getSyncData(material);
+		return R.data(list);
+	}
+
+	@GetMapping("/syncMaterial")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "同步材料", notes = "传入材料id,和选中行id")
+	@ApiImplicitParams(value = {
+			@ApiImplicitParam(name = "id", value = "材料id", required = true),
+			@ApiImplicitParam(name = "selectId", value = "选中行id", required = true),
+	})
+	public R<String> syncMaterial(Long id,Long selectId) {
+		contractMaterialService.syncMaterial(id,selectId);
+		return R.success("同步成功");
+	}
+
 	
 	/**
 	 * 删除 合同材料表
 	 */
 	@PostMapping("/remove")
-	@ApiOperationSupport(order = 4)
+	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "删除", notes = "传入ids")
 	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
-		return R.status(contractMaterialService.deleteLogic(Func.toLongList(ids)));
+		contractMaterialService.delete(ids);
+		return R.success("删除成功");
 	}
 
 	/**
 	 * 材料树 合同材料表
 	 */
 	@GetMapping("/materialTree")
-	@ApiOperationSupport(order = 2)
+	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "材料树", notes = "传入合同id")
 	public R<List<ContractMaterialTreeVO>> materialTree(Long contractId) {
 		return R.data(contractMaterialService.materialTree(contractId));

+ 35 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialAdjust;
+
+import java.util.Set;
+
+/**
+ * 附件表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface ContractMaterialAdjustMapper extends BaseMapper<ContractMaterialAdjust> {
+
+
+}

+ 7 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.meter.mapper.ContractMaterialAdjustMapper">
+
+
+
+</mapper>

+ 7 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialMapper.java

@@ -16,11 +16,14 @@
  */
 package org.springblade.meter.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.springblade.meter.entity.ContractMaterial;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 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 java.util.List;
 
@@ -34,4 +37,8 @@ public interface ContractMaterialMapper extends BaseMapper<ContractMaterial> {
 
 
     List<ContractMaterialVO> getALLMaterial(@Param("contractId") Long contractId);
+
+    IPage<ContractMaterialVO2> page2(IPage<ContractMaterialVO2> iPage,@Param("material") ContractMaterial material);
+
+    List<SyncMaterialVO> getSyncData(@Param("material") ContractMaterial material);
 }

+ 14 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialMapper.xml

@@ -19,7 +19,6 @@
         <result column="specification" property="specification"/>
         <result column="unit" property="unit"/>
         <result column="price" property="price"/>
-        <result column="amount" property="amount"/>
     </resultMap>
     <select id="getALLMaterial" resultType="org.springblade.meter.vo.ContractMaterialVO">
         select *,false as hasChild,
@@ -27,6 +26,20 @@
                 ELSE concat(material_name, '[',material_number,']') end) as nodeName
         from s_contract_material where is_deleted = 0 and contract_id = #{contractId}
     </select>
+    <select id="page2" resultType="org.springblade.meter.vo.ContractMaterialVO2">
+        select *,
+               (select count(1) from s_contract_material scm2 where is_deleted = 0 and project_id = #{material.projectId}
+                        and contract_id != #{material.contractId} and scm.material_number = scm2.material_number ) as otherTotal,
+               (select count(1) from s_contract_material_adjust where is_deleted = 0 and contract_id = #{material.contractId} and scm.id = contract_material_id) as adjustTotal
+        from s_contract_material scm where is_deleted = 0 and contract_id = #{material.contractId}
+    </select>
+    <select id="getSyncData" resultType="org.springblade.meter.vo.SyncMaterialVO">
+        select *,(select contract_name from m_contract_info where id = scm.contract_id) as contractName
+        from s_contract_material scm
+        where is_deleted = 0 and project_id = #{material.projectId}
+          and contract_id != #{material.contractId}
+          and scm.material_number = #{material.materialNumber}
+    </select>
 
 
 </mapper>

+ 35 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialPriceMapper.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialPrice;
+
+import java.util.Set;
+
+/**
+ * 附件表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface ContractMaterialPriceMapper extends BaseMapper<ContractMaterialPrice> {
+
+
+}

+ 7 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialPriceMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.meter.mapper.ContractMaterialPriceMapper">
+
+
+
+</mapper>

+ 35 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialValidity;
+
+import java.util.Set;
+
+/**
+ * 附件表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface ContractMaterialValidityMapper extends BaseMapper<ContractMaterialValidity> {
+
+
+}

+ 8 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.meter.mapper.ContractMaterialValidityMapper">
+
+
+
+
+</mapper>

+ 34 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialAdjustService.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialAdjust;
+
+import java.util.Set;
+
+/**
+ * 附件表 服务类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface IContractMaterialAdjustService extends BaseService<ContractMaterialAdjust> {
+
+
+}

+ 34 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialPriceService.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialPrice;
+
+import java.util.Set;
+
+/**
+ * 附件表 服务类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface IContractMaterialPriceService extends BaseService<ContractMaterialPrice> {
+
+
+}

+ 14 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialService.java

@@ -16,9 +16,13 @@
  */
 package org.springblade.meter.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.mp.support.Query;
 import org.springblade.meter.entity.ContractMaterial;
 import org.springblade.core.mp.base.BaseService;
 import org.springblade.meter.vo.ContractMaterialTreeVO;
+import org.springblade.meter.vo.ContractMaterialVO2;
+import org.springblade.meter.vo.SyncMaterialVO;
 
 import java.util.List;
 
@@ -32,4 +36,14 @@ public interface IContractMaterialService extends BaseService<ContractMaterial>
 
 
     List<ContractMaterialTreeVO> materialTree(Long contractId);
+
+    void addOrUpdate(ContractMaterial contractMaterial);
+
+    IPage<ContractMaterialVO2> page2(ContractMaterial material, Query query);
+
+    void  syncMaterial(Long id,Long selectId);
+
+    List<SyncMaterialVO> getSyncData(ContractMaterial material);
+
+    void delete(String ids);
 }

+ 34 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialValidityService.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialValidity;
+
+import java.util.Set;
+
+/**
+ * 附件表 服务类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface IContractMaterialValidityService extends BaseService<ContractMaterialValidity> {
+
+
+}

+ 40 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java

@@ -0,0 +1,40 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.service.impl;
+
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialAdjust;
+import org.springblade.meter.mapper.AttachmentFormMapper;
+import org.springblade.meter.mapper.ContractMaterialAdjustMapper;
+import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IContractMaterialAdjustService;
+import org.springframework.stereotype.Service;
+
+import java.util.Set;
+
+/**
+ * 附件表 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Service
+public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractMaterialAdjustMapper, ContractMaterialAdjust> implements IContractMaterialAdjustService {
+
+
+}

+ 41 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialPriceServiceImpl.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.service.impl;
+
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialPrice;
+import org.springblade.meter.mapper.AttachmentFormMapper;
+import org.springblade.meter.mapper.ContractMaterialPriceMapper;
+import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IContractMaterialPriceService;
+import org.springframework.stereotype.Service;
+
+import java.util.Set;
+
+/**
+ * 附件表 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Service
+public class ContractMaterialPriceServiceImpl extends BaseServiceImpl<ContractMaterialPriceMapper, ContractMaterialPrice> implements IContractMaterialPriceService {
+
+
+
+}

+ 127 - 2
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialServiceImpl.java

@@ -16,17 +16,34 @@
  */
 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;
 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;
 import java.util.List;
+import java.util.function.Consumer;
 
 /**
  * 合同材料表 服务实现类
@@ -35,8 +52,14 @@ import java.util.List;
  * @since 2023-11-29
  */
 @Service
+@AllArgsConstructor
 public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMaterialMapper, ContractMaterial> implements IContractMaterialService {
 
+    private final IContractMaterialAdjustService adjustService;
+
+    private final IContractMaterialPriceService priceService;
+
+
 
     /**
      * 材料树 合同材料表
@@ -53,8 +76,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 +86,106 @@ 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){
+            //如果存在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());
+        }
+        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->{
+            l.setIsSync(0);
+            l.setIsUpdateOrDelete(0);
+            if (l.getAdjustTotal() == 0){
+                l.setIsUpdateOrDelete(1);
+                if (l.getOtherTotal() > 0){
+                    l.setIsSync(1);
+                }
+            }
+        });
+        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);
+    }
+
+    @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);
+    }
 }

+ 40 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialValidityServiceImpl.java

@@ -0,0 +1,40 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.service.impl;
+
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialValidity;
+import org.springblade.meter.mapper.AttachmentFormMapper;
+import org.springblade.meter.mapper.ContractMaterialValidityMapper;
+import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IContractMaterialValidityService;
+import org.springframework.stereotype.Service;
+
+import java.util.Set;
+
+/**
+ * 附件表 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Service
+public class ContractMaterialValidityServiceImpl extends BaseServiceImpl<ContractMaterialValidityMapper, ContractMaterialValidity> implements IContractMaterialValidityService {
+
+
+}