package com.product.administration.controller; import com.product.administration.config.CmnConst; import com.product.administration.config.SystemCode; import com.product.administration.service.CarApplicationService; import com.product.administration.service.ide.ICarApplicationService; import com.product.administration.service.ide.IQuestionnaireService; import com.product.common.lang.StringUtils; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.entity.RequestParameterEntity; import com.product.core.exception.BaseException; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.module.sys.version.ApiVersion; 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 javax.servlet.http.HttpServletRequest; /** * Copyright LX * @Title: CarApplicationController * @Project: product-server * @date: 2021-05-06 9:20 * @author: ZhouJie * @Description: 用车申请 */ @RequestMapping("/api/applications") @RestController public class CarApplicationController extends AbstractBaseController { @Autowired public CarApplicationService carApplicationService; /** * @description: 保存用车申请 * @author: ZhouJie * @date: 2021-05-06 11:02 */ @RequestMapping(value = "/save-application/{version}", method = RequestMethod.POST) public String saveCarApplication(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse=null; Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if(bean != null){ RequestParameterEntity reqp=(RequestParameterEntity)bean; fse = reqp.getFormData(); } //判断参数是否为空 if(bean == null || fse == null) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_CAR_APPLICATION.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } ICarApplicationService service = (ICarApplicationService) getProxyInstance(carApplicationService); String uuid = service.saveCarApplication(fse); if (!StringUtils.isEmpty(uuid)) { return OK_Add(uuid); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_SAVE_CAR_APPLICATION_FAIL.getValue(), SystemCode.SYSTEM_SAVE_CAR_APPLICATION_FAIL.getText()); return error(SystemCode.SYSTEM_SAVE_CAR_APPLICATION_FAIL.getValue(), SystemCode.SYSTEM_SAVE_CAR_APPLICATION_FAIL.getText()); }catch(BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_SAVE_CAR_APPLICATION_FAIL.getValue(), SystemCode.SYSTEM_SAVE_CAR_APPLICATION_FAIL.getText()); } } /** * @description: 删除用车申请 * @author: ZhouJie * @date: 2021-05-06 11:02 */ @RequestMapping(value = "/delete-application/{version}", method = RequestMethod.POST) @ApiVersion(1) public String deleteCarApplication(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse=null; Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if(bean != null) { RequestParameterEntity reqp=(RequestParameterEntity)bean; fse = reqp.getFormData(); } //判断参数是否为空 if(bean == null || fse == null) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_CAR_APPLICATION.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } ICarApplicationService service = (ICarApplicationService) getProxyInstance(carApplicationService); boolean success=service.deleteCarApplication(fse); if(success) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DELETE_CAR_APPLICATION_FAIL.getValue(),SystemCode.SYSTEM_DELETE_CAR_APPLICATION_FAIL.getText()); return error(SystemCode.SYSTEM_DELETE_CAR_APPLICATION_FAIL.getValue(),SystemCode.SYSTEM_DELETE_CAR_APPLICATION_FAIL.getText()); }catch(BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_DELETE_CAR_APPLICATION_FAIL.getValue(),SystemCode.SYSTEM_DELETE_CAR_APPLICATION_FAIL.getText()); } } /** * @description: 用车申请列表获取 * @author: ZhouJie * @date: 2021-05-06 14:02 */ @RequestMapping(value = "/list-application/{version}", method = RequestMethod.POST) public String CarApplicationList(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (bean == null || fse == null) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (!CmnConst.PRODUCT_OA_CAR_APPLICATION.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断分页参数 if (fse.getString(CmnConst.PAGESIZE) == null || fse.getString(CmnConst.CPAGE) == null) { return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(), SystemCode.SYSTEM_CPAGES_NOT_NULL.getText()); } DataTableEntity dt = carApplicationService.CarApplicationlist(fse); return OK_List(dt); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_GET_CAR_APPLICATION_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_CAR_APPLICATION_LIST_FAIL.getText()); } } /** * @description: 用车申请详情查看 * @author: ZhouJie * @date: 2021-05-06 15:03 */ @RequestMapping(value = "/info-application/{version}", method = RequestMethod.POST) @ApiVersion(1) public String CarApplicationInfo(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (bean == null || fse == null) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (!CmnConst.PRODUCT_OA_CAR_APPLICATION.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } FieldSetEntity fs = carApplicationService.CarApplicationInfo(fse); return OK_List(fs); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_GET_CAR_APPLICATION_INFO_FAIL.getValue(), SystemCode.SYSTEM_GET_CAR_APPLICATION_INFO_FAIL.getText()); } } /** * @description: 用车申请送办 * @author: ZhouJie * @date: 2021-06-03 15:32 */ @RequestMapping(value = "/sendapply/{version}", method = RequestMethod.POST) public String senCarApplication(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse=null; Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if(bean != null){ RequestParameterEntity reqp=(RequestParameterEntity)bean; fse = reqp.getFormData(); } //判断参数是否为空 if(bean == null || fse == null) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_CAR_APPLICATION.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } ICarApplicationService service = (ICarApplicationService) getProxyInstance(carApplicationService); boolean succ = service.senCarApplication(fse.getUUID()); if (succ) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_SEND_CAR_APPLICATION_FAIL.getValue(), SystemCode.SYSTEM_SEND_CAR_APPLICATION_FAIL.getText()); return error(SystemCode.SYSTEM_SEND_CAR_APPLICATION_FAIL.getValue(), SystemCode.SYSTEM_SEND_CAR_APPLICATION_FAIL.getText()); }catch(BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_SEND_CAR_APPLICATION_FAIL.getValue(), SystemCode.SYSTEM_SEND_CAR_APPLICATION_FAIL.getText()); } } }