From 3a3ab7e50002d269b65473f8cb139fb7f908f292 Mon Sep 17 00:00:00 2001 From: luohairen <3399054449@qq.com> Date: 星期四, 12 十二月 2024 17:25:03 +0800 Subject: [PATCH] 调整 --- business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java | 68 ++++++++++++++-------------------- 1 files changed, 28 insertions(+), 40 deletions(-) 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 6e189bc..78f132c 100644 --- a/business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java +++ b/business/src/main/java/com/ycl/service/impl/ProjectPlanInfoServiceImpl.java @@ -9,8 +9,8 @@ import com.ycl.domain.entity.ProjectPlanInfo; import com.ycl.domain.entity.ProjectPlanRecord; import com.ycl.domain.form.ProjectPlanInfoForm; +import com.ycl.domain.form.ProjectPlanInfoRequestForm; 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; @@ -20,11 +20,9 @@ import com.ycl.service.ProjectPlanInfoService; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Date; @@ -113,7 +111,7 @@ * @return */ @Override - public Result detail(Integer id) { + public Result detail(Long id) { 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()); @@ -135,19 +133,16 @@ @Transactional(rollbackFor = Exception.class) @Override - public Result addPlanInfo(ProjectPlanInfoRequest request) { - if (CollectionUtils.isEmpty(request.getAddList())) {{ - return Result.error("璇烽�夋嫨瑕佹坊鍔犵殑璁″垝椤�"); - }} + public Result addPlanInfo(ProjectPlanInfoRequestForm form) { // 鍒犻櫎鍘熸湁璁板綍 new LambdaUpdateChainWrapper<>(baseMapper) - .eq(ProjectPlanInfo::getProjectPlanRecordId, request.getProjectPlanRecordId()) + .eq(ProjectPlanInfo::getProjectPlanRecordId, form.getProjectPlanRecordId()) .remove(); // 鎵归噺鎻掑叆鏂拌褰� List<ProjectPlanInfo> list = new ArrayList<>(); - request.getAddList().forEach(item -> { + form.getAddList().forEach(item -> { ProjectPlanInfo projectPlanInfo = new ProjectPlanInfo(); - projectPlanInfo.setProjectPlanRecordId(request.getProjectPlanRecordId().longValue()); + projectPlanInfo.setProjectPlanRecordId(form.getProjectPlanRecordId()); projectPlanInfo.setTitle(item.getTitle()); // 璁″垝椤规爣棰� projectPlanInfo.setPlanStatus(0); // 璁″垝椤圭姸鎬佷负鏈紑濮� projectPlanInfo.setProgressStatus(0); // 璁″垝椤硅繘搴︿负鏈紑濮� @@ -158,36 +153,37 @@ this.saveBatch(list); // 鏇存柊璁″垝璁板綍鐨勬姇璧�,浠ュ強涓婃姤鐘舵�� new LambdaUpdateChainWrapper<>(projectPlanRecordMapper) - .eq(ProjectPlanRecord::getId, request.getProjectPlanRecordId()) - .set(ProjectPlanRecord::getActualInvest, request.getActualInvest()) + .eq(ProjectPlanRecord::getId, form.getProjectPlanRecordId()) + .set(ProjectPlanRecord::getActualInvest, form.getActualInvest()) .set(ProjectPlanRecord::getReportStatus, 0) .update(); // 鏂板涓�鏉″鏍歌褰� - ProjectPlanExamineRecord item = new ProjectPlanExamineRecord(); - item.setProjectPlanRecordId(request.getProjectPlanRecordId()); - item.setEventType(0); // 璁″垝涓婃姤 - list.stream().forEach(i -> { + for (ProjectPlanInfo i : list){ + ProjectPlanExamineRecord item = new ProjectPlanExamineRecord(); + item.setProjectPlanRecordId(form.getProjectPlanRecordId()); + item.setEventType(0); // 璁″垝涓婃姤 item.setProjectPlanInfoId(i.getId()); projectPlanExamineRecordMapper.insert(item); - }); + } return Result.ok("娣诲姞鎴愬姛"); } @Override - public Result savePlanInfo(ProjectPlanInfo item, Integer planRecordId) { - item.setProjectPlanRecordId(planRecordId.longValue()); // 椤圭洰璁″垝璁板綍id - item.setProgressStatus(0); // 鏈紑濮� - item.setDeleted(0); // 鏈垹闄� - item.setPlanStatus(0); // 鏈鏍� + public Result savePlanInfo(ProjectPlanInfoForm form, Long planRecordId) { + ProjectPlanInfo entity = new ProjectPlanInfo(); + BeanUtils.copyProperties(form, entity); + entity.setProjectPlanRecordId(planRecordId); // 椤圭洰璁″垝璁板綍id + entity.setProgressStatus(0); // 鏈紑濮� + entity.setPlanStatus(0); // 鏈鏍� // 鍒ゆ柇id鏄惁瀛樺湪锛屽瓨鍦ㄥ垯鏇存柊锛屼笉瀛樺湪鍒欐柊澧� - if (item.getId() == null) { - baseMapper.insert(item); + if (entity.getId() == null) { + baseMapper.insert(entity); } else { - new LambdaUpdateChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getId, item.getId()) - .set(ProjectPlanInfo::getTitle, item.getTitle()) - .set(ProjectPlanInfo::getStartTime, item.getStartTime()) - .set(ProjectPlanInfo::getEndTime, item.getEndTime()) + new LambdaUpdateChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getId, entity.getId()) + .set(ProjectPlanInfo::getTitle, entity.getTitle()) + .set(ProjectPlanInfo::getStartTime, entity.getStartTime()) + .set(ProjectPlanInfo::getEndTime, entity.getEndTime()) .update(); } return Result.ok("淇濆瓨鎴愬姛"); @@ -211,14 +207,6 @@ .orderByDesc(ProjectPlanExamineRecord::getGmtCreate) .last("LIMIT 1") .one(); - // 鏂板涓�鏉″鏍歌褰� -// item.setId(null); -// item.setEventType(1); -// item.setDelayStartTime(request.getStartTime()); -// item.setDelayEndTime(request.getEndTime()); -// item.setGmtCreate(null); -// item.setGmtUpdate(null); -// projectPlanExamineRecordMapper.insertOne(item); // 鏇存柊鍘熸潵鐨勫鏍歌褰� item.setEventType(1); item.setDelayStartTime(request.getStartTime()); @@ -228,6 +216,7 @@ } @Override + @Transactional(rollbackFor = Exception.class) public Result resubmitPlanInfo(ProjectPlanInfoForm form) { // 鏇存柊閲嶆柊涓婃姤鍚庣殑鍐呭 new LambdaUpdateChainWrapper<>(baseMapper) @@ -240,11 +229,10 @@ // 鏂板涓�鏉¤鍒掍笂鎶ョ殑瀹℃牳璁板綍 ProjectPlanExamineRecord item = new ProjectPlanExamineRecord(); - item.setProjectPlanRecordId(form.getProjectPlanRecordId().longValue()); - item.setProjectPlanInfoId(form.getId().longValue()); + item.setProjectPlanRecordId(form.getProjectPlanRecordId()); + item.setProjectPlanInfoId(form.getId()); item.setEventType(0); // 璁″垝涓婃姤 item.setGmtCreate(new Date()); - item.setDeleted(0); // 鏈垹闄� projectPlanExamineRecordMapper.insert(item); return Result.ok("閲嶆柊涓婃姤鎴愬姛"); } -- Gitblit v1.8.0