package cn.ksource.web.facade.bpbj; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Stack; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import cn.ksource.beans.CMDB_CI_CATEGORY; import cn.ksource.beans.GG_RECORD; import cn.ksource.beans.SC_WORKFLOW_RELEASE; import cn.ksource.beans.SPARE_PART; import cn.ksource.beans.SPARE_PART_STORAGE; import cn.ksource.beans.WORKFLOW_BASE; import cn.ksource.beans.WORKFLOW_NODE; import cn.ksource.core.dao.BaseDao; import cn.ksource.core.dao.SqlParameter; import cn.ksource.core.page.PageInfo; import cn.ksource.core.util.AjaxUtil; import cn.ksource.core.util.ConvertUtil; import cn.ksource.core.util.DateUtil; import cn.ksource.core.util.JsonUtil; import cn.ksource.core.util.OrderCodeUtil; import cn.ksource.core.util.StringUtil; import cn.ksource.core.util.TwoDimensionCode; import cn.ksource.core.web.SysInfoMsg; import cn.ksource.core.web.WebUtil; import cn.ksource.core.workflow.NodeDealEntity; import cn.ksource.core.workflow.NodeFinishEntity; import cn.ksource.core.workflow.WorkflowBusinessService; import cn.ksource.core.workflow.WorkflowCoreService; import cn.ksource.web.Constants; import cn.ksource.web.entity.WorkFlowSupportEntity; import cn.ksource.web.service.WorkOrderCodeService; import cn.ksource.web.service.record.RecordService; import cn.ksource.web.service.workFlowSupport.WorkFlowSupportService; @Service("SpareQueryFacade") public class SpareQueryFacadeImpl implements SpareQueryFacade { @Resource private BaseDao baseDao; /** * 备件申请列表信息 * @return */ @Override public List getSpareList() { return baseDao.queryForList(" select * from SPARE_PART_APPLY where STATE=1 "); } /** * 备件申请列表信息 * @param pageInfo * @param params * @return */ @Override public PageInfo getSpareListData(Map params,PageInfo pageInfo){ StringBuilder sql = new StringBuilder(); Map paramMap = new HashMap(); sql.append(" select * from SPARE_PART_APPLY where 1=1 AND STATE>=3 "); String order_code=params.get("order_code"); String order_name=params.get("order_name"); String state=params.get("state"); String start_time=params.get("start_time"); String end_time=params.get("end_time"); String customer_id=params.get("customer_id"); //项目 if (StringUtil.isNotBlank(customer_id)) { sql.append(" and PROJECT_ID=:project_id "); paramMap.put("project_id", customer_id); } //工单编号 if (StringUtil.isNotBlank(order_code)) { sql.append(" and order_code like :order_code "); paramMap.put("order_code","%"+order_code.trim()+"%"); } //工单名称 if (StringUtil.isNotBlank(order_name)) { sql.append(" and order_name like:order_name "); paramMap.put("order_name", "%"+order_name.trim()+"%"); } //工单状态 if (StringUtil.isNotBlank(state)) { sql.append(" and state=:state "); paramMap.put("state", state); } //开始时间 if(StringUtil.isNotBlank(start_time)){ sql.append(" AND gmt_create>=:start_time"); paramMap.put("start_time", start_time+"000000"); } //结束时间 if(StringUtil.isNotBlank(end_time)){ sql.append(" and gmt_create<=:end_time"); paramMap.put("end_time", end_time+"235959"); } sql.append(" order by gmt_create desc "); return baseDao.queryforSplitPageInfo(pageInfo,sql.toString(), paramMap); } /** * 备件申请列表数量信息 * @param pageInfo * @param params * @return */ @Override public int getSpareListCount(Map params) { StringBuilder sql = new StringBuilder(); Map paramMap = new HashMap(); sql.append(" select count(*) from SPARE_PART_APPLY where 1=1 AND STATE>=3"); String order_code=params.get("order_code"); String order_name=params.get("order_name"); String state=params.get("state"); String start_time=params.get("start_time"); String end_time=params.get("end_time"); String customer_id=params.get("customer_id"); //项目 if (StringUtil.isNotBlank(customer_id)) { sql.append(" and PROJECT_ID=:project_id "); paramMap.put("project_id", customer_id); } //工单编号 if (StringUtil.isNotBlank(order_code)) { sql.append(" and order_code like :order_code "); paramMap.put("order_code","%"+order_code.trim()+"%"); } //工单名称 if (StringUtil.isNotBlank(order_name)) { sql.append(" and order_name like:order_name "); paramMap.put("order_name", "%"+order_name.trim()+"%"); } //工单状态 if (StringUtil.isNotBlank(state)) { sql.append(" and state=:state "); paramMap.put("state", state); } //开始时间 if(StringUtil.isNotBlank(start_time)){ sql.append(" AND gmt_create>=:start_time"); paramMap.put("start_time", start_time+"000000"); } //结束时间 if(StringUtil.isNotBlank(end_time)){ sql.append(" and gmt_create<=:end_time"); paramMap.put("end_time", end_time+"235959"); } int count = baseDao.queryForInteger(sql.toString(), paramMap); return count; } }