| | |
| | | import java.sql.Timestamp; |
| | | |
| | | |
| | | |
| | | import com.gkhy.safePlatform.targetDuty.utils.DateUtils; |
| | | 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.TargetDutyfileInfo; |
| | | 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.TargetDutyfileInfoQueryCriteria; |
| | | 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; |
| | |
| | | @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)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增或者修改数据 |
| | |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | 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)); |
| | | } |
| | | } |
| | | } |