package com.hx.phip.deduction.controller;
|
|
import com.hx.common.BaseController;
|
import com.hx.phiappt.common.DeductionSingleConstants;
|
import com.hx.phiappt.model.BaseEntity;
|
import com.hx.phiappt.model.ComparePhotoRecord;
|
import com.hx.phiappt.model.ComparePhotoRecordPictures;
|
import com.hx.phiappt.model.deduction.*;
|
import com.hx.phip.deduction.service.*;
|
import com.hx.phip.dto.DeductionDto;
|
import com.hx.phip.service.ComparePhotoRecordPicturesService;
|
import com.hx.phip.service.ComparePhotoRecordService;
|
import com.hx.resultTool.Result;
|
import com.hx.util.StringUtils;
|
import com.platform.constants.LoginConstant;
|
import com.platform.entity.ThirtApplication;
|
import com.platform.exception.PlatTipsException;
|
import com.platform.resultTool.PlatformCode;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 执行划扣控制器
|
* @USER: Andru
|
* @DATE: 2021/12/10
|
*/
|
@RestController
|
@RequestMapping("/deduction")
|
public class DeductionController extends BaseController {
|
|
@Resource
|
private DeductionSingleService deductionSingleService;
|
@Resource
|
private DeductionProjectService deductionProjectService;
|
@Resource
|
private DeductionJoinService deductionJoinService;
|
@Resource
|
private DeductionSignService deductionSignService;
|
@Resource
|
private DeductionDrugsService deductionDrugsService;
|
@Resource
|
private DeductionDeviceParameterService deductionDeviceParameterService;
|
@Resource
|
private ComparePhotoRecordService comparePhotoRecordService;
|
@Resource
|
private ComparePhotoRecordPicturesService comparePhotoRecordPicturesService;
|
|
/**
|
*查看记录
|
*/
|
@RequestMapping(value = "/see")
|
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,"登入失败,请登入后在试!");
|
}
|
|
Map<String,Object> mapData = new HashMap<>();
|
DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId);
|
if(deductionSingle != null) {
|
// 划扣记录
|
mapData.put("deductionSingle", deductionSingle);
|
// 项目划扣
|
DeductionProject deductionProject = deductionProjectService.selectOneByDeductionSingleId(deductionSingle.getId());
|
mapData.put("deductionProject", deductionProject);
|
if(deductionProject != null) {
|
// 参与人员信息
|
List<DeductionJoin> deductionJoinList = deductionJoinService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
|
mapData.put("deductionJoinList", deductionJoinList);
|
// 消耗物品信息
|
List<DeductionDrugs> deductionDrugsList = deductionDrugsService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
|
mapData.put("deductionDrugsList", deductionDrugsList);
|
// 治疗参数(设备)信息
|
List<DeductionDeviceParameter> deductionDeviceParameterList = deductionDeviceParameterService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
|
mapData.put("deductionDeviceParameterList", deductionDeviceParameterList);
|
// 客户签名信息
|
List<DeductionSign> deductionSignList = deductionSignService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
|
mapData.put("deductionSignList", deductionSignList);
|
// 治疗图片
|
ComparePhotoRecord comparePhotoRecord = comparePhotoRecordService.selectOneByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
|
if(comparePhotoRecord != null) {
|
List<ComparePhotoRecordPictures> comparePhotoRecordPicturesList = comparePhotoRecordPicturesService.selectListByComparePhotoRecordId(comparePhotoRecord.getId());
|
mapData.put("comparePhotoRecordPicturesList", comparePhotoRecordPicturesList);
|
}else{
|
mapData.put("comparePhotoRecordPicturesList", null);
|
}
|
}
|
}
|
return Result.success(mapData);
|
}
|
|
/**
|
* 新增划扣记录
|
*/
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
public Result addData(HttpServletRequest request, DeductionDto deductionDto) {
|
// 校验参数
|
checkParam(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());
|
|
// 添加数据
|
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不能为空");
|
}
|
// 校验参数
|
checkParam(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());
|
|
// 添加数据
|
deductionSingleService.editInfo(deductionDto, BaseEntity.NO);
|
|
return Result.success();
|
}
|
|
/**
|
* 删除记录
|
*/
|
@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不能为空");
|
}
|
|
ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
|
if(thirtApplication == null){
|
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!");
|
}
|
|
// 删除数据
|
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不能为空");
|
}
|
|
ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
|
if(thirtApplication == null){
|
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!");
|
}
|
|
// 删除数据
|
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不能为空");
|
}
|
|
if(deductionDto.getDeductionNum() <= 0){
|
throw new PlatTipsException(PlatformCode.ERROR_TIPS,"数量/划扣次数需要大于0");
|
}
|
|
if(deductionDto.getExecuteStartTime() == null){
|
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"执行开始时间不内为空!");
|
}
|
|
if(deductionDto.getExecuteEndTime() == null){
|
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"执行结束时间不内为空!");
|
}
|
}
|
}
|