Bladeren bron

Merge branch 'master' of http://39.108.216.210:3000/zhuwei/bladex

huangtf 7 maanden geleden
bovenliggende
commit
0d5571b828
20 gewijzigde bestanden met toevoegingen van 363 en 26 verwijderingen
  1. 60 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/ContractMaterialDTO2.java
  2. 3 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/AttachmentForm.java
  3. 8 1
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java
  4. 2 6
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjustDetail.java
  5. 19 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialAdjustVO.java
  6. 3 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/GetLinkAllFormVO.java
  7. 26 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/MaterialAdjustDetailVO.java
  8. 43 3
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialAdjustController.java
  9. 11 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialController.java
  10. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractInventoryFormMapper.java
  11. 3 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractInventoryFormMapper.xml
  12. 11 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.java
  13. 24 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.xml
  14. 3 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialMapper.xml
  15. 14 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialAdjustService.java
  16. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IInventoryFormMaterialService.java
  17. 17 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractInventoryFormServiceImpl.java
  18. 111 8
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java
  19. 2 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialServiceImpl.java
  20. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/InventoryFormMaterialServiceImpl.java

+ 60 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/ContractMaterialDTO2.java

@@ -0,0 +1,60 @@
+/*
+ *      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.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.ContractMaterial;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+
+/**
+ * 合同材料表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+public class ContractMaterialDTO2 {
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty(value = "合同段id")
+	@NotNull(message = "请传入合同段id!")
+	private Long contractId;
+
+	@ApiModelProperty(value = "合同材料id")
+	@NotNull(message = "请传入合同材料id!")
+	private Long contractMaterialId;
+
+	@ApiModelProperty(value = "合同计量期id(调差期)")
+	@NotNull(message = "请传入调差期id!")
+	private Long contractPeriodId;
+
+	@ApiModelProperty(value = "调差时间")
+	private String adjustMonth;
+
+	@ApiModelProperty("当前页")
+	private Integer current;
+
+	@ApiModelProperty("每页的数量")
+	private Integer size;
+
+
+}

+ 3 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/AttachmentForm.java

@@ -19,6 +19,7 @@ package org.springblade.meter.entity;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 
 import io.swagger.annotations.ApiModelProperty;
 import org.springblade.core.mp.base.BaseEntity;
@@ -86,5 +87,7 @@ public class AttachmentForm extends BaseEntity {
     @ApiModelProperty(value = "文件大小名称")
     private String fileSizeName;
 
+    @ApiModelProperty(value = "文件上传时间")
+    private LocalDateTime fileUpTime;
 
 }

+ 8 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java

@@ -58,10 +58,14 @@ public class ContractMaterialAdjust extends BaseEntity {
     @NotNull(message = "请传入合同材料id!")
     private Long contractMaterialId;
 
-    @ApiModelProperty(value = "合同计量期id(调差期)")
+    @ApiModelProperty(value = "调差期id(合同计量期id)")
     @NotNull(message = "请传入调差期id!")
     private Long contractPeriodId;
 
+    @ApiModelProperty(value = "调差期期号(合同计量期期号)")
+    @NotNull(message = "请传入调差期期号!")
+    private String contractPeriodNumber;
+
     @ApiModelProperty(value = "调差月份")
     @NotNull(message = "请填写调差月份!")
     private String adjustMonth;
@@ -100,4 +104,7 @@ public class ContractMaterialAdjust extends BaseEntity {
     @ApiModelProperty(value = "调差计算式")
     private String adjustCalculation;
 
+    @ApiModelProperty(value = "审批状态:0未完成1已完成(此处根据计量期状态)")
+    private Integer approveStatus;
+
 }

+ 2 - 6
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjustDetail.java

@@ -38,14 +38,10 @@ public class ContractMaterialAdjustDetail extends BaseEntity {
 
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 项目id
-     */
+
     @ApiModelProperty(value = "项目id")
     private Long projectId;
-    /**
-     * 合同段id
-     */
+
     @ApiModelProperty(value = "合同段id")
     private Long contractId;
 

+ 19 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialAdjustVO.java

