# Conflicts: # pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.javatags/24080901
@@ -6,7 +6,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.ningdatech.basic.function.VUtils; | import com.ningdatech.basic.function.VUtils; | ||||
import com.ningdatech.pmapi.common.enumeration.ProjectProessStageEnum; | import com.ningdatech.pmapi.common.enumeration.ProjectProessStageEnum; | ||||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | ||||
import com.ningdatech.pmapi.projectdeclared.entity.dto.*; | |||||
import com.ningdatech.pmapi.projectdeclared.entity.dto.ConstructionPlanDto; | |||||
import com.ningdatech.pmapi.projectdeclared.entity.dto.ProjectConditionDto; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | ||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | import com.ningdatech.pmapi.projectlib.service.IProjectService; | ||||
@@ -45,6 +46,7 @@ public class ConstructionPlanManage { | |||||
/** | /** | ||||
* 提交预审 | * 提交预审 | ||||
* | |||||
* @param dto | * @param dto | ||||
* @return | * @return | ||||
*/ | */ | ||||
@@ -88,7 +90,7 @@ public class ConstructionPlanManage { | |||||
log.info("建设方案项目申报成功 【{}】", instanceId); | log.info("建设方案项目申报成功 【{}】", instanceId); | ||||
//保存建设项目 | //保存建设项目 | ||||
modifyProject(projectInfo, instanceId,dto.getConstructionPlanFile()); | |||||
modifyProject(projectInfo, instanceId, dto.getConstructionPlanFile()); | |||||
return instanceId; | return instanceId; | ||||
} | } | ||||
@@ -99,14 +101,14 @@ public class ConstructionPlanManage { | |||||
* @param project | * @param project | ||||
* @param instanceId | * @param instanceId | ||||
*/ | */ | ||||
private void modifyProject(Project project, String instanceId,String constructionPlanFile) { | |||||
private void modifyProject(Project project, String instanceId, String constructionPlanFile) { | |||||
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示 | //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 | ||||
try { | try { | ||||
project.setUpdateOn(LocalDateTime.now()); | project.setUpdateOn(LocalDateTime.now()); | ||||
project.setInstCode(instanceId); | project.setInstCode(instanceId); | ||||
project.setConstructionPlanFile(constructionPlanFile); | project.setConstructionPlanFile(constructionPlanFile); | ||||
//调用状态机 进入下一个通过状态 | //调用状态机 进入下一个通过状态 | ||||
stateMachineUtils.execute(project,stateMachineUtils.getProjectStatusPassEvent(project.getStatus())); | |||||
stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus())); | |||||
projectService.updateById(project); | projectService.updateById(project); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log.error("提交建设方案 项目信息修改 错误 ", e); | log.error("提交建设方案 项目信息修改 错误 ", e); | ||||
@@ -14,6 +14,7 @@ import lombok.AllArgsConstructor; | |||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import org.springframework.web.multipart.MultipartFile; | import org.springframework.web.multipart.MultipartFile; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import javax.validation.Valid; | import javax.validation.Valid; | ||||
/** | /** | ||||
@@ -66,4 +67,10 @@ public class AnnualPlanController { | |||||
annualPlanLibManage.importAnnualPlan(file); | annualPlanLibManage.importAnnualPlan(file); | ||||
} | } | ||||
@GetMapping("/exportAnnualPlanEditTable") | |||||
@ApiOperation("导出年度计划编辑表") | |||||
public void exportAnnualPlanEditTable(HttpServletResponse response) { | |||||
annualPlanLibManage.exportAnnualPlanEditTable(response); | |||||
} | |||||
} | } |
@@ -1,8 +1,8 @@ | |||||
package com.ningdatech.pmapi.projectlib.manage; | package com.ningdatech.pmapi.projectlib.manage; | ||||
import cn.hutool.poi.excel.ExcelUtil; | |||||
import com.alibaba.excel.EasyExcel; | import com.alibaba.excel.EasyExcel; | ||||
import com.alibaba.excel.ExcelReader; | |||||
import com.alibaba.excel.context.AnalysisContext; | |||||
import com.alibaba.excel.event.AnalysisEventListener; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
@@ -10,10 +10,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
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.ValidUtil; | |||||
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; | import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; | ||||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | ||||
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | ||||
import com.ningdatech.pmapi.projectlib.model.dto.AnnualLibImportDTO; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.model.req.ProjectApprovedReq; | import com.ningdatech.pmapi.projectlib.model.req.ProjectApprovedReq; | ||||
import com.ningdatech.pmapi.projectlib.model.req.ProjectIdReq; | import com.ningdatech.pmapi.projectlib.model.req.ProjectIdReq; | ||||
@@ -26,12 +28,12 @@ import org.springframework.stereotype.Component; | |||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import org.springframework.web.multipart.MultipartFile; | import org.springframework.web.multipart.MultipartFile; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; | import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; | ||||
@@ -139,10 +141,67 @@ public class AnnualPlanLibManage { | |||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public void importAnnualPlan(MultipartFile file) { | public void importAnnualPlan(MultipartFile file) { | ||||
try (InputStream inputStream = file.getInputStream()) { | try (InputStream inputStream = file.getInputStream()) { | ||||
EasyExcel.read(inputStream).sheet(0); | |||||
EasyExcel.read(inputStream, new AnalysisEventListener<AnnualLibImportDTO>() { | |||||
private List<Project> records = new ArrayList<>(); | |||||
@Override | |||||
public void onException(Exception exception, AnalysisContext context) throws Exception { | |||||
super.onException(exception, context); | |||||
throw BizException.wrap("导入年度计划解析失败"); | |||||
} | |||||
@Override | |||||
public void invoke(AnnualLibImportDTO data, AnalysisContext context) { | |||||
ValidUtil.valid(data); | |||||
Project project = new Project(); | |||||
project.setId(data.getProjectId()); | |||||
project.setProjectName(data.getProjectName()); | |||||
project.setProjectRemarks(data.getProjectRemarks()); | |||||
project.setEngineeringSpeedOne(data.getEngineeringSpeedOne()); | |||||
project.setEngineeringSpeedTwo(data.getEngineeringSpeedTwo()); | |||||
project.setEngineeringSpeedThree(data.getEngineeringSpeedThree()); | |||||
project.setEngineeringSpeedFour(data.getEngineeringSpeedFour()); | |||||
project.setAnnualPlanAmount(data.getAnnualPlanAmount()); | |||||
project.setDeclareOtherAmount(data.getDeclareOtherAmount()); | |||||
project.setBuildBasis(data.getBuildBasis()); | |||||
project.setBuildOrgName(data.getBuildUnitName()); | |||||
project.setDeclareBankLendingAmount(data.getDeclareBankLendingAmount()); | |||||
project.setDeclareGovOwnFinanceAmount(data.getDeclareGovOwnFinanceAmount()); | |||||
project.setDeclareGovSuperiorFinanceAmount(data.getDeclareGovSuperiorFinanceAmount()); | |||||
project.setDeclareHaveAmount(data.getDeclareHaveAmount()); | |||||
project.setDeclareOtherAmount(data.getDeclareOtherAmount()); | |||||
project.setContactName(data.getContactName()); | |||||
project.setResponsibleMan(data.getResponsibleMan()); | |||||
String[] dataArr = data.getBuildCycle().split("至"); | |||||
project.setBeginTime(dataArr[0].trim()); | |||||
project.setEndTime(dataArr[1].trim()); | |||||
project.setProjectIntroduction(data.getProjectIntroduction()); | |||||
project.setIsFirst(data.getIsFirst().equals("新建") ? 1 : 0); | |||||
records.add(project); | |||||
} | |||||
@Override | |||||
public void doAfterAllAnalysed(AnalysisContext context) { | |||||
if (records.isEmpty()) { | |||||
throw BizException.wrap("导入年度计划为空"); | |||||
} | |||||
List<Long> projectIds = CollUtils.fieldList(records, Project::getId); | |||||
long count = projectService.count(Wrappers.lambdaQuery(Project.class) | |||||
.in(Project::getId, projectIds)); | |||||
if (count != records.size()) { | |||||
throw BizException.wrap("请确保所有项目都存在"); | |||||
} | |||||
projectService.updateBatchById(records); | |||||
} | |||||
}).sheet(0).doReadSync(); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw BizException.wrap("导入年度计划失败"); | throw BizException.wrap("导入年度计划失败"); | ||||
} | } | ||||
} | } | ||||
public void exportAnnualPlanEditTable(HttpServletResponse response) { | |||||
// TODO | |||||
} | |||||
} | } |
@@ -52,7 +52,7 @@ public class AnnualLibImportDTO { | |||||
@NotNull(message = "年度投资额不能为空") | @NotNull(message = "年度投资额不能为空") | ||||
@ExcelProperty("年度投资额") | @ExcelProperty("年度投资额") | ||||
private BigDecimal annualPlanAMount; | |||||
private BigDecimal annualPlanAmount; | |||||
@ExcelProperty("自有资金") | @ExcelProperty("自有资金") | ||||
@NotNull(message = "自由资金不能为空") | @NotNull(message = "自由资金不能为空") | ||||
@@ -1,9 +1,15 @@ | |||||
package com.ningdatech.pmapi.sys.service; | package com.ningdatech.pmapi.sys.service; | ||||
import cn.hutool.core.collection.CollUtil; | |||||
import cn.hutool.core.io.FileUtil; | |||||
import cn.hutool.db.Db; | import cn.hutool.db.Db; | ||||
import cn.hutool.db.Entity; | import cn.hutool.db.Entity; | ||||
import cn.hutool.json.JSONArray; | |||||
import cn.hutool.json.JSONObject; | |||||
import cn.hutool.json.JSONUtil; | |||||
import com.ningdatech.pmapi.AppTests; | import com.ningdatech.pmapi.AppTests; | ||||
import com.ningdatech.pmapi.sys.model.entity.Menu; | import com.ningdatech.pmapi.sys.model.entity.Menu; | ||||
import com.ningdatech.pmapi.sys.model.entity.RoleMenu; | |||||
import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
@@ -34,4 +40,45 @@ class IMenuServiceTest extends AppTests { | |||||
}); | }); | ||||
} | } | ||||
@Autowired | |||||
private IRoleMenuService roleMenuService; | |||||
@Test | |||||
public void initMenu() { | |||||
/*String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8"); | |||||
List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class); | |||||
save(obj, 0);*/ | |||||
menuService.list().forEach(w -> { | |||||
roleMenuService.save(new RoleMenu(){{ | |||||
setRoleId(1L); | |||||
setMenuId(w.getId()); | |||||
}}); | |||||
}); | |||||
} | |||||
public void save(List<JSONObject> objs, long parentId) { | |||||
objs.forEach(w -> { | |||||
Menu menu = new Menu(); | |||||
menu.setActiveMenu(w.getStr("activeMenu")); | |||||
menu.setComponent(w.getStr("component")); | |||||
menu.setIcon(w.getStr("icon")); | |||||
menu.setPath(w.getStr("path")); | |||||
menu.setName(w.getStr("path").replace("/", "")); | |||||
menu.setTopMenu(w.getStr("topMenu")); | |||||
menu.setTitle(w.getStr("title")); | |||||
menu.setHidden(w.getBool("hidden")); | |||||
menu.setPid(parentId); | |||||
menu.setRedirect(w.getStr("redirect")); | |||||
menu.setSort(w.getInt("sort")); | |||||
menu.setDataScopeOption(""); | |||||
menu.setHasDataScope(false); | |||||
menuService.save(menu); | |||||
List<JSONObject> children = w.getBeanList("children", JSONObject.class); | |||||
if (CollUtil.isNotEmpty(children)) { | |||||
save(children, menu.getId()); | |||||
} | |||||
}); | |||||
} | |||||
} | } |