Browse Source

跑组织数据 代码优化

master
PoffyZhang 1 year ago
parent
commit
bdf8f79ad8
4 changed files with 79 additions and 150 deletions
  1. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java
  2. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/GovBusinessStripsTask.java
  3. +66
    -147
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/FinalAcceptanceManage.java
  4. +2
    -2
      pmapi/src/main/resources/integration/zwdd-prod.yml

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java View File

@@ -23,7 +23,6 @@ import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition.GovEmploy
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -67,6 +66,7 @@ public class EmployeeBatchGetTask {
// 获取所有的组织列表用户获取组织下的 用户信息(暂时 只查 单位的类型)
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getTypeCode,"GOV_UNIT"));
log.info("所有待更新员工的单位数:{}",dingOrganizationList.size());
if (CollUtil.isNotEmpty(dingOrganizationList)) {
//记录任务 单位数
Integer index = 0;


+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/GovBusinessStripsTask.java View File

@@ -1,6 +1,7 @@
package com.ningdatech.pmapi.ding.task;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.pmapi.organization.entity.GovBusinessStrip;
import com.ningdatech.pmapi.organization.service.IGovBusinessStripService;
@@ -8,6 +9,7 @@ import com.ningdatech.zwdd.client.ZwddClient;
import com.ningdatech.zwdd.model.Page;
import com.ningdatech.zwdd.model.dto.SubGovBusinessStripsDTO;
import com.ningdatech.zwdd.model.query.PageSubGovBusinessStripsQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -22,6 +24,7 @@ import java.util.stream.Collectors;
*/

@Component
@Slf4j
public class GovBusinessStripsTask {

private final static Integer PAGE_SIZE = 20;
@@ -41,6 +44,13 @@ public class GovBusinessStripsTask {
pageSubGovBusinessStripsQuery.setPageNo(1);
pageSubGovBusinessStripsQuery.setPageSize(100);
GenericResult<Page<SubGovBusinessStripsDTO>> pageGenericResult = zwddClient.pageSubGovBusinessStrips(pageSubGovBusinessStripsQuery);

log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult));

if(!pageGenericResult.isSuccess()){
return;
}

Page<SubGovBusinessStripsDTO> data = pageGenericResult.getData();
List<SubGovBusinessStripsDTO> govBusinessStripsDTOList = data.getData();



+ 66
- 147
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/FinalAcceptanceManage.java View File

@@ -1,6 +1,5 @@
package com.ningdatech.pmapi.projectdeclared.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -12,32 +11,33 @@ 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.enumeration.ProjectProcessStageEnum;
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.ContractSaveDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract;
import com.ningdatech.pmapi.projectdeclared.model.entity.PaymentPlan;
import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase;
import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO;
import com.ningdatech.pmapi.projectdeclared.model.vo.FinalAcceptanceVO;
import com.ningdatech.pmapi.projectdeclared.model.vo.PaymentPlanVO;
import com.ningdatech.pmapi.projectdeclared.service.IContractService;
import com.ningdatech.pmapi.projectdeclared.service.IPaymentPlanService;
import com.ningdatech.pmapi.projectdeclared.service.IPreInsAcceptancePersonService;
import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService;
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException;
import com.wflow.workflow.bean.dto.OrgInfoDTO;
import com.wflow.workflow.bean.vo.ProcessStartParamsVo;
import com.wflow.workflow.service.ProcessInstanceService;
import com.wflow.workflow.service.ProcessModelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -46,9 +46,6 @@ import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -69,16 +66,13 @@ public class FinalAcceptanceManage {

private final IProjectService projectService;
private final UserInfoHelper userInfoHelper;
private final StateMachineUtils stateMachineUtils;

private final IPurchaseService purchaseService;

private final IContractService contractService;

private final IPaymentPlanService paymentPlanService;
private final ProcessModelService processModelService;

private final IPreInsAcceptancePersonService acceptancePersonService;
private final ProcessInstanceService processInstanceService;

private final StateMachineUtils stateMachineUtils;
private final DefaultDeclaredProjectManage declaredProjectManage;

/**
* 待采购的-项目列表
@@ -102,12 +96,6 @@ public class FinalAcceptanceManage {
return PageVo.empty();
}

List<Long> projectIds = page.getRecords().stream().map(Project::getId).collect(Collectors.toList());

List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class)
.in(Purchase::getProjectId, projectIds));
Map<Long, Purchase> purchaseMap = purchases.stream().collect(Collectors.toMap(Purchase::getProjectId, v -> v));

List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> {
ProjectLibListItemVO item = new ProjectLibListItemVO();
item.setId(w.getId());
@@ -125,11 +113,6 @@ public class FinalAcceptanceManage {
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg());
item.setApprovedAmount(w.getApprovalAmount());
item.setApprovalDate(w.getApprovalDate());
if(purchaseMap.containsKey(w.getId())){
Purchase purchase = purchaseMap.get(w.getId());
item.setTransactionAmount(purchase.getTransactionAmount());
item.setTransactionTime(purchase.getTransactionTime());
}
item.setBuildCycle(StringUtils.isNotBlank(w.getBuildCycle()) ?
Integer.valueOf(w.getBuildCycle()) : null);
return item;
@@ -153,12 +136,6 @@ public class FinalAcceptanceManage {
AtomicInteger serialNumber = new AtomicInteger(0);
List<DeclaredProjectExportDTO> collect = Lists.newArrayList();
if(CollUtil.isNotEmpty(records)){
List<Long> projectIds = records.stream().map(Project::getId).collect(Collectors.toList());

List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class)
.in(Purchase::getProjectId, projectIds));
Map<Long, Purchase> purchaseMap = purchases.stream().collect(Collectors.toMap(Purchase::getProjectId, v -> v));

collect = records.stream().map(r -> {
DeclaredProjectExportDTO exportDTO = new DeclaredProjectExportDTO();
BeanUtils.copyProperties(r, exportDTO);
@@ -196,114 +173,6 @@ public class FinalAcceptanceManage {
return StringUtils.EMPTY;
}

/**
* 获取合同备案详情
* @param projectId
* @return
*/
public ContractVO detailContractByProjectId(Long projectId) {
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class)
.eq(Contract::getProjectId, projectId)
.last(BizConst.LIMIT_1));

ContractVO vo = BeanUtil.copyProperties(contract, ContractVO.class);

List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class)
.eq(PaymentPlan::getProjectId, projectId)
.orderByAsc(PaymentPlan::getPaymentTime));

