多品牌使用
This commit is contained in:
@@ -20,7 +20,8 @@ public enum ErrorCodeEnum {
|
||||
PARTNER_MOBILE_INCORRECT(418, "请输入正确的手机号", null),
|
||||
PUBLIC_LINE_NOT_FOLLOW(419, "该线索已存在公海,无跟进人", null),
|
||||
LINE_EXIST_FOLLOW(420, "该线索已存在,跟进人为【{0},{1}】", null),
|
||||
|
||||
INTERNAL_SERVER_ERROR(50000, "服务器异常", null),
|
||||
NO_DATA(50001,"无数据导出",null),
|
||||
ERROR_MESSAGE(421, "{0}", null),
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.cool.store.enums;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/24/下午7:37
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
public enum FileTypeEnum {
|
||||
TO_BE_ASSIGNED_LINE("toBeAssignedLine","待分配线索表"),
|
||||
TEAM_LINE("team_line","团队线索表"),
|
||||
TEAM_POINT("team_point","团队铺位管理表"),
|
||||
MY_POINT("my_point","我的铺位管理表"),
|
||||
MY_FRANCHISEES("my_franchisees","我的加盟商"),
|
||||
TEAM_FRANCHISEES("team_franchisees","团队加盟商"),
|
||||
PREPARATION("preparation","进度管理表"),
|
||||
;
|
||||
private String fileType;
|
||||
private String desc;
|
||||
private FileTypeEnum(String fileType, String desc) {
|
||||
this.fileType = fileType;
|
||||
this.desc = desc;
|
||||
}
|
||||
public String getFileType() {
|
||||
return fileType;
|
||||
}
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.cool.store.enums;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/24/下午7:44
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
public enum ImportStatusEnum {
|
||||
Ongoing(1,"进行中"),
|
||||
success(2,"成功"),
|
||||
fail(3,"失败");
|
||||
private int code;
|
||||
private String msg;
|
||||
ImportStatusEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
|
||||
import com.cool.store.entity.ImportTaskDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author 邵凌志
|
||||
* @date 2020/12/9 17:58
|
||||
*/
|
||||
@Mapper
|
||||
public interface ImportTaskMapper {
|
||||
|
||||
Integer insert(@Param("eid") String eid, @Param("task") ImportTaskDO task);
|
||||
|
||||
List<ImportTaskDO> getAllImportTask(@Param("eid") String eid, @Param("fileType") String fileType,
|
||||
@Param("userId") String userId, @Param("isImport") Boolean isImport,
|
||||
@Param("status") Integer status);
|
||||
|
||||
Integer update(@Param("eid") String eid, @Param("task")ImportTaskDO task);
|
||||
|
||||
|
||||
ImportTaskDO getImportTaskById(@Param("eid") String eid, @Param("id")Long id);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cool.store.mapper.ImportTaskMapper">
|
||||
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="task.id" >
|
||||
insert into import_task_${eid}
|
||||
(file_name, file_type, is_import, status, file_url, create_user_id, create_name, create_time, remark)
|
||||
values
|
||||
(
|
||||
#{task.fileName},
|
||||
#{task.fileType},
|
||||
#{task.isImport},
|
||||
#{task.status},
|
||||
#{task.fileUrl},
|
||||
#{task.createUserId},
|
||||
#{task.createName},
|
||||
#{task.createTime},
|
||||
#{task.remark}
|
||||
)
|
||||
</insert>
|
||||
<update id="update">
|
||||
update import_task_${eid}
|
||||
set status = #{task.status}
|
||||
<if test="task.fileUrl != null and task.fileUrl != '' ">
|
||||
, file_url = #{task.fileUrl}
|
||||
</if>
|
||||
<if test="task.remark != null and task.remark != '' ">
|
||||
, remark = #{task.remark}
|
||||
</if>
|
||||
<if test="task.successNum != null ">
|
||||
, success_num = #{task.successNum}
|
||||
</if>
|
||||
<if test="task.totalNum != null ">
|
||||
, total_num = #{task.totalNum}
|
||||
</if>
|
||||
<if test="task.fileName != null and task.fileName != '' ">
|
||||
, file_name = #{task.fileName}
|
||||
</if>
|
||||
where id = #{task.id}
|
||||
</update>
|
||||
<select id="getAllImportTask" resultType="com.cool.store.entity.ImportTaskDO">
|
||||
select
|
||||
id,
|
||||
file_name as fileName,
|
||||
status,
|
||||
file_type as fileType,
|
||||
is_import as isImport,
|
||||
file_url as fileUrl,
|
||||
create_name as createName,
|
||||
create_time as createTime,
|
||||
remark,
|
||||
success_num as successNum,
|
||||
total_num as totalNum
|
||||
from import_task_${eid}
|
||||
where create_user_id = #{userId}
|
||||
<if test="fileType != null and fileType != '' ">
|
||||
and file_type = #{fileType}
|
||||
</if>
|
||||
<if test="isImport != null">
|
||||
and is_import = #{isImport}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="getImportTaskById" resultType="com.cool.store.entity.ImportTaskDO">
|
||||
select
|
||||
id,
|
||||
file_name as fileName,
|
||||
status,
|
||||
file_type as fileType,
|
||||
is_import as isImport,
|
||||
file_url as fileUrl,
|
||||
create_name as createName,
|
||||
create_time as createTime,
|
||||
remark,
|
||||
success_num as successNum,
|
||||
total_num as totalNum
|
||||
from import_task_${eid}
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -438,8 +438,8 @@
|
||||
<if test="request.investmentManagerUserId != null and request.investmentManagerUserId != ''">
|
||||
and a.investment_manager = #{request.investmentManagerUserId}
|
||||
</if>
|
||||
<if test="regionIds !=null and regionIds.size>0">
|
||||
<foreach collection="regionIds" item="regionId" open="and a.region_id in (" close=")" separator=",">
|
||||
<if test="request.regionIds !=null and request.regionIds.size>0">
|
||||
<foreach collection="request.regionIds" item="regionId" open="and a.region_id in (" close=")" separator=",">
|
||||
#{regionId}
|
||||
</foreach>
|
||||
</if>
|
||||
@@ -473,8 +473,8 @@
|
||||
and a.development_manager = #{request.queryUserId}
|
||||
</if>
|
||||
</if>
|
||||
<if test="regionIds !=null and regionIds.size>0">
|
||||
<foreach collection="regionIds" item="regionId" open="and a.region_id in (" close=")" separator=",">
|
||||
<if test="request.regionIds !=null and request.regionIds.size>0">
|
||||
<foreach collection="request.regionIds" item="regionId" open="and a.region_id in (" close=")" separator=",">
|
||||
#{regionId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.cool.store.dto;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2024/4/26 15:00
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@ContentStyle(horizontalAlignment = HorizontalAlignment.LEFT,wrapped = true)
|
||||
public class PreparationScheduleDTO {
|
||||
|
||||
@ExcelProperty("加盟商名称")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("加盟商名称")
|
||||
private String username;
|
||||
|
||||
@ExcelProperty("加盟商手机号")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("加盟手机号")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("门店名称")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("门店名称")
|
||||
private String shopName;
|
||||
|
||||
@ExcelProperty("门店编号")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("门店编码")
|
||||
private String storeNum;
|
||||
|
||||
|
||||
@ExcelProperty("当前进度")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("当前进度")
|
||||
private String currentProgress;
|
||||
|
||||
@ExcelProperty("计划开店时间")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("计划开店时间")
|
||||
private String planOpenTime;
|
||||
|
||||
@ExcelProperty("开店时长(小时)")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("开店时长")
|
||||
private String days;
|
||||
|
||||
@ExcelProperty("所属区域")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("所属站区")
|
||||
private String regionNodeName;
|
||||
|
||||
@ExcelProperty("招商经理")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("招商经理名称")
|
||||
private String investmentManagerName;
|
||||
|
||||
@ExcelProperty("招商经理名称")
|
||||
@ColumnWidth(30)
|
||||
@ApiModelProperty("督导")
|
||||
private String supervisionName;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.cool.store.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 邵凌志
|
||||
* @date 2020/12/9 16:00
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ImportTaskDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件类型:region-区域,store-门店,user-人员
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* 是否是导入
|
||||
*/
|
||||
private Boolean isImport;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 成功条数
|
||||
*/
|
||||
private Integer successNum;
|
||||
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
private Integer totalNum;
|
||||
|
||||
/**
|
||||
* 上传人员id
|
||||
*/
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 上传人
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
*/
|
||||
private Long createTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public ImportTaskDO(String fileName, String fileType, Boolean isImport, Integer status, String createUserId, String createName, Long createTime) {
|
||||
this.fileName = fileName;
|
||||
this.fileType = fileType;
|
||||
this.isImport = isImport;
|
||||
this.status = status;
|
||||
this.createUserId = createUserId;
|
||||
this.createName = createName;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.vo.Preparation;
|
||||
|
||||
import com.cool.store.vo.BaseInfoVO;
|
||||
import com.lowagie.text.alignment.HorizontalAlignment;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
package com.cool.store.oss;
|
||||
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.aliyun.oss.event.ProgressEvent;
|
||||
import com.aliyun.oss.event.ProgressEventType;
|
||||
import com.aliyun.oss.event.ProgressListener;
|
||||
import com.aliyun.oss.model.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Created by gavin on 15/8/5.
|
||||
* 阿里云OSS客户端
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OssClientService {
|
||||
|
||||
@Value("${oss.endpoint}")
|
||||
private String endpoint;
|
||||
@Value("${oss.accessKeyId}")
|
||||
private String accessKeyId;
|
||||
@Value("${oss.accessKeySecret}")
|
||||
private String accessKeySecret;
|
||||
@Value("${oss.bucket}")
|
||||
private String bucketName;
|
||||
|
||||
@Value("${oss.host}")
|
||||
private String ossHost;
|
||||
|
||||
|
||||
private OSSClient client = null;
|
||||
|
||||
private OSSClient getClient() {
|
||||
if(client==null) {
|
||||
synchronized(this){
|
||||
client= new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
}
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
/**OSSClient
|
||||
* 获取上传进度回调
|
||||
*/
|
||||
class PutObjectProgressListener implements ProgressListener {
|
||||
|
||||
private long bytesWritten = 0;
|
||||
private long totalBytes = -1;
|
||||
private boolean succeed = false;
|
||||
|
||||
@Override
|
||||
public void progressChanged(ProgressEvent progressEvent) {
|
||||
long bytes = progressEvent.getBytes();
|
||||
ProgressEventType eventType = progressEvent.getEventType();
|
||||
switch (eventType) {
|
||||
case TRANSFER_STARTED_EVENT:
|
||||
log.info("Start to upload......");
|
||||
break;
|
||||
|
||||
case REQUEST_CONTENT_LENGTH_EVENT:
|
||||
this.totalBytes = bytes;
|
||||
log.info(this.totalBytes + " bytes in total will be uploaded to OSS");
|
||||
break;
|
||||
|
||||
case REQUEST_BYTE_TRANSFER_EVENT:
|
||||
this.bytesWritten += bytes;
|
||||
if (this.totalBytes != -1) {
|
||||
int percent = (int) (this.bytesWritten * 100.0 / this.totalBytes);
|
||||
log.info(bytes + " bytes have been written at this time, upload progress: " +
|
||||
percent + "%(" + this.bytesWritten + "/" + this.totalBytes + ")");
|
||||
} else {
|
||||
log.info(bytes + " bytes have been written at this time, upload ratio: unknown" +
|
||||
"(" + this.bytesWritten + "/...)");
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANSFER_COMPLETED_EVENT:
|
||||
this.succeed = true;
|
||||
log.info("Succeed to upload, " + this.bytesWritten + " bytes have been transferred in total");
|
||||
break;
|
||||
|
||||
case TRANSFER_FAILED_EVENT:
|
||||
log.info("Failed to upload, " + this.bytesWritten + " bytes have been transferred");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSucceed() {
|
||||
return succeed;
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectMetadata getObject(String key) {
|
||||
OSSClient ossClient = getClient();
|
||||
ObjectMetadata metadata = ossClient.getObjectMetadata(bucketName, key);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public InputStream getFileContent(String key) {
|
||||
OSSClient ossClient = getClient();
|
||||
InputStream content = ossClient.getObject(bucketName, key).getObjectContent();
|
||||
return content;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void downloadFile(String key, String filePath, String tempFilePath) {
|
||||
|
||||
OSSClient ossClient = getClient();
|
||||
DownloadFileRequest downloadFileRequest = new DownloadFileRequest(bucketName, key);
|
||||
downloadFileRequest.setDownloadFile(filePath);
|
||||
downloadFileRequest.setPartSize(1 * 1024 * 1024L);
|
||||
downloadFileRequest.setTaskNum(10);
|
||||
downloadFileRequest.setEnableCheckpoint(true);
|
||||
downloadFileRequest.setCheckpointFile(tempFilePath);
|
||||
try {
|
||||
DownloadFileResult downloadRes = ossClient.downloadFile(downloadFileRequest);
|
||||
downloadRes.getObjectMetadata();
|
||||
} catch (Throwable throwable) {
|
||||
log.error("downloadFile error", throwable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到阿里云OSS
|
||||
*
|
||||
* @param fileName
|
||||
* @param inputStream
|
||||
* @param contentLength
|
||||
* @param contentType
|
||||
* @throws Exception
|
||||
*/
|
||||
@Async("taskExecutor")
|
||||
public void putObjectAsync(String fileName, InputStream inputStream, Long contentLength, String contentType) throws Exception {
|
||||
putObject(fileName, inputStream, contentLength, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到阿里云OSS
|
||||
*
|
||||
* @param fileName
|
||||
* @param inputStream
|
||||
* @param contentLength
|
||||
* @param contentType
|
||||
* @throws Exception
|
||||
*/
|
||||
public String putObject(String fileName, InputStream inputStream, Long contentLength, String contentType) throws Exception {
|
||||
|
||||
OSSClient ossClient = getClient();
|
||||
|
||||
try {
|
||||
ObjectMetadata meta = new ObjectMetadata();
|
||||
meta.setContentLength(contentLength);
|
||||
|
||||
meta.setContentType(contentType);
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileName, inputStream, meta);
|
||||
log.info("uploadBaseImage, send...");
|
||||
PutObjectResult p = ossClient.putObject(putObjectRequest.withProgressListener(new PutObjectProgressListener()));
|
||||
String url = "https://"+bucketName+"."+endpoint +"/"+ fileName;
|
||||
log.info("uploadBaseImage, send over,url:{}", url);
|
||||
return url;
|
||||
|
||||
// return p.getETag();
|
||||
|
||||
} catch (OSSException oe) {
|
||||
log.warn("oss出现问题", oe);
|
||||
log.error("Caught an OSSException, which means your request made it to OSS, " + "but was rejected with an error response for some reason.");
|
||||
log.error("Error Message: " + oe.getErrorCode());
|
||||
log.error("Error Code: " + oe.getErrorCode());
|
||||
log.error("Request ID: " + oe.getRequestId());
|
||||
log.error("Host ID: " + oe.getHostId());
|
||||
throw oe;
|
||||
} catch (ClientException ce) {
|
||||
log.warn("oss客户端出现问题", ce);
|
||||
log.error("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
log.error("Error Message: " + ce.getMessage());
|
||||
throw ce;
|
||||
}catch (Exception e){
|
||||
log.warn("uploadBaseImage, error");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到阿里云OSS
|
||||
*
|
||||
* @param fileName
|
||||
* @param inputStream
|
||||
*/
|
||||
public String putObject(String fileName, InputStream inputStream) {
|
||||
|
||||
OSSClient ossClient = getClient();
|
||||
|
||||
try {
|
||||
log.info("uploadBaseImage, send...");
|
||||
PutObjectResult p = ossClient.putObject(bucketName, fileName, inputStream);
|
||||
log.info("uploadBaseImage, send over");
|
||||
String url = ossHost + fileName;
|
||||
return url;
|
||||
// return p.getETag();
|
||||
} catch (OSSException oe) {
|
||||
log.warn("oss出现问题", oe);
|
||||
log.error("Caught an OSSException, which means your request made it to OSS, " + "but was rejected with an error response for some reason.");
|
||||
log.error("Error Message: " + oe.getErrorCode());
|
||||
log.error("Error Code: " + oe.getErrorCode());
|
||||
log.error("Request ID: " + oe.getRequestId());
|
||||
log.error("Host ID: " + oe.getHostId());
|
||||
throw oe;
|
||||
} catch (ClientException ce) {
|
||||
log.warn("oss客户端出现问题", ce);
|
||||
log.error("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
log.error("Error Message: " + ce.getMessage());
|
||||
throw ce;
|
||||
}catch (Exception e){
|
||||
log.warn("uploadBaseImage, error");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.Preparation.PreparationDTO;
|
||||
import com.cool.store.entity.ImportTaskDO;
|
||||
import com.cool.store.entity.LineInfoDO;
|
||||
import com.cool.store.entity.PointInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/29/下午1:57
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
public interface ExportRealizeService {
|
||||
|
||||
void preparationList( List<PreparationDTO> preparationDTOS,ImportTaskDO importTaskDO);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.request.*;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/24/下午4:57
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
public interface ExportService {
|
||||
Boolean preparationList(PreparationRequest request,LoginUserInfo loginUserInfo);
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.*;
|
||||
|
||||
import com.cool.store.dto.Preparation.PreparationDTO;
|
||||
import com.cool.store.dto.Preparation.ScheduleDTO;
|
||||
import com.cool.store.dto.PreparationScheduleDTO;
|
||||
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.enums.point.*;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.ImportTaskMapper;
|
||||
import com.cool.store.mapper.IntentAgreementMapper;
|
||||
import com.cool.store.mapper.PointInfoMapper;
|
||||
import com.cool.store.request.InitiatingRequest;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.utils.easyExcel.EasyExcelUtil;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cool.store.utils.poi.DateUtils.YYYY_MM_DD;
|
||||
import static com.cool.store.utils.poi.DateUtils.YYYY_MM_DD_HH_MM_SS;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/29/下午1:58
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ExportRealizeServiceImpl implements ExportRealizeService {
|
||||
@Resource
|
||||
private PointInfoMapper pointInfoMapper;
|
||||
@Resource
|
||||
private ImportTaskMapper importTaskMapper;
|
||||
@Autowired
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
@Autowired
|
||||
private HyPartnerUserChannelDAO hyPartnerUserChannelDAO;
|
||||
@Resource
|
||||
EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
SysRoleService sysRoleService;
|
||||
@Resource
|
||||
UserAuthMappingService userAuthMappingService;
|
||||
@Resource
|
||||
private RegionService regionService;
|
||||
@Resource
|
||||
HyOpenAreaInfoDAO hyOpenAreaInfoDAO;
|
||||
@Resource
|
||||
DeskService deskService;
|
||||
@Resource
|
||||
private EasyExcelUtil easyExcelUtil;
|
||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||
private String eid;
|
||||
@Resource
|
||||
private IntentAgreementMapper intentAgreementMapper;
|
||||
@Resource
|
||||
private ShopInfoDAO shopInfoDAO;
|
||||
@Autowired
|
||||
private ShopStageInfoDAO shopStageInfoDAO;
|
||||
@Resource
|
||||
private QualificationsInfoDAO qualificationsInfoDAO;
|
||||
@Resource
|
||||
private LinePayDAO linePayDAO;
|
||||
@Resource
|
||||
RedisUtilPool redisUtilPool;
|
||||
|
||||
@Autowired
|
||||
private RegionDao regionDao;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void preparationList(List<PreparationDTO> preparationDTOS, ImportTaskDO importTaskDO) {
|
||||
Boolean flag = Boolean.TRUE;
|
||||
String url = "";
|
||||
try {
|
||||
List<Long> shopIds = preparationDTOS.stream().map(PreparationDTO::getId).collect(Collectors.toList());
|
||||
List<ScheduleDTO> scheduleList = shopStageInfoDAO.getScheduleList(shopIds);
|
||||
List<ShopStageInfoDO> shopContractActualCompletionTime = shopStageInfoDAO.getShopContractActualCompletionTime(shopIds);
|
||||
Map<Long, ScheduleDTO> scheduleDTOMap = scheduleList.stream().collect(Collectors.toMap(ScheduleDTO::getShopId, x -> x));
|
||||
Map<Long, ShopStageInfoDO> shopStageInfoDOMap = shopContractActualCompletionTime.stream().collect(Collectors.toMap(ShopStageInfoDO::getShopId, x -> x));
|
||||
List<Long> regionIds = preparationDTOS.stream().map(PreparationDTO::getRegionId).collect(Collectors.toList());
|
||||
Map<Long, String> regionNameMap = regionService.getBelongWarRegionNameMap(regionIds);
|
||||
Set<String> userIds = preparationDTOS.stream().filter(x -> StringUtils.isNotEmpty(x.getShopManagerUserId())).map(PreparationDTO::getShopManagerUserId).collect(Collectors.toSet());
|
||||
userIds.addAll(preparationDTOS.stream().filter(x -> StringUtils.isNotEmpty(x.getInvestmentManager())).map(PreparationDTO::getInvestmentManager).collect(Collectors.toSet()));
|
||||
userIds.addAll(preparationDTOS.stream().filter(x -> StringUtils.isNotEmpty(x.getSupervisorUserId())).map(PreparationDTO::getSupervisorUserId).collect(Collectors.toSet()));
|
||||
Map<String, EnterpriseUserDO> userInfoMap = enterpriseUserDAO.getUserInfoMap(new ArrayList<>(userIds));
|
||||
|
||||
List<PreparationScheduleDTO> result = new ArrayList<>();
|
||||
preparationDTOS.forEach(x -> {
|
||||
PreparationScheduleDTO dto1 = new PreparationScheduleDTO();
|
||||
dto1.setMobile(x.getMobile());
|
||||
dto1.setUsername(x.getUsername());
|
||||
dto1.setShopName(x.getShopName());
|
||||
dto1.setPlanOpenTime(DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, x.getPlanOpenTime()));
|
||||
dto1.setStoreNum(x.getStoreNum());
|
||||
dto1.setSupervisionName(userInfoMap.getOrDefault(x.getSupervisorUserId(), new EnterpriseUserDO()).getName());
|
||||
dto1.setInvestmentManagerName(userInfoMap.getOrDefault(x.getInvestmentManager(), new EnterpriseUserDO()).getName());
|
||||
dto1.setRegionNodeName(regionNameMap.getOrDefault(x.getRegionId(), ""));
|
||||
ScheduleDTO dto = scheduleDTOMap.getOrDefault(x.getId(), new ScheduleDTO());
|
||||
dto1.setCurrentProgress(dto.getTotalColumn().toString() + "/" + dto.getCompletionColumn().toString());
|
||||
ShopStageInfoDO stageInfoDO = shopStageInfoDOMap.getOrDefault(x.getId(), new ShopStageInfoDO());
|
||||
if (StringUtils.isNotEmpty(stageInfoDO.getActualCompleteTime()) && x.getPlanOpenTime() != null) {
|
||||
long between = ChronoUnit.SECONDS.between(DateUtils.strToDate(stageInfoDO.getActualCompleteTime(), DateUtils.YYYY_MM_DD_HH_MM_SS).toInstant(), x.getPlanOpenTime().toInstant());
|
||||
double days = (double) between / (24 * 60 * 60);
|
||||
String day = String.format("%.1f", days);
|
||||
if (StringUtils.isNotEmpty(day)) {
|
||||
dto1.setDays(day);
|
||||
}
|
||||
}
|
||||
result.add(dto1);
|
||||
});
|
||||
url = easyExcelUtil.exportExcel(PreparationScheduleDTO.class, result, null, FileTypeEnum.PREPARATION.getDesc(), FileTypeEnum.PREPARATION.getDesc());
|
||||
} catch (Throwable e) {
|
||||
flag = Boolean.FALSE;
|
||||
log.error("fileUpload upload err, originFileName={}", FileTypeEnum.TEAM_LINE.getDesc(), e);
|
||||
throw new ServiceException(ErrorCodeEnum.INTERNAL_SERVER_ERROR);
|
||||
} finally {
|
||||
if (flag) {
|
||||
importTaskDO.setStatus(ImportStatusEnum.success.getCode());
|
||||
importTaskDO.setFileUrl(url);
|
||||
} else {
|
||||
importTaskDO.setStatus(ImportStatusEnum.fail.getCode());
|
||||
}
|
||||
importTaskMapper.update(eid, importTaskDO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.HyOpenAreaInfoDAO;
|
||||
import com.cool.store.dao.LineInfoDAO;
|
||||
import com.cool.store.dao.ShopInfoDAO;
|
||||
import com.cool.store.dto.Preparation.PreparationDTO;
|
||||
import com.cool.store.dto.Preparation.ScheduleDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.FileTypeEnum;
|
||||
import com.cool.store.enums.ImportStatusEnum;
|
||||
import com.cool.store.enums.point.PointStatusEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.ImportTaskMapper;
|
||||
import com.cool.store.mapper.PointInfoMapper;
|
||||
import com.cool.store.request.*;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.utils.easyExcel.EasyExcelUtil;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import com.cool.store.vo.Preparation.PreparationScheduleVO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/24/下午5:03
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
@Service
|
||||
public class ExportServiceImpl implements ExportService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ExportServiceImpl.class);
|
||||
@Resource
|
||||
private ExportRealizeService exportRealizeService;
|
||||
@Resource
|
||||
private PointInfoMapper pointInfoMapper;
|
||||
@Resource
|
||||
private ImportTaskMapper importTaskMapper;
|
||||
@Autowired
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
@Resource
|
||||
SysRoleService sysRoleService;
|
||||
@Resource
|
||||
UserAuthMappingService userAuthMappingService;
|
||||
@Resource
|
||||
private RegionService regionService;
|
||||
@Resource
|
||||
HyOpenAreaInfoDAO hyOpenAreaInfoDAO;
|
||||
@Resource
|
||||
private EasyExcelUtil easyExcelUtil;
|
||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||
private String eid;
|
||||
@Autowired
|
||||
private ShopInfoDAO shopInfoDAO;
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean preparationList(PreparationRequest request,LoginUserInfo loginUserInfo) {
|
||||
if (!sysRoleService.checkIsAdmin(request.getCurUserId())) {
|
||||
request.setAuthRegionIds(userAuthMappingService.getAuthRegionIdAndSubRegionIdByUserId(request.getCurUserId()));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(request.getRegionIds())) {
|
||||
if (request.getRegionIds().contains(CommonConstants.ROOT_DEPT_ID_STR)) {
|
||||
request.setRegionIds(null);
|
||||
} else {
|
||||
request.setRegionIds(regionService.getSubRegionIdsByRegionIds(request.getRegionIds()));
|
||||
}
|
||||
}
|
||||
//开业进度数据
|
||||
List<PreparationDTO> preparationDTOS = shopInfoDAO.ListByCondition(request);
|
||||
if (CollectionUtils.isEmpty(preparationDTOS)) {
|
||||
throw new ServiceException(ErrorCodeEnum.NO_DATA);
|
||||
}
|
||||
ImportTaskDO importTaskDO = new ImportTaskDO();
|
||||
importTaskDO.setStatus(ImportStatusEnum.Ongoing.getCode());
|
||||
importTaskDO.setFileName(FileTypeEnum.PREPARATION.getDesc());
|
||||
importTaskDO.setIsImport(Boolean.FALSE);
|
||||
importTaskDO.setFileType(FileTypeEnum.PREPARATION.getFileType());
|
||||
importTaskDO.setCreateUserId(request.getCurUserId());
|
||||
importTaskDO.setCreateTime(new Date().getTime());
|
||||
importTaskDO.setCreateName(loginUserInfo.getName());
|
||||
importTaskMapper.insert(eid, importTaskDO);
|
||||
exportRealizeService.preparationList(preparationDTOS, importTaskDO);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.cool.store.utils.easyExcel;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy;
|
||||
import com.cool.store.mapper.ImportTaskMapper;
|
||||
import com.cool.store.oss.OssClientService;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EasyExcelUtil {
|
||||
|
||||
private static final String EXCEL_SUFFIX = ".xlsx";
|
||||
private static final String CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||
private String eid;
|
||||
@Resource
|
||||
private OssClientService ossClientService;
|
||||
@Resource
|
||||
private ImportTaskMapper importTaskMapper;
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param fileName 保存文件的标题
|
||||
* @param head 保存excel对象的实体类
|
||||
* @param list 需要保存的数据列表
|
||||
* @throws IOException 异常捕获
|
||||
*/
|
||||
public String exportExcel( Class head, List list, Set<String> set, String sheetName, String fileName) throws Exception {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
if (set == null) {
|
||||
EasyExcel.write(outputStream, head)
|
||||
.autoCloseStream(true)
|
||||
.registerWriteHandler(new SimpleRowHeightStyleStrategy((short)25,(short)25))
|
||||
.sheet(sheetName)
|
||||
.doWrite(list);
|
||||
} else {
|
||||
EasyExcel.write(outputStream, head).autoCloseStream(true).includeColumnFiledNames(set).sheet(sheetName)
|
||||
.doWrite(list);
|
||||
}
|
||||
byte[] bytes = outputStream.toByteArray();
|
||||
long size = bytes.length;
|
||||
InputStream is = new ByteArrayInputStream(bytes);
|
||||
if (StringUtils.isNotBlank(fileName) && fileName.contains(".")) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf("."));
|
||||
}
|
||||
String file = getUploadPath(eid) + fileName + "_" + UUIDUtils.get32UUID() + EXCEL_SUFFIX;
|
||||
return ossClientService.putObject(file, is, size, CONTENT_TYPE);
|
||||
|
||||
}
|
||||
|
||||
private String getUploadPath(String eid) {
|
||||
String time = DateUtil.format(new Date(), "yyMM");
|
||||
return "eid" + "/" + eid + "/" + time + "/";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.cool.store.controller.webb;
|
||||
|
||||
import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.request.*;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.ExportService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2024/10/25/上午10:20
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pc/export")
|
||||
@Api("导出")
|
||||
public class ExportController {
|
||||
|
||||
@Resource
|
||||
private ExportService exportService;
|
||||
|
||||
|
||||
@PostMapping("/preparationList")
|
||||
@ApiOperation("进度管理")
|
||||
public ResponseResult preparationList(@RequestBody PreparationRequest request) {
|
||||
request.setCurUserId(CurrentUserHolder.getUserId());
|
||||
return ResponseResult.success(exportService.preparationList(request, CurrentUserHolder.getUser()));
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-in
|
||||
rocketmq.topic=simple_message
|
||||
|
||||
#oss配置
|
||||
oss.host=https://oss-store.coolcollege.cn/
|
||||
oss.accessKeyId=LTAI5tRSXy2MrqaaBJ6gReur
|
||||
oss.accessKeySecret=FFsl8d9batprJ0vXr0k4Y8ada40Wm2
|
||||
oss.endpoint=oss-cn-hangzhou.aliyuncs.com
|
||||
|
||||
@@ -32,6 +32,7 @@ rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-in
|
||||
rocketmq.topic=simple_message
|
||||
|
||||
#oss配置
|
||||
oss.host=https://oss-store.coolcollege.cn/
|
||||
oss.accessKeyId=LTAI5tS2khSZfYrTL5cerHbY
|
||||
oss.accessKeySecret=YChLLev5KRZmgHCAkU7odkhGWk1aif
|
||||
oss.endpoint=oss-cn-hangzhou.aliyuncs.com
|
||||
|
||||
@@ -32,6 +32,7 @@ rocketmq.nameSrvAdder=http://rmq-cn-9lb38l1rx04.cn-hangzhou.rmq.aliyuncs.com:808
|
||||
rocketmq.topic=simple_message
|
||||
|
||||
#oss配置
|
||||
oss.host=https://oss-store.coolcollege.cn/
|
||||
oss.accessKeyId=LTAI5tRSXy2MrqaaBJ6gReur
|
||||
oss.accessKeySecret=FFsl8d9batprJ0vXr0k4Y8ada40Wm2
|
||||
oss.endpoint=oss-cn-hangzhou.aliyuncs.com
|
||||
|
||||
@@ -32,6 +32,7 @@ rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-in
|
||||
rocketmq.topic=simple_message
|
||||
|
||||
#oss配置
|
||||
oss.host=https://oss-store.coolcollege.cn/
|
||||
oss.accessKeyId=LTAI5tS2khSZfYrTL5cerHbY
|
||||
oss.accessKeySecret=YChLLev5KRZmgHCAkU7odkhGWk1aif
|
||||
oss.endpoint=oss-cn-hangzhou.aliyuncs.com
|
||||
|
||||
@@ -32,6 +32,7 @@ rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-in
|
||||
rocketmq.topic=simple_message
|
||||
|
||||
#oss配置
|
||||
oss.host=https://oss-store.coolcollege.cn/
|
||||
oss.accessKeyId=LTAI5t6Zk3Y3vyrMXC87jGYB
|
||||
oss.accessKeySecret=6Gw06jtW5xNKWqbhnt1KmVZx1z9Dev
|
||||
oss.endpoint=oss-cn-hangzhou.aliyuncs.com
|
||||
|
||||
Reference in New Issue
Block a user