添加与完善线索导入与新增
This commit is contained in:
@@ -13,16 +13,16 @@ public class ExcelErrorConstants {
|
|||||||
|
|
||||||
public static final String MOBILE_EXIST= "手机号已存在";
|
public static final String MOBILE_EXIST= "手机号已存在";
|
||||||
|
|
||||||
public static final String LIVEAREA_LOSE= "常驻区域缺失";
|
public static final String LIVE_AREA_LOSE = "常驻区域缺失";
|
||||||
|
|
||||||
public static final String LIVEAREA_FORMAT_ERROR= "常驻区域格式错误";
|
public static final String LIVE_AREA_FORMAT_ERROR = "常驻区域格式错误";
|
||||||
|
|
||||||
public static final String WANTSHOPAREA_LOSE= "意向区域缺失";
|
public static final String WANT_SHOP_AREA_LOSE = "意向区域缺失";
|
||||||
|
|
||||||
public static final String WANTSHOPAREA_FORMAT_ERROR= "意向区域格式错误";
|
public static final String WANT_SHOP_AREA_FORMAT_ERROR = "意向区域格式错误";
|
||||||
|
|
||||||
public static final String ACCEPTADJUSTTYPE_LOSE= "是否接受调剂缺失";
|
public static final String ACCEPT_ADJUST_TYPE_LOSE = "是否接受调剂缺失";
|
||||||
|
|
||||||
public static final String INVESTMENTMANAGER_LOSE= "未找到此招商经理,请核实";
|
public static final String INVESTMENT_MANAGER_LOSE = "未找到此招商经理,请核实";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ public enum ErrorCodeEnum {
|
|||||||
INTERVIEW_INTERVIEW_TIME_IS_UNUSABLE(1021114, "当前预约时间不可用,请和线索用户协商其他时间后确定预约时间\n面试人:{0} 手机号:{1}", null),
|
INTERVIEW_INTERVIEW_TIME_IS_UNUSABLE(1021114, "当前预约时间不可用,请和线索用户协商其他时间后确定预约时间\n面试人:{0} 手机号:{1}", null),
|
||||||
INTERVIEW_PARTNER_NOT_EXIST(1021115, "线索下的加盟商不存在!", null),
|
INTERVIEW_PARTNER_NOT_EXIST(1021115, "线索下的加盟商不存在!", null),
|
||||||
ROOM_STATUS_ERROR(10211156, "当前面试房间状态不允许进行该操作!", null),
|
ROOM_STATUS_ERROR(10211156, "当前面试房间状态不允许进行该操作!", null),
|
||||||
|
MOBILE_APP_NOT_ONLINE_ERROR(10211157, "拨出手机APP不在线!", null),
|
||||||
|
CALL_RECORD_NOT_EXIST_ERROR(10211158, "通话记录不存在!", null),
|
||||||
|
|
||||||
|
CREATE_CALL_REQUEST_ERROR(10211158, "创建电话请求失败!", null),
|
||||||
|
CALL_UP_ERROR(10211159, "拨出电话异常!", null),
|
||||||
CONTENT_DUPLICATED(10211200, "动态标题重复!", null),
|
CONTENT_DUPLICATED(10211200, "动态标题重复!", null),
|
||||||
SIGN_FAIL(600000, "验签失败", null),
|
SIGN_FAIL(600000, "验签失败", null),
|
||||||
GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误!", null),
|
GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误!", null),
|
||||||
@@ -89,6 +94,12 @@ public enum ErrorCodeEnum {
|
|||||||
INSPECTION_USER_OCCUPY(600002,"当前稽核人已经配置其他战区",null),
|
INSPECTION_USER_OCCUPY(600002,"当前稽核人已经配置其他战区",null),
|
||||||
INSPECTION_INFO_NOT_EXIST(600005, "稽核信息不存在!", null),
|
INSPECTION_INFO_NOT_EXIST(600005, "稽核信息不存在!", null),
|
||||||
OPEN_AREA_NULL(600006,"归属地区不能为空",null),
|
OPEN_AREA_NULL(600006,"归属地区不能为空",null),
|
||||||
|
|
||||||
|
OUTBOUND_NUMBER_EXIST(110001, "该呼出号码已被绑定,请更改后重试", null),
|
||||||
|
|
||||||
|
LABEL_GROUP_IN_USE(120001, "该标签组下存在标签,不可删除;请确保该标签组下标签数量为0后再进行删除", null),
|
||||||
|
LABEL_GROUP_EXIST(120002, "该标签组已存在,请重新输入", null),
|
||||||
|
LABEL_EXIST(120003, "该标签已存在,请重新输入", null),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
<include refid="Base_Column_List"></include>
|
<include refid="Base_Column_List"></include>
|
||||||
FROM `hy_open_area_info`
|
FROM `hy_open_area_info`
|
||||||
WHERE area_path= concat('/',#{areaPath},'/') and deleted=0
|
WHERE area_path= concat('/',#{areaPath},'/') and deleted=0 and province_city_flag=0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -22,7 +22,7 @@ import java.io.Serializable;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class HyPartnerLineDO implements Serializable {
|
public class HyPartnerLineDO implements Serializable {
|
||||||
|
|
||||||
@Excel(name = "*姓名(必填)")
|
@Excel(name = "*姓名(必填)" )
|
||||||
@ApiModelProperty("姓名")
|
@ApiModelProperty("姓名")
|
||||||
private String partnerName;
|
private String partnerName;
|
||||||
|
|
||||||
@@ -30,33 +30,32 @@ public class HyPartnerLineDO implements Serializable {
|
|||||||
@ApiModelProperty("手机号")
|
@ApiModelProperty("手机号")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
@Excel(name = "*常驻区域(必填)")
|
@Excel(name = "*常驻区域(必填)",width =18)
|
||||||
@ApiModelProperty("常驻区域")
|
@ApiModelProperty("常驻区域")
|
||||||
private String liveAreaReplace;
|
private String liveAreaReplace;
|
||||||
|
|
||||||
private String liveArea;
|
private String liveArea;
|
||||||
|
|
||||||
@Excel(name = "*意向区域(必填)")
|
@Excel(name = "*意向区域(必填)",width =18)
|
||||||
@ApiModelProperty("意向区域")
|
@ApiModelProperty("意向区域")
|
||||||
private String wantShopAreaReplace;
|
private String wantShopAreaReplace;
|
||||||
|
|
||||||
private Long wantShopArea;
|
private Long wantShopArea;
|
||||||
|
|
||||||
@Excel(name = "*是否接受调剂(必填)")
|
@Excel(name = "*是否接受调剂(必填)",width =18)
|
||||||
@ApiModelProperty("是否接受调剂")
|
@ApiModelProperty("是否接受调剂")
|
||||||
private String acceptAdjustTypeReplace;
|
private String acceptAdjustTypeReplace;
|
||||||
|
|
||||||
private Integer acceptAdjustType;
|
private Integer acceptAdjustType;
|
||||||
|
|
||||||
@Excel(name = "分配招商经理")
|
@Excel(name = "分配招商经理",width =18)
|
||||||
@ApiModelProperty("分配招商经理")
|
@ApiModelProperty("分配招商经理")
|
||||||
private String investmentManagerReplace;
|
private String investmentManagerReplace;
|
||||||
|
|
||||||
private String investmentManager;
|
private String investmentManager;
|
||||||
|
|
||||||
|
|
||||||
|
@Excel(name = "错误信息",width =26)
|
||||||
@Excel(name = "错误信息")
|
|
||||||
@ApiModelProperty("错误信息")
|
@ApiModelProperty("错误信息")
|
||||||
private String errorInfo;
|
private String errorInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ public class AddLineRequest {
|
|||||||
/**
|
/**
|
||||||
* (0不接受调剂、1全国调剂、2省内调剂、3市内调剂)*
|
* (0不接受调剂、1全国调剂、2省内调剂、3市内调剂)*
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "是否接受调剂不能为空")
|
@NotNull(message = "是否接受调剂不能为空")
|
||||||
@ApiModelProperty("是否接受调剂")
|
@ApiModelProperty("是否接受调剂")
|
||||||
private Integer acceptAdjustType;
|
private Integer acceptAdjustType;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.cool.store.service.impl;
|
package com.cool.store.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cool.store.constants.ExcelErrorConstants;
|
import com.cool.store.constants.ExcelErrorConstants;
|
||||||
import com.cool.store.dao.*;
|
import com.cool.store.dao.*;
|
||||||
@@ -22,6 +23,7 @@ import com.cool.store.utils.UUIDUtils;
|
|||||||
import com.cool.store.utils.poi.ExcelUtil;
|
import com.cool.store.utils.poi.ExcelUtil;
|
||||||
import com.cool.store.utils.poi.constant.Constants;
|
import com.cool.store.utils.poi.constant.Constants;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -41,6 +43,13 @@ import java.util.regex.Pattern;
|
|||||||
public class LineHighSeasServiceImpl implements LineHighSeasService {
|
public class LineHighSeasServiceImpl implements LineHighSeasService {
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${oss.excelFile.dir:null}")
|
||||||
|
private String dir;
|
||||||
|
|
||||||
|
@Value("${manual.channel.id}")
|
||||||
|
private Integer manual;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
|
private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
|
||||||
|
|
||||||
@@ -78,13 +87,14 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增线索
|
* 新增线索
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
public void add(AddLineRequest request) {
|
public void add(AddLineRequest request) {
|
||||||
String partnerId = UUIDUtils.get32UUID();
|
String partnerId = UUIDUtils.get32UUID();
|
||||||
HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO();
|
HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO();
|
||||||
resultUser.setUsername(request.getPartnerName()).setMobile(request.getMobile()).setPartnerId(partnerId).setCreateTime(new Date()).setAcceptAdjustType(request.getAcceptAdjustType())
|
resultUser.setUsername(request.getPartnerName()).setMobile(request.getMobile()).setPartnerId(partnerId).setCreateTime(new Date()).setAcceptAdjustType(request.getAcceptAdjustType())
|
||||||
.setLiveArea(request.getLiveArea()).setWantShopArea(request.getWantShopArea());
|
.setLiveArea(request.getLiveArea()).setWantShopArea(request.getWantShopArea()).setUserChannelId(manual);
|
||||||
hyPartnerUserInfoDAO.insertSelective(resultUser);
|
hyPartnerUserInfoDAO.insertSelective(resultUser);
|
||||||
|
|
||||||
HyPartnerLineInfoDO resultLine = new HyPartnerLineInfoDO();
|
HyPartnerLineInfoDO resultLine = new HyPartnerLineInfoDO();
|
||||||
@@ -118,116 +128,123 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseResult importLine(MultipartFile file) {
|
public ResponseResult importLine(MultipartFile file) {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ExcelUtil<HyPartnerLineDO> util = new ExcelUtil<HyPartnerLineDO>(HyPartnerLineDO.class);
|
ExcelUtil<HyPartnerLineDO> util = new ExcelUtil<HyPartnerLineDO>(HyPartnerLineDO.class);
|
||||||
List<HyPartnerLineDO> lineDOList = util.importExcel(file.getInputStream());
|
List<HyPartnerLineDO> lineDOList = util.importExcel(file.getInputStream());
|
||||||
if (lineDOList.size() > excelMaxSize) {
|
|
||||||
|
|
||||||
//上传文件到oss
|
|
||||||
// ossServer.uploadFileServer()
|
|
||||||
return new ResponseResult(500, "", new ErrorExcelResponse(lineDOList.size(), excelMaxSize, ""));
|
|
||||||
}
|
|
||||||
Map<Integer, Map<Integer, List<String>>> styleCells = new HashMap<>(4);
|
Map<Integer, Map<Integer, List<String>>> styleCells = new HashMap<>(4);
|
||||||
|
if (lineDOList.size() > excelMaxSize) {
|
||||||
|
//超出五百条的excel都标红
|
||||||
|
for (int i = excelMaxSize; i < lineDOList.size() ; i++) {
|
||||||
|
styleCells.put(i,new HashMap<>());
|
||||||
|
}
|
||||||
|
ExcelUtil.setRowStyle(styleCells,ExcelUtil.FONT_RED,7);
|
||||||
|
util.exportExcel(outputStream, lineDOList, "", styleCells);
|
||||||
|
InputStream stream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||||
|
String fileStr = ossServer.uploadFileServer(stream, dir + getExcelName());
|
||||||
|
return new ResponseResult(500, "每次数据最多导入500条,请分批上传", new ErrorExcelResponse(lineDOList.size(), excelMaxSize, fileStr));
|
||||||
|
}
|
||||||
for (int i = 0; i < lineDOList.size(); i++) {
|
for (int i = 0; i < lineDOList.size(); i++) {
|
||||||
HyPartnerLineDO hyPartnerLineDO = lineDOList.get(i);
|
HyPartnerLineDO hyPartnerLineDO = lineDOList.get(i);
|
||||||
if (StringUtil.isEmpty(hyPartnerLineDO.getPartnerName())) {
|
if (StringUtil.isEmpty(hyPartnerLineDO.getPartnerName())) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.NAME_LOSE));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.NAME_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.NAME_LOSE));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 0, new String[]{ExcelUtil.FONT_RED});
|
||||||
}
|
}
|
||||||
String mobile = hyPartnerLineDO.getMobile();
|
String mobile = hyPartnerLineDO.getMobile().trim();
|
||||||
//手机号为空
|
//手机号为空
|
||||||
if (StringUtil.isEmpty(mobile)) {
|
if (StringUtil.isEmpty(mobile)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_LOSE));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_LOSE));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 2, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
|
||||||
} else {
|
} else {
|
||||||
//手机号格式判断
|
//手机号格式判断
|
||||||
if (!isPhone(mobile)) {
|
if (!isPhone(mobile)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_ERROR));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_ERROR : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_ERROR));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 2, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
|
||||||
}
|
}
|
||||||
//手机号是否已存在
|
//手机号是否已存在
|
||||||
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(mobile);
|
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(mobile);
|
||||||
if (ObjectUtil.isNotNull(hyPartnerUserInfoDO)) {
|
if (ObjectUtil.isNotNull(hyPartnerUserInfoDO)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_EXIST));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_EXIST : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_EXIST));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 2, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//常驻区域为空
|
//常驻区域为空
|
||||||
String liveArea = hyPartnerLineDO.getLiveAreaReplace();
|
String liveArea = hyPartnerLineDO.getLiveAreaReplace().trim();
|
||||||
if (StringUtil.isEmpty(liveArea)) {
|
if (StringUtil.isEmpty(liveArea)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.LIVEAREA_LOSE));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.LIVE_AREA_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.LIVE_AREA_LOSE));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 3, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 2, new String[]{ExcelUtil.FONT_RED});
|
||||||
} else {
|
} else {
|
||||||
//判断格式是否为错
|
//判断格式是否为错
|
||||||
if (ObjectUtil.isNull(hyOpenAreaInfoDAO.selectByAreaPath(liveArea))) {
|
if (ObjectUtil.isNull(hyOpenAreaInfoDAO.selectByAreaPath(liveArea))) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.LIVEAREA_FORMAT_ERROR));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.LIVE_AREA_FORMAT_ERROR : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.LIVE_AREA_FORMAT_ERROR));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 3, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 2, new String[]{ExcelUtil.FONT_RED});
|
||||||
}else {
|
} else {
|
||||||
hyPartnerLineDO.setLiveArea(liveArea.replace(Constants.FORWARD_SLASH, Constants.SPACE));
|
hyPartnerLineDO.setLiveArea(liveArea.replace(Constants.FORWARD_SLASH, Constants.SPACE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//意向区域
|
//意向区域
|
||||||
String wantShopArea = hyPartnerLineDO.getWantShopAreaReplace();
|
String wantShopArea = hyPartnerLineDO.getWantShopAreaReplace().trim();
|
||||||
if (StringUtil.isEmpty(wantShopArea)) {
|
if (StringUtil.isEmpty(wantShopArea)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.WANTSHOPAREA_LOSE));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.WANT_SHOP_AREA_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.WANT_SHOP_AREA_LOSE));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 4, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 3, new String[]{ExcelUtil.FONT_RED});
|
||||||
} else {
|
} else {
|
||||||
//判断格式是否为错
|
//判断格式是否为错
|
||||||
HyOpenAreaInfoDO hyOpenAreaInfoDO = hyOpenAreaInfoDAO.selectByAreaPath(wantShopArea);
|
HyOpenAreaInfoDO hyOpenAreaInfoDO = hyOpenAreaInfoDAO.selectByAreaPath(wantShopArea);
|
||||||
if (ObjectUtil.isNull(hyOpenAreaInfoDO)) {
|
if (ObjectUtil.isNull(hyOpenAreaInfoDO)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.WANTSHOPAREA_FORMAT_ERROR));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.WANT_SHOP_AREA_FORMAT_ERROR : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.WANT_SHOP_AREA_FORMAT_ERROR));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 4, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 3, new String[]{ExcelUtil.FONT_RED});
|
||||||
}else {
|
} else {
|
||||||
hyPartnerLineDO.setWantShopArea(hyOpenAreaInfoDO.getId());
|
hyPartnerLineDO.setWantShopArea(hyOpenAreaInfoDO.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//是否接受调剂
|
//是否接受调剂
|
||||||
String acceptAdjustType = hyPartnerLineDO.getAcceptAdjustTypeReplace();
|
String acceptAdjustType = hyPartnerLineDO.getAcceptAdjustTypeReplace().trim();
|
||||||
if (StringUtil.isEmpty(acceptAdjustType)) {
|
if (StringUtil.isEmpty(acceptAdjustType)) {
|
||||||
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.ACCEPT_ADJUST_TYPE_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.ACCEPT_ADJUST_TYPE_LOSE));
|
||||||
|
ExcelUtil.setStyleMap(styleCells, i, 4, new String[]{ExcelUtil.FONT_RED});
|
||||||
|
}else {
|
||||||
Integer enumByName = AcceptAdjustTypeEnum.findEnumByName(acceptAdjustType);
|
Integer enumByName = AcceptAdjustTypeEnum.findEnumByName(acceptAdjustType);
|
||||||
if(ObjectUtil.isNull(enumByName)){
|
if (ObjectUtil.isNull(enumByName)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.ACCEPTADJUSTTYPE_LOSE));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.ACCEPT_ADJUST_TYPE_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.ACCEPT_ADJUST_TYPE_LOSE));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 5, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 4, new String[]{ExcelUtil.FONT_RED});
|
||||||
}else {
|
} else {
|
||||||
hyPartnerLineDO.setAcceptAdjustType(enumByName);
|
hyPartnerLineDO.setAcceptAdjustType(enumByName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//分配招商经理
|
//分配招商经理
|
||||||
String investmentManager = hyPartnerLineDO.getInvestmentManagerReplace();
|
String investmentManager = hyPartnerLineDO.getInvestmentManagerReplace().trim();
|
||||||
if (StringUtil.isNotEmpty(investmentManager)) {
|
if (StringUtil.isNotEmpty(investmentManager)) {
|
||||||
//判断是否能够查询的到
|
//判断是否能够查询的到
|
||||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByInvestmentManager(investmentManager);
|
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByInvestmentManager(investmentManager);
|
||||||
if (ObjectUtil.isNull(enterpriseUserDO)) {
|
if (ObjectUtil.isNull(enterpriseUserDO)) {
|
||||||
hyPartnerLineDO.setErrorInfo(hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.INVESTMENTMANAGER_LOSE));
|
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.INVESTMENT_MANAGER_LOSE : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.INVESTMENT_MANAGER_LOSE));
|
||||||
ExcelUtil.setStyleMap(styleCells, i, 6, new String[]{ExcelUtil.FONT_RED});
|
ExcelUtil.setStyleMap(styleCells, i, 5, new String[]{ExcelUtil.FONT_RED});
|
||||||
}else {
|
} else {
|
||||||
hyPartnerLineDO.setInvestmentManager(enterpriseUserDO.getUserId());
|
hyPartnerLineDO.setInvestmentManager(enterpriseUserDO.getUserId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
util.exportExcel(outputStream, lineDOList, "", styleCells);
|
util.exportExcel(outputStream, lineDOList, "", styleCells);
|
||||||
InputStream stream = new ByteArrayInputStream(outputStream.toByteArray());
|
InputStream stream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||||
String fileStr = ossServer.uploadFileServer(stream, "");
|
String fileStr = ossServer.uploadFileServer(stream, dir + getExcelName());
|
||||||
if (styleCells.size() != 0) {
|
if (styleCells.size() != 0) {
|
||||||
return new ResponseResult(500, "", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr));
|
return new ResponseResult(500, "共上传" + lineDOList.size() + "条线索,其中" + styleCells.size() + "条存在异常", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr));
|
||||||
}
|
}
|
||||||
for (HyPartnerLineDO hyPartnerLineDO : lineDOList) {
|
for (HyPartnerLineDO hyPartnerLineDO : lineDOList) {
|
||||||
AddLineRequest addLineRequest = new AddLineRequest();
|
AddLineRequest addLineRequest = new AddLineRequest();
|
||||||
BeanUtil.copyProperties(addLineRequest,hyPartnerLineDO);
|
BeanUtil.copyProperties(hyPartnerLineDO, addLineRequest);
|
||||||
addLineRequest.setWantShopArea(hyPartnerLineDO.getWantShopArea().toString());
|
addLineRequest.setWantShopArea(hyPartnerLineDO.getWantShopArea().toString());
|
||||||
add(addLineRequest);
|
add(addLineRequest);
|
||||||
}
|
}
|
||||||
return new ResponseResult(200, "", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr));
|
return new ResponseResult(200, "共上传" + lineDOList.size() + "条线索", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param phone 字符串类型的手机号
|
* @param phone 字符串类型的手机号
|
||||||
* 传入手机号,判断后返回
|
* 传入手机号,判断后返回
|
||||||
* true为手机号,false相反
|
* true为手机号,false相反
|
||||||
*/
|
* */
|
||||||
private boolean isPhone(String phone) {
|
public static boolean isPhone(String phone) {
|
||||||
String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
|
String regex = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$";
|
||||||
if (phone.length() != 11) {
|
if (phone.length() != 11) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -236,4 +253,15 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
|
|||||||
return m.matches();
|
return m.matches();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取excel名称
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getExcelName() {
|
||||||
|
String format = DateUtil.format(new Date(), "yyyyMMdd").concat(Constants.D_LINE).concat(IdUtil.simpleUUID().substring(0, 10));
|
||||||
|
return format.concat(Constants.POMINT).concat(Constants.EXCEL_XLSX);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.cool.store.utils.poi;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.aliyun.openservices.shade.com.google.common.collect.Lists;
|
||||||
import com.cool.store.annotation.Excel;
|
import com.cool.store.annotation.Excel;
|
||||||
import com.cool.store.annotation.Excels;
|
import com.cool.store.annotation.Excels;
|
||||||
import com.cool.store.utils.poi.constant.Constants;
|
import com.cool.store.utils.poi.constant.Constants;
|
||||||
@@ -14,6 +15,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|||||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -177,6 +179,39 @@ public class ExcelUtil<T> {
|
|||||||
throw new IOException("文件sheet不存在");
|
throw new IOException("文件sheet不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int num = sheet.getLastRowNum();
|
||||||
|
//删除的空行(包含空白行和带有格式的空行)
|
||||||
|
int bk = 0;
|
||||||
|
//记录空白行的集合
|
||||||
|
List<Integer> nums = Lists.newArrayList();
|
||||||
|
for (int i = 1; i <= num; i++) {
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
boolean flag = false;
|
||||||
|
//带有格式的空白行
|
||||||
|
if (row != null) {
|
||||||
|
for (Cell cell : row) {
|
||||||
|
//判断该单元格是否全为空
|
||||||
|
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
nums.add(i);
|
||||||
|
bk++;
|
||||||
|
}
|
||||||
|
//空白行
|
||||||
|
} else {
|
||||||
|
nums.add(i);
|
||||||
|
bk++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除无效数据行(空白行,带格式的空白行)
|
||||||
|
for (Integer n : nums) {
|
||||||
|
if (sheet.getRow(n) != null) {
|
||||||
|
sheet.removeRow(sheet.getRow(n));
|
||||||
|
}
|
||||||
|
}
|
||||||
int rows = sheet.getPhysicalNumberOfRows();
|
int rows = sheet.getPhysicalNumberOfRows();
|
||||||
|
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
@@ -485,7 +520,7 @@ public class ExcelUtil<T> {
|
|||||||
//默认样式
|
//默认样式
|
||||||
CellStyle cellStyle = cell.getRow().getSheet().getWorkbook().createCellStyle();
|
CellStyle cellStyle = cell.getRow().getSheet().getWorkbook().createCellStyle();
|
||||||
cellStyle.cloneStyleFrom(styles.get("data"));
|
cellStyle.cloneStyleFrom(styles.get("data"));
|
||||||
if(stylePan){
|
if(stylePan&&!CollectionUtils.isEmpty(styleCells)){
|
||||||
if (styleCells.containsKey(lineNumber)) {
|
if (styleCells.containsKey(lineNumber)) {
|
||||||
Map<Integer, List<String>> columnMap = styleCells.get(lineNumber);
|
Map<Integer, List<String>> columnMap = styleCells.get(lineNumber);
|
||||||
if (columnMap.containsKey(column)) {
|
if (columnMap.containsKey(column)) {
|
||||||
@@ -587,13 +622,13 @@ public class ExcelUtil<T> {
|
|||||||
*
|
*
|
||||||
* @param styleMap
|
* @param styleMap
|
||||||
* @param style
|
* @param style
|
||||||
* @param columNumCount 总列数
|
* @param columnNumCount 总列数
|
||||||
*/
|
*/
|
||||||
public static void setRowStyle(Map<Integer, Map<Integer, List<String>>> styleMap, String style, int columNumCount) {
|
public static void setRowStyle(Map<Integer, Map<Integer, List<String>>> styleMap, String style, int columnNumCount) {
|
||||||
for (Integer row : styleMap.keySet()) {
|
for (Integer row : styleMap.keySet()) {
|
||||||
boolean pan = false;
|
boolean pan = false;
|
||||||
Map<Integer, List<String>> integerListMap = styleMap.get(row);
|
Map<Integer, List<String>> integerListMap = styleMap.get(row);
|
||||||
for (int i = 0; i <= columNumCount; i++) {
|
for (int i = 0; i <= columnNumCount; i++) {
|
||||||
if (pan) {
|
if (pan) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ public class Constants
|
|||||||
* 图片格式
|
* 图片格式
|
||||||
*/
|
*/
|
||||||
public static final String IMAGE_JPG = "jpg";
|
public static final String IMAGE_JPG = "jpg";
|
||||||
|
/**
|
||||||
|
* 图片格式
|
||||||
|
*/
|
||||||
|
public static final String EXCEL_XLSX = "xlsx";
|
||||||
/**
|
/**
|
||||||
* 图片格式
|
* 图片格式
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,13 +19,17 @@ public class BodyWrapperFilter implements Filter {
|
|||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||||
ServletRequest requestWrapper = null;
|
ServletRequest requestWrapper = null;
|
||||||
if(servletRequest instanceof HttpServletRequest) {
|
if (org.springframework.util.StringUtils.hasLength(servletRequest.getContentType()) && servletRequest.getContentType().contains("multipart/form-data")) {
|
||||||
requestWrapper = new CustomHttpServletRequestWrapper((HttpServletRequest) servletRequest);
|
|
||||||
}
|
|
||||||
if(requestWrapper == null) {
|
|
||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
} else {
|
}else {
|
||||||
filterChain.doFilter(requestWrapper, servletResponse);
|
if (servletRequest instanceof HttpServletRequest) {
|
||||||
|
requestWrapper = new CustomHttpServletRequestWrapper((HttpServletRequest) servletRequest);
|
||||||
|
}
|
||||||
|
if (requestWrapper == null) {
|
||||||
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
|
} else {
|
||||||
|
filterChain.doFilter(requestWrapper, servletResponse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,17 @@
|
|||||||
package com.cool.store.controller;
|
package com.cool.store.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.cool.store.entity.HyPartnerLineDO;
|
|
||||||
import com.cool.store.exception.ApiException;
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.request.AddLineRequest;
|
import com.cool.store.request.AddLineRequest;
|
||||||
import com.cool.store.response.ResponseResult;
|
import com.cool.store.response.ResponseResult;
|
||||||
import com.cool.store.service.LineHighSeasService;
|
import com.cool.store.service.LineHighSeasService;
|
||||||
import com.cool.store.utils.poi.ExcelUtil;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: hxd
|
* @Author: hxd
|
||||||
@@ -28,21 +23,20 @@ import java.util.List;
|
|||||||
public class LineHighSeasController {
|
public class LineHighSeasController {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private LineHighSeasService lineHighSeasService;
|
private LineHighSeasService lineHighSeasService;
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ApiOperation("新建线索")
|
@ApiOperation("新建线索")
|
||||||
public ResponseResult addLine(@RequestBody @Valid AddLineRequest request) throws ApiException {
|
public ResponseResult addLine(@RequestBody @Valid AddLineRequest request) throws ApiException {
|
||||||
|
|
||||||
return ResponseResult.success(lineHighSeasService.addLine(request));
|
return ResponseResult.success(lineHighSeasService.addLine(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/import")
|
@PostMapping(value = "/import")
|
||||||
@ApiOperation("批量导入线索")
|
@ApiOperation("批量导入线索")
|
||||||
public ResponseResult importLine(MultipartFile file) throws Exception {
|
public ResponseResult importLine(@RequestParam(value = "file") MultipartFile file) throws Exception {
|
||||||
return lineHighSeasService.importLine(file);
|
return lineHighSeasService.importLine(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user