if(CollUtil.isNotEmpty(payments)){
vo.setPayments(convertPayments(payments,contract.getTotalAmount()));
}

return vo;
}

private List<PaymentPlanVO> convertPayments(List<PaymentPlan> payments,BigDecimal totalAmount) {
if(CollUtil.isEmpty(payments)){
return Collections.emptyList();
}
return payments.stream().map(p -> {
PaymentPlanVO vo = BeanUtil.copyProperties(p, PaymentPlanVO.class);
vo.setRatio((Objects.isNull(totalAmount)||totalAmount.compareTo(BigDecimal.ZERO) == 0) ? "0%"
: p.getPaymentAmount().multiply(BigDecimal.valueOf(100))
.divide(totalAmount,BigDecimal.ROUND_CEILING,BigDecimal.ROUND_CEILING) + "%");
return vo;
})
.collect(Collectors.toList());
}

/**
* 填写合同信息
* @param dto
* @return
*/
public String submitContract(ContractSaveDTO 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.UNDER_CONSTRUCTION.getCode().equals(project.getStatus()) ||
!ProjectStatusEnum.PROJECT_APPROVED.getCode().equals(project.getStage()))
.throwMessage("提交失败 该项目不是 建设中或者已立项阶段");

Contract contractEntity = new Contract();
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class)
.eq(Contract::getProjectId, projectId)
.last(BizConst.LIMIT_1));

BeanUtil.copyProperties(dto,contractEntity);
if(Objects.isNull(contract)){
contractEntity.setCreateOn(LocalDateTime.now());
contractEntity.setCreateBy(employeeCode);
}else{
contractEntity.setId(contract.getId());
}
contractEntity.setProjectId(projectId);
if(contractService.saveOrUpdate(contractEntity)){
//存 付款计划信心
if(Objects.nonNull(dto.getPayments())){
//先删除
paymentPlanService.remove(Wrappers.lambdaQuery(PaymentPlan.class)
.eq(PaymentPlan::getProjectId,projectId));
if(CollUtil.isNotEmpty(dto.getPayments())){
List<PaymentPlan> payments = dto.getPayments().stream().map(d -> {
PaymentPlan plan = BeanUtil.copyProperties(d, PaymentPlan.class);
plan.setProjectId(projectId);
plan.setCreateOn(LocalDateTime.now());
plan.setUpdateOn(LocalDateTime.now());
plan.setCreateBy(employeeCode);
plan.setUpdateBy(employeeCode);
return plan;
}).collect(Collectors.toList());

paymentPlanService.saveBatch(payments);
}
}
}

