소스 검색

资金预算

qianxb 1 년 전
부모
커밋
85932bc3f0
15개의 변경된 파일854개의 추가작업 그리고 0개의 파일을 삭제
  1. 26 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/FormPeriodDTO.java
  2. 29 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/FormPeriodDetailDTO.java
  3. 79 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/FormPeriod.java
  4. 71 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/FormPeriodDetail.java
  5. 34 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/FormPeriodDetailVO.java
  6. 19 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/FormPeriodVO.java
  7. 114 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/FormPeriodController.java
  8. 42 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodDetailMapper.java
  9. 27 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodDetailMapper.xml
  10. 41 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodMapper.java
  11. 18 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodMapper.xml
  12. 42 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IFormPeriodDetailService.java
  13. 43 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IFormPeriodService.java
  14. 178 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/FormPeriodDetailServiceImpl.java
  15. 91 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/FormPeriodServiceImpl.java

+ 26 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/FormPeriodDTO.java

@@ -0,0 +1,26 @@
+package org.springblade.meter.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springblade.meter.entity.ContractMeterPeriod;
+import org.springblade.meter.entity.FormPeriod;
+
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/6/21 14:56
+ **/
+@Data
+public class FormPeriodDTO {
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "合同段id")
+    private Long contractId;
+
+    @ApiModelProperty(value = "计量期集合")
+    private List<FormPeriod> list;
+
+}

+ 29 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/FormPeriodDetailDTO.java

@@ -0,0 +1,29 @@
+package org.springblade.meter.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springblade.meter.entity.FormPeriod;
+import org.springblade.meter.entity.FormPeriodDetail;
+
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/6/21 16:16
+ **/
+@Data
+public class FormPeriodDetailDTO {
+
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "合同段id")
+    private Long contractId;
+
+    @ApiModelProperty(value = "资金预算期id")
+    private Long formPeriodId;
+
+    @ApiModelProperty(value = "清单计划集合")
+    private List<FormPeriodDetail> list;
+}

+ 79 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/FormPeriod.java

@@ -0,0 +1,79 @@
+/*
+ *      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 com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 资金预算期(清单)
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+@TableName("s_form_period")
+@EqualsAndHashCode(callSuper = true)
+public class FormPeriod extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 项目id
+     */
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+    /**
+     * 合同段id
+     */
+    @ApiModelProperty(value = "合同段id")
+    private Long contractId;
+    /**
+     * 期号
+     */
+    @ApiModelProperty(value = "期名称")
+    private String periodName;
+
+    /**
+     * 年
+     */
+    @ApiModelProperty(value = "年")
+    private Integer periodYear;
+
+    private BigDecimal one;
+    private BigDecimal two;
+    private BigDecimal three;
+    private BigDecimal four;
+    private BigDecimal five;
+    private BigDecimal six;
+    private BigDecimal seven;
+    private BigDecimal eight;
+    private BigDecimal nine;
+    private BigDecimal ten;
+    private BigDecimal eleven;
+    private BigDecimal twelve;
+
+
+}

+ 71 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/FormPeriodDetail.java

