package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.shiro.ShiroUser;
|
import com.stylefeng.guns.modular.system.controller.resp.TDriverResp;
|
import com.stylefeng.guns.modular.system.controller.util.ExcelUtil;
|
import com.stylefeng.guns.modular.system.model.TAgent;
|
import com.stylefeng.guns.modular.system.model.TAppUser;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.shiro.subject.Subject;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.stylefeng.guns.core.log.LogObjectHolder;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import com.stylefeng.guns.modular.system.model.TDriver;
|
import com.stylefeng.guns.modular.system.service.ITDriverService;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.OutputStream;
|
import java.math.BigDecimal;
|
import java.text.DateFormat;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2023-02-20 09:07:06
|
*/
|
@Controller
|
@RequestMapping("/tDriver")
|
public class TDriverController extends BaseController {
|
|
private String PREFIX = "/system/tDriver/";
|
|
@Autowired
|
private ITDriverService tDriverService;
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tDriver.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tDriver_add")
|
public String tDriverAdd() {
|
return PREFIX + "tDriver_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tDriver_update/{tDriverId}")
|
public String tDriverUpdate(@PathVariable Integer tDriverId, Model model) {
|
TDriver tDriver = tDriverService.selectById(tDriverId);
|
model.addAttribute("item",tDriver);
|
LogObjectHolder.me().set(tDriver);
|
return PREFIX + "tDriver_edit.html";
|
}
|
|
/**
|
* 跳转冻结页面
|
* @return
|
*/
|
@RequestMapping("/tDriver_start_and_stop")
|
public String tAppUserStartAndStop( Integer id,
|
Model model) {
|
TDriver tDriver = tDriverService.selectById(id);
|
|
model.addAttribute("id",id);
|
model.addAttribute("status",tDriver.getStatus());
|
return PREFIX + "tDriverStartAndStop.html";
|
}
|
|
/**
|
* 跳转充值页面
|
* @return
|
*/
|
@RequestMapping("/rechargeBalancePage")
|
public String rechargeBalancePage( Integer id,
|
Model model) {
|
model.addAttribute("id",id);
|
return PREFIX + "tDriverRechargeBalancePage.html";
|
}
|
|
/**
|
* 跳转异常页面
|
* @return
|
*/
|
@RequestMapping("/tDriver_exception")
|
public String tDriverException(Model model) {
|
model.addAttribute("isException",2);
|
return PREFIX + "tDriverException.html";
|
}
|
/**
|
* 跳转异常启用冻结页面
|
* @return
|
*/
|
@RequestMapping("/tDriverException_start_and_stop")
|
public String tDriverExceptionStartAndStop(Integer id,Model model) {
|
TDriver tDriver = tDriverService.selectById(id);
|
model.addAttribute("id",id);
|
model.addAttribute("status",tDriver.getStatus());
|
return PREFIX + "tDriverExceptionStartAndStop.html";
|
}
|
|
/**
|
* 跳转审核页面
|
* @return
|
*/
|
@RequestMapping("/auditPage")
|
public String auditPage( Integer id,
|
Model model) {
|
tDriverService.auditPage(id,model);
|
return PREFIX + "tDriverAudit.html";
|
}
|
|
/**
|
* 跳转详情页面
|
*/
|
@RequestMapping("/driverDetail")
|
public String driverDetail(Integer tDriverId, Model model) {
|
tDriverService.detail(tDriverId,model);
|
|
return PREFIX + "tDriverDetail.html";
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String createTime,String phone,Integer status) {
|
EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status);
|
wrapper.ne("isException",2);
|
List<TDriver> tDrivers = tDriverService.selectList(wrapper);
|
return tDriverService.getTDriverResp(tDrivers);
|
}
|
/**
|
* 获取异常列表
|
*/
|
@RequestMapping(value = "/exceptionList")
|
@ResponseBody
|
public Object exceptionList(String createTime,String phone,Integer status) {
|
EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status);
|
wrapper.eq("isException",2);
|
List<TDriver> tDrivers = tDriverService.selectList(wrapper);
|
return tDriverService.getTDriverResp(tDrivers);
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list-back")
|
@ResponseBody
|
public Object listBack(String condition) {
|
return tDriverService.selectList(null);
|
}
|
|
/**
|
* 审核
|
*/
|
@RequestMapping(value = "/auditSubmit")
|
@ResponseBody
|
public Object auditSubmit(Integer id,Integer approvalStatus,String approvalNotes) {
|
TDriver tDriver = tDriverService.selectById(id);
|
tDriver.setApprovalStatus(approvalStatus);
|
tDriver.setApprovalNotes(approvalNotes);
|
// 审核用户id
|
Subject subject = ShiroKit.getSubject();
|
ShiroUser shiroUser = (ShiroUser)subject.getPrincipal();
|
tDriver.setApprovalUserId(shiroUser.getId());
|
tDriver.setApprovalTime(new Date());
|
tDriverService.updateById(tDriver);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 新增
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(TDriver tDriver) {
|
tDriverService.insert(tDriver);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tDriverId) {
|
tDriverService.deleteById(tDriverId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改司机状态
|
*/
|
@RequestMapping(value = "/update-status")
|
@ResponseBody
|
public Object updateStatus(Integer id,Integer status,
|
String remark) {
|
TDriver tDriver = tDriverService.selectById(id);
|
if(1 == status){
|
tDriver.setStatus(2);
|
}
|
if(2 == status){
|
tDriver.setStatus(1);
|
}
|
tDriver.setRemark(remark);
|
tDriverService.updateById(tDriver);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 充值余额
|
*/
|
@ApiOperation(value = "充值余额")
|
@RequestMapping(value = "/recharge-balance")
|
@ResponseBody
|
public Object rechargeBalance(Integer id, String money) {
|
TDriver tDriver = tDriverService.selectById(id);
|
tDriver.setBackgroundBalance(new BigDecimal(money).add(tDriver.getBackgroundBalance()));
|
tDriverService.updateById(tDriver);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TDriver tDriver) {
|
tDriverService.updateById(tDriver);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tDriverId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tDriverId") Integer tDriverId) {
|
return tDriverService.selectById(tDriverId);
|
}
|
|
@ApiOperation(value = "导出司机列表",notes="导出司机列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@RequestMapping(value = "/export")
|
@ResponseBody
|
public void export(String createTime,String phone,Integer status,HttpServletResponse response) {
|
try {
|
Date date = new Date();
|
DateFormat format = new SimpleDateFormat("yyyyMMdd");
|
String time1 = format.format(date);
|
String fileName = "DriverInfo"+time1+".xls";
|
String[] title = new String[] {"编号","姓名","手机号","性别","驾驶证号码","身份证号码",
|
"身份证","所属代理商","所属分公司","钱包余额","累计订单量","当月订单量","积分","拒单次数","状态","添加时间"};
|
EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status);
|
// 是否异常
|
List<TDriver> list = tDriverService.selectList(wrapper);
|
|
List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(list);
|
|
String[][] values = new String[tDriverResp.size()][];
|
for (int i = 0; i < tDriverResp.size(); i++) {
|
TDriverResp d = tDriverResp.get(i);
|
values[i] = new String[title.length];
|
values[i][0] = d.getCode();
|
values[i][1] = d.getName();
|
values[i][2] = d.getPhone();
|
Integer sex = d.getSex();
|
if(Objects.isNull(sex)){
|
values[i][3] = "未知";
|
}else if(1 == sex){
|
values[i][3] = "男";
|
}else if(2 == sex){
|
values[i][3] = "女";
|
}
|
values[i][4] = d.getDriverLicenseNumber();
|
values[i][5] = d.getIdcard();
|
if(StringUtils.hasLength(d.getIdcardFront())){
|
values[i][6] = "已上传";
|
}else {
|
values[i][6] = "未上传";
|
}
|
values[i][7] = d.getAgentName();
|
values[i][8] = d.getBranchName();
|
values[i][9] = String.valueOf(d.getBalance());
|
values[i][10] = String.valueOf(d.getCumulativeOrderCount());
|
values[i][11] = String.valueOf(d.getMonthOrderCount());
|
values[i][12] = String.valueOf(d.getIntegral());
|
values[i][13] = String.valueOf(d.getRefusalCount());
|
Integer status1 = d.getStatus();
|
if(1 == status1){
|
values[i][14] = "正常";
|
}else if(2 == status1){
|
values[i][14] = "冻结";
|
}else {
|
values[i][14] = "删除";
|
}
|
values[i][15] = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(d.getCreateTime());
|
}
|
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null);
|
ExcelUtil.setResponseHeader(response, fileName);
|
OutputStream os = response.getOutputStream();
|
wb.write(os);
|
os.flush();
|
os.close();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@ApiOperation(value = "导出司机异常列表",notes="导出司机异常列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@RequestMapping(value = "/export-exception")
|
@ResponseBody
|
public void exportException(String createTime,String phone,Integer status,HttpServletResponse response) {
|
try {
|
Date date = new Date();
|
DateFormat format = new SimpleDateFormat("yyyyMMdd");
|
String time1 = format.format(date);
|
String fileName = "DriverExceptionInfo"+time1+".xls";
|
String[] title = new String[] {"编号","姓名","手机号","性别","驾驶证号码","身份证号码",
|
"身份证","累计订单量","当月订单量","积分","连续未上线(天)","状态","添加时间"};
|
EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status);
|
wrapper.eq("isException",2);
|
// 是否异常
|
List<TDriver> list = tDriverService.selectList(wrapper);
|
|
List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(list);
|
|
String[][] values = new String[tDriverResp.size()][];
|
for (int i = 0; i < tDriverResp.size(); i++) {
|
TDriverResp d = tDriverResp.get(i);
|
values[i] = new String[title.length];
|
values[i][0] = d.getCode();
|
values[i][1] = d.getName();
|
values[i][2] = d.getPhone();
|
Integer sex = d.getSex();
|
if(Objects.isNull(sex)){
|
values[i][3] = "未知";
|
}else if(1 == sex){
|
values[i][3] = "男";
|
}else if(2 == sex){
|
values[i][3] = "女";
|
}
|
values[i][4] = d.getDriverLicenseNumber();
|
values[i][5] = d.getIdcard();
|
if(StringUtils.hasLength(d.getIdcardFront())){
|
values[i][6] = "已上传";
|
}else {
|
values[i][6] = "未上传";
|
}
|
values[i][7] = String.valueOf(d.getCumulativeOrderCount());
|
values[i][8] = String.valueOf(d.getMonthOrderCount());
|
values[i][9] = String.valueOf(d.getIntegral());
|
values[i][10] = String.valueOf(Objects.isNull(d.getNotOnlineCount())?0:d.getNotOnlineCount());
|
values[i][11] = "异常";
|
values[i][12] = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(d.getCreateTime());
|
}
|
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null);
|
ExcelUtil.setResponseHeader(response, fileName);
|
OutputStream os = response.getOutputStream();
|
wb.write(os);
|
os.flush();
|
os.close();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|