|
@@ -8,6 +8,7 @@ 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.domain.PoUser;
|
|
|
import com.ruoyi.system.mapper.PoNewsMapper;
|
|
|
import com.ruoyi.system.mapper.PoUserMapper;
|
|
|
import com.ruoyi.system.service.IPoNewsService;
|
|
@@ -225,11 +226,10 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
* @param phoneList 手机号数据
|
|
|
* @param updateSupport 是否支持更新 存在则更新
|
|
|
* @param userName 操作用户
|
|
|
- * @param poNews 返回结果
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public String importPhone(List<PoNews> phoneList, boolean updateSupport, String userName, PoNews poNews) {
|
|
|
+ public String importPhone(List<PoNews> phoneList, boolean updateSupport, String userName) {
|
|
|
if (StringUtils.isNull(phoneList) || phoneList.size() == 0) {
|
|
|
throw new ServiceException("导入用户电话数据不能为空!");
|
|
|
}
|
|
@@ -241,7 +241,7 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
for (PoNews phone : phoneList) {
|
|
|
try {
|
|
|
// 验证是否存在这个用户
|
|
|
- SysUser u = poUserMapper.selectUserByUserPhoneNumber(phone.getPhonenumber());
|
|
|
+ PoUser u = poUserMapper.selectUserByUserPhoneNumber(phone.getPhonenumber());
|
|
|
if (StringUtils.isNull(u)) {
|
|
|
BeanValidators.validateWithException(validator, phone);
|
|
|
phone.setPhonenumber(phone.getPhonenumber());
|
|
@@ -250,11 +250,28 @@ public class PoNewsServiceImpl implements IPoNewsService {
|
|
|
successNum++;
|
|
|
successMsg.append("<br/>" + successNum + "、电话号 " + phone.getPhonenumber() + " 导入成功");
|
|
|
}
|
|
|
+ else if (updateSupport){
|
|
|
+ BeanValidators.validateWithException(validator, phone);
|
|
|
+ phone.setUpdateBy(userName);
|
|
|
+ this.updatePoNews(phone);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>" + successNum + "、手机 " + phone.getPhonenumber() + " 更新成功");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、手机 " + phone.getPhonenumber()+ " 已经存在");
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
failureNum++;
|
|
|
- String msg = "<br/>" + failureNum + "、dian " + phone.getPhonenumber() + " 导入失败:";
|
|
|
+ String msg = "<br/>" + failureNum + "、电话号 " + phone.getPhonenumber() + " 导入失败:";
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
}
|
|
|
+ }
|
|
|
+ if (failureNum > 0){
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ }else{
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
}
|
|
|
return successMsg.toString();
|
|
|
}
|