@@ -0,0 +1,19 @@
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.ContractMaterialAdjust;
+
+/**
+ * @Param   分页VO
+ * @Author wangwl
+ * @Date 2024/4/25 9:36
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ContractMaterialAdjustVO extends ContractMaterialAdjust {
+
+    @ApiModelProperty(value = "审批状态名称")
+    private String approveStatusName;
+}

+ 3 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/GetLinkAllFormVO.java

@@ -28,4 +28,7 @@ public class GetLinkAllFormVO {
 
     @ApiModelProperty(value = "调差系数")
     private BigDecimal adjustFactor;
+
+    @ApiModelProperty(value = "是否被引用0否1是,被引用后不允许取消")
+    private Integer isQuote;
 }

+ 26 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/MaterialAdjustDetailVO.java

@@ -0,0 +1,26 @@
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialAdjust;
+import org.springblade.meter.entity.ContractMaterialAdjustDetail;
+
+import java.util.List;
+
+/**
+ * @Param   材料调差详情
+ * @Author wangwl
+ * @Date 2024/4/25 10:15
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class MaterialAdjustDetailVO extends ContractMaterialAdjust {
+
+    @ApiModelProperty(value = "材料明细集合")
+    private List<ContractMaterialAdjustDetail> details;
+
+    @ApiModelProperty(value = "附件集合")
+    private List<AttachmentForm> files;
+}

+ 43 - 3
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialAdjustController.java

@@ -28,13 +28,20 @@ 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.dto.ContractMaterialAdjustAddDTO;
+import org.springblade.meter.dto.ContractMaterialDTO2;
 import org.springblade.meter.entity.AttachmentForm;
 import org.springblade.meter.entity.ContractMaterial;
+import org.springblade.meter.entity.ContractMaterialAdjustDetail;
 import org.springblade.meter.service.IAttachmentFormService;
 import org.springblade.meter.service.IContractMaterialAdjustService;
+import org.springblade.meter.vo.ContractMaterialAdjustVO;
+import org.springblade.meter.vo.MaterialAdjustDetailVO;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import javax.validation.groups.Default;
 
 import javax.validation.Valid;
+import java.util.List;
 
 /**
  * 附件表 控制器
@@ -50,12 +57,45 @@ public class ContractMaterialAdjustController extends BladeController {
 
     private final IContractMaterialAdjustService adjustService;
 
-    @PostMapping("/add")
+    @PostMapping("/get-material-detail")
     @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "新增时获取材料明细", notes = "传入调差期id,材料id")
+    public R<List<ContractMaterialAdjustDetail>> getMaterialDetail(@Valid @RequestBody ContractMaterialDTO2 dto) {
+        List<ContractMaterialAdjustDetail> list = adjustService.getMaterialDetail(dto);
+        return R.data(list);
+    }
+
+    @PostMapping("/add")
+    @ApiOperationSupport(order = 2)
     @ApiOperation(value = "新增", notes = "传入材料调差单")
-    public R submit(@Valid @RequestBody ContractMaterialAdjustAddDTO dto) {
+    public R add(@Valid @RequestBody ContractMaterialAdjustAddDTO dto) {
         adjustService.add(dto);
         return R.success("新增成功");
     }
-	
+
+    @PostMapping("/page")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "材料调差分页", notes = "传入合同id分页信息,搜索条件:调差期id,调差时间")
+    public R<IPage<ContractMaterialAdjustVO>> page(@RequestBody ContractMaterialDTO2 dto) {
+        IPage<ContractMaterialAdjustVO> list = adjustService.page2(dto);
+        return R.data(list);
+    }
+
+    @GetMapping("/detail")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "材料调差详情", notes = "传入材料调差表id")
+    public R<MaterialAdjustDetailVO> detail(Long id) {
+        MaterialAdjustDetailVO vo = adjustService.detail(id);
+        return R.data(vo);
+    }
+
+    @PostMapping("/update")
+    @ApiOperationSupport(order = 5)
+    @ApiOperation(value = "修改", notes = "传入材料调差单")
+    public R update(@Valid @RequestBody ContractMaterialAdjustAddDTO dto) {
+        adjustService.update2(dto);
+        return R.success("修改成功");
+    }
+
+
 }

+ 11 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialController.java

@@ -27,6 +27,8 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.meter.dto.MaterialLinkFormDTO;
 import org.springblade.meter.dto.MaterialListDTO;
+import org.springblade.meter.entity.InventoryFormMaterial;
+import org.springblade.meter.service.IInventoryFormMaterialService;
 import org.springblade.meter.vo.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -51,6 +53,8 @@ public class ContractMaterialController extends BladeController {
 
 	private final IContractMaterialService contractMaterialService;
 
+	private final IInventoryFormMaterialService formMaterialService;
+
 
 	/**
 	 * 新增或修改 合同材料表
@@ -174,5 +178,12 @@ public class ContractMaterialController extends BladeController {
 		contractMaterialService.removeLinkForm(id);
 		return R.success("解除成功");
 	}
+	@PostMapping("/submit-link-form")
+	@ApiOperationSupport(order = 13)
+	@ApiOperation(value = "调差系数-提交编辑", notes = "传入编辑列表数据,只传入id和调差系数")
+	public R submitLinkForm(@RequestBody List<InventoryFormMaterial> list) {
+		formMaterialService.updateBatchById(list);
+		return R.success("修改成功");
+	}
 	
 }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractInventoryFormMapper.java

@@ -70,5 +70,5 @@ public interface ContractInventoryFormMapper extends BaseMapper<ContractInventor
 
     List<FormNodeSortVO> getAllForm(@Param("contractId") Long contractId);
 
-    List<FormTreeVO2> getAllForm2(@Param("contractId") Long contractId);
+    List<FormTreeVO2> getAllForm2(@Param("contractId") Long contractId,@Param("materialId") Long materialId);
 }

+ 3 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractInventoryFormMapper.xml

@@ -174,7 +174,9 @@
         order by -sort desc,create_time
     </select>
     <select id="getAllForm2" resultType="org.springblade.meter.vo.FormTreeVO2">
-        select id ,parent_id,form_name,is_form_node,is_adjust,0 as isSelect,0 as isQuote
+        select id ,parent_id,form_name,is_form_node,is_adjust,0 as isSelect,
+               if((select count(1) from s_contract_material_adjust_detail mad where mad.contract_form_id = scif.id
+                                and mad.contract_material_id = #{materialId}) > 0,1,0) as isQuote
         from s_contract_inventory_form scif where contract_id = #{contractId} and is_deleted = 0
         order by -sort desc,create_time
     </select>

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

@@ -17,10 +17,16 @@
 package org.springblade.meter.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.meter.dto.ContractMaterialDTO2;
 import org.springblade.meter.entity.AttachmentForm;
 import org.springblade.meter.entity.ContractMaterialAdjust;
+import org.springblade.meter.entity.ContractMaterialAdjustDetail;
+import org.springblade.meter.vo.ContractMaterialAdjustVO;
+import org.springblade.meter.vo.MaterialAdjustDetailVO;
 
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -32,4 +38,9 @@ import java.util.Set;
 public interface ContractMaterialAdjustMapper extends BaseMapper<ContractMaterialAdjust> {
 
 
+    List<ContractMaterialAdjustDetail> getMaterialDetail(@Param("dto") ContractMaterialDTO2 dto,@Param("ids") List<Long> ids);
+
+    IPage<ContractMaterialAdjustVO> page2(IPage<ContractMaterialAdjustVO> iPage,@Param("dto") ContractMaterialDTO2 dto);
+
+    MaterialAdjustDetailVO detail(@Param("id") Long id);
 }

+ 24 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.xml

@@ -3,5 +3,28 @@
 <mapper namespace="org.springblade.meter.mapper.ContractMaterialAdjustMapper">
 
 
-
+    <select id="getMaterialDetail" resultType="org.springblade.meter.entity.ContractMaterialAdjustDetail">
+        select ifa.project_id,ifa.contract_id,ifa.middle_meter_id,ifa.contract_form_id,ifa.current_meter_total as meterTotal,
+                cif.form_number,cif.form_name,cif.unit,
+                (select meter_number from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) as meterNumber,
+                (select adjust_factor from s_inventory_form_material ifm where ifm.contract_material_id = #{dto.contractMaterialId}
+                                            and ifm.contract_form_id = ifa.contract_form_id) as adjustFactor
+        from s_inventory_form_apply ifa left join s_contract_inventory_form cif on ifa.contract_form_id = cif.id
+        where ifa.is_deleted = 0 and cif.is_deleted = 0 and ifa.contract_id = #{dto.contractId}
+          and ifa.contract_period_id = #{dto.contractPeriodId} and ifa.contract_form_id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
+    <select id="page2" resultType="org.springblade.meter.vo.ContractMaterialAdjustVO">
+        select *,if(approve_status = 0,'未完成','已完成') as approveStatusName
+        from s_contract_material_adjust
+        where contract_id = #{dto.contractId} and is_deleted = 0 and contract_period_id = #{dto.contractPeriodId}
+        <if test="dto.adjustMonth != null and dto.adjustMonth != ''">
+            and adjust_month = #{dto.adjustMonth}
+        </if>
+    </select>
+    <select id="detail" resultType="org.springblade.meter.vo.MaterialAdjustDetailVO">
+        select * from s_contract_material_adjust where id = #{id}
+    </select>
 </mapper>

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

@@ -58,7 +58,9 @@
         select id,adjust_factor,
                (select form_number from s_contract_inventory_form cif where cif.id = ifm.contract_form_id) as formNumber,
                (select form_name from s_contract_inventory_form cif where cif.id = ifm.contract_form_id) as formName,
-               (select material_name from s_contract_material scm where scm.id = ifm.contract_material_id) as materialName
+               (select material_name from s_contract_material scm where scm.id = ifm.contract_material_id) as materialName,
+               if((select count(1) from s_contract_material_adjust_detail mad where mad.contract_form_id = ifm.contract_form_id
+                                    and mad.contract_material_id = #{materialId}) > 0,1,0) as isQuote
         from s_inventory_form_material ifm
         where  is_deleted = 0 and contract_id = #{contractId} and contract_material_id = #{materialId}
     </select>

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

@@ -16,11 +16,17 @@
  */
 package org.springblade.meter.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.core.mp.base.BaseService;
 import org.springblade.meter.dto.ContractMaterialAdjustAddDTO;