//判断下 如果和初验都完成了 才进入下一阶段
if(StringUtils.isNotBlank(project.getPreliminaryInspectionMaterials())){
//进入到下一状态
stateMachineUtils.pass(project);
}
project.setUpdateOn(LocalDateTime.now());
if(Objects.nonNull(dto.getDeliveryTime())){
project.setDeliveryTime(dto.getDeliveryTime());
}
if(Objects.nonNull(dto.getTotalAmount())){
project.setContractAmount(dto.getTotalAmount());
}
projectService.updateById(project);

return "填写成功";
}

public FinalAcceptanceVO detailByProjectId(Long projectId) {
FinalAcceptanceVO vo = new FinalAcceptanceVO();
@@ -325,7 +194,57 @@ public class FinalAcceptanceManage {
* @return
*/
public String startProcess(DefaultDeclaredDTO dto) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String employeeCode = user.getEmployeeCode();
VUtils.isTrue(Objects.isNull(user) || Objects.isNull(employeeCode))
.throwMessage("获取登录用户失败!");

ProjectDTO projectDto = dto.getProjectInfo();
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getNewProject(projectDto.getId());
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");
VUtils.isTrue(StringUtils.isBlank(projectDto.getFinalAcceptanceMaterials())).throwMessage("提交失败 请提交终验材料!");

String regionCode = projectInfo.getAreaCode();

//放入终验材料
projectInfo.setFinalAcceptanceMaterials(projectDto.getFinalAcceptanceMaterials());

WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class)
.eq(WflowModels::getRegionCode, regionCode)
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.ACCEPTANCE_DECLARATION_APPROVAL_PROCESS.getCode())
.last(BizConst.LIMIT_1));

if (Objects.isNull(model)) {
log.error("此 【{}】区域找不到 验收申报流程配置", regionCode);
throw new BusinessException(String.format("此 【%s】区域找不到 验收申报流程配置", regionCode));
}

return null;
//首先要判断 项目当前状态 是不是 方案待申报
VUtils.isTrue(!ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.PROJECT_APPROVED.getCode().equals(projectInfo.getStage()))
.throwMessage("提交失败 该项目不是 待终验状态或者已立项阶段");

ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(declaredProjectManage.buildUser(employeeCode));
params.setProcessUsers(Collections.emptyMap());
//放入条件判断的项目字段
//把条件值给放入工作流
declaredProjectManage.buildCondition(params, dto);
// 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息
Map<String, OrgInfoDTO> orgModelMap = declaredProjectManage.buildOrgModelMap(employeeCode, projectInfo);
String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(), model.getFormId(), params, orgModelMap);
log.info("终验方案项目申报成功 【{}】", instanceId);

//保存终验项目
//生成新版本 并且进入下一状态
// projectInfo = projectLibManage.saveProjectWithVersionAndPass(projectInfo,instanceId, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode());
//
//
// //发送给第一个审批人消息
// noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId,
// WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW);

return instanceId;
}
}

+ 2
- 2
pmapi/src/main/resources/integration/zwdd-prod.yml View File

@@ -5,8 +5,8 @@ integration:
app-auth-key: ls_project_managment_din-b1Y3I1g7Rr94yX76KfFkpp18Uy4WHtU0b6rINJ3
app-auth-secret: 75e8PMHv984KYF0Mcy6v4pxt480y73dbD7kB65dD
#免登/获取信息
app-key: ls_rebuild-10c8n5X0707yFV7jURr
app-secret: gN8J3WazyXLMWKDuFmx6C4yaH5lFUY41x8rYLLo6
app-key: ls_project-c32LNu87v60UiANZVja
app-secret: R14QgbBr21751LTGml3Vt8oX9doPl4Lk1ROzZNfG
#专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729
tenantId: 196729
domain: openplatform-pro.ding.zj.gov.cn

Loading…
Cancel
Save