zhaocaiapi提交
This commit is contained in:
parent
a7ba0f21e5
commit
49ccfe70b5
@ -69,12 +69,12 @@ public interface LauncherConstant {
|
||||
/**
|
||||
* nacos prod 地址
|
||||
*/
|
||||
String NACOS_PROD_ADDR = "172.30.0.48:8848";
|
||||
String NACOS_PROD_ADDR = "127.0.0.1:8848";
|
||||
|
||||
/**
|
||||
* nacos test 地址
|
||||
*/
|
||||
String NACOS_TEST_ADDR = "172.19.2.126:30848";
|
||||
String NACOS_TEST_ADDR = "127.0.0.1:8848";
|
||||
|
||||
/**
|
||||
* sentinel dev 地址
|
||||
|
||||
@ -6,7 +6,7 @@ spring:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace:
|
||||
namespace: public
|
||||
group: DEFAULT_GROUP
|
||||
username: nacos
|
||||
password: nacos
|
||||
|
||||
@ -29,21 +29,21 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import org.springblade.core.tenant.mp.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 招采计划实体类
|
||||
* 年度招采计划实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_procurement_plan")
|
||||
@TableName("zc_procurement_plan")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProcurementPlan extends BaseEntity {
|
||||
public class ProcurementPlan extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -85,21 +85,21 @@ public class ProcurementPlan extends BaseEntity {
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
* 需求部门
|
||||
*/
|
||||
@Schema(description = "所属部门")
|
||||
@Schema(description = "需求部门")
|
||||
private String dept;
|
||||
|
||||
/**
|
||||
* 申请信息中的所属公司
|
||||
* 需求公司
|
||||
*/
|
||||
@Schema(description = "申请所属公司")
|
||||
@Schema(description = "需求公司")
|
||||
private String applyCompany;
|
||||
|
||||
/**
|
||||
* 预估总金额(万元)
|
||||
* 年度预估总金额(万元)
|
||||
*/
|
||||
@Schema(description = "预估总金额(万元)")
|
||||
@Schema(description = "年度预估总金额(万元)")
|
||||
private BigDecimal estimatedAmount;
|
||||
|
||||
/**
|
||||
@ -114,4 +114,16 @@ public class ProcurementPlan extends BaseEntity {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 流程当前节点
|
||||
*/
|
||||
@Schema(description = "流程当前节点")
|
||||
private String flowStatus;
|
||||
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
@Schema(description = "流程实例ID")
|
||||
private String processInstanceId;
|
||||
|
||||
}
|
||||
|
||||
@ -31,20 +31,21 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import org.springblade.core.tenant.mp.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 招采计划明细实体类
|
||||
* 年度招采计划项目明细实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_procurement_plan_detail")
|
||||
@TableName("zc_procurement_plan_project")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProcurementPlanDetail extends BaseEntity {
|
||||
public class ProcurementPlanDetail extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -63,16 +64,10 @@ public class ProcurementPlanDetail extends BaseEntity {
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 计划
|
||||
* 计划号
|
||||
*/
|
||||
@Schema(description = "计划")
|
||||
private String plan;
|
||||
|
||||
/**
|
||||
* 计划类型
|
||||
*/
|
||||
@Schema(description = "计划类型")
|
||||
private String planType;
|
||||
@Schema(description = "计划号")
|
||||
private String planNo;
|
||||
|
||||
/**
|
||||
* 序号
|
||||
@ -98,6 +93,13 @@ public class ProcurementPlanDetail extends BaseEntity {
|
||||
@Schema(description = "项目对接人")
|
||||
private String contactPerson;
|
||||
|
||||
/**
|
||||
* 项目对接人ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@Schema(description = "项目对接人ID")
|
||||
private Long contactPersonId;
|
||||
|
||||
/**
|
||||
* 计划申请日期
|
||||
*/
|
||||
@ -117,9 +119,39 @@ public class ProcurementPlanDetail extends BaseEntity {
|
||||
private String projectAttr;
|
||||
|
||||
/**
|
||||
* 采购物料明细
|
||||
* 采购需求
|
||||
*/
|
||||
@Schema(description = "采购物料明细")
|
||||
@Schema(description = "采购需求")
|
||||
private String purchaseRequirement;
|
||||
|
||||
/**
|
||||
* 预算金额(万元)
|
||||
*/
|
||||
@Schema(description = "预算金额(万元)")
|
||||
private BigDecimal budgetAmount;
|
||||
|
||||
/**
|
||||
* 招标方式
|
||||
*/
|
||||
@Schema(description = "招标方式")
|
||||
private String biddingMethod;
|
||||
|
||||
/**
|
||||
* 项目简介
|
||||
*/
|
||||
@Schema(description = "项目简介")
|
||||
private String projectIntro;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 物料明细冗余汇总
|
||||
*/
|
||||
@Schema(description = "物料明细冗余汇总")
|
||||
private String materialDetail;
|
||||
|
||||
}
|
||||
|
||||
@ -31,9 +31,10 @@ import lombok.EqualsAndHashCode;
|
||||
import org.springblade.zhaocai.pojo.entity.ProcurementPlanDetail;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 招采计划明细视图对象
|
||||
* 年度招采计划项目明细视图对象
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@ -44,4 +45,10 @@ public class ProcurementPlanDetailVO extends ProcurementPlanDetail {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 物料明细列表
|
||||
*/
|
||||
@Schema(description = "物料明细列表")
|
||||
private List<ProcurementPlanMaterialVO> materialList;
|
||||
|
||||
}
|
||||
|
||||
@ -48,6 +48,10 @@
|
||||
<artifactId>blade-core-auto</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-tool</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -37,33 +37,49 @@ 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.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.zhaocai.pojo.entity.ProcurementPlan;
|
||||
import org.springblade.zhaocai.pojo.vo.ProcurementPlanVO;
|
||||
import org.springblade.zhaocai.service.IBillCodeService;
|
||||
import org.springblade.zhaocai.service.IProcurementPlanService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 招采计划控制器
|
||||
* 年度招采计划控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@RequestMapping("procurement-plan")
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "招采计划", description = "招采计划接口")
|
||||
@PreAuth(menu = "procurement-plan")
|
||||
@Tag(name = "年度招采计划", description = "年度招采计划接口")
|
||||
public class ProcurementPlanController extends BladeController {
|
||||
|
||||
private final IProcurementPlanService procurementPlanService;
|
||||
private final IBillCodeService billCodeService;
|
||||
|
||||
/**
|
||||
* 生成单据号
|
||||
*/
|
||||
@GetMapping("/bill-no")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "生成单据号", description = "生成唯一单据号")
|
||||
public R<String> generateBillNo() {
|
||||
return R.data(billCodeService.generateBillCode("PROCUREMENT_PLAN"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情(含明细)
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "详情", description = "传入id")
|
||||
public R<ProcurementPlanVO> detail(@Parameter(name = "id", description = "主键", in = ParameterIn.QUERY, schema = @Schema(type = "integer")) @RequestParam Long id) {
|
||||
ProcurementPlanVO detail = procurementPlanService.detail(id);
|
||||
@ -79,7 +95,7 @@ public class ProcurementPlanController extends BladeController {
|
||||
@Parameter(name = "billNo", description = "单据号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "year", description = "年度", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入procurementPlan")
|
||||
public R<IPage<ProcurementPlan>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> procurementPlan, Query query) {
|
||||
IPage<ProcurementPlan> pages = procurementPlanService.page(Condition.getPage(query), Condition.getQueryWrapper(procurementPlan, ProcurementPlan.class));
|
||||
@ -90,7 +106,7 @@ public class ProcurementPlanController extends BladeController {
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入procurementPlan")
|
||||
public R save(@RequestBody ProcurementPlanVO procurementPlanVO) {
|
||||
return R.status(procurementPlanService.submit(procurementPlanVO));
|
||||
@ -100,7 +116,7 @@ public class ProcurementPlanController extends BladeController {
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入procurementPlan")
|
||||
public R update(@RequestBody ProcurementPlanVO procurementPlanVO) {
|
||||
return R.status(procurementPlanService.submit(procurementPlanVO));
|
||||
@ -110,7 +126,7 @@ public class ProcurementPlanController extends BladeController {
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入procurementPlan")
|
||||
public R submit(@RequestBody ProcurementPlanVO procurementPlanVO) {
|
||||
return R.status(procurementPlanService.submit(procurementPlanVO));
|
||||
@ -120,7 +136,7 @@ public class ProcurementPlanController extends BladeController {
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(name = "ids", description = "主键集合", in = ParameterIn.QUERY, schema = @Schema(type = "string")) @RequestParam String ids) {
|
||||
boolean temp = procurementPlanService.deleteLogic(Func.toLongList(ids));
|
||||
|
||||
@ -14,15 +14,20 @@
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="plan_id" property="planId"/>
|
||||
<result column="year" property="year"/>
|
||||
<result column="plan" property="plan"/>
|
||||
<result column="plan_type" property="planType"/>
|
||||
<result column="plan_no" property="planNo"/>
|
||||
<result column="sort_no" property="sortNo"/>
|
||||
<result column="project_name" property="projectName"/>
|
||||
<result column="project_type" property="projectType"/>
|
||||
<result column="contact_person" property="contactPerson"/>
|
||||
<result column="contact_person_id" property="contactPersonId"/>
|
||||
<result column="apply_date" property="applyDate"/>
|
||||
<result column="expect_date" property="expectDate"/>
|
||||
<result column="project_attr" property="projectAttr"/>
|
||||
<result column="purchase_requirement" property="purchaseRequirement"/>
|
||||
<result column="budget_amount" property="budgetAmount"/>
|
||||
<result column="bidding_method" property="biddingMethod"/>
|
||||
<result column="project_intro" property="projectIntro"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="material_detail" property="materialDetail"/>
|
||||
</resultMap>
|
||||
|
||||
@ -30,20 +35,21 @@
|
||||
<sql id="baseColumnList">
|
||||
select
|
||||
id, tenant_id, create_user, create_time, update_user, update_time, status, is_deleted,
|
||||
plan_id, year, plan, plan_type, sort_no, project_name, project_type, contact_person,
|
||||
apply_date, expect_date, project_attr, material_detail
|
||||
plan_id, year, plan_no, sort_no, project_name, project_type, contact_person, contact_person_id,
|
||||
apply_date, expect_date, project_attr, purchase_requirement, budget_amount, bidding_method,
|
||||
project_intro, remark, material_detail
|
||||
</sql>
|
||||
|
||||
<select id="selectByPlanId" resultMap="procurementPlanDetailResultMap">
|
||||
<include refid="baseColumnList"/>
|
||||
from blade_procurement_plan_detail
|
||||
from zc_procurement_plan_project
|
||||
where plan_id = #{planId}
|
||||
and is_deleted = 0
|
||||
order by sort_no asc
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPlanId">
|
||||
delete from blade_procurement_plan_detail where plan_id = #{planId}
|
||||
delete from zc_procurement_plan_project where plan_id = #{planId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -24,18 +24,21 @@
|
||||
<result column="estimated_amount" property="estimatedAmount"/>
|
||||
<result column="amount_upper" property="amountUpper"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="flow_status" property="flowStatus"/>
|
||||
<result column="process_instance_id" property="processInstanceId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="baseColumnList">
|
||||
select
|
||||
id, tenant_id, create_user, create_dept, create_time, update_user, update_time, status, is_deleted,
|
||||
applicant, apply_time, phone, company, bill_no, year, dept, apply_company, estimated_amount, amount_upper, remark
|
||||
applicant, apply_time, phone, company, bill_no, year, dept, apply_company, estimated_amount, amount_upper,
|
||||
remark, flow_status, process_instance_id
|
||||
</sql>
|
||||
|
||||
<select id="selectProcurementPlanPage" resultMap="procurementPlanResultMap">
|
||||
<include refid="baseColumnList"/>
|
||||
from blade_procurement_plan
|
||||
from zc_procurement_plan
|
||||
where is_deleted = 0
|
||||
<if test="procurementPlan.applicant != null and procurementPlan.applicant != ''">
|
||||
and applicant like concat('%', #{procurementPlan.applicant}, '%')
|
||||
|
||||
@ -32,17 +32,25 @@ import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.zhaocai.mapper.ProcurementPlanMapper;
|
||||
import org.springblade.zhaocai.pojo.entity.ProcurementPlan;
|
||||
import org.springblade.zhaocai.pojo.entity.ProcurementPlanDetail;
|
||||
import org.springblade.zhaocai.pojo.entity.ProcurementPlanMaterial;
|
||||
import org.springblade.zhaocai.pojo.vo.ProcurementPlanDetailVO;
|
||||
import org.springblade.zhaocai.pojo.vo.ProcurementPlanMaterialVO;
|
||||
import org.springblade.zhaocai.pojo.vo.ProcurementPlanVO;
|
||||
import org.springblade.zhaocai.service.IBillCodeService;
|
||||
import org.springblade.zhaocai.service.IProcurementPlanDetailService;
|
||||
import org.springblade.zhaocai.service.IProcurementPlanMaterialService;
|
||||
import org.springblade.zhaocai.service.IProcurementPlanService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 招采计划服务实现类
|
||||
* 年度招采计划服务实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@ -51,6 +59,8 @@ import java.util.List;
|
||||
public class ProcurementPlanServiceImpl extends BaseServiceImpl<ProcurementPlanMapper, ProcurementPlan> implements IProcurementPlanService {
|
||||
|
||||
private final IProcurementPlanDetailService procurementPlanDetailService;
|
||||
private final IProcurementPlanMaterialService procurementPlanMaterialService;
|
||||
private final IBillCodeService billCodeService;
|
||||
|
||||
@Override
|
||||
public IPage<ProcurementPlan> selectProcurementPlanPage(IPage<ProcurementPlan> page, ProcurementPlan procurementPlan) {
|
||||
@ -69,34 +79,170 @@ public class ProcurementPlanServiceImpl extends BaseServiceImpl<ProcurementPlanM
|
||||
vo.setDetailList(detailList.stream().map(detail -> {
|
||||
ProcurementPlanDetailVO detailVO = new ProcurementPlanDetailVO();
|
||||
Func.copy(detail, detailVO);
|
||||
List<ProcurementPlanMaterial> materialList = procurementPlanMaterialService.listByProjectId(detail.getId());
|
||||
detailVO.setMaterialList(materialList.stream().map(material -> {
|
||||
ProcurementPlanMaterialVO materialVO = new ProcurementPlanMaterialVO();
|
||||
Func.copy(material, materialVO);
|
||||
return materialVO;
|
||||
}).collect(Collectors.toList()));
|
||||
return detailVO;
|
||||
}).toList());
|
||||
}).collect(Collectors.toList()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean submit(ProcurementPlanVO procurementPlanVO) {
|
||||
// 新建时生成单据号
|
||||
if (procurementPlanVO.getId() == null && !StringUtils.hasText(procurementPlanVO.getBillNo())) {
|
||||
String billNo = billCodeService.generateBillCode("PROCUREMENT_PLAN");
|
||||
procurementPlanVO.setBillNo(billNo);
|
||||
}
|
||||
|
||||
// 自动计算项目属性、招标方式、主表金额
|
||||
this.calculateDetail(procurementPlanVO);
|
||||
|
||||
// 保存主表
|
||||
boolean result = saveOrUpdate(procurementPlanVO);
|
||||
Long planId = procurementPlanVO.getId();
|
||||
// 删除旧明细
|
||||
|
||||
// 删除旧项目明细和物料明细
|
||||
procurementPlanDetailService.removeByPlanId(planId);
|
||||
// 保存新明细
|
||||
procurementPlanMaterialService.removeByPlanId(planId);
|
||||
|
||||
// 保存项目明细及物料明细
|
||||
List<ProcurementPlanDetailVO> detailVOList = procurementPlanVO.getDetailList();
|
||||
if (Func.isNotEmpty(detailVOList)) {
|
||||
List<ProcurementPlanDetail> detailList = detailVOList.stream().map(detailVO -> {
|
||||
for (int i = 0; i < detailVOList.size(); i++) {
|
||||
ProcurementPlanDetailVO detailVO = detailVOList.get(i);
|
||||
ProcurementPlanDetail detail = new ProcurementPlanDetail();
|
||||
Func.copy(detailVO, detail);
|
||||
detail.setPlanId(planId);
|
||||
return detail;
|
||||
}).toList();
|
||||
for (int i = 0; i < detailList.size(); i++) {
|
||||
detailList.get(i).setSortNo(i + 1);
|
||||
detail.setSortNo(i + 1);
|
||||
procurementPlanDetailService.save(detail);
|
||||
Long detailId = detail.getId();
|
||||
|
||||
// 保存物料明细
|
||||
List<ProcurementPlanMaterialVO> materialVOList = detailVO.getMaterialList();
|
||||
if (Func.isNotEmpty(materialVOList)) {
|
||||
List<ProcurementPlanMaterial> materialList = new ArrayList<>();
|
||||
for (int j = 0; j < materialVOList.size(); j++) {
|
||||
ProcurementPlanMaterialVO materialVO = materialVOList.get(j);
|
||||
ProcurementPlanMaterial material = new ProcurementPlanMaterial();
|
||||
Func.copy(materialVO, material);
|
||||
material.setPlanId(planId);
|
||||
material.setProjectId(detailId);
|
||||
material.setSortNo(j + 1);
|
||||
materialList.add(material);
|
||||
}
|
||||
procurementPlanDetailService.saveBatch(detailList);
|
||||
procurementPlanMaterialService.saveBatch(materialList);
|
||||
// 冗余汇总
|
||||
detail.setMaterialDetail(buildMaterialSummary(materialList));
|
||||
procurementPlanDetailService.updateById(detail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 接入 blade-flow 流程引擎
|
||||
// R<BladeFlow> result = flowClient.startProcessInstanceById(
|
||||
// processDefinitionId,
|
||||
// FlowUtil.getBusinessKey("zc_procurement_plan", String.valueOf(planId)),
|
||||
// variables
|
||||
// );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算项目明细的项目属性、招标方式,并汇总主表金额
|
||||
*/
|
||||
private void calculateDetail(ProcurementPlanVO procurementPlanVO) {
|
||||
List<ProcurementPlanDetailVO> detailVOList = procurementPlanVO.getDetailList();
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
if (Func.isNotEmpty(detailVOList)) {
|
||||
for (ProcurementPlanDetailVO detailVO : detailVOList) {
|
||||
String projectType = detailVO.getProjectType();
|
||||
BigDecimal budgetAmount = detailVO.getBudgetAmount() == null ? BigDecimal.ZERO : detailVO.getBudgetAmount();
|
||||
String projectAttr = calculateProjectAttr(projectType, budgetAmount);
|
||||
String biddingMethod = calculateBiddingMethod(projectType, budgetAmount);
|
||||
detailVO.setProjectAttr(projectAttr);
|
||||
detailVO.setBiddingMethod(biddingMethod);
|
||||
totalAmount = totalAmount.add(budgetAmount);
|
||||
}
|
||||
}
|
||||
procurementPlanVO.setEstimatedAmount(totalAmount);
|
||||
procurementPlanVO.setAmountUpper(digitUppercase(totalAmount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算项目属性
|
||||
*/
|
||||
private String calculateProjectAttr(String projectType, BigDecimal budgetAmount) {
|
||||
boolean isEngineering = "工程类".equals(projectType);
|
||||
if ((isEngineering && budgetAmount.compareTo(new BigDecimal("100")) >= 0)
|
||||
|| (!isEngineering && budgetAmount.compareTo(new BigDecimal("50")) >= 0)) {
|
||||
return "一类项目";
|
||||
}
|
||||
if ((isEngineering && budgetAmount.compareTo(new BigDecimal("50")) >= 0)
|
||||
|| (!isEngineering && budgetAmount.compareTo(new BigDecimal("10")) >= 0)) {
|
||||
return "二类项目";
|
||||
}
|
||||
return "三类项目";
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算招标方式
|
||||
*/
|
||||
private String calculateBiddingMethod(String projectType, BigDecimal budgetAmount) {
|
||||
String projectAttr = calculateProjectAttr(projectType, budgetAmount);
|
||||
if ("一类项目".equals(projectAttr) || "二类项目".equals(projectAttr)) {
|
||||
return "招标";
|
||||
}
|
||||
return "比价";
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建物料明细冗余汇总
|
||||
*/
|
||||
private String buildMaterialSummary(List<ProcurementPlanMaterial> materialList) {
|
||||
return materialList.stream()
|
||||
.map(material -> material.getMaterialName() + " x " + material.getQuantity())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
/**
|
||||
* 金额大写转换
|
||||
*/
|
||||
private String digitUppercase(BigDecimal amount) {
|
||||
if (amount == null || amount.compareTo(BigDecimal.ZERO) == 0) {
|
||||
return "零元整";
|
||||
}
|
||||
String[] fraction = {"角", "分"};
|
||||
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
||||
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
|
||||
double n = amount.doubleValue();
|
||||
String head = n < 0 ? "欠" : "";
|
||||
n = Math.abs(n);
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < fraction.length; i++) {
|
||||
s.append((digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("零.", ""));
|
||||
}
|
||||
if (s.length() == 0) {
|
||||
s.append("整");
|
||||
}
|
||||
n = Math.floor(n);
|
||||
for (int i = 0; i < unit[0].length && n > 0; i++) {
|
||||
StringBuilder p = new StringBuilder();
|
||||
for (int j = 0; j < unit[1].length && n > 0; j++) {
|
||||
p.insert(0, digit[(int) (n % 10)] + unit[1][j]);
|
||||
n = Math.floor(n / 10);
|
||||
}
|
||||
s.insert(0, p.toString().replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i]);
|
||||
}
|
||||
return head + s.toString()
|
||||
.replaceAll("(零.)*零元", "元")
|
||||
.replaceAll("(零.)+", "零")
|
||||
.replaceAll("^整$", "零元整");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ spring:
|
||||
datasource:
|
||||
#主数据源信息
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://172.16.92.89:3306/bladex_zhaocai?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://localhost:3306/bladex_zhaocai?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: Aa123456
|
||||
#动态数据源信息
|
||||
@ -23,6 +23,6 @@ spring:
|
||||
#独立校验配置
|
||||
validation-query: select 1
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://172.16.92.89:3306/bladex_zhaocai?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://localhost:3306/bladex_zhaocai?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: Aa123456
|
||||
|
||||
@ -3,7 +3,7 @@ spring:
|
||||
data:
|
||||
redis:
|
||||
##redis 单机环境配置
|
||||
host: 172.16.92.89
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password:
|
||||
database: 0
|
||||
|
||||
@ -3,11 +3,29 @@
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for blade_procurement_plan
|
||||
-- Table structure for zc_bill_code
|
||||
-- 单据号码表,用于保证单据号唯一性
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `blade_procurement_plan`;
|
||||
DROP TABLE IF EXISTS `zc_bill_code`;
|
||||
|
||||
CREATE TABLE `blade_procurement_plan` (
|
||||
CREATE TABLE `zc_bill_code` (
|
||||
`id` bigint(20) NOT NULL COMMENT '主键',
|
||||
`bill_code` varchar(64) NOT NULL COMMENT '单据号',
|
||||
`bill_type` varchar(64) DEFAULT NULL COMMENT '单据类型',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_bill_code` (`bill_code`) USING BTREE,
|
||||
KEY `idx_bill_type` (`bill_type`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='单据号码表';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for zc_procurement_plan
|
||||
-- 年度招采计划主表
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `zc_procurement_plan`;
|
||||
|
||||
CREATE TABLE `zc_procurement_plan` (
|
||||
`id` bigint(20) NOT NULL COMMENT '主键',
|
||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
||||
`applicant` varchar(64) DEFAULT NULL COMMENT '申请人',
|
||||
@ -16,11 +34,13 @@ CREATE TABLE `blade_procurement_plan` (
|
||||
`company` varchar(128) DEFAULT NULL COMMENT '所属公司',
|
||||
`bill_no` varchar(64) DEFAULT NULL COMMENT '单据号',
|
||||
`year` varchar(4) DEFAULT NULL COMMENT '年度',
|
||||
`dept` varchar(128) DEFAULT NULL COMMENT '所属部门',
|
||||
`apply_company` varchar(128) DEFAULT NULL COMMENT '申请所属公司',
|
||||
`estimated_amount` decimal(18,2) DEFAULT '0.00' COMMENT '预估总金额(万元)',
|
||||
`dept` varchar(128) DEFAULT NULL COMMENT '需求部门',
|
||||
`apply_company` varchar(128) DEFAULT NULL COMMENT '需求公司',
|
||||
`estimated_amount` decimal(18,2) DEFAULT '0.00' COMMENT '年度预估总金额(万元)',
|
||||
`amount_upper` varchar(256) DEFAULT NULL COMMENT '预估总金额大写',
|
||||
`remark` text COMMENT '备注',
|
||||
`flow_status` varchar(64) DEFAULT NULL COMMENT '流程当前节点',
|
||||
`process_instance_id` varchar(64) DEFAULT NULL COMMENT '流程实例ID',
|
||||
`status` int(2) DEFAULT '1' COMMENT '状态',
|
||||
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
|
||||
@ -32,29 +52,35 @@ CREATE TABLE `blade_procurement_plan` (
|
||||
UNIQUE KEY `uk_bill_no` (`bill_no`) USING BTREE,
|
||||
KEY `idx_year` (`year`) USING BTREE,
|
||||
KEY `idx_applicant` (`applicant`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='招采计划主表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='年度招采计划主表';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for blade_procurement_plan_detail
|
||||
-- Table structure for zc_procurement_plan_project
|
||||
-- 年度招采计划项目明细表
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `blade_procurement_plan_detail`;
|
||||
DROP TABLE IF EXISTS `zc_procurement_plan_project`;
|
||||
|
||||
CREATE TABLE `blade_procurement_plan_detail` (
|
||||
CREATE TABLE `zc_procurement_plan_project` (
|
||||
`id` bigint(20) NOT NULL COMMENT '主键',
|
||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
||||
`plan_id` bigint(20) NOT NULL COMMENT '主表ID',
|
||||
`year` varchar(4) DEFAULT NULL COMMENT '年度',
|
||||
`plan` varchar(128) DEFAULT NULL COMMENT '计划',
|
||||
`plan_type` varchar(64) DEFAULT NULL COMMENT '计划类型',
|
||||
`plan_no` varchar(64) DEFAULT NULL COMMENT '计划号',
|
||||
`sort_no` int(11) DEFAULT '0' COMMENT '序号',
|
||||
`project_name` varchar(256) DEFAULT NULL COMMENT '项目名称',
|
||||
`project_name` varchar(100) DEFAULT NULL COMMENT '项目名称',
|
||||
`project_type` varchar(64) DEFAULT NULL COMMENT '项目类型',
|
||||
`contact_person` varchar(64) DEFAULT NULL COMMENT '项目对接人',
|
||||
`contact_person_id` bigint(20) DEFAULT NULL COMMENT '项目对接人ID',
|
||||
`apply_date` date DEFAULT NULL COMMENT '计划申请日期',
|
||||
`expect_date` date DEFAULT NULL COMMENT '期望使用/完成日期',
|
||||
`project_attr` varchar(64) DEFAULT NULL COMMENT '项目属性',
|
||||
`material_detail` varchar(512) DEFAULT NULL COMMENT '采购物料明细',
|
||||
`purchase_requirement` varchar(512) DEFAULT NULL COMMENT '采购需求',
|
||||
`budget_amount` decimal(18,2) DEFAULT '0.00' COMMENT '预算金额(万元)',
|
||||
`bidding_method` varchar(64) DEFAULT NULL COMMENT '招标方式',
|
||||
`project_intro` text COMMENT '项目简介',
|
||||
`remark` text COMMENT '备注',
|
||||
`material_detail` text COMMENT '物料明细冗余汇总',
|
||||
`status` int(2) DEFAULT '1' COMMENT '状态',
|
||||
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
@ -63,5 +89,47 @@ CREATE TABLE `blade_procurement_plan_detail` (
|
||||
`is_deleted` int(2) DEFAULT '0' COMMENT '是否已删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_plan_id` (`plan_id`) USING BTREE,
|
||||
KEY `idx_plan_no` (`plan_no`) USING BTREE,
|
||||
KEY `idx_year` (`year`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='招采计划明细表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='年度招采计划项目明细表';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for zc_procurement_plan_material
|
||||
-- 年度招采计划物料明细表
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `zc_procurement_plan_material`;
|
||||
|
||||
CREATE TABLE `zc_procurement_plan_material` (
|
||||
`id` bigint(20) NOT NULL COMMENT '主键',
|
||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
||||
`plan_id` bigint(20) NOT NULL COMMENT '主表ID',
|
||||
`project_id` bigint(20) NOT NULL COMMENT '项目明细ID',
|
||||
`sort_no` int(11) DEFAULT '0' COMMENT '序号',
|
||||
`material_name` varchar(100) DEFAULT NULL COMMENT '物料名称',
|
||||
`material_code` varchar(64) DEFAULT NULL COMMENT '物料编码',
|
||||
`specification` varchar(256) DEFAULT NULL COMMENT '规格型号',
|
||||
`brand` varchar(128) DEFAULT NULL COMMENT '品牌',
|
||||
`unit` varchar(64) DEFAULT NULL COMMENT '计量单位',
|
||||
`reference_price` decimal(18,2) DEFAULT '0.00' COMMENT '参考价',
|
||||
`quantity` int(11) DEFAULT '0' COMMENT '预计数量',
|
||||
`estimated_amount` decimal(18,2) DEFAULT '0.00' COMMENT '预估金额(元)',
|
||||
`contact_person` varchar(64) DEFAULT NULL COMMENT '对接人',
|
||||
`contact_person_id` bigint(20) DEFAULT NULL COMMENT '对接人ID',
|
||||
`apply_date` date DEFAULT NULL COMMENT '计划申请日期',
|
||||
`expect_date` date DEFAULT NULL COMMENT '期望使用/完成日期',
|
||||
`last_year_total` int(11) DEFAULT '0' COMMENT '去年总量',
|
||||
`last_year_avg_price` decimal(18,2) DEFAULT '0.00' COMMENT '去年均价',
|
||||
`last_year_total_amount` decimal(18,2) DEFAULT '0.00' COMMENT '去年总金额',
|
||||
`requirement_intro` text COMMENT '需求简介',
|
||||
`remark` text COMMENT '备注',
|
||||
`status` int(2) DEFAULT '1' COMMENT '状态',
|
||||
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` int(2) DEFAULT '0' COMMENT '是否已删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_plan_id` (`plan_id`) USING BTREE,
|
||||
KEY `idx_project_id` (`project_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='年度招采计划物料明细表';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user