|
|
@@ -43,7 +43,9 @@ import com.hz.pm.api.sys.manage.NoticeManage; |
|
|
|
import com.hz.pm.api.todocenter.constant.WorkNoticeConst; |
|
|
|
import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
|
import com.hz.pm.api.user.model.dto.UnitDTO; |
|
|
|
import com.hz.pm.api.user.model.entity.MhUnit; |
|
|
|
import com.hz.pm.api.user.security.model.UserInfoDetails; |
|
|
|
import com.hz.pm.api.user.service.IMhUnitService; |
|
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
@@ -63,6 +65,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
@@ -86,6 +89,7 @@ public class DeclaredRecordManage { |
|
|
|
private final IMhProjectSchemaTargetDataService schemaTargetDataService; |
|
|
|
private final IProjectService projectService; |
|
|
|
private final MhUnitCache mhUnitCache; |
|
|
|
private final IMhUnitService mhUnitService; |
|
|
|
private final NoticeManage noticeManage; |
|
|
|
private final IProjectDraftService projectDraftService; |
|
|
|
private final ProcessModelService processModelService; |
|
|
@@ -385,6 +389,7 @@ public class DeclaredRecordManage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void importProjectFinanceInfos(MultipartFile file) { |
|
|
|
try (InputStream is = file.getInputStream()) { |
|
|
|
List<Map<String, Object>> rows = ExcelUtil.getReader(is).readAll(); |
|
|
@@ -404,43 +409,49 @@ public class DeclaredRecordManage { |
|
|
|
financeInfo.setDeclareGovSuperiorFinanceAmount(MapUtil.get(w, "上级补助资金", BigDecimal.class)); |
|
|
|
return financeInfo; |
|
|
|
}); |
|
|
|
Map<String, List<ImportProjectFinanceInfosDTO>> groupByUnit = CollUtils.group(importDataList, ImportProjectFinanceInfosDTO::getUnitName); |
|
|
|
List<Project> projects = new ArrayList<>(); |
|
|
|
for (Map.Entry<String, List<ImportProjectFinanceInfosDTO>> entry : groupByUnit.entrySet()) { |
|
|
|
if (entry.getValue().size() != 1) { |
|
|
|
log.warn("单位存在多个项目:{}", entry.getKey()); |
|
|
|
continue; |
|
|
|
for (ImportProjectFinanceInfosDTO importData : importDataList) { |
|
|
|
String projectName = importData.getProjectName(); |
|
|
|
Project project = projectService.getByProjectName(projectName); |
|
|
|
if (project == null) { |
|
|
|
List<MhUnit> units = mhUnitService.listByName(importData.getUnitName()); |
|
|
|
if (units.size() != 1) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
MhUnit unit = units.get(0); |
|
|
|
MhUnitTypeEnum unitType = MhUnitTypeEnum.getByCode(unit.getType()).get(); |
|
|
|
MhProject mhProject = new MhProject(); |
|
|
|
mhProject.setUnitStrip(unitType.getStrip().getCode()); |
|
|
|
mhProject.setUnitName(unit.getName()); |
|
|
|
mhProject.setUnitId(unit.getId()); |
|
|
|
mhProject.setCreateTime(LocalDateTime.now()); |
|
|
|
mhProject.setProjectName(importData.getProjectName()); |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
mhProject.setProjectCode(projectCodeGenUtil.generateProjectCode(now.getYear())); |
|
|
|
mhProjectService.save(mhProject); |
|
|
|
project = new Project(); |
|
|
|
project.setProjectCode(mhProject.getProjectCode()); |
|
|
|
project.setNewest(Boolean.TRUE); |
|
|
|
project.setVersion(1); |
|
|
|
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); |
|
|
|
project.setStatus(ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD.getCode()); |
|
|
|
project.setCreateOn(now); |
|
|
|
project.setUpdateOn(now); |
|
|
|
project.setUnitStrip(mhProject.getUnitStrip()); |
|
|
|
project.setBuildOrgName(unit.getName()); |
|
|
|
project.setBuildOrgCode(String.valueOf(unit.getId())); |
|
|
|
} |
|
|
|
Collection<Project> projectsTmp = listProjectsByUnitName(entry.getKey()); |
|
|
|
if (projectsTmp.size() != 1) { |
|
|
|
log.warn("单位存在多个项目:{}", entry.getKey()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
Project project = new ArrayList<>(projects).get(0); |
|
|
|
ImportProjectFinanceInfosDTO importData = entry.getValue().get(0); |
|
|
|
project.setApprovalAmount(importData.getDeclareAmount()); |
|
|
|
project.setApprovalGovOwnFinanceAmount(importData.getDeclareGovOwnFinanceAmount()); |
|
|
|
project.setApprovalGovSuperiorFinanceAmount(importData.getDeclareGovSuperiorFinanceAmount()); |
|
|
|
project.setApprovalHaveAmount(importData.getDeclareHaveAmount()); |
|
|
|
projects.add(project); |
|
|
|
projectService.saveOrUpdate(project); |
|
|
|
} |
|
|
|
if (projects.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
projectService.updateBatchById(projects); |
|
|
|
} catch (Exception e) { |
|
|
|
log.info("读取数据失败:", e); |
|
|
|
throw new BizException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private Collection<Project> listProjectsByUnitName(String unitName) { |
|
|
|
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getBuildOrgName, unitName)); |
|
|
|
return BizUtils.groupFirst(projects, Project::getProjectCode, |
|
|
|
Comparator.comparing(Project::getCreateOn).reversed()); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void importReplaceSystemInfos(MultipartFile file) { |
|
|
|
try (InputStream is = file.getInputStream()) { |
|
|
@@ -457,7 +468,6 @@ public class DeclaredRecordManage { |
|
|
|
importData.setSourceName(MapUtil.getStr(w, "替代前系统")); |
|
|
|
importData.setTargetName(MapUtil.getStr(w, "替代后系统")); |
|
|
|
importData.setUnitName(MapUtil.getStr(w, "单位")); |
|
|
|
Assert.notBlank(importData.getUnitName(), "单位名称不能为空"); |
|
|
|
if (StrUtil.equals(importData.getReplaceType(), "/") |
|
|
|
|| StrUtil.isBlank(importData.getReplaceType())) { |
|
|
|
importData.setReplaceType(null); |
|
|
@@ -469,16 +479,14 @@ public class DeclaredRecordManage { |
|
|
|
return importData; |
|
|
|
}); |
|
|
|
Map<String, List<ImportReplaceSystemInfosDTO>> groupByProject = CollUtils.group(importDataList, |
|
|
|
ImportReplaceSystemInfosDTO::getUnitName); |
|
|
|
ImportReplaceSystemInfosDTO::getProjectName); |
|
|
|
List<Long> projectIds = new ArrayList<>(); |
|
|
|
List<ProjectGovSystemReplaceInfos> replaceInfos = new ArrayList<>(); |
|
|
|
for (Map.Entry<String, List<ImportReplaceSystemInfosDTO>> entry : groupByProject.entrySet()) { |
|
|
|
Collection<Project> projects = listProjectsByUnitName(entry.getKey()); |
|
|
|
if (projects.size() != 1) { |
|
|
|
log.warn("单位存在多个项目:{}", entry.getKey()); |
|
|
|
Project project = projectService.getByProjectName(entry.getKey()); |
|
|
|
if (project == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Project project = new ArrayList<>(projects).get(0); |
|
|
|
projectIds.add(project.getId()); |
|
|
|
Map<String, Integer> batchNoMap = new HashMap<>(); |
|
|
|
AtomicInteger integer = new AtomicInteger(1); |
|
|
|