Commit 5c497366 by zhiwj

调整排序 修改sql

parent 358e0c01
......@@ -2,13 +2,13 @@ package com.gic.enterprise.constant.billing;
public enum FeeTypeEnum {
TOTAL(1, "消费总金额"),
VOICE_CODE(2, "语音验证码"),
SMS(3, "国内短信消费"),
SMS_PACKAGE(4, "短信套餐包(余额支付)"),
RECORDING_STORAGE(5, "语音存储"),
DOUBLE_CALLING(6, "双向呼叫"),
ACCOUNT_BALANCE(7, "余额支付"),
INTERNATIONAL_SMS(8, "海外短信消费");
ACCOUNT_BALANCE(7, "服务市场和供销平台购买明细"),
SMS_PACKAGE(4, "短信套餐包明细(余额支付)"),
SMS(3, "国内短信消费明细"),
INTERNATIONAL_SMS(8, "海外短信消费明细"),
VOICE_CODE(2, "语音验证码消费明细"),
DOUBLE_CALLING(6, "双向呼叫消费明细"),
RECORDING_STORAGE(5, "录音存储消费明细");
private int code;
private String message;
......
......@@ -86,6 +86,31 @@ public class BillingSmsRecordDTO {
*/
private Integer enterpriseSmsPackageId;
/**
* 会员姓名
*/
private String memberName;
/**
* 门店id
*/
private Integer storeId;
/**
* 门店名称
*/
private String storeName;
/**
* 门店分组id
*/
private Integer storeGroupId;
/**
* 门店分组名称
*/
private String storeGroupName;
public Integer getSmsRecordId() {
return smsRecordId;
}
......@@ -213,4 +238,44 @@ public class BillingSmsRecordDTO {
public void setEnterpriseSmsPackageId(Integer enterpriseSmsPackageId) {
this.enterpriseSmsPackageId = enterpriseSmsPackageId;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public Integer getStoreId() {
return storeId;
}
public void setStoreId(Integer storeId) {
this.storeId = storeId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public Integer getStoreGroupId() {
return storeGroupId;
}
public void setStoreGroupId(Integer storeGroupId) {
this.storeGroupId = storeGroupId;
}
public String getStoreGroupName() {
return storeGroupName;
}
public void setStoreGroupName(String storeGroupName) {
this.storeGroupName = storeGroupName;
}
}
\ No newline at end of file
......@@ -116,6 +116,17 @@ public interface BillingRecordApiService {
ServiceResponse<Page<SmsRecordDTO>> listSmsRecord(RecordQO recordQO);
/**
*
* @Title: countSmsRecord
* @Description:
* @author zhiwj
* @param recordQO
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
* @throws
*/
ServiceResponse<Integer> countSmsRecord(RecordQO recordQO);
/**
* 海外消费明细
* @Title: listInternationalSmsRecord
* @Description:
......@@ -126,6 +137,16 @@ public interface BillingRecordApiService {
*/
ServiceResponse<Page<InternationalSmsRecordDTO>> listInternationalSmsRecord(RecordQO recordQO);
/**
* @Title: countInternationalSmsRecord
* @Description:
* @author zhiwj
* @param recordQO
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
* @throws
*/
ServiceResponse<Integer> countInternationalSmsRecord(RecordQO recordQO);
/**
* 语音验证码
* @Title: listVoiceCodeRecord
......@@ -159,5 +180,4 @@ public interface BillingRecordApiService {
* @throws
*/
ServiceResponse<List<Map<String, Object>>> listFee(Integer enterpriseId, String startTime, String endTime);
}
......@@ -72,5 +72,7 @@ public interface TabBillingInternationalSmsRecordMapper {
Page<TabBillingInternationalSmsRecord> listInternationalSmsRecord(RecordQO recordQO);
Integer countInternationalSmsRecord(RecordQO recordQO);
double getTotalFee(@Param("enterpriseId") Integer enterpriseId, @Param("startTime") String startTime, @Param("endTime") String endTime);
}
\ No newline at end of file
......@@ -87,4 +87,6 @@ public interface TabBillingSmsRecordMapper {
Page<TabBillingSmsRecord> listSmsRecord(RecordQO recordQO);
double getTotalFee(@Param("enterpriseId") Integer enterpriseId, @Param("startTime") String startTime, @Param("endTime") String endTime);
Integer countSmsRecord(RecordQO recordQO);
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ public class TabBillingSmsRecord {
/**
* 支付方式
*/
private Integer payType=0;
private Integer payType;
/**
* 应用
......@@ -86,6 +86,31 @@ public class TabBillingSmsRecord {
*/
private Integer enterpriseSmsPackageId;
/**
* 会员姓名
*/
private String memberName;
/**
* 门店id
*/
private Integer storeId;
/**
* 门店名称
*/
private String storeName;
/**
* 门店分组id
*/
private Integer storeGroupId;
/**
* 门店分组名称
*/
private String storeGroupName;
public Integer getSmsRecordId() {
return smsRecordId;
}
......@@ -213,4 +238,44 @@ public class TabBillingSmsRecord {
public void setEnterpriseSmsPackageId(Integer enterpriseSmsPackageId) {
this.enterpriseSmsPackageId = enterpriseSmsPackageId;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public Integer getStoreId() {
return storeId;
}
public void setStoreId(Integer storeId) {
this.storeId = storeId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public Integer getStoreGroupId() {
return storeGroupId;
}
public void setStoreGroupId(Integer storeGroupId) {
this.storeGroupId = storeGroupId;
}
public String getStoreGroupName() {
return storeGroupName;
}
public void setStoreGroupName(String storeGroupName) {
this.storeGroupName = storeGroupName;
}
}
\ No newline at end of file
......@@ -42,4 +42,6 @@ public interface BillingInternationalSmsRecordService {
Double getTotalFee(Integer enterpriseId, String startTime, String endTime);
Integer save(InternationalSmsRecordDTO internationalSmsRecordDTO);
Integer countInternationalSmsRecord(RecordQO recordQO);
}
......@@ -42,7 +42,10 @@ public interface BillingSmsRecordService {
Page<TabBillingSmsRecord> listSmsRecord(RecordQO recordQO);
Integer countSmsRecord(RecordQO recordQO);
Double getTotalFee(Integer enterpriseId, String startTime, String endTime);
Integer saveSmsRecord(SmsRecordDTO smsRecordDTO);
}
......@@ -61,8 +61,9 @@ public class AppletServiceConfigServiceImpl implements AppletServiceConfigServic
appletServiceConfig.setUpdateTime(new Date());
return appletServiceConfig;
}).collect(Collectors.toList());
tabAppletServiceConfigMapper.insertList(configList);
if (CollectionUtils.isNotEmpty(configList)) {
tabAppletServiceConfigMapper.insertList(configList);
}
}
}
......
......@@ -59,4 +59,9 @@ public class BillingInternationalSmsRecordServiceImpl implements BillingInternat
TabBillingInternationalSmsRecord billingInternationalSmsRecord = EntityUtil.changeEntityByJSON(TabBillingInternationalSmsRecord.class, internationalSmsRecordDTO);
return this.tabBillingInternationalSmsRecordMapper.insertSelective(billingInternationalSmsRecord);
}
@Override
public Integer countInternationalSmsRecord(RecordQO recordQO) {
return tabBillingInternationalSmsRecordMapper.countInternationalSmsRecord(recordQO);
}
}
......@@ -49,6 +49,11 @@ public class BillingSmsRecordServiceImpl implements BillingSmsRecordService{
}
@Override
public Integer countSmsRecord(RecordQO recordQO) {
return tabBillingSmsRecordMapper.countSmsRecord(recordQO);
}
@Override
public Double getTotalFee(Integer enterpriseId, String startTime, String endTime) {
return tabBillingSmsRecordMapper.getTotalFee(enterpriseId, startTime, endTime);
}
......
......@@ -114,6 +114,12 @@ public class BillingRecordApiServiceImpl implements BillingRecordApiService {
}
@Override
public ServiceResponse<Integer> countSmsRecord(RecordQO recordQO) {
Integer count = this.billingSmsRecordService.countSmsRecord(recordQO);
return ServiceResponse.success(count);
}
@Override
public ServiceResponse<Page<InternationalSmsRecordDTO>> listInternationalSmsRecord(RecordQO recordQO) {
com.github.pagehelper.Page<TabBillingInternationalSmsRecord> page = this.billingInternationalSmsRecordService.listInternationalSmsRecord(recordQO);
Page<InternationalSmsRecordDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, InternationalSmsRecordDTO.class);
......@@ -121,6 +127,12 @@ public class BillingRecordApiServiceImpl implements BillingRecordApiService {
}
@Override
public ServiceResponse<Integer> countInternationalSmsRecord(RecordQO recordQO) {
Integer count = this.billingInternationalSmsRecordService.countInternationalSmsRecord(recordQO);
return ServiceResponse.success(count);
}
@Override
public ServiceResponse<Page<VoiceCodeRecordDTO>> listVoiceCodeRecord(RecordQO recordQO) {
com.github.pagehelper.Page<TabBillingVoiceCodeRecord> page = this.billingVoiceCodeRecordService.listVoiceCodeRecord(recordQO);
Page<VoiceCodeRecordDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, VoiceCodeRecordDTO.class);
......
......@@ -309,4 +309,26 @@
</where>
order by create_time desc
</select>
<select id="countInternationalSmsRecord" resultType="int">
select
count(*)
from tab_billing_international_sms_record
<where>
<if test="enterpriseId != null ">
and enterprise_id = #{enterpriseId}
</if>
<if test="startTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="appCode != null ">
and app_code = #{appCode}
</if>
<if test="smsContent != null and smsContent != '' ">
and ( sms_content like concat('%', #{smsContent}, '%') or receive_phone like concat('%', #{smsContent}, '%') )
</if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -18,11 +18,16 @@
<result column="deduction_time" jdbcType="TIMESTAMP" property="deductionTime" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="enterprise_sms_package_id" jdbcType="INTEGER" property="enterpriseSmsPackageId" />
<result column="member_name" jdbcType="VARCHAR" property="memberName" />
<result column="store_id" jdbcType="INTEGER" property="storeId" />
<result column="store_name" jdbcType="VARCHAR" property="storeName" />
<result column="store_group_id" jdbcType="INTEGER" property="storeGroupId" />
<result column="store_group_name" jdbcType="VARCHAR" property="storeGroupName" />
</resultMap>
<sql id="Base_Column_List">
sms_record_id, status, send_time, receive_phone, pay_type, app_code, app_name, sms_type,
sms_record_id, status, send_time, receive_phone, pay_type, app_code, app_name, sms_type,
bill_number, fee, sms_content, create_time, update_time, deduction_time, enterprise_id,
enterprise_sms_package_id
enterprise_sms_package_id, member_name, store_id, store_name, store_group_id, store_group_name
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
......@@ -36,17 +41,21 @@
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabBillingSmsRecord">
insert into tab_billing_sms_record (sms_record_id, status, send_time,
receive_phone, pay_type, app_code,
receive_phone, pay_type, app_code,
app_name, sms_type, bill_number,
fee, sms_content, create_time,
update_time, deduction_time, enterprise_id,
enterprise_sms_package_id)
enterprise_sms_package_id, member_name, store_id,
store_name, store_group_id, store_group_name
)
values (#{smsRecordId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{sendTime,jdbcType=TIMESTAMP},
#{receivePhone,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, #{appCode,jdbcType=VARCHAR},
#{receivePhone,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, #{appCode,jdbcType=VARCHAR},
#{appName,jdbcType=VARCHAR}, #{smsType,jdbcType=INTEGER}, #{billNumber,jdbcType=INTEGER},
#{fee,jdbcType=DOUBLE}, #{smsContent,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deductionTime,jdbcType=TIMESTAMP}, #{enterpriseId,jdbcType=INTEGER},
#{enterpriseSmsPackageId,jdbcType=INTEGER})
#{enterpriseSmsPackageId,jdbcType=INTEGER}, #{memberName,jdbcType=VARCHAR}, #{storeId,jdbcType=INTEGER},
#{storeName,jdbcType=VARCHAR}, #{storeGroupId,jdbcType=INTEGER}, #{storeGroupName,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.enterprise.entity.TabBillingSmsRecord">
insert into tab_billing_sms_record
......@@ -99,6 +108,21 @@
<if test="enterpriseSmsPackageId != null">
enterprise_sms_package_id,
</if>
<if test="memberName != null">
member_name,
</if>
<if test="storeId != null">
store_id,
</if>
<if test="storeName != null">
store_name,
</if>
<if test="storeGroupId != null">
store_group_id,
</if>
<if test="storeGroupName != null">
store_group_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="smsRecordId != null">
......@@ -149,6 +173,21 @@
<if test="enterpriseSmsPackageId != null">
#{enterpriseSmsPackageId,jdbcType=INTEGER},
</if>
<if test="memberName != null">
#{memberName,jdbcType=VARCHAR},
</if>
<if test="storeId != null">
#{storeId,jdbcType=INTEGER},
</if>
<if test="storeName != null">
#{storeName,jdbcType=VARCHAR},
</if>
<if test="storeGroupId != null">
#{storeGroupId,jdbcType=INTEGER},
</if>
<if test="storeGroupName != null">
#{storeGroupName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.enterprise.entity.TabBillingSmsRecord">
......@@ -199,6 +238,21 @@
<if test="enterpriseSmsPackageId != null">
enterprise_sms_package_id = #{enterpriseSmsPackageId,jdbcType=INTEGER},
</if>
<if test="memberName != null">
member_name = #{memberName,jdbcType=VARCHAR},
</if>
<if test="storeId != null">
store_id = #{storeId,jdbcType=INTEGER},
</if>
<if test="storeName != null">
store_name = #{storeName,jdbcType=VARCHAR},
</if>
<if test="storeGroupId != null">
store_group_id = #{storeGroupId,jdbcType=INTEGER},
</if>
<if test="storeGroupName != null">
store_group_name = #{storeGroupName,jdbcType=VARCHAR},
</if>
</set>
where sms_record_id = #{smsRecordId,jdbcType=INTEGER}
</update>
......@@ -218,7 +272,12 @@
update_time = #{updateTime,jdbcType=TIMESTAMP},
deduction_time = #{deductionTime,jdbcType=TIMESTAMP},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
enterprise_sms_package_id = #{enterpriseSmsPackageId,jdbcType=INTEGER}
enterprise_sms_package_id = #{enterpriseSmsPackageId,jdbcType=INTEGER},
member_name = #{memberName,jdbcType=VARCHAR},
store_id = #{storeId,jdbcType=INTEGER},
store_name = #{storeName,jdbcType=VARCHAR},
store_group_id = #{storeGroupId,jdbcType=INTEGER},
store_group_name = #{storeGroupName,jdbcType=VARCHAR}
where sms_record_id = #{smsRecordId,jdbcType=INTEGER}
</update>
<select id="listHomeStatistics" parameterType="com.gic.enterprise.qo.HomeStatisticsQO" resultType="com.gic.enterprise.dto.HomeStatisticsDTO">
......@@ -229,7 +288,7 @@
where status = 1
and enterprise_id = #{enterpriseId}
<if test="startTime != null">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') >= #{startTime}
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &lt;= #{endTime}
......@@ -289,7 +348,7 @@
and enterprise_id = #{enterpriseId}
</if>
<if test="startTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') >= #{startTime}
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &lt;= #{endTime}
......@@ -306,4 +365,29 @@
</where>
order by create_time desc
</select>
<select id="countSmsRecord" resultType="int">
select
count(*)
from tab_billing_sms_record
<where>
<if test="enterpriseId != null ">
and enterprise_id = #{enterpriseId}
</if>
<if test="startTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="payType != null ">
and pay_type = #{payType}
</if>
<if test="appCode != null ">
and app_code = #{appCode}
</if>
<if test="smsContent != null and smsContent != '' ">
and sms_content like concat('%', #{smsContent}, '%')
</if>
</where>
</select>
</mapper>
\ No newline at end of file
package com.gic.enterprise.web.controller.export;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.download.utils.DataDownloadUtils;
import com.gic.download.utils.DownloadReport;
import com.gic.download.utils.DownloadUtils;
import com.gic.download.utils.ExecutorPoolSingleton;
import com.gic.enterprise.context.RequestContext;
import com.gic.enterprise.dto.InternationalSmsRecordDTO;
import com.gic.enterprise.qo.RecordQO;
import com.gic.enterprise.service.BillingRecordApiService;
import com.gic.enterprise.service.DictApiService;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.enterprise.web.qo.ExportQO;
import com.gic.enterprise.web.utils.DataContentUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
*
* @Description:
* @author zhiwj
* @date 2019-12-19 15:13
*/
public class InternationalSmsRecordController extends DownloadUtils {
private Logger logger = LogManager.getLogger(VoiceCodeRecordController.class);
@Autowired
private BillingRecordApiService billingRecordApiService;
@Autowired
private DictApiService dictApiService;
@RequestMapping("/list-international-sms-field")
public RestResponse listInternationalSmsField() {
InternationalSmsFieldEnum[] values = InternationalSmsFieldEnum.values();
List<Map<String, Object>> arrayList = new ArrayList<>(values.length);
for (InternationalSmsFieldEnum value : values) {
Map<String, Object> hashMap = new HashMap<>(4);
hashMap.put("fieldCode", value.getFieldCode());
hashMap.put("fieldName", value.getFieldName());
hashMap.put("needEncrypt", value.getNeedEncrypt());
arrayList.add(hashMap);
}
return RestResponse.success(arrayList);
}
@RequestMapping("/export-international-sms")
public RestResponse exportSmsRecord(HttpServletRequest request, RecordQO recordQO, ExportQO exportQO) {
recordQO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
ServiceResponse<Integer> serviceResponse = billingRecordApiService.countInternationalSmsRecord(recordQO);
List<String> fieldCodeList = exportQO.getFieldCodeList();
List<String> fieldNameList = new ArrayList<>(fieldCodeList.size());
for (String fieldCode: fieldCodeList) {
String fieldName = InternationalSmsFieldEnum.valueOf(fieldCode).getFieldName();
fieldNameList.add(fieldName);
}
// 开始下载
String dataContent = DataContentUtils.getDataContent();
// 生成入参数据
DownloadReport report = new DownloadReport();
//申请人ID
report.setApplyUserId(UserDetailUtils.getUserDetail().getUserId());
//数据源(频道页),用 "-" 隔开上级和本级
report.setDataContent(dataContent);
//待下载数据的数据总量
report.setDataCount(serviceResponse.getResult());
//报告类型 1:完整数据, 2:脱敏数据, 3:二维码
report.setDataType(exportQO.getDataType());
//数据源超链接,用于点击跳转对应频道页面
report.setDataUrl((String) RequestContext.getContext().getRequest().getAttribute("moduleMenuUrl"));
report.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
//待下载文件名
report.setFileName(exportQO.getFileName());
//待下载数据的结束时间
if (StringUtils.isNotBlank(recordQO.getEndTime())) {
report.setReportEndTime(DateUtil.strToDate(recordQO.getEndTime(), DateUtil.FORMAT_DATETIME_19));
}
//待下载数据的开始时间
if (StringUtils.isNotBlank(recordQO.getStartTime())) {
report.setReportStartTime(DateUtil.strToDate(recordQO.getStartTime(), DateUtil.FORMAT_DATETIME_19));
}
//调用生成方法,获取reportId
Integer reportId = DataDownloadUtils.createDownloadReport(report);
String path = request.getSession().getServletContext().getRealPath("/excel/csv/collaborator/file/");
ExecutorPoolSingleton.getInstance().executeTask(() -> {
DownloadDataLoader<InternationalSmsRecordDTO> loader = new DownloadDataLoader<InternationalSmsRecordDTO>() {
@Override
protected List<InternationalSmsRecordDTO> getDownloadData(Integer pageNum) throws Exception {
//调用分页查询接口
recordQO.setCurrentPage(pageNum);
recordQO.setPageSize(1000);
ServiceResponse<Page<InternationalSmsRecordDTO>> result = billingRecordApiService.listInternationalSmsRecord(recordQO);
return result.getResult().getResult();
}
};
try {
//参数说明:excelExtensionCode,Excel后缀名code ,枚举类:ExcelExtensionEnum, Arrays.asList("phone")这个phone是需要加密的字段
download(path, reportId, exportQO.getFileName(), exportQO.getExcelExtension(), fieldNameList, fieldCodeList, loader, Arrays.asList("receivePhone"), null);
} catch (Exception e) {
logger.warn("下载错误", e);
}
});
return RestResponse.success(reportId);
}
private enum InternationalSmsFieldEnum {
deductionTime("deductionTime", "扣费时间", 0),
nation_code("nation_code", "国家(或地区)", 0),
nation_name("nation_name", "国家(或地区)码", 0),
paySerialNumber("paySerialNumber", "支付流水号", 0),
billNumber("billNumber", "条数", 0),
fee("fee", "费用", 0),
receivePhone("receivePhone", "接收手机号", 1),
memberName("memberName", "会员姓名", 0),
storeName("storeName", "服务门店", 0),
storeGroupName("storeGroupName", "门店分组", 0),
payType("payType", "支付方式", 0),
appName("appName", "应用", 0),
smsContent("smsContent", "短信内容", 0)
;
private String fieldCode;
private String fieldName;
private Integer needEncrypt;
InternationalSmsFieldEnum(String fieldCode, String fieldName, Integer needEncrypt) {
this.fieldCode = fieldCode;
this.fieldName = fieldName;
this.needEncrypt = needEncrypt;
}
public String getFieldCode() {
return fieldCode;
}
public String getFieldName() {
return fieldName;
}
public Integer getNeedEncrypt() {
return needEncrypt;
}
}
}
package com.gic.enterprise.web.controller.export;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.download.utils.DataDownloadUtils;
import com.gic.download.utils.DownloadReport;
import com.gic.download.utils.DownloadUtils;
import com.gic.download.utils.ExecutorPoolSingleton;
import com.gic.enterprise.context.RequestContext;
import com.gic.enterprise.dto.SmsRecordDTO;
import com.gic.enterprise.qo.RecordQO;
import com.gic.enterprise.service.BillingRecordApiService;
import com.gic.enterprise.service.DictApiService;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.enterprise.web.qo.ExportQO;
import com.gic.enterprise.web.utils.DataContentUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
*
* @Description:
* @author zhiwj
* @date 2019-12-19 14:31
*/
public class SmsRecordController extends DownloadUtils {
private Logger logger = LogManager.getLogger(SmsRecordController.class);
@Autowired
private BillingRecordApiService billingRecordApiService;
@Autowired
private DictApiService dictApiService;
@RequestMapping("/list-sms-field")
public RestResponse listSmsField() {
SmsFieldEnum[] values = SmsFieldEnum.values();
List<Map<String, Object>> arrayList = new ArrayList<>(values.length);
for (SmsFieldEnum value : values) {
Map<String, Object> hashMap = new HashMap<>(4);
hashMap.put("fieldCode", value.getFieldCode());
hashMap.put("fieldName", value.getFieldName());
hashMap.put("needEncrypt", value.getNeedEncrypt());
arrayList.add(hashMap);
}
return RestResponse.success(arrayList);
}
@RequestMapping("/export-sms")
public RestResponse exportSmsRecord(HttpServletRequest request, RecordQO recordQO, ExportQO exportQO) {
recordQO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
ServiceResponse<Integer> serviceResponse = billingRecordApiService.countSmsRecord(recordQO);
List<String> fieldCodeList = exportQO.getFieldCodeList();
List<String> fieldNameList = new ArrayList<>(fieldCodeList.size());
for (String fieldCode: fieldCodeList) {
String fieldName = SmsFieldEnum.valueOf(fieldCode).getFieldName();
fieldNameList.add(fieldName);
}
// 开始下载
String dataContent = DataContentUtils.getDataContent();
// 生成入参数据
DownloadReport report = new DownloadReport();
//申请人ID
report.setApplyUserId(UserDetailUtils.getUserDetail().getUserId());
//数据源(频道页),用 "-" 隔开上级和本级
report.setDataContent(dataContent);
//待下载数据的数据总量
report.setDataCount(serviceResponse.getResult());
//报告类型 1:完整数据, 2:脱敏数据, 3:二维码
report.setDataType(exportQO.getDataType());
//数据源超链接,用于点击跳转对应频道页面
report.setDataUrl((String) RequestContext.getContext().getRequest().getAttribute("moduleMenuUrl"));
report.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
//待下载文件名
report.setFileName(exportQO.getFileName());
//待下载数据的结束时间
if (StringUtils.isNotBlank(recordQO.getEndTime())) {
report.setReportEndTime(DateUtil.strToDate(recordQO.getEndTime(), DateUtil.FORMAT_DATETIME_19));
}
//待下载数据的开始时间
if (StringUtils.isNotBlank(recordQO.getStartTime())) {
report.setReportStartTime(DateUtil.strToDate(recordQO.getStartTime(), DateUtil.FORMAT_DATETIME_19));
}
//调用生成方法,获取reportId
Integer reportId = DataDownloadUtils.createDownloadReport(report);
String path = request.getSession().getServletContext().getRealPath("/excel/csv/collaborator/file/");
ExecutorPoolSingleton.getInstance().executeTask(() -> {
DownloadDataLoader<SmsRecordDTO> loader = new DownloadDataLoader<SmsRecordDTO>() {
@Override
protected List<SmsRecordDTO> getDownloadData(Integer pageNum) throws Exception {
//调用分页查询接口
recordQO.setCurrentPage(pageNum);
recordQO.setPageSize(1000);
ServiceResponse<Page<SmsRecordDTO>> result = billingRecordApiService.listSmsRecord(recordQO);
return result.getResult().getResult();
}
};
try {
//参数说明:excelExtensionCode,Excel后缀名code ,枚举类:ExcelExtensionEnum, Arrays.asList("phone")这个phone是需要加密的字段
download(path, reportId, exportQO.getFileName(), exportQO.getExcelExtension(), fieldNameList, fieldCodeList, loader, Arrays.asList("receivePhone"), null);
} catch (Exception e) {
logger.warn("下载错误", e);
}
});
return RestResponse.success(reportId);
}
private enum SmsFieldEnum {
deductionTime("deductionTime", "扣费时间", 0),
paySerialNumber("paySerialNumber", "支付流水号", 0),
billNumber("billNumber", "条数", 0),
fee("fee", "费用", 0),
receivePhone("receivePhone", "接收手机号", 1),
memberName("memberName", "会员姓名", 0),
storeName("storeName", "服务门店", 0),
storeGroupName("storeGroupName", "门店分组", 0),
payType("payType", "支付方式", 0),
appName("appName", "应用", 0),
smsContent("smsContent", "短信内容", 0)
;
private String fieldCode;
private String fieldName;
private Integer needEncrypt;
SmsFieldEnum(String fieldCode, String fieldName, Integer needEncrypt) {
this.fieldCode = fieldCode;
this.fieldName = fieldName;
this.needEncrypt = needEncrypt;
}
public String getFieldCode() {
return fieldCode;
}
public String getFieldName() {
return fieldName;
}
public Integer getNeedEncrypt() {
return needEncrypt;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment