Commit aade45f4 by Water Wang

add leads statement

parent 5f8e2c3f
package com.yd.api.agms;
import com.yd.api.agms.service.AgmsStatementService;
import com.yd.api.agms.vo.statement.FinancialStatementRequestVO;
import com.yd.api.agms.vo.statement.FinancialStatementResponseVO;
import com.yd.api.agms.service.AgmsStatisticsService;
import com.yd.api.agms.vo.statistics.FinancialStatisticsRequestVO;
import com.yd.api.agms.vo.statistics.FinancialStatisticsResponseVO;
import com.yd.api.agms.vo.statistics.LeadsStatisticsRequestVO;
import com.yd.api.agms.vo.statistics.LeadsStatisticsResponseVO;
import com.yd.api.result.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -17,19 +19,33 @@ import javax.servlet.http.HttpServletResponse;
@RequestMapping("/agms")
public class AgmsController {
@Autowired
private AgmsStatementService agmsStatementService;
private AgmsStatisticsService agmsStatisticsService;
/**
* AGMS -- 财务管理报表
* @param requestVO 请求数据
* @return 响应数据
*/
@RequestMapping("/financialPredictStatement")
public Object financialPredictStatement(@RequestBody FinancialStatementRequestVO requestVO, HttpServletResponse response){
@RequestMapping("/financialPredictStatistics")
public Object financialPredictStatistics(@RequestBody FinancialStatisticsRequestVO requestVO, HttpServletResponse response){
JsonResult result = new JsonResult();
FinancialStatementResponseVO responseVO = agmsStatementService.financialPredictStatement(requestVO,response);
FinancialStatisticsResponseVO responseVO = agmsStatisticsService.financialPredictStatistics(requestVO,response);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* AGMS -- 商机统计报表
* @param requestVO
* @return
*/
@RequestMapping(value="/leadsStatistics")
public Object leadsStatistics(@RequestBody LeadsStatisticsRequestVO requestVO,HttpServletResponse response) {
JsonResult result = new JsonResult();
LeadsStatisticsResponseVO responseVO = agmsStatisticsService.leadsStatistics(requestVO,response);
result.setData(responseVO);
result.addResult(responseVO);
return result;
}
}
package com.yd.api.agms.service;
import com.yd.api.agms.vo.statement.FinancialStatementRequestVO;
import com.yd.api.agms.vo.statement.FinancialStatementResponseVO;
import com.yd.api.agms.vo.statistics.FinancialStatisticsRequestVO;
import com.yd.api.agms.vo.statistics.FinancialStatisticsResponseVO;
import com.yd.api.agms.vo.statistics.LeadsStatisticsRequestVO;
import com.yd.api.agms.vo.statistics.LeadsStatisticsResponseVO;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
@Service("agmsStatementService")
public interface AgmsStatementService {
public interface AgmsStatisticsService {
/**
* 线下寿险预估数据管理报表
* @param requestVO 请求报文
* @return 响应报文
*/
FinancialStatementResponseVO financialPredictStatement(FinancialStatementRequestVO requestVO, HttpServletResponse response);
FinancialStatisticsResponseVO financialPredictStatistics(FinancialStatisticsRequestVO requestVO, HttpServletResponse response);
/**
* 商机统计报表
* @param requestVO 请求报文
* @return 响应报文
*/
LeadsStatisticsResponseVO leadsStatistics(LeadsStatisticsRequestVO requestVO,HttpServletResponse response);
}
package com.yd.api.agms.service.impl;
import com.github.pagehelper.PageInfo;
import com.google.common.base.Strings;
import com.yd.api.agms.service.AgmsStatementService;
import com.yd.api.agms.vo.statement.FinancialStatementRequestVO;
import com.yd.api.agms.vo.statement.FinancialStatementResponseVO;
import com.yd.api.agms.vo.statement.statementData;
import com.yd.api.commission.service.CommissionService;
import com.yd.api.result.CommonResult;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@Service("agmsStatementService")
public class AgmsStatementServiceImpl implements AgmsStatementService {
@Autowired
private CommissionService commissionService;
@Override
public FinancialStatementResponseVO financialPredictStatement(FinancialStatementRequestVO requestVO, HttpServletResponse response) {
FinancialStatementResponseVO responseVO = new FinancialStatementResponseVO();
PageInfo<statementData> pageInfo = requestVO.getPageInfo();
String inCommissionDateSpan = requestVO.getInCommissionDateSpan();//来佣开始时间
String outCommissionDateSpan = requestVO.getOutCommissionDateSpan();//发佣开始时间
String inCommissionStartTime = null;//来佣开始时间
String inCommissionEndTime = null;//发佣开始时间
String outCommissionStartTime= null;//来佣开始时间
String outCommissionEndTime= null;//发佣开始时间
if(!Strings.isNullOrEmpty(inCommissionDateSpan)){
String[] inDataSpan = inCommissionDateSpan.split(":");
if(inDataSpan.length == 1){
inCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(inDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
}else if(inDataSpan.length == 2){
inCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(inDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
inCommissionEndTime = getTime(inDataSpan[1]);
// inCommissionEndTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(inDataSpan[1],"yyyy-MM-dd"),"yyyyMM");
}
}
if(!Strings.isNullOrEmpty(outCommissionDateSpan)){
String[] outDataSpan = outCommissionDateSpan.split(":");
if(outDataSpan.length == 1){
outCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(outDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
}else if(outDataSpan.length == 2){
outCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(outDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
outCommissionEndTime = getTime(outDataSpan[1]);
// outCommissionEndTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(outDataSpan[1],"yyyy-MM-dd"),"yyyyMM");
}
}
String insurerBranchId = requestVO.getInsurerBranchId();//分公司
String deptId = requestVO.getDeptId();//营业部
String subordinateId = requestVO.getSubordinateId();//体系
Integer type = requestVO.getType();
Integer isStatement = requestVO.getIsStatement();
if(isStatement == 1){
List<statementData> dataList = commissionService.getStatementData(isStatement,type, inCommissionStartTime, outCommissionStartTime,inCommissionEndTime,outCommissionEndTime,insurerBranchId,deptId,subordinateId);
createCSV(type,dataList,response);
}else{
PageInfo<statementData> dataPage = commissionService.getStatementDataByPage(pageInfo.getPageNum(),pageInfo.getSize(),isStatement,type, inCommissionStartTime, outCommissionStartTime,inCommissionEndTime,outCommissionEndTime,insurerBranchId,deptId,subordinateId);
responseVO.setPredictStatementDataList(dataPage);
}
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO;
}
private String getTime(String time) {
Date date = CommonUtil.stringParseDate(time,"yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH,-1);
date = calendar.getTime();
return CommonUtil.dateParseString(date,"yyyyMM");
}
private void createCSV(Integer type, List<statementData> dataList, HttpServletResponse response) {
String CSV_COLUMN_SEPARATOR = ",";//CSV文件列分隔符
String CSV_ROW_SEPARATOR = "\r\n";//CSV文件行分隔符
String charset = "UTF-8"; // 读取字符编码
String[] columnName ;
String tableName ;
if(type == 2){
tableName = "YD_FinancialStatement_predict_";
columnName = new String[]{"序号","预估来佣年月","预估发佣年月","保单号","分公司","营业部","体系","经纪人姓名","员工编号","职阶","职阶率","保费","FYC","RYC","应收佣金","应发佣金","佣奖类型"};
}else{
tableName = "YD_FinancialStatement_actual_";
columnName = new String[]{"序号","实际来佣年月","实际发佣年月","保单号","分公司","营业部","体系","经纪人姓名","员工编号","职阶","职阶率","保费","FYC","RYC","应收佣金","应发佣金","佣奖类型"};
}
// 保证线程安全
StringBuilder buf = new StringBuilder();
// 组装表头
for (String title : columnName) {
buf.append(title).append(CSV_COLUMN_SEPARATOR);
}
buf.append(CSV_ROW_SEPARATOR);
// 组装数据
if (CollectionUtils.isNotEmpty(dataList)) {
for (int i = 0; i < dataList.size(); i++) {
statementData statementData = dataList.get(i);//遍历每个对象
buf.append(i + 1).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getInCommissionTime()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getOutCommissionTime()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPolicyNo()+"\t").append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getInsurerBranch()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getDept()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getSubordinate()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPractitioner()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPractitionerIdEG()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getTitle()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getTitleRate()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPremium()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getFYC()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getRYC()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getRightReceiveCommission()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getRightPayCommission()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getCommissionType()).append(CSV_COLUMN_SEPARATOR);
buf.append(CSV_ROW_SEPARATOR);
}
}
// 设置文件后缀
String fn = tableName + System.currentTimeMillis() + ".csv";
String headStr = "attachment; filename=\"" + fn + "\"";
// 设置响应
response.setContentType("APPLICATION/ms-csv.numberformat");
response.setCharacterEncoding(charset);
response.setHeader("Content-Disposition", headStr);
response.setHeader("Cache-Control", "max-age=30");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Pragma", "public");
OutputStream os = null;
try {
os = response.getOutputStream();
os.write(buf.toString().getBytes("GBK"));
os.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(os != null){
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
package com.yd.api.agms.service.impl;
import com.github.pagehelper.PageInfo;
import com.google.common.base.Strings;
import com.yd.api.agms.service.AgmsStatisticsService;
import com.yd.api.agms.vo.statistics.*;
import com.yd.api.commission.service.CommissionService;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.AclPractitioner;
import com.yd.dal.entity.meta.MdDropOptions;
import com.yd.dal.service.customer.AclPractitionerDALService;
import com.yd.dal.service.marketing.MktLeadsPoolDALService;
import com.yd.dal.service.meta.MdDropOptionsDALService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import com.yd.util.page.PageInfoUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
@Service("agmsStatementService")
public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
@Autowired
private CommissionService commissionService;
@Autowired
private MktLeadsPoolDALService mktLeadsPoolDALService;
@Autowired
private MdDropOptionsDALService mdDropOptionsDALService;
@Autowired
private AclPractitionerDALService aclPractitionerDALService;
// @Autowired
// private MdCityDALService mdCityDALService;
@Override
public FinancialStatisticsResponseVO financialPredictStatistics(FinancialStatisticsRequestVO requestVO, HttpServletResponse response) {
FinancialStatisticsResponseVO responseVO = new FinancialStatisticsResponseVO();
PageInfo<statementData> pageInfo = requestVO.getPageInfo();
String inCommissionDateSpan = requestVO.getInCommissionDateSpan();//来佣开始时间
String outCommissionDateSpan = requestVO.getOutCommissionDateSpan();//发佣开始时间
String inCommissionStartTime = null;//来佣开始时间
String inCommissionEndTime = null;//发佣开始时间
String outCommissionStartTime= null;//来佣开始时间
String outCommissionEndTime= null;//发佣开始时间
if(!Strings.isNullOrEmpty(inCommissionDateSpan)){
String[] inDataSpan = inCommissionDateSpan.split(":");
if(inDataSpan.length == 1){
inCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(inDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
}else if(inDataSpan.length == 2){
inCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(inDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
inCommissionEndTime = getTime(inDataSpan[1]);
// inCommissionEndTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(inDataSpan[1],"yyyy-MM-dd"),"yyyyMM");
}
}
if(!Strings.isNullOrEmpty(outCommissionDateSpan)){
String[] outDataSpan = outCommissionDateSpan.split(":");
if(outDataSpan.length == 1){
outCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(outDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
}else if(outDataSpan.length == 2){
outCommissionStartTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(outDataSpan[0],"yyyy-MM-dd"),"yyyyMM");
outCommissionEndTime = getTime(outDataSpan[1]);
// outCommissionEndTime = CommonUtil.dateParseString(CommonUtil.stringParseDate(outDataSpan[1],"yyyy-MM-dd"),"yyyyMM");
}
}
String insurerBranchId = requestVO.getInsurerBranchId();//分公司
String deptId = requestVO.getDeptId();//营业部
String subordinateId = requestVO.getSubordinateId();//体系
Integer type = requestVO.getType();
Integer isStatement = requestVO.getIsStatement();
if(isStatement == 1){
List<statementData> dataList = commissionService.getStatementData(isStatement,type, inCommissionStartTime, outCommissionStartTime,inCommissionEndTime,outCommissionEndTime,insurerBranchId,deptId,subordinateId);
createCSV(type,dataList,response);
}else{
PageInfo<statementData> dataPage = commissionService.getStatementDataByPage(pageInfo.getPageNum(),pageInfo.getSize(),isStatement,type, inCommissionStartTime, outCommissionStartTime,inCommissionEndTime,outCommissionEndTime,insurerBranchId,deptId,subordinateId);
responseVO.setPredictStatementDataList(dataPage);
}
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO;
}
@Override
public LeadsStatisticsResponseVO leadsStatistics(LeadsStatisticsRequestVO requestVO, HttpServletResponse response) {
LeadsStatisticsResponseVO responseVO = new LeadsStatisticsResponseVO();
Integer expertApplyStatus = requestVO.getExpertApplyStatus(),leadsStatus = requestVO.getLeadsStatus();
String leadsDateSpan = requestVO.getLeadsDateSpan();
PageInfo<LeadsStatisticsInfo> requestPage = requestVO.getPageInfo();
//1、查询商机信息
List<LeadsStatisticsInfo> resultList;
List<LeadsStatisticsInfo> leadsInfos = getLeadsInfoByDate(leadsDateSpan);
if(leadsInfos != null && leadsInfos.size() > 0){
if(leadsStatus != null && leadsStatus == 1){//未派遣的商机
resultList = getIsNotAssignLeads(leadsInfos);
}else{
//2、查询商机的派遣情况
List<LeadsStatisticsInfo> isAssignLeadsInfos = mktLeadsPoolDALService.findIsAssignLeads();
Map<Long,LeadsStatisticsInfo> leadsAssignMap = new HashMap<>();
if(isAssignLeadsInfos != null && isAssignLeadsInfos.size() > 0){
isAssignLeadsInfos.forEach(i->leadsAssignMap.put(i.getAssignId(),i));
}
//3、商机状态
Map<Long,Long> leadsStatusMap = mktLeadsPoolDALService.findLeadsStatusMap();
//4、商机状态信息
List<MdDropOptions> dropList = mdDropOptionsDALService.findByDropMasterCodes(Arrays.asList("leads_manual_blood_type","leads_manual_zodiac_type","leads_manual_source","action_code"));
Map<Long,String> dropMap = new HashMap<>();
if(dropList != null && dropList.size() > 0){
dropList.forEach(i->dropMap.put(i.getId(),i.getDropOptionName()));
}
//5、经纪人信息
List<AclPractitioner> practitionerList = aclPractitionerDALService.findAll();
Map<Long,AclPractitioner> practitionerMap = new HashMap<>();
if(practitionerList != null && practitionerList.size()>0){
practitionerList.forEach(i->practitionerMap.put(i.getId(),i));
}
/*
//6、城市信息
List<MdCity> cityList = mdCityDALService.findByInsurerId(2L);
Map<Long,String> cityMap = new HashMap<>();
if(cityList != null && cityList.size() > 0 ){
cityList.forEach(i->cityMap.put(i.getId(),i.getCityName()));
}
*/
//7、整理信息
resultList = integrateResponse(leadsInfos,leadsAssignMap,leadsStatusMap,dropMap,practitionerMap);
//8、安装条件筛选
resultList = screenResult(resultList,leadsStatus,expertApplyStatus);
}
PageInfo<LeadsStatisticsInfo> pageInfoResult = PageInfoUtils.list2PageInfo(resultList,requestPage.getPageNum(),requestPage.getPageSize());
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
responseVO.setStatisticsPageInfo(pageInfoResult);
}else{
responseVO.setCommonResult(new CommonResult(false,ZHBErrorConfig.getErrorInfo("820001")));
}
return responseVO;
}
/**
* 按照条件筛选
* @param resultList 结果集
* @param leadsStatus 0/null:全部,1:未派遣,2:已派遣
* @param expertApplyStatus 0/null:全部,1:未申请,2:申请中,3:已指派,
*/
private List<LeadsStatisticsInfo> screenResult(List<LeadsStatisticsInfo> resultList, Integer leadsStatus, Integer expertApplyStatus) {
List<LeadsStatisticsInfo> isAssignList,unapplyList,applyingList,isAssignExpertList;
if(leadsStatus == 2){
isAssignList = new ArrayList<>();
for(LeadsStatisticsInfo item : resultList){
if(item.getAssignId() != null){
isAssignList.add(item);
}
}
if(expertApplyStatus == null || expertApplyStatus == 0){//已派遣的全部
return isAssignList;
}else if(!isAssignList.isEmpty()){
unapplyList = new ArrayList<>();
applyingList = new ArrayList<>();
isAssignExpertList = new ArrayList<>();
for(LeadsStatisticsInfo item : isAssignList) {
if (item.getRequestSMEDate() == null) {
unapplyList.add(item);//未申请
}else{
if(item.getAssignSMEDate() == null){
applyingList.add(item);//申请中
}else{
isAssignExpertList.add(item);//已派遣专家
}
}
}
if(expertApplyStatus == 1){//未申请
return unapplyList;
}else if(expertApplyStatus == 2){//申请中
return applyingList;
}else if(expertApplyStatus == 3){//已指派
return isAssignExpertList;
}else{//全部
return isAssignList;
}
}
}
return resultList;
}
/**
* 整合响应信息
* @param leadsInfos 商机信息
* @param leadsAssignMap 商机派遣信息
* @param leadsStatusMap 商机状态信息
* @param dropMap 基础信息
* @param practitionerMap 经纪人信息
* @return 整合信息
*/
private List<LeadsStatisticsInfo> integrateResponse(List<LeadsStatisticsInfo> leadsInfos, Map<Long, LeadsStatisticsInfo> leadsAssignMap, Map<Long, Long> leadsStatusMap, Map<Long, String> dropMap, Map<Long, AclPractitioner> practitionerMap) {
List<LeadsStatisticsInfo> resultList = new ArrayList<>();
Long assignId,leadsCustomerId,smePractitionerId,practitionerId;
LeadsStatisticsInfo assignInfo;
AclPractitioner practitioner,smePractitioner;
for (LeadsStatisticsInfo item : leadsInfos){
assignId = item.getAssignId();
leadsCustomerId = item.getLeadsCustomerId();
item.setLeadsSource(dropMap.get(item.getLeadsSourceId()));
item.setLeadsStatus(dropMap.get(leadsStatusMap.get(leadsCustomerId)));
item.setLeadsBloodType(dropMap.get(item.getLeadsBloodTypeId()));
item.setLeadsZodiacType(dropMap.get(item.getLeadsZodiacTypeId()));
assignInfo = leadsAssignMap.get(assignId);
if(assignInfo != null && leadsCustomerId.equals(assignInfo.getLeadsCustomerId())){
practitionerId = assignInfo.getPractitionerId();
smePractitionerId = assignInfo.getSmePractitionerId();
if(practitionerId != null){//经纪人
practitioner = practitionerMap.get(practitionerId);
item.setPractitionerId(practitionerId);
item.setPractitionerName(practitioner.getName());
item.setPractitionerMobileNo(practitioner.getMobileNo());
}
if(smePractitionerId != null){//专家
smePractitioner = practitionerMap.get(smePractitionerId);
item.setSmePractitionerId(smePractitionerId);
item.setSme(smePractitioner.getName());
item.setSmeMobileNo(smePractitioner.getMobileNo());
}
item.setRequestSMEDate(assignInfo.getRequestSMEDate());
item.setAssignSMEDate(assignInfo.getAssignSMEDate());
item.setSmePractitionerId(assignInfo.getSmePractitionerId());
item.setPredictFYC(assignInfo.getPredictFYC());
item.setPredictFYP(assignInfo.getPredictFYP());
item.setPredictPieces(assignInfo.getPredictPieces());
item.setDealTime(assignInfo.getDealTime());
}
resultList.add(item);
}
return resultList;
}
//塞选未分配的商机
private List<LeadsStatisticsInfo> getIsNotAssignLeads(List<LeadsStatisticsInfo> leadsInfos) {
List<LeadsStatisticsInfo> resultList = new ArrayList<>();
if(leadsInfos != null && leadsInfos.size() > 0){
for(LeadsStatisticsInfo item : leadsInfos){
if(item.getPractitionerId() == null){
resultList.add(item);
}
}
}
return resultList;
}
/**
* 获取商机
* @param leadsDateSpan 商机时间
* @return 商机列表
*/
private List<LeadsStatisticsInfo> getLeadsInfoByDate(String leadsDateSpan) {
String leadsStartTime = null,leadsEndTime = null;
if(!Strings.isNullOrEmpty(leadsDateSpan)){
String[] dateStr = leadsDateSpan.split(":");
if(dateStr.length == 1){
leadsStartTime = dateStr[0];
}else{
leadsStartTime = dateStr[0];
leadsEndTime = dateStr[1];
}
}
return mktLeadsPoolDALService.findALLByDate(leadsStartTime,leadsEndTime);
}
private String getTime(String time) {
Date date = CommonUtil.stringParseDate(time,"yyyy-MM-dd");
if(date != null){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH,-1);
date = calendar.getTime();
}
return CommonUtil.dateParseString(date,"yyyyMM");
}
private void createCSV(Integer type, List<statementData> dataList, HttpServletResponse response) {
String CSV_COLUMN_SEPARATOR = ",";//CSV文件列分隔符
String CSV_ROW_SEPARATOR = "\r\n";//CSV文件行分隔符
String charset = "UTF-8"; // 读取字符编码
String[] columnName ;
String tableName ;
if(type == 2){
tableName = "YD_FinancialStatement_predict_";
columnName = new String[]{"序号","预估来佣年月","预估发佣年月","保单号","分公司","营业部","体系","经纪人姓名","员工编号","职阶","职阶率","保费","FYC","RYC","应收佣金","应发佣金","佣奖类型"};
}else{
tableName = "YD_FinancialStatement_actual_";
columnName = new String[]{"序号","实际来佣年月","实际发佣年月","保单号","分公司","营业部","体系","经纪人姓名","员工编号","职阶","职阶率","保费","FYC","RYC","应收佣金","应发佣金","佣奖类型"};
}
// 保证线程安全
StringBuilder buf = new StringBuilder();
// 组装表头
for (String title : columnName) {
buf.append(title).append(CSV_COLUMN_SEPARATOR);
}
buf.append(CSV_ROW_SEPARATOR);
// 组装数据
if (CollectionUtils.isNotEmpty(dataList)) {
for (int i = 0; i < dataList.size(); i++) {
statementData statementData = dataList.get(i);//遍历每个对象
buf.append(i + 1).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getInCommissionTime()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getOutCommissionTime()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPolicyNo()+"\t").append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getInsurerBranch()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getDept()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getSubordinate()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPractitioner()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPractitionerIdEG()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getTitle()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getTitleRate()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getPremium()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getFYC()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getRYC()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getRightReceiveCommission()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getRightPayCommission()).append(CSV_COLUMN_SEPARATOR);
buf.append(statementData.getCommissionType()).append(CSV_COLUMN_SEPARATOR);
buf.append(CSV_ROW_SEPARATOR);
}
}
// 设置文件后缀
String fn = tableName + System.currentTimeMillis() + ".csv";
String headStr = "attachment; filename=\"" + fn + "\"";
// 设置响应
response.setContentType("APPLICATION/ms-csv.numberformat");
response.setCharacterEncoding(charset);
response.setHeader("Content-Disposition", headStr);
response.setHeader("Cache-Control", "max-age=30");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Pragma", "public");
OutputStream os = null;
try {
os = response.getOutputStream();
os.write(buf.toString().getBytes("GBK"));
os.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(os != null){
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
package com.yd.api.agms.vo.statement;
package com.yd.api.agms.vo.statistics;
import com.github.pagehelper.PageInfo;
public class FinancialStatementRequestVO {
public class FinancialStatisticsRequestVO {
private Integer type ; //2、预测,1、实际
private Integer isStatement;//0=非报表,1=报表
private String inCommissionDateSpan;
......
package com.yd.api.agms.vo.statement;
package com.yd.api.agms.vo.statistics;
import com.github.pagehelper.PageInfo;
import com.yd.api.result.CommonResult;
public class FinancialStatementResponseVO {
public class FinancialStatisticsResponseVO {
private PageInfo<statementData> predictStatementDataList;
private CommonResult commonResult;
......
package com.yd.api.agms.vo.statistics;
public class LeadsStatisticsInfo {
private String requestSMEDate;//专家请求时间
private String assignSMEDate;//专家派遣时间
private Long smePractitionerId;//专家id
private String sme; //SME
private String smeMobileNo; //SME手机号
private String talkTime; //开谈时间
private Long assignId; //分派Id
private Long practitionerId;//经纪人id
private String practitionerName; //经纪人姓名
private String practitionerMobileNo; //经纪人手机号
private String leadsCreateTime; //商机创建时间
private String leadsAssignTime; //商机派遣时间
private Long leadsCustomerId;//商机id
private String leadsName; //商机姓名
private String leadsMobileNo; //商机手机号码
private String leadsWeChatId; //商机微信号
private String leadsAge; //商机年龄
private String leadsGender; //商机性别
private String leadsCity; //商机城市
private String leadsBloodType; //商机血型
private String leadsZodiacType; //商机星座
private Double predictFYP; //预计FYP
private Double predictFYC; //预计FYC
private Double predictPieces; //件数
private String dealTime; //成交时间
private String leadsSource; //商机来源
private String leadsStatus; //商机状态
private Long leadsSourceId;
private Long leadsZodiacTypeId;
private Long leadsBloodTypeId;
public String getSme() {
return sme;
}
public void setSme(String sme) {
this.sme = sme;
}
public String getSmeMobileNo() {
return smeMobileNo;
}
public void setSmeMobileNo(String smeMobileNo) {
this.smeMobileNo = smeMobileNo;
}
public String getTalkTime() {
return talkTime;
}
public void setTalkTime(String talkTime) {
this.talkTime = talkTime;
}
public String getPractitionerName() {
return practitionerName;
}
public void setPractitionerName(String practitionerName) {
this.practitionerName = practitionerName;
}
public String getPractitionerMobileNo() {
return practitionerMobileNo;
}
public void setPractitionerMobileNo(String practitionerMobileNo) {
this.practitionerMobileNo = practitionerMobileNo;
}
public String getLeadsCreateTime() {
return leadsCreateTime;
}
public void setLeadsCreateTime(String leadsCreateTime) {
this.leadsCreateTime = leadsCreateTime;
}
public String getLeadsName() {
return leadsName;
}
public void setLeadsName(String leadsName) {
this.leadsName = leadsName;
}
public String getLeadsMobileNo() {
return leadsMobileNo;
}
public void setLeadsMobileNo(String leadsMobileNo) {
this.leadsMobileNo = leadsMobileNo;
}
public String getLeadsWeChatId() {
return leadsWeChatId;
}
public void setLeadsWeChatId(String leadsWeChatId) {
this.leadsWeChatId = leadsWeChatId;
}
public String getLeadsAge() {
return leadsAge;
}
public void setLeadsAge(String leadsAge) {
this.leadsAge = leadsAge;
}
public String getLeadsGender() {
return leadsGender;
}
public void setLeadsGender(String leadsGender) {
this.leadsGender = leadsGender;
}
public String getLeadsCity() {
return leadsCity;
}
public void setLeadsCity(String leadsCity) {
this.leadsCity = leadsCity;
}
public String getLeadsBloodType() {
return leadsBloodType;
}
public void setLeadsBloodType(String leadsBloodType) {
this.leadsBloodType = leadsBloodType;
}
public String getLeadsZodiacType() {
return leadsZodiacType;
}
public void setLeadsZodiacType(String leadsZodiacType) {
this.leadsZodiacType = leadsZodiacType;
}
public Double getPredictFYP() {
return predictFYP;
}
public void setPredictFYP(Double predictFYP) {
this.predictFYP = predictFYP;
}
public Double getPredictFYC() {
return predictFYC;
}
public void setPredictFYC(Double predictFYC) {
this.predictFYC = predictFYC;
}
public Double getPredictPieces() {
return predictPieces;
}
public void setPredictPieces(Double predictPieces) {
this.predictPieces = predictPieces;
}
public String getDealTime() {
return dealTime;
}
public void setDealTime(String dealTime) {
this.dealTime = dealTime;
}
public String getLeadsSource() {
return leadsSource;
}
public void setLeadsSource(String leadsSource) {
this.leadsSource = leadsSource;
}
public String getLeadsStatus() {
return leadsStatus;
}
public void setLeadsStatus(String leadsStatus) {
this.leadsStatus = leadsStatus;
}
public Long getSmePractitionerId() {
return smePractitionerId;
}
public void setSmePractitionerId(Long smePractitionerId) {
this.smePractitionerId = smePractitionerId;
}
public Long getPractitionerId() {
return practitionerId;
}
public void setPractitionerId(Long practitionerId) {
this.practitionerId = practitionerId;
}
public String getLeadsAssignTime() {
return leadsAssignTime;
}
public void setLeadsAssignTime(String leadsAssignTime) {
this.leadsAssignTime = leadsAssignTime;
}
public Long getLeadsCustomerId() {
return leadsCustomerId;
}
public void setLeadsCustomerId(Long leadsCustomerId) {
this.leadsCustomerId = leadsCustomerId;
}
public Long getAssignId() {
return assignId;
}
public void setAssignId(Long assignId) {
this.assignId = assignId;
}
public String getRequestSMEDate() {
return requestSMEDate;
}
public void setRequestSMEDate(String requestSMEDate) {
this.requestSMEDate = requestSMEDate;
}
public String getAssignSMEDate() {
return assignSMEDate;
}
public void setAssignSMEDate(String assignSMEDate) {
this.assignSMEDate = assignSMEDate;
}
public Long getLeadsSourceId() {
return leadsSourceId;
}
public void setLeadsSourceId(Long leadsSourceId) {
this.leadsSourceId = leadsSourceId;
}
public Long getLeadsZodiacTypeId() {
return leadsZodiacTypeId;
}
public void setLeadsZodiacTypeId(Long leadsZodiacTypeId) {
this.leadsZodiacTypeId = leadsZodiacTypeId;
}
public Long getLeadsBloodTypeId() {
return leadsBloodTypeId;
}
public void setLeadsBloodTypeId(Long leadsBloodTypeId) {
this.leadsBloodTypeId = leadsBloodTypeId;
}
}
package com.yd.api.agms.vo.statistics;
import com.github.pagehelper.PageInfo;
public class LeadsStatisticsRequestVO {
private String leadsDateSpan;
private Integer leadsStatus; // 0/null:全部,1:未派遣,2:已派遣
private Integer expertApplyStatus; // 0/null:全部,1:未申请,2:申请中,3:已指派,
private PageInfo<LeadsStatisticsInfo> pageInfo;
public String getLeadsDateSpan() {
return leadsDateSpan;
}
public void setLeadsDateSpan(String leadsDateSpan) {
this.leadsDateSpan = leadsDateSpan;
}
public Integer getLeadsStatus() {
return leadsStatus;
}
public void setLeadsStatus(Integer leadsStatus) {
this.leadsStatus = leadsStatus;
}
public Integer getExpertApplyStatus() {
return expertApplyStatus;
}
public void setExpertApplyStatus(Integer expertApplyStatus) {
this.expertApplyStatus = expertApplyStatus;
}
public PageInfo<LeadsStatisticsInfo> getPageInfo() {
return pageInfo;
}
public void setPageInfo(PageInfo<LeadsStatisticsInfo> pageInfo) {
this.pageInfo = pageInfo;
}
}
package com.yd.api.agms.vo.statistics;
import com.github.pagehelper.PageInfo;
import com.yd.api.result.CommonResult;
public class LeadsStatisticsResponseVO {
private PageInfo<LeadsStatisticsInfo> statisticsPageInfo;
private CommonResult commonResult;
public PageInfo<LeadsStatisticsInfo> getStatisticsPageInfo() {
return statisticsPageInfo;
}
public void setStatisticsPageInfo(PageInfo<LeadsStatisticsInfo> statisticsPageInfo) {
this.statisticsPageInfo = statisticsPageInfo;
}
public CommonResult getCommonResult() {
return commonResult;
}
public void setCommonResult(CommonResult commonResult) {
this.commonResult = commonResult;
}
}
package com.yd.api.agms.vo.statement;
package com.yd.api.agms.vo.statistics;
public class statementData {
private String inCommissionTime;
......
......@@ -3,7 +3,7 @@ package com.yd.api.commission.service;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statement.statementData;
import com.yd.api.agms.vo.statistics.statementData;
import com.yd.api.commission.vo.CommissionEGoldenVO;
import com.yd.api.commission.vo.CommissionVO;
......
......@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statement.statementData;
import com.yd.api.agms.vo.statistics.statementData;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......
package com.yd.dal.entity.leads;
public class LeadsStatusInfo {
private Long leadsCustomerId;
private Long leadsStatus;
public Long getLeadsCustomerId() {
return leadsCustomerId;
}
public void setLeadsCustomerId(Long leadsCustomerId) {
this.leadsCustomerId = leadsCustomerId;
}
public Long getLeadsStatus() {
return leadsStatus;
}
public void setLeadsStatus(Long leadsStatus) {
this.leadsStatus = leadsStatus;
}
}
package com.yd.dal.entity.meta;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ag_md_city
* @author
*/
@Data
public class MdCity implements Serializable {
/**
* serial id
*/
private Long id;
/**
* FK ag_md_province.id
*/
private Long provinceId;
/**
* FK ag_md_product.id
*/
private Long productId;
/**
* City name
*/
private String cityName;
/**
* City English name
*/
private String cityNameEn;
/**
* 国际码
*/
private String cityCode;
/**
* 几线城市
*/
private String cityLine;
/**
* 国际码
*/
private String globalCode;
/**
* Zip Code 邮政编码
*/
private String zipCode;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
/**
* FK ag_acl_insurer.id
*/
private Long insurerId;
private Date createdAt;
private Long createdBy;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ package com.yd.dal.mapper.commission;
import java.util.List;
import com.github.pagehelper.Page;
import com.yd.api.agms.vo.statement.statementData;
import com.yd.api.agms.vo.statistics.statementData;
import org.apache.ibatis.annotations.Param;
import com.yd.dal.entity.commission.CommissionEGolden;
......
......@@ -64,4 +64,6 @@ public interface AclPractitionerMapper {
PractitionerBasicInfo findByIdEG(@Param("practitionerIdEG")String practitionerIdEG);
AclPractitioner findPractitionerByLeadsAssignedId(Long leadsAssignedId);
List<AclPractitioner> findAll();
}
\ No newline at end of file
package com.yd.dal.mapper.marketing;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo;
import com.yd.dal.entity.leads.LeadsStatusInfo;
import com.yd.dal.entity.marketing.MktLeadsPool;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface MktLeadsPoolMapper {
int deleteByPrimaryKey(Long id);
......@@ -16,4 +22,14 @@ public interface MktLeadsPoolMapper {
int updateByPrimaryKey(MktLeadsPool record);
MktLeadsPool findByCustomerId(Long customerId);
List<LeadsStatisticsInfo> findALLByDate(@Param("leadsStartTime")String leadsStartTime, @Param("leadsEndTime")String leadsEndTime);
List<LeadsStatisticsInfo> findIsAssignByDate(@Param("leadsStartTime")String leadsStartTime, @Param("leadsEndTime")String leadsEndTime);
List<LeadsStatisticsInfo> findIsNotAssignByDate(@Param("leadsStartTime")String leadsStartTime, @Param("leadsEndTime")String leadsEndTime);
List<LeadsStatisticsInfo> findIsAssignLeads();
List<LeadsStatusInfo> findLeadsStatusMap();
}
\ No newline at end of file
package com.yd.dal.mapper.meta;
import com.yd.dal.entity.meta.MdCity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MdCityMapper {
int deleteByPrimaryKey(Long id);
int insert(MdCity record);
int insertSelective(MdCity record);
MdCity selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(MdCity record);
int updateByPrimaryKey(MdCity record);
List<MdCity> findByInsurerId(@Param("insurerId") Long insurerId);
}
\ No newline at end of file
......@@ -48,4 +48,6 @@ public interface MdDropOptionsMapper {
List<InsurerBranchInfo> findInsurerBranchInfoByIdEG(@Param("insurerBranchIds")List<String> insurerBranchIds);
List<InsurerBranchInfo> findInsurerBranchInfoEG();
List<MdDropOptions> findByDropMasterCodes(@Param("masterCodeList")List<String> masterCodeList);
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ package com.yd.dal.service.commission;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statement.statementData;
import com.yd.api.agms.vo.statistics.statementData;
import com.yd.dal.entity.commission.CommissionEGolden;
/**
......
......@@ -3,7 +3,7 @@ package com.yd.dal.service.commission;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statement.statementData;
import com.yd.api.agms.vo.statistics.statementData;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
......
......@@ -169,4 +169,10 @@ public interface AclPractitionerDALService {
* @return
*/
AclPractitioner findPractitionerByLeadsAssignedId(Long leadsAssignedId);
/**
* 查询所有经纪人
* @return 结果
*/
List<AclPractitioner> findAll();
}
......@@ -160,4 +160,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
public AclPractitioner findPractitionerByLeadsAssignedId(Long leadsAssignedId) {
return aclPractitionerMapper.findPractitionerByLeadsAssignedId(leadsAssignedId);
}
@Override
public List<AclPractitioner> findAll() {
return aclPractitionerMapper.findAll();
}
}
package com.yd.dal.service.marketing.Impl;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo;
import com.yd.dal.entity.leads.LeadsStatusInfo;
import com.yd.dal.entity.marketing.MktLeadsPool;
import com.yd.dal.mapper.marketing.MktLeadsPoolMapper;
import com.yd.dal.service.marketing.MktLeadsPoolDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("mktLeadsPoolDALService")
public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService {
......@@ -21,4 +26,32 @@ public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService {
public void save(MktLeadsPool pool) {
mktLeadsPoolMapper.insertSelective(pool);
}
@Override
public List<LeadsStatisticsInfo> findALLByDate(String leadsStartTime, String leadsEndTime) {
return mktLeadsPoolMapper.findALLByDate(leadsStartTime,leadsEndTime);
}
@Override
public List<LeadsStatisticsInfo> findIsAssignByDate(String leadsStartTime, String leadsEndTime) {
return mktLeadsPoolMapper.findIsAssignByDate(leadsStartTime,leadsEndTime);
}
@Override
public List<LeadsStatisticsInfo> findIsNotAssignByDate(String leadsStartTime, String leadsEndTime) {
return mktLeadsPoolMapper.findIsNotAssignByDate(leadsStartTime,leadsEndTime);
}
@Override
public List<LeadsStatisticsInfo> findIsAssignLeads() {
return mktLeadsPoolMapper.findIsAssignLeads();
}
@Override
public Map<Long, Long> findLeadsStatusMap() {
Map<Long, Long> leadsMap = new HashMap<>();
List<LeadsStatusInfo> leadsStatusInfoList = mktLeadsPoolMapper.findLeadsStatusMap();
leadsStatusInfoList.forEach(i->leadsMap.put(i.getLeadsCustomerId(),i.getLeadsStatus()));
return leadsMap;
}
}
package com.yd.dal.service.marketing;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo;
import com.yd.dal.entity.marketing.MktLeadsPool;
import java.util.List;
import java.util.Map;
public interface MktLeadsPoolDALService {
MktLeadsPool findByCustomerId(Long customerId);
void save(MktLeadsPool pool);
List<LeadsStatisticsInfo> findALLByDate(String leadsStartTime, String leadsEndTime);
List<LeadsStatisticsInfo> findIsAssignByDate(String leadsStartTime, String leadsEndTime);
List<LeadsStatisticsInfo> findIsNotAssignByDate(String leadsStartTime, String leadsEndTime);
List<LeadsStatisticsInfo> findIsAssignLeads();
Map<Long, Long> findLeadsStatusMap();
}
package com.yd.dal.service.meta;
import com.yd.dal.entity.meta.MdCity;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("mdCityDALService")
public interface MdCityDALService {
List<MdCity> findByInsurerId(Long i);
}
......@@ -38,4 +38,6 @@ public interface MdDropOptionsDALService {
List<InsurerBranchInfo> findInsurerBranchInfoByIdEG(List<String> insurerBranchIds);
List<InsurerBranchInfo> findInsurerBranchInfoEG();
List<MdDropOptions> findByDropMasterCodes(List<String> asList);
}
package com.yd.dal.service.meta.impl;
import com.yd.dal.entity.meta.MdCity;
import com.yd.dal.mapper.meta.MdCityMapper;
import com.yd.dal.service.meta.MdCityDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("mdCityDALService")
public class MdCityDALServiceImpl implements MdCityDALService {
@Resource
private MdCityMapper mdCityMapper;
@Override
public List<MdCity> findByInsurerId(Long insurerId) {
return mdCityMapper.findByInsurerId(insurerId);
}
}
......@@ -106,4 +106,9 @@ public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService {
public List<InsurerBranchInfo> findInsurerBranchInfoEG() {
return mdDropOptionsMapper.findInsurerBranchInfoEG();
}
@Override
public List<MdDropOptions> findByDropMasterCodes(List<String> masterCodeList) {
return mdDropOptionsMapper.findByDropMasterCodes(masterCodeList);
}
}
package com.yd.util.page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.LinkedList;
import java.util.List;
public class PageInfoUtils {
public static <T> PageInfo<T> list2PageInfo(List<T> arrayList, Integer pageNum, Integer pageSize) {
//实现list分页
PageHelper.startPage(pageNum, pageSize);
int pageStart = pageNum == 1 ? 0 : (pageNum - 1) * pageSize;
int pageEnd = arrayList.size() < pageSize * pageNum ? arrayList.size() : pageSize * pageNum;
List<T> pageResult = new LinkedList<T>();
if (arrayList.size() > pageStart) {
pageResult = arrayList.subList(pageStart, pageEnd);
}
PageInfo<T> pageInfo = new PageInfo<T>(pageResult);
//获取PageInfo其他参数
pageInfo.setTotal(arrayList.size());
int endRow = pageInfo.getEndRow() == 0 ? 0 : (pageNum - 1) * pageSize + pageInfo.getEndRow() + 1;
pageInfo.setEndRow(endRow);
boolean hasNextPage = arrayList.size() <= pageSize * pageNum ? false : true;
pageInfo.setHasNextPage(hasNextPage);
boolean hasPreviousPage = pageNum == 1 ? false : true;
pageInfo.setHasPreviousPage(hasPreviousPage);
pageInfo.setIsFirstPage(!hasPreviousPage);
boolean isLastPage = (arrayList.size() > pageSize * (pageNum - 1) && arrayList.size() <= pageSize * pageNum) ? true : false;
pageInfo.setIsLastPage(isLastPage);
int pages = arrayList.size() % pageSize == 0 ? arrayList.size() / pageSize : (arrayList.size() / pageSize) + 1;
pageInfo.setNavigateLastPage(pages);
int[] navigatePageNums = new int[pages];
for (int i = 1; i < pages; i++) {
navigatePageNums[i - 1] = i;
}
pageInfo.setNavigatepageNums(navigatePageNums);
int nextPage = pageNum < pages ? pageNum + 1 : 0;
pageInfo.setNextPage(nextPage);
pageInfo.setPageNum(pageNum);
pageInfo.setPageSize(pageSize);
pageInfo.setPages(pages);
pageInfo.setPrePage(pageNum - 1);
pageInfo.setSize(pageInfo.getList().size());
int starRow = arrayList.size() < pageSize * pageNum ? 1 + pageSize * (pageNum - 1) : 0;
pageInfo.setStartRow(starRow);
return pageInfo;
}
}
......@@ -27,7 +27,7 @@
WHERE policy.INS_MST_REPEAL != 1 AND sales.SAL_MST_MOBILE = #{login}
</select>
<select id="getStatementDataByPage" resultType="com.yd.api.agms.vo.statement.statementData">
<select id="getStatementDataByPage" resultType="com.yd.api.agms.vo.statistics.statementData">
select if(#{type,jdbcType=INTEGER} = 1,receive.mon024_302,receive.MON024_301) as inCommissionTime, -- 预计来佣年月
if(#{type,jdbcType=INTEGER} = 1,pay.MON025_302,pay.mon025_301) as outCommissionTime,
policy.INS_MST_POLICY_NUM as policyNo, -- 保单号
......
......@@ -919,4 +919,9 @@
left join ag_mkt_leads_assigneds a on a.assigned_practitioner_id = p.id
where a.id = #{leadsAssignedId,jdbcType=BIGINT}
</select>
<select id="findAll" resultType="com.yd.dal.entity.customer.AclPractitioner">
select
<include refid="Base_Column_List" />
from ag_acl_practitioner
</select>
</mapper>
\ No newline at end of file
......@@ -154,4 +154,101 @@
from ag_mkt_leads_pool
where customer_id = #{customerId,jdbcType=BIGINT}
</select>
<select id="findALLByDate" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo">
select c.id as leadsCustomerId,
c.`name` as leadsName,
c.login as leadsMobileNo,
c.wechat_no as leadsWeChatId,
c.age as leadsAge,
c.address as leadsCity,
c.blood_type_id as leadsBloodTypeId,
c.zodiac_type_id as leadsZodiacTypeId,
IF(c.gender = 1, '男', '女') as leadsGender,
date_format(pool.added_at , '%Y-%m-%d %H:%i:%s') as leadsCreatTime,
assign.id as assignId,
assign.assigned_practitioner_id as practitionerId,
pool.source_from as leadsSourceId,
date_format(assign.created_at, '%Y-%m-%d %H:%i:%s') as leadsAssignTime
from ag_mkt_leads_pool pool LEFT JOIN ag_acl_customer c on pool.customer_id = c.id
left join ag_mkt_leads_assigneds assign on assign.customer_id = pool.customer_id
where pool.is_active = 1
<if test="leadsStartTime != null">
and pool.added_at &gt;= #{leadsStartTime,jdbcType=VARCHAR}
</if>
<if test="leadsEndTime != null">
and pool.added_at &lt;= #{leadsEndTime,jdbcType=VARCHAR}
</if>
order by pool.added_at desc;
</select>
<select id="findIsAssignByDate" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo">
select c.`name` as leadsName,
c.login as leadsMobileNo,
c.wechat_no as leadsWeChatId,
c.age as leadsAge,
c.city_id as cityId,
c.blood_type_id as bloodTypeId,
c.zodiac_type_id as zodiacTypeId,
IF(c.gender = 1, '男', '女') as leadsGender,
date_format(pool.added_at , '%Y-%m-%d %H:%i:%s') as leadsCreatTime,
assgin.assigned_practitioner_id as practitionerId,
date_format(assgin.created_at, '%Y-%m-%d %H:%i:%s') as leadsAssignTime
from ag_mkt_leads_pool pool LEFT JOIN ag_acl_customer c on pool.customer_id = c.id
inner join ag_mkt_leads_assigneds assgin on assgin.customer_id = pool.customer_id
# where 1 == 1
<!-- <if test="leadsStartTime != null">-->
<!-- and pool.added_at >= #{leadsStartTime,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- <if test="leadsEndTime != null">-->
<!-- and pool.added_at <= #{leadsEndTime,jdbcType=VARCHAR}-->
<!-- </if>-->
order by pool.added_at desc;
</select>
<select id="findIsNotAssignByDate" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo">
select c.`name` as leadsName,
c.login as leadsMobileNo,
c.wechat_no as leadsWeChatId,
c.age as leadsAge,
c.city_id as cityId,
c.blood_type_id as bloodTypeId,
c.zodiac_type_id as zodiacTypeId,
IF(c.gender = 1, '男', '女') as leadsGender,
date_format(pool.added_at , '%Y-%m-%d %H:%i:%s') as leadsCreatTime,
assgin.assigned_practitioner_id as practitionerId,
date_format(assgin.created_at, '%Y-%m-%d %H:%i:%s') as leadsAssignTime
from ag_mkt_leads_pool pool LEFT JOIN ag_acl_customer c on pool.customer_id = c.id
left outer join ag_mkt_leads_assigneds assgin on assgin.customer_id = pool.customer_id
where assgin.customer_id is null
<!-- <if test="leadsStartTime != null">-->
<!-- and pool.added_at >= #{leadsStartTime,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- <if test="leadsEndTime != null">-->
<!-- and pool.added_at <= #{leadsEndTime,jdbcType=VARCHAR}-->
<!-- </if>-->
order by pool.added_at desc;
</select>
<select id="findIsAssignLeads" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo">
SELECT
assign.id as assignId, -- 派遣id
assign.customer_id as leadsCustomerId, -- 商机id
assign.assigned_practitioner_id as practitionerId, -- 经纪人id
expertAssign.expert_practitioner_id as smePractitionerId, -- 专家经纪人id
date_format(expertAssign.created_at , '%Y-%m-%d %H:%i:%s') as assignSMEDate, -- 专家派遣时间
date_format(assign.created_at , '%Y-%m-%d %H:%i:%s') as leadsAssignTime, -- 商机派遣时间
date_format(request.created_at , '%Y-%m-%d %H:%i:%s') as requestSMEDate, -- 专家请求时间
assign.FYC as predictFYP, -- 预计FYP
assign.FYP as predictFYC, -- 预计FYC
assign.pieces as predictPieces, -- 预计件数
date_format(assign.time_to_close , '%Y-%m-%d %H:%i:%s') as dealTime -- 预计成交时间
FROM ag_mkt_leads_assigneds assign left join ag_mkt_leads_expert_request request on request.leads_assigned_id = assign.id
left join ag_mkt_leads_expert_assign expertAssign on request.id = expertAssign.leads_expert_request_id
</select>
<select id="findLeadsStatusMap" resultType="com.yd.dal.entity.leads.LeadsStatusInfo">
SELECT maxt.customer_id as leadsCustomerId,
# tr.leads_assigned_id as assignId,
tr.md_drop_option_id as statusId -- 商机状态id
FROM(SELECT customer_id,max(updated_at) as track_time FROM ag_mkt_leads_assigned_track tr GROUP BY tr.customer_id) maxt
INNER JOIN ag_mkt_leads_assigned_track tr on maxt.customer_id=tr.customer_id AND maxt.track_time = tr.updated_at order by tr.leads_assigned_id;
</select>
</mapper>
\ No newline at end of file
<?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.yd.dal.mapper.meta.MdCityMapper">
<resultMap id="BaseResultMap" type="com.yd.dal.entity.meta.MdCity">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="province_id" jdbcType="BIGINT" property="provinceId" />
<result column="product_id" jdbcType="BIGINT" property="productId" />
<result column="city_name" jdbcType="VARCHAR" property="cityName" />
<result column="city_name_en" jdbcType="VARCHAR" property="cityNameEn" />
<result column="city_code" jdbcType="VARCHAR" property="cityCode" />
<result column="city_line" jdbcType="VARCHAR" property="cityLine" />
<result column="global_code" jdbcType="VARCHAR" property="globalCode" />
<result column="zip_code" jdbcType="VARCHAR" property="zipCode" />
<result column="is_active" jdbcType="INTEGER" property="isActive" />
<result column="insurer_id" jdbcType="BIGINT" property="insurerId" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="BIGINT" property="createdBy" />
</resultMap>
<sql id="Base_Column_List">
id, province_id, product_id, city_name, city_name_en, city_code, city_line, global_code,
zip_code, is_active, insurer_id, created_at, created_by
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_md_city
where id = #{id,jdbcType=BIGINT}
</select>
<select id="findByInsurerId" resultType="com.yd.dal.entity.meta.MdCity">
select
<include refid="Base_Column_List" />
from ag_md_city
where insurer_id = #{insurerId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from ag_md_city
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdCity" useGeneratedKeys="true">
insert into ag_md_city (province_id, product_id, city_name,
city_name_en, city_code, city_line,
global_code, zip_code, is_active,
insurer_id, created_at, created_by
)
values (#{provinceId,jdbcType=BIGINT}, #{productId,jdbcType=BIGINT}, #{cityName,jdbcType=VARCHAR},
#{cityNameEn,jdbcType=VARCHAR}, #{cityCode,jdbcType=VARCHAR}, #{cityLine,jdbcType=VARCHAR},
#{globalCode,jdbcType=VARCHAR}, #{zipCode,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER},
#{insurerId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdCity" useGeneratedKeys="true">
insert into ag_md_city
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="provinceId != null">
province_id,
</if>
<if test="productId != null">
product_id,
</if>
<if test="cityName != null">
city_name,
</if>
<if test="cityNameEn != null">
city_name_en,
</if>
<if test="cityCode != null">
city_code,
</if>
<if test="cityLine != null">
city_line,
</if>
<if test="globalCode != null">
global_code,
</if>
<if test="zipCode != null">
zip_code,
</if>
<if test="isActive != null">
is_active,
</if>
<if test="insurerId != null">
insurer_id,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="provinceId != null">
#{provinceId,jdbcType=BIGINT},
</if>
<if test="productId != null">
#{productId,jdbcType=BIGINT},
</if>
<if test="cityName != null">
#{cityName,jdbcType=VARCHAR},
</if>
<if test="cityNameEn != null">
#{cityNameEn,jdbcType=VARCHAR},
</if>
<if test="cityCode != null">
#{cityCode,jdbcType=VARCHAR},
</if>
<if test="cityLine != null">
#{cityLine,jdbcType=VARCHAR},
</if>
<if test="globalCode != null">
#{globalCode,jdbcType=VARCHAR},
</if>
<if test="zipCode != null">
#{zipCode,jdbcType=VARCHAR},
</if>
<if test="isActive != null">
#{isActive,jdbcType=INTEGER},
</if>
<if test="insurerId != null">
#{insurerId,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.meta.MdCity">
update ag_md_city
<set>
<if test="provinceId != null">
province_id = #{provinceId,jdbcType=BIGINT},
</if>
<if test="productId != null">
product_id = #{productId,jdbcType=BIGINT},
</if>
<if test="cityName != null">
city_name = #{cityName,jdbcType=VARCHAR},
</if>
<if test="cityNameEn != null">
city_name_en = #{cityNameEn,jdbcType=VARCHAR},
</if>
<if test="cityCode != null">
city_code = #{cityCode,jdbcType=VARCHAR},
</if>
<if test="cityLine != null">
city_line = #{cityLine,jdbcType=VARCHAR},
</if>
<if test="globalCode != null">
global_code = #{globalCode,jdbcType=VARCHAR},
</if>
<if test="zipCode != null">
zip_code = #{zipCode,jdbcType=VARCHAR},
</if>
<if test="isActive != null">
is_active = #{isActive,jdbcType=INTEGER},
</if>
<if test="insurerId != null">
insurer_id = #{insurerId,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.meta.MdCity">
update ag_md_city
set province_id = #{provinceId,jdbcType=BIGINT},
product_id = #{productId,jdbcType=BIGINT},
city_name = #{cityName,jdbcType=VARCHAR},
city_name_en = #{cityNameEn,jdbcType=VARCHAR},
city_code = #{cityCode,jdbcType=VARCHAR},
city_line = #{cityLine,jdbcType=VARCHAR},
global_code = #{globalCode,jdbcType=VARCHAR},
zip_code = #{zipCode,jdbcType=VARCHAR},
is_active = #{isActive,jdbcType=INTEGER},
insurer_id = #{insurerId,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
......@@ -335,4 +335,22 @@
t.SPC_TEL_NUM as contactNo
from spc001 t where t.SPC_CANCEL = 0;
</select>
<select id="findByDropMasterCodes" resultType="com.yd.dal.entity.meta.MdDropOptions">
select
o.id id,
o.drop_master_id dropMasterId,
o.drop_option_name dropOptionName,
o.drop_option_code dropOptionCode,
o.drop_option_order dropOptionOrder,
o.drop_option_score dropOptionScore,
o.drop_option_remark dropOptionRemark,
o.is_active isActive,
o.created_at createdAt,
o.created_by createdBy
from ag_md_drop_master m left join ag_md_drop_options o on m.id = o.drop_master_id and o.is_active = 1
where m.scenario_code in
<foreach collection="masterCodeList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
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