package com.stylefeng.guns.modular.system.service.impl;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.modular.system.model.Region;
|
import com.stylefeng.guns.modular.system.model.TCompany;
|
import com.stylefeng.guns.modular.system.dao.TCompanyMapper;
|
import com.stylefeng.guns.modular.system.model.User;
|
import com.stylefeng.guns.modular.system.service.ITCompanyService;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import org.apache.poi.hssf.usermodel.*;
|
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* <p>
|
* 公司信息表 服务实现类
|
* </p>
|
*
|
* @author 吕雪
|
* @since 2020-06-06
|
*/
|
@Service
|
public class TCompanyServiceImpl extends ServiceImpl<TCompanyMapper, TCompany> implements ITCompanyService {
|
|
|
@Resource
|
private TCompanyMapper companyMapper;
|
|
|
|
|
@Override
|
public List<Map<String, Object>> getCompanyList(Page<Map<String, Object>> page, String beginTime, String endTime, String name, String principalName, String principalPhone, String adminName, String adminPhone, String serviceStr, Integer state) {
|
return this.baseMapper.getCompanyList(page, beginTime, endTime, name, principalName, principalPhone, adminName, adminPhone, serviceStr, state);
|
}
|
|
@Override
|
public List<Map<String, Object>> getCompanyScopeById(Integer id) {
|
return this.baseMapper.getCompanyScopeById(id);
|
}
|
|
@Override
|
public List<Map<String, Object>> getFranchiseeList(Page<Map<String, Object>> page, String beginTime, String endTime, String name, String account, String principalName, String principalPhone, String serviceStr, Integer state, Integer roleType, Integer nowUserId) {
|
return this.baseMapper.getFranchiseeList(page, beginTime, endTime, name, account, principalName, principalPhone, serviceStr, state, roleType, nowUserId);
|
}
|
|
@Override
|
public ResultUtil selectCompanyInfoById(String id) throws Exception {
|
Map<String, Object> map = new HashMap<>();
|
TCompany companyInfo = this.selectById(id);
|
/*Address address = addressService.selectById((String) companyInfo.getDetailAddress());
|
companyInfo.setAddressId(address);
|
Map<String, List<Region>> regions = null;
|
if(null != address){
|
//查询注册地址对应的行政数据
|
regions = regionService.getRegions(address.getProvince(), address.getCity());
|
}
|
//查询企业的超级管理员
|
EntityWrapper<User> entityWrapper = new EntityWrapper<>();
|
entityWrapper.eq("is_admin", "0");
|
entityWrapper.eq("company_info_id", companyInfo.getCompanyId());
|
entityWrapper.ne("status", 3);
|
User user = userService.selectOne(entityWrapper);
|
|
//查询企业的经营范围
|
List<OperateRegion> OperateRegions = operateRegionService.getDataByCompanyInfoId(companyInfo.getCompanyId());
|
|
map.put("companyInfo", companyInfo);
|
map.put("region", regions);
|
map.put("OperateRegion", OperateRegions);
|
map.put("admin", user);*/
|
return ResultUtil.success(map);
|
}
|
|
|
/**
|
* 获取运营汇总数据
|
* @param type
|
* @param start
|
* @param end
|
* @param companyId
|
* @param offset
|
* @param limit
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public Map<String, Object> queryOperationalData(Integer type, String start, String end, Integer companyId, Integer offset, Integer limit) throws Exception {
|
Map<String, Object> map = new HashMap<>();
|
List<Map<String, Object>> list = companyMapper.queryOperationalData(type, start, end, companyId, offset, limit);
|
int i = companyMapper.queryOperationalDataCount(type, start, end, companyId);
|
map.put("rows", list);
|
map.put("total", i);
|
return map;
|
}
|
|
|
/**
|
* 下载运营汇总数据
|
* @param type
|
* @param companyId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public HSSFWorkbook downloadOperationalData(Integer type, String start, String end, Integer companyId) throws Exception {
|
List<Map<String, Object>> list = companyMapper.queryOperationalData(type, start, end, companyId, null, null);
|
|
List<List<String>> lists = new ArrayList<>();
|
List<String> list1 = new ArrayList<>();
|
list1.add("类别:");
|
list1.add(type == 1 ? "专车" : type == 2 ? "出租车" : type == 3 ? "城际" : "小件物流");
|
list1.add("");
|
list1.add("");
|
list1.add("起止时间:");
|
list1.add(null == start || "".equals(start) ? "" : start + " ~ " + end);
|
list1.add("");
|
list1.add("");
|
list1.add("运营商:");
|
String company = "";
|
if(null != companyId){
|
company = companyMapper.selectById(companyId).getName();
|
}
|
list1.add(company);
|
list1.add("");
|
list1.add("");
|
lists.add(list1);
|
list1 = new ArrayList<>();
|
list1.add("日期");
|
list1.add("用户注册数量");
|
list1.add("在线司机数");
|
list1.add("订单情况");
|
list1.add("");
|
list1.add("");
|
list1.add("支付情况");
|
list1.add("");
|
list1.add("");
|
list1.add("");
|
list1.add("");
|
list1.add("投诉数量");
|
lists.add(list1);
|
list1 = new ArrayList<>();
|
list1.add("");
|
list1.add("");
|
list1.add("");
|
list1.add("下单数量");
|
list1.add("乘客取消数量");
|
list1.add("取消占比");
|
list1.add("通过平台支付(单)");
|
list1.add("通过其它支付(单)");
|
list1.add("合计");
|
list1.add("平台支付占比%");
|
list1.add("金额");
|
list1.add("");
|
lists.add(list1);
|
|
List<List<List<String>>> lists1 = new ArrayList<>();
|
List<List<String>> lists2 = new ArrayList<>();
|
for(Map<String, Object> map : list){
|
List<String> list2 = new ArrayList<>();
|
list2.add(null != map.get("time") ? map.get("time").toString() : "");
|
list2.add(null != map.get("register") ? map.get("register").toString() : "");
|
list2.add(null != map.get("online") ? map.get("online").toString() : "");
|
list2.add(null != map.get("orderNum") ? map.get("orderNum").toString() : "");
|
list2.add(null != map.get("cancelNum") ? map.get("cancelNum").toString() : "");
|
list2.add(null != map.get("cancelProportion") ? map.get("cancelProportion").toString() : "");
|
list2.add(null != map.get("onlinePay") ? map.get("onlinePay").toString() : "");
|
list2.add(null != map.get("offlinePay") ? map.get("offlinePay").toString() : "");
|
list2.add(null != map.get("total") ? map.get("total").toString() : "");
|
list2.add(null != map.get("payProportion") ? map.get("payProportion").toString() : "");
|
list2.add(null != map.get("money") ? map.get("money").toString() : "");
|
list2.add(null != map.get("complaint") ? map.get("complaint").toString() : "");
|
lists2.add(list2);
|
}
|
lists1.add(lists2);
|
HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
|
HSSFSheet hssfSheet = hssfWorkbook.createSheet();
|
hssfSheet.setColumnWidth(0, 6 * 256);
|
hssfSheet.setDefaultRowHeightInPoints(20f);
|
for(int i = 0; i < lists.size(); i++){
|
HSSFRow hssfRow = hssfSheet.createRow(i);//设置第一行数据(标题)
|
HSSFCellStyle style = hssfWorkbook.createCellStyle();
|
HSSFFont font = hssfWorkbook.createFont();
|
font.setBold(true);
|
style.setFont(font);
|
style.setAlignment(HorizontalAlignment.CENTER);
|
for (int l = 0; l < lists.get(i).size(); l++) {
|
HSSFCell hssfCell = hssfRow.createCell(l);
|
hssfCell.setCellType(CellType.STRING);//设置表格类型
|
hssfCell.setCellValue(lists.get(i).get(l));
|
hssfCell.setCellStyle(style);
|
if(l > 0) {
|
hssfSheet.setColumnWidth(l , 20 * 256);
|
}
|
|
}
|
}
|
//这个就是合并单元格
|
//参数说明:1:开始行 2:结束行 3:开始列 4:结束列
|
//比如我要合并 第二行到第四行的 第六列到第八列 sheet.addMergedRegion(new CellRangeAddress(1,3,5,7));
|
hssfSheet.addMergedRegion(new CellRangeAddress(0,0,1,3));
|
hssfSheet.addMergedRegion(new CellRangeAddress(0,0,5,7));
|
hssfSheet.addMergedRegion(new CellRangeAddress(0,0,9,10));
|
hssfSheet.addMergedRegion(new CellRangeAddress(1,2,0,0));
|
hssfSheet.addMergedRegion(new CellRangeAddress(1,2,1,1));
|
hssfSheet.addMergedRegion(new CellRangeAddress(1,2,2,2));
|
hssfSheet.addMergedRegion(new CellRangeAddress(1,1,3,5));
|
hssfSheet.addMergedRegion(new CellRangeAddress(1,1,6,10));
|
hssfSheet.addMergedRegion(new CellRangeAddress(1,2,11,11));
|
|
|
for(int i = 0; i < lists1.size(); i++){
|
//将数据添加到表格中
|
List<String> data = null;
|
for (int l = 0; l < lists1.get(i).size(); l++) {
|
HSSFRow row = hssfSheet.createRow(l + 3);
|
data = lists1.get(i).get(l);
|
for (int j = 0; j < data.size(); j++) {
|
HSSFCell hssfCell = row.createCell(j);
|
hssfCell.setCellType(CellType.STRING);//设置表格类型
|
hssfCell.setCellValue(data.get(j));
|
}
|
}
|
}
|
return hssfWorkbook;
|
}
|
}
|