| | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrProject; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrIntake; |
| | | import com.dy.pipIrrGlobal.voIr.VoProject; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectOne; |
| | | import com.dy.pipIrrGlobal.voPr.VoIntake; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectSimple; |
| | | import com.dy.pipIrrGlobal.voSe.VoActiveCard; |
| | | import com.dy.pipIrrIrrigate.project.dto.irrigateProject; |
| | | import com.dy.pipIrrIrrigate.result.IrrigateResultCode; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private final ProjectSv projectSv; |
| | | |
| | | /** |
| | | * 添加项目 |
| | | * |
| | | * 添加项目,旧版本,原则上废弃 |
| | | * @param po 项目实体对象 |
| | | * @param bindingResult |
| | | * @return 添加是否成功 |
| | |
| | | log.error("添加项目异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | | /** |
| | | * 添加项目,新版本,使用这个 |
| | | * @param po 项目实体对象 |
| | | * @param bindingResult |
| | | * @return 添加是否成功 |
| | | */ |
| | | @PostMapping(path = "addIrrigateProject", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> addIrrigateProject(@RequestBody @Valid irrigateProject po, BindingResult bindingResult) { |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | String projectName = po.getProjectName(); |
| | | String irrigateGroups = po.getIrrigateGroups(); |
| | | Long operatorId = po.getOperatorId(); |
| | | |
| | | IrProject irProject = new IrProject(); |
| | | irProject.setProjectName(projectName); |
| | | irProject.setProjectState((byte)1); |
| | | irProject.setOperator(operatorId); |
| | | irProject.setOperateTime(new Date()); |
| | | irProject.setDeleted((byte)0); |
| | | Long projectId = projectSv.addIrrigateProject(irProject); |
| | | if(projectId == null) { |
| | | return BaseResponseUtils.buildErrorMsg("创建灌溉项目失败"); |
| | | } |
| | | |
| | | //String[] irrigateGroupArr = irrigateGroups.split(","); |
| | | //for(Long irrigateGroupId : irrigateGroupArr) { |
| | | // |
| | | //} |
| | | |
| | | |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | |
| | | @SsoAop() |
| | | public BaseResponse<VoProjectOne> one(@RequestParam Long id) { |
| | | VoProjectOne irProject = this.projectSv.selectById(id); |
| | | if (irProject == null) { |
| | | return BaseResponseUtils.buildFail(IrrigateResultCode.NO_PROJECT.getMessage()); |
| | | } else { |
| | | |
| | | return BaseResponseUtils.buildSuccess(irProject); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * 分页查询,旧版本,原则上废弃 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | |
| | | }) |
| | | @GetMapping(path = "some") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoProject>>> getIntakes(QueryVo vo) { |
| | | public BaseResponse<QueryResultVo<List<VoProject>>> getProjects(QueryVo vo) { |
| | | try { |
| | | QueryResultVo<List<VoProject>> res = projectSv.getProjects(vo); |
| | | if (res == null) { |
| | | return BaseResponseUtils.buildFail(IrrigateResultCode.NO_PROJECT.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取项目记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分页查询项目,新版本,目前使用 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getSimpleProjects") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoProjectSimple>>> getSimpleProjects(QueryVo qo) { |
| | | try { |
| | | QueryResultVo<List<VoProjectSimple>> res = projectSv.getSimpleProjects(qo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取项目记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |