Bladeren bron

项目导入2

qianxb 1 jaar geleden
bovenliggende
commit
e6cf901ed2

+ 1 - 1
src/main/java/org/springblade/modules/project/controller/ProjectInfoController.java

@@ -58,7 +58,7 @@ public class ProjectInfoController extends BladeController {
     @PostMapping("/update")
     @ApiOperationSupport(order = 4)
     @Operation(summary = "修改项目", description = "修改项目,传入项目信息和每一年的计划数组")
-    public R update(@RequestBody ProjectInfoDTO dto) {
+    public R update(@RequestBody ProjectInfoDetailVO dto) {
         projectInfoService.update2(dto);
         return R.success("修改成功");
     }

+ 2 - 1
src/main/java/org/springblade/modules/project/pojo/vo/ProjectInfoDetailVO.java

@@ -14,11 +14,12 @@ import java.util.List;
  * @Date 2024/4/8 11:45
  **/
 @Data
-@Schema(description = "项目详情")
 @EqualsAndHashCode(callSuper = true)
+@Schema(description = "项目详情")
 public class ProjectInfoDetailVO extends ProjectInfo {
 
     @Schema(description = "每年计划集合")
     private List<ProjectInvestPlan> list;
 
 }
+

+ 1 - 1
src/main/java/org/springblade/modules/project/service/IProjectInfoService.java

@@ -21,7 +21,7 @@ public interface IProjectInfoService extends BaseService<ProjectInfo> {
 
     ProjectInfoDetailVO detail(Long id);
 
-    void update2(ProjectInfoDTO dto);
+    void update2(ProjectInfoDetailVO dto);
 
     ProjectAndPlanDetailVO detail2(Long id);
 

+ 18 - 17
src/main/java/org/springblade/modules/project/service/impl/ProjectInfoServiceImpl.java

@@ -165,7 +165,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
 
     @Override
     @Transactional
-    public void update2(ProjectInfoDTO dto) {
+    public void update2(ProjectInfoDetailVO dto) {
         ProjectInfo oldInfo = this.getById(dto.getId());
         if (oldInfo.getStartYear() != null){
             if (!oldInfo.getStartYear().equals(dto.getStartYear()) || !oldInfo.getEndYear().equals(dto.getEndYear())){
@@ -1177,10 +1177,8 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             //判断是新增项目还是修改项目
             if (project.getIsExist()){
                 /*修改项目*/
-                //查询出项目详情
-                ProjectInfoDetailVO detailVO = this.detail(project.getProjectId());
-                ProjectInfoDTO dto = new ProjectInfoDTO();
-                BeanUtils.copyProperties(detailVO,dto);
+                //查询出项目详情,用返回给前端的VO
+                ProjectInfoDetailVO dto = this.detail(project.getProjectId());
                 //修改指定几个项目信息
                 dto.setBuildScale(project.getBuildScale());
                 dto.setBuildScaleUnit(project.getBuildScaleUnit());
@@ -1191,7 +1189,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 dto.setIsPilotPlan(project.getIsPilotPlan());
                 //修改指定年的计划信息
                 for (ProjectInvestPlan plan : dto.getList()) {
-                    if (plan.getPlanYear() == project.getPlanYear()){
+                    if (plan.getPlanYear().equals(project.getPlanYear())){
                         plan.setYearlyInvest(project.getYearlyInvest());
                         plan.setOneInvest(project.getOneInvest());
                         plan.setTwoInvest(project.getTwoInvest());
@@ -1307,6 +1305,9 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             if (year > LocalDate.now().getYear()){
                 throw new ServiceException("标题年份不能大于今年");
             }
+            if (month < 0 || month > 12){
+                throw new ServiceException("标题月份必须在1-12之间");
+            }
             Integer projectType;
             Integer projectStage = 0;
             if (title.contains("重")){
@@ -1396,19 +1397,19 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                         BigDecimal twoInvest = StringChangeBigdecimal(dataFormatter.formatCellValue(row.getCell(10,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK)));
                         BigDecimal threeInvest = StringChangeBigdecimal(dataFormatter.formatCellValue(row.getCell(11,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK)));
                         BigDecimal fourInvest = StringChangeBigdecimal(dataFormatter.formatCellValue(row.getCell(12,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK)));
-                        String yearlyTarget = row.getCell(13, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String onePlan = row.getCell(14, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String twoPlan = row.getCell(15, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String threePlan = row.getCell(16, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String fourPlan = row.getCell(17, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String questionable = row.getCell(22, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String workAdvise = row.getCell(23, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String linkman = row.getCell(24, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String phone = row.getCell(25, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
+                        String yearlyTarget = dataFormatter.formatCellValue(row.getCell(12, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String onePlan = dataFormatter.formatCellValue(row.getCell(14, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String twoPlan = dataFormatter.formatCellValue(row.getCell(15, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String threePlan = dataFormatter.formatCellValue(row.getCell(16, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String fourPlan = dataFormatter.formatCellValue(row.getCell(17, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String questionable = dataFormatter.formatCellValue(row.getCell(22, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String workAdvise = dataFormatter.formatCellValue(row.getCell(23, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String linkman = dataFormatter.formatCellValue(row.getCell(24, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String phone = dataFormatter.formatCellValue(row.getCell(25, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
                         /*月度信息行*/
                         BigDecimal investMoney = StringChangeBigdecimal(dataFormatter.formatCellValue(row.getCell(18,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK)));
-                        String workProgress = row.getCell(19, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
-                        String workProgressAll = row.getCell(20, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
+                        String workProgress = dataFormatter.formatCellValue(row.getCell(19, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
+                        String workProgressAll = dataFormatter.formatCellValue(row.getCell(20, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK));
                         BigDecimal planRatio = StringChangeBigdecimal(dataFormatter.formatCellValue(row.getCell(21,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK)));
                         if (planRatio != null && (planRatio.compareTo(BigDecimal.ZERO) == -1 || planRatio.compareTo(new BigDecimal(100)) == 1)){
                             throw new ServiceException("工程整体形象进度要在0-100之间");