Ver código fonte

司机管理

huangfuli 4 anos atrás
pai
commit
a863c62c2d

+ 36 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/DriverViewInfoController.java

@@ -1,6 +1,12 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.DriverViewInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverViewInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
@@ -16,6 +22,36 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/driverViewInfo")
 public class DriverViewInfoController {
+    @Autowired
+    private IDriverViewInfoService driverViewInfoService;
+
+    /**
+     * 司机管理页面列表
+     * @param driverViewInfo
+     * @return
+     */
+    @GetMapping("/selectDriverInfoPage")
+    public Page<DriverViewInfo> selectDriverInfoPage(DriverViewInfo driverViewInfo){
+        return driverViewInfoService.selectDriverInfoPage(driverViewInfo);
+    }
+    /**
+     * 查看司机信息
+     * @param id
+     * @return
+     */
+    @GetMapping("/getDriver")
+    public DriverViewInfo getDriver (String id){
+        return driverViewInfoService.getDriver(id);
+    }
+
+    /**
+     * 删除司机信息
+     * @param id
+     */
+    @PostMapping("/api/deleteDriver")
+    public void deleteDriver(String id){
+        driverViewInfoService.deleteDriver(id);
+    }
 
 }
 

+ 62 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/DriverViewInfo.java

@@ -2,7 +2,9 @@ package com.yh.saas.plugin.yiliangyiyun.entity;
 
 import com.baomidou.mybatisplus.activerecord.Model;
 import java.io.Serializable;
+import java.util.List;
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.annotations.Version;
@@ -75,6 +77,66 @@ public class DriverViewInfo extends BaseModel<DriverViewInfo> {
      */
     private String disableReasons;
 
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+
+    /**
+     * 车牌号
+     */
+    @TableField(exist = false)
+    private String carNumber;
+
+    /**
+     * 车型
+     */
+    @TableField(exist = false)
+    private String carModel;
+
+    /**
+     * 车长
+     */
+    @TableField(exist = false)
+    private Float carLength;
+
+    /**
+     * 收款人姓名
+     */
+    @TableField(exist = false)
+    private String payeeName;
+
+    /**
+     * 收款人身份证号码
+     */
+    @TableField(exist = false)
+    private String payeeNumberCard;
+
+    /**
+     * 开户行
+     */
+    @TableField(exist = false)
+    private String bankDeposit;
+
+    /**
+     * 银行卡账号
+     */
+    @TableField(exist = false)
+    private String bankCard;
+
+    /**
+     * 企业名称
+     */
+    @TableField(exist = false)
+    private String compName;
+
+    @TableField(exist = false)
+    private List<DriverCarInfo> driverCarInfoList;
+
+    @TableField(exist = false)
+    private List<DriverPayeeInfo> driverPayeeInfoList;
+
 
     @Override
     protected Serializable pkVal() {

+ 18 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/DriverViewInfoMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.DriverViewInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录司机信息 Mapper 接口
@@ -13,4 +16,19 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  */
 public interface DriverViewInfoMapper extends BaseMapper<DriverViewInfo> {
 
+    /**
+     * 根据条件查询司机总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询司机列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<DriverViewInfo> getListByCondition(Map<String, Object> pageView);
 }

+ 15 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IDriverViewInfoService.java

@@ -2,7 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.service;
 
 import com.yh.saas.plugin.yiliangyiyun.entity.DriverViewInfo;
 import com.baomidou.mybatisplus.service.IService;
-
+import com.baomidou.mybatisplus.plugins.Page;
 /**
  * <p>
  * 记录司机信息 服务类
@@ -13,4 +13,18 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface IDriverViewInfoService extends IService<DriverViewInfo> {
 
+    /**
+     *司机管理页面列表
+     */
+    Page<DriverViewInfo> selectDriverInfoPage(DriverViewInfo driverViewInfo);
+
+    /**
+     *查看司机信息
+     */
+    DriverViewInfo getDriver (String id);
+
+    /**
+     *删除司机信息
+     */
+    void deleteDriver(String id);
 }

+ 92 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/DriverViewInfoServiceImpl.java

@@ -1,10 +1,23 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.yh.saas.plugin.yiliangyiyun.entity.DriverCarInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.DriverPayeeInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.DriverViewInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.DriverViewInfoMapper;
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverCarInfoService;
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverPayeeInfoService;
 import com.yh.saas.plugin.yiliangyiyun.service.IDriverViewInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -17,4 +30,83 @@ import org.springframework.stereotype.Service;
 @Service
 public class DriverViewInfoServiceImpl extends ServiceImpl<DriverViewInfoMapper, DriverViewInfo> implements IDriverViewInfoService {
 
+    @Autowired
+    private IDriverCarInfoService driverCarInfoService;
+    @Autowired
+    private IDriverPayeeInfoService driverPayeeInfoService;
+
+    /**
+     * 司机管理页面列表
+     * @param driverViewInfo
+     * @return
+     */
+    @Override
+    public Page<DriverViewInfo> selectDriverInfoPage(DriverViewInfo driverViewInfo){
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (driverViewInfo.getCurrentPage() - 1)
+                * driverViewInfo.getPageSize());
+        //公司id
+        pageView.put("compId",driverViewInfo.getCompId());
+        pageView.put("residentCityProvincial",driverViewInfo.getResidentCityProvincial());
+        pageView.put("residentCityMunicipal",driverViewInfo.getResidentCityMunicipal());
+        pageView.put("searchKeyWord",driverViewInfo.getSearchKeyWord());
+        pageView.put("pageSize",driverViewInfo.getPageSize());
+        pageView.put("currentPage",driverViewInfo.getCurrentPage());
+        // 查询司机总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<DriverViewInfo> dataList = baseMapper.getListByCondition(pageView);
+        Page<DriverViewInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(driverViewInfo.getCurrentPage());
+        page.setSize(driverViewInfo.getPageSize());
+        return page;
+    }
+
+    /**
+     * 查看司机信息
+     * @param id
+     * @return
+     */
+    @Override
+    public DriverViewInfo getDriver (String id){
+        //查看司机信息
+        DriverViewInfo driverViewInfo = this.selectById(id);
+        //查看货车信息
+        List<DriverCarInfo> driverCarInfoList = driverCarInfoService.selectList(new EntityWrapper<DriverCarInfo>()
+                .eq("driver_id",id));
+        driverViewInfo.setDriverCarInfoList(driverCarInfoList);
+        //查看收款账户信息
+        List<DriverPayeeInfo> driverPayeeInfoList = driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
+                .eq("driver_id",id));
+        driverViewInfo.setDriverPayeeInfoList(driverPayeeInfoList);
+        return driverViewInfo;
+    }
+
+    /**
+     * 删除司机信息
+     * @param id
+     */
+    @Override
+    public void deleteDriver(String id){
+        //删除司机信息
+        DriverViewInfo driverViewInfo = this.selectById(id);
+        this.deleteById(driverViewInfo.getId());
+        //删除货车信息
+        List<DriverCarInfo> driverCarInfoList = driverCarInfoService.selectList(new EntityWrapper<DriverCarInfo>()
+                .eq("driver_id",id));
+        if (!CollectionUtils.isEmpty(driverCarInfoList)){
+            for (DriverCarInfo driverCarInfo : driverCarInfoList){
+                driverCarInfoService.deleteById(driverCarInfo.getId());
+            }
+        }
+        //删除收款账户信息
+        List<DriverPayeeInfo> driverPayeeInfoList = driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
+                .eq("driver_id",id));
+        if (!CollectionUtils.isEmpty(driverPayeeInfoList)){
+            for (DriverPayeeInfo driverPayeeInfo : driverPayeeInfoList){
+                driverPayeeInfoService.deleteById(driverPayeeInfo.getId());
+            }
+        }
+    }
 }

