修改大客户导入模板和上下班打卡逻辑
parent
158514632e
commit
8bc652b66e
|
|
@ -1,17 +1,28 @@
|
|||
package com.cpxt.web.controller.biz;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.cpxt.biz.domain.*;
|
||||
import com.cpxt.biz.domain.vo.BizCustomerRouteVo;
|
||||
import com.cpxt.biz.domain.vo.BizOrderVo;
|
||||
import com.cpxt.biz.domain.vo.BizOrderVoCustomer;
|
||||
import com.cpxt.biz.mapper.*;
|
||||
import com.cpxt.common.constant.HttpStatus;
|
||||
import com.cpxt.common.core.domain.entity.SysUser;
|
||||
import com.cpxt.common.utils.SecurityUtils;
|
||||
import com.cpxt.system.mapper.SysDictDataMapper;
|
||||
import com.cpxt.system.service.ISysUserService;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -19,7 +30,6 @@ import com.cpxt.common.annotation.Log;
|
|||
import com.cpxt.common.core.controller.BaseController;
|
||||
import com.cpxt.common.core.domain.AjaxResult;
|
||||
import com.cpxt.common.enums.BusinessType;
|
||||
import com.cpxt.biz.domain.BizOrder;
|
||||
import com.cpxt.biz.service.IBizOrderService;
|
||||
import com.cpxt.common.utils.poi.ExcelUtil;
|
||||
import com.cpxt.common.core.page.TableDataInfo;
|
||||
|
|
@ -40,6 +50,21 @@ public class BizOrderController extends BaseController {
|
|||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private BizCustomerMapper bizCustomerMapper;
|
||||
|
||||
@Autowired
|
||||
private BizCustomerRouteMapper bizCustomerRouteMapper;
|
||||
|
||||
@Autowired
|
||||
private BizCustomerWarehouseMapper bizCustomerWarehouseMapper;
|
||||
|
||||
@Autowired
|
||||
private BizCustomerShopMapper bizCustomerShopMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDictDataMapper sysDictDataMapper;
|
||||
|
||||
/**
|
||||
* 查询订单列表(分页)
|
||||
*/
|
||||
|
|
@ -86,15 +111,138 @@ public class BizOrderController extends BaseController {
|
|||
* 订单导入模板
|
||||
*/
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
SysUser user = sysUserService.selectUserById(SecurityUtils.getLoginUser().getUserId());
|
||||
if ("0".equals(user.getUserType())) {
|
||||
ExcelUtil<BizOrderVo> util = new ExcelUtil<BizOrderVo>(BizOrderVo.class);
|
||||
util.importTemplateExcel(response, "订单数据");
|
||||
} else {
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
// 创建订单数据Sheet
|
||||
Sheet sheet1 = workbook.createSheet("订单数据");
|
||||
setSheet1(sheet1);
|
||||
// 创建路线数据Sheet
|
||||
Sheet sheet2 = workbook.createSheet("路线数据");
|
||||
setSheet2(sheet2);
|
||||
// 创建仓库数据Sheet
|
||||
Sheet sheet3 = workbook.createSheet("仓库数据");
|
||||
setSheet3(sheet3);
|
||||
// 创建仓库数据Sheet
|
||||
Sheet sheet4 = workbook.createSheet("店铺数据");
|
||||
setSheet4(sheet4);
|
||||
// 创建物品类型Sheet
|
||||
Sheet sheet5 = workbook.createSheet("物品类型");
|
||||
setSheet5(sheet5);
|
||||
// 设置响应头,指定下载的文件名和内容类型
|
||||
response.setHeader("Content-Disposition", "attachment; filename=orders.xlsx");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
// 将工作簿写入响应输出流
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
workbook.write(outputStream);
|
||||
} finally {
|
||||
workbook.close();
|
||||
}
|
||||
// ExcelUtil<BizOrderVoCustomer> util = new ExcelUtil<BizOrderVoCustomer>(BizOrderVoCustomer.class);
|
||||
// util.importTemplateExcel(response, "订单数据");
|
||||
}
|
||||
}
|
||||
|
||||
ExcelUtil<BizOrderVoCustomer> util = new ExcelUtil<BizOrderVoCustomer>(BizOrderVoCustomer.class);
|
||||
util.importTemplateExcel(response, "订单数据");
|
||||
private void setSheet1(Sheet sheet1) {
|
||||
Row row0 = sheet1.createRow(0);
|
||||
Cell cell0 = row0.createCell(0);
|
||||
cell0.setCellValue("路线名称");
|
||||
Cell cell1 = row0.createCell(1);
|
||||
cell1.setCellValue("仓库名称");
|
||||
Cell cell2 = row0.createCell(2);
|
||||
cell2.setCellValue("店铺名称");
|
||||
Cell cell3 = row0.createCell(3);
|
||||
cell3.setCellValue("物品类型");
|
||||
Cell cell4 = row0.createCell(4);
|
||||
cell4.setCellValue("物品名称");
|
||||
Cell cell5 = row0.createCell(5);
|
||||
cell5.setCellValue("重量");
|
||||
Cell cell6 = row0.createCell(6);
|
||||
cell6.setCellValue("长");
|
||||
Cell cell7 = row0.createCell(7);
|
||||
cell7.setCellValue("宽");
|
||||
Cell cell8 = row0.createCell(8);
|
||||
cell8.setCellValue("高");
|
||||
Cell cell9 = row0.createCell(9);
|
||||
cell9.setCellValue("备注");
|
||||
}
|
||||
|
||||
private void setSheet2(Sheet sheet2) {
|
||||
BizCustomer bizCustomer = bizCustomerMapper.selectByLinkPhone(SecurityUtils.getUsername());
|
||||
List<String> nameList = bizCustomerRouteMapper.selectNameByCustomerId(bizCustomer.getId());
|
||||
Row row0 = sheet2.createRow(0);
|
||||
Cell cell0 = row0.createCell(0);
|
||||
cell0.setCellValue("路线名称");
|
||||
for (int i = 0; i < nameList.size(); i++) {
|
||||
Row row = sheet2.createRow(i + 1);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(nameList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void setSheet3(Sheet sheet3) {
|
||||
BizCustomer bizCustomer = bizCustomerMapper.selectByLinkPhone(SecurityUtils.getUsername());
|
||||
List<BizCustomerWarehouse> warehouseList = bizCustomerWarehouseMapper.selectByCustomerId(bizCustomer.getId());
|
||||
Row row0 = sheet3.createRow(0);
|
||||
Cell cell0 = row0.createCell(0);
|
||||
cell0.setCellValue("仓库名称");
|
||||
Cell cell1 = row0.createCell(1);
|
||||
cell1.setCellValue("联系人");
|
||||
Cell cell2 = row0.createCell(2);
|
||||
cell2.setCellValue("联系电话");
|
||||
Cell cell3 = row0.createCell(3);
|
||||
cell3.setCellValue("仓库地址");
|
||||
for (int i = 0; i < warehouseList.size(); i++) {
|
||||
Row row = sheet3.createRow(i + 1);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(warehouseList.get(i).getName());
|
||||
Cell cell11 = row.createCell(1);
|
||||
cell11.setCellValue(warehouseList.get(i).getLinkman());
|
||||
Cell cell22 = row.createCell(2);
|
||||
cell22.setCellValue(warehouseList.get(i).getLinkphone());
|
||||
Cell cell33 = row.createCell(3);
|
||||
cell33.setCellValue(warehouseList.get(i).getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
private void setSheet4(Sheet sheet4) {
|
||||
BizCustomer bizCustomer = bizCustomerMapper.selectByLinkPhone(SecurityUtils.getUsername());
|
||||
List<BizCustomerShop> shopList = bizCustomerShopMapper.selectByCustomerId(bizCustomer.getId());
|
||||
Row row0 = sheet4.createRow(0);
|
||||
Cell cell0 = row0.createCell(0);
|
||||
cell0.setCellValue("店铺名称");
|
||||
Cell cell1 = row0.createCell(1);
|
||||
cell1.setCellValue("联系人");
|
||||
Cell cell2 = row0.createCell(2);
|
||||
cell2.setCellValue("联系电话");
|
||||
Cell cell3 = row0.createCell(3);
|
||||
cell3.setCellValue("店铺地址");
|
||||
for (int i = 0; i < shopList.size(); i++) {
|
||||
Row row = sheet4.createRow(i + 1);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(shopList.get(i).getName());
|
||||
Cell cell11 = row.createCell(1);
|
||||
cell11.setCellValue(shopList.get(i).getLinkman());
|
||||
Cell cell22 = row.createCell(2);
|
||||
cell22.setCellValue(shopList.get(i).getLinkphone());
|
||||
Cell cell33 = row.createCell(3);
|
||||
cell33.setCellValue(shopList.get(i).getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
private void setSheet5(Sheet sheet5) {
|
||||
List<String> nameList = sysDictDataMapper.selectLabelByType("sys_goods_type");
|
||||
Row row0 = sheet5.createRow(0);
|
||||
Cell cell0 = row0.createCell(0);
|
||||
cell0.setCellValue("物品类型");
|
||||
for (int i = 0; i < nameList.size(); i++) {
|
||||
Row row = sheet5.createRow(i + 1);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(nameList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -196,4 +344,12 @@ public class BizOrderController extends BaseController {
|
|||
public AjaxResult arrived(@RequestBody Map map) {
|
||||
return toAjax(bizOrderService.arrived(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* app当前司机订单统计
|
||||
*/
|
||||
@GetMapping("/statics")
|
||||
public AjaxResult statics() {
|
||||
return AjaxResult.success(bizOrderService.getOrderStaticsByDriver());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class SysNoticeController extends BaseController
|
|||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysNotice notice)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,6 +100,6 @@ public class BizDriver
|
|||
private Integer onlineStatus;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<BizDriverClock> bizDriverClockList;
|
||||
private BizDriverClock bizDriverClock;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cpxt.biz.domain.BizCustomerRoute;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 路线Mapper接口
|
||||
|
|
@ -15,4 +16,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface BizCustomerRouteMapper extends BaseMapper<BizCustomerRoute>
|
||||
{
|
||||
@Select("select name from biz_customer_route where customer_id = ${id}")
|
||||
List<String> selectNameByCustomerId(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cpxt.biz.domain.BizCustomerShop;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 门店Mapper接口
|
||||
|
|
@ -14,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface BizCustomerShopMapper extends BaseMapper<BizCustomerShop>
|
||||
{ }
|
||||
{
|
||||
@Select("select * from biz_customer_shop where customer_id = ${id}")
|
||||
List<BizCustomerShop> selectByCustomerId(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cpxt.biz.domain.BizCustomerWarehouse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 仓库Mapper接口
|
||||
|
|
@ -14,4 +15,10 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface BizCustomerWarehouseMapper extends BaseMapper<BizCustomerWarehouse>
|
||||
{ }
|
||||
{
|
||||
@Select("select * from biz_customer_warehouse where customer_id = ${id}")
|
||||
List<BizCustomerWarehouse> selectByCustomerId(Long id);
|
||||
|
||||
@Select("select linkphone from biz_customer_warehouse where customer_id = ${id}")
|
||||
List<String> selectLinkPhoneByCustomerId(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,4 +76,6 @@ public interface IBizOrderService
|
|||
|
||||
public int goDelivery(Map map);
|
||||
public int arrived(Map map);
|
||||
|
||||
Map<String,Long> getOrderStaticsByDriver();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ public class BizDriverServiceImpl implements IBizDriverService
|
|||
queryWrapper1.eq(BizDriverClock::getDriverId,driver.getId());
|
||||
queryWrapper1.orderByDesc(BizDriverClock::getUpdateTime);
|
||||
queryWrapper1.last("limit 1");
|
||||
List<BizDriverClock> driverClockList = bizDriverClockMapper.selectList(queryWrapper1);
|
||||
driver.setBizDriverClockList(driverClockList);
|
||||
driver.setBizDriverClock(bizDriverClockMapper.selectOne(queryWrapper1));
|
||||
}
|
||||
return bizDrivers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.cpxt.biz.service.impl;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ public class BizOrderServiceImpl implements IBizOrderService {
|
|||
LambdaQueryWrapper<BizOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizOrder::getStatus,1);
|
||||
queryWrapper.eq(BizOrder::getOrderStatus,orderStatus);
|
||||
queryWrapper.and(wq -> wq.like(BizOrder::getDriverName,bizDriver.getName()).or().like(BizOrder::getCopilotName,bizDriver.getName()));
|
||||
queryWrapper.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().like(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
queryWrapper.orderByDesc(BizOrder::getCreateTime);
|
||||
return bizOrderMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper);
|
||||
}
|
||||
|
|
@ -721,4 +722,52 @@ public class BizOrderServiceImpl implements IBizOrderService {
|
|||
order.setOrderStatus("3");
|
||||
return bizOrderMapper.updateById(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> getOrderStaticsByDriver() {
|
||||
String today = DateUtil.format(new Date(),"yyyy-MM-dd");
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
BizDriver bizDriver = bizDriverMapper.selectByUserId(userId);
|
||||
LambdaQueryWrapper<BizOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizOrder::getOrderStatus,"1");
|
||||
queryWrapper.eq(BizOrder::getStatus,1);
|
||||
queryWrapper.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().eq(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
Long dqj = bizOrderMapper.selectCount(queryWrapper);
|
||||
LambdaQueryWrapper<BizOrder> queryWrapper2 = new LambdaQueryWrapper<>();
|
||||
queryWrapper2.eq(BizOrder::getOrderStatus,"2");
|
||||
queryWrapper2.eq(BizOrder::getStatus,1);
|
||||
queryWrapper2.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().eq(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
Long psz = bizOrderMapper.selectCount(queryWrapper2);
|
||||
LambdaQueryWrapper<BizOrder> queryWrapper3 = new LambdaQueryWrapper<>();
|
||||
queryWrapper3.eq(BizOrder::getOrderStatus,"3");
|
||||
queryWrapper3.eq(BizOrder::getStatus,1);
|
||||
queryWrapper3.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().eq(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
Long ywc = bizOrderMapper.selectCount(queryWrapper3);
|
||||
LambdaQueryWrapper<BizOrder> queryWrapper4 = new LambdaQueryWrapper<>();
|
||||
queryWrapper4.eq(BizOrder::getOrderStatus,"1");
|
||||
queryWrapper4.eq(BizOrder::getStatus,1);
|
||||
queryWrapper4.like(BizOrder::getCreateTime,today);
|
||||
queryWrapper4.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().eq(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
Long dqjToday = bizOrderMapper.selectCount(queryWrapper4);
|
||||
LambdaQueryWrapper<BizOrder> queryWrapper5 = new LambdaQueryWrapper<>();
|
||||
queryWrapper5.eq(BizOrder::getOrderStatus,"2");
|
||||
queryWrapper5.eq(BizOrder::getStatus,1);
|
||||
queryWrapper5.like(BizOrder::getUpdateTime,today);
|
||||
queryWrapper5.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().eq(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
Long pszToday = bizOrderMapper.selectCount(queryWrapper5);
|
||||
LambdaQueryWrapper<BizOrder> queryWrapper6 = new LambdaQueryWrapper<>();
|
||||
queryWrapper6.eq(BizOrder::getOrderStatus,"3");
|
||||
queryWrapper6.eq(BizOrder::getStatus,1);
|
||||
queryWrapper6.like(BizOrder::getUpdateTime,today);
|
||||
queryWrapper6.and(wq -> wq.eq(BizOrder::getDriverId,bizDriver.getId()).or().eq(BizOrder::getCopilotId,bizDriver.getId()));
|
||||
Long ywcToday = bizOrderMapper.selectCount(queryWrapper6);
|
||||
Map<String,Long> map = new HashMap<>();
|
||||
map.put("dqj",dqj);
|
||||
map.put("psz",psz);
|
||||
map.put("ywc",ywc);
|
||||
map.put("dqjToday",dqjToday);
|
||||
map.put("pszToday",pszToday);
|
||||
map.put("ywcToday",ywcToday);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
package com.cpxt.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.cpxt.common.core.domain.entity.SysDictData;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 字典表 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysDictDataMapper
|
||||
@Mapper
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictData>
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
|
|
@ -92,4 +97,7 @@ public interface SysDictDataMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
|
||||
|
||||
@Select("select dict_label from sys_dict_data where dict_type = #{type}")
|
||||
List<String> selectLabelByType(String type);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue