From 759bbb8ee99665382a689fa90277a9b2279238da Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期五, 19 八月 2022 19:04:02 +0800 Subject: [PATCH] Merge branches 'genchuang' and 'master' of https://sinanoaq.cn:8888/r/safePlatform-out into master --- goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetExamineController.java | 184 +++++++++++++++++++++++---------------------- 1 files changed, 95 insertions(+), 89 deletions(-) diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetExamineController.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetExamineController.java index 4088452..768aebe 100644 --- a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetExamineController.java +++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetExamineController.java @@ -1,37 +1,23 @@ package com.gkhy.safePlatform.targetDuty.controller; -import java.util.*; -import java.sql.Timestamp; - - -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; -import com.gkhy.safePlatform.targetDuty.entity.ExamineItem; -import com.gkhy.safePlatform.targetDuty.entity.TargetExamine; -import com.gkhy.safePlatform.targetDuty.entity.TargetMng; -import com.gkhy.safePlatform.targetDuty.model.dto.req.ExamineTemplateSaveOrUpdate; -import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetExamineSaveOrUpdate; -import com.gkhy.safePlatform.targetDuty.model.dto.resp.ExamineTemplateDto; -import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetExamineDivideDto; -import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetExamineDto; -import com.gkhy.safePlatform.targetDuty.service.CommonService; -import com.gkhy.safePlatform.targetDuty.service.TargetExamineService; -import com.gkhy.safePlatform.targetDuty.service.TargetMngService; -import com.google.common.collect.Lists; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; +import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.utils.PageUtils; import com.gkhy.safePlatform.commons.vo.ResultVO; -import com.gkhy.safePlatform.commons.enums.ResultCodes; +import com.gkhy.safePlatform.targetDuty.entity.TargetExamine; import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetExamineQueryCriteria; +import com.gkhy.safePlatform.targetDuty.service.CommonService; +import com.gkhy.safePlatform.targetDuty.service.TargetExamineService; +import com.gkhy.safePlatform.targetDuty.service.TargetMngService; +import org.springframework.web.bind.annotation.*; -import java.util.stream.Collectors; import javax.annotation.Resource; import java.io.Serializable; +import java.sql.Timestamp; +import java.util.Arrays; +import java.util.Date; +import java.util.List; /** * (TargetExamine)表控制层 @@ -53,49 +39,75 @@ @Resource private CommonService commonService; +// /** +// * 通过主键查询单条数据 +// * +// * @param targetId 主键 +// * @return 单条数据 +// */ +// @GetMapping(value = "/selectOne/{targetId}") +// public ResultVO selectOne(@PathVariable Long targetId) { +// TargetExamineDto dto = new TargetExamineDto(); +// TargetMng targetMng = targetMngService.getById(targetId); +// if(targetMng == null) { +// return new ResultVO<>(ResultCodes.CLIENT_PROJECT_NOT_EXIST); +// } +// +// TargetExamineQueryCriteria criteria = new TargetExamineQueryCriteria(); +// criteria.setTargetId(targetId); +// +// List<TargetExamineDivideDto> respList = BeanCopyUtils.copyBeanList(this.targetExamineService.queryAll(criteria), TargetExamineDivideDto.class); +// +// +// // --------------------------- 获取部门信息----------------------- +// //收集所用到的部门ID +// Set<Long> collectDepIdSet = new HashSet(); +// respList.forEach(f->{ +// collectDepIdSet.add(f.getDutyDepartmentId()); +// collectDepIdSet.add(f.getMakerDepartmentId()); +// }); +// //获取部门名集合 +// Map<Long,String> depNameMap = commonService.getDepName(collectDepIdSet); +// +// respList.forEach(f->{ +// f.setDutyDepartmentName(depNameMap.get(f.getDutyDepartmentId())); +// f.setMakerDepartmentName(depNameMap.get(f.getMakerDepartmentId())); +// }); +// +// dto.setExamineList(respList); +// dto.setId(targetMng.getId()); +// dto.setIndexNum(targetMng.getIndexNum()); +// dto.setqName(targetMng.getqName()); +// dto.setValue(targetMng.getValue()); +// dto.setYear(targetMng.getYear()); +// return new ResultVO<>(ResultCodes.OK,dto); +// } + + + /** + * 分页查询所有数据 + * + * @param pageQuery 查询实体 + * @return 所有数据 + */ + @PostMapping(value = "/page/list") + public ResultVO selectAll(@RequestBody PageQuery<TargetExamineQueryCriteria> pageQuery){ + PageUtils.checkCheck(pageQuery); + return this.targetExamineService.queryAll(pageQuery); + } + + /** * 通过主键查询单条数据 * - * @param targetId 主键 + * @param id 主键 * @return 单条数据 */ - @GetMapping(value = "/selectOne/{targetId}") - public ResultVO selectOne(@PathVariable Long targetId) { - TargetExamineDto dto = new TargetExamineDto(); - TargetMng targetMng = targetMngService.getById(targetId); - if(targetMng == null) { - return new ResultVO<>(ResultCodes.CLIENT_PROJECT_NOT_EXIST); - } - - TargetExamineQueryCriteria criteria = new TargetExamineQueryCriteria(); - criteria.setTargetId(targetId); - - List<TargetExamineDivideDto> respList = BeanCopyUtils.copyBeanList(this.targetExamineService.queryAll(criteria), TargetExamineDivideDto.class); - - - // --------------------------- 获取部门信息----------------------- - //收集所用到的部门ID - Set<Long> collectDepIdSet = new HashSet(); - respList.forEach(f->{ - collectDepIdSet.add(f.getDutyDepartmentId()); - collectDepIdSet.add(f.getMakerDepartmentId()); - }); - //获取部门名集合 - Map<Long,String> depNameMap = commonService.getDepName(collectDepIdSet); - - respList.forEach(f->{ - f.setDutyDepartmentName(depNameMap.get(f.getDutyDepartmentId())); - f.setMakerDepartmentName(depNameMap.get(f.getMakerDepartmentId())); - }); - - dto.setExamineList(respList); - dto.setId(targetMng.getId()); - dto.setIndexNum(targetMng.getIndexNum()); - dto.setqName(targetMng.getqName()); - dto.setValue(targetMng.getValue()); - dto.setYear(targetMng.getYear()); - return new ResultVO<>(ResultCodes.OK,dto); + @GetMapping(value = "/selectOne/{id}") + public ResultVO selectOne(@PathVariable Serializable id) { + return new ResultVO<>(ResultCodes.OK,this.targetExamineService.getById(id)); } + /** * 新增或者修改数据 @@ -104,17 +116,14 @@ * @return 修改结果 */ @PostMapping(value = "/addOrUpdate") - public ResultVO update(@RequestBody TargetExamineSaveOrUpdate infoDto) { - if(infoDto.getId() == null) { - return new ResultVO<>(ResultCodes.CLIENT_PARAM_ERROR); + public ResultVO update(@RequestBody TargetExamine infoDto) { + infoDto.setExamineDate(new Timestamp(new Date().getTime())); + if (infoDto.getId() == null) { + return new ResultVO<>(ResultCodes.OK,targetExamineService.save(infoDto)); + } else { + targetExamineService.update(infoDto,new UpdateWrapper<TargetExamine>().eq("id",infoDto.getId())); + return new ResultVO<>(ResultCodes.OK); } - TargetMng targetMng = targetMngService.getById(infoDto.getId()); - if(targetMng == null) { - return new ResultVO<>(ResultCodes.CLIENT_PROJECT_NOT_EXIST); - } - - targetExamineService.addOrUpdate(infoDto); - return new ResultVO<>(ResultCodes.OK); } /** @@ -135,23 +144,20 @@ public static void main(String[] args) { - TargetExamineSaveOrUpdate saveOrUpdate = new TargetExamineSaveOrUpdate(); - saveOrUpdate.setDelIds("1,2"); - - - List<TargetExamine> examineList = Lists.newArrayList(); - TargetExamine item = new TargetExamine(); - item.setDutyDepartmentId(12L); - item.setExamineValue("3"); - item.setMakerDepartmentId(4L); - item.setMakeDate(new Timestamp(new java.util.Date().getTime())); - item.setUploadValue("2"); - item.setUploadDate(new Timestamp(new java.util.Date().getTime())); - item.setExamineResult(1); - item.setExaminePersonId(0L); - item.setExamineDate(new Timestamp(new java.util.Date().getTime())); - examineList.add(item); - saveOrUpdate.setExamineList(examineList); - System.out.println(JSONObject.toJSONString(saveOrUpdate)); +// TargetExamineSaveOrUpdate saveOrUpdate = new TargetExamineSaveOrUpdate(); +// saveOrUpdate.setDelIds("1,2"); +// +// +// List<TargetExamine> examineList = Lists.newArrayList(); +// TargetExamine item = new TargetExamine(); +// item.setTargetDivideDetailId(1L); +// item.setUploadValue("2"); +// item.setUploadDate(new Timestamp(new java.util.Date().getTime())); +// item.setExamineResult(1); +// item.setExaminePersonId(0L); +// item.setExamineDate(new Timestamp(new java.util.Date().getTime())); +// examineList.add(item); +// saveOrUpdate.setExamineList(examineList); +// System.out.println(JSONObject.toJSONString(saveOrUpdate)); } } \ No newline at end of file -- Gitblit v1.9.2