Browse Source

修改采购结果填写接口

master
WendyYang 1 year ago
parent
commit
e05a249b0e
5 changed files with 31 additions and 146 deletions
  1. +1
    -10
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java
  2. +0
    -59
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java
  3. +0
    -62
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java
  4. +29
    -14
      pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java
  5. +1
    -1
      pmapi/src/test/resources/application.yml

+ 1
- 10
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java View File

@@ -6,7 +6,6 @@ import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage; import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage;
import com.ningdatech.pmapi.projectdeclared.manage.PurchaseManage; import com.ningdatech.pmapi.projectdeclared.manage.PurchaseManage;
import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTO; 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.projectdeclared.model.vo.PurchaseVO;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
@@ -56,19 +55,11 @@ public class PurchaseController {
ExcelDownUtil.downXls(response, req, purchaseManage::exportList); ExcelDownUtil.downXls(response, req, purchaseManage::exportList);
} }


/*@ApiOperation(value = "填写采购结果", notes = "填写采购结果")
@ApiOperation(value = "填写采购结果", notes = "填写采购结果")
@WebLog("填写采购结果") @WebLog("填写采购结果")
@PostMapping("/submit-result") @PostMapping("/submit-result")
public String submitResult(@Validated @RequestBody PurchaseSaveDTO dto) { public String submitResult(@Validated @RequestBody PurchaseSaveDTO dto) {
return purchaseManage.submitResult(dto); return purchaseManage.submitResult(dto);
}*/

@ApiOperation(value = "填写采购结果", notes = "填写采购结果")
@WebLog("填写采购结果")
@PostMapping("/submit-result")
public String submitResult(@Validated @RequestBody PurchaseSaveDTOV1 dto) {
return purchaseManage.submitResultV1(dto);
} }



} }

+ 0
- 59
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java View File

@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.exception.BizException;
@@ -12,14 +11,12 @@ import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.NdDateUtils; 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.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.common.util.ExcelExportStyle;
import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO; import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTO; 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.entity.Purchase;
import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO;
import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService; import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService;
@@ -230,60 +227,4 @@ public class PurchaseManage {
return "保存失败"; 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 "保存失败";
}
} }

+ 0
- 62
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java View File

@@ -1,62 +0,0 @@
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;

}

+ 29
- 14
pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java View File

@@ -3,26 +3,21 @@ package com.ningdatech.pmapi.instance;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.wflow.contants.ProcessConstant;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import com.wflow.workflow.bean.dto.TodoCenterListReqDTO; import com.wflow.workflow.bean.dto.TodoCenterListReqDTO;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.history.HistoricActivityInstance; import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ActivityInstance; import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery; import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;


import java.util.*; import java.util.*;
@@ -49,7 +44,7 @@ public class InstanceTest extends AppTests {
private IProjectInstService projectInstService; private IProjectInstService projectInstService;


@Test @Test
public void test(){
public void test() {
String instanceId = "896fa188-96d8-11ed-9539-e2d4e8f16b2f"; String instanceId = "896fa188-96d8-11ed-9539-e2d4e8f16b2f";
Object user = runtimeService.getVariable(instanceId, Object user = runtimeService.getVariable(instanceId,
"owner"); "owner");
@@ -57,7 +52,7 @@ public class InstanceTest extends AppTests {
} }


@Test @Test
public void testHistory(){
public void testHistory() {
//如果有已经被审核过的 节点 //如果有已经被审核过的 节点
List<HistoricActivityInstance> finished = historyService.createHistoricActivityInstanceQuery() List<HistoricActivityInstance> finished = historyService.createHistoricActivityInstanceQuery()
.processInstanceId("085af7ef-d133-11ed-a3f6-02426daa406d").finished() .processInstanceId("085af7ef-d133-11ed-a3f6-02426daa406d").finished()
@@ -68,7 +63,7 @@ public class InstanceTest extends AppTests {
} }


@Test @Test
public void testRuntime(){
public void testRuntime() {
//如果有已经被审核过的 节点 //如果有已经被审核过的 节点
List<ActivityInstance> userTask = runtimeService.createActivityInstanceQuery() List<ActivityInstance> userTask = runtimeService.createActivityInstanceQuery()
.processInstanceId("1709ebe3-d148-11ed-9351-02426daa406d") .processInstanceId("1709ebe3-d148-11ed-9351-02426daa406d")
@@ -78,7 +73,7 @@ public class InstanceTest extends AppTests {
} }


@Test @Test
public void testTodo(){
public void testTodo() {
String employeeCode = "GE_e9d5c7917acd4eeea04ff2a9454af62e"; String employeeCode = "GE_e9d5c7917acd4eeea04ff2a9454af62e";
// 查出项目库项目 // 查出项目库项目
ProjectListReq projectListReq = new ProjectListReq(); ProjectListReq projectListReq = new ProjectListReq();
@@ -93,7 +88,7 @@ public class InstanceTest extends AppTests {
List<ProjectInst> projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) List<ProjectInst> projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, projectIdList) .in(ProjectInst::getProjectId, projectIdList)
.orderByDesc(ProjectInst::getProjectId)); .orderByDesc(ProjectInst::getProjectId));
Map<String, Project> projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId())));
Map<String, Project> projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId())));
List<String> instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); List<String> instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList());


