From f791f8b1781e8209422c9d604695720e415826db Mon Sep 17 00:00:00 2001 From: luohairen <3399054449@qq.com> Date: 星期二, 26 十一月 2024 15:52:09 +0800 Subject: [PATCH] 完成计划项编辑上报 --- business/src/main/java/com/ycl/domain/entity/ProjectPlanInfo.java | 15 ++++ business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoResponseVO.java | 17 +++++ business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java | 57 ++++++++++++++++++ business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoItem.java | 16 +++++ business/src/main/resources/mapper/ProjectPlanInfoMapper.xml | 17 ++++- business/src/main/java/com/ycl/controller/ProjectPlanInfoController.java | 17 +++++ business/src/main/java/com/ycl/service/ProjectPlanInfoService.java | 15 ++++ business/src/main/java/com/ycl/mapper/ProjectPlanInfoMapper.java | 3 + business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoRequest.java | 17 +++++ 9 files changed, 162 insertions(+), 12 deletions(-) diff --git a/business/src/main/java/com/ycl/controller/ProjectPlanInfoController.java b/business/src/main/java/com/ycl/controller/ProjectPlanInfoController.java index e92a71f..84e7722 100644 --- a/business/src/main/java/com/ycl/controller/ProjectPlanInfoController.java +++ b/business/src/main/java/com/ycl/controller/ProjectPlanInfoController.java @@ -4,8 +4,10 @@ import com.ycl.common.base.Result; import com.ycl.common.group.Add; import com.ycl.common.group.Update; +import com.ycl.domain.entity.ProjectPlanInfo; import com.ycl.domain.form.ProjectPlanInfoForm; import com.ycl.domain.query.ProjectPlanInfoQuery; +import com.ycl.domain.vo.ProjectPlanInfoRequest; import com.ycl.service.ProjectPlanInfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,7 +36,7 @@ @PostMapping @ApiOperation(value = "娣诲姞", notes = "娣诲姞") - @PreAuthorize("hasAuthority('projectPlanInfo:add')") +// @PreAuthorize("hasAuthority('projectPlanInfo:add')") public Result add(@RequestBody @Validated(Add.class) ProjectPlanInfoForm form) { return projectPlanInfoService.add(form); } @@ -69,7 +71,7 @@ @GetMapping("/{id}") @ApiOperation(value = "璇︽儏", notes = "璇︽儏") - @PreAuthorize("hasAuthority('projectPlanInfo:detail')") +// @PreAuthorize("hasAuthority('projectPlanInfo:detail')") public Result detail(@PathVariable("id") Integer id) { return projectPlanInfoService.detail(id); } @@ -80,4 +82,15 @@ public Result list() { return projectPlanInfoService.all(); } + + + @PostMapping("/addPlanInfo") + public Result addPlanInfo(@RequestBody ProjectPlanInfoRequest request) { + return projectPlanInfoService.addPlanInfo(request); + } + + @PostMapping("/savePlanInfo") + public Result savePlanInfo(@RequestBody ProjectPlanInfo item) { + return projectPlanInfoService.savePlanInfo(item); + } } diff --git a/business/src/main/java/com/ycl/domain/entity/ProjectPlanInfo.java b/business/src/main/java/com/ycl/domain/entity/ProjectPlanInfo.java index 421f60b..a1933c7 100644 --- a/business/src/main/java/com/ycl/domain/entity/ProjectPlanInfo.java +++ b/business/src/main/java/com/ycl/domain/entity/ProjectPlanInfo.java @@ -1,11 +1,13 @@ package com.ycl.domain.entity; +import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.ycl.system.domain.base.AbsEntity; import lombok.Data; import java.time.LocalDateTime; +import java.util.Date; /** * 椤圭洰璁″垝椤� @@ -33,11 +35,20 @@ @TableField("start_time") /** 璁″垝寮�濮嬫椂闂� */ - private LocalDateTime startTime; + private Date startTime; @TableField("end_time") /** 璁″垝瀹屾垚鏃堕棿 */ - private LocalDateTime endTime; + private Date endTime; + /** 鍒涘缓鏃堕棿 */ + @TableField(exist = false) + private Date gmtCreate; + /** 淇敼鏃堕棿 */ + @TableField(exist = false) + private Date gmtUpdate; + + @TableField(exist = false) + private Integer deleted; } diff --git a/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoItem.java b/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoItem.java new file mode 100644 index 0000000..9be4fa1 --- /dev/null +++ b/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoItem.java @@ -0,0 +1,16 @@ +package com.ycl.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ProjectPlanInfoItem { + private String title; + private Date startTime; + private Date endTime; +} diff --git a/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoRequest.java b/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoRequest.java new file mode 100644 index 0000000..38745a9 --- /dev/null +++ b/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoRequest.java @@ -0,0 +1,17 @@ +package com.ycl.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ProjectPlanInfoRequest { + private Integer projectPlanRecordId; + private BigDecimal actualInvest; + private List<ProjectPlanInfoItem> addList; +} diff --git a/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoResponseVO.java b/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoResponseVO.java new file mode 100644 index 0000000..1156970 --- /dev/null +++ b/business/src/main/java/com/ycl/domain/vo/ProjectPlanInfoResponseVO.java @@ -0,0 +1,17 @@ +package com.ycl.domain.vo; + +import com.ycl.domain.entity.ProjectPlanInfo; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ProjectPlanInfoResponseVO { + private List<ProjectPlanInfo> list; + private BigDecimal actualInvest; +} diff --git a/business/src/main/java/com/ycl/mapper/ProjectPlanInfoMapper.java b/business/src/main/java/com/ycl/mapper/ProjectPlanInfoMapper.java index 36005d1..d0d21cd 100644 --- a/business/src/main/java/com/ycl/mapper/ProjectPlanInfoMapper.java +++ b/business/src/main/java/com/ycl/mapper/ProjectPlanInfoMapper.java @@ -31,4 +31,7 @@ */ IPage getPage(IPage page, @Param("query") ProjectPlanInfoQuery query); + void batchInsert(@Param("list") List<ProjectPlanInfo> list); + + void insertOne(ProjectPlanInfo item); } diff --git a/business/src/main/java/com/ycl/service/ProjectPlanInfoService.java b/business/src/main/java/com/ycl/service/ProjectPlanInfoService.java index ef8c612..e8c4e77 100644 --- a/business/src/main/java/com/ycl/service/ProjectPlanInfoService.java +++ b/business/src/main/java/com/ycl/service/ProjectPlanInfoService.java @@ -5,6 +5,7 @@ import com.ycl.domain.entity.ProjectPlanInfo; import com.ycl.domain.form.ProjectPlanInfoForm; import com.ycl.domain.query.ProjectPlanInfoQuery; +import com.ycl.domain.vo.ProjectPlanInfoRequest; import java.util.List; @@ -59,8 +60,20 @@ Result detail(Integer id); /** - * 鍒楄〃 + * 鏂板璁″垝椤� * @return */ Result all(); + + /** + * 鏂板璁″垝椤� + * @return + */ + Result addPlanInfo(ProjectPlanInfoRequest request); + + /** + * 淇濆瓨璁″垝椤� + * @return + */ + Result savePlanInfo(ProjectPlanInfo item); } diff --git a/business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java index 6c533f0..9f58f2e 100644 --- a/business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java +++ b/business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java @@ -1,20 +1,27 @@ package com.ycl.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.common.base.Result; import com.ycl.domain.entity.ProjectPlanInfo; +import com.ycl.domain.entity.ProjectPlanRecord; import com.ycl.domain.form.ProjectPlanInfoForm; import com.ycl.domain.query.ProjectPlanInfoQuery; +import com.ycl.domain.vo.ProjectPlanInfoRequest; +import com.ycl.domain.vo.ProjectPlanInfoResponseVO; import com.ycl.domain.vo.ProjectPlanInfoVO; import com.ycl.framework.utils.PageUtil; import com.ycl.mapper.ProjectPlanInfoMapper; +import com.ycl.mapper.ProjectPlanRecordMapper; import com.ycl.service.ProjectPlanInfoService; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -29,6 +36,7 @@ public class ProjectPlanInfoServiceImpl extends ServiceImpl<ProjectPlanInfoMapper, ProjectPlanInfo> implements ProjectPlanInfoService { private final ProjectPlanInfoMapper projectPlanInfoMapper; + private final ProjectPlanRecordMapper projectPlanRecordMapper; /** * 娣诲姞 @@ -99,8 +107,9 @@ */ @Override public Result detail(Integer id) { - ProjectPlanInfoVO vo = baseMapper.getById(id); - Assert.notNull(vo, "璁板綍涓嶅瓨鍦�"); + ProjectPlanInfoResponseVO vo = new ProjectPlanInfoResponseVO(); + vo.setList(new LambdaQueryChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getProjectPlanRecordId, id).list()); + vo.setActualInvest(new LambdaQueryChainWrapper<>(projectPlanRecordMapper).eq(ProjectPlanRecord::getId, id).one().getActualInvest()); return Result.ok().data(vo); } @@ -116,4 +125,48 @@ .collect(Collectors.toList()); return Result.ok().data(vos); } + + @Override + public Result addPlanInfo(ProjectPlanInfoRequest request) { + if (request.getAddList() == null || request.getAddList().isEmpty()) {{ + return Result.error("璇烽�夋嫨瑕佹坊鍔犵殑璁″垝椤�"); + }} + // 鍒犻櫎鍘熸湁璁板綍 + new LambdaUpdateChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getProjectPlanRecordId, request.getProjectPlanRecordId()).remove(); + // 鎵归噺鎻掑叆鏂拌褰� + List<ProjectPlanInfo> list = new ArrayList<>(); + request.getAddList().forEach(item -> { + ProjectPlanInfo projectPlanInfo = new ProjectPlanInfo(); + projectPlanInfo.setProjectPlanRecordId(request.getProjectPlanRecordId().longValue()); + projectPlanInfo.setTitle(item.getTitle()); + projectPlanInfo.setProgressStatus(0); + projectPlanInfo.setStartTime(item.getStartTime()); + projectPlanInfo.setEndTime(item.getEndTime()); + list.add(projectPlanInfo); + }); + baseMapper.batchInsert(list); + // 鏇存柊璁″垝璁板綍鐨勬姇璧�,浠ュ強涓婃姤鐘舵�� + new LambdaUpdateChainWrapper<>(projectPlanRecordMapper) + .eq(ProjectPlanRecord::getId, request.getProjectPlanRecordId()) + .set(ProjectPlanRecord::getActualInvest, request.getActualInvest()) + .set(ProjectPlanRecord::getReportStatus, 0) + .update(); + return Result.ok("娣诲姞鎴愬姛"); + } + + @Override + public Result savePlanInfo(ProjectPlanInfo item) { + item.setProgressStatus(0); + // 鍒ゆ柇id鏄惁瀛樺湪锛屽瓨鍦ㄥ垯鏇存柊锛屼笉瀛樺湪鍒欐柊澧� + if (item.getId() == null) { + baseMapper.insertOne(item); + } else { + new LambdaUpdateChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getId, item.getId()) + .set(ProjectPlanInfo::getTitle, item.getTitle()) + .set(ProjectPlanInfo::getStartTime, item.getStartTime()) + .set(ProjectPlanInfo::getEndTime, item.getEndTime()) + .update(); + } + return Result.ok("淇濆瓨鎴愬姛"); + } } diff --git a/business/src/main/resources/mapper/ProjectPlanInfoMapper.xml b/business/src/main/resources/mapper/ProjectPlanInfoMapper.xml index 2ea53cc..002a186 100644 --- a/business/src/main/resources/mapper/ProjectPlanInfoMapper.xml +++ b/business/src/main/resources/mapper/ProjectPlanInfoMapper.xml @@ -10,11 +10,18 @@ <result column="start_time" property="startTime" /> <result column="end_time" property="endTime" /> </resultMap> - - - - - + <insert id="batchInsert"> + insert into t_project_plan_info(project_plan_record_id, title, progress_status, start_time, end_time) + values + <foreach collection="list" item="item" separator=","> + (#{item.projectPlanRecordId}, #{item.title}, #{item.progressStatus}, #{item.startTime}, #{item.endTime}) + </foreach> + </insert> + <insert id="insertOne"> + insert into t_project_plan_info(project_plan_record_id, title, progress_status, start_time, end_time) + values + (#{projectPlanRecordId}, #{title}, #{progressStatus}, #{startTime}, #{endTime}) + </insert> <select id="getById" resultMap="BaseResultMap"> -- Gitblit v1.8.0