@@ -0,0 +1,71 @@
+/*
+ *      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;
+
+/**
+ * 资金预算期详情
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+@TableName("s_form_period_detail")
+@EqualsAndHashCode(callSuper = true)
+public class FormPeriodDetail 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 formPeriodId;
+
+    @ApiModelProperty(value = "合同工程清单id")
+    private Long contractFormId;
+
+    private BigDecimal one;
+    private BigDecimal two;
+    private BigDecimal three;
+    private BigDecimal four;
+    private BigDecimal five;
+    private BigDecimal six;
+    private BigDecimal seven;
+    private BigDecimal eight;
+    private BigDecimal nine;
+    private BigDecimal ten;
+    private BigDecimal eleven;
+    private BigDecimal twelve;
+
+
+}

+ 34 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/FormPeriodDetailVO.java

@@ -0,0 +1,34 @@
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.FormPeriodDetail;
+
+import java.math.BigDecimal;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/6/21 15:20
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FormPeriodDetailVO extends FormPeriodDetail {
+
+    @ApiModelProperty(value = "清单号")
+    private String formNumber;
+
+    @ApiModelProperty(value = "清单名称")
+    private String formName;
+
+    @ApiModelProperty(value = "合同金额")
+    private BigDecimal contractMoney;
+
+    @ApiModelProperty(value = "变更金额")
+    private BigDecimal realChangeMoney;
+
+    @ApiModelProperty(value = "变更后金额")
+    private BigDecimal changeMoney;
+
+}

+ 19 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/FormPeriodVO.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.FormPeriod;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/6/21 14:43
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FormPeriodVO extends FormPeriod {
+
+    @ApiModelProperty(value = "引用状态,0未引用,1引用。如果被引用就不能删除")
+    private Integer citeStatus;
+}

+ 114 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/FormPeriodController.java

@@ -0,0 +1,114 @@
+/*
+ *      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.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+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.ContractMeterPeriodDTO;
+import org.springblade.meter.dto.FormPeriodDTO;
+import org.springblade.meter.dto.FormPeriodDetailDTO;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IFormPeriodDetailService;
+import org.springblade.meter.service.IFormPeriodService;
+import org.springblade.meter.vo.ContractMeterPeriodVO;
+import org.springblade.meter.vo.FormPeriodDetailVO;
+import org.springblade.meter.vo.FormPeriodVO;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *资金预算期
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/formPeriod")
+@Api(value = "资金预算期", tags = "资金预算期接口")
+public class FormPeriodController extends BladeController {
+
+	private final IFormPeriodService formPeriodService;
+
+	private final IFormPeriodDetailService formPeriodDetailService;
+
+
+	/**
+	 * 分页
+	 */
+	@GetMapping("/periodPage")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "资金预算期分页", notes = "传入合同id和分页条件,返回citeStatus判断是否可以编辑")
+	public R<List<FormPeriodVO>> periodPage(Long contractId) {
+		List<FormPeriodVO> pages = formPeriodService.periodPage(contractId);
+		return R.data(pages);
+	}
+
+	/**
+	 * 编辑计量期
+	 */
+	@PostMapping("/edit")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "编辑资金预算期", notes = "传入合同段id与计量期集合")
+	@Transactional
+	public R edit(@Valid @RequestBody FormPeriodDTO dto) {
+		formPeriodService.edit(dto);
+		return R.success("保存成功");
+	}
+
+	@GetMapping("/getFormPlan")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "获取资金预算计划", notes = "传入 合同id,资金预算期id,返回所有清单详情")
+	public R<List<FormPeriodDetailVO>> getFormPlan(Long contractId, Long formPeriodId) {
+		List<FormPeriodDetailVO> list = formPeriodDetailService.getFormPlan(contractId,formPeriodId);
+		return R.data(list);
+	}
+
+	@PostMapping("/updateFormPlan")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "修改资金预算计划", notes = "传入项目id,合同id,资金预算期id ,清单计划集合")
+	public R updateFormPlan(@RequestBody FormPeriodDetailDTO dto) {
+		formPeriodDetailService.updateFormPlan(dto);
+		return R.success("保存成功");
+	}
+
+	@GetMapping("/getMeterMonth")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "获取已经计量月份", notes = "传入 合同id,资金预算期id,返回月份数组")
+	public R<Set<String>> getMeterMonth(Long contractId, Long formPeriodId) {
+		Set<String> list = formPeriodDetailService.getMeterMonth(contractId,formPeriodId);
+		return R.data(list);
+	}
+
+
+
+	
+}

