Authored by linlong

短信发送优化

@@ -73,6 +73,8 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -73,6 +73,8 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
73 73
74 public static final int BATCH_MESSAGE_NUMBER = 500; 74 public static final int BATCH_MESSAGE_NUMBER = 500;
75 75
  76 + public static final int INSERT_MESSAGE_NUMBER = 500;
  77 +
76 public static final short SMS_STATUS_SUCCESS = 1; //短信发送成功状态 78 public static final short SMS_STATUS_SUCCESS = 1; //短信发送成功状态
77 79
78 public static final short SMS_STATUS_FAIL = 0; 80 public static final short SMS_STATUS_FAIL = 0;
@@ -159,125 +161,6 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -159,125 +161,6 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
159 return pageChannelGroupRspBO; 161 return pageChannelGroupRspBO;
160 } 162 }
161 163
162 -// @Override  
163 -// public int sendMessage(ChannelMessageRequestBO channelGroupRequestBO, int sendUserId) {  
164 -// logger.info("enter sendMessage. param channelGroupRequestBO{}", channelGroupRequestBO);  
165 -// int groupId = channelGroupRequestBO.getGroupId();  
166 -// String content = channelGroupRequestBO.getContent();  
167 -//  
168 -// //1.根据groupId查询条件  
169 -// List<ChannelGroupCondition> conditions = channelGroupConditionDAO.selectByGroupId(groupId);  
170 -// logger.info("sendMessage:conditions is {}", conditions);  
171 -// Map<String, Object> params = conditions.stream().collect(Collectors.toMap(ChannelGroupCondition::getKey, ChannelGroupCondition::getValue));  
172 -//  
173 -// //2.根据条件分批查询手机号  
174 -// int total = channelUserDAO.selectCount(params);  
175 -// if (total == 0) {  
176 -// logger.info("not find users to send message,param channelGroupRequestBO{}", channelGroupRequestBO);  
177 -// return 0;  
178 -// }  
179 -// Set<String> mobileSet = Sets.newHashSet();  
180 -// //2.1分批从数据库中查询,每次1000,使用mobileSet去重  
181 -// for (int i = 0; i < total; i += BATCH_MESSAGE_NUMBER) {  
182 -// List<ChannelUser> channelUsers = channelUserDAO.selectPage(params, i, i + BATCH_MESSAGE_NUMBER);  
183 -// Set<String> channelMobiles = channelUsers.stream().map(ChannelUser::getMobile).collect(Collectors.toSet());  
184 -// mobileSet.addAll(channelMobiles);  
185 -// }  
186 -//  
187 -// //2.2查询出来的手机号剔除黑名单数据  
188 -// List<String> blackList = channelSmsBlackDAO.selectAll();  
189 -// mobileSet.removeAll(blackList);  
190 -//  
191 -// //2.3添加默认运营的号码  
192 -// List<String> businessMobileList = Arrays.asList(businessMobile.split(","));  
193 -// mobileSet.addAll(businessMobileList);  
194 -//  
195 -// //剔除黑名单后,发送手机号为空,返回  
196 -//// if (CollectionUtils.isEmpty(mobileSet)) {  
197 -//// logger.info("not find users to send message,param channelGroupRequestBO{}", channelGroupRequestBO);  
198 -//// return 0;  
199 -//// }  
200 -//  
201 -// //3.记录分组批次表  
202 -// int sendTime = DateUtils.getCurrentTimeSecond();  
203 -//  
204 -// UserInfoBO userInfoBO = null;  
205 -//  
206 -// try {  
207 -// userInfoBO = erpApiServiceHelper.getUserByPid(String.valueOf(sendUserId));  
208 -// } catch (Exception e) {  
209 -// logger.warn("call erpApiServiceHelper.getUserByPid occurs Exception,e is {}", e.getMessage());  
210 -// }  
211 -//  
212 -// String sendUserName = userInfoBO != null ? userInfoBO.getAccount() : "";  
213 -// ChannelGroupBatch channelGroupBatch = new ChannelGroupBatch(groupId, content, sendTime, sendUserId, sendUserName);  
214 -// channelGroupBatchDAO.insertSelective(channelGroupBatch);  
215 -// logger.info("sendMessage:insert channelGroupBatch,channelGroupBatch ={}", channelGroupBatch);  
216 -// int groupBatchId = channelGroupBatch.getId();  
217 -//  
218 -// List<String> mobileList = Lists.newArrayList(mobileSet);  
219 -// List<ChannelSmsDetail> smsDetails = Lists.newArrayList();  
220 -// //4.用户去重、黑名单后,分批发送短信  
221 -// List<String> mobiles = null;  
222 -// int successCount = 0;  
223 -// for (int i = 0; i < mobileList.size(); i += BATCH_MESSAGE_NUMBER) {  
224 -// if (i + BATCH_MESSAGE_NUMBER > mobileList.size()) {  
225 -// mobiles = mobileList.subList(i, mobileList.size());  
226 -// } else {  
227 -// mobiles = mobileList.subList(i, i + BATCH_MESSAGE_NUMBER);  
228 -// }  
229 -// String mobile = StringUtils.join(mobiles.toArray(), ",");  
230 -// //调用SDK发送短信接口  
231 -// SendMessageRspBo sendMessageRspBo = null;  
232 -//  
233 -// try {  
234 -// sendMessageRspBo = sendCrmMessage.generalSceneMsg(mobile, content);  
235 -// logger.info("sendMessage:call generalSceneMsg,sendMessageRspBo is {}", sendMessageRspBo);  
236 -// } catch (Exception e) {  
237 -// logger.warn("sendMessage:call generalSceneMsg occurs Exception,e is {}", e.getMessage());  
238 -// }  
239 -//  
240 -//  
241 -// //4.1短信发送成功,记录短信日志表(状态为1)  
242 -// if (sendMessageRspBo != null && sendMessageRspBo.getCode() == 200 && sendMessageRspBo.getMessage().equals("SUCCESS")) {  
243 -// for (String sms : mobiles) {  
244 -// ChannelSmsDetail channelSmsDetail = new ChannelSmsDetail(sms, groupBatchId, SMS_STATUS_SUCCESS, sendTime);  
245 -// smsDetails.add(channelSmsDetail);  
246 -// successCount++;  
247 -// }  
248 -// } else {  
249 -// //4.2短信发送失败,打印日志,记录短信日志表(状态为0)和分组批次表  
250 -// for (String sms : mobiles) {  
251 -// ChannelSmsDetail channelSmsDetail = new ChannelSmsDetail(sms, groupBatchId, SMS_STATUS_FAIL, sendTime);  
252 -// smsDetails.add(channelSmsDetail);  
253 -// }  
254 -// }  
255 -// }  
256 -//  
257 -// //异步记录日志表,以后查询日志方便  
258 -// try {  
259 -// saveSmsDetail(smsDetails);  
260 -// } catch (Exception e) {  
261 -// logger.error("", e);  
262 -// }  
263 -// logger.info("sendMessage:insert channelSmsDetai,smsDetails is {}", smsDetails);  
264 -//  
265 -// //5.修改分组表的分组人数、发送时间、修改时间、内容、发送人  
266 -// ChannelGroup channelGroup = new ChannelGroup();  
267 -// channelGroup.setId(groupId);  
268 -// channelGroup.setUpdateTime(sendTime);  
269 -// channelGroup.setGroupNumber(mobileSet.size());  
270 -// channelGroup.setSuccessCount(successCount);  
271 -// channelGroup.setSendTime(sendTime);  
272 -// channelGroup.setContent(content);  
273 -// channelGroup.setSendUserName(sendUserName);  
274 -// channelGroup.setSendUser(sendUserId);  
275 -// channelGroup.setSmsNumber(groupBatchId);  
276 -// channelGroup.setStatus(1);  
277 -// int count = channelGroupDAO.updateByPrimaryKeySelective(channelGroup);  
278 -// logger.info("sendMessage:update channelGroup,channelGroup is {}", channelGroup);  
279 -// return count;  
280 -// }  
281 164
282 @Override 165 @Override
283 public int sendMessage(ChannelMessageRequestBO channelGroupRequestBO, int sendUserId) { 166 public int sendMessage(ChannelMessageRequestBO channelGroupRequestBO, int sendUserId) {
@@ -300,6 +183,7 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -300,6 +183,7 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
300 channelGroup.setContent(content); 183 channelGroup.setContent(content);
301 channelGroup.setSendUserName(sendUserName); 184 channelGroup.setSendUserName(sendUserName);
302 channelGroup.setSendUser(sendUserId); 185 channelGroup.setSendUser(sendUserId);
  186 + channelGroup.setSendTime(DateUtils.getCurrentTimeSecond());
303 channelGroup.setStatus(2); //状态2:发送中 187 channelGroup.setStatus(2); //状态2:发送中
304 int count = channelGroupDAO.updateByPrimaryKeySelective(channelGroup); 188 int count = channelGroupDAO.updateByPrimaryKeySelective(channelGroup);
305 logger.info("sendMessage:sending message,channelGroup is {}", channelGroup); 189 logger.info("sendMessage:sending message,channelGroup is {}", channelGroup);
@@ -334,7 +218,7 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -334,7 +218,7 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
334 } 218 }
335 Set<String> mobileSet = Sets.newHashSet(); 219 Set<String> mobileSet = Sets.newHashSet();
336 //2.1分批从数据库中查询,每次500,使用mobileSet去重 220 //2.1分批从数据库中查询,每次500,使用mobileSet去重
337 - 221 + int queryCount = 0; //查询失败手机号
338 for (int i = 0; i < total; i += BATCH_MESSAGE_NUMBER) { 222 for (int i = 0; i < total; i += BATCH_MESSAGE_NUMBER) {
339 try{ 223 try{
340 List<ChannelUser> channelUsers = channelUserDAO.selectPage(params, i, i + BATCH_MESSAGE_NUMBER); 224 List<ChannelUser> channelUsers = channelUserDAO.selectPage(params, i, i + BATCH_MESSAGE_NUMBER);
@@ -342,12 +226,26 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -342,12 +226,26 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
342 mobileSet.addAll(channelMobiles); 226 mobileSet.addAll(channelMobiles);
343 }catch (Exception e){ 227 }catch (Exception e){
344 //查询超时等异常 228 //查询超时等异常
  229 + if(total-i>BATCH_MESSAGE_NUMBER){
  230 + queryCount +=BATCH_MESSAGE_NUMBER;
  231 + }else{
  232 + //最后一次查询出现异常,失败数不是批量值
  233 + queryCount = queryCount+total-i;
  234 + }
345 logger.warn("sendMessage:query users fail."); 235 logger.warn("sendMessage:query users fail.");
346 } 236 }
347 } 237 }
348 238
349 - //2.2查询出来的手机号剔除黑名单数据  
350 - List<String> blackList = channelSmsBlackDAO.selectAll(); 239 + //2.2查询出来的手机号剔除黑名单数据,也分批查询黑名单
  240 + Integer blackTotal = channelSmsBlackDAO.selectCount();
  241 + List<String> blackList = Lists.newArrayList();
  242 + if(blackTotal!=null){
  243 + for (int i = 0; i < blackTotal; i += BATCH_MESSAGE_NUMBER) {
  244 + List<String> temp = channelSmsBlackDAO.selectAll(i,i+BATCH_MESSAGE_NUMBER);
  245 + blackList.addAll(temp);
  246 + }
  247 + }
  248 +