+ 65 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/DriverViewInfoMapper.xml

@@ -1,5 +1,69 @@
 <?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.yh.saas.plugin.yiliangyiyun.mapper.DriverViewInfoMapper">
-
+    <!-- 获得司机总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(d.id)
+        FROM driver_view_info d
+        left join driver_car_info c on d.id=c.driver_id
+        left join driver_payee_info p on d.id=p.driver_id
+        WHERE
+        d.comp_id = #{compid}
+        and d.delete_flag = '0'
+        <if test="residentCityProvincial != null and residentCityProvincial != ''">
+            AND d.resident_city_provincial = #{residentCityProvincial}
+        </if>
+        <if test="residentCityMunicipal != null and residentCityMunicipal != ''">
+            AND d.resident_city_municipal = #{residentCityMunicipal}
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(d.driver_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(d.driver_phone) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(d.number_card) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(c.car_number) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+    </select>
+    <!-- 司机列表查询 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.DriverViewInfo">
+        SELECT
+        d.id,
+        d.driver_name as driverName,
+        d.number_card as numberCard,
+        d.driver_phone as driverPhone,
+        c.car_number as carNunber,
+        d.resident_city_provincial as residentCityProvincial,
+        d.resident_city_municipal as residentCityMunicipal,
+        c.car_model as carModel,
+        c.car_length as carLength,
+        d.address_url as addressUrl,
+        p.payee_name as payeeName,
+        p.payee_number_card as payeeNumberCard,
+        p.bank_deposit as bankDeposit,
+        p.bank_card as bankCard,
+        p.comp_name as compName,
+        FROM driver_view_info d
+        left join driver_car_info c on d.id=c.driver_id
+        left join driver_payee_info p on d.id=p.driver_id
+        WHERE
+        d.comp_id = #{compid}
+        and d.delete_flag = '0'
+        <if test="residentCityProvincial != null and residentCityProvincial != ''">
+            AND d.resident_city_provincial = #{residentCityProvincial}
+        </if>
+        <if test="residentCityMunicipal != null and residentCityMunicipal != ''">
+            AND d.resident_city_municipal = #{residentCityMunicipal}
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(d.driver_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(d.driver_phone) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(d.number_card) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(c.car_number) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        ORDER BY d.update_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>