package cn.ksource.web.facade.uc.order; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import cn.ksource.beans.SC_WORKFLOW_INCIDENT_LOCAL; import cn.ksource.core.dao.BaseDao; import cn.ksource.core.dao.SqlParameter; import cn.ksource.core.page.PageInfo; import cn.ksource.core.util.ConvertUtil; import cn.ksource.core.util.StringUtil; import cn.ksource.core.web.WebUtil; import cn.ksource.web.Constants; import cn.ksource.web.facade.incident.IncidentFacade; import cn.ksource.web.service.file.FileService; @Service("ucZcywFacade") public class UcZcywFacadeImpl implements UcZcywFacade { @Autowired private BaseDao baseDao; @Autowired private IncidentFacade incidentFacade; @Autowired private FileService fileService; @Override public int zcywCountForFwt(Map params) { StringBuilder builder = new StringBuilder(); builder.append("SELECT COUNT(WB.ID) "); builder.append("FROM WORKFLOW_BASE WB,SC_WORKFLOW_INCIDENT_LOCAL B WHERE WB.BUSINESS_ID = B.ID "); builder.append("AND WB.BUSINESSTYPE = :businessType "); params.put("businessType", ConvertUtil.obj2StrBlank(Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT_LOCAL)); builder.append(" AND B.CUSTOMER_ID = :cusId "); String orderName = params.get("orderName"); if(StringUtil.notEmpty(orderName)) { builder.append(" AND WB.WFNAME LIKE :orderName "); params.put("orderName", "%"+orderName+"%"); } String orderStatus = params.get("orderStatus"); if(StringUtil.notEmpty(orderStatus)) { builder.append(" AND WB.WFSTATE = :orderStatus "); params.put("orderStatus", orderStatus); } String orderCode = params.get("orderCode"); if(StringUtil.notEmpty(orderCode)) { builder.append(" AND WB.ORDER_CODE LIKE :orderCode "); params.put("orderCode", "%"+orderCode+"%"); } return baseDao.queryForInteger(builder.toString(), params); } @Override public PageInfo zcywDataForFwt(PageInfo pageInfo,Map params) { StringBuilder builder = new StringBuilder(); builder.append("SELECT WB.ID,WB.ORDER_CODE,WB.WFNAME,WB.BUSINESSTYPE,WB.CREATERNAME,WB.CREATETIME,WB.WFNOTE, "); builder.append("WB.CURRENT_NODE_ID,WB.CURRENT_NODE_NAME,WB.CUSTOMER_NAME,WB.CURRENT_DEALER_NAME,WB.BUSINESS_ID,WB.WFSTATE,B.ANSWER_TIMEOUT,B.DEAL_TIMEOUT "); builder.append("FROM WORKFLOW_BASE WB,SC_WORKFLOW_INCIDENT_LOCAL B WHERE WB.BUSINESS_ID = B.ID "); builder.append("AND WB.BUSINESSTYPE = :businessType "); params.put("businessType", ConvertUtil.obj2StrBlank(Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT_LOCAL)); builder.append(" AND B.CUSTOMER_ID = :cusId "); String orderName = params.get("orderName"); if(StringUtil.notEmpty(orderName)) { builder.append(" AND WB.WFNAME LIKE :orderName "); params.put("orderName", "%"+orderName+"%"); } String orderStatus = params.get("orderStatus"); if(StringUtil.notEmpty(orderStatus)) { builder.append(" AND WB.WFSTATE = :orderStatus "); params.put("orderStatus", orderStatus); } String orderCode = params.get("orderCode"); if(StringUtil.notEmpty(orderCode)) { builder.append(" AND WB.ORDER_CODE LIKE :orderCode "); params.put("orderCode", "%"+orderCode+"%"); } builder.append( " ORDER BY WB.CREATETIME DESC "); return baseDao.queryforSplitPageInfo(pageInfo, builder.toString(), params); } /** * 查询驻场运维记录基本信息 */ @Override public Map queryIncidentLocalBaseMsg(String orderId) { String selectSql = "SELECT A.*,N.ANSWER_TIME AS XY_TIME,B.WFSTATE FROM SC_WORKFLOW_INCIDENT_LOCAL A LEFT JOIN WORKFLOW_BASE B ON A.ID = B.BUSINESS_ID LEFT JOIN WORKFLOW_NODE N ON B.CURRENT_NODE_ID = N.ID WHERE A.ID = :orderId "; Map baseMap = baseDao.queryForMap(selectSql,new SqlParameter("orderId",orderId)); if(null!=baseMap && baseMap.size()>0) { //查询附件 List files = fileService.getFileList(orderId); baseMap.put("files", files); } return baseMap; } @Override public Map queryWcReport(String orderId) { Map incident = new SC_WORKFLOW_INCIDENT_LOCAL(orderId).getBeanMapById(); String flowId = ConvertUtil.obj2StrBlank(incident.get("FLOW_ID")); //查询关联工单 if(null!=incident && incident.size()>0) { List orders = queryOrders(orderId); List devices = incidentFacade.queryDevices(flowId); List files = queryFiles(orderId); incident.put("orders", orders); incident.put("devices", devices); incident.put("files", files); } return incident; } @Override public List queryOrders(String orderId) { String selectSql = "SELECT A.*,B.ID AS LINK_ID FROM SC_WORKFLOW_INCIDENT_LOCAL_ORDER B,WORKFLOW_BASE A WHERE A.ID = B.RELATE_FLOW_ID AND A.WFSTATE != :wfstate AND B.BUSINESS_ID = :businessId "; List orders = baseDao.queryForList(selectSql,new SqlParameter("businessId",orderId).addValue("wfstate", Constants.WORKFLOW_BASE_WFSTATE_DELETE)); return orders; } @Override public List queryFiles(String orderId) { List files = fileService.getFileList(orderId,1); if(null!=files && files.size()>0) { for(Map file : files) { file.put("FILE_SIZE", StringUtil.getFileSize(ConvertUtil.obj2Double(file.get("FILE_SIZE")))); } } return files; } @Override public Map queryCloseReport(String orderId) { Map incident = new SC_WORKFLOW_INCIDENT_LOCAL(orderId).getBeanMapById(); if(null!=incident && incident.size()>0) { String merged_business_id = ConvertUtil.obj2StrBlank(incident.get("MERGED_BUSINESS_ID")); if(StringUtil.notEmpty(merged_business_id)) { Map linkIncident = new SC_WORKFLOW_INCIDENT_LOCAL(merged_business_id).getBeanMapById(); incident.put("linkIncident", linkIncident); } } return incident; } }