351 mobileSet.removeAll(blackList); 249 mobileSet.removeAll(blackList);
352 250
353 //2.3添加默认运营的号码 251 //2.3添加默认运营的号码
@@ -366,8 +264,9 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -366,8 +264,9 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
366 264
367 //4.用户去重、黑名单后,分批发送短信 265 //4.用户去重、黑名单后,分批发送短信
368 List<String> mobiles = null; 266 List<String> mobiles = null;
369 - int successCount = 0;  
370 - int failCount = 0; 267 + int successCount = 0; //发送成功短信数
  268 + int failCount = 0; //发送失败短信数
  269 +
371 for (int i = 0; i < mobileList.size(); i += BATCH_MESSAGE_NUMBER) { 270 for (int i = 0; i < mobileList.size(); i += BATCH_MESSAGE_NUMBER) {
372 if (i + BATCH_MESSAGE_NUMBER > mobileList.size()) { 271 if (i + BATCH_MESSAGE_NUMBER > mobileList.size()) {
373 mobiles = mobileList.subList(i, mobileList.size()); 272 mobiles = mobileList.subList(i, mobileList.size());
@@ -386,7 +285,7 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -386,7 +285,7 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
386 } 285 }
387 286
388 287
389 - //4.1短信发送成功,记录短信日志表(状态为1) 288 +// 4.1短信发送成功,记录短信日志表(状态为1)
390 if (sendMessageRspBo != null && sendMessageRspBo.getCode() == 200 && sendMessageRspBo.getMessage().equals("SUCCESS")) { 289 if (sendMessageRspBo != null && sendMessageRspBo.getCode() == 200 && sendMessageRspBo.getMessage().equals("SUCCESS")) {
391 for (String sms : mobiles) { 290 for (String sms : mobiles) {
392 ChannelSmsDetail channelSmsDetail = new ChannelSmsDetail(sms, groupBatchId, SMS_STATUS_SUCCESS, sendTime); 291 ChannelSmsDetail channelSmsDetail = new ChannelSmsDetail(sms, groupBatchId, SMS_STATUS_SUCCESS, sendTime);
@@ -403,22 +302,32 @@ public class ChannelGroupServiceImpl implements IChannelGroupService { @@ -403,22 +302,32 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
403 } 302 }
404 } 303 }
405 304
406 - //5.记录短信明细表  
407 - channelSmsDetailDAO.batchInsert(smsDetails);  
408 - logger.info("sendMessage:end insert channelSmsDetai,smsDetails is {}", smsDetails);  
409 305
410 - //6.发送成功更新发送人、发送时间、状态等 306 +
  307 + //5.发送成功更新发送人、发送时间、状态等
411 ChannelGroup channelGroup = new ChannelGroup(); 308 ChannelGroup channelGroup = new ChannelGroup();
412 channelGroup.setId(groupId); 309 channelGroup.setId(groupId);
413 channelGroup.setUpdateTime(sendTime); 310 channelGroup.setUpdateTime(sendTime);
414 channelGroup.setGroupNumber(mobileSet.size()); 311 channelGroup.setGroupNumber(mobileSet.size());
415 channelGroup.setSuccessCount(successCount); 312 channelGroup.setSuccessCount(successCount);
416 - channelGroup.setSendTime(sendTime);  
417 channelGroup.setSmsNumber(groupBatchId); 313 channelGroup.setSmsNumber(groupBatchId);
418 channelGroup.setStatus(1); 314 channelGroup.setStatus(1);
419 channelGroup.setFailCount(failCount); 315 channelGroup.setFailCount(failCount);
  316 + channelGroup.setQueryCount(queryCount);
420 channelGroupDAO.updateByPrimaryKeySelective(channelGroup); 317 channelGroupDAO.updateByPrimaryKeySelective(channelGroup);
421 318
  319 + //6.最后再更新日志表,批量更新一次1000
  320 + List<ChannelSmsDetail> temp = null;
  321 + for(int i=0;i<smsDetails.size();i++){
  322 + if (i + INSERT_MESSAGE_NUMBER > mobileList.size()) {
  323 + temp = smsDetails.subList(i, mobileList.size());
  324 + } else {
  325 + temp = smsDetails.subList(i, i + INSERT_MESSAGE_NUMBER);
  326 + }
  327 + channelSmsDetailDAO.batchInsert(temp);
  328 + }
  329 + logger.info("sendMessage:end insert channelSmsDetai,smsDetails is {}", smsDetails);
  330 +
422 logger.info("sendMessage:end sendSmsDetail,groupId={},content={},sendUserId={},sendUserName={}", groupId,content,sendUserId,sendUserName); 331 logger.info("sendMessage:end sendSmsDetail,groupId={},content={},sendUserId={},sendUserName={}", groupId,content,sendUserId,sendUserName);
423 } 332 }
424 }); 333 });
@@ -26,7 +26,13 @@ public interface IChannelSmsBlackDAO { @@ -26,7 +26,13 @@ public interface IChannelSmsBlackDAO {
26 * 查询所有的黑名单 26 * 查询所有的黑名单
27 * @return 27 * @return
28 */ 28 */
29 - List<String> selectAll(); 29 + List<String> selectAll(@Param("offset") int offset, @Param("rows") int rows);
  30 +
  31 + /**
  32 + * 查询黑名单总数
  33 + * @return
  34 + */
  35 + Integer selectCount();
30 36
31 /** 37 /**
32 * 批量添加黑名单 38 * 批量添加黑名单
@@ -35,6 +35,16 @@ public class ChannelGroup { @@ -35,6 +35,16 @@ public class ChannelGroup {
35 35
36 private Integer failCount; 36 private Integer failCount;
37 37
  38 + private Integer queryCount;
  39 +
  40 + public Integer getQueryCount() {
  41 + return queryCount;
  42 + }
  43 +
  44 + public void setQueryCount(Integer queryCount) {
  45 + this.queryCount = queryCount;
  46 + }
  47 +
38 public Integer getSendTime() { 48 public Integer getSendTime() {
39 return sendTime; 49 return sendTime;
40 } 50 }
@@ -17,9 +17,10 @@ @@ -17,9 +17,10 @@
17 <result column="send_userName" property="sendUserName" jdbcType="VARCHAR" /> 17 <result column="send_userName" property="sendUserName" jdbcType="VARCHAR" />
18 <result column="update_time" property="updateTime" jdbcType="INTEGER" /> 18 <result column="update_time" property="updateTime" jdbcType="INTEGER" />
19 <result column="fail_count" property="failCount" jdbcType="INTEGER" /> 19 <result column="fail_count" property="failCount" jdbcType="INTEGER" />
  20 + <result column="query_count" property="queryCount" jdbcType="INTEGER" />
20 </resultMap> 21 </resultMap>
21 <sql id="Base_Column_List" > 22 <sql id="Base_Column_List" >
22 - id, name, group_number,sms_number,success_count, create_time, create_user, create_userName, content,status,send_time,send_user,send_userName,update_time,fail_count 23 + id, name, group_number,sms_number,success_count, create_time, create_user, create_userName, content,status,send_time,send_user,send_userName,update_time,fail_count,query_count
23 </sql> 24 </sql>
24 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 25 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
25 select 26 select
@@ -33,11 +34,11 @@ @@ -33,11 +34,11 @@
33 </delete> 34 </delete>
34 <insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true" > 35 <insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true" >
35 insert into channel_group (id, name, content,group_number,sms_number,success_count, 36 insert into channel_group (id, name, content,group_number,sms_number,success_count,
36 - create_time, create_user, create_userName,status,send_time,send_user,send_userName,update_time,fail_count 37 + create_time, create_user, create_userName,status,send_time,send_user,send_userName,update_time,fail_count,query_count
37 ) 38 )
38 values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},#{groupNumber,jdbcType=INTEGER},#{smsNumber,jdbcType=INTEGER},#{successCount,jdbcType=INTEGER}, 39 values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},#{groupNumber,jdbcType=INTEGER},#{smsNumber,jdbcType=INTEGER},#{successCount,jdbcType=INTEGER},
39 #{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 40 #{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
40 - #{sendTime,jdbcType=INTEGER}, #{sendUser,jdbcType=INTEGER}, #{sendUserName,jdbcType=VARCHAR}, #{updateTime,jdbcType=INTEGER},#{failCount,jdbcType=INTEGER} 41 + #{sendTime,jdbcType=INTEGER}, #{sendUser,jdbcType=INTEGER}, #{sendUserName,jdbcType=VARCHAR}, #{updateTime,jdbcType=INTEGER},#{failCount,jdbcType=INTEGER},#{queryCount,jdbcType=INTEGER}
41 ) 42 )
42 </insert> 43 </insert>
43 <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true"> 44 <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true">
@@ -64,6 +65,9 @@ @@ -64,6 +65,9 @@
64 <if test="failCount != null" > 65 <if test="failCount != null" >
65 fail_count, 66 fail_count,
66 </if> 67 </if>
  68 + <if test="queryCount != null" >
  69 + query_count,
  70 + </if>
67 <if test="createTime != null" > 71 <if test="createTime != null" >
68 create_time, 72 create_time,
69 </if> 73 </if>
@@ -111,6 +115,9 @@ @@ -111,6 +115,9 @@
111 <if test="failCount != null" > 115 <if test="failCount != null" >
112 #{failCount,jdbcType=INTEGER}, 116 #{failCount,jdbcType=INTEGER},
113 </if> 117 </if>
  118 + <if test="queryCount != null" >
  119 + #{queryCount,jdbcType=INTEGER},
  120 + </if>
114 <if test="createTime != null" > 121 <if test="createTime != null" >
115 #{createTime,jdbcType=INTEGER}, 122 #{createTime,jdbcType=INTEGER},
116 </if> 123 </if>
@@ -158,6 +165,9 @@ @@ -158,6 +165,9 @@
158 <if test="failCount != null" > 165 <if test="failCount != null" >
159 fail_count = #{failCount,jdbcType=INTEGER}, 166 fail_count = #{failCount,jdbcType=INTEGER},
160 </if> 167 </if>
  168 + <if test="queryCount != null" >
  169 + query_count = #{failCount,jdbcType=INTEGER},
  170 + </if>
161 <if test="createTime != null" > 171 <if test="createTime != null" >
162 create_time = #{createTime,jdbcType=INTEGER}, 172 create_time = #{createTime,jdbcType=INTEGER},
163 </if> 173 </if>
@@ -200,7 +210,8 @@ @@ -200,7 +210,8 @@
200 send_user = #{sendUser,jdbcType=INTEGER}, 210 send_user = #{sendUser,jdbcType=INTEGER},
201 send_userName = #{sendUserName,jdbcType=VARCHAR}, 211 send_userName = #{sendUserName,jdbcType=VARCHAR},
202 update_time = #{updateTime,jdbcType=INTEGER}, 212 update_time = #{updateTime,jdbcType=INTEGER},
203 - fail_count = #{failCount,jdbcType=INTEGER} 213 + fail_count = #{failCount,jdbcType=INTEGER},
  214 + query_count = #{queryCount,jdbcType=INTEGER},
204 where id = #{id,jdbcType=INTEGER} 215 where id = #{id,jdbcType=INTEGER}
205 </update> 216 </update>
206 <select id ="selectListCountByParam" resultType="java.lang.Integer"> 217 <select id ="selectListCountByParam" resultType="java.lang.Integer">
@@ -219,7 +230,7 @@ @@ -219,7 +230,7 @@
219 and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%') 230 and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%')
220 </if> 231 </if>
221 <if test="status != null" > 232 <if test="status != null" >
222 - and status = #{status,jdbcType=INTEGER} 233 + and status !=0
223 </if> 234 </if>
224 <if test="smsNumber != null" > 235 <if test="smsNumber != null" >
225 and sms_number = #{smsNumber,jdbcType=INTEGER} 236 and sms_number = #{smsNumber,jdbcType=INTEGER}
@@ -252,7 +263,7 @@ @@ -252,7 +263,7 @@
252 and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%') 263 and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%')
253 </if> 264 </if>
254 <if test="status != null" > 265 <if test="status != null" >
255 - and status = #{status,jdbcType=INTEGER} 266 + and status !=0
256 </if> 267 </if>
257 <if test="smsNumber != null" > 268 <if test="smsNumber != null" >
258 and sms_number = #{smsNumber,jdbcType=INTEGER} 269 and sms_number = #{smsNumber,jdbcType=INTEGER}
@@ -24,6 +24,12 @@ @@ -24,6 +24,12 @@
24 <select id="selectAll" resultType="java.lang.String"> 24 <select id="selectAll" resultType="java.lang.String">
25 select mobile 25 select mobile
26 from channel_sms_black 26 from channel_sms_black
  27 + ORDER BY create_time DESC
  28 + limit #{offset}, #{rows}
  29 + </select>
  30 + <select id="selectCount" resultType="java.lang.Integer">
  31 + select count(1)
  32 + from channel_sms_black
27 </select> 33 </select>
28 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 34 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
29 delete from channel_sms_black 35 delete from channel_sms_black
1 -<!DOCTYPE html>  
2 -<html >  
3 -<head>  
4 - <meta charset="UTF-8">  
5 - <title>Title</title>  
6 - <script src="/union/js/include.js"></script>  
7 - <script src="/union/js/ajaxfileupload.js"></script>  
8 -</head>  
9 -<body>  
10 -<table style="width: 100%;padding: 30px 30px 0px 30px">  
11 - <tbody>  
12 - <tr>  
13 - <td style="width:200px;">上传文件:</td>  
14 - <td>  
15 - <div id="batchImportDiv"></div>  
16 - </td>  
17 - </tr>  
18 - </tbody>  
19 -</table>  
20 -<div id="matchDiv" style="padding:30px;"></div>  
21 -</body>  
22 -<script type="text/javascript">  
23 - $(function () {  
24 - $("#batchImportDiv").fileUpload({  
25 - text: "请选择文件", //按钮文字  
26 - uploadInputName: "file", //上传文件的控件名称  
27 - url: contextPath + "/batch/import", //提交到后端的url  
28 - queryParams: {  
29 - type: "deviceIdMatchImport"  
30 - }, //提交到后端额外参数  
31 - showFileName: false, //上传成功后,是否显示文件名  
32 - onLoadSuccess: function (fileName, data) {  
33 - $.messager.show({  
34 - title: "提示",  
35 - msg: "匹配完成",  
36 - height: 250  
37 - });  
38 - var match = data.data;  
39 - var output = "匹配的内容</br>" ;  
40 - for(var i=0;i<match.length;i++){  
41 - output += match[i]+"</br>";  
42 - }  
43 - $("#matchDiv").append(output);  
44 - }  
45 - });  
46 -  
47 -  
48 - });  
49 -</script>  
50 -</html>  
@@ -164,11 +164,13 @@ @@ -164,11 +164,13 @@
164 width: 140, 164 width: 140,
165 align: "center", 165 align: "center",
166 formatter: function (value, rowData, rowIndex) { 166 formatter: function (value, rowData, rowIndex) {
  167 + if(rowData.status==2){
  168 + return "发送中,稍后刷新重试!"
  169 + }
167 if (rowData.content == null || rowData.content == '') { 170 if (rowData.content == null || rowData.content == '') {
168 return ""; 171 return "";
169 } else { 172 } else {
170 - var fail = rowData.groupNumber - value;  
171 - return "成功数" + value + ",失败数" + fail; 173 + return "成功数" + value + ",失败数" + rowData.failCount + "查询失败数:" + rowData.queryCount;
172 } 174 }
173 } 175 }
174 }, { 176 }, {
@@ -180,8 +182,8 @@ @@ -180,8 +182,8 @@
180 var str = ""; 182 var str = "";
181 if (rowData.content == null || rowData.content == '') { 183 if (rowData.content == null || rowData.content == '') {
182 str = "<a role='send' dataId='" + rowData.id + "' dataContent='" + rowData.content + "' style='margin-left:10px'>发送短信</a>"; 184 str = "<a role='send' dataId='" + rowData.id + "' dataContent='" + rowData.content + "' style='margin-left:10px'>发送短信</a>";
183 - }else{  
184 - str = "<a role='send' dataId='" + rowData.id + "' dataContent='" + rowData.content + "' style='margin-left:10px'>再次发送</a>"; 185 + } else {
  186 + str = "<a role='send' dataId='" + rowData.id + "' dataContent='" + rowData.content + "' style='margin-left:10px' >再次发送</a>";
185 } 187 }
186 str += "<a role='delete' dataId='" + rowData.id + "' style='margin-left:10px'>删除</a>"; 188 str += "<a role='delete' dataId='" + rowData.id + "' style='margin-left:10px'>删除</a>";
187 return str; 189 return str;
@@ -197,13 +199,26 @@ @@ -197,13 +199,26 @@
197 checkOnSelect: false, 199 checkOnSelect: false,
198 onLoadSuccess: function (data) { 200 onLoadSuccess: function (data) {
199 getCondition(data); 201 getCondition(data);
  202 +
200 $(this).myDatagrid("getPanel").find("a[role='send']").linkbutton({ 203 $(this).myDatagrid("getPanel").find("a[role='send']").linkbutton({
201 iconCls: "icon-more", 204 iconCls: "icon-more",
202 onClick: function () { 205 onClick: function () {
203 - sendMessage($(this).attr("dataId"),$(this).attr("dataContent")); 206 + sendMessage($(this).attr("dataId"), $(this).attr("dataContent"));
204 } 207 }
205 }); 208 });
206 209
  210 + var currentDate = getNowFormatDate();
  211 + for (var i = 0; i < data.list.length; i++) {
  212 + var obj = data.list[i].sendTime;
  213 + if(obj!=""){
  214 + obj = obj.substring(0,10);
  215 + }
  216 + if(currentDate == obj){
  217 + var btn = $(this).myDatagrid("getPanel").find("a[role='send']")[i];
  218 + $(btn).linkbutton("disable")
  219 + }
  220 + }
  221 +
207 $(this).myDatagrid("getPanel").find("a[role='delete']").linkbutton({ 222 $(this).myDatagrid("getPanel").find("a[role='delete']").linkbutton({
208 iconCls: "icon-more", 223 iconCls: "icon-more",
209 onClick: function () { 224 onClick: function () {
@@ -271,18 +286,18 @@ @@ -271,18 +286,18 @@
271 function showblackList() { 286 function showblackList() {
272 var div = $("<div>").appendTo($(window.self.document.body)); 287 var div = $("<div>").appendTo($(window.self.document.body));
273 window.self.$(div).myDialog({ 288 window.self.$(div).myDialog({
274 - modal : true,  
275 - collapsible : true,  
276 - cache : false,  
277 - title : "黑名单列表", 289 + modal: true,
  290 + collapsible: true,
  291 + cache: false,
  292 + title: "黑名单列表",
278 width: 600, 293 width: 600,
279 height: 600, 294 height: 600,
280 href: contextPath + "/html/channel/blackList.html", 295 href: contextPath + "/html/channel/blackList.html",
281 - buttons : [{  
282 - id : "closeBtn",  
283 - text : "关闭",  
284 - iconCls : "icon-cancel",  
285 - handler : function() { 296 + buttons: [{
  297 + id: "closeBtn",
  298 + text: "关闭",
  299 + iconCls: "icon-cancel",
  300 + handler: function () {
286 window.self.$(div).dialog('close'); 301 window.self.$(div).dialog('close');
287 } 302 }
288 }] 303 }]
@@ -315,7 +330,7 @@ @@ -315,7 +330,7 @@
315 }); 330 });
316 } 331 }
317 332
318 - function sendMessage(id,content) { 333 + function sendMessage(id, content) {
319 window.paramObject.sms = content; 334 window.paramObject.sms = content;
320 var div = $("<div>").appendTo($(document.body)); 335 var div = $("<div>").appendTo($(document.body));
321 var title = "发送短信"; 336 var title = "发送短信";
@@ -337,7 +352,7 @@ @@ -337,7 +352,7 @@
337 iconCls: "icon-save", 352 iconCls: "icon-save",
338 handler: function () { 353 handler: function () {
339 var content = $("#content").val(); 354 var content = $("#content").val();
340 - if(content.length>250){ 355 + if (content.length > 250) {
341 window.self.$.messager.alert("提示消息", "短信字数不能超过250!"); 356 window.self.$.messager.alert("提示消息", "短信字数不能超过250!");
342 } 357 }
343 $.post(contextPath + "/channel/sendMessage", {groupId: id, content: content}, function (data) { 358 $.post(contextPath + "/channel/sendMessage", {groupId: id, content: content}, function (data) {
@@ -403,7 +418,22 @@ @@ -403,7 +418,22 @@
403 addTooltip(content[id], 'condition-' + i); 418 addTooltip(content[id], 'condition-' + i);
404 } 419 }
405 }); 420 });
  421 + }
406 422
  423 + function getNowFormatDate() {
  424 + var date = new Date();
  425 + var seperator1 = "-";
  426 + var year = date.getFullYear();
  427 + var month = date.getMonth() + 1;
  428 + var strDate = date.getDate();
  429 + if (month >= 1 && month <= 9) {
  430 + month = "0" + month;
  431 + }
  432 + if (strDate >= 0 && strDate <= 9) {
  433 + strDate = "0" + strDate;
  434 + }
  435 + var currentdate = year + seperator1 + month + seperator1 + strDate;
  436 + return currentdate;
407 } 437 }
408 </script> 438 </script>
409 439