Browse Source

增加项目信息同步接口

tags/24080901
WendyYang 8 months ago
parent
commit
08a2b2a823
7 changed files with 75 additions and 7 deletions
  1. +11
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderAction.java
  2. +6
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java
  3. +5
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStatusChangeEvent.java
  4. +5
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java
  5. +5
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseService.java
  6. +3
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java
  7. +40
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java

+ 11
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderAction.java View File

@@ -118,6 +118,17 @@ public class TenderAction {
}

/**
* 终验申报重新提交
*
* @param message \
*/
@OnTransition(source = "FINALLY_INSPECTED_FAILED", target = "ON_FINALLY_INSPECTED_APPLY")
public void RESUBMIT_FINALLY_INSPECTED(Message<ProjectStatusChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setStatus(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY.getTenderStatus());
}

/**
* 终验申报通过
*
* @param message \


+ 6
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java View File

@@ -117,6 +117,12 @@ public class TenderStateMachineBuilderImpl implements TenderStateMachineBuilder
.target(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY)
.event(TenderStatusChangeEvent.SUBMIT_FINALLY_INSPECTED)
.and()
// 终验申报重新提交
.withExternal()
.source(TenderStatusEnum.FINALLY_INSPECTED_FAILED)
.target(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY)
.event(TenderStatusChangeEvent.RESUBMIT_FINALLY_INSPECTED)
.and()
// 终验申报通过
.withExternal()
.source(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY)


+ 5
- 1
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStatusChangeEvent.java View File

@@ -50,9 +50,13 @@ public enum TenderStatusChangeEvent {
*/
SUBMIT_FINALLY_INSPECTED(401, null, null),
/**
* 终验申报重新提交
*/
RESUBMIT_FINALLY_INSPECTED(402, null, null),
/**
* 终验申报通过
*/
FINALLY_INSPECTED_PASSED(501, null, null),
FINALLY_INSPECTED_PASSED(502, null, null),
/**
* 终验申报拒绝
*/


+ 5
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java View File

@@ -33,6 +33,11 @@ public class MhSyncController {
syncMhUserOrgManage.syncUsers(syncTime);
}

@GetMapping("/projects")
public void getUsers() {
syncMhUserOrgManage.syncMhProjects();
}

@GetMapping("/units")
public void getUnits() {
syncMhUserOrgManage.syncUnits();


+ 5
- 4
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseService.java View File

@@ -1,5 +1,6 @@
package com.hz.pm.api.projectdeclared.service;

import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -7,10 +8,7 @@ import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum;
import com.ningdatech.basic.util.CollUtils;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

/**
@@ -36,6 +34,9 @@ public interface IPurchaseService extends IService<Purchase> {
}

default Set<Long> listProjectIdByStatus(TenderStatusEnum... status) {
if (ArrayUtil.isEmpty(status)) {
return Collections.emptySet();
}
List<Integer> statusCodes = Arrays.stream(status)
.map(TenderStatusEnum::getTenderStatus)
.collect(Collectors.toList());


+ 3
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java View File

@@ -78,7 +78,9 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle {
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.SUBMIT_PURCHASE_NOTICE.name())
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
if (projectStatusChange != null) {
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
}
}
processDetailVO.setProcessName(CommonConst.TENDER_PURCHASE);
processSchedule.add(processDetailVO);


+ 40
- 1
hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java View File

@@ -1,5 +1,6 @@
package com.hz.pm.api.user.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
@@ -19,7 +20,10 @@ import com.hz.pm.api.meta.helper.DictionaryCache;
import com.hz.pm.api.meta.model.dto.DictionaryDTO;
import com.hz.pm.api.meta.model.entity.ExpertDictionary;
import com.hz.pm.api.meta.service.IExpertDictionaryService;
import com.hz.pm.api.user.helper.MhUnitCache;
import com.hz.pm.api.projectlib.model.entity.MhProject;
import com.hz.pm.api.projectlib.model.entity.MhProjectSchemaTargetData;
import com.hz.pm.api.projectlib.service.IMhProjectSchemaTargetDataService;
import com.hz.pm.api.projectlib.service.IMhProjectService;
import com.hz.pm.api.user.model.entity.MhCompany;
import com.hz.pm.api.user.model.entity.MhUnit;
import com.hz.pm.api.user.model.entity.UserInfo;
@@ -32,6 +36,7 @@ import com.ningdatech.basic.util.CollUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.ArrayList;
@@ -62,6 +67,40 @@ public class SyncMhUserOrgManage {
private final IMhCompanyService mhCompanyService;
private final DictionaryCache dictionaryCache;
private final IExpertDictionaryService expertDictionaryService;
private final IMhProjectService mhProjectService;
private final IMhProjectSchemaTargetDataService mhProjectSchemaTargetDataService;

@Transactional(rollbackFor = Exception.class)
public void syncMhProjects() {
MhRetDTO<List<MhProjectDTO>> mhRet = mhApiClient.listProjects();
if (mhRet.isOk()) {
List<MhProjectDTO> mhRetData = mhRet.getData();
if (CollUtil.isEmpty(mhRetData)) {
log.warn("未获取到可同步的项目信息:{}", JSONUtil.toJsonStr(mhRet));
return;
}
Map<String, MhProjectDTO> retProjectMap = CollUtils.listToMap(mhRetData, w -> w.getProjectName() + "#" + w.getUnitId());
List<MhProject> preProjects = mhProjectService.list();
Map<String, MhProject> preProjectMap = CollUtils.listToMap(preProjects, w -> w.getProjectName() + "#" + w.getUnitId());
retProjectMap.forEach((k, v) -> {
MhProject preProject = preProjectMap.get(k);
if (preProject != null) {
BeanUtil.copyProperties(v, preProject);
} else {
preProject = BeanUtil.copyProperties(v, MhProject.class);
}
mhProjectService.saveOrUpdate(preProject);
if (v.getSchemeTargetData() != null) {
MhProjectSchemaTargetData schemaTargetData = new MhProjectSchemaTargetData();
BeanUtil.copyProperties(v.getSchemeTargetData(), schemaTargetData);
schemaTargetData.setMhProjectId(preProject.getId());
mhProjectSchemaTargetDataService.saveOrUpdate(schemaTargetData);
}
});
} else {
log.error("同步项目信息失败:{}", JSONUtil.toJsonStr(mhRet));
}
}

public void syncUsers(LocalDateTime syncDateTime) {
MhRetDTO<List<MhUserDTO>> mhRet = mhApiClient.queryUsers(syncDateTime);


Loading…
Cancel
Save