package com.product.project.management.controller; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.product.project.management.config.Cmnconst; import com.product.project.management.config.SystemCode; import com.product.project.management.service.ProjectInfoService; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; import com.product.module.sys.version.ApiVersion; import com.product.util.BaseUtil; import com.product.util.ResultInfo; @RequestMapping("/api/qxlw-project") @RestController("qxlw-project-controller") public class ProjectInfoController extends AbstractBaseController { @Autowired ProjectInfoService projectInfoService; /** * 获取项目列表(根据创建人) * * @param request * @return */ @RequestMapping(value = "/list-project-by-created/{version}", method = RequestMethod.POST) @ApiVersion(1) public String listProjectByCreated(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); //判断分页参数是否为空 if (BaseUtil.strIsNull(fse.getString(CoreConst.CPAGE)) || BaseUtil.strIsNull(fse.getString(CoreConst.PAGESIZE))) { return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(), SystemCode.SYSTEM_CPAGES_NOT_NULL.getText()); } return OK_List(projectInfoService.listProjectByCreated(fse.getInteger(Cmnconst.CPAGE), fse.getInteger(Cmnconst.PAGESIZE))); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取模板项目分项 * * @param request * @return */ @RequestMapping(value = "/get-projectTypeItem/{version}", method = RequestMethod.POST) @ApiVersion(1) public String getProjectTypeItem(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); // 判断uuid是否为空 if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECTTYPE))) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } return OK_List(projectInfoService.getProjectTypeItem(fse.getString(Cmnconst.PROJECTTYPE))); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取项目信息(项目分项多个树) * * @param request * @return */ @RequestMapping(value = "/get-projectItem/{version}", method = RequestMethod.POST) @ApiVersion(1) public String getProjectItem(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); // 判断uuid是否为空 if (BaseUtil.strIsNull(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } return OK_List(projectInfoService.getProjectItem(fse.getUUID())); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取项目子表分项(单个树) * * @param request * @return */ @RequestMapping(value = "/get-projectAllItem/{version}", method = RequestMethod.POST) @ApiVersion(1) public String getProjectAllItem(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); // 判断uuid是否为空 if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID))) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } return OK_List(projectInfoService.getProjectAllItem(fse.getString(Cmnconst.PROJECT_UUID))); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取项目信息(无分页参数) * * @param request * @return */ @RequestMapping(value = "/list-project/{version}", method = RequestMethod.POST) @ApiVersion(1) public String listProject(HttpServletRequest request) { try { return OK_List(projectInfoService.listProject()); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 删除单个项目分项验证(根据预算验证是否删除) * * @param request * @return */ @RequestMapping(value = "/del-itemize-valdate/{version}", method = RequestMethod.POST) @ApiVersion(1) public String deleteItemizeValidate(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); //判断uuid是否为空 if (BaseUtil.strIsNull(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } projectInfoService.deleteItemizeValidate(fse.getUUID()); return OK(); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取项目预算信息 * * @param request * @return */ @RequestMapping(value = "/list-itemize-budget/{version}", method = RequestMethod.POST) @ApiVersion(1) public String listItemizeBudget(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); //判断分页参数是否为空 if (BaseUtil.strIsNull(fse.getString(CoreConst.CPAGE)) || BaseUtil.strIsNull(fse.getString(CoreConst.PAGESIZE))) { return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(), SystemCode.SYSTEM_CPAGES_NOT_NULL.getText()); } return OK_List(projectInfoService.listItemizeBudget(fse.getString(Cmnconst.ITEMIZE_UUID), fse.getInteger(CoreConst.CPAGE), fse.getInteger(CoreConst.PAGESIZE))); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取项目分项材料 * * @param request * @return */ @RequestMapping(value = "/list-material-v/{version}", method = RequestMethod.POST) @ApiVersion(1) public String listMaterialV(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); //判断uuid是否为空 if (BaseUtil.strIsNull(fse.getString(Cmnconst.UUID))) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //判断分页参数是否为空 if (BaseUtil.strIsNull(fse.getString(CoreConst.CPAGE)) || BaseUtil.strIsNull(fse.getString(CoreConst.PAGESIZE))) { return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(), SystemCode.SYSTEM_CPAGES_NOT_NULL.getText()); } return OK_List(projectInfoService.listMaterialV(fse.getString(Cmnconst.UUID), fse.getInteger(CoreConst.CPAGE), fse.getInteger(CoreConst.PAGESIZE))); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 获取项目分项材料 * * @param request * @return */ @RequestMapping(value = "/find-inventory_v/{version}", method = RequestMethod.POST) @ApiVersion(1) public String findInventoryV(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); //判断仓库和材料是否为空 if (BaseUtil.strIsNull(fse.getString("warehouse_uuid"))||BaseUtil.strIsNull(fse.getString("material_uuid"))) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } return OK_List(projectInfoService.findInventoryV(fse.getString("warehouse_uuid"), fse.getString("material_uuid"))); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } /** * 根据uuid获取项目分项树结构详情 * * @param request * @return */ @RequestMapping(value = "/get-treeProjectItem/{version}", method = RequestMethod.POST) @ApiVersion(1) public String getTreeProjectItem(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); // 判断uuid是否为空 if (BaseUtil.strIsNull(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } return ResultInfo.success(projectInfoService.getTreeProjectItem(fse.getUUID())); } catch (BaseException e) { e.printStackTrace(); return this.error(e); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); } } }