Commit 7bbb7553 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents 7e50dd22 6369eeb8
......@@ -8,4 +8,4 @@ target/
.classpath
ace-modules/ace-tool/src/main/resources/application-dev.yml
src/main/test/**
logs/**
/logs
......@@ -56,6 +56,15 @@ public class AuthController {
return new ObjectRestResponse<String>().data(token);
}
@RequestMapping(value = "token/small", method = RequestMethod.POST)
public ObjectRestResponse<String> createAuthenticationTokenSmall(
@RequestBody JwtAuthenticationRequest authenticationRequest,
HttpServletRequest request) throws Exception {
log.info(authenticationRequest.getUsername()+" require logging...");
// keliii 分请求类型处理token
return authService.loginSmall(authenticationRequest);
}
@RequestMapping(value = "refresh", method = RequestMethod.GET)
public ObjectRestResponse<String> refreshAndGetAuthenticationToken(
HttpServletRequest request) throws Exception {
......
......@@ -20,6 +20,9 @@ public interface IUserService {
@RequestMapping(value = "/api/user/validate", method = RequestMethod.POST)
public UserInfo validate(@RequestBody JwtAuthenticationRequest authenticationRequest);
@RequestMapping(value = "/api/user/validate/small", method = RequestMethod.POST)
public UserInfo validateSmall(@RequestBody JwtAuthenticationRequest authenticationRequest);
@RequestMapping(value = "/api/app/user/validate", method = RequestMethod.POST)
AppUserInfo AppValidate(@RequestBody JwtAuthenticationRequest authenticationRequest);
......
......@@ -3,10 +3,12 @@ package com.github.wxiaoqi.security.auth.service;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.web.bind.annotation.RequestParam;
public interface AuthService {
String login(JwtAuthenticationRequest authenticationRequest) throws Exception;
ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception;
String refresh(String oldToken) throws Exception;
void validate(String token) throws Exception;
JSONObject sendsms(String username, Integer type) throws Exception;
......
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.auth.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.api.vo.user.AppUserInfo;
import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.common.util.jwt.JWTInfo;
import com.github.wxiaoqi.security.auth.feign.IUserService;
import com.github.wxiaoqi.security.auth.service.AuthService;
......@@ -9,6 +10,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
......@@ -36,6 +38,20 @@ public class AppAuthServiceImpl implements AuthService {
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override
public ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception {
UserInfo info = userService.validateSmall(authenticationRequest);
if (info!=null&&!StringUtils.isEmpty(info.getId())) {
info.setPassword(null);
JSONObject object=new JSONObject();
String token=jwtTokenUtil.generateToken(new JWTInfo(info.getUsername(), info.getId() + "", info.getName()));
object.put("token",token);
object.put("info",info);
return ObjectRestResponse.succ(object);
}
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override
public String refresh(String oldToken) throws Exception {
return jwtTokenUtil.generateToken(jwtTokenUtil.getInfoFromToken(oldToken));
......
......@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
......@@ -36,6 +37,20 @@ public class AuthServiceImpl implements AuthService {
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override
public ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception {
UserInfo info = userService.validateSmall(authenticationRequest);
if (info!=null&&!StringUtils.isEmpty(info.getId())) {
info.setPassword(null);
JSONObject object=new JSONObject();
String token=jwtTokenUtil.generateToken(new JWTInfo(info.getUsername(), info.getId() + "", info.getName()));
object.put("token",token);
object.put("info",info);
return ObjectRestResponse.succ(object);
}
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override
public void validate(String token) throws Exception {
jwtTokenUtil.getInfoFromToken(token);
......
......@@ -40,6 +40,11 @@ public class UserRest {
public @ResponseBody UserInfo validate(@RequestBody Map<String,String> body){
return permissionService.validate(body.get("username"),body.get("password"));
}
@RequestMapping(value = "/user/validate/small", method = RequestMethod.POST)
public @ResponseBody UserInfo validateSmall(@RequestBody Map<String,String> body){
return permissionService.validateSmall(body.get("username"),body.get("password"));
}
......
......@@ -14,6 +14,8 @@ import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.constant.CommonConstants;
import com.github.wxiaoqi.security.common.util.TreeUtil;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,6 +40,9 @@ public class PermissionService {
private ElementBiz elementBiz;
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private VehicleFeign vehicleFeign;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
......@@ -60,6 +65,22 @@ public class PermissionService {
}
return info;
}
//小程序登录
public UserInfo validateSmall(String username,String password){
UserInfo info = new UserInfo();
User user = userBiz.getUserByUsername(username);
if (user!=null){
if (encoder.matches(password, user.getPassword())) {
BeanUtils.copyProperties(user, info);
info.setId(user.getId().toString());
List<BranchCompany> list=vehicleFeign.companyAll(2,user.getDataCompany(),null);
if (list.size()>0){
info.setDataCompanyName(list.get(0).getName());
}
}
}
return info;
}
public List<PermissionInfo> getAllPermission() {
List<Menu> menus = menuBiz.selectListAll();
......
......@@ -18,6 +18,7 @@ public class UserInfo implements Serializable{
private Integer dataAll;
private String dataZone;
private String dataCompany;
private String dataCompanyName;
public Date getUpdTime() {
return updTime;
......@@ -92,4 +93,13 @@ public class UserInfo implements Serializable{
public void setDataCompany(String dataCompany) {
this.dataCompany = dataCompany;
}
public String getDataCompanyName() {
return dataCompanyName;
}
public void setDataCompanyName(String dataCompanyName) {
this.dataCompanyName = dataCompanyName;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -370,8 +370,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
}
}
public DailyOrderStatistics getTotalOrder() {
return mapper.getTotalOrder();
public boolean getTotalOrder() {
mapper.getTotalOrder();
return false;
}
// @Scheduled(cron = "0 0 2 * * ? ")
......
......@@ -24,7 +24,7 @@ public class BaseOrderStatisticsJobHandler extends IJobHandler {
@Override
public ReturnT<String> execute(String s) throws Exception {
try {
DailyOrderStatistics dailyOrderStatistics= baseOrderBiz.getTotalOrder();
baseOrderBiz.getTotalOrder();
ReturnT returnT = new ReturnT(){{
setCode(100);
......
......@@ -41,6 +41,7 @@ public class CertificationController {
private UserFeign userFeign;
@Qualifier("applicationTaskExecutor")
@Autowired
private TaskExecutor executor;
......@@ -102,12 +103,13 @@ public class CertificationController {
if (type!=null&&type==0){
ObjectRestResponse<Integer> result = certificationService.certificate(idInformation);
if (result.getRel()) {
executor.execute(new Runnable() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
setIntegral(appUserDTO.getUserid(),result.getData());
}
});
thread.start();
}
return result ;
}
......
......@@ -36,8 +36,6 @@ public class TrafficViolationsService {
@Autowired
private LicensePlateTypeBiz licensePlateTypeBiz;
@Autowired
private TaskExecutor taskExecutor;
@Value("${ALIYUN.CODE}")
private String CODE;
......@@ -191,12 +189,15 @@ public class TrafficViolationsService {
licensePlateTypes = saveLicensePlateType();
List<LicensePlateType> finalLicensePlateTypes = licensePlateTypes;
taskExecutor.execute(new Runnable() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
insertLicensePlateType(finalLicensePlateTypes);
}
});
} );
thread.start();
}
return licensePlateTypes;
}
......
......@@ -86,4 +86,8 @@ public class VehicleDepartureLog {
* 预约记录id
*/
Integer bookRecordId;
String illegalPic;
Integer illegalAmount;
}
package com.xxfc.platform.vehicle.pojo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import java.util.List;
@Data
public class VehicleBookRecordQueryVo {
public class VehicleBookRecordQueryVo extends PageParam {
/**
* 车辆编号,0-没有
......@@ -38,19 +41,16 @@ public class VehicleBookRecordQueryVo {
*/
private Integer retCompany;
private Integer page;
private Integer limit;
/**
* 预定类型
*/
private Integer bookType;
private Integer zoneId;
private Integer companyId;
private List<String> zoneIds;
private String[] zoneIds;
private String[] companyIds;
private List<String> companyIds;
private String upkeepIds;
private Integer userCompany;
}
\ No newline at end of file
......@@ -28,4 +28,8 @@ public class VehicleBookRecordVo extends VehicleBookRecord {
private VehicleDepartureLogVo vehicleDepartureLogVo;
private String numberPlate;
private Integer liftStatus;
private Integer retStatus;
}
......@@ -26,4 +26,9 @@ public class VehicleDepartureLogVo {
String departureDay;
String departureName;
String arrivalName;
Integer bookRecordId;
String illegalPic;
Integer illegalAmount;
}
package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -404,7 +405,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
}
//检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -418,21 +419,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
VehicleBookRecord vehicleBookRecord = null;
if(bookVehicleVo.getVehicleBookRecordId() == null) {
vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId());
vehicleBookRecord.setBookType(bookVehicleVo.getBookType());
BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName);
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
vehicleBookRecord.setVehicleUsername(bookVehicleVo.getVehicleUsername());
vehicleBookRecord.setVehicleUserPhone(bookVehicleVo.getVehicleUserPhone());
vehicleBookRecord.setUpkeepIds(bookVehicleVo.getUpkeepIds());
vehicleBookRecordBiz.save(vehicleBookRecord);
} else {
vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId());
......@@ -497,7 +489,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
}
//检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -511,21 +503,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
VehicleBookRecord vehicleBookRecord = null;
if(bookVehicleVo.getVehicleBookRecordId() == null) {
vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId());
vehicleBookRecord.setBookType(bookVehicleVo.getBookType());
BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode());
vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName);
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
vehicleBookRecord.setVehicleUsername(bookVehicleVo.getVehicleUsername());
vehicleBookRecord.setVehicleUserPhone(bookVehicleVo.getVehicleUserPhone());
vehicleBookRecord.setUpkeepIds(bookVehicleVo.getUpkeepIds());
vehicleBookRecordBiz.save(vehicleBookRecord);
} else {
vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId());
......@@ -747,7 +730,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -826,7 +809,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
for( DateTime curDate = startDay;curDate.compareTo(endDay)<=0;curDate=curDate.plusDays(1)){
String curDateStr = curDate.toString(DEFAULT_DATE_TIME_FORMATTER);
if(curDateStr.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER))<0){
throw new CustomIllegalParamException("you can only unbook from today");
throw new CustomIllegalParamException("只可以取消当前时间之后的车辆");
}
String curYearMonth = curDate.toString(YEARMONTH_DATE_TIME_FORMATTER);
if(!yearMonthAndDate.containsKey(curYearMonth)){
......@@ -837,7 +820,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
}
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
}
}
......@@ -856,7 +839,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -877,7 +860,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
params.put("yearMonth",yearMonth);
//加入更新条件
if(CollectionUtils.isEmpty(unbookDates)){
throw new CustomIllegalParamException(" there are no day to unbook ");
throw new CustomIllegalParamException(" 车辆不可预定");
}
Map<String,List<String>> yearMonthAndDate = new HashMap<>();
yearMonthAndDate.put(yearMonth,unbookDates);
......@@ -904,7 +887,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
public void fillBookedDateSearchParam(Map<String, Object> params,
Map<String,List<String>> yearMonthAndDate,Map<String,List<String>> yearMonthAndDateNotBooked){
if(MapUtils.isEmpty(yearMonthAndDate)&&MapUtils.isEmpty(yearMonthAndDateNotBooked)){//没有预定信息查询条件
throw new CustomIllegalParamException(" at least apply one book info condition.");
throw new CustomIllegalParamException("没有预订信息!");
}
Map<String,Map<String,Integer>> yearMonthAndParam = new HashMap<>();
......@@ -949,7 +932,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
}
for (String dateStr:entry.getValue()) {//已预定作为条件,该位与1作与运算必定为1
if(bookedYearMonth.contains(dateStr)){
throw new CustomIllegalParamException(" 同一天既作为未预定查询条件又作为已预定查询条件");
throw new CustomIllegalParamException("同一天既作为未预定查询条件又作为已预定查询条件");
}
DateTime dateTime = DateTime.parse(dateStr, DEFAULT_DATE_TIME_FORMATTER);
//仅对应位为1的整形值
......@@ -1291,22 +1274,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
String zoneId = null;
if(StringUtils.isNotBlank(userDTO.getDataZone())) {
if(userDTO.getDataZone().contains(",")) {
zoneId = userDTO.getDataZone();
} else {
zoneId = userDTO.getDataZone() + ",";
}
} else {
zoneId = userDTO.getZoneId() + ",";
}
vehiclePlanDto.setZoneIds(zoneId.split(","));
String companyId = null;
if(StringUtils.isNotBlank(userDTO.getDataCompany())) {
if(userDTO.getDataCompany().contains(",")) {
companyId = userDTO.getDataCompany();
} else {
companyId = userDTO.getDataCompany() + ",";
}
} else {
companyId = userDTO.getCompanyId() + ",";
}
......
......@@ -37,6 +37,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -93,10 +95,13 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
public RestResponse<PageDataVO> getBookRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo) {
Integer pageNo = vehicleBookRecordQueryVo.getPage() == null ? 1 : vehicleBookRecordQueryVo.getPage();
Integer pageSize = vehicleBookRecordQueryVo.getLimit() == null ? 10 : vehicleBookRecordQueryVo.getLimit();
vehicleBookRecordQueryVo.setPage(pageNo);
vehicleBookRecordQueryVo.setLimit(pageSize);
UserDTO userDTO = adminInfoFeign.getAdminUserInfo();
if(userDTO == null) {
return RestResponse.codeAndMessage(235, "token失效");
}
vehicleBookRecordQueryVo.setUserCompany(userDTO.getCompanyId());
if(vehicleBookRecordQueryVo.getZoneId() == null) { //默认查出所有权限内的数据
if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
String zoneId = null;
......@@ -109,7 +114,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
} else {
zoneId = userDTO.getZoneId() + ",";
}
vehicleBookRecordQueryVo.setZoneIds(zoneId.split(","));
vehicleBookRecordQueryVo.setZoneIds(Arrays.asList(zoneId.split(",")));
String companyId = null;
if(StringUtils.isNotBlank(userDTO.getDataCompany())) {
if(userDTO.getDataCompany().contains(",")) {
......@@ -120,23 +125,29 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
} else {
companyId = userDTO.getCompanyId() + ",";
}
vehicleBookRecordQueryVo.setCompanyIds(companyId.split(","));
vehicleBookRecordQueryVo.setCompanyIds(Arrays.asList(companyId.split(",")));
}
} else {
vehicleBookRecordQueryVo.setZoneIds(Arrays.asList((vehicleBookRecordQueryVo.getZoneId() + ",").split(",")));
vehicleBookRecordQueryVo.setCompanyIds(Arrays.asList((vehicleBookRecordQueryVo.getLiftCompany() + ",").split(",")));
}
List<VehicleBookRecordVo> list = mapper.getBookRecord(vehicleBookRecordQueryVo);
PageHelper.startPage(pageNo,pageSize);
PageInfo<VehicleBookRecordVo> vehiclePageInfo = new PageInfo<>(list);
return RestResponse.suc(PageDataVO.pageInfo(vehiclePageInfo));
vehicleBookRecordQueryVo.getCompanyIds().add(vehicleBookRecordQueryVo.getCompanyId() + "");
Query query = new Query(vehicleBookRecordQueryVo);
PageDataVO<VehicleBookRecordVo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getBookRecordInfo(query.getSuper()));
return RestResponse.suc(pageDataVO);
}
public RestResponse<PageDataVO> getBookRecordInfo(VehicleBookRecordQueryVo vehicleBookRecordQueryVo) {
Integer pageNo = vehicleBookRecordQueryVo.getPage() == null ? 1 : vehicleBookRecordQueryVo.getPage();
Integer pageSize = vehicleBookRecordQueryVo.getLimit() == null ? 10 : vehicleBookRecordQueryVo.getLimit();
vehicleBookRecordQueryVo.setPage(pageNo);
vehicleBookRecordQueryVo.setLimit(pageSize);
UserDTO userDTO = adminInfoFeign.getAdminUserInfo();
if(userDTO == null) {
return RestResponse.codeAndMessage(235, "token失效");
}
vehicleBookRecordQueryVo.setUserCompany(userDTO.getCompanyId());
if(vehicleBookRecordQueryVo.getZoneId() == null) { //默认查出所有权限内的数据
if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
String zoneId = null;
......@@ -149,7 +160,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
} else {
zoneId = userDTO.getZoneId() + ",";
}
vehicleBookRecordQueryVo.setZoneIds(zoneId.split(","));
vehicleBookRecordQueryVo.setZoneIds(Arrays.asList(zoneId.split(",")));
String companyId = null;
if(StringUtils.isNotBlank(userDTO.getDataCompany())) {
if(userDTO.getDataCompany().contains(",")) {
......@@ -160,13 +171,21 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
} else {
companyId = userDTO.getCompanyId() + ",";
}
vehicleBookRecordQueryVo.setCompanyIds(companyId.split(","));
vehicleBookRecordQueryVo.setCompanyIds(Arrays.asList(companyId.split(",")));
}
} else {
vehicleBookRecordQueryVo.setZoneIds(Arrays.asList((vehicleBookRecordQueryVo.getZoneId() + ",").split(",")));
vehicleBookRecordQueryVo.setCompanyIds(Arrays.asList((vehicleBookRecordQueryVo.getLiftCompany() + ",").split(",")));
}
if(vehicleBookRecordQueryVo.getCompanyId() != null) {
if(vehicleBookRecordQueryVo.getCompanyIds() == null) {
vehicleBookRecordQueryVo.setCompanyIds(new ArrayList<>());
}
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(vehicleBookRecordQueryVo);
PageHelper.startPage(pageNo,pageSize);
PageInfo<VehicleBookRecordVo> vehiclePageInfo = new PageInfo<>(list);
return RestResponse.suc(PageDataVO.pageInfo(vehiclePageInfo));
vehicleBookRecordQueryVo.getCompanyIds().add(vehicleBookRecordQueryVo.getCompanyId() + "");
}
Query query = new Query(vehicleBookRecordQueryVo);
PageDataVO<VehicleBookRecordVo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getBookRecordInfo(query.getSuper()));
return RestResponse.suc(pageDataVO);
}
public RestResponse<Integer> lift(Integer operatorId, String userName, LiftVehicleVo liftVehicleVo) throws Exception{
......
package com.xxfc.platform.vehicle.biz;
import com.github.pagehelper.Page;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
......@@ -13,6 +14,7 @@ import com.xxfc.platform.vehicle.mapper.VehicleDepartureLogMapper;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureStatisticDataVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -24,17 +26,15 @@ import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, VehicleDepartureLog> {
@Autowired
VehicleDepartureLogMapper vehicleDepartureLogMapper;
@Autowired
VehicleMapper vehicleMapper;
public PageInfo<VehicleDepartureLogVo> page(String numberPlate, String time, Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(vehicleDepartureLogMapper.selectVoAll(numberPlate, time));
return new PageInfo<>(mapper.selectVoAll(numberPlate, time));
}
public PageInfo<VehicleDepartureLogVo> pageNotAllData(String numberPlate, String time, Integer page, Integer limit, List<Integer> companyList) {
......@@ -42,12 +42,12 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
if (companyList == null || companyList.size() == 0) {
companyList = Arrays.asList(-1);
}
return new PageInfo<>(vehicleDepartureLogMapper.selectVoAllNotAllData(numberPlate, time, companyList));
return new PageInfo<>(mapper.selectVoAllNotAllData(numberPlate, time, companyList));
}
public PageInfo<VehicleDepartureLogVo> findByVehicle(String vehicleId, Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(vehicleDepartureLogMapper.selectByVehicleId(vehicleId));
return new PageInfo<>(mapper.selectByVehicleId(vehicleId));
}
public VehicleDepartureStatisticDataVo statistic(String numberPlate) {
......@@ -61,29 +61,42 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
// 出行次数
VehicleDepartureLog departureLog = new VehicleDepartureLog();
departureLog.setVehicleId(vehicle.getId());
statisticData.setDepartureCount(vehicleDepartureLogMapper.selectCount(departureLog));
statisticData.setDepartureCount(mapper.selectCount(departureLog));
// 出行天数
statisticData.setDepartureDay(vehicleDepartureLogMapper.selectDayByVehicleId(vehicle.getId()));
statisticData.setDepartureDay(mapper.selectDayByVehicleId(vehicle.getId()));
// 出行公里数
statisticData.setDepartureMileage(vehicleDepartureLogMapper.selectMileageByVehicleId(vehicle.getId()));
statisticData.setDepartureMileage(mapper.selectMileageByVehicleId(vehicle.getId()));
return statisticData;
}
@Transactional
public ObjectRestResponse save(VehicleDepartureLog vehicleDepartureLog) {
Integer id = vehicleDepartureLog.getId();
log.info("添加出行记录参数: vehicleDepartureLog = {}", vehicleDepartureLog);
if (id == null || id == 0) {
vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setState(0);
insertSelective(vehicleDepartureLog);
return ObjectRestResponse.succ();
} else {
vehicleDepartureLog.setUpdateTime(new Date());
updateSelectiveById(vehicleDepartureLog);
VehicleDepartureLog oldValue = mapper.selectByPrimaryKey(vehicleDepartureLog);
if(oldValue != null) {
log.info("更新出行记录: vehicleDepartureLog = {}", oldValue);
BeanUtil.copyProperties(vehicleDepartureLog, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
oldValue.setUpdateTime(new Date());
updateSelectiveById(oldValue);
return ObjectRestResponse.succ();
} else {
vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setState(0);
insertSelective(vehicleDepartureLog);
return ObjectRestResponse.succ();
}
}
return ObjectRestResponse.succ();
}
......
......@@ -34,5 +34,5 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> {
public List<VehicleBookRecordVo> getBookRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo);
public List<VehicleBookRecordVo> getBookRecordInfo(VehicleBookRecordQueryVo vehicleBookRecordQueryVo);
public List<VehicleBookRecordVo> getBookRecordInfo(Map<String, Object> param);
}
\ No newline at end of file
......@@ -461,13 +461,13 @@ public class VehicleController extends BaseController<VehicleBiz> {
}
@GetMapping(value = "/app/unauth/getBookRecord")
@ApiOperation(value = "获取排班记录")
@ApiOperation(value = "获取预定记录")
public RestResponse<PageDataVO> getRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo) {
return vehicleBookRecordBiz.getBookRecord(vehicleBookRecordQueryVo);
}
@GetMapping(value = "/app/unauth/getBookRecordInfo")
@ApiOperation(value = "获取排班记录信息")
@ApiOperation(value = "获取预定记录信息")
public RestResponse<PageDataVO> getBookRecordInfo(VehicleBookRecordQueryVo vehicleBookRecordQueryVo) {
return vehicleBookRecordBiz.getBookRecordInfo(vehicleBookRecordQueryVo);
}
......
......@@ -416,12 +416,9 @@
</select>
<select id="getBookRecordInfo" resultMap="searchBookRecord" parameterType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordQueryVo">
select bc3.name parkCompanyName,bc4.name subordinateBranchName, conv(v2.booked_date,10,2) book_date, conv(v4.booked_hour,10,2) startHour,conv(v5.booked_hour,10,2) endHour, bc1.`name` lift_company_name, bc2.`name` ret_company_name, v3.number_plate,v1.*
<select id="getBookRecordInfo" resultMap="searchBookRecord" parameterType="java.util.Map">
select (CASE v1.lift_company WHEN #{userCompany} THEN 1 ELSE 0 end) liftStatus,(CASE v1.ret_company WHEN #{userCompany} THEN 1 ELSE 0 end) retStatus,bc4.name subordinateBranchName, bc1.`name` lift_company_name, bc2.`name` ret_company_name, v3.number_plate,v1.*
from vehicle_book_record v1
LEFT JOIN vehicle_book_info v2 on v1.vehicle_id = v2.vehicle and v2.year_month = CONCAT(YEAR(v1.book_start_date),"-",IF(MONTH(v1.book_start_date) > 10,MONTH(v1.book_start_date),CONCAT("0",MONTH(v1.book_start_date))))
LEFT JOIN vehicle_book_hour_info v4 on v4.book_record_id = v1.id and YEAR(v4.year_month_day) = YEAR(v1.book_start_date) AND MONTH(v4.year_month_day) = MONTH(v1.book_start_date) AND DAY(v4.year_month_day) =DAY(v1.book_start_date)
LEFT JOIN vehicle_book_hour_info v5 on v5.book_record_id = v1.id and YEAR(v5.year_month_day) = YEAR(v1.book_end_date) AND MONTH(v5.year_month_day) = MONTH(v1.book_end_date) AND DAY(v5.year_month_day) =DAY(v1.book_end_date)
LEFT JOIN branch_company bc1 ON v1.lift_company = bc1.id
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
LEFT JOIN vehicle v3 on v3.id = v1.vehicle_id
......@@ -429,7 +426,7 @@
LEFT JOIN branch_company bc4 on v3.subordinate_branch = bc4.id
<where>
<if test="selectedMonth != null">
and v2.year_month = #{selectedMonth}
and (v1.book_start_date like CONCAT(#{selectedMonth}, "%") or v1.book_start_date like CONCAT(#{selectedMonth}, "%"))
</if>
<if test="numberPlate != null">
and v3.number_plate = #{numberPlate}
......@@ -438,11 +435,14 @@
and v1.book_type = #{bookType}
</if>
<if test="companyIds != null">
and v1.lift_company in
and (v1.lift_company in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
or v1.ret_company in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>)
</if>
<if test="zoneIds != null">
and bc1.zone_id in
......@@ -454,6 +454,7 @@
and v1.status = #{status}
</if>
</where>
group by v1.id
order by create_time DESC
</select>
......
......@@ -20,7 +20,6 @@
<select id="selectByBookRecordId" parameterType="java.lang.Integer" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.*
from vehicle_departure_log
left join vehicle on vehicle_departure_log.vehicle_id = vehicle.id
where vehicle_departure_log.book_record_id = #{id}
order by create_time desc
</select>
......
......@@ -457,7 +457,7 @@
</select>
<select id="getVehicle" resultMap="vehicleModel" parameterType="java.util.Map">
select v1.* from vehicle v1
select v1.*,bc3.name parkCompanyName from vehicle v1
LEFT JOIN branch_company bc3 ON v1.park_branch_company_id = bc3.id
<where>
<if test="numberPlate != null">
......@@ -468,7 +468,6 @@
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="zoneIds != null">
and bc3.zone_id in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment