ソースを参照

合同debug

tags/24080901
PoffyZhang 1年前
コミット
adb01ee2b7
2個のファイルの変更192行の追加13行の削除
  1. +13
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java
  2. +179
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollection3Test.java

+ 13
- 13
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java ファイルの表示

@@ -158,8 +158,8 @@ public class WorkbenchManage {

List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE)
.eq(user.getRegionAdmin(),Project::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),Project::getBuildOrgCode,user.getEmpPosUnitCode()));
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),Project::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),Project::getBuildOrgCode,user.getEmpPosUnitCode()));
Set<String> projectCodeS = Sets.newHashSet();
Map<String,String> projectNameMap = projects.stream()
.filter(p -> projectCodeS.add(p.getProjectCode()))
@@ -171,13 +171,13 @@ public class WorkbenchManage {
Long overCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.OVER.getCode())
.or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType))
.eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()));
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()));
accumulate.setOver(overCount.intValue());
Long adventCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode())
.eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()));
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()));
accumulate.setAdvent(adventCount.intValue());
projectEarlyWarning.setAccumulate(accumulate);

@@ -189,18 +189,18 @@ public class WorkbenchManage {
Page<ProjectEarlyWarning> normalPage = Page.of(1,1000);
LambdaQueryWrapper<ProjectEarlyWarning> overWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME.name())
.eq(user.getRegionAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
projectEarlyWarningService.page(overPage,overWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> adventWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.ADVENT_TIME.name())
.eq(user.getRegionAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
projectEarlyWarningService.page(adventPage,adventWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> normalWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL.name())
.eq(user.getRegionAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
projectEarlyWarningService.page(normalPage,normalWrapper);

WorkbenchVO.WarningStatistics cuurent = new WorkbenchVO.WarningStatistics();
@@ -213,8 +213,8 @@ public class WorkbenchManage {
projectEarlyWarning.setCurrent(cuurent);

List<WflowEarlyWarningRecords> warningRecords = earlyWarningRecordsService.list(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq(user.getIsOrgAdmin() || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode())
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode())
.orderByDesc(WflowEarlyWarningRecords::getWarningTime));
Set<String> projectCodeSet = Sets.newHashSet();
Map<String, WflowEarlyWarningRecords> warningMap = warningRecords.stream()


+ 179
- 0
pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollection3Test.java ファイルの表示

@@ -0,0 +1,179 @@
package com.ningdatech.pmapi.projectCollection;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.common.constant.RegionConst;
import com.ningdatech.pmapi.gov.contants.BizProjectContant;
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO;
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO;
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO;
import com.ningdatech.pmapi.gov.model.entity.*;
import com.ningdatech.pmapi.gov.service.*;
import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @Classname ProjectCollection3Test
* @Description
* @Date 2023/9/7 15:08
* @Author PoffyZhang
*/
@Slf4j
public class ProjectCollection3Test extends AppTests {

@Autowired
private IGovBizProjectBaseinfoService baseinfoService;

@Autowired
private IGovBizProjectApplyService applyService;

@Autowired
private IGovBizProjectApproveService approveService;

@Autowired
private IGovBizProjectCimplementService cimplementService;

@Autowired
private IGovBizProjectMimplementService mimplementService;

@Autowired
private IGovBizProjectProcureService procureService;

@Autowired
private GenerateProjectCodeUtil generateProjectCodeUtil;

@Autowired
private IProjectService projectService;

@Test
public void importData() throws Exception {
Workbook wb;
File f = new File("C:\\Users\\PoffyZhang\\Desktop\\恢复清单.xlsx");
wb = readExcel(new FileInputStream(f),f.getName());
Row row = null;
Integer successed = 0;
List<String> failed = Lists.newArrayList();
if(wb != null) {
//获取第一个sheet
Sheet sheet = wb.getSheetAt(0);
//获取最大行数
int rownum = sheet.getPhysicalNumberOfRows();

//获取第一行
row = sheet.getRow(0);
//获取最大列数
for (int i = 0; i < rownum; i++) {
row = sheet.getRow(i);
if(Objects.isNull(row) || Objects.isNull(row.getCell(0))){
break;
}

GovBizProjectBaseinfo baseinfo = new GovBizProjectBaseinfo();
//
String projName = Objects.nonNull(row.getCell(2)) ? row.getCell(2).toString() : StringUtils.EMPTY;
log.info("projName :{}",projName);
GovBizProjectBaseinfo base = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class)
.eq(GovBizProjectBaseinfo::getBaseProjName, projName)
.last(BizConst.LIMIT_1));
if(Objects.isNull(base)){
log.info("没有匹配项目 :{}",projName);
failed.add(projName);
continue;
}
//否则 就去恢复
String baseProjId = base.getBaseProjId();
base.setDeleted(Boolean.FALSE);
baseinfoService.updateById(base);

GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class)
.eq(GovBizProjectApply::getBaseProjId, baseProjId)
.last(BizConst.LIMIT_1));
if(Objects.nonNull(apply)){
apply.setDeleted(Boolean.FALSE);
applyService.updateById(apply);
}

GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaQuery(GovBizProjectApprove.class)
.eq(GovBizProjectApprove::getBaseProjId, baseProjId)
.last(BizConst.LIMIT_1));
if(Objects.nonNull(approve)){
approve.setDeleted(Boolean.FALSE);
approveService.updateById(approve);
}

GovBizProjectCimplement cimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class)
.eq(GovBizProjectCimplement::getBaseProjId, baseProjId)
.last(BizConst.LIMIT_1));
if(Objects.nonNull(cimplement)){
cimplement.setDeleted(Boolean.FALSE);
cimplementService.updateById(cimplement);
}

GovBizProjectMimplement mimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class)
.eq(GovBizProjectMimplement::getBaseProjId, baseProjId)
.last(BizConst.LIMIT_1));
if(Objects.nonNull(mimplement)){
mimplement.setDeleted(Boolean.FALSE);
mimplementService.updateById(mimplement);
}

List<GovBizProjectProcure> procures = procureService.list(Wrappers.lambdaQuery(GovBizProjectProcure.class)
.eq(GovBizProjectProcure::getBaseProjId, baseProjId)
.last(BizConst.LIMIT_1));
if(CollUtil.isNotEmpty(procures)){
for(GovBizProjectProcure procure : procures){
procure.setDeleted(Boolean.FALSE);
procureService.updateById(procure);
}
}

successed ++;
}
}

log.info("导入完成 :{}个",successed);
log.info("导入失败 :{}",failed);
}

//这个下面是单独函数
public static Workbook readExcel(InputStream is, String extString){
Workbook wb = null;
extString = extString.substring(extString.lastIndexOf("."));
try {
if(".xls".equals(extString)){
return wb = new HSSFWorkbook(is);
}else if(".xlsx".equals(extString)){
return wb = new XSSFWorkbook(is);
}else {
return wb = null;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return wb;
}
}

読み込み中…
キャンセル
保存