| | |
| | | package com.hx.phip.deduction.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.hx.common.BaseController; |
| | | import com.hx.phiappt.common.DeductionSingleConstants; |
| | | import com.hx.phiappt.model.BaseEntity; |
| | |
| | | |
| | | /** |
| | | * 执行划扣控制器 |
| | | * |
| | | * @USER: Andru |
| | | * @DATE: 2021/12/10 |
| | | */ |
| | |
| | | private ComparePhotoRecordPicturesService comparePhotoRecordPicturesService; |
| | | |
| | | /** |
| | | *查看记录 |
| | | * 查看记录 |
| | | */ |
| | | @RequestMapping(value = "/see") |
| | | public Result seeData(HttpServletRequest request,String deductionSingleId){ |
| | | public Result seeData(HttpServletRequest request, String deductionSingleId) { |
| | | // 获取用户信息 |
| | | ThirtApplication thirtApplication= (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if(thirtApplication == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); |
| | | ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if (thirtApplication == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "登入失败,请登入后在试!"); |
| | | } |
| | | |
| | | Map<String,Object> mapData = new HashMap<>(); |
| | | Map<String, Object> mapData = new HashMap<>(); |
| | | DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId); |
| | | if(deductionSingle != null) { |
| | | if (deductionSingle != null) { |
| | | // 划扣记录 |
| | | mapData.put("deductionSingle", deductionSingle); |
| | | // 项目划扣 |
| | | DeductionProject deductionProject = deductionProjectService.selectOneByDeductionSingleId(deductionSingle.getId()); |
| | | mapData.put("deductionProject", deductionProject); |
| | | if(deductionProject != null) { |
| | | if (deductionProject != null) { |
| | | // 参与人员信息 |
| | | List<DeductionJoin> deductionJoinList = deductionJoinService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); |
| | | mapData.put("deductionJoinList", deductionJoinList); |
| | |
| | | mapData.put("deductionSignList", deductionSignList); |
| | | // 治疗图片 |
| | | ComparePhotoRecord comparePhotoRecord = comparePhotoRecordService.selectOneByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); |
| | | if(comparePhotoRecord != null) { |
| | | if (comparePhotoRecord != null) { |
| | | List<ComparePhotoRecordPictures> comparePhotoRecordPicturesList = comparePhotoRecordPicturesService.selectListByComparePhotoRecordId(comparePhotoRecord.getId()); |
| | | mapData.put("comparePhotoRecordPicturesList", comparePhotoRecordPicturesList); |
| | | }else{ |
| | | } else { |
| | | mapData.put("comparePhotoRecordPicturesList", null); |
| | | } |
| | | } |
| | |
| | | // 校验参数 |
| | | checkParam(deductionDto); |
| | | // 获取用户信息 |
| | | ThirtApplication thirtApplication= (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if(thirtApplication == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); |
| | | ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if (thirtApplication == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "登入失败,请登入后在试!"); |
| | | } |
| | | // 填充接口登入信息 |
| | | deductionDto.setSourceCode(thirtApplication.getAppId()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 批量新增划扣记录 |
| | | */ |
| | | @RequestMapping(value = "/batch/add", method = RequestMethod.POST) |
| | | public Result batchAddData(HttpServletRequest request, String userProjectIds, DeductionDto deductionDto) { |
| | | // 获取用户信息 |
| | | ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if (thirtApplication == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "登入失败,请登入后在试!"); |
| | | } |
| | | // 填充接口登入信息 |
| | | deductionDto.setSourceCode(thirtApplication.getAppId()); |
| | | deductionDto.setSourceName(thirtApplication.getName()); |
| | | |
| | | // 解析批量id |
| | | List<String> userProjectIdList = JSONArray.parseArray(userProjectIds, String.class); |
| | | |
| | | // 判断是否传值 |
| | | if(userProjectIdList == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户项目id列表不能为空!"); |
| | | } |
| | | |
| | | // 批量划扣 |
| | | for (String userProjectId : userProjectIdList) { |
| | | deductionDto.setUserProjectId(userProjectId); |
| | | // 添加数据 |
| | | deductionSingleService.editInfo(deductionDto, BaseEntity.YES); |
| | | } |
| | | return Result.success(); |
| | | } |
| | | |
| | | /** |
| | | * 修改划扣记录 |
| | | */ |
| | | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| | | public Result updateData(HttpServletRequest request, DeductionDto deductionDto) { |
| | | // 判断deductionSingleId 是否为空 |
| | | if(StringUtils.isEmpty(deductionDto.getDeductionSingleId())){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"deductionSingleId不能为空"); |
| | | if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); |
| | | } |
| | | // 校验参数 |
| | | checkParam(deductionDto); |
| | | // 获取用户信息 |
| | | ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if(thirtApplication == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); |
| | | if (thirtApplication == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "登入失败,请登入后在试!"); |
| | | } |
| | | // 填充接口登入信息 |
| | | deductionDto.setSourceCode(thirtApplication.getAppId()); |
| | |
| | | * 删除记录 |
| | | */ |
| | | @RequestMapping(value = "/delete", method = RequestMethod.POST) |
| | | public Result deleteData(HttpServletRequest request,String deductionSingleId){ |
| | | if(StringUtils.isEmpty(deductionSingleId)){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"deductionSingleId不能为空"); |
| | | public Result deleteData(HttpServletRequest request, String deductionSingleId) { |
| | | if (StringUtils.isEmpty(deductionSingleId)) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); |
| | | } |
| | | |
| | | ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if(thirtApplication == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); |
| | | if (thirtApplication == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "登入失败,请登入后在试!"); |
| | | } |
| | | |
| | | // 删除数据 |
| | | deductionSingleService.deleteOne(deductionSingleId,thirtApplication.getAppId(),thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL); |
| | | deductionSingleService.deleteOne(deductionSingleId, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | * 撤销记录 |
| | | */ |
| | | @RequestMapping(value = "/rescinded", method = RequestMethod.POST) |
| | | public Result rescindedData(HttpServletRequest request,String deductionSingleId){ |
| | | if(StringUtils.isEmpty(deductionSingleId)){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"deductionSingleId不能为空"); |
| | | public Result rescindedData(HttpServletRequest request, String deductionSingleId) { |
| | | if (StringUtils.isEmpty(deductionSingleId)) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); |
| | | } |
| | | |
| | | ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); |
| | | if(thirtApplication == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); |
| | | if (thirtApplication == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "登入失败,请登入后在试!"); |
| | | } |
| | | |
| | | // 删除数据 |
| | | deductionSingleService.deleteOne(deductionSingleId,thirtApplication.getAppId(),thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED); |
| | | deductionSingleService.deleteOne(deductionSingleId, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED); |
| | | return Result.success(); |
| | | } |
| | | |
| | | /** |
| | | * 校验参数 |
| | | * |
| | | * @param deductionDto 参数对象 |
| | | */ |
| | | private void checkParam(DeductionDto deductionDto){ |
| | | if(StringUtils.isEmpty(deductionDto.getUserProjectId())){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"userProjectId不能为空"); |
| | | private void checkParam(DeductionDto deductionDto) { |
| | | if (StringUtils.isEmpty(deductionDto.getUserProjectId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空"); |
| | | } |
| | | |
| | | if(deductionDto.getDeductionNum() <= 0){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"数量/划扣次数需要大于0"); |
| | | if (deductionDto.getDeductionNum() <= 0) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "数量/划扣次数需要大于0"); |
| | | } |
| | | |
| | | if(deductionDto.getExecuteStartTime() == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"执行开始时间不内为空!"); |
| | | if (deductionDto.getExecuteStartTime() == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "执行开始时间不内为空!"); |
| | | } |
| | | |
| | | if(deductionDto.getExecuteEndTime() == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"执行结束时间不内为空!"); |
| | | if (deductionDto.getExecuteEndTime() == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "执行结束时间不内为空!"); |
| | | } |
| | | } |
| | | } |