+import org.springblade.meter.dto.ContractMaterialDTO2;
 import org.springblade.meter.entity.AttachmentForm;
 import org.springblade.meter.entity.ContractMaterialAdjust;
+import org.springblade.meter.entity.ContractMaterialAdjustDetail;
+import org.springblade.meter.vo.ContractMaterialAdjustVO;
+import org.springblade.meter.vo.MaterialAdjustDetailVO;
 
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -33,4 +39,12 @@ public interface IContractMaterialAdjustService extends BaseService<ContractMate
 
 
     void add(ContractMaterialAdjustAddDTO dto);
+
+    List<ContractMaterialAdjustDetail> getMaterialDetail(ContractMaterialDTO2 dto);
+
+    IPage<ContractMaterialAdjustVO> page2(ContractMaterialDTO2 dto);
+
+    MaterialAdjustDetailVO detail(Long id);
+
+    void update2(ContractMaterialAdjustAddDTO dto);
 }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IInventoryFormMaterialService.java

@@ -23,7 +23,7 @@ import org.springblade.meter.entity.InventoryFormMaterial;
 import java.util.Set;
 
 /**
- * 附件表 服务类
+ *
  *
  * @author BladeX
  * @since 2023-11-29

+ 17 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractInventoryFormServiceImpl.java

@@ -60,6 +60,7 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
 
         private final IInventoryFormMaterialService formMaterialService;
 
+
     /**
      * 导入excel
      * @param file
@@ -454,6 +455,15 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
         if (isChange){
             throw new ServiceException("当前节点已经被分解或者变更,不允许修改");
         }
+        //校验是否允许调差是否被修改,如果从是修改为否,则校验是否已经关联了
+        if (nodeInfo.getIsAdjust() == 1 && form.getIsAdjust() == 0){
+            int count = Math.toIntExact(formMaterialService.count(new LambdaQueryWrapper<InventoryFormMaterial>()
+                    .eq(InventoryFormMaterial::getContractFormId, form.getId())));
+            if (count > 0){
+                throw new ServiceException("当前清单已经关联材料,请取消关联后再修改不允许调差");
+            }
+
+        }
         //如果当前节点类型和修改后的节点类型相同,则不校验
         if (nodeInfo.getIsFormNode().equals(form.getIsFormNode())) {
             //相同则先判断修改后节点类型是否为清单类型
@@ -563,6 +573,12 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
         if (total > 0) {
             throw new ServiceException("当前节点下有子节点已经被变更,不能删除");
         }
+        //校验是否被材料关联
+        int count = Math.toIntExact(formMaterialService.count(new LambdaQueryWrapper<InventoryFormMaterial>()
+                .eq(InventoryFormMaterial::getContractFormId, id)));
+        if (count > 0){
+            throw new ServiceException("当前清单已经关联材料,请取消关联后再删除");
+        }
         baseMapper.updateNode(id,contractId);
     }
 
@@ -660,7 +676,7 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
                 .eq(InventoryFormMaterial::getContractMaterialId, materialId));
         Map<Long, BigDecimal> map = formMaterials.stream().collect(Collectors.toMap(l -> l.getContractFormId(), l -> l.getAdjustFactor()));
         //获取所有清单节点
-        List<FormTreeVO2> vo2s = baseMapper.getAllForm2(contractId);
+        List<FormTreeVO2> vo2s = baseMapper.getAllForm2(contractId,materialId);
         List<FormTreeVO2> list = new ArrayList<>();
         List<Long> ids = new ArrayList<>();
         //循环清单节点,把最底层节点不允许调差的删除,并且标识已关联的节点

+ 111 - 8
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java

@@ -16,20 +16,21 @@
  */
 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.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.meter.dto.ContractMaterialAdjustAddDTO;
