|
|
@@ -15,6 +15,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
+
|
|
|
+import com.alibaba.druid.sql.visitor.functions.If;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.DailySalesReportMapper;
|
|
|
import com.goafanti.common.dao.UserMapper;
|
|
|
@@ -22,13 +24,17 @@ import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.DailySalesReport;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
+import com.goafanti.report.bo.CountDepMarketingStatisticsBo;
|
|
|
+import com.goafanti.report.bo.CountMarketingStatisticsBo;
|
|
|
import com.goafanti.report.bo.DepartmentSalesReportBO;
|
|
|
import com.goafanti.report.bo.PersonalSalesReportBO;
|
|
|
import com.goafanti.report.bo.ReportDate;
|
|
|
import com.goafanti.report.bo.SalesValues;
|
|
|
+import com.goafanti.report.bo.SomeTimeMarketingBo;
|
|
|
import com.goafanti.report.bo.marketingESBo;
|
|
|
import com.goafanti.report.enums.OrderBy;
|
|
|
import com.goafanti.report.enums.SalesReportOrderField;
|
|
|
+import com.goafanti.report.enums.TimeType;
|
|
|
|
|
|
@Service
|
|
|
public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMapper> {
|
|
|
@@ -249,138 +255,188 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- public Pagination<marketingESBo> marketingStatistics(String depId,Integer pNo,Integer pSize) {
|
|
|
- if (pNo == null || pNo < 0) {
|
|
|
- pNo = 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (pSize == null || pSize < 0 || pSize > 10) {
|
|
|
- pSize = 10;
|
|
|
- }
|
|
|
- Map<String, Object> params=new HashMap<>();
|
|
|
- if (StringUtils.isNotBlank(depId)) {
|
|
|
- params.put("depId", depId);
|
|
|
- }
|
|
|
- Pagination<marketingESBo> p=(Pagination<marketingESBo>) findPage("findmarketingStatisticsListByPage",
|
|
|
- "findmarketingStatisticsCount",params,
|
|
|
- pNo, pSize);
|
|
|
- List<marketingESBo> list=(List<marketingESBo>) p.getList();
|
|
|
- List<marketingESBo> l=new ArrayList<>();
|
|
|
-
|
|
|
- ReportDate rd = new ReportDate(new Date());
|
|
|
-
|
|
|
- for (marketingESBo m : list) {
|
|
|
+
|
|
|
+ public List<marketingESBo> marketingStatistics(String depId) {
|
|
|
+ List<marketingESBo> list=salesReportMapper.findmarketingStatisticsList(depId);
|
|
|
+ ReportDate rd = new ReportDate(new Date());
|
|
|
+ for (marketingESBo m : list) {
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
marketingESBo day=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getDailyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getDailyEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (day!=null&&StringUtils.isBlank(day.getYearFollowNo())) {
|
|
|
- m.setDailyFollowNo(day.getYearFollowNo());
|
|
|
- }
|
|
|
- if (day!=null&&StringUtils.isBlank(day.getYearTelNo())) {
|
|
|
- m.setDailyTelNo(day.getYearTelNo());
|
|
|
- }
|
|
|
- if (day!=null&&StringUtils.isBlank(day.getYearVisitNo())) {
|
|
|
- m.setDailyVisitNo(day.getYearVisitNo());
|
|
|
- }
|
|
|
+ Map<String,String> daily =valuesloading(day);
|
|
|
+ map.put("daily", daily);
|
|
|
marketingESBo weekly=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getWeeklyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getWeeklyEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearFollowNo())) {
|
|
|
- m.setWeeklyFollowNo(weekly.getYearFollowNo());
|
|
|
- }
|
|
|
- if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearTelNo())) {
|
|
|
- m.setWeeklyTelNo(weekly.getYearTelNo());
|
|
|
- }
|
|
|
- if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearVisitNo())) {
|
|
|
- m.setWeeklyVisitNo(weekly.getYearVisitNo());
|
|
|
- }
|
|
|
+ Map<String,String> week =valuesloading(weekly);
|
|
|
+ map.put("week", week);
|
|
|
marketingESBo month=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getMonthStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getMonthEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (month!=null&&StringUtils.isNotBlank(month.getYearFollowNo())) {
|
|
|
- m.setMonthFollowNo(month.getYearFollowNo());
|
|
|
- }
|
|
|
- if (month!=null&&StringUtils.isNotBlank(month.getYearTelNo())) {
|
|
|
- m.setMonthTelNo(month.getYearTelNo());
|
|
|
- }
|
|
|
- if (month!=null&&StringUtils.isNotBlank(month.getYearVisitNo())) {
|
|
|
- m.setMonthVisitNo(month.getYearVisitNo());
|
|
|
- }
|
|
|
+ Map<String,String> months =valuesloading(month);
|
|
|
+ map.put("months", months);
|
|
|
marketingESBo year=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getYearStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getYearEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (year!=null&&StringUtils.isNotBlank(year.getYearFollowNo())) {
|
|
|
- m.setYearFollowNo(year.getYearFollowNo());
|
|
|
- }
|
|
|
- if (year!=null&&StringUtils.isNotBlank(year.getYearTelNo())) {
|
|
|
- m.setYearTelNo(year.getYearTelNo());
|
|
|
- }
|
|
|
- if (year!=null&&StringUtils.isNotBlank(year.getYearVisitNo())) {
|
|
|
- m.setYearVisitNo(year.getYearVisitNo());
|
|
|
- }
|
|
|
- l.add(m);
|
|
|
+ Map<String,String> annual =valuesloading(year);
|
|
|
+ map.put("annual", annual);
|
|
|
+ m.setValues(map);
|
|
|
}
|
|
|
- p.setList(l);
|
|
|
- return p;
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- public Pagination<marketingESBo> marketingDepStatistics(String depId, Integer pNo, Integer pSize) {
|
|
|
- if (pNo == null || pNo < 0) {
|
|
|
- pNo = 1;
|
|
|
+
|
|
|
+ private Map<String, String> valuesloading(marketingESBo day) {
|
|
|
+ Map<String, String> map=new HashMap<>();
|
|
|
+ if (null!=day) {
|
|
|
+ map.put("VisitNo", day.getYearVisitNo());
|
|
|
+ map.put("TelNo", day.getYearTelNo());
|
|
|
+ map.put("FollowNo", day.getYearFollowNo());
|
|
|
+ }else {
|
|
|
+ map.put("VisitNo", "0");
|
|
|
+ map.put("TelNo", "0");
|
|
|
+ map.put("FollowNo", "0");
|
|
|
}
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
|
|
|
- if (pSize == null || pSize < 0 || pSize > 10) {
|
|
|
- pSize = 10;
|
|
|
- }
|
|
|
- Map<String, Object> params=new HashMap<>();
|
|
|
- if (StringUtils.isNotBlank(depId)) {
|
|
|
- params.put("depId", depId);
|
|
|
- }
|
|
|
- Pagination<marketingESBo> p=(Pagination<marketingESBo>) findPage("findmarketingDepStatisticsListByPage","findmarketingDepStatisticsCount",params,pNo, pSize);
|
|
|
- List<marketingESBo> list=(List<marketingESBo>) p.getList();
|
|
|
- List<marketingESBo> l=new ArrayList<>();
|
|
|
+ public List<marketingESBo> marketingDepStatistics(String depId) {
|
|
|
+ List<marketingESBo> list=salesReportMapper.marketingDepStatisticsList(depId);
|
|
|
ReportDate rd = new ReportDate(new Date());
|
|
|
for (marketingESBo m : list) {
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
marketingESBo day=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getDailyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getDailyEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (day!=null&&StringUtils.isNotBlank(day.getYearFollowNo())) {
|
|
|
- m.setDailyFollowNo(day.getYearFollowNo());
|
|
|
- System.out.println(day.getYearFollowNo());
|
|
|
- System.out.println(m.getDailyFollowNo());
|
|
|
- }
|
|
|
- if (day!=null&&StringUtils.isNotBlank(day.getYearTelNo())) {
|
|
|
- m.setDailyTelNo(day.getYearTelNo());
|
|
|
- }
|
|
|
- if (day!=null&&StringUtils.isNotBlank(day.getYearVisitNo())) {
|
|
|
- m.setDailyVisitNo(day.getYearVisitNo());
|
|
|
- }
|
|
|
+ Map<String,String> daily =valuesloading(day);
|
|
|
+ daily.put("AVG", calculateAVG((null==day||null==day.getYearFollowNo())?"0":day.getYearFollowNo(),(null==day||null==day.getDepartmentNumber())?"0":day.getDepartmentNumber()));
|
|
|
+ map.put("daily", daily);
|
|
|
marketingESBo weekly=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getWeeklyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getWeeklyEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearFollowNo())) {
|
|
|
- m.setWeeklyFollowNo(weekly.getYearFollowNo());
|
|
|
- }
|
|
|
- if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearTelNo())) {
|
|
|
- m.setWeeklyTelNo(weekly.getYearTelNo());
|
|
|
- }
|
|
|
- if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearVisitNo())) {
|
|
|
- m.setWeeklyVisitNo(weekly.getYearVisitNo());
|
|
|
- }
|
|
|
+ Map<String,String> week =valuesloading(weekly);
|
|
|
+ map.put("week", week);
|
|
|
marketingESBo month=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getMonthStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getMonthEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (month!=null&&StringUtils.isNotBlank(month.getYearFollowNo())) {
|
|
|
- m.setMonthFollowNo(month.getYearFollowNo());
|
|
|
- }
|
|
|
- if (month!=null&&StringUtils.isNotBlank(month.getYearTelNo())) {
|
|
|
- m.setMonthTelNo(month.getYearTelNo());
|
|
|
- }
|
|
|
- if (month!=null&&StringUtils.isNotBlank(month.getYearVisitNo())) {
|
|
|
- m.setMonthVisitNo(month.getYearVisitNo());
|
|
|
- }
|
|
|
+ Map<String,String> months =valuesloading(month);
|
|
|
+ map.put("months", months);
|
|
|
marketingESBo year=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getYearStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getYearEnd(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
- if (year!=null&&StringUtils.isNotBlank(year.getYearFollowNo())) {
|
|
|
- m.setYearFollowNo(year.getYearFollowNo());
|
|
|
- }
|
|
|
- if (year!=null&&StringUtils.isNotBlank(year.getYearTelNo())) {
|
|
|
- m.setYearTelNo(year.getYearTelNo());
|
|
|
- }
|
|
|
- if (year!=null&&StringUtils.isNotBlank(year.getYearVisitNo())) {
|
|
|
- m.setYearVisitNo(year.getYearVisitNo());
|
|
|
- }
|
|
|
- l.add(m);
|
|
|
+ Map<String,String> annual =valuesloading(year);
|
|
|
+ map.put("annual", annual);
|
|
|
+ m.setValues(map);
|
|
|
}
|
|
|
- p.setList(l);
|
|
|
- return p;
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CountMarketingStatisticsBo countMarketingStatistics(String depId) {
|
|
|
+ CountMarketingStatisticsBo count=salesReportMapper.privateCustomersCount(depId);
|
|
|
+ if (null==count) {
|
|
|
+ count=new CountMarketingStatisticsBo();
|
|
|
+ }
|
|
|
+ ReportDate rd = new ReportDate(new Date());
|
|
|
+ CountMarketingStatisticsBo d=userMapper.countmarketingDepStatistics(depId,rd.getStringDailyStart(),rd.getStringDailyEnd());
|
|
|
+ if (null!=d.getYearFollowNo()) {
|
|
|
+ count.setDailyFollowNo(d.getYearFollowNo());
|
|
|
+ count.setDailyTelNo(d.getYearTelNo());
|
|
|
+ count.setDailyVisitNo(d.getYearVisitNo());
|
|
|
+ }
|
|
|
+ CountMarketingStatisticsBo w=userMapper.countmarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
|
|
|
+ if (null!=w) {
|
|
|
+ count.setWeeklyFollowNo(w.getYearFollowNo());
|
|
|
+ count.setWeeklyTelNo(w.getYearTelNo());
|
|
|
+ count.setWeeklyVisitNo(w.getYearVisitNo());
|
|
|
+ }
|
|
|
+ CountMarketingStatisticsBo m=userMapper.countmarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
|
|
|
+ if (null!=d) {
|
|
|
+ count.setMonthFollowNo(m.getYearFollowNo());
|
|
|
+ count.setMonthTelNo(m.getYearTelNo());
|
|
|
+ count.setMonthVisitNo(m.getYearVisitNo());
|
|
|
+ }
|
|
|
+ CountMarketingStatisticsBo y=userMapper.countmarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
|
|
|
+ if (null!=d) {
|
|
|
+ count.setYearFollowNo(y.getYearFollowNo());
|
|
|
+ count.setYearTelNo(y.getYearTelNo());
|
|
|
+ count.setYearVisitNo(y.getYearVisitNo());
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CountMarketingStatisticsBo countMarketingDepStatistics(String depId) {
|
|
|
+
|
|
|
+ CountDepMarketingStatisticsBo count=salesReportMapper.privateCustomersDepCount(depId);
|
|
|
+ ReportDate rd = new ReportDate(new Date());
|
|
|
+ CountMarketingStatisticsBo d=userMapper.countmarketingDepStatistics(depId,rd.getStringDailyStart(),rd.getStringDailyEnd());
|
|
|
+ if (null!=d) {
|
|
|
+ count.setDailyFollowNo(d.getYearFollowNo());
|
|
|
+ count.setDailyTelNo(d.getYearTelNo());
|
|
|
+ count.setDailyVisitNo(d.getYearVisitNo());
|
|
|
+ count.setDailyAVG(calculateAVG(count.getDailyFollowNo(),count.getDepartmentNumber()));
|
|
|
+ }
|
|
|
+ CountMarketingStatisticsBo w=userMapper.countmarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
|
|
|
+ if (null!=w) {
|
|
|
+ count.setWeeklyFollowNo(w.getYearFollowNo());
|
|
|
+ count.setWeeklyTelNo(w.getYearTelNo());
|
|
|
+ count.setWeeklyVisitNo(w.getYearVisitNo());
|
|
|
+ count.setWeeklyAVG(calculateAVG(count.getWeeklyFollowNo(),count.getDepartmentNumber()));
|
|
|
+ }
|
|
|
+ CountMarketingStatisticsBo m=userMapper.countmarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
|
|
|
+ if (null!=m) {
|
|
|
+ count.setMonthFollowNo(m.getYearFollowNo());
|
|
|
+ count.setMonthTelNo(m.getYearTelNo());
|
|
|
+ count.setMonthVisitNo(m.getYearVisitNo());
|
|
|
+ count.setMonthAVG(calculateAVG(count.getMonthFollowNo(),count.getDepartmentNumber()));
|
|
|
+ }
|
|
|
+ CountMarketingStatisticsBo y=userMapper.countmarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
|
|
|
+ if (null!=y) {
|
|
|
+ count.setYearFollowNo(y.getYearFollowNo());
|
|
|
+ count.setYearTelNo(y.getYearTelNo());
|
|
|
+ count.setYearVisitNo(y.getYearVisitNo());
|
|
|
+ count.setYearAVG(calculateAVG(count.getYearFollowNo(),count.getDepartmentNumber()));
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String calculateAVG(String a, String b) {
|
|
|
+ if (StringUtils.isNumeric(a)&&StringUtils.isNumeric(b)) {
|
|
|
+ if ((float)Integer.valueOf(a)==0||(float)Integer.valueOf(b)==0)return "0";
|
|
|
+ float f=(float)Integer.valueOf(a)/(float)Integer.valueOf(b);
|
|
|
+ return String.valueOf(f);
|
|
|
+ }else {
|
|
|
+ return"0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<SomeTimeMarketingBo> sometimeMarketingStatistics(String depId, Integer timeType, String startTime, String endTime) {
|
|
|
+ List<SomeTimeMarketingBo> list = null;
|
|
|
+ ReportDate rd = new ReportDate(new Date());
|
|
|
+ if (TimeType.WEEKLY.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.MONTH.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.QTR.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringQuarterStart(),rd.getStringQuarterEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.YEAR.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.ZS.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingStatistics(depId,startTime,endTime);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<SomeTimeMarketingBo> sometimeMarketingDepStatistics(String depId, Integer timeType, String startTime, String endTime) {
|
|
|
+ List<SomeTimeMarketingBo> list = null;
|
|
|
+ ReportDate rd = new ReportDate(new Date());
|
|
|
+ if (TimeType.WEEKLY.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.MONTH.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.QTR.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringQuarterStart(),rd.getStringQuarterEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.YEAR.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
|
|
|
+ }
|
|
|
+ if (TimeType.ZS.getCode()==timeType) {
|
|
|
+ list=salesReportMapper.sometimeMarketingDepStatistics(depId,startTime,endTime);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
}
|