|
@@ -1,15 +1,21 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
+import com.ruoyi.common.utils.bean.BeanValidators;
|
|
|
import com.ruoyi.system.domain.PoNews;
|
|
|
import com.ruoyi.system.mapper.PoNewsMapper;
|
|
|
+import com.ruoyi.system.mapper.PoUserMapper;
|
|
|
import com.ruoyi.system.service.IPoNewsService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.validation.Validator;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -23,6 +29,13 @@ import java.util.stream.Collectors;
|
|
|
public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
@Autowired
|
|
|
private PoNewsMapper poNewsMapper;
|
|
|
+ @Autowired
|
|
|
+ private PoUserMapper poUserMapper;
|
|
|
+ @Autowired
|
|
|
+ protected Validator validator;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PoUserServiceImpl poUserService;
|
|
|
|
|
|
/**
|
|
|
* 根据Id查询
|
|
@@ -34,7 +47,7 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
public List<PoNews> selectPoNewsByNewsId(String newsId) {
|
|
|
|
|
|
List list = new ArrayList();
|
|
|
- List<PoNews> poNewsList =new ArrayList<>();
|
|
|
+ List<PoNews> poNewsList = new ArrayList<>();
|
|
|
poNewsList.add(poNewsMapper.selectPoNewsByNewsId(newsId));
|
|
|
List<PoNews> collect = poNewsList.stream().map((item) -> {
|
|
|
PoNews poNews = new PoNews();
|
|
@@ -45,7 +58,7 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
poNews.setPhonenumber(list.toString());
|
|
|
return poNews;
|
|
|
}).collect(Collectors.toList());
|
|
|
- return collect;
|
|
|
+ return collect;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -123,6 +136,7 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
|
|
|
/**
|
|
|
* 搜索消息
|
|
|
+ *
|
|
|
* @param title
|
|
|
* @param newsTimeStart
|
|
|
* @param newsTimeEnd
|
|
@@ -137,18 +151,16 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
|
|
|
if (newsTimeStart.before(newsTimeEnd)) {
|
|
|
return poNewsMapper.selectPoNewsListByTitleAndNewsTimeStartAndNewsTimeEnd(title, newsTimeStart, newsTimeEnd);
|
|
|
- }
|
|
|
- else if((newsTimeStart != null && newsTimeEnd == null) || (newsTimeStart == null && newsTimeEnd != null)) {
|
|
|
+ } else if ((newsTimeStart != null && newsTimeEnd == null) || (newsTimeStart == null && newsTimeEnd != null)) {
|
|
|
//有一个时间不为空返回提示信息
|
|
|
List list = new ArrayList();
|
|
|
list.add("请选择正确的时间段");
|
|
|
return list;
|
|
|
}
|
|
|
+ } else {//时间都为空
|
|
|
+ return poNewsMapper.selectPoNewsListByTitle(title);
|
|
|
}
|
|
|
- else {//时间都为空
|
|
|
- return poNewsMapper.selectPoNewsListByTitle(title);
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
//标题为空
|
|
|
else {
|
|
|
//时间不为空
|
|
@@ -163,6 +175,7 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
|
|
|
/**
|
|
|
* 获取详细消息内容
|
|
|
+ *
|
|
|
* @param newsId
|
|
|
* @return
|
|
|
*/
|
|
@@ -173,6 +186,7 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
|
|
|
/**
|
|
|
* 校验图片是否重复
|
|
|
+ *
|
|
|
* @param poNews
|
|
|
* @return
|
|
|
*/
|
|
@@ -190,19 +204,59 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
|
|
|
/**
|
|
|
* 校验时间是否相等
|
|
|
+ *
|
|
|
* @param poNews
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public String checkPostNewsTimeUnique(PoNews poNews) {
|
|
|
- String poNewsId = StringUtils.isNull(poNews.getNewsId())? "图片不存在" : poNews.getNewsId();
|
|
|
+ String poNewsId = StringUtils.isNull(poNews.getNewsId()) ? "图片不存在" : poNews.getNewsId();
|
|
|
PoNews info = poNewsMapper.checkPostNewsTimeUnique(poNews.getCreateTime());
|
|
|
- if (StringUtils.isNotNull(info) && info.getNewsId() != poNewsId){
|
|
|
+ if (StringUtils.isNotNull(info) && info.getNewsId() != poNewsId) {
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
}
|
|
|
- return UserConstants.UNIQUE;
|
|
|
+ return UserConstants.UNIQUE;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入用户手机号
|
|
|
+ *
|
|
|
+ * @param phoneList 手机号数据
|
|
|
+ * @param updateSupport 是否支持更新 存在则更新
|
|
|
+ * @param userName 操作用户
|
|
|
+ * @param poNews 返回结果
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String importPhone(List<PoNews> phoneList, boolean updateSupport, String userName, PoNews poNews) {
|
|
|
+ if (StringUtils.isNull(phoneList) || phoneList.size() == 0) {
|
|
|
+ throw new ServiceException("导入用户电话数据不能为空!");
|
|
|
+ }
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+
|
|
|
+ for (PoNews phone : phoneList) {
|
|
|
+ try {
|
|
|
+ // 验证是否存在这个用户
|
|
|
+ SysUser u = poUserMapper.selectUserByUserPhoneNumber(phone.getPhonenumber());
|
|
|
+ if (StringUtils.isNull(u)) {
|
|
|
+ BeanValidators.validateWithException(validator, phone);
|
|
|
+ phone.setPhonenumber(phone.getPhonenumber());
|
|
|
+ phone.setCreateBy(userName);
|
|
|
+ this.insertPoNews(phone);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>" + successNum + "、电话号 " + phone.getPhonenumber() + " 导入成功");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ failureNum++;
|
|
|
+ String msg = "<br/>" + failureNum + "、dian " + phone.getPhonenumber() + " 导入失败:";
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
}
|
|
|
|