作者 王勇

匹配前端,修改代码

... ... @@ -138,6 +138,11 @@
<artifactId>fastjson</artifactId>
<version>1.2.49</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.5</version>
</dependency>
<!-- tools end -->
<!-- test start -->
... ...
... ... @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
* Description:公司信息 Controller
* 时间:2020/4/28 15:41
*/
@CrossOrigin
@Api(value = "公司信息,业务", tags = "业务管理——公司信息")
@RequestMapping("dispatch/companyInfo")
@RestController
... ...
package com.sunyo.wlpt.dispatch.controller;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.dispatch.domain.DispatchNote;
import com.sunyo.wlpt.dispatch.domain.VehicleInfo;
import com.sunyo.wlpt.dispatch.response.ResultJson;
... ... @@ -24,6 +25,7 @@ import static java.util.stream.Collectors.toList;
* Description:调度车辆
* 时间:2020/4/21 16:44
*/
@CrossOrigin
@Api(value = "调度车辆业务", tags = "业务——我要调度车辆")
@RequestMapping("dispatch")
@RestController
... ... @@ -126,39 +128,59 @@ public class DispatchController {
@ApiOperation(value = "开始工作", notes = "车辆被调度后,开始工作的时刻")
@PutMapping("/startTask")
public void startTask(@RequestBody DispatchNote req) {
public ResultJson startTask(@RequestBody DispatchNote req) {
ResultJson result = new ResultJson();
/**
* 设置调度记录表,开始任务时间(由客户端传递过来,比较精确)
*/
req.setBeginTime(new Date());
dispatchNoteService.updateByPrimaryKeySelective(req);
if (req.getBeginTime() == null) {
req.setBeginTime(new Date());
int num = dispatchNoteService.updateByPrimaryKeySelective(req);
if (num > 0) {
result.setMsg("手动开启调度任务,成功");
} else {
result.setCode("400");
result.setMsg("手动开启调度任务,失败");
}
}
return result;
}
@ApiOperation(value = "完成工作", notes = "车辆被调度后,完成工作的时刻")
@PutMapping("/completeTask")
public void completeTask(@RequestBody DispatchNote req) {
public ResultJson completeTask(@RequestBody DispatchNote req) {
ResultJson result = new ResultJson();
/**
* 车辆信息表,修改
* 1.设置车辆信息表,为空闲状态(1)
* 2.设置车辆信息表开始空闲时间(任务的完成时间)
*/
// 根据记录表中的车牌号,获取到车辆信息
String licensePlateNumber = req.getLicensePlateNumber();
VehicleInfo vehicleInfo = vehicleInfoService.selectByLPN(licensePlateNumber);
//设置车辆信息表,为空闲状态(1)
vehicleInfo.setVehicleStatus("1");
//设置车辆信息表,开始空闲时间
Date nowTime = new Date();
vehicleInfo.setFreetime(nowTime);
vehicleInfoService.updateByPrimaryKeySelective(vehicleInfo);
/**
* 调度记录表,修改
* 1.设置调度记录,完成时间
* 2.设置调度记录,完成状态(1)
*/
req.setStatus("1");
req.setEndTime(nowTime);
dispatchNoteService.updateByPrimaryKeySelective(req);
if (req.getEndTime() == null) {
// 根据记录表中的车牌号,获取到车辆信息
String licensePlateNumber = req.getLicensePlateNumber();
VehicleInfo vehicleInfo = vehicleInfoService.selectByLPN(licensePlateNumber);
//设置车辆信息表,为空闲状态(1)
vehicleInfo.setVehicleStatus("1");
//设置车辆信息表,开始空闲时间
Date nowTime = new Date();
vehicleInfo.setFreetime(nowTime);
vehicleInfoService.updateByPrimaryKeySelective(vehicleInfo);
/**
* 调度记录表,修改
* 1.设置调度记录,完成时间
* 2.设置调度记录,完成状态(1)
*/
req.setStatus("1");
req.setEndTime(nowTime);
int num = dispatchNoteService.updateByPrimaryKeySelective(req);
if (num > 0) {
result.setMsg("手动完成调度任务,成功");
} else {
result.setCode("400");
result.setMsg("手动完成调度任务,失败");
}
}
return result;
}
@ApiOperation(value = "取消调度车辆", notes = "判断了多种情况下,取消调度车辆")
... ...
... ... @@ -6,13 +6,17 @@ import com.sunyo.wlpt.dispatch.domain.VehicleInfo;
import com.sunyo.wlpt.dispatch.response.ResultJson;
import com.sunyo.wlpt.dispatch.service.DispatchNoteService;
import com.sunyo.wlpt.dispatch.service.VehicleInfoService;
import com.sunyo.wlpt.dispatch.utils.DateTimeUtils;
import com.sunyo.wlpt.dispatch.utils.GetUUID;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
... ... @@ -20,6 +24,7 @@ import java.util.Date;
* Description:
* 时间:2020/4/24 20:30
*/
@CrossOrigin
@Api(value = "调度记录信息,业务", tags = "业务管理——车辆调度记录信息")
@RequestMapping("dispatch/dispatchNote")
@RestController
... ... @@ -38,7 +43,7 @@ public class DispatchNoteController {
@RequestParam(value = "userMobile", required = false) String userMobile,
@ApiParam(name = "dispatchType", value = "业务类型", required = false)
@RequestParam(value = "dispatchType", required = false) String dispatchType,
@ApiParam(name = "gmtCreate", value = "创建时间", required = false)
@ApiParam(name = "gmtCreate", value = "任务创建时间", required = false)
@RequestParam(value = "gmtCreate", required = false) Date gmtCreate,
@ApiParam(name = "endTime", value = "任务结束时间", required = false)
@RequestParam(value = "endTime", required = false) Date endTime,
... ... @@ -58,31 +63,20 @@ public class DispatchNoteController {
* 1.用户姓名;2.用户电话;3.创建时间;4.完成时间
* 5.业务类型;6.记录状态
*/
if ("".equals(userName)) {
//获取参数,用户姓名
dispatchNote.setUserName(userName);
}
if ("".equals(userMobile)) {
//获取参数,用户联系方式
dispatchNote.setUserMobile(userMobile);
}
if ("".equals(dispatchType)) {
//获取参数,业务类型
dispatchNote.setDispatchType(dispatchType);
}
if (null != gmtCreate) {
//获取参数,创建时间
dispatchNote.setGmtCreate(gmtCreate);
}
if ("".equals(status)) {
//获取参数,记录表状态
dispatchNote.setStatus(status);
}
if (null != endTime) {
//获取参数,任务结束(完成)时间
dispatchNote.setEndTime(endTime);
}
//获取参数,用户姓名
dispatchNote.setUserName(userName);
//获取参数,用户联系方式
dispatchNote.setUserMobile(userMobile);
//获取参数,业务类型
dispatchNote.setDispatchType(dispatchType);
System.out.println(gmtCreate);
//获取参数,创建时间
dispatchNote.setGmtCreate(gmtCreate);
//获取参数,记录表状态
dispatchNote.setStatus(status);
//获取参数,任务结束(完成)时间
dispatchNote.setEndTime(endTime);
System.out.println(dispatchNote);
PageInfo pageInfo = dispatchNoteService.selectDispatchNoteList(dispatchNote, pageNum, pageSize);
if (pageInfo.getTotal() > 0) {
result.setData(pageInfo);
... ... @@ -159,4 +153,10 @@ public class DispatchNoteController {
}
return result;
}
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
}
... ...
... ... @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
* Description:
* 时间:2020/4/26 14:04
*/
@CrossOrigin
@Api(value = "驾驶员信息管理", tags = "业务管理——驾驶员信息管理")
@RequestMapping("dispatch/driverInfo")
@RestController
... ... @@ -33,7 +34,7 @@ public class DriverInfoController {
@RequestParam(value = "driverMobile", required = false) String driverMobile,
@ApiParam(name = "driverCompany", value = "驾驶员所属公司", required = false)
@RequestParam(value = "driverCompany", required = false) String driverCompany,
@ApiParam(name = "driverStatus", value = "驾驶员状态:驾驶员状态:1.空闲状态;2.执行状态;3.轮休状态;.请假状态", required = false)
@ApiParam(name = "driverStatus", value = "驾驶员状态:驾驶员状态:1.空闲状态;2.执行状态;3.轮休状态;4.请假状态", required = false)
@RequestParam(value = "driverStatus", required = false) String driverStatus,
@ApiParam(name = "pageNum", value = "第几页,默认为第一页", required = false)
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
... ... @@ -41,22 +42,14 @@ public class DriverInfoController {
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
ResultJson<PageInfo> result = new ResultJson<>();
DriverInfo driverInfo = new DriverInfo();
if ("".equals(driverName)) {
//获取参数,驾驶员姓名
driverInfo.setDriverName(driverName);
}
if ("".equals(driverMobile)) {
//获取参数,驾驶员联系方式
driverInfo.setDriverMobile(driverMobile);
}
if ("".equals(driverCompany)) {
//获取参数,驾驶员所属公司
driverInfo.setDriverCompany(driverCompany);
}
if ("".equals(driverStatus)) {
//获取参数,驾驶员状态
driverInfo.setDriverStatus(driverStatus);
}
PageInfo pageInfo = driverInfoService.selectDriverInfoList(driverInfo, pageNum, pageSize);
if (pageInfo.getTotal() > 0) {
result.setData(pageInfo);
... ...
... ... @@ -18,6 +18,7 @@ import java.util.Date;
* Description:
* 时间:2020/4/24 17:03
*/
@CrossOrigin
@Api(value = "车辆信息", tags = "业务管理——车辆信息管理")
@RequestMapping("dispatch/vehicleInfo")
@RestController
... ... @@ -43,22 +44,14 @@ public class VehicleInfoController {
ResultJson<PageInfo> result = new ResultJson<>();
VehicleInfo vehicleInfo = new VehicleInfo();
if ("".equals(vehicleStatus)) {
//获取参数,车辆状态
vehicleInfo.setVehicleStatus(vehicleStatus);
}
if ("".equals(vehicleType)) {
//获取参数,车辆类型
vehicleInfo.setVehicleType(vehicleType);
}
if ("".equals(licensePlateNumber)) {
//获取参数,车牌号
vehicleInfo.setLicensePlateNumber(licensePlateNumber);
}
if ("".equals(vehicleCompany)) {
//获取参数,公司名
vehicleInfo.setVehicleCompany(vehicleCompany);
}
PageInfo pageInfo = vehicleInfoService.selectVehicleInfoList(vehicleInfo, pageNum, pageSize);
if (pageInfo.getTotal() > 0) {
result.setData(pageInfo);
... ...
... ... @@ -78,7 +78,6 @@ public class DispatchNote implements Serializable {
/**
* 调度记录(任务)创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate;
... ... @@ -98,7 +97,6 @@ public class DispatchNote implements Serializable {
/**
* 任务完成时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
... ...
... ... @@ -49,7 +49,7 @@ public class DriverInfo implements Serializable {
private String jobNumber;
/**
* 驾驶员职位:队长,班长,副班长,员工
* 驾驶员职位:队长,班长,副班长,员工
*/
private String driverPosition;
... ...
... ... @@ -16,10 +16,10 @@ public interface DispatchNoteMapper {
/**
* 分页查询,调度记录列表
*
* @param record
* @param dispatchNote
* @return
*/
List<DispatchNote> selectVehicleInfoList(DispatchNote record);
List<DispatchNote> selectVehicleInfoList(@Param("dispatchNote") DispatchNote dispatchNote);
int deleteByPrimaryKey(String id);
... ...
package com.sunyo.wlpt.dispatch.utils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/6 21:16
*/
public class DateTimeUtils {
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
private static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 获取年月日,date类型
* @param s
* @return
*/
public static Date getDate(String s){
Date time = null;
if(s == null){
return time;
}
try {
if (s.length()>0){
time = simpleDateFormat.parse(s);
}
}catch (Exception e){
e.printStackTrace();
}
return time;
}
/**
* 获取年月日,String类型
* @param date
* @return
*/
public static String getDateString(Date date){
return simpleDateFormat.format(date);
}
/**
* 获取当前年月日时分秒,String类型
* @param date
* @return
*/
public static String getDateTimeString(Date date){
return simpleDateTimeFormat.format(date);
}
public static List getSeverDay(){
List<Date> dates = new ArrayList<>();
Date date = new Date();
dates.add(date);
for (int i=1;i<7;i++) {
long time = date.getTime() - i*24 * 3600 * 1000L;
Date preTime = new Date(time);
dates.add(preTime);
}
return dates;
}
}
... ...
... ... @@ -7,6 +7,10 @@ spring:
name: dispatch-system
profiles:
active: dev
jackson:
default-property-inclusion: ALWAYS
time-zone: GMT+8
date-format: yyyy-MM-dd
security:
user:
name: admin
... ... @@ -68,6 +72,8 @@ mybatis:
# 日志打印
logging:
config: config/logback-dev.xml
level:
com.sunyo.wlpt.dispatch.mapper: debug
logback:
appname: dispatch-system
logdir: ./log
... ...
... ... @@ -33,34 +33,32 @@
select
<include refid="Base_Column_List"/>
from dispatch_note
<where>
<trim suffixOverrides=",">
<!-- 用户姓名 -->
<if test="userName != null and userName != ''">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<!-- 用户联系方式 -->
<if test="userMobile != null and userMobile != ''">
AND user_mobile = #{userMobile,jdbcType=VARCHAR},
</if>
<!-- 业务类型 -->
<if test="dispatchType != null and dispatchType != ''">
AND dispatch_type = #{dispatchType,jdbcType=VARCHAR},
</if>
<!-- 记录表状态 -->
<if test="status != null and status != ''">
AND status = #{status,jdbcType=VARCHAR},
</if>
<!-- 任务创建时间 -->
<if test="gmtCreate != null">
AND DATE_FORMAT(gmt_create,'%Y-%m-%d') = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<!-- 任务(结束)完成时间 -->
<if test="endTime != null">
AND DATE_FORMAT(end_time,'%Y-%m-%d') = #{endTime,jdbcType=TIMESTAMP}
</if>
</trim>
</where>
where 1=1
<!-- 用户姓名 -->
<if test="dispatchNote.userName != null and dispatchNote.userName != ''">
AND user_name = #{dispatchNote.userName,jdbcType=VARCHAR}
</if>
<!-- 用户联系方式 -->
<if test="dispatchNote.userMobile != null and dispatchNote.userMobile != ''">
AND user_mobile = #{dispatchNote.userMobile,jdbcType=VARCHAR}
</if>
<!-- 业务类型 -->
<if test="dispatchNote.dispatchType != null and dispatchNote.dispatchType != ''">
AND dispatch_type = #{dispatchNote.dispatchType,jdbcType=VARCHAR}
</if>
<!-- 记录表状态 -->
<if test="dispatchNote.status != null and dispatchNote.status != ''">
AND status = #{dispatchNote.status,jdbcType=VARCHAR}
</if>
<!-- 任务创建时间 -->
<if test="dispatchNote.gmtCreate != null">
AND DATE_FORMAT(gmt_create,'%Y-%m-%d') = #{dispatchNote.gmtCreate,jdbcType=DATE}
</if>
<!-- 任务(结束)完成时间 -->
<if test="dispatchNote.endTime != null">
AND DATE_FORMAT(end_time,'%Y-%m-%d') = #{dispatchNote.endTime,jdbcType=DATE}
</if>
order by gmt_create desc
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
... ...
... ... @@ -466,25 +466,22 @@
<include refid="Base_Column_List"/>
from driver_info
<where>
<trim suffixOverrides=",">
<!-- 驾驶员,姓名 -->
<if test="driverName != null and driverName != ''">
driver_name = #{driverName,jdbcType=VARCHAR},
driver_name = #{driverName,jdbcType=VARCHAR}
</if>
<!-- 驾驶员,联系方式 -->
<if test="driverMobile != null and driverMobile != ''">
AND driver_mobile = #{driverMobile,jdbcType=VARCHAR},
AND driver_mobile = #{driverMobile,jdbcType=VARCHAR}
</if>
<!-- 驾驶员,所属公司 -->
<if test="driverCompany != null and driverCompany != ''">
AND driver_company = #{driverCompany,jdbcType=VARCHAR},
AND driver_company = #{driverCompany,jdbcType=VARCHAR}
</if>
<!-- 驾驶员,状态 -->
<if test="driverStatus != null and driverStatus != ''">
AND driver_status = #{driverStatus,jdbcType=VARCHAR}
</if>
</trim>
</where>
</select>
</mapper>
... ...
... ... @@ -567,24 +567,23 @@
<include refid="Base_Column_List"/>
from vehicle_info
<where>
<trim suffixOverrides=",">
<!-- 车牌号 -->
<if test="licensePlateNumber != null and licensePlateNumber !=''">
license_plate_number = #{licensePlateNumber,jdbcType=VARCHAR},
license_plate_number = #{licensePlateNumber,jdbcType=VARCHAR}
</if>
<!-- 车辆类型 -->
<if test="vehicleType != null and vehicleType != ''">
AND vehicle_type = #{vehicleType,jdbcType=VARCHAR},
AND vehicle_type = #{vehicleType,jdbcType=VARCHAR}
</if>
<!-- 车辆状态 -->
<if test="vehicleStatus != null and vehicleStatus != ''">
AND vehicle_status = #{vehicleStatus,jdbcType=VARCHAR},
AND vehicle_status = #{vehicleStatus,jdbcType=VARCHAR}
</if>
<!-- 所属公司 -->
<if test="vehicleCompany != null and vehicleCompany != ''">
AND vehicle_company = #{vehicleCompany,jdbcType=VARCHAR}
</if>
</trim>
</where>
order by freetime
</select>
</mapper>
... ...