// 查出用户工作流 // 查出用户工作流
@@ -108,7 +103,7 @@ public class InstanceTest extends AppTests {
historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql); historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql);
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list(); List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();


Set set = new HashSet();
Set<String> set = new HashSet<>();
List<HistoricTaskInstance> taskInstanceList = taskInstances.stream() List<HistoricTaskInstance> taskInstanceList = taskInstances.stream()
.filter(t -> instCodes.contains(t.getProcessInstanceId())) .filter(t -> instCodes.contains(t.getProcessInstanceId()))
.sorted(Comparator.comparing(HistoricTaskInstance::getEndTime)).collect(Collectors.toList()) .sorted(Comparator.comparing(HistoricTaskInstance::getEndTime)).collect(Collectors.toList())
@@ -120,14 +115,34 @@ public class InstanceTest extends AppTests {
} }


@Test @Test
public void test2(){
public void test2() {
// 获取节点处理结果 // 获取节点处理结果
// Map<String, ProcessHandlerEnum> varMap = historyService.createHistoricVariableInstanceQuery() // Map<String, ProcessHandlerEnum> varMap = historyService.createHistoricVariableInstanceQuery()
// .processInstanceId("e99fe24c-d21c-11ed-af5d-02426daa406d") // .processInstanceId("e99fe24c-d21c-11ed-af5d-02426daa406d")
// .variableNameLike("approve_%") // .variableNameLike("approve_%")
// .list().stream() // .list().stream()
// .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerEnum) v.getValue())); // .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerEnum) v.getValue()));
runtimeService.removeVariable("564102ce-d1ff-11ed-b694-02424b2b849f","approve_7d2a191a-d1ff-11ed-b694-02424b2b849f");
runtimeService.removeVariable("564102ce-d1ff-11ed-b694-02424b2b849f", "approve_7d2a191a-d1ff-11ed-b694-02424b2b849f");
System.out.println(1); System.out.println(1);
} }

@Test
public void usageTimeStat() {
// 查询所有已完成的流程实例
List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery()
.orderByProcessInstanceStartTime()
.desc()
.finished()
.list();

// 统计每个流程实例的审批耗时
for (HistoricProcessInstance processInstance : processInstanceList) {
System.out.println("流程实例ID:" + processInstance.getId());
System.out.println("流程开始时间:" + processInstance.getStartTime());
System.out.println("流程结束时间:" + processInstance.getEndTime());
System.out.println("流程耗时(ms):" + processInstance.getDurationInMillis() / 1000);
System.out.println("================================================================");
}
}

} }

+ 1
- 1
pmapi/src/test/resources/application.yml View File

@@ -1,3 +1,3 @@
spring: spring:
profiles: profiles:
active: prod
active: dev

Loading…
Cancel
Save