作者 王勇

@Autowired更换成@Resource

... ... @@ -11,6 +11,8 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:公司信息 Controller
... ... @@ -21,7 +23,7 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("dispatch/companyInfo")
@RestController
public class CompanyInfoController {
@Autowired
@Resource
private CompanyInfoService companyInfoService;
@ApiOperation("分页查询,公司信息列表")
... ... @@ -54,6 +56,12 @@ public class CompanyInfoController {
return result;
}
/**
* 增加公司信息.
*
* @param companyInfo {@link CompanyInfo}
* @return
*/
@ApiOperation("增加,公司信息")
@PostMapping("/insertCompanyInfo")
public ResultJson insertCompanyInfo(@RequestBody CompanyInfo companyInfo) {
... ... @@ -69,6 +77,12 @@ public class CompanyInfoController {
return result;
}
/**
* 编辑公司信息
*
* @param companyInfo {@link CompanyInfo}
* @return
*/
@ApiOperation("编辑,公司信息")
@PutMapping("/updateCompanyInfo")
public ResultJson updateCompanyInfo(@RequestBody CompanyInfo companyInfo) {
... ... @@ -83,6 +97,12 @@ public class CompanyInfoController {
return result;
}
/**
* 删除公司信息
*
* @param companyInfo {@link CompanyInfo}
* @return
*/
@ApiOperation("删除,公司信息")
@DeleteMapping("/deleteCompanyInfo")
public ResultJson deleteCompanyInfo(@RequestBody CompanyInfo companyInfo) {
... ...
... ... @@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
... ... @@ -31,12 +32,18 @@ import static java.util.stream.Collectors.toList;
@RestController
public class DispatchController {
@Autowired
@Resource
private VehicleInfoService vehicleInfoService;
@Autowired
@Resource
private DispatchNoteService dispatchNoteService;
/**
* 我要调度车辆.
*
* @param req {@link DispatchNote}
* @return 成功返回已调度的车辆信息
*/
@ApiOperation(value = "我要调度车辆", notes = "我要调度车辆")
@PostMapping("/dispatch")
public ResultJson dispatch(@RequestBody DispatchNote req) {
... ... @@ -126,6 +133,12 @@ public class DispatchController {
return result;
}
/**
* 手动开启任务调度.
*
* @param req {@link DispatchNote}
* @return
*/
@ApiOperation(value = "开始工作", notes = "车辆被调度后,开始工作的时刻")
@PutMapping("/startTask")
public ResultJson startTask(@RequestBody DispatchNote req) {
... ... @@ -149,6 +162,12 @@ public class DispatchController {
return result;
}
/**
* 手动完成任务调度.
*
* @param req {@link DispatchNote}
* @return 成功完成任务
*/
@ApiOperation(value = "完成工作", notes = "车辆被调度后,完成工作的时刻")
@PutMapping("/completeTask")
public ResultJson completeTask(@RequestBody DispatchNote req) {
... ... @@ -186,7 +205,12 @@ public class DispatchController {
}
return result;
}
/**
* 取消调度车辆.
*
* @param req {@link DispatchNote}
* @return
*/
@ApiOperation(value = "取消调度车辆", notes = "判断了多种情况下,取消调度车辆")
@PutMapping("/cancel")
public ResultJson cancel(@RequestBody DispatchNote req) {
... ... @@ -208,7 +232,7 @@ public class DispatchController {
* 开始时间为null==>还没有开启调度任务
* 结束时间为null==>代表并没有完成任务
*/
if (req.getBeginTime() == null && req.getEndTime()==null) {
if (req.getBeginTime() == null && req.getEndTime() == null) {
/**
* 设置车辆状态,为空闲状态("1")
* 设置车辆,开始空闲时间
... ...
... ... @@ -16,6 +16,7 @@ import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
... ... @@ -29,11 +30,24 @@ import java.util.Date;
@RequestMapping("dispatch/dispatchNote")
@RestController
public class DispatchNoteController {
@Autowired
@Resource
private DispatchNoteService dispatchNoteService;
@Autowired
@Resource
private VehicleInfoService vehicleInfoService;
/**
* 分页查询调度记录列表.
*
* @param userName 用户名称
* @param userMobile 用户联系方式
* @param dispatchType 调度类型
* @param gmtCreate 创建时间
* @param endTime 完成时间
* @param status 记录状态
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return 成功返回查询记录列表
*/
@ApiOperation("分页查询,调度记录信息列表")
@GetMapping("/selectDispatchNoteList")
public ResultJson<PageInfo> selectDispatchNoteList(
... ... @@ -87,6 +101,12 @@ public class DispatchNoteController {
return result;
}
/**
* 删除调度记录.
*
* @param dispatchNote {@link DispatchNote}
* @return
*/
@ApiOperation("删除调度记录信息")
@DeleteMapping("/deleteDispatchNote")
public ResultJson<DispatchNote> deleteDispatchNote(@RequestBody DispatchNote dispatchNote) {
... ... @@ -121,6 +141,12 @@ public class DispatchNoteController {
return result;
}
/**
* 批量删除调度记录.
*
* @param ids 所要删除的id以','相连接的字符串
* @return ResultJson {@link ResultJson}
*/
@ApiOperation("批量删除调度记录")
@GetMapping("/batchRemove")
public ResultJson batchRemoveDispatchNote(String ids) {
... ... @@ -198,7 +224,12 @@ public class DispatchNoteController {
return result;
}
/**
* 编辑调度记录信息.
*
* @param dispatchNote {@link DispatchNote}
* @return
*/
@ApiOperation("编辑调度记录信息")
@PutMapping("/updateDispatchNote")
public ResultJson<DispatchNote> updateDispatchNote(@RequestBody DispatchNote dispatchNote) {
... ... @@ -216,6 +247,12 @@ public class DispatchNoteController {
return result;
}
/**
* 增加调度记录信息.
*
* @param dispatchNote {@link DispatchNote}
* @return
*/
@ApiOperation("增加调度记录信息")
@PostMapping("/insertDispatchNote")
public ResultJson<DispatchNote> insertDispatchNote(@RequestBody DispatchNote dispatchNote) {
... ...
... ... @@ -11,9 +11,11 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:
* Description:驾驶员信息管理.
* 时间:2020/4/26 14:04
*/
@CrossOrigin
... ... @@ -21,10 +23,20 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("dispatch/driverInfo")
@RestController
public class DriverInfoController {
@Autowired
@Resource
private DriverInfoService driverInfoService;
/**
* 分页查询,驾驶员信息.
*
* @param driverName 驾驶员姓名
* @param driverMobile 驾驶员联系方式
* @param driverCompany 驾驶员所属公司
* @param driverStatus 驾驶员状态
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return 成功返回查询列表
*/
@ApiOperation("获取驾驶员列表")
@GetMapping("/selectDriverInfoList")
public ResultJson<PageInfo> selectDriverInfoList(
... ... @@ -62,6 +74,12 @@ public class DriverInfoController {
return result;
}
/**
* 删除驾驶员信息.
*
* @param driverInfo {@link DriverInfo}
* @return
*/
@ApiOperation("删除驾驶员信息")
@DeleteMapping("/deleteDriverInfo")
public ResultJson deleteDriverInfo(@RequestBody DriverInfo driverInfo) {
... ... @@ -80,6 +98,12 @@ public class DriverInfoController {
return result;
}
/**
* 批量删除驾驶员信息.
*
* @param ids 所要删除的id以','相连接的字符串
* @return
*/
@ApiOperation("批量删除驾驶员信息")
@GetMapping("/batchRemove")
public ResultJson batchRemoveDriverInfo(String ids) {
... ... @@ -95,7 +119,12 @@ public class DriverInfoController {
return result;
}
/**
* 编辑驾驶员信息.
*
* @param driverInfo {@link DriverInfo}
* @return
*/
@ApiOperation("编辑驾驶员信息")
@PutMapping("/updateDriverInfo")
public ResultJson updateDriverInfo(@RequestBody DriverInfo driverInfo) {
... ... @@ -114,6 +143,12 @@ public class DriverInfoController {
return result;
}
/**
* 增加驾驶员信息.
*
* @param driverInfo {@link DriverInfo}
* @return
*/
@ApiOperation("增加驾驶员信息")
@PostMapping("/insertDriverInfo")
public ResultJson insertDriverInfo(@RequestBody DriverInfo driverInfo) {
... ...
... ... @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
... ... @@ -20,7 +21,7 @@ import javax.servlet.http.HttpServletRequest;
@RestController
public class GetUserController {
@Autowired
@Resource
private GetUserFegin getUserFegin;
@GetMapping("/user/getUser")
... ...
... ... @@ -9,13 +9,15 @@ 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.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
/**
* @author 子诚
* Description:
* Description:车辆信息管理.
* 时间:2020/4/24 17:03
*/
@CrossOrigin
... ... @@ -23,9 +25,20 @@ import java.util.Date;
@RequestMapping("dispatch/vehicleInfo")
@RestController
public class VehicleInfoController {
@Autowired
@Resource
private VehicleInfoService vehicleInfoService;
/**
* 分页获取车辆列表.
*
* @param vehicleStatus 车辆状态
* @param vehicleType 车辆类型
* @param licensePlateNumber 车牌号码
* @param vehicleCompany 车辆所属公司
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return 成功返回查询列表
*/
@ApiOperation("获取车辆列表")
@GetMapping("/selectVehicleInfoList")
public ResultJson<PageInfo> selectVehicleInfoList(
... ... @@ -65,31 +78,42 @@ public class VehicleInfoController {
}
/**
* 增加
* 添加车辆信息.
*
* @param vehicleInfo {@link VehicleInfo}
* @return
*/
@ApiOperation("添加车辆信息")
@PostMapping("/insertVehicleInfo")
public ResultJson insertVehicleInfo(@RequestBody VehicleInfo vehicleInfo) {
ResultJson result = new ResultJson<>();
//设置车辆id,(uuid)
vehicleInfo.setId(GetUUID.getuuid());
//设置车辆状态,为空闲状态
vehicleInfo.setVehicleStatus("1");
//设置车辆开始空闲时间
vehicleInfo.setFreetime(new Date());
int num = vehicleInfoService.insertSelective(vehicleInfo);
if (num > 0) {
result.setCode("200");
result.setMsg("添加车辆信息,成功");
} else {
result.setCode("400");
result.setMsg("添加车辆信息,失败");
String message = validateVehicle(vehicleInfo);
//验证通过
if (message == null) {
ResultJson result = new ResultJson<>();
//设置车辆id,(uuid)
vehicleInfo.setId(GetUUID.getuuid());
//设置车辆状态,为空闲状态
vehicleInfo.setVehicleStatus("1");
//设置车辆开始空闲时间
vehicleInfo.setFreetime(new Date());
int num = vehicleInfoService.insertSelective(vehicleInfo);
if (num > 0) {
result.setCode("200");
result.setMsg("添加车辆信息,成功");
} else {
result.setCode("400");
result.setMsg("添加车辆信息,失败");
}
return result;
}
return result;
return new ResultJson("406", message != null ? message : "添加车辆信息,失败!");
}
/**
* 修改
* 修改车辆信息.
*
* @param vehicleInfo {@link VehicleInfo}
* @return
*/
@ApiOperation("修改车辆信息")
@PutMapping("/updateVehicleInfo")
... ... @@ -106,7 +130,12 @@ public class VehicleInfoController {
return result;
}
/**
* 删除车辆信息.
*
* @param vehicleInfo {@link VehicleInfo}
* @return
*/
@ApiOperation("删除车辆信息")
@DeleteMapping("/deleteVehicleInfo")
public ResultJson deleteVehicleInfo(@RequestBody VehicleInfo vehicleInfo) {
... ... @@ -122,6 +151,12 @@ public class VehicleInfoController {
return result;
}
/**
* 批量删除车辆信息.
*
* @param ids 所要删除的id以','相连接的字符串
* @return
*/
@ApiOperation("批量删除车辆信息")
@GetMapping("/batchRemove")
public ResultJson batchRemoveVehicleInfo(String ids) {
... ... @@ -136,4 +171,18 @@ public class VehicleInfoController {
}
return result;
}
/**
* 验证新增车辆信息
*
* @param vehicleInfo {@link VehicleInfo}
* @return 错误信息
*/
private String validateVehicle(VehicleInfo vehicleInfo) {
VehicleInfo info = vehicleInfoService.selectByLPN(vehicleInfo.getLicensePlateNumber());
if (info != null) {
return "车牌号已存在,请谨慎输入";
}
return null;
}
}
... ...
... ... @@ -12,7 +12,7 @@ import org.springframework.format.annotation.DateTimeFormat;
/**
* @author 子诚
* Description:
* Description:调度记录实体类
* 时间:2020/4/22 15:32
*/
... ...
... ... @@ -19,7 +19,7 @@ public interface GetUserFegin {
/**
* 根据用户名获取到 CLOUD-USER-CENTER 服务中的用户的信息
*
* @param userName
* @param userName 用户名称
* @return
*/
@GetMapping("/user/list")
... ...
... ... @@ -9,12 +9,18 @@ import org.springframework.web.client.RestTemplate;
/**
* @author 子诚
* Description:
* Description:获取用户信息,熔断器
* 时间:2020/5/8 19:06
*/
@Service
public class GetUserFeginHystrix implements GetUserFegin {
/**
*
*
* @param userName 用户名称
* @param token 令牌
* @return
*/
@Override
public ResultJson<PageInfo> list(String userName, String token) {
System.out.println("与 CLOUD-USER-CENTER 服务断开连接");
... ...
... ... @@ -7,7 +7,7 @@ import java.util.List;
/**
* @author 子诚
* Description:
* Description:返回结果封装类
* 时间:2020/4/24 10:06
*/
@Data
... ...