From 15317e9470f71fb33c8aeac55cf8e6a2c23c6d41 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 28 Jul 2023 09:22:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PurchaseController.java | 10 +++- .../projectdeclared/manage/PurchaseManage.java | 60 +++++++++++++++++++++ .../model/dto/PurchaseSaveDTOV1.java | 62 ++++++++++++++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java index 5ac1638..3d0a7fd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java @@ -6,6 +6,7 @@ import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage; import com.ningdatech.pmapi.projectdeclared.manage.PurchaseManage; import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTO; +import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTOV1; import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; @@ -55,11 +56,18 @@ public class PurchaseController { ExcelDownUtil.downXls(response, req, purchaseManage::exportList); } - @ApiOperation(value = "填写采购结果", notes = "填写采购结果") + /*@ApiOperation(value = "填写采购结果", notes = "填写采购结果") @WebLog("填写采购结果") @PostMapping("/submit-result") public String submitResult(@Validated @RequestBody PurchaseSaveDTO dto) { return purchaseManage.submitResult(dto); + }*/ + + @ApiOperation(value = "填写采购结果", notes = "填写采购结果") + @WebLog("填写采购结果") + @PostMapping("/submit-result") + public String submitResult(@Validated @RequestBody PurchaseSaveDTOV1 dto) { + return purchaseManage.submitResultV1(dto); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java index f883e34..55b7afb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.lang.Assert; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.ningdatech.basic.exception.BizException; @@ -11,12 +12,14 @@ import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO; import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTO; +import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTOV1; import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase; import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService; @@ -226,4 +229,61 @@ public class PurchaseManage { return "保存失败"; } + + /** + * 填写采购结果 + * + * @param dto + * @return + */ + public String submitResultV1(PurchaseSaveDTOV1 dto) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + String employeeCode = user.getEmployeeCode(); + VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); + + Long projectId = dto.getProjectId(); + VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!"); + Project project = projectService.getNewProject(dto.getProjectId()); + VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); + + //首先要判断 项目当前状态 是不是 采购结果备案 + VUtils.isTrue(!ProjectStatusEnum.TO_BE_PURCHASED.eq(project.getStatus()) + || !ProjectStatusEnum.PROJECT_APPROVED.eq(project.getStage())) + .throwMessage("提交失败 该项目不是 待采购备案状态或者已立项阶段"); + + Purchase purchase1 = purchaseService.getOne(Wrappers.lambdaQuery(Purchase.class) + .eq(Purchase::getProjectId, projectId) + .last(BizConst.LIMIT_1)); + Purchase purchase = BeanUtil.copyProperties(dto, Purchase.class); + if (purchase1 == null) { + purchase.setCreateBy(employeeCode); + purchase.setCreateOn(LocalDateTime.now()); + } + purchase.setProjectId(projectId); + + if (purchaseService.saveOrUpdate(purchase)) { + // 如果 需要推送项目和应用管理的话 只有遂昌县才有 + // String areaCode = project.getAreaCode(); + // String appCode = dto.getAppCode(); + // if(RegionConst.RC_SC.equals(areaCode) && StringUtils.isNotBlank(appCode)){ + // try{ + // + // }catch (Exception e){ + // log.info("绑定以及推送项目和应用关系 失败! {}" + e.getMessage()); + // } + // } + //进入到下一状态 + stateMachineUtils.pass(project); + project.setUpdateOn(LocalDateTime.now()); + + // 获取总的成交时间及金额 + project.setTransactionAmount(purchase.getTransactionAmount()); + project.setTransactionTime(purchase.getTransactionTime()); + projectService.updateById(project); + + return "填写成功"; + } + + return "保存失败"; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java new file mode 100644 index 0000000..7a5ee25 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java @@ -0,0 +1,62 @@ +package com.ningdatech.pmapi.projectdeclared.model.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * @Classname Purchase + * @Description + * @Date 2023/5/29 10:00 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "采购对象", description = "采购对象") +@AllArgsConstructor +public class PurchaseSaveDTOV1 { + + @ApiModelProperty("项目ID") + @NotNull(message = "请传项目ID") + private Long projectId; + + @ApiModelProperty("供应商") + private String supplier; + + @ApiModelProperty("供应商联系人") + private String supplierContact; + + @ApiModelProperty("供应商联系方式") + private String supplierContactInfo; + + @ApiModelProperty("采购方式 1公开招标 2自行采购") + private Integer purchaseMethod; + + @ApiModelProperty("成交金额") + private BigDecimal transactionAmount; + + @ApiModelProperty("成交时间") + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDateTime transactionTime; + + @ApiModelProperty("代理机构") + private String agency; + + @ApiModelProperty("投标文件") + private String biddingDoc; + + @ApiModelProperty("招标文件") + private String bidDoc; + + @ApiModelProperty("中标通知书") + private String acceptanceLetter; + + @ApiModelProperty("应用编码") + private String appCode; + +}