代码:用车申请-列表查询


/*我的用车申请列表查询接口*/
@RequestMapping(value = "/apply/myList", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public BaseResp applyList(@RequestBody VehUseApplyInfoListReq bizReq, HttpServletRequest request){
    //时间格式为yyyy-MM-dd HH:mm ,查询时需要填充到最大秒
    if(bizReq.getPlanEndTime() != null)//用车计划结束时间
        bizReq.setPlanEndTime(DateUtils.setSeconds(bizReq.getPlanEndTime(),59));
    return new AbstractRequestExecutor("查询我的用车申请列表接口", "myVehUseApplyList"){
        protected ListResp queryList(BaseEntity bizReq, HttpServletRequest request) throws Exception{
            return vehUseApplyService.queryApplyInfoList((VehUseApplyInfoListReq) bizReq);
        }
    }.executeQueryList(bizReq, request, true);
}


PagerListResp queryApplyInfoList(VehUseApplyInfoListReq req) throws Exception;


@Override
public PagerListResp queryApplyInfoList(VehUseApplyInfoListReq req) throws Exception{
    //申请人编号
    req.setCreateUserId(Common.getLoginAppUserId());
    
    long totalCount = vehUseApplyInfoDao.queryApplyInfoTotalCount(req);
    PagerListResp resp = new PagerListResp(totalCount, req.getStartRow(), req.getMaxSize());
    List<VehUseApplyInfoListResp> useApplyInfos = Collections.emptyList();
    if(totalCount > 0){
        useApplyInfos = vehUseApplyInfoDao.queryApplyInfoList(req);
        DictionaryUtil.translate(useApplyInfos);
    }
    resp.setList(useApplyInfos);
    return resp;
}


long queryApplyInfoTotalCount(VehUseApplyInfoListReq req) throws Exception;

List<VehUseApplyInfoListResp> queryApplyInfoList(VehUseApplyInfoListReq req) throws Exception;


@Override
public long queryApplyInfoTotalCount(VehUseApplyInfoListReq req) throws Exception {
    HibernateParams hParams = new HibernateParams();
    hParams.addSqlStrBuffer("SELECT COUNT(*) ");
    generateCondition(req, hParams);
    return findCountBySql(hParams.getSqlStr(), hParams.getParamObj());
}


@Override
public List<VehUseApplyInfoListResp> queryApplyInfoList(VehUseApplyInfoListReq req) throws Exception {
	HibernateParams hParams = new HibernateParams();
	hParams.addSqlStrBuffer("SELECT apply_id,veh_user_id,veh_user_name,dest_addr as dest_address,'SDL_RUNTIME.view.myCarApplyManage.myCarApplySP.MainLeaderSpWin' flowNodeKey ");
	hParams.addSqlStrBuffer(",veh_use_org_dept_name,apply_status,decode(apply_status,5,0,9,1,11,1) as processStatus");
	hParams.addSqlStrBuffer(",veh_use_type,host_veh_type,veh_use_range,veh_use_plan_num,dispatch_status,dispatch_lock_status");
	hParams.addSqlStrBuffer(",begin_use_time,end_use_time,veh_use_reason as applyReason");
	hParams.addSqlStrBuffer(",flow_inst_id,flow_execution_Id,flow_key");
	hParams.addSqlStrBuffer(",create_time as applyTime");
	hParams.addSqlStrBuffer(",create_user_id as applyUserId");
	hParams.addSqlStrBuffer(",create_user_name as applyUser");
	hParams.addSqlStrBuffer(",create_org_dept_name as applyUserOrgDeptName");
	generateCondition(req, hParams);
	hParams.addSqlStrBuffer(" ORDER BY create_time desc");
	return findBySql(hParams, req.getStartRow().intValue(), req.getMaxSize().intValue(), VehUseApplyInfoListResp.class);
}


private void generateCondition(VehUseApplyInfoListReq req,HibernateParams hParams) throws Exception{
    OrgDeptSearchFilter helper = new OrgDeptSearchFilter();
    hParams.addSqlStrBuffer(" FROM VD_VEH_USE_APPLY_INFO t ");
    StringBuilder condition = new StringBuilder();
    
    if(Util.isNotEmpty(req.getCreateUserId())) 
        addEqualCondition(condition, hParams, "create_user_id", req.getCreateUserId());
    //只返回正常用车申请,不包括紧急调度
    addEqualCondition(condition, hParams, "apply_list_type", Constant.VehUseApplyType.NORMAL);
    if(!ArrayUtils.isEmpty(req.getApplyStatus())){//申请状态
        if (req.getApplyStatus().length == 1){
            condition.append(" and apply_Status=? ");
            hParams.addParamObj(req.getApplyStatus()[0]);
        }else{
            condition.append(" and apply_Status in (").append(whereIn(req.getApplyStatus(), hParams)).append(") ");
        }
    }
    
    addEqualCondition(condition, hParams, "dispatch_status", req.getDispatchStatus());
    addEqualCondition(condition, hParams, "veh_Use_Type", req.getVehUseType());
    addEqualCondition(condition, hParams, "host_veh_type", req.getHostVehType());
    addEqualCondition(condition, hParams, "veh_Use_Range", req.getVehUseRange());
    
    if(isNotEmpty(req.getApplyId()))//申请单编号
        addCondition(condition, hParams, "apply_id like ? ", likeValue(req.getApplyId().trim()));
    if(isNotEmpty(req.getVehUserName()))//用车人姓名
        addCondition(condition, hParams, "veh_User_Name like ? ", likeValue(req.getVehUserName().trim()));

    if(req.getPlanBeginTime() != null && req.getPlanEndTime() == null) {
        addCondition(condition,hParams,"begin_use_time < ? ", req.getPlanBeginTime());
        addCondition(condition,hParams,"end_use_time > ? ", req.getPlanBeginTime());
    }else if(req.getPlanBeginTime() == null && req.getPlanEndTime() != null) {
        addCondition(condition,hParams,"begin_use_time < ? ", req.getPlanEndTime());
        addCondition(condition,hParams,"end_use_time > ? ", req.getPlanEndTime());
    }else if(req.getPlanBeginTime() != null && req.getPlanEndTime() != null) {//首尾时间有交集或包含关系
        condition.append(" and (begin_use_time <= ? and end_use_time>=?)");
        hParams.addParamObj(req.getPlanEndTime());
        hParams.addParamObj(req.getPlanBeginTime());
    }
    
    if(req.getApplyBeginTime()!=null) {
        addCondition(condition,hParams,"create_time >= ? ", req.getApplyBeginTime());
    }
    
    if(req.getApplyEndTime()!=null) {
        addCondition(condition,hParams,"create_time <= ? ", req.getApplyEndTime());
    }
    
    if(req.getVehUseOrgId() != null && req.getVehUseDeptId() != null) {
        condition.append(" and(veh_use_org_id,veh_use_dept_id) in(");
        condition.append(helper.getMyViewSubDeptSql(req.getVehUseOrgId(),req.getVehUseDeptId(),hParams));
        condition.append(")");
    }
    
    if(Util.isNotEmpty(req.getCreateOrgId()) && Util.isNotEmpty(req.getCreateDeptId())) {
        condition.append(" and(create_org_id,create_dept_id) in(");
        condition.append(helper.getMyViewSubDeptSql(req.getCreateOrgId(),req.getCreateDeptId(),hParams));
        condition.append(")");
    }
    
    if(Util.isNotEmpty(req.getQueryCreateTimeBegin())) addCondition(condition, hParams, "create_time >= ?", req.getQueryCreateTimeBegin());
    if(Util.isNotEmpty(req.getQueryCreateTimeEnd())) addCondition(condition, hParams, "create_time <= ?", req.getQueryCreateTimeEnd());
    
    hParams.addSqlStrBuffer(condition.toString().replaceFirst(" and ", " where "));
}


SELECT COUNT(*)
  FROM VD_VEH_USE_APPLY_INFO t
 where create_user_id = ?
   and apply_list_type = ?

SELECT apply_id,
       veh_user_id,
       veh_user_name,
       dest_addr as dest_address,
       'SDL_RUNTIME.view.myCarApplyManage.myCarApplySP.MainLeaderSpWin' flowNodeKey,
       veh_use_org_dept_name,
       apply_status,
       decode(apply_status, 5, 0, 9, 1, 11, 1) as processStatus,
       veh_use_type,
       host_veh_type,
       veh_use_range,
       veh_use_plan_num,
       dispatch_status,
       dispatch_lock_status,
       begin_use_time,
       end_use_time,
       veh_use_reason as applyReason,
       flow_inst_id,
       flow_execution_Id,
       flow_key,
       create_time as applyTime,
       create_user_id as applyUserId,
       create_user_name as applyUser,
       create_org_dept_name as applyUserOrgDeptName
  FROM VD_VEH_USE_APPLY_INFO t
 where create_user_id = 1
   and apply_list_type = 1
 ORDER BY create_time desc


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZHOU_VIP

您的鼓励将是我创作最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值