+ 42 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodDetailMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      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.ContractMeterPeriod;
+import org.springblade.meter.entity.FormPeriod;
+import org.springblade.meter.entity.FormPeriodDetail;
+import org.springblade.meter.vo.FormPeriodDetailVO;
+
+import java.util.List;
+
+/**
+ * 附件表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface FormPeriodDetailMapper extends BaseMapper<FormPeriodDetail> {
+
+
+    List<FormPeriodDetailVO> getAllSecondForm(@Param("contractId") Long contractId);
+
+    void removeByFormPeriodId(@Param("formPeriodId") Long formPeriodId);
+
+    List<ContractMeterPeriod> getAllFinishPeriod(@Param("contractId") Long contractId);
+}

+ 27 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodDetailMapper.xml

@@ -0,0 +1,27 @@
+<?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.FormPeriodDetailMapper">
+    <delete id="removeByFormPeriodId">
+        delete from s_form_period_detail where form_period_id = #{formPeriodId}
+    </delete>
+
+
+    <select id="getAllSecondForm" resultType="org.springblade.meter.vo.FormPeriodDetailVO">
+        select id as contractFormId,form_number,form_name,
+               (select sum(contract_money) from s_contract_inventory_form sci
+                            where sci.is_deleted=0 and sci.contract_id = #{contractId}
+                                and (sci.id = scif.id or FIND_IN_SET(scif.id,ancestors) > 0)) as contract_money,
+               (select sum(change_money) from s_contract_inventory_form sci
+                            where sci.is_deleted=0 and sci.contract_id = #{contractId}
+                                and (sci.id = scif.id or FIND_IN_SET(scif.id,ancestors) > 0)) as change_money
+        from s_contract_inventory_form scif
+        WHERE parent_id = (select id from s_contract_inventory_form
+                           WHERE contract_id = #{contractId} and parent_id = 0)
+        order by -sort desc,create_time
+    </select>
+    <select id="getAllFinishPeriod" resultType="org.springblade.meter.entity.ContractMeterPeriod">
+        select *
+        from s_contract_meter_period
+        where is_deleted = 0 and contract_id = #{contractId} and approve_status in (1,2)
+    </select>
+</mapper>

+ 41 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodMapper.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.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.entity.AttachmentForm;
+import org.springblade.meter.entity.FormPeriod;
+import org.springblade.meter.vo.FormPeriodVO;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 附件表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface FormPeriodMapper extends BaseMapper<FormPeriod> {
+
+
+    List<FormPeriodVO> periodPage(@Param("contractId") Long contractId);
+
+    void removeByContractId(@Param("contractId") Long contractId);
+}

+ 18 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/FormPeriodMapper.xml

@@ -0,0 +1,18 @@
+<?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.FormPeriodMapper">
+    <delete id="removeByContractId">
+        delete from s_form_period where contract_id = #{contractId}
+    </delete>
+
+
+    <select id="periodPage" resultType="org.springblade.meter.vo.FormPeriodVO">
+        select *,
+               if((select count(1) from s_contract_meter_period cmp
+                    where contract_id = #{contractId} and is_deleted = 0 and sfp.period_year = cmp.period_year
+                    and approve_status in (2,3))=0,0,1) as citeStatus
+        from s_form_period sfp
+        where is_deleted = 0 and contract_id = #{contractId}
+        ORDER BY period_year
+    </select>
+</mapper>

+ 42 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IFormPeriodDetailService.java

@@ -0,0 +1,42 @@
+/*
+ *      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.dto.FormPeriodDetailDTO;
+import org.springblade.meter.entity.FormPeriod;
+import org.springblade.meter.entity.FormPeriodDetail;
+import org.springblade.meter.vo.FormPeriodDetailVO;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 附件表 服务类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface IFormPeriodDetailService extends BaseService<FormPeriodDetail> {
+
+
+    List<FormPeriodDetailVO> getFormPlan(Long contractId,Long formPeriodId);
+
+    void updateFormPlan(FormPeriodDetailDTO dto);
+
+    Set<String> getMeterMonth(Long contractId, Long formPeriodId);
+}

+ 43 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IFormPeriodService.java

@@ -0,0 +1,43 @@
+/*
+ *      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 com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.mp.support.Query;
+import org.springblade.meter.dto.ContractMeterPeriodDTO;
+import org.springblade.meter.dto.FormPeriodDTO;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.FormPeriod;
+import org.springblade.meter.vo.FormPeriodVO;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 附件表 服务类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+public interface IFormPeriodService extends BaseService<FormPeriod> {
+
+
+    List<FormPeriodVO> periodPage(Long contractId);
+
+    void edit(FormPeriodDTO dto);
+}

+ 178 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/FormPeriodDetailServiceImpl.java

@@ -0,0 +1,178 @@
+/*
+ *      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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.meter.dto.FormPeriodDetailDTO;
+import org.springblade.meter.entity.ContractMeterPeriod;
+import org.springblade.meter.entity.FormPeriod;
+import org.springblade.meter.entity.FormPeriodDetail;
+import org.springblade.meter.mapper.FormPeriodDetailMapper;
+import org.springblade.meter.mapper.FormPeriodMapper;
+import org.springblade.meter.service.IFormPeriodDetailService;
+import org.springblade.meter.service.IFormPeriodService;
+import org.springblade.meter.vo.FormPeriodDetailVO;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 附件表 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Service
+@AllArgsConstructor
+public class FormPeriodDetailServiceImpl extends BaseServiceImpl<FormPeriodDetailMapper, FormPeriodDetail> implements IFormPeriodDetailService {
+
+    private final IFormPeriodService formPeriodService;
+
+
+    @Override
+    public List<FormPeriodDetailVO> getFormPlan(Long contractId,Long formPeriodId) {
+        if (formPeriodId == null){
+            throw new ServiceException("请传入资金预算期id");
+        }
+        //获取所有清单二级节点
+        List<FormPeriodDetailVO> vos = baseMapper.getAllSecondForm(contractId);
+        vos.stream().forEach(l->{
+            if (l.getContractMoney() != null && l.getChangeMoney() != null){
+                l.setRealChangeMoney(l.getChangeMoney().subtract(l.getContractMoney()));
+            }
+        });
+        //获取当前计量期详情
+        List<FormPeriodDetail> list = this.list(new LambdaQueryWrapper<FormPeriodDetail>()
+                .eq(FormPeriodDetail::getFormPeriodId, formPeriodId));
+        //如果存在数据,则按照清单id分组,循环清单设置
+        if (list.size() > 0){
+            Map<Long, FormPeriodDetail> detailMap = list.stream().collect(Collectors.toMap(l -> l.getContractFormId(), l -> l));
+            for (FormPeriodDetailVO vo : vos) {
+                FormPeriodDetail detail = detailMap.get(vo.getContractFormId());
+                if (detail != null){
+                    BeanUtils.copyProperties(detail,vo);
+                }
+            }
+        }
+        return vos;
+    }
+
+    @Override
+    public void updateFormPlan(FormPeriodDetailDTO dto) {
+        List<FormPeriodDetail> list = dto.getList();
+        FormPeriod formPeriod = formPeriodService.getById(dto.getFormPeriodId());
+        //先直接删除
+        baseMapper.removeByFormPeriodId(dto.getFormPeriodId());
+        if (list.size() > 0){
+            BigDecimal one = new BigDecimal(0);
+            BigDecimal two = new BigDecimal(0);
+            BigDecimal three = new BigDecimal(0);
+            BigDecimal four = new BigDecimal(0);
+            BigDecimal five = new BigDecimal(0);
+            BigDecimal six = new BigDecimal(0);
+            BigDecimal seven = new BigDecimal(0);
+            BigDecimal eight = new BigDecimal(0);
+            BigDecimal nine = new BigDecimal(0);
+            BigDecimal ten = new BigDecimal(0);
+            BigDecimal eleven = new BigDecimal(0);
+            BigDecimal twelve = new BigDecimal(0);
+            for (FormPeriodDetail period : list) {
+                period.setProjectId(dto.getProjectId());
+                period.setContractId(dto.getContractId());
+                period.setFormPeriodId(dto.getFormPeriodId());
+                if (period.getOne() != null){
+                    one = one.add(period.getOne());
+                }
+                if (period.getTwo() != null){
+                    two = two.add(period.getTwo());
+                }
+                if (period.getThree() != null){
+                    three = three.add(period.getThree());
+                }
+                if (period.getFour() != null){
+                    four = four.add(period.getFour());
+                }
+                if (period.getFive() != null){
+                    five = five.add(period.getFive());
+                }
+                if (period.getSix() != null){
+                    six = six.add(period.getSix());
+                }
+                if (period.getSeven() != null){
+                    seven = seven.add(period.getSeven());
+                }
+                if (period.getEight() != null){
+                    eight = eight.add(period.getEight());
+                }
+                if (period.getNine() != null){
+                    nine = nine.add(period.getNine());
+                }
+                if (period.getTen() != null){
+                    ten = ten.add(period.getTen());
+                }
+                if (period.getEleven() != null){
+                    eleven = eleven.add(period.getEleven());
+                }
+                if (period.getTwelve() != null){
+                    twelve = twelve.add(period.getTwelve());
+                }
+            }
+            formPeriod.setOne(one);
+            formPeriod.setTwo(two);
+            formPeriod.setThree(three);
+            formPeriod.setFour(four);
+            formPeriod.setFive(five);
+            formPeriod.setSix(six);
+            formPeriod.setSeven(seven);
+            formPeriod.setEight(eight);
+            formPeriod.setNine(nine);
+            formPeriod.setTen(ten);
+            formPeriod.setEleven(eleven);
+            formPeriod.setTwelve(twelve);
+            formPeriodService.updateById(formPeriod);
+            this.saveBatch(list);
+        }
+    }
+
+    @Override
+    public Set<String> getMeterMonth(Long contractId, Long formPeriodId) {
+        String[] months = {"aa","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"};
+        Set<String> list = new HashSet<>();
+        //获取所有进行中或已审批的合同计量期
+        List<ContractMeterPeriod> meterPeriods = baseMapper.getAllFinishPeriod(contractId);
+        if (meterPeriods.size() != 0) {
+            //获取当前资金预算期年份
+            FormPeriod formPeriod = formPeriodService.getById(formPeriodId);
+            //获取出对应年份的合同计量期
+            meterPeriods = meterPeriods.stream().filter(l->l.getPeriodYear().equals(formPeriod.getPeriodYear())).collect(Collectors.toList());
+            //把所有月份添加
+            if (meterPeriods.size() != 0){
+                for (ContractMeterPeriod meterPeriod : meterPeriods) {
+                    list.add(months[meterPeriod.getPeriodMonth()]);
+                }
+            }
+        }
+        return list;
+    }
+}

+ 91 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/FormPeriodServiceImpl.java

@@ -0,0 +1,91 @@
+/*
+ *      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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+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.base.BaseServiceImpl;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.meter.dto.ContractMeterPeriodDTO;
+import org.springblade.meter.dto.FormPeriodDTO;
+import org.springblade.meter.entity.*;
+import org.springblade.meter.mapper.AttachmentFormMapper;
+import org.springblade.meter.mapper.FormPeriodMapper;
+import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IFormPeriodService;
+import org.springblade.meter.vo.ContractMeterPeriodVO;
+import org.springblade.meter.vo.FormPeriodVO;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * 附件表 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Service
+public class FormPeriodServiceImpl extends BaseServiceImpl<FormPeriodMapper, FormPeriod> implements IFormPeriodService {
+
+
+    @Override
+    public List<FormPeriodVO> periodPage(Long contractId) {
+        List<FormPeriodVO> list = baseMapper.periodPage(contractId);
+        return list;
+    }
+
+    @Override
+    @Transactional
+    public void edit(FormPeriodDTO dto) {
+        List<FormPeriod> list = dto.getList();
+        //先直接删除
+        baseMapper.removeByContractId(dto.getContractId());
+        if (list.size() > 0){
+            Set<Integer> years = new HashSet<>();
+            Set<String> names = new HashSet<>();
+            //校验年是否存在重复
+            for (FormPeriod period : list) {
+                if (StringUtils.isBlank(period.getPeriodName()) || period.getPeriodYear() == null){
+                    throw new ServiceException("请填写完期名称,年份");
+                }
+                years.add(period.getPeriodYear());
+                names.add(period.getPeriodName());
+                period.setProjectId(dto.getProjectId());
+                period.setContractId(dto.getContractId());
+            }
+            if (years.size() != list.size()){
+                throw new ServiceException("保存失败,年份不能重复");
+            }
+            if (names.size() != list.size()){
+                throw new ServiceException("保存失败,名称不能重复");
+            }
+            this.saveBatch(list);
+        }
+    }
+}