//package com.weaver.seconddev.interfaces.workflow.entity;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.cloudstore.dev.api.bean.MessageBean;
//import com.cloudstore.dev.api.bean.MessageType;
//import com.cloudstore.dev.api.util.Util_Message;
//import org.apache.commons.lang.StringUtils;
//import  com.weaver.seconddev.interfaces.eipoa.PortalPlanService;
//import  com.weaver.seconddev.interfaces.eipoa.SI_HTPortalPlan_OUTServiceStub.InsertPlan;
//import  com.weaver.seconddev.interfaces.swfa.BillFieldUtil;
//import weaver.meeting.Maint.MeetingRoomComInfo;
//import java.net.URLEncoder;
//import java.text.SimpleDateFormat;
//import java.util.*;
//import com.weaver.common.i18n.tool.util.I18nContextUtil;
//import com.weaver.verupgrade.conn.CONN_TYPE;
//import org.springframework.core.env.Environment;
//import java.lang.*;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import com.weaver.verupgrade.conn.RecordSet;
//import com.weaver.verupgrade.general.BaseBean;
//import com.weaver.verupgrade.general.Util;
//
//public class Meeting extends BaseBean implements Runnable {
//
//    private static final org.slf4j.Logger logger_b81e0cc9 = LoggerFactory.getLogger(Meeting.class);
//
//    private String requestid;
//
//    private static BillFieldUtil util = new BillFieldUtil();
//
//    private static String systemId = "SYS006";
//
//    private static String password = "123456";
//
//    // 测试86，正式22
//    private static String type = "22";
//
//    public Meeting(String requestid) {
//        this.requestid = requestid;
//    }
//
//    @Override
//    public void run() {
//        logger_b81e0cc9.error(String.valueOf("requestid:" + requestid));
//        RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String url = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.pc_url")).trim();
//        String address = "";
//        String contacter = "";
//        List<String> sendList = new ArrayList<String>();
//        String id = "";
//        try {
//            String sql = "select top 1 m.ApproveID,t.name AS meetingtype,m.Contacter,m.MeetingName,m.address,m.customizeAddress,m.resources,m.BeginDate," + "m.BeginTime,m.EndDate,m.EndTime,m.description,L.operateuserid,L.operatedate,L.operatetime from bill_meeting m INNER JOIN mt_type t " + "ON m.meetingtype = t.id inner join MeetingLog L on m.ApproveID = L.relatedid " + "where m.requestid=" + requestid;
//            String poolname = CONN_TYPE.workflow.getType();
//            // TODO E10执行sql方法第二参数必须指定源，默认使用流程源，单体客户无需修改，微服务/组合客户需根据查询表所属服务切换源，或使用外部数据源
//            rs.executeSql(sql, poolname);
//            Map<String, String> map = new HashMap<String, String>();
//            if (rs.next()) {
//                id = Util.null2String(rs.getString("ApproveID"));
//                String meetingtype = Util.null2String(rs.getString("meetingtype"));
//                String name = Util.null2String(rs.getString("MeetingName"));
//                contacter = Util.null2String(rs.getString("Contacter"));
//                address = Util.null2String(rs.getString("address"));
//                String customizeAddress = Util.null2String(rs.getString("customizeAddress"));
//                String hrmmembers = Util.null2String(rs.getString("resources"));
//                String begindate = Util.null2String(rs.getString("BeginDate"));
//                String begintime = Util.null2String(rs.getString("BeginTime"));
//                String enddate = Util.null2String(rs.getString("EndDate"));
//                String endtime = Util.null2String(rs.getString("EndTime"));
//                String creater = Util.null2String(rs.getString("operateuserid"));
//                String createdate = Util.null2String(rs.getString("operatedate"));
//                String createtime = Util.null2String(rs.getString("operatetime"));
//                String description = Util.null2String(rs.getString("description"));
//                String userId = getWorkcode(hrmmembers);
//                String fromName = util.getName(creater);
//                String fromWorkcode = util.getWorkcode(creater);
//                String itemId = systemId + fromWorkcode + sdf.parse(createdate + " " + createtime.substring(0, 5) + ":00").getTime() + id;
//                String location = "";
//                sendList.add(contacter);
//                if (!"".equals(address)) {
//                    MeetingRoomComInfo info = new MeetingRoomComInfo();
//                    location = info.getMeetingRoomInfoname(address);
//                    logger_b81e0cc9.error(String.valueOf("会议地点：" + location));
//                } else {
//                    location = customizeAddress;
//                }
//                map.put("id", id);
//                map.put("userId", userId);
//                map.put("systemId", systemId);
//                map.put("password", password);
//                map.put("itemId", itemId);
//                map.put("title", name);
//                map.put("url", url + URLEncoder.encode(Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.meeting_url")).trim() + id));
//                map.put("type", type);
//                map.put("startDate", begindate + " " + begintime + ":00");
//                map.put("endDate", enddate + " " + endtime + ":00");
//                map.put("status", "0");
//                map.put("priority", "0");
//                map.put("formName", fromName);
//                map.put("mobileUrl", url + URLEncoder.encode(Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.meeting_mobileUrl")).trim() + id));
//                map.put("category", meetingtype);
//                map.put("source", "1");
//                map.put("content", "会议地点：" + location + "\r\n会议内容：" + description);
//            }
//            if (!"".equals(address)) {
//                String[] str = address.split(",");
//                MessageType messageType = MessageType.newInstance(506);
//                for (int a = 0; a < str.length; a++) {
//                    int adr = Integer.parseInt(str[a]);
//                    if (adr <= 9 || (adr >= 93 && adr <= 97) || adr == 166 || adr == 167) {
//                        logger_b81e0cc9.error(String.valueOf("开始微信提醒预约人：" + I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.MeetingReminderStart")));
//                        // InterfaceUtil.sendMsg(sendList, ",2a202436404f44368a0a7b50295d6273,", "", getPropValue("remindforweixin","MeetingReminderStart"), 3);
//                        MessageBean messageBean = Util_Message.createMessage(messageType, new HashSet(sendList), I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.MeetingReminderStart"), I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.MeetingReminderStart"), "", "");
//                        messageBean.setCreater(1);
//                        Util_Message.store(messageBean);
//                        String senduser = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.senduser"));
//                        if (!"".equals(senduser)) {
//                            String[] users = senduser.split(",");
//                            List<String> userlist = Arrays.asList(users);
//                            // Map sendmap = new HashMap();
//                            String meetingurl = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.url")) + id;
//                            // sendmap.put("mobilemodeUrl", meetingurl);
//                            logger_b81e0cc9.error(String.valueOf("开始微信提醒预约人：" + I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.remind")));
//                            // InterfaceUtil.sendMsg(userlist, ",15418c34550c4271956f925ba4386b10,", id, getPropValue("remindforweixin","remind"), 15,sendmap);
//                            MessageType messageType1 = MessageType.newInstance(538);
//                            MessageBean messageBean1 = Util_Message.createMessage(messageType1, new HashSet(userlist), I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.remind"), I18nContextUtilcus.getBean(Environment.class).getProperty("remindforweixin.remind"), "", meetingurl);
//                            messageBean1.setCreater(1);
//                            Util_Message.store(messageBean1);
//                        }
//                    }
//                }
//            }
//            PortalPlanService service = new PortalPlanService();
//            InsertPlan insertData = JSONObject.parseObject(JSON.toJSONString(map), InsertPlan.class);
//            String[] str = service.insertPlan(insertData);
//            logger_b81e0cc9.error(String.valueOf("推送会议到门户结束--" + map.get("id") + "--" + str[1]));
//        } catch (Exception e) {
//            logger_b81e0cc9.error(String.valueOf("推送会议到门户失败--" + requestid + "--" + e.toString()));
//        }
//    }
//
//    public String getWorkcode(String ids) {
//        String[] arr = ids.split(",");
//        Set<String> list = new HashSet<String>();
//        for (int i = 0; i < arr.length; i++) {
//            if (!"".equals(arr[i])) {
//                list.add(util.getWorkcode(arr[i]));
//            }
//        }
//        return StringUtils.join(list.toArray(), ";");
//    }
//}