-import org.springblade.meter.entity.AttachmentForm;
-import org.springblade.meter.entity.ContractMaterialAdjust;
-import org.springblade.meter.entity.ContractMaterialAdjustDetail;
-import org.springblade.meter.entity.ContractMaterialValidity;
+import org.springblade.meter.dto.ContractMaterialDTO2;
+import org.springblade.meter.entity.*;
 import org.springblade.meter.mapper.AttachmentFormMapper;
 import org.springblade.meter.mapper.ContractMaterialAdjustMapper;
-import org.springblade.meter.service.IAttachmentFormService;
-import org.springblade.meter.service.IContractMaterialAdjustDetailService;
-import org.springblade.meter.service.IContractMaterialAdjustService;
-import org.springblade.meter.service.IContractMaterialValidityService;
+import org.springblade.meter.service.*;
+import org.springblade.meter.vo.ContractMaterialAdjustVO;
+import org.springblade.meter.vo.MaterialAdjustDetailVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -39,6 +40,7 @@ import java.math.RoundingMode;
 import java.time.format.DateTimeFormatter;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * 附件表 服务实现类
@@ -56,6 +58,8 @@ public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractM
 
     private final IAttachmentFormService attachmentFormService;
 
+    private final IInventoryFormMaterialService formMaterialService;
+
     @Override
     @Transactional
     public void add(ContractMaterialAdjustAddDTO dto) {
@@ -104,4 +108,103 @@ public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractM
             attachmentFormService.saveBatch(files);
         }
     }
+
+    @Override
+    public List<ContractMaterialAdjustDetail> getMaterialDetail(ContractMaterialDTO2 dto) {
+        //1 获取所有材料关联的清单,如果没有则提示
+        List<InventoryFormMaterial> formMaterials = formMaterialService.list(new LambdaQueryWrapper<InventoryFormMaterial>()
+                .eq(InventoryFormMaterial::getContractMaterialId, dto.getContractMaterialId()));
+        if (formMaterials.size() == 0){
+            throw new ServiceException("当前材料并未关联清单");
+        }
+        List<Long> formIds = formMaterials.stream().map(l -> l.getContractFormId()).collect(Collectors.toList());
+        //2 获取当前计量期下,包含当前清单的所有计量单
+        List<ContractMaterialAdjustDetail> list = baseMapper.getMaterialDetail(dto,formIds);
+        for (ContractMaterialAdjustDetail detail : list) {
+            detail.setContractMaterialId(dto.getContractMaterialId());
+        }
+        return list;
+    }
+
+    @Override
+    public IPage<ContractMaterialAdjustVO> page2(ContractMaterialDTO2 dto) {
+        if (dto.getContractId() == null || dto.getContractPeriodId() == null){
+            throw new ServiceException("请传入合同id和调差期id");
+        }
+        IPage<ContractMaterialAdjustVO> iPage = new Page<>(dto.getCurrent(),dto.getSize());
+        return baseMapper.page2(iPage,dto);
+    }
+
+    @Override
+    public MaterialAdjustDetailVO detail(Long id) {
+        //获取材料调差单数据
+        MaterialAdjustDetailVO vo = baseMapper.detail(id);
+        //获取材料详情
+        List<ContractMaterialAdjustDetail> adjustDetailList = adjustDetailService.list(new LambdaQueryWrapper<ContractMaterialAdjustDetail>()
+                .eq(ContractMaterialAdjustDetail::getContractId, vo.getContractId())
+                .eq(ContractMaterialAdjustDetail::getMaterialAdjustId, id));
+        vo.setDetails(adjustDetailList);
+        //获取附件详情
+        List<AttachmentForm> files = attachmentFormService.list(new LambdaQueryWrapper<AttachmentForm>()
+                .eq(AttachmentForm::getContractId, vo.getContractId())
+                .eq(AttachmentForm::getMasterId, id));
+        vo.setFiles(files);
+        return vo;
+    }
+
+    @Override
+    @Transactional
+    public void update2(ContractMaterialAdjustAddDTO dto) {
+        //获取材料有效期
+        ContractMaterialValidity validity = validityService.getById(dto.getMaterialValidityId());
+        /*保存材料调差单*/
+        ContractMaterialAdjust adjust = new ContractMaterialAdjust();
+        BeanUtils.copyProperties(dto,adjust);
+        //计算调差金额,生成计算式
+        StringBuilder str = new StringBuilder("调差价格依据于:"+dto.getMaterialName()+
+                "("+validity.getStartDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+"至"+
+                validity.getEndDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+")\n");
+        BigDecimal adjustMoney;
+        BigDecimal price = dto.getMaterialPrice();
+        BigDecimal currentPrice = dto.getCurrentPrice();
+        if (price.compareTo(currentPrice) == 1){
+            //市场价低于基准价
+            adjustMoney = dto.getMaterialTotal().multiply(currentPrice.subtract((price.multiply(new BigDecimal(1).add(dto.getRangePriceRatio().abs().divide(new BigDecimal(100))))))).multiply(new BigDecimal(1.09)).setScale(2, RoundingMode.DOWN);
+            str.append("调差公式(标准):调增金额=调差数量×[市场价-基准价×(1-风险幅度差%)]×(1+合同增值税税率)\n");
+            str.append("调差公式(计算):"+adjustMoney+"="+dto.getMaterialTotal()+"*["+currentPrice+"-"+price+"*(1+"+dto.getRangePriceRatio().abs()+"%)]*(1+9.0/100)");
+        }else {
+            //市场价高于基准价
+            adjustMoney = dto.getMaterialTotal().multiply(currentPrice.subtract((price.multiply(new BigDecimal(1).add(dto.getRangePriceRatio().divide(new BigDecimal(100))))))).multiply(new BigDecimal(1.09)).setScale(2, RoundingMode.DOWN);
+            str.append("调差公式(标准):调增金额=调差数量×[市场价-基准价×(1+风险幅度差%)]×(1+合同增值税税率)\n");
+            str.append("调差公式(计算):"+adjustMoney+"="+dto.getMaterialTotal()+"*["+currentPrice+"-"+price+"*(1-"+dto.getRangePriceRatio()+"%)]*(1+9.0/100)");
+        }
+        adjust.setAdjustMoney(adjustMoney);
+        adjust.setAdjustCalculation(str.toString());
+        this.updateById(adjust);
+
+        /*保存材料明细*/
+        //先删除再清空id
+        adjustDetailService.remove(new LambdaQueryWrapper<ContractMaterialAdjustDetail>()
+                .eq(ContractMaterialAdjustDetail::getMaterialAdjustId,adjust.getId()));
+        List<ContractMaterialAdjustDetail> details = dto.getDetails();
+        if (details.size() != 0){
+            for (ContractMaterialAdjustDetail detail : details) {
+                detail.setId(null);
+                detail.setMaterialAdjustId(adjust.getId());
+            }
+            adjustDetailService.saveBatch(details);
+        }
+        /*保存附件信息*/
+        //先删除再清空id
+        attachmentFormService.remove(new LambdaQueryWrapper<AttachmentForm>()
+                .eq(AttachmentForm::getMasterId,adjust.getId()));
+        List<AttachmentForm> files = dto.getFiles();
+        if (files.size() != 0){
+            for (AttachmentForm file : files) {
+                file.setId(null);
+                file.setMasterId(adjust.getId());
+            }
+            attachmentFormService.saveBatch(files);
+        }
+    }
 }

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

@@ -182,7 +182,8 @@ public class ContractMaterialServiceImpl extends BaseServiceImpl<ContractMateria
         priceService.remove(new LambdaQueryWrapper<ContractMaterialPrice>()
                 .in(ContractMaterialPrice::getContractMaterialId,list));
         //删除调差系数
-
+        formMaterialService.remove(new LambdaQueryWrapper<InventoryFormMaterial>()
+                .in(InventoryFormMaterial::getContractMaterialId,list));
         //删除材料信息
         this.removeBatchByIds(list);
     }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/InventoryFormMaterialServiceImpl.java

@@ -28,7 +28,7 @@ import org.springframework.stereotype.Service;
 import java.util.Set;
 
 /**
- * 附件表 服务实现类
+ *
  *
  * @author BladeX
  * @since 2023-11-29