|
@@ -4,6 +4,7 @@ import com.palmnest.application.bean.Page;
|
|
|
import com.palmnest.application.core.util.RegularPattern;
|
|
|
import com.palmnest.application.core.util.StringUtil;
|
|
|
import com.palmnest.application.dto.ConsumerDto;
|
|
|
+import com.palmnest.application.dto.output.ElementDto;
|
|
|
import com.palmnest.dao.ElementGroupDao;
|
|
|
import com.palmnest.dao.dinner.*;
|
|
|
import com.palmnest.dao.estateserve.AppUserDao;
|
|
@@ -11,6 +12,7 @@ import com.palmnest.dao.estateserve.VirtualArchDao;
|
|
|
import com.palmnest.model.dinner.*;
|
|
|
import com.palmnest.model.estateserve.AppUser;
|
|
|
import com.palmnest.model.property.VirtualArchitecture;
|
|
|
+import com.palmnest.service.ElementGroupManager;
|
|
|
import com.palmnest.service.dinner.manager.ConsumerManager;
|
|
|
import com.palmnest.service.estateserve.AppUserManager;
|
|
|
import com.palmnest.service.impl.GenericManagerImpl;
|
|
@@ -60,7 +62,7 @@ public class ConsumerManagerImpl extends GenericManagerImpl<Consumer, Long> impl
|
|
|
@Autowired
|
|
|
private AppUserDao appUserDao;
|
|
|
@Autowired
|
|
|
- private ElementGroupDao elementGroupDao;
|
|
|
+ private ElementGroupManager elementGroupManager;
|
|
|
@Autowired
|
|
|
private AppUserManager appUserManager;
|
|
|
@Autowired
|
|
@@ -466,4 +468,165 @@ public class ConsumerManagerImpl extends GenericManagerImpl<Consumer, Long> impl
|
|
|
return mapList;
|
|
|
}
|
|
|
|
|
|
+ private List<ElementDto> getAddress(Integer orgId){
|
|
|
+ List<ElementDto> addressDtoList = elementGroupManager.getOrgElementGroupInfo(orgId, "dinnerAddress");
|
|
|
+ Collections.sort(addressDtoList, new Comparator<ElementDto>() {
|
|
|
+ @Override
|
|
|
+ public int compare(ElementDto o1, ElementDto o2) {
|
|
|
+ String name1 = o1.getId().toString();
|
|
|
+ String name2 = o2.getId().toString();
|
|
|
+ return name1.compareTo(name2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return addressDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> importUserAddress(InputStream ins, String orgId) {
|
|
|
+ Map<String, Object> retMap = new HashMap<String, Object>();
|
|
|
+ List<Object> userList = new ArrayList<Object>();
|
|
|
+ int bugCount = 0;
|
|
|
+ StringBuffer bugStr = new StringBuffer("");
|
|
|
+ StringBuffer countStr = new StringBuffer("");
|
|
|
+ List<String> mobiles = new ArrayList<String>();
|
|
|
+ Sheet sheet = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ Workbook workbook = WorkbookFactory.create(ins);
|
|
|
+ sheet = workbook.getSheet("ConsumerAddress");
|
|
|
+ } catch (Exception e) {
|
|
|
+ bugCount++;
|
|
|
+ bugStr.append("模板格式有问题,请下载最新的模板");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (sheet == null) {
|
|
|
+ bugCount++;
|
|
|
+ bugStr.append("模板格式有问题,请下载最新的模板");
|
|
|
+ } else {
|
|
|
+ int rows = sheet.getLastRowNum();
|
|
|
+ //如果大于2000行数据
|
|
|
+ if (rows > 20000) {
|
|
|
+ bugCount++;
|
|
|
+ bugStr.append("数据量太大,不能大于2w行");
|
|
|
+ } else if (rows < 1) {
|
|
|
+ bugCount++;
|
|
|
+ bugStr.append("数据为空,请录入账单信息");
|
|
|
+ } else {
|
|
|
+
|
|
|
+ List<ElementDto> addressList = getAddress(Integer.parseInt(orgId));
|
|
|
+
|
|
|
+ for (int i = 1; i <= rows; i++) {
|
|
|
+ if (sheet.getRow(i) == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (sheet.getRow(i).getCell(0) == null) {
|
|
|
+ bugStr.append("第" + i + "行第1列数据有问题,请检查,问题:姓名必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sheet.getRow(i).getCell(0).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ if (StringUtils.isBlank(sheet.getRow(i).getCell(0).getStringCellValue())) {
|
|
|
+ bugStr.append("第" + i + "行第1列数据有问题,请检查,问题:姓名必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String userName = sheet.getRow(i).getCell(0).getStringCellValue();
|
|
|
+
|
|
|
+
|
|
|
+ if (sheet.getRow(i).getCell(1) == null) {
|
|
|
+ bugStr.append("第" + i + "行第2列数据有问题,请检查,问题:手机号码必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sheet.getRow(i).getCell(1).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ if (StringUtils.isBlank(sheet.getRow(i).getCell(1).getStringCellValue())) {
|
|
|
+ bugStr.append("第" + i + "行第2列数据有问题,请检查,问题:手机号码必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String mobile = sheet.getRow(i).getCell(1).getStringCellValue();
|
|
|
+ boolean bool = RegularPattern.isMobileNO(mobile);//验证手机格式是否正确
|
|
|
+ if (StringUtils.isNotEmpty(mobile) && !bool) {
|
|
|
+ bugStr.append("第" + i + "行第2列数据有问题,请检查,问题:" + mobile + "手机号码格式有问题,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ AppUser cons = appUserDao.getAppUsersByPhoneAndOrg(mobile, orgId, "1");
|
|
|
+ if (cons != null && !"-1".equals(cons.getUserType())) {
|
|
|
+ countStr.append("第" + i + "行第2列数据有问题,请检查,问题:" + mobile + "该手机号码已存在账号,请导出系统模板匹配录入<br/>");
|
|
|
+ mobiles.add(mobile);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sheet.getRow(i).getCell(3) == null) {
|
|
|
+ bugStr.append("第" + i + "行第4列数据有问题,请检查,问题:送餐地址必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sheet.getRow(i).getCell(3).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ if (StringUtils.isBlank(sheet.getRow(i).getCell(3).getStringCellValue())) {
|
|
|
+ bugStr.append("第" + i + "行第4列数据有问题,请检查,问题:送餐地址必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String address = sheet.getRow(i).getCell(3).getStringCellValue();
|
|
|
+ Long addressId = null;
|
|
|
+ //判断该地址在不在系统内
|
|
|
+ for(ElementDto el : addressList){
|
|
|
+ if(!address.equals(el.getItemname())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ addressId = el.getId();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(null == addressId){
|
|
|
+ bugStr.append("第" + i + "行第4列数据有问题,请检查,问题:送餐地址不在系统中,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (sheet.getRow(i).getCell(4) == null) {
|
|
|
+ bugStr.append("第" + i + "行第5列数据有问题,请检查,问题:账户类型必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sheet.getRow(i).getCell(4).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ if (StringUtils.isBlank(sheet.getRow(i).getCell(4).getStringCellValue())) {
|
|
|
+ bugStr.append("第" + i + "行第5列数据有问题,请检查,问题:账户类型必填,请导出系统模板匹配录入<br/>");
|
|
|
+ bugCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String roleTypeStr = sheet.getRow(i).getCell(4).getStringCellValue();
|
|
|
+ Integer roleType = 2;
|
|
|
+ if("个人账号".equals(roleTypeStr)){
|
|
|
+ roleType=2;
|
|
|
+ }else if("管理员".equals(roleTypeStr)){
|
|
|
+ roleType=1;
|
|
|
+ }else if("可被代订".equals(roleTypeStr)){
|
|
|
+ roleType=3;
|
|
|
+ }
|
|
|
+
|
|
|
+ cons.setAddress(addressId.toString());
|
|
|
+ cons.setRoleType(roleType.toString());
|
|
|
+ userList.add(cons);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retMap.put("bugCount", bugCount);
|
|
|
+ retMap.put("countStr", countStr);
|
|
|
+ retMap.put("bugStr", bugStr.toString());
|
|
|
+ retMap.put("userList", userList);
|
|
|
+ retMap.put("okCount", userList.size());
|
|
|
+ return retMap;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ retMap.put("bugCount", bugCount);
|
|
|
+ retMap.put("countStr", countStr);
|
|
|
+ retMap.put("bugStr", bugStr.toString());
|
|
|
+ retMap.put("userList", userList);
|
|
|
+ retMap.put("okCount", userList.size());
|
|
|
+ e.printStackTrace();
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|