package cn.ksource.web.facade.wechat.ewyw;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
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 cn.ksource.beans.CUSTOMER_CONTACTS;
|
import cn.ksource.beans.GG_MESSAGE;
|
import cn.ksource.beans.GG_RECORD;
|
import cn.ksource.beans.REPAIR_RECORD;
|
import cn.ksource.beans.SC_PARTNER_CUSTOMER_INFO;
|
import cn.ksource.beans.SC_SERVCE_CATEGORY;
|
import cn.ksource.beans.SC_WORKFLOW_INCIDENT;
|
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.NumberUtil;
|
import cn.ksource.core.util.StringUtil;
|
import cn.ksource.core.web.SysInfoMsg;
|
import cn.ksource.core.web.WebUtil;
|
import cn.ksource.core.workflow.NodeAnswerEntity;
|
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.controller.wechat.util.WechatConstants;
|
import cn.ksource.web.facade.incident.IncidentFacade;
|
import cn.ksource.web.facade.message.MessageFacade;
|
import cn.ksource.web.facade.servicelist.SlaPartnerFacade;
|
import cn.ksource.web.service.DataDictionaryService;
|
import cn.ksource.web.service.WorkOrderCodeService;
|
import cn.ksource.web.service.device.DeviceService;
|
import cn.ksource.web.service.file.FileService;
|
import cn.ksource.web.service.order.OrderService;
|
import cn.ksource.web.service.record.RecordService;
|
import cn.ksource.web.service.sl.SlaProjectService;
|
import cn.ksource.web.service.sl.sla.NoticeUser;
|
import cn.ksource.web.service.sl.sla.SLAEntity;
|
import cn.ksource.web.service.sl.sla.SLALevel;
|
|
@Service("ewIncidentFacade")
|
public class EwIncidentFacadeImpl implements EwIncidentFacade {
|
|
@Autowired
|
private BaseDao baseDao;
|
|
@Autowired
|
private WorkOrderCodeService workOrderCodeService;
|
|
@Autowired
|
private DataDictionaryService dataDictionaryService;
|
|
@Autowired
|
private WorkflowBusinessService workflowBusinessService;
|
|
@Autowired
|
private WorkflowCoreService workflowCoreService;
|
|
@Autowired
|
private FileService fileService;
|
|
@Autowired
|
private MessageFacade messageFacade;
|
|
|
@Autowired
|
private RecordService recordService;
|
|
@Autowired
|
private OrderService orderService;
|
|
@Autowired
|
private DeviceService deviceService;
|
|
@Resource(name="slaProjectService")
|
private SlaProjectService slaProjectService;
|
|
@Resource(name="slaPartnerFacade")
|
private SlaPartnerFacade slaPartnerFacade;
|
|
@Override
|
public String doOrderConfirm(HttpServletRequest request) {
|
String incidentId = request.getParameter("incidentId");
|
String flowId = request.getParameter("flowId");
|
|
Map user = WebUtil.getEngineerMsg(request);
|
String userId = ConvertUtil.obj2StrBlank(user.get("ID"));
|
String userName = ConvertUtil.obj2StrBlank(user.get("ZSXM"));
|
|
NodeAnswerEntity answerEntity = new NodeAnswerEntity();
|
answerEntity.setUser_id(userId);
|
answerEntity.setUser_name(userName);
|
|
|
WORKFLOW_BASE base = new WORKFLOW_BASE(flowId).getInstanceById();
|
|
|
//判断该工单是否已经响应过
|
|
|
|
//工单响应
|
boolean result = workflowCoreService.answerNode(base, new WORKFLOW_NODE(base.getCurrent_node_id()).getInstanceById(), answerEntity);
|
if(!result) {
|
return "2";
|
}
|
|
|
//判断是否是第一次响应,如果是第一次响应的话,则更新事件表中实际响应时间(第一次响应时间)
|
String selectSql = "SELECT ANSWER_TIME,CREATE_TIME,ANSWER_TIMEOUT_TIME FROM SC_WORKFLOW_INCIDENT WHERE ID = :incidentId";
|
Map map = baseDao.queryForMap(selectSql,new SqlParameter("incidentId",incidentId));
|
String answerTime = ConvertUtil.obj2StrBlank(map.get("ANSWER_TIME"));
|
long create_time = ConvertUtil.obj2Long(map.get("CREATE_TIME"));
|
|
|
Map paramMap = new HashMap();
|
StringBuilder builder = new StringBuilder("UPDATE SC_WORKFLOW_INCIDENT SET STATE = STATE + 1");
|
|
if(!StringUtil.notEmpty(answerTime)) {
|
long answer_time = DateUtil.getCurrentDate14();
|
//判断是否响应超时
|
long answer_timeout_time = ConvertUtil.obj2Long(map.get("ANSWER_TIMEOUT_TIME"));
|
|
String answer_timeout = "2";
|
if(answer_time>answer_timeout_time) {
|
answer_timeout = "1";
|
}
|
|
builder.append(",ANSWER_TIME = :answerTime,ANSWER_USE_TIME = :answer_user_time,ANSWER_TIMEOUT = :answer_timeout ");
|
paramMap.put("answerTime",answer_time);
|
paramMap.put("answer_timeout", answer_timeout);
|
|
//计算第一次响应时间和创建事件的事件差 将时间差转化为分钟
|
long seconds = DateUtil.getSecondsFormDate2Date(create_time, answer_time);
|
//将秒转化为分钟
|
double sjxysj = NumberUtil.div(ConvertUtil.obj2Double(seconds), ConvertUtil.obj2Double(60), 1);
|
|
paramMap.put("answer_user_time", sjxysj);
|
|
|
//如果是第一次响应,则删除所有的响应通知
|
String deleteSql = "DELETE FROM SC_INCIDENT_SLA_NOTICE WHERE TYPE = 1 AND INCIDENT_ID = :incidentId";
|
baseDao.execute(deleteSql, new SqlParameter("incidentId",incidentId));
|
|
|
}
|
|
builder.append(" WHERE ID = :incidentId");
|
paramMap.put("incidentId", incidentId);
|
baseDao.execute(builder.toString(), paramMap);
|
|
return "1";
|
}
|
|
@Override
|
public String doOrderConfirm(String incidentId,
|
String userId, String userName) {
|
String flowId = "";
|
|
NodeAnswerEntity answerEntity = new NodeAnswerEntity();
|
answerEntity.setUser_id(userId);
|
answerEntity.setUser_name(userName);
|
if(StringUtil.notEmpty(incidentId)) {
|
SC_WORKFLOW_INCIDENT incident = new SC_WORKFLOW_INCIDENT(incidentId).getInstanceById();
|
flowId = incident.getFlow_id();
|
}
|
|
WORKFLOW_BASE base = new WORKFLOW_BASE(flowId).getInstanceById();
|
|
|
//判断该工单是否已经响应过
|
|
|
|
//工单响应
|
boolean result = workflowCoreService.answerNode(base, new WORKFLOW_NODE(base.getCurrent_node_id()).getInstanceById(), answerEntity);
|
if(!result) {
|
return "2";
|
}
|
|
|
//判断是否是第一次响应,如果是第一次响应的话,则更新事件表中实际响应时间(第一次响应时间)
|
String selectSql = "SELECT ANSWER_TIME,CREATE_TIME,ANSWER_TIMEOUT_TIME FROM SC_WORKFLOW_INCIDENT WHERE ID = :incidentId";
|
Map map = baseDao.queryForMap(selectSql,new SqlParameter("incidentId",incidentId));
|
String answerTime = ConvertUtil.obj2StrBlank(map.get("ANSWER_TIME"));
|
long create_time = ConvertUtil.obj2Long(map.get("CREATE_TIME"));
|
|
|
Map paramMap = new HashMap();
|
StringBuilder builder = new StringBuilder("UPDATE SC_WORKFLOW_INCIDENT SET STATE = STATE + 1");
|
|
if(!StringUtil.notEmpty(answerTime)) {
|
long answer_time = DateUtil.getCurrentDate14();
|
//判断是否响应超时
|
long answer_timeout_time = ConvertUtil.obj2Long(map.get("ANSWER_TIMEOUT_TIME"));
|
|
String answer_timeout = "2";
|
if(answer_time>answer_timeout_time) {
|
answer_timeout = "1";
|
}
|
|
builder.append(",ANSWER_TIME = :answerTime,ANSWER_USE_TIME = :answer_user_time,ANSWER_TIMEOUT = :answer_timeout ");
|
paramMap.put("answerTime",answer_time);
|
paramMap.put("answer_timeout", answer_timeout);
|
|
//计算第一次响应时间和创建事件的事件差 将时间差转化为分钟
|
long seconds = DateUtil.getSecondsFormDate2Date(create_time, answer_time);
|
//将秒转化为分钟
|
double sjxysj = NumberUtil.div(ConvertUtil.obj2Double(seconds), ConvertUtil.obj2Double(60), 1);
|
|
paramMap.put("answer_user_time", sjxysj);
|
|
|
//如果是第一次响应,则删除所有的响应通知
|
String deleteSql = "DELETE FROM SC_INCIDENT_SLA_NOTICE WHERE TYPE = 1 AND INCIDENT_ID = :incidentId";
|
baseDao.execute(deleteSql, new SqlParameter("incidentId",incidentId));
|
|
|
}
|
|
builder.append(" WHERE ID = :incidentId");
|
paramMap.put("incidentId", incidentId);
|
baseDao.execute(builder.toString(), paramMap);
|
|
return "1";
|
}
|
|
@Override
|
public Map queryCusSub(String customerId) {
|
Map resultMap = new HashMap();
|
String subcusId = "";
|
if(!StringUtil.isEmpty(customerId)){
|
String[] subs = customerId.split("--");
|
if(subs.length > 1){
|
subcusId = subs[1];
|
}
|
}
|
String sql = "SELECT * FROM SC_PARTNER_CUSTOMER_INFO WHERE CUSTOMER_STATE = 1 ";
|
List<Map> cusList = baseDao.queryForList(sql);
|
Map cusMap = new HashMap();
|
|
if(null!=cusList && cusList.size()>0){
|
for(Map cus:cusList){
|
cusMap.put(cus.get("ID"), cus.get("CUSTOMER_NAME"));
|
}
|
}
|
String selectSubSql = "SELECT * FROM SC_PARTNER_CUSTOMER_SUB WHERE DEL_FLAG = 1 ORDER BY MY_LEVEL ";
|
List<Map> subCus = baseDao.queryForList(selectSubSql);
|
|
List<Map> subs = new ArrayList();
|
|
List<Map> checkSl = new ArrayList();
|
|
|
Map cacheMap = new HashMap();
|
if(null!=subCus && subCus.size()>0){
|
for(Map cus : subCus) {
|
String level = ConvertUtil.obj2StrBlank(cus.get("MY_LEVEL"));
|
String id = ConvertUtil.obj2Str(cus.get("ID"));
|
String name = ConvertUtil.obj2StrBlank(cus.get("CUSTOMER_NAME"));
|
String cusId = ConvertUtil.obj2StrBlank(cus.get("CUSTOMER_ID"));
|
|
if(subcusId.equals(id)) {
|
cus.put("checked", 1);
|
Map map = new HashMap();
|
map.put("checkId", cusId + "--" +id);
|
map.put("checkName",cusMap.get(cusId) + "--" + name);
|
checkSl.add(map);
|
} else {
|
cus.put("checked", 2);
|
}
|
|
|
if(level.equals("1")) {
|
List ejList = new ArrayList();
|
cacheMap.put(id, ejList);
|
cus.put("subs", ejList);
|
subs.add(cus);
|
continue;
|
}
|
|
if(level.equals("2")) {
|
String pid = ConvertUtil.obj2StrBlank(cus.get("P_ID"));
|
List ejList = (List)cacheMap.get(pid);
|
ejList.add(cus);
|
}
|
}
|
}
|
if(null!=cusList && cusList.size()>0){
|
for(Map cus:cusList){
|
if(!StringUtil.isEmpty(customerId)){
|
if(StringUtil.isEmpty(subcusId)){
|
String id = ConvertUtil.obj2Str(cus.get("ID"));
|
String name = ConvertUtil.obj2StrBlank(cus.get("CUSTOMER_NAME"));
|
|
if(customerId.equals(id)) {
|
cus.put("checked", 1);
|
Map map = new HashMap();
|
map.put("checkId", id);
|
map.put("checkName", name);
|
checkSl.add(map);
|
} else {
|
cus.put("checked", 2);
|
}
|
}
|
}
|
for(Map sub:subs){
|
if(sub.get("CUSTOMER_ID").equals(cus.get("ID"))){
|
List<Map> subcus = (List)cus.get("sublist");
|
if(subcus == null){
|
subcus = new ArrayList<Map>();
|
subcus.add(sub);
|
cus.put("sublist", subcus);
|
}else{
|
subcus.add(sub);
|
cus.put("sublist", subcus);
|
}
|
}
|
}
|
}
|
}
|
resultMap.put("cusList", cusList);
|
resultMap.put("checks", checkSl);
|
return resultMap;
|
}
|
|
@Override
|
public Map queryContactInfo(String customer_id, String contactPhone) {
|
|
String selectSql = "SELECT CONTACT_NAME,YWKS,SUB_CUSTOMER_ID,SUB_CUSTOMER_NAME FROM CUSTOMER_CONTACTS WHERE CONTACTS_TYPE = :contactPhone AND CUSTOMER_ID = :customer_id ";
|
Map map = baseDao.queryForMap(selectSql,new SqlParameter("contactPhone",contactPhone).addValue("customer_id", customer_id));
|
if(null!=map && map.size()>0) {
|
map.put("hasMsg", "1");
|
} else {
|
map.put("hasMsg", "2");
|
}
|
return map;
|
}
|
|
@Override
|
public List<Map> queryLinkDevice(Map<String, String> params) {
|
StringBuilder builder = new StringBuilder();
|
builder = getDevicesql(builder,params);
|
List<Map> devices = baseDao.queryForList( builder.toString(), params);
|
|
for(Map device : devices){
|
device.put("LASTUPDATETIME", DateUtil.format("yyyy-MM-dd HH:mm:ss", device.get("LASTUPDATETIME")));
|
int i = device.get("STATE") == null ? 0 : ConvertUtil.obj2Int(device.get("STATE"));
|
device.put("STATE", Constants.getCMDB_CI_BASE_USINGSTATE_Label(i));
|
}
|
return devices;
|
}
|
|
public StringBuilder getDevicesql(StringBuilder builder,Map<String, String> params){
|
|
String customerId = params.get("customerId");
|
String ciids = params.get("ciids");
|
String cmdbName = AjaxUtil.decode(params.get("cmdbName"));
|
String subCustomerId = "";
|
if(!StringUtil.isEmpty(customerId)){
|
String[] subs = customerId.split("--");
|
if(subs.length > 1){
|
customerId = subs[0];
|
subCustomerId = subs[1];
|
if(customerId.equals(subCustomerId)){
|
subCustomerId="";
|
}
|
}else{
|
customerId = subs[0];
|
}
|
}
|
|
//查询关联设备
|
//builder.append("SELECT A.* FROM CMDB_CI_BASE A,CMDB_CI_FLOW B WHERE A.ID = B.CFG_ID AND B.STATE = 4 AND A.STATE = 1 ");
|
builder.append("SELECT\n" +
|
" A.*\n" +
|
"FROM\n" +
|
" CMDB_CI_BASE A\n" +
|
"left JOIN CMDB_CI_FLOW B ON A.ID = B.CFG_ID\n" +
|
"WHERE\n" +
|
" A.STATE = 1 and (b.STATE is null or b.STATE = 4)"
|
);
|
if(StringUtil.notEmpty(ciids)){
|
String ciid[] = ciids.split("-");
|
if (!StringUtil.isEmpty(ciids)) {
|
String para="";
|
for(int i=0;i<ciid.length;i++){
|
if(i<ciid.length-1){
|
para+=ciid[i]+"','";
|
}else if(i==ciid.length-1){
|
para+=ciid[i];
|
}
|
}
|
builder.append(" and A.ID NOT IN ('");
|
builder.append(para);
|
builder.append("') ");
|
}
|
}
|
|
if(StringUtil.notEmpty(cmdbName)) {
|
builder.append(" AND (A.CINAME LIKE :ciName OR A.SEARCHCODE LIKE :ciName )");
|
params.put("ciName", "%"+cmdbName+"%");
|
}
|
|
if(StringUtil.notEmpty(subCustomerId)) {
|
String sql="SELECT MY_LEVEL FROM SC_PARTNER_CUSTOMER_SUB WHERE id =:subCustomerId AND DEL_FLAG = 1";
|
params.put("subCustomerId", subCustomerId);
|
String lv=baseDao.queryForString(sql,params);
|
if(StringUtil.isNotBlank(lv)){
|
if(lv.equals("1")){
|
builder.append(" AND A.SUB_CUS_ID in (select id from SC_PARTNER_CUSTOMER_SUB where P_ID=:subCustomerId)");
|
}else{
|
builder.append(" AND A.SUB_CUS_ID =:subCustomerId");
|
}
|
}
|
|
}else{
|
builder.append(" AND A.CUS_ID = :customerId ");
|
params.put("customerId", customerId);
|
}
|
|
builder.append(" ORDER BY A.CODE ");
|
return builder;
|
}
|
|
@Override
|
public List<Map> queryLinkOrder(Map<String, String> params) {
|
String orderCode = params.get("orderCode");
|
String customerId = params.get("customerId");
|
String orderids = params.get("orderids");
|
StringBuilder sql = new StringBuilder("SELECT A.ID,A.WFNAME,A.BUSINESSTYPE,A.WFSTATE,A.BUSINESS_ID,A.ORDER_CODE,A.CUSTOMER_NAME,A.CREATETIME,A.CREATERNAME FROM WORKFLOW_BASE A WHERE A.WFSTATE != :wfstate AND A.WFSTATE != :wfstate1 ");
|
if(!StringUtil.isEmpty(customerId)){
|
String[] subs = customerId.split("--");
|
if(subs.length > 1){
|
customerId = subs[0];
|
params.put("customerId", customerId);
|
}
|
}
|
if(!StringUtil.isEmpty(customerId)){
|
sql.append(" AND A.CUSTOMER_ID = :customerId ");
|
}
|
|
params.put("wfstate", ConvertUtil.obj2StrBlank(Constants.WORKFLOW_BASE_WFSTATE_DELETE));
|
params.put("wfstate1", ConvertUtil.obj2StrBlank(Constants.WORKFLOW_BASE_WFSTATE_CLOSE));
|
|
String flowid[] = orderids.split("-");
|
if (!StringUtil.isEmpty(orderids)) {
|
String para="";
|
for(int i=0;i<flowid.length;i++){
|
if(i<flowid.length-1){
|
para+=flowid[i]+"','";
|
}else if(i==flowid.length-1){
|
para+=flowid[i];
|
}
|
}
|
sql.append(" AND A.ID NOT IN ('"+para+"') ");
|
}
|
|
if (StringUtils.isNotBlank(orderCode)) {
|
sql.append("AND A.ORDER_CODE like :orderCode ");
|
params.put("orderCode", "%"+orderCode+"%");
|
}
|
|
sql.append("ORDER BY A.WFSTATE ASC,A.CREATETIME DESC");
|
|
|
List<Map> list = baseDao.queryForList(sql.toString(),params);
|
|
for (Map map2 : list) {
|
map2.put("BUSINESSTYPE_TEXT", Constants.mapWORKFLOW_BUSINESS_TYPE_Label(ConvertUtil.obj2Str(map2.get("BUSINESSTYPE"))));
|
map2.put("WFSTATE_TEXT", Constants.getWORKFLOW_BASE_WFSTATE_Label(ConvertUtil.obj2Str(map2.get("WFSTATE"))));
|
map2.put("CREATE_TIME", DateUtil.format("yyyy-MM-dd HH:mm:ss", map2.get("CREATE_TIME")));
|
}
|
return list;
|
}
|
|
@Override
|
public Map saveEngineerIncident(HttpServletRequest request,
|
SC_WORKFLOW_INCIDENT sc_workflow_incident) {
|
Map resultMap = new HashMap();
|
resultMap.put("result", "2");
|
Map user = WebUtil.getEngineerMsg(request);
|
|
|
String userId = ConvertUtil.obj2StrBlank(user.get("ID"));
|
String userName = ConvertUtil.obj2StrBlank(user.get("ZSXM"));
|
String customerId = sc_workflow_incident.getCustomer_id();
|
String customerName = sc_workflow_incident.getCustomer_name();
|
String subCustomerId = "";
|
String subCustomerName = "";
|
if(!StringUtil.isEmpty(customerId)){
|
String[] subs = customerId.split("--");
|
String[] subNames = customerName.split("--");
|
if(subs.length > 1){
|
customerId = subs[0];
|
subCustomerId = subs[1];
|
customerName = subNames[0];
|
subCustomerName = subNames[1];
|
}else{
|
subCustomerId = subs[0];
|
subCustomerName = subNames[0];
|
}
|
}
|
String happen_time = request.getParameter("happen_time");
|
happen_time = happen_time.replace("-", "").replace(" ", "").replace(":", "");
|
sc_workflow_incident.setHappen_time(ConvertUtil.obj2Long(happen_time+"00"));
|
sc_workflow_incident.setCustomer_id(customerId).setSub_customer_id(subCustomerId).setSub_customer_name(subCustomerName);
|
String type_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getType_id()).get("DATAVALUE"));
|
sc_workflow_incident.setType_name(type_name);
|
String apply_type_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getApply_type_id()).get("DATAVALUE"));
|
sc_workflow_incident.setApply_type_name(apply_type_name);
|
String source_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getSource_id()).get("DATAVALUE"));
|
sc_workflow_incident.setSource_name(source_name);
|
String priority_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getPriority_id()).get("DATAVALUE"));
|
sc_workflow_incident.setPriority_name(priority_name);
|
String influence_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getInfluence_id()).get("DATAVALUE"));
|
sc_workflow_incident.setInfluence_name(influence_name);
|
String serivceListId = request.getParameter("serivceListId");
|
String serivceList = request.getParameter("serivceList");
|
String first_category_id = new String();
|
String first_category_name = new String();
|
String second_category_id = new String();
|
String second_category_name = new String();
|
String third_category_id = new String();
|
String third_category_name = new String();
|
if(StringUtil.notEmpty(serivceListId) && StringUtil.notEmpty(serivceList)) {
|
String[] serivceListIds = serivceListId.split("-");
|
String[] serivceLists = serivceList.split("->");
|
first_category_id = serivceListIds[0];
|
first_category_name = serivceLists[0];
|
second_category_id = serivceListIds[1];
|
second_category_name = serivceLists[1];
|
third_category_id = serivceListIds[2];
|
third_category_name = serivceLists[2];
|
}
|
|
|
//查询当前项目的服务台组的编号
|
String selectSql = "SELECT A.* FROM AC_ROLE A WHERE A.IDENTIFY = :roleid ";
|
Map map = baseDao.queryForMap(selectSql,new SqlParameter("roleid",Constants.ROLE_SERVICE));
|
|
|
String roleId = ConvertUtil.obj2StrBlank(map.get("ID"));
|
String roleName = ConvertUtil.obj2StrBlank(map.get("ROLENAME"));
|
|
List<Map> dealerList = new ArrayList<Map>();
|
//查询改组下面的所有人员信息
|
String selectUser = "SELECT B.ID AS USER_ID,B.ZSXM AS USER_NAME FROM AC_USER_REF_ROLE A,GG_USER B WHERE A.JSBH = :roleId AND A.YHBH = B.ID ";
|
dealerList = baseDao.queryForList(selectUser,new SqlParameter("roleId",roleId));
|
|
if(dealerList == null || dealerList.size() == 0){
|
resultMap.put("result", 2);
|
resultMap.put("nouser", 1);
|
return resultMap;
|
}
|
|
String state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDFWT;
|
String node_template_id = Constants.KFRY;
|
|
|
String order_code = workOrderCodeService.getIncidentOrderCode();
|
|
|
//响应时间为分钟
|
Long requestAnswerTime = sc_workflow_incident.getRequest_answer_time();
|
Long dealTime = sc_workflow_incident.getRequest_deal_time();
|
if(null == requestAnswerTime) {
|
requestAnswerTime = Long.valueOf(0);
|
}
|
|
if(null == dealTime) {
|
dealTime = Long.valueOf(0);
|
}
|
|
//处理时间为小时
|
long createTime = DateUtil.getCurrentDate14();
|
|
long answerTimeoutTime = DateUtil.getTimeAdd(createTime, ConvertUtil.obj2Int(requestAnswerTime),2);
|
long dealTimeoutTime = DateUtil.getTimeAdd(createTime, ConvertUtil.obj2Int(dealTime),1);
|
|
sc_workflow_incident.setFirst_category_id(first_category_id).setFirst_category_name(first_category_name).setSecond_category_id(second_category_id)
|
.setSecond_category_name(second_category_name).setThird_category_id(third_category_id).setThird_category_name(third_category_name).setCreate_user_id(userId).setCreate_user_name(userName)
|
.setCreate_time(createTime);
|
String id = StringUtil.getUUID();
|
sc_workflow_incident.setId(id).setState(ConvertUtil.obj2Integer(state)).setOrder_code(order_code).setFlow_name(sc_workflow_incident.getName()).setAnswer_timeout(2).setAnswer_timeout_time(answerTimeoutTime).setDeal_timeout(2).setDeal_timeout_time(dealTimeoutTime).setCreate_type(2);
|
sc_workflow_incident.insert();
|
|
String bz = request.getParameter("bz");
|
//启动流程
|
WORKFLOW_BASE base = workflowBusinessService.startIncidentWorkflow(id,bz);
|
|
|
|
//启动流程
|
|
NodeDealEntity entity = new NodeDealEntity();
|
entity.setDealer_type(3);
|
entity.setBefore_Dealer_type(1);
|
entity.setRoleID(roleId);
|
entity.setRoleName(roleName);
|
|
workflowBusinessService.toNode(base, node_template_id, entity);
|
|
String hasMsg = request.getParameter("hasMsg");
|
if(StringUtil.notEmptyNum(hasMsg) && hasMsg.equals("2")) {
|
//保存联系人的信息
|
CUSTOMER_CONTACTS project_contacts = new CUSTOMER_CONTACTS();
|
project_contacts.setId(StringUtil.getUUID()).setCustomer_id(sc_workflow_incident.getCustomer_id())
|
.setContact_name(sc_workflow_incident.getContact_name()).setContacts_type(sc_workflow_incident.getContact_phone()).setYwks(sc_workflow_incident.getKeshi())
|
.setIs_satis(0).setState(1).setIsemail(1).setIsphone(1).setAllow_login(2).setSub_customer_id(sc_workflow_incident.getSub_customer_id()).setSub_customer_name(sc_workflow_incident.getSub_customer_name());
|
project_contacts.insert();
|
}
|
|
String wxUrl = WechatConstants.ORDER_INCIDENT_DETAIL_ADDRESS+"?orderId="+base.getBusiness_id()+"&orderType="+Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT;
|
//发送消息
|
GG_MESSAGE message = new GG_MESSAGE();
|
message.setTitle(sc_workflow_incident.getName())
|
.setContent(sc_workflow_incident.getName())
|
.setSender_id(userId)
|
.setSender_name(userName)
|
.setSend_time(DateUtil.getCurrentDate14())
|
.setBusiness_id(base.getBusiness_id())
|
.setWeb_url(Constants.INCIDENT_WEB_MSG_URL+"?flowId="+base.getId()+"&orderId="+base.getBusiness_id())
|
.setWx_url(wxUrl)
|
.setOrder_code(order_code)
|
.setType(Constants.GG_MESSAGE_TYPE_SJGL);
|
messageFacade.doSendMessage(message, dealerList);
|
|
|
|
//所有的业务主键都是flowId(即流程主表的id)
|
String flowId = base.getId();
|
|
//提交工单时添加关联工单
|
String[] orderId = request.getParameterValues("orderId");
|
orderService.saveLinkOrders(flowId,orderId,request);
|
|
//提交工单时上传文档附件
|
//fileService.uploadFile(request,flowId,flowId,null,null,Constants.GG_FOLDERS_SJFOLDERS,Constants.FILE_STATE_SHTG,null);
|
|
//提交工单时添加关联设备
|
String[] deviceId = request.getParameterValues("deviceId");
|
deviceService.saveLinkDevices(flowId,deviceId);
|
|
|
//添加处理记录
|
GG_RECORD record = new GG_RECORD();
|
record.setDeal_content("创建事件:"+userName+"创建了事件");
|
record.setDeal_user_id("1");
|
record.setDeal_user_name(userName);
|
record.setBusiness_id(flowId);
|
recordService.addRecord(record);
|
|
|
|
resultMap.put("result", "1");
|
SysInfoMsg msg = new SysInfoMsg("1",roleName,Constants.incidentNode.get(node_template_id));
|
resultMap.put("msg", msg);
|
resultMap.put("incidentId", id);
|
|
|
//增加该事件的SLA通知信息
|
addSlaNoticeMsg(id,createTime,sc_workflow_incident.getSla_id(),sc_workflow_incident.getCustomer_id(),sc_workflow_incident.getThird_category_id(),answerTimeoutTime,dealTimeoutTime,dealerList);
|
//一键报修
|
String repair = request.getParameter("repair");
|
if(!StringUtil.isEmpty(repair)){
|
REPAIR_RECORD repairrecord = new REPAIR_RECORD();
|
repairrecord.setId(repair).setIncident_id(sc_workflow_incident.getId()).setStatus(3).update();
|
}
|
return resultMap;
|
}
|
|
private void addSlaNoticeMsg(String id,long createTime,String levelId,String customer_id,String third_category_id,long answerTimeoutTime,long dealTimeoutTime,List<Map> dealLists) {
|
SLAEntity slaEntity = slaProjectService.getLevelMsg( customer_id, third_category_id);
|
if(null!=slaEntity) {
|
Map<String, SLALevel> levelMap = slaEntity.getLevelMap();
|
if(null!=levelMap && levelMap.size()>0) {
|
SLALevel level = levelMap.get(levelId);
|
if(null != level) {
|
String insertSql = "INSERT INTO SC_INCIDENT_SLA_NOTICE (ID,INCIDENT_ID,TYPE,NOTICE_TIME,STATUS,NOTICE_USERS,OUT_TIME) VALUES (:id,:incidentId,:type,:noticeTime,1,:noticeUsers,:out_time)";
|
List<SqlParameter> params = new ArrayList<SqlParameter>();
|
|
String responseTime = level.getResponseTime();
|
String noticeUsers = level.getUserId();
|
if(StringUtil.notEmpty(responseTime)) {
|
//响应时间为分钟,将其转化为毫秒
|
SqlParameter sqlParameter = new SqlParameter();
|
sqlParameter.put("id", StringUtil.getUUID());
|
sqlParameter.put("incidentId", id);
|
sqlParameter.put("type", 1);
|
sqlParameter.put("noticeTime", answerTimeoutTime);
|
sqlParameter.put("noticeUsers", noticeUsers);
|
sqlParameter.put("out_time", "");
|
params.add(sqlParameter);
|
|
List<NoticeUser> noticeUser1 = level.getResponseNotices();
|
if(null!=noticeUser1 && noticeUser1.size()>0) {
|
for(NoticeUser noticeUser : noticeUser1) {
|
String overTime = noticeUser.getOverTime();
|
if(StringUtil.notEmpty(overTime)) {
|
SqlParameter sqlParameter1 = new SqlParameter();
|
sqlParameter1.put("id", StringUtil.getUUID());
|
sqlParameter1.put("incidentId", id);
|
sqlParameter1.put("type", 1);
|
|
sqlParameter1.put("noticeTime", DateUtil.getTimeAdd(answerTimeoutTime, ConvertUtil.obj2Int(overTime),2));
|
|
StringBuffer bufferUser = new StringBuffer();
|
if(null!=dealLists && dealLists.size()>0) {
|
for(Map map : dealLists) {
|
String user_id = ConvertUtil.obj2StrBlank(map.get("USER_ID"));
|
bufferUser.append(user_id);
|
bufferUser.append(",");
|
}
|
bufferUser.deleteCharAt(bufferUser.lastIndexOf(","));
|
}
|
|
System.out.println("bufferUser---------->"+bufferUser);
|
sqlParameter1.put("noticeUsers", noticeUser.getUserId()+bufferUser.toString());
|
sqlParameter1.put("out_time", overTime);
|
params.add(sqlParameter1);
|
}
|
}
|
}
|
|
|
}
|
|
String resolveTime = level.getResolveTime();
|
if(StringUtil.notEmpty(resolveTime)) {
|
//解决时间为小时,将其转化为毫秒
|
SqlParameter sqlParameter = new SqlParameter();
|
sqlParameter.put("id", StringUtil.getUUID());
|
sqlParameter.put("incidentId", id);
|
sqlParameter.put("type", 2);
|
sqlParameter.put("noticeTime", dealTimeoutTime);
|
sqlParameter.put("noticeUsers", noticeUsers);
|
sqlParameter.put("out_time", "");
|
params.add(sqlParameter);
|
|
|
|
List<NoticeUser> noticeUser2 = level.getResolveNotices();
|
if(null!=noticeUser2 && noticeUser2.size()>0) {
|
for(NoticeUser noticeUser : noticeUser2) {
|
String overTime = noticeUser.getOverTime();
|
if(StringUtil.notEmpty(overTime)) {
|
SqlParameter sqlParameter1 = new SqlParameter();
|
sqlParameter1.put("id", StringUtil.getUUID());
|
sqlParameter1.put("incidentId", id);
|
sqlParameter1.put("type", 2);
|
sqlParameter1.put("noticeTime", DateUtil.getTimeAdd(dealTimeoutTime, ConvertUtil.obj2Int(overTime),2));
|
sqlParameter1.put("noticeUsers", noticeUser.getUserId());
|
sqlParameter1.put("out_time", overTime);
|
params.add(sqlParameter1);
|
}
|
}
|
}
|
}
|
|
|
if(params.size()>0) {
|
baseDao.executeBatch(insertSql,params);
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
}
|
|
@Override
|
public Map saveFwtIncident(HttpServletRequest request,
|
SC_WORKFLOW_INCIDENT sc_workflow_incident) {
|
String dtype = new String();
|
Map resultMap = new HashMap();
|
resultMap.put("result", 2);
|
System.out.println("selectUser-------------->"+request.getParameter("selectUser"));
|
Map user = WebUtil.getEngineerMsg(request);
|
|
|
String userId = ConvertUtil.obj2StrBlank(user.get("ID"));
|
String userName = ConvertUtil.obj2StrBlank(user.get("ZSXM"));
|
String customerId = sc_workflow_incident.getCustomer_id();
|
String customerName = sc_workflow_incident.getCustomer_name();
|
String subCustomerId = "";
|
String subCustomerName = "";
|
if(!StringUtil.isEmpty(customerId)){
|
String[] subs = customerId.split("--");
|
String[] subNames = customerName.split("--");
|
if(subs.length > 1){
|
customerId = subs[0];
|
subCustomerId = subs[1];
|
customerName = subNames[0];
|
subCustomerName = subNames[1];
|
}else{
|
subCustomerId = subs[0];
|
subCustomerName = subNames[0];
|
}
|
}
|
String happen_time = request.getParameter("happen_time");
|
happen_time = happen_time.replace("-", "").replace(" ", "").replace(":", "");
|
sc_workflow_incident.setHappen_time(ConvertUtil.obj2Long(happen_time+"00"));
|
String currentUserId = userId;
|
String currentUserName = userName;
|
sc_workflow_incident.setCustomer_id(customerId).setSub_customer_id(subCustomerId).setSub_customer_name(subCustomerName);
|
String type_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getType_id()).get("DATAVALUE"));
|
sc_workflow_incident.setType_name(type_name);
|
String apply_type_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getApply_type_id()).get("DATAVALUE"));
|
sc_workflow_incident.setApply_type_name(apply_type_name);
|
String source_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getSource_id()).get("DATAVALUE"));
|
sc_workflow_incident.setSource_name(source_name);
|
String priority_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getPriority_id()).get("DATAVALUE"));
|
sc_workflow_incident.setPriority_name(priority_name);
|
String influence_name = ConvertUtil.obj2StrBlank(dataDictionaryService.getDataDictionaryByKey(sc_workflow_incident.getInfluence_id()).get("DATAVALUE"));
|
sc_workflow_incident.setInfluence_name(influence_name);
|
String serivceListId = request.getParameter("serivceListId");
|
String serivceList = request.getParameter("serivceList");
|
String first_category_id = new String();
|
String first_category_name = new String();
|
String second_category_id = new String();
|
String second_category_name = new String();
|
String third_category_id = new String();
|
String third_category_name = new String();
|
if(StringUtil.notEmpty(serivceListId) && StringUtil.notEmpty(serivceList)) {
|
String[] serivceListIds = serivceListId.split("-");
|
String[] serivceLists = serivceList.split("-");
|
first_category_id = serivceListIds[0];
|
first_category_name = serivceLists[0];
|
second_category_id = serivceListIds[1];
|
second_category_name = serivceLists[1];
|
third_category_id = serivceListIds[2];
|
third_category_name = serivceLists[2];
|
}
|
|
String dealer_type = "1";
|
String dealUserId = userId;
|
String dealUserName = userName;
|
|
String type = request.getParameter("type");
|
String state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDFWT;
|
String node_template_id = Constants.KFRY;
|
if(type.equals("1")) {
|
String selectUser = request.getParameter("selectUser");
|
if(StringUtil.notEmpty(selectUser)) {
|
String[] userMsg = selectUser.split("-");
|
if(userMsg.length==4) {
|
dealer_type = userMsg[0];
|
String userType = userMsg[1];
|
dealUserId = userMsg[2];
|
dealUserName = userMsg[3];
|
if(userType.equals(Constants.ROLE_SERVICE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDFWT;
|
node_template_id = Constants.KFRY;
|
} else if(userType.equals(Constants.ROLE_OPERATION)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDYCJSZC;
|
node_template_id = Constants.YCJSZC;
|
} else if(userType.equals(Constants.ROLE_FLINE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDYX;
|
node_template_id = Constants.YXCL;
|
} else if(userType.equals(Constants.ROLE_SLINE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDEX;
|
node_template_id = Constants.EXCL;
|
} else if(userType.equals(Constants.ROLE_TLINE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDSX;
|
node_template_id = Constants.SXCL;
|
}
|
}
|
}
|
|
}
|
|
String order_code = workOrderCodeService.getIncidentOrderCode();
|
|
//响应时间为分钟
|
Long requestAnswerTime = sc_workflow_incident.getRequest_answer_time();
|
Long dealTime = sc_workflow_incident.getRequest_deal_time();
|
if(null == requestAnswerTime) {
|
requestAnswerTime = Long.valueOf(0);
|
}
|
|
if(null == dealTime) {
|
dealTime = Long.valueOf(0);
|
}
|
|
//处理时间为小时
|
long createTime = DateUtil.getCurrentDate14();
|
|
long answerTimeoutTime = DateUtil.getTimeAdd(createTime, ConvertUtil.obj2Int(requestAnswerTime),2);
|
long dealTimeoutTime = DateUtil.getTimeAdd(createTime, ConvertUtil.obj2Int(dealTime),1);
|
|
sc_workflow_incident.setFirst_category_id(first_category_id).setFirst_category_name(first_category_name).setSecond_category_id(second_category_id)
|
.setSecond_category_name(second_category_name).setThird_category_id(third_category_id).setThird_category_name(third_category_name).setCreate_user_id(userId).setCreate_user_name(userName)
|
.setCreate_time(createTime);
|
String id = StringUtil.getUUID();
|
sc_workflow_incident.setId(id).setState(ConvertUtil.obj2Integer(state)).setOrder_code(order_code).setFlow_name(sc_workflow_incident.getName()).setAnswer_timeout(2).setAnswer_timeout_time(answerTimeoutTime).setDeal_timeout(2).setDeal_timeout_time(dealTimeoutTime).setCreate_type(1);
|
sc_workflow_incident.insert();
|
|
String bz = request.getParameter("bz");
|
|
|
NodeDealEntity entity = new NodeDealEntity();
|
entity.setDealer_type(3);
|
List<Map> dealerList = new ArrayList<Map>();
|
if(dealer_type.equals("1")) {
|
entity.setBefore_Dealer_type(2);
|
Map map = new HashMap();
|
map.put("USER_ID", dealUserId);
|
map.put("USER_NAME", dealUserName);
|
map.put("IS_ADMIN", "1");
|
|
dealerList.add(map);
|
dtype = "2";
|
} else {
|
if(dealer_type.equals("2")){
|
dtype = "3";
|
}else{
|
dtype = "1";
|
}
|
entity.setBefore_Dealer_type(1);
|
entity.setRoleID(dealUserId);
|
entity.setRoleName(dealUserName);
|
|
//查询改角色/分组下面的所有人员信息
|
String usersql = "SELECT B.ID AS USER_ID ,B.ZSXM AS USER_NAME FROM AC_USER_REF_ROLE A,GG_USER B WHERE A.YHBH = B.ID AND A.JSBH = :groupId ";
|
dealerList = baseDao.queryForList(usersql,new SqlParameter("groupId",dealUserId));
|
if(dealerList == null || dealerList.size() == 0){
|
String groupusersql = "SELECT B.ID AS USER_ID ,B.ZSXM AS USER_NAME FROM AC_ROLE_GROUP_USER A,GG_USER B WHERE A.USER_ID = B.ID AND A.GROUP_ID = :groupId AND A.STATE = 1 ";
|
dealerList = baseDao.queryForList(groupusersql,new SqlParameter("groupId",dealUserId));
|
if(dealerList == null || dealerList.size() == 0){
|
resultMap.put("result", 2);
|
resultMap.put("nouser", 2);
|
return resultMap;
|
}
|
}
|
|
}
|
|
//启动流程
|
WORKFLOW_BASE base = workflowBusinessService.startIncidentWorkflow(id,bz);
|
|
entity.setDealerList(dealerList);
|
workflowBusinessService.toNode(base, node_template_id, entity);
|
|
|
String hasMsg = request.getParameter("hasMsg");
|
if(StringUtil.notEmptyNum(hasMsg) && hasMsg.equals("2")) {
|
//保存联系人的信息
|
CUSTOMER_CONTACTS project_contacts = new CUSTOMER_CONTACTS();
|
project_contacts.setId(StringUtil.getUUID()).setCustomer_id(sc_workflow_incident.getCustomer_id())
|
.setContact_name(sc_workflow_incident.getContact_name()).setContacts_type(sc_workflow_incident.getContact_phone()).setYwks(sc_workflow_incident.getKeshi())
|
.setIs_satis(0).setState(1).setIsemail(1).setIsphone(1).setAllow_login(2).setSub_customer_id(sc_workflow_incident.getSub_customer_id()).setSub_customer_name(sc_workflow_incident.getSub_customer_name());
|
project_contacts.insert();
|
}
|
|
//dtype = ConvertUtil.obj2StrBlank(entity.getBefore_Dealer_type());
|
|
String wxUrl = WechatConstants.ORDER_INCIDENT_DETAIL_ADDRESS+"?orderId="+base.getBusiness_id()+"&orderType="+Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT;
|
//System.out.println("wxUrl------------------------>"+wxUrl);
|
//发送消息
|
GG_MESSAGE message = new GG_MESSAGE();
|
message.setTitle(sc_workflow_incident.getName())
|
.setContent(sc_workflow_incident.getName())
|
.setSender_id(currentUserId)
|
.setSender_name(currentUserName)
|
.setSend_time(DateUtil.getCurrentDate14())
|
.setBusiness_id(base.getBusiness_id())
|
.setWeb_url(Constants.INCIDENT_WEB_MSG_URL+"?flowId="+base.getId()+"&orderId="+base.getBusiness_id())
|
.setWx_url(wxUrl)
|
.setOrder_code(order_code)
|
.setType(Constants.GG_MESSAGE_TYPE_SJGL);
|
messageFacade.doSendMessage(message, dealerList);
|
|
//所有的业务主键都是flowId(即流程主表的id)
|
String flowId = base.getId();
|
|
|
//提交工单时添加关联工单
|
String[] orderId = request.getParameterValues("orderId");
|
orderService.saveLinkOrders(flowId,orderId,request);
|
|
//提交工单时上传文档附件
|
//fileService.uploadFile(request,flowId,flowId,null,null,Constants.GG_FOLDERS_SJFOLDERS,Constants.FILE_STATE_SHTG,null);
|
|
//提交工单时添加关联设备
|
String[] deviceId = request.getParameterValues("deviceId");
|
deviceService.saveLinkDevices(flowId,deviceId);
|
|
|
//添加处理记录
|
GG_RECORD record = new GG_RECORD();
|
record.setDeal_content("创建事件:"+userName+"创建了事件");
|
record.setDeal_user_id("1");
|
record.setDeal_user_name(userName);
|
record.setBusiness_id(flowId);
|
recordService.addRecord(record);
|
|
|
|
SysInfoMsg msg = new SysInfoMsg(dtype,dealUserName,Constants.incidentNode.get(node_template_id));
|
resultMap.put("msg", msg);
|
resultMap.put("incidentId", id);
|
resultMap.put("result", 1);
|
|
|
//增加该事件的SLA通知信息
|
addSlaNoticeMsg(id,createTime,sc_workflow_incident.getSla_id(),sc_workflow_incident.getCustomer_id(),sc_workflow_incident.getThird_category_id(),answerTimeoutTime,dealTimeoutTime,dealerList);
|
|
return resultMap;
|
}
|
|
@Override
|
public Map users(String threeServiceListId, String flowId, String customerId) {
|
Map cacheMap = new HashMap();
|
|
String currentNode = new String();
|
if(StringUtil.notEmpty(flowId)) {
|
Map node = getCurrentNode(flowId);
|
currentNode = ConvertUtil.obj2StrBlank(node.get("NODE_TEMPLATE_ID"));
|
} else {
|
currentNode = Constants.KFRY;
|
}
|
|
//查询当前节点能发送的节点
|
String selectSql = "SELECT * FROM SC_WORKFLOW_INCIDENT_FLOWRULE WHERE PROJECT_ID = :projectId";
|
List<Map> list = baseDao.queryForList(selectSql,new SqlParameter("projectId",customerId));
|
if(null!=list && list.size()>0) {
|
Map m = list.get(0);
|
String json = ConvertUtil.obj2StrBlank(m.get(Constants.incidentNodeColunm.get(currentNode)));
|
List<Map> nodes = JsonUtil.json2List(json);
|
if(null!=nodes && nodes.size()>0) {
|
for(Map n : nodes) {
|
cacheMap.put(n.get("nodeId"), n);
|
}
|
}
|
}else{
|
String gsSql = "SELECT * FROM SC_WORKFLOW_INCIDENT_FLOWRULE WHERE (PROJECT_ID IS NULL OR PROJECT_ID = '')";
|
List<Map> gslist = baseDao.queryForList(gsSql);
|
if(null!=gslist && gslist.size()>0) {
|
Map m = gslist.get(0);
|
String json = ConvertUtil.obj2StrBlank(m.get(Constants.incidentNodeColunm.get(currentNode)));
|
List<Map> nodes = JsonUtil.json2List(json);
|
if(null!=nodes && nodes.size()>0) {
|
for(Map n : nodes) {
|
cacheMap.put(n.get("nodeId"), n);
|
}
|
}
|
}
|
}
|
|
|
//查询该客户该项目对应的服务目录选择的服务目录人员
|
List<Map> serviceUsers = new ArrayList<Map>();
|
SC_SERVCE_CATEGORY cate = new SC_SERVCE_CATEGORY(threeServiceListId).getInstanceById();
|
Map serviceUserMap = slaPartnerFacade.querySlaUser(customerId,threeServiceListId,cate.getP_id(),3);
|
if(serviceUserMap !=null && serviceUserMap.size() > 0){
|
Map yxMap = (Map)serviceUserMap.get("yxMap");
|
Map exMap = (Map)serviceUserMap.get("exMap");
|
Map sxMap = (Map)serviceUserMap.get("sxMap");
|
serviceUsers.add(yxMap);
|
serviceUsers.add(exMap);
|
serviceUsers.add(sxMap);
|
}
|
Map serviceUserCache = new HashMap();
|
Map serviceGroupCache = new HashMap();
|
String groupRole = "SELECT A.*,B.IDENTIFY FROM AC_ROLE_GROUP A,AC_ROLE B WHERE A.JSBH = B.ID ";
|
List<Map> groupList = baseDao.queryForList(groupRole);
|
String role = "SELECT * FROM AC_ROLE ";
|
List<Map> roleList = baseDao.queryForList(role);
|
Map cache = new HashMap();
|
for(Map map:groupList){
|
cache.put(map.get("ID"), map.get("IDENTIFY"));
|
}
|
Map cacheRole = new HashMap();
|
for(Map map:roleList){
|
cacheRole.put(map.get("ID"), map.get("IDENTIFY"));
|
}
|
|
for(Map serviceUser : serviceUsers) {
|
String userType = ConvertUtil.obj2StrBlank(serviceUser.get("USER_TYPE"));
|
if(userType.equals("1")) {
|
String group_id = ConvertUtil.obj2StrBlank(serviceUser.get("GROUP_ID"));
|
if(cache.containsKey(group_id)){
|
serviceGroupCache.put(group_id+cache.get(group_id), serviceUser);
|
}
|
} else {
|
String user_id = ConvertUtil.obj2StrBlank(serviceUser.get("USER_ID"));
|
String group_id = ConvertUtil.obj2StrBlank(serviceUser.get("GROUP_ID"));
|
if(cacheRole.containsKey(group_id)){
|
serviceUserCache.put(user_id+cacheRole.get(group_id), serviceUser);
|
}
|
}
|
}
|
|
List<Map> kfry = new ArrayList<Map>();
|
List<Map> yczc = new ArrayList<Map>();
|
List<Map> yxgcs = new ArrayList<Map>();
|
List<Map> exgcs = new ArrayList<Map>();
|
List<Map> sxgcs = new ArrayList<Map>();
|
|
|
Map removeUser = new HashMap();
|
//查询出该项目组下的所有的人员
|
String userSql = "SELECT A.*,C.IDENTIFY FROM GG_USER A,AC_USER_REF_ROLE B,AC_ROLE C WHERE A.ID = B.YHBH AND B.JSBH = C.ID ORDER BY C.IDENTIFY ASC ";
|
List<Map> users = baseDao.queryForList(userSql);
|
List<Map> seluserList = new ArrayList<Map>();
|
//运维经理
|
SC_PARTNER_CUSTOMER_INFO customer = new SC_PARTNER_CUSTOMER_INFO(customerId).getInstanceById();
|
for(Map user : users) {
|
String groupType = ConvertUtil.obj2StrBlank(user.get("IDENTIFY"));
|
String userId = ConvertUtil.obj2StrBlank(user.get("ID"));
|
String username = ConvertUtil.obj2StrBlank(user.get("ZSXM"));
|
String unitKey = userId+groupType;
|
|
if(serviceUserCache.containsKey(unitKey)||unitKey.equals(customer.getYwjl_id()+Constants.ROLE_OPERATION)) {
|
user.put("type", 1);
|
Map mapuser = new HashMap();
|
mapuser.put("id", "1-"+groupType+"-"+userId+"-"+username);
|
mapuser.put("name", username);
|
if(Constants.ROLE_SERVICE.equals(groupType)){
|
mapuser.put("type", "kf");
|
}else if(Constants.ROLE_OPERATION.equals(groupType)){
|
mapuser.put("type", "ywjl");
|
}else if(Constants.ROLE_FLINE.equals(groupType)){
|
mapuser.put("type", "yx");
|
}else if(Constants.ROLE_SLINE.equals(groupType)){
|
mapuser.put("type", "ex");
|
}else if(Constants.ROLE_TLINE.equals(groupType)){
|
mapuser.put("type", "sx");
|
}
|
seluserList.add(mapuser);
|
} else {
|
user.put("type", 2);
|
}
|
|
|
if(groupType.equals(Constants.ROLE_SERVICE)) {
|
if(!removeUser.containsKey(unitKey)) {
|
if(!cacheMap.containsKey(Constants.KFRY)) {
|
user.put("usered", 1);
|
}
|
kfry.add(user);
|
removeUser.put(unitKey, user);
|
}
|
continue;
|
}
|
if(groupType.equals(Constants.ROLE_OPERATION)) {
|
if(!removeUser.containsKey(unitKey)) {
|
if(!cacheMap.containsKey(Constants.YCJSZC)) {
|
user.put("usered", 1);
|
}
|
yczc.add(user);
|
removeUser.put(unitKey, user);
|
}
|
continue;
|
}
|
if(groupType.equals(Constants.ROLE_FLINE)) {
|
if(!removeUser.containsKey(unitKey)) {
|
if(!cacheMap.containsKey(Constants.YXCL)) {
|
user.put("usered", 1);
|
}
|
yxgcs.add(user);
|
removeUser.put(unitKey, user);
|
}
|
continue;
|
}
|
if(groupType.equals(Constants.ROLE_SLINE)) {
|
if(!removeUser.containsKey(unitKey)) {
|
if(!cacheMap.containsKey(Constants.EXCL)) {
|
user.put("usered", 1);
|
}
|
exgcs.add(user);
|
removeUser.put(unitKey, user);
|
}
|
continue;
|
}
|
if(groupType.equals(Constants.ROLE_TLINE)) {
|
if(!removeUser.containsKey(unitKey)) {
|
if(!cacheMap.containsKey(Constants.SXCL)) {
|
user.put("usered", 1);
|
}
|
sxgcs.add(user);
|
removeUser.put(unitKey, user);
|
}
|
}
|
}
|
|
|
List<Map> zkfry = new ArrayList<Map>();
|
List<Map> zyczc = new ArrayList<Map>();
|
List<Map> zyxgcs = new ArrayList<Map>();
|
List<Map> zexgcs = new ArrayList<Map>();
|
List<Map> zsxgcs = new ArrayList<Map>();
|
|
for(Map group : groupList) {
|
String groupType = ConvertUtil.obj2StrBlank(group.get("IDENTIFY"));
|
|
|
String group_Id = ConvertUtil.obj2StrBlank(group.get("ID"));
|
String group_Name = ConvertUtil.obj2StrBlank(group.get("GROUPNAME"));
|
if(serviceGroupCache.containsKey(group_Id+groupType)) {
|
group.put("type", 1);
|
Map mapuser = new HashMap();
|
mapuser.put("id", "2-"+groupType+"-"+group_Id+"-"+group_Name);
|
mapuser.put("name", group_Name);
|
if(Constants.ROLE_SERVICE.equals(groupType)){
|
mapuser.put("type", "kf");
|
}else if(Constants.ROLE_OPERATION.equals(groupType)){
|
mapuser.put("type", "ywjl");
|
}else if(Constants.ROLE_FLINE.equals(groupType)){
|
mapuser.put("type", "yx");
|
}else if(Constants.ROLE_SLINE.equals(groupType)){
|
mapuser.put("type", "ex");
|
}else if(Constants.ROLE_TLINE.equals(groupType)){
|
mapuser.put("type", "sx");
|
}
|
seluserList.add(mapuser);
|
} else {
|
group.put("type", 2);
|
}
|
|
if(groupType.equals(Constants.ROLE_FLINE)) {
|
if(!cacheMap.containsKey(Constants.YXCL)) {
|
group.put("usered", 1);
|
}
|
zyxgcs.add(group);
|
continue;
|
}
|
if(groupType.equals(Constants.ROLE_SLINE)) {
|
if(!cacheMap.containsKey(Constants.EXCL)) {
|
group.put("usered", 1);
|
}
|
zexgcs.add(group);
|
continue;
|
}
|
if(groupType.equals(Constants.ROLE_TLINE)) {
|
if(!cacheMap.containsKey(Constants.SXCL)) {
|
group.put("usered", 1);
|
}
|
zsxgcs.add(group);
|
}
|
}
|
|
Map jskfry = new HashMap();
|
Map jsyczc = new HashMap();
|
Map jsyxgcs = new HashMap();
|
Map jsexgcs = new HashMap();
|
Map jssxgcs = new HashMap();
|
Map param = new HashMap();
|
String rolesql = "SELECT ID,ROLENAME FROM AC_ROLE WHERE IDENTIFY = :identify";
|
param.put("identify", Constants.ROLE_SERVICE);
|
jskfry = baseDao.queryForMap(rolesql,param);
|
param.put("identify", Constants.ROLE_OPERATION);
|
jsyczc = baseDao.queryForMap(rolesql,param);
|
param.put("identify", Constants.ROLE_FLINE);
|
jsyxgcs = baseDao.queryForMap(rolesql,param);
|
param.put("identify", Constants.ROLE_SLINE);
|
jsexgcs = baseDao.queryForMap(rolesql,param);
|
param.put("identify", Constants.ROLE_TLINE);
|
jssxgcs = baseDao.queryForMap(rolesql,param);
|
|
Map resultMap = new HashMap();
|
resultMap.put("kfry", kfry);
|
resultMap.put("yczc", yczc);
|
resultMap.put("yxgcs", yxgcs);
|
resultMap.put("exgcs", exgcs);
|
resultMap.put("sxgcs", sxgcs);
|
|
resultMap.put("zkfry", zkfry);
|
resultMap.put("zyczc", zyczc);
|
resultMap.put("zyxgcs", zyxgcs);
|
resultMap.put("zexgcs", zexgcs);
|
resultMap.put("zsxgcs", zsxgcs);
|
|
resultMap.put("jskfry", jskfry);
|
resultMap.put("jsyczc", jsyczc);
|
resultMap.put("jsyxgcs", jsyxgcs);
|
resultMap.put("jsexgcs", jsexgcs);
|
resultMap.put("jssxgcs", jssxgcs);
|
|
int size = 1;
|
|
if(cacheMap.containsKey(Constants.KFRY)) {
|
resultMap.put("kf", 1);
|
size++;
|
} else {
|
resultMap.put("kf", 2);
|
}
|
if(cacheMap.containsKey(Constants.YCJSZC)) {
|
resultMap.put("sjjl", 1);
|
size++;
|
} else {
|
resultMap.put("sjjl", 2);
|
}
|
if(cacheMap.containsKey(Constants.YXCL)) {
|
resultMap.put("yx", 1);
|
size++;
|
} else {
|
resultMap.put("yx", 2);
|
}
|
if(cacheMap.containsKey(Constants.EXCL)) {
|
resultMap.put("ex", 1);
|
size++;
|
} else {
|
resultMap.put("ex", 2);
|
}
|
if(cacheMap.containsKey(Constants.SXCL)) {
|
resultMap.put("sx", 1);
|
size++;
|
} else {
|
resultMap.put("sx", 2);
|
}
|
|
resultMap.put("size", size);
|
resultMap.put("seluserList", seluserList);
|
return resultMap;
|
}
|
|
public Map getCurrentNode(String flowId) {
|
String selectSql = "SELECT B.NODE_TEMPLATE_ID FROM WORKFLOW_BASE A,WORKFLOW_NODE B WHERE A.CURRENT_NODE_ID = B.ID AND A.ID = :id";
|
return baseDao.queryForMap(selectSql,new SqlParameter("id",flowId));
|
}
|
|
@Override
|
public Map saveDispatchTask(HttpServletRequest request) {
|
String type = new String();
|
Map resultMap = new HashMap();
|
resultMap.put("result", 2);
|
String id = request.getParameter("id");
|
String selectUser = request.getParameter("userMsg");
|
|
|
|
String dealer_type = "1";
|
String dealUserId = new String();
|
String dealUserName = new String();
|
String state = new String();
|
|
String node_template_id = Constants.KFRY;
|
|
if(StringUtil.notEmpty(selectUser)) {
|
String[] userMsg = selectUser.split("-");
|
if(userMsg.length==4) {
|
dealer_type = userMsg[0];
|
String userType = userMsg[1];
|
dealUserId = userMsg[2];
|
dealUserName = userMsg[3];
|
if(userType.equals(Constants.ROLE_SERVICE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDFWT;
|
node_template_id = Constants.KFRY;
|
} else if(userType.equals(Constants.ROLE_OPERATION)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDYCJSZC;
|
node_template_id = Constants.YCJSZC;
|
} else if(userType.equals(Constants.ROLE_FLINE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDYX;
|
node_template_id = Constants.YXCL;
|
} else if(userType.equals(Constants.ROLE_SLINE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDEX;
|
node_template_id = Constants.EXCL;
|
} else if(userType.equals(Constants.ROLE_TLINE)) {
|
state = Constants.SC_WORKFLOW_INCIDENT_STATE_FPDSX;
|
node_template_id = Constants.SXCL;
|
}
|
}
|
}
|
|
|
if(StringUtil.notEmpty(dealUserId) && StringUtil.notEmpty(dealUserName)) {
|
//执行分派任务
|
|
WORKFLOW_BASE base = new WORKFLOW_BASE(id).getInstanceById();
|
|
|
|
NodeDealEntity entity = new NodeDealEntity();
|
entity.setDealer_type(3);
|
List<Map> dealerList = new ArrayList<Map>();
|
if(dealer_type.equals("1")) {
|
entity.setBefore_Dealer_type(2);
|
Map map = new HashMap();
|
map.put("USER_ID", dealUserId);
|
map.put("USER_NAME", dealUserName);
|
map.put("IS_ADMIN", "1");
|
|
dealerList.add(map);
|
|
entity.setDealerList(dealerList);
|
type = "2";
|
} else {
|
if(dealer_type.equals("2")){
|
type = "3";
|
}else{
|
type = "1";
|
}
|
entity.setBefore_Dealer_type(1);
|
entity.setRoleID(dealUserId);
|
entity.setRoleName(dealUserName);
|
|
//查询改组下面的所有人员信息
|
String selectUserSql = "SELECT B.ID AS USER_ID,B.ZSXM AS USER_NAME FROM AC_USER_REF_ROLE A,GG_USER B WHERE A.JSBH = :roleId AND A.YHBH = B.ID";
|
dealerList = baseDao.queryForList(selectUserSql,new SqlParameter("roleId",dealUserId));
|
if(dealerList == null || dealerList.size() == 0){
|
String groupusersql = "SELECT B.ID AS USER_ID ,B.ZSXM AS USER_NAME FROM AC_ROLE_GROUP_USER A,GG_USER B WHERE A.USER_ID = B.ID AND A.GROUP_ID = :groupId AND A.STATE = 1 ";
|
dealerList = baseDao.queryForList(groupusersql,new SqlParameter("groupId",dealUserId));
|
if(dealerList == null || dealerList.size() == 0){
|
resultMap.put("result", 2);
|
resultMap.put("nouser", 2);
|
return resultMap;
|
}
|
}
|
}
|
|
|
String bz = request.getParameter("bz");
|
|
NodeFinishEntity finishEntity = new NodeFinishEntity();
|
finishEntity.setDeal_result(1);
|
finishEntity.setDeal_note_title("节点转至 :" + dealUserName);
|
finishEntity.setDeal_note(bz);
|
|
|
|
WORKFLOW_NODE node = new WORKFLOW_NODE(base.getCurrent_node_id()).getInstanceById();
|
boolean canFinish = workflowCoreService.finishNode(base, node, finishEntity);
|
if (canFinish) {
|
workflowBusinessService.toNode(base, node_template_id, entity);
|
}
|
|
|
//更新事件状态
|
String updateIncidentSql = "UPDATE SC_WORKFLOW_INCIDENT SET STATE = :state WHERE ID = :incidentId ";
|
baseDao.execute(updateIncidentSql, new SqlParameter("state",state).addValue("incidentId", base.getBusiness_id()));
|
|
Map user = WebUtil.getEngineerMsg(request);
|
String userId = ConvertUtil.obj2StrBlank(user.get("ID"));
|
String userName = ConvertUtil.obj2StrBlank(user.get("ZSXM"));
|
|
|
String flowId = base.getId();
|
|
//增加事件处理记录
|
GG_RECORD record = new GG_RECORD();
|
record.setDeal_content("指派任务:"+userName+"将事件指派给了"+dealUserName);
|
record.setDeal_time(DateUtil.getCurrentDate14());
|
record.setDeal_user_id("1");
|
record.setDeal_user_name(userName);
|
record.setBusiness_id(base.getId());
|
|
recordService.addRecord(record);
|
|
|
|
String wxUrl = WechatConstants.ORDER_INCIDENT_DETAIL_ADDRESS+"?orderId="+base.getBusiness_id()+"&orderType="+Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT;
|
//发送消息
|
GG_MESSAGE message = new GG_MESSAGE();
|
message.setTitle(base.getWfname())
|
.setContent(base.getWfname())
|
.setSender_id(userId)
|
.setSender_name(userName)
|
.setSend_time(DateUtil.getCurrentDate14())
|
.setBusiness_id(base.getBusiness_id())
|
.setWeb_url(Constants.INCIDENT_WEB_MSG_URL+"?flowId="+base.getId()+"&orderId="+base.getBusiness_id())
|
.setWx_url(wxUrl)
|
.setOrder_code(base.getOrder_code())
|
.setType(Constants.GG_MESSAGE_TYPE_SJGL);
|
messageFacade.doSendMessage(message, dealerList);
|
resultMap.put("result", 1);
|
//type = ConvertUtil.obj2StrBlank(entity.getBefore_Dealer_type());
|
|
}
|
|
SysInfoMsg msg = new SysInfoMsg(type,dealUserName,Constants.incidentNode.get(node_template_id));
|
|
resultMap.put("msg", msg);
|
return resultMap;
|
}
|
@Override
|
public int checkFz(Map param) {
|
String sql="select count(id) from AC_ROLE_GROUP_USER where GROUP_ID=:id and STATE=1";
|
return baseDao.queryForInteger(sql, param);
|
}
|
|
@Override
|
public int checkJs(Map param) {
|
String sql="select count(id) from AC_USER_REF_ROLE where JSBH=:id";
|
return baseDao.queryForInteger(sql, param);
|
}
|
|
|
}
|