Commit f5c4bb84 authored by unset's avatar unset

Merge branch 'master-vehicle-price' into dev-tiande

# Conflicts:
#	xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
parents c2643bab db8d0acb
......@@ -3,11 +3,9 @@ package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
@Table(name = "base_user")
@Data
......@@ -109,5 +107,8 @@ public class User {
private String attr8;
@Transient
private List<Integer> companyIds;
}
\ No newline at end of file
......@@ -37,6 +37,9 @@ public interface UserFeign {
@RequestMapping(value = "/public/userinfo-by-token")
public ObjectRestResponse<UserDTO> userinfoByToken(@RequestParam("token") String token);
@RequestMapping(value = "/public/v2/userinfo-by-token")
ObjectRestResponse<UserDTO> userinfoByTokenV2(@RequestParam("token") String token,@RequestParam("flag") boolean flag);
@RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
......
......@@ -17,6 +17,9 @@ public class UserDTO extends User {
}
public List<Integer> dataCompany2List() {
if (getCompanyIds() != null && getCompanyIds().size() > 0){
return getCompanyIds();
}
return str2List(getDataCompany());
}
......
......@@ -17,6 +17,8 @@ import java.util.List;
public interface UserRestInterface {
public UserFeign getUserFeign();
default HttpServletRequest getRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
......@@ -39,14 +41,22 @@ public interface UserRestInterface {
}
}
default UserDTO getAdminUserInfoV2(boolean flag) {
if(getRequest().getHeader("Authorization") !=null) {
return getUserFeign().userinfoByTokenV2(getRequest().getHeader("Authorization"),flag).getData();
}else {
return null;
}
}
default void checkAdminUser(){
if(null == getAdminUserInfo()) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
}
}
default void setPowerData(DataInter dataInter){
UserDTO userDTO = getAdminUserInfo();
default void setPowerData(DataInter dataInter,boolean flag){
UserDTO userDTO = getAdminUserInfoV2(flag);
if (userDTO == null) {
return;
}
......@@ -58,7 +68,12 @@ public interface UserRestInterface {
}else {
List<Integer> dataCorporation2List = userDTO.dataCorporation2List();
if (dataCorporation2List != null && dataCorporation2List.size() > 0){
if (flag){
dataInter.setDataCorporationIds(dataCorporation2List);
}else {
dataInter.setDataCompanyIds(dataCompany2List);
}
}else {
List<Integer> ids=new ArrayList<>();
ids.add(0);
......
......@@ -12,13 +12,18 @@ import com.github.wxiaoqi.security.admin.vo.UserMemberVo;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.CompanySearchVO;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* ${DESCRIPTION}
......@@ -51,6 +56,9 @@ public class PublicController {
@Autowired
private AppUserRelationBiz relationBiz;
@Autowired
VehicleFeign vehicleFeign;
@RequestMapping(value = "/userinfo-by-token", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse userinfoByToken(String token) throws Exception {
......@@ -65,6 +73,32 @@ public class PublicController {
return new ObjectRestResponse<User>().rel(true).data(user);
}
@RequestMapping(value = "v2/userinfo-by-token", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse userinfoByTokenV2(String token,boolean flag) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getUniqueName();
if (username == null) {
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
User user = userBiz.getUserByUsername(username);
if (user == null) {
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
if (!flag && user.getDataCorporation() != null){
CompanySearchDTO companySearchDTO =new CompanySearchDTO();
companySearchDTO.setCompanyIds(Arrays.asList(user.getDataCorporation().split(",")).parallelStream().map(s -> Integer.valueOf(s)).collect(Collectors.toList()));
ObjectRestResponse<List<CompanySearchVO>> restResponse=vehicleFeign.listByIds(companySearchDTO);
if (restResponse != null ){
List<CompanySearchVO> companySearchVOList=restResponse.getData();
if(companySearchVOList != null && companySearchVOList.size() > 0){
List<Integer> companyIds = companySearchVOList.stream().map(CompanySearchVO::getId).distinct().collect(Collectors.toList());
user.setCompanyIds(companyIds);
}
}
}
return new ObjectRestResponse<User>().rel(true).data(user);
}
@RequestMapping(value = "/app/userinfo-by-token", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse userDetailByToken(String token) throws Exception {
......
......@@ -3,6 +3,8 @@ package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import java.util.List;
@Data
public class VehicleCommonPriceDto extends PageParam {
private Integer companyId;
......@@ -19,4 +21,7 @@ public class VehicleCommonPriceDto extends PageParam {
*/
private Integer parkBranchCompanyId;
List<Integer> dataCompanyIds;
List<Integer> dataCorporationIds;
}
......@@ -1138,7 +1138,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
* @throws Exception
*/
public PageDataVO<ResultVehicleVo> getByPage(VehiclePageQueryVo vehiclePageQueryVo) throws Exception {
setPowerData(vehiclePageQueryVo);
setPowerData(vehiclePageQueryVo, true);
Map<String, Object> params = PropertyUtils.describe(vehiclePageQueryVo);
Integer pageSize = (Integer) params.get("limit");
params.remove("pageSize");
......@@ -1163,7 +1163,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
* @return
* @throws Exception
*/
public PageDataVO<ResultVehicleVo> getByPageNotAllData(VehiclePageQueryVo vehiclePageQueryVo, List<Integer> companyList) throws Exception {
public PageDataVO<ResultVehicleVo> getByPageNotAllData(VehiclePageQueryVo vehiclePageQueryVo) throws Exception {
Map<String, Object> params = PropertyUtils.describe(vehiclePageQueryVo);
Integer pageSize = (Integer) params.get("limit");
params.remove("pageSize");
......@@ -1171,11 +1171,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params.remove("pageNo");
//处理预定日期相关参数
adjustBookedInfoParam(params, vehiclePageQueryVo);
if (companyList != null && companyList.size() > 0) {
params.put("companyList", companyList);
} else {
params.put("companyList", null);
}
PageHelper.startPage(pageNo, pageSize);
List<ResultVehicleVo> vehicles = mapper.getByPageNotAllData(params);
PageInfo<ResultVehicleVo> vehiclePageInfo = new PageInfo<>(vehicles);
......
......@@ -50,7 +50,8 @@ public class VehicleCommonPriceInfoBiz extends BaseBiz<VehicleCommonPriceInfoMap
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "车辆不存在!");
}
setPowerData(vehicleCommonPriceInfo);
vehicleCommonPriceInfo.setModelId(vehicle.getModelId());
setPowerData(vehicleCommonPriceInfo, false);
vehicleCommonPriceInfo.setCompanyId(vehicle.getSubordinateBranch());
List<Vehicle> vehicleList = null;
if (vehicleCommonPriceInfo.getAllVehicleUse() != null && vehicleCommonPriceInfo.getAllVehicleUse() == 1) {//所有车辆可用
......
......@@ -70,7 +70,7 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "车辆不存在!");
}
setPowerData(vehicleHolidayPriceInfo);
setPowerData(vehicleHolidayPriceInfo, false);
vehicleHolidayPriceInfo.setCompanyId(vehicle.getSubordinateBranch());
List<Vehicle> vehicleList = null;
if (vehicleHolidayPriceInfo.getAllVehicleUse() != null && vehicleHolidayPriceInfo.getAllVehicleUse() == 1) {//所有车辆可用
......
......@@ -148,8 +148,8 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
if (userDTO != null) {
if (userDTO.getDataAll() == 2) {
setPowerData(vehiclePageQueryVo);
return RestResponse.data(baseBiz.getByPageNotAllData(vehiclePageQueryVo, vehiclePageQueryVo.getDataCompanyIds()));
setPowerData(vehiclePageQueryVo, true);
return RestResponse.data(baseBiz.getByPageNotAllData(vehiclePageQueryVo));
}
}
return RestResponse.data(baseBiz.getByPage(vehiclePageQueryVo));
......@@ -169,8 +169,8 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
UserDTO userDTO = userFeign.userinfoByUid(uid).getData();
if (userDTO != null) {
if (userDTO.getDataAll() == 2) {
setPowerData(vehiclePageQueryVo);
return RestResponse.data(baseBiz.getByPageNotAllData(vehiclePageQueryVo, vehiclePageQueryVo.getDataCompanyIds()));
setPowerData(vehiclePageQueryVo, true);
return RestResponse.data(baseBiz.getByPageNotAllData(vehiclePageQueryVo));
}
}
......
......@@ -38,7 +38,7 @@ public class AdminBranchCompanyController extends BaseController<BranchCompanyBi
@RequestMapping(value ="/search",method = RequestMethod.GET)
public RestResponse<PageDataVO<CompanySearchVO>> search(@Validated CompanySearchDTO vo) {
setPowerData(vo);
setPowerData(vo,false);
return RestResponse.data(baseBiz.search(vo));
}
......
......@@ -26,7 +26,7 @@
and vci.model_id = #{modelId}
</if>
<if test="subordinateBranch !=null ">
and ( v.park_branch_company_id = #{subordinateBranch})
and ( bc2.id = #{subordinateBranch})
</if>
<if test="parkBranchCompanyId !=null ">
and ( bc.id = #{parkBranchCompanyId})
......@@ -34,6 +34,25 @@
<if test="companyId !=null ">
and ( ci.id = #{companyId})
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and ci.id in (
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and (bc.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
) or
bc2.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
))
</if>
<if test="numberPlate !=null and numberPlate != ''">
and v.number_plate like concat('%',#{numberPlate},'%')
</if>
......
......@@ -166,7 +166,7 @@
</foreach>
</if>
<if test="subordinateBranch !=null ">
and ( v.park_branch_company_id = #{subordinateBranch})
and ( bc2.id = #{subordinateBranch})
</if>
<if test="parkBranchCompanyId !=null ">
and ( bc.id = #{parkBranchCompanyId})
......@@ -174,6 +174,25 @@
<if test="companyId !=null ">
and ( ci.id = #{companyId})
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and ci.id in (
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and (bc.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
) or
bc2.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
))
</if>
<if test=" addrProvince !=null or addrCity !=null or zoneId !=null ">
<if test="addrProvince !=null">
and bc.addr_province=#{addrProvince}
......@@ -257,29 +276,6 @@
LEFT JOIN (select * from constant where type = 2) c ON v.use_type = c.code
where
v.is_del=0
<if test="companyList != null">
and ( v.park_branch_company_id in (
<trim suffixOverrides=",">
<foreach collection="companyList" item="companyId">
#{companyId},
</foreach>
</trim>
)
<!--or v.expect_destination_branch_company_id in (
<trim suffixOverrides=",">
<foreach collection="companyList" item="companyId">
#{companyId},
</foreach>
</trim>
)-->
<!-- or v.subordinate_branch in (-->
<!-- <trim suffixOverrides=",">-->
<!-- <foreach collection="companyList" item="companyId">-->
<!-- #{companyId},-->
<!-- </foreach>-->
<!-- </trim>-->
)
</if>
<if test="mRangeDateEnd !=null">
and v.maintenance_date &lt;= #{mRangeDateEnd}
</if>
......@@ -310,9 +306,6 @@
<if test="vin !=null and vin != ''">
and v.vin = #{vin}
</if>
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<if test="code !=null">
and v.code = #{code}
</if>
......@@ -342,7 +335,7 @@
</foreach>
</if>
<if test="subordinateBranch !=null ">
and ( v.park_branch_company_id = #{subordinateBranch})
and ( bc2.id = #{subordinateBranch})
</if>
<if test="parkBranchCompanyId !=null ">
and ( bc.id = #{parkBranchCompanyId})
......@@ -350,6 +343,26 @@
<if test="companyId !=null ">
and ( ci.id = #{companyId})
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and ci.id in (
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and (bc.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
) or
bc2.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
))
</if>
<if test=" addrProvince !=null or addrCity !=null or zoneId !=null ">
<if test="addrProvince !=null">
and bc.addr_province=#{addrProvince}
......@@ -473,6 +486,25 @@
<if test="companyId !=null ">
and ( ci.id = #{companyId})
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and ci.id in (
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and (bc.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
) or
bc2.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
))
</if>
<if test=" addrProvince !=null or addrCity !=null or zoneId !=null ">
<if test="addrProvince !=null">
and bc.addr_province=#{addrProvince}
......@@ -512,29 +544,6 @@
LEFT JOIN (select * from constant where type = 2) c ON v.use_type = c.code
where
v.is_del=0
<if test="companyList != null">
and ( v.park_branch_company_id in (
<trim suffixOverrides=",">
<foreach collection="companyList" item="companyId">
#{companyId},
</foreach>
</trim>
)
<!--or v.expect_destination_branch_company_id in (
<trim suffixOverrides=",">
<foreach collection="companyList" item="companyId">
#{companyId},
</foreach>
</trim>
)-->
<!-- or v.subordinate_branch in (-->
<!-- <trim suffixOverrides=",">-->
<!-- <foreach collection="companyList" item="companyId">-->
<!-- #{companyId},-->
<!-- </foreach>-->
<!-- </trim>-->
)
</if>
<if test="mRangeDateEnd !=null">
and v.maintenance_date &lt;= #{mRangeDateEnd}
</if>
......@@ -606,6 +615,25 @@
and ( v.park_branch_company_id = #{subordinateBranch} or
v.expect_destination_branch_company_id=#{subordinateBranch} )
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and ci.id in (
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and (bc.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
) or
bc2.id in (
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
))
</if>
<if test=" addrProvince !=null or addrCity !=null or zoneId !=null ">
<if test="addrProvince !=null">
and bc.addr_province=#{addrProvince}
......
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