Commit 92c04da1 authored by libin's avatar libin

Merge branch 'master' into dev

parents 0b9c157c 99e96cbc
...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.common.log; ...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.common.log;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.log.CommonLogService;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity; import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -16,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -36,7 +33,7 @@ public class XxLogInterceptor{ ...@@ -36,7 +33,7 @@ public class XxLogInterceptor{
CommonLogService commonLogService; CommonLogService commonLogService;
//触发条件为:com.xxfc.platform包下面所有controller //触发条件为:com.xxfc.platform包下面所有controller
@Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..*)") @Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..* || com.github.wxiaoqi.security.admin.rest..* || com.github.wxiaoqi.security.admin.rest..*)")
public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable { public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
...@@ -60,6 +57,7 @@ public class XxLogInterceptor{ ...@@ -60,6 +57,7 @@ public class XxLogInterceptor{
try{ try{
//###################上面代码为方法执行前##################### //###################上面代码为方法执行前#####################
result = pjp.proceed();//执行方法,获取返回参数 result = pjp.proceed();//执行方法,获取返回参数
log.info("接口调用返回:{}", xxLogEntity.toString());
//###################下面代码为方法执行后##################### //###################下面代码为方法执行后#####################
if(result instanceof JSONObject) { if(result instanceof JSONObject) {
commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString()); commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString());
......
...@@ -95,4 +95,11 @@ public class AppUserDTO { ...@@ -95,4 +95,11 @@ public class AppUserDTO {
private Boolean isBindQQ; private Boolean isBindQQ;
//用户上线 //用户上线
private Integer parentId; private Integer parentId;
//用户上线身份id
private Integer parentPositionId;
//用户上线记录id
private Integer parentPositionTempId;
//用户分公司id
private Integer parentCompanyId;
} }
...@@ -23,7 +23,10 @@ import tk.mybatis.spring.annotation.MapperScan; ...@@ -23,7 +23,10 @@ import tk.mybatis.spring.annotation.MapperScan;
*/ */
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableCircuitBreaker @EnableCircuitBreaker
@SpringBootApplication @SpringBootApplication(scanBasePackages = {
"com.github.wxiaoqi.security.common.log",
"com.github.wxiaoqi.security.admin"
})
@EnableFeignClients(value = {"com.github.wxiaoqi.security","com.xxfc.platform"},defaultConfiguration = HeaderConfig.class) @EnableFeignClients(value = {"com.github.wxiaoqi.security","com.xxfc.platform"},defaultConfiguration = HeaderConfig.class)
@EnableScheduling @EnableScheduling
@EnableAceAuthClient @EnableAceAuthClient
......
...@@ -334,5 +334,15 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A ...@@ -334,5 +334,15 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
} }
} }
public AppUserPositionTemp getOne(Integer userId){
Example example = new Example(AppUserPositionTemp.class);
example.createCriteria().andEqualTo("userId", userId).andEqualTo("isDel", 0);
List<AppUserPositionTemp> list=selectByExample(example);
if (list.size()>0){
return list.get(0);
}
return null;
}
} }
...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache; import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear; import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.dto.UserRelationDTO; import com.github.wxiaoqi.security.admin.dto.UserRelationDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail; import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserRelationTemp;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.bo.InviteMemberBO; import com.github.wxiaoqi.security.admin.bo.InviteMemberBO;
...@@ -20,7 +18,6 @@ import org.springframework.aop.framework.AopContext; ...@@ -20,7 +18,6 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import com.github.wxiaoqi.security.admin.mapper.AppUserRelationMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserRelationMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
...@@ -57,6 +54,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -57,6 +54,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
@Value("${admin.validTime}") @Value("${admin.validTime}")
private Long validTime; private Long validTime;
@Autowired
private AppUserPositionTempBiz positionTempBiz;
/** /**
* 关系绑定 * 关系绑定
* 规则A->B (B无有效上线+无有效下线) * 规则A->B (B无有效上线+无有效下线)
...@@ -369,6 +369,15 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -369,6 +369,15 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
parentId=relation.getParentId(); parentId=relation.getParentId();
} }
userDTO.setParentId(parentId); userDTO.setParentId(parentId);
if (parentId!=null&&parentId>0){
AppUserPositionTemp positionTemp= positionTempBiz.getOne(parentId);
if (positionTemp!=null){
userDTO.setParentPositionId(positionTemp.getPositionId());
userDTO.setParentPositionTempId(positionTemp.getId());
userDTO.setParentCompanyId(positionTemp.getCompanyId());
}
}
} }
} }
...@@ -342,7 +342,7 @@ public class AppUserController extends CommonBaseController{ ...@@ -342,7 +342,7 @@ public class AppUserController extends CommonBaseController{
} }
@PostMapping("/bind") @PostMapping("/bind")
private ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO, HttpServletRequest request){ public ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO, HttpServletRequest request){
try { try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)); IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
return appUserLoginBiz.bindAccount(accountBindDTO, Integer.valueOf(infoFromToken.getId()), request); return appUserLoginBiz.bindAccount(accountBindDTO, Integer.valueOf(infoFromToken.getId()), request);
......
...@@ -7,7 +7,7 @@ public enum CrosstownTypeEnum { ...@@ -7,7 +7,7 @@ public enum CrosstownTypeEnum {
DEPARTURE(1, "交车"), DEPARTURE(1, "交车"),
ARRIVE(2, "还车"), ARRIVE(2, "还车"),
FIXED_LOSS(3, "定损"), FIXED_LOSS(3, "定损"),
FIXED_LOSS_NOW(4, "定损"), FIXED_LOSS_NOW(4, "立即定损"),
; ;
/** /**
* 编码 * 编码
......
...@@ -309,16 +309,23 @@ public class BaseOrder implements Serializable { ...@@ -309,16 +309,23 @@ public class BaseOrder implements Serializable {
private Integer remark; private Integer remark;
/** /**
* 备注 * 上级id
*/ */
@ApiModelProperty(value = "上级id") @ApiModelProperty(value = "上级id")
@Column(name = "parent_user_id") @Column(name = "parent_user_id")
private Integer parentUserId; private Integer parentUserId;
/** /**
* 备注 * 上级公司id
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "上级公司id")
@Column(name = "parent_user_company_id") @Column(name = "parent_user_company_id")
private Integer parentUserCompanyId; private Integer parentUserCompanyId;
/**
* 上级公司员工id
*/
@ApiModelProperty(value = "上级公司员工id")
@Column(name = "parent_position_id")
private Integer parentPositionId;
} }
...@@ -41,4 +41,7 @@ public class BgOrderListVo { ...@@ -41,4 +41,7 @@ public class BgOrderListVo {
private Integer vehicleCode; private Integer vehicleCode;
private Integer userId; private Integer userId;
//员工身份
private String positionName;
} }
...@@ -298,7 +298,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -298,7 +298,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} catch (Exception e) { } catch (Exception e) {
return ObjectRestResponse.createFailedResult(1001, e.getMessage()); return ObjectRestResponse.createFailedResult(1001, e.getMessage());
} }
} else if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.ARRIVE.getCode() || orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode()) { //还车 } else if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.ARRIVE.getCode() || orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode() || orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.FIXED_LOSS_NOW.getCode()) { //还车
VehicleArrivalVo vehicleArrivalVo = new VehicleArrivalVo(); VehicleArrivalVo vehicleArrivalVo = new VehicleArrivalVo();
vehicleArrivalVo.setVehicleId(orderRentVehicleDetail.getVehicleId()); vehicleArrivalVo.setVehicleId(orderRentVehicleDetail.getVehicleId());
vehicleArrivalVo.setArrivalBranchCompanyId(userDTO.getCompanyId()); vehicleArrivalVo.setArrivalBranchCompanyId(userDTO.getCompanyId());
......
...@@ -101,6 +101,8 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or ...@@ -101,6 +101,8 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or
//设置上级 //设置上级
baseOrder.setParentUserId(appUserDTO.getParentId()); baseOrder.setParentUserId(appUserDTO.getParentId());
baseOrder.setParentUserCompanyId(appUserDTO.getParentCompanyId());
baseOrder.setParentPositionId(appUserDTO.getParentPositionTempId());
return baseOrder; return baseOrder;
} }
......
...@@ -241,85 +241,58 @@ ...@@ -241,85 +241,58 @@
</select> </select>
<select id="getAllOrderList" parameterType="Map" resultType="com.xxfc.platform.order.pojo.bg.BgOrderListVo"> <select id="getAllOrderList" parameterType="Map" resultType="com.xxfc.platform.order.pojo.bg.BgOrderListVo">
SELECT SELECT * from order_list_info
DISTINCT(b1.id),
bc1.`name` AS startCompanyName,
bc2. NAME AS endCompanyName,
v1.number_plate AS numberPlate,
v1.code AS vehicleCode,
a1. NAME AS username,
a2.username AS telephone,
a2.id As userId,
b1.id AS orderId,
b1.`no` AS orderNo,
b1.`status` as status,
b1.`name` as vehicleName,
b1.crt_time as crtTime,
o1.start_time as startTime,
o1.end_time as endTime,
b1.real_amount as realAmount,
b1.pay_way as payWay,
o1.id as detailId,
b1.pay_time as payTime
FROM
base_order b1
LEFT JOIN order_rent_vehicle_detail o1 ON b1.detail_id = o1.id
LEFT JOIN vehicle.branch_company bc1 ON bc1.id = o1.start_company_id
LEFT JOIN vehicle.branch_company bc2 ON bc2.id = o1.end_company_id
LEFT JOIN vehicle.vehicle v1 ON v1.id = o1.vehicle_id
LEFT JOIN xxfc_third_platform.id_information a1 ON b1.user_id = a1.user_login_id
LEFT JOIN ag_admin_v1.app_user_login a2 ON a2.id = b1.user_id
<where> <where>
<if test="userIds != null and userIds.size() > 0"> <if test="userIds != null and userIds.size() > 0">
and b1.user_id in and userId in
<foreach collection="userIds" item="item" open="(" separator="," close=")"> <foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="phone != null and phone != ''"> <if test="phone != null and phone != ''">
and a2.username like CONCAT ("%", #{phone}, "%") and telephone like CONCAT ("%", #{phone}, "%")
</if> </if>
<if test="realName != null and realName != ''"> <if test="realName != null and realName != ''">
and a1.name like CONCAT ("%", #{realName}, "%") and username like CONCAT ("%", #{realName}, "%")
</if> </if>
<if test="userId != null"> <if test="userId != null">
and b1.user_id = #{userId} and userId = #{userId}
</if> </if>
<if test="status != null"> <if test="status != null">
and b1.status = #{status} and status = #{status}
</if> </if>
<if test="type != null"> <if test="type != null">
and b1.type = #{type} and type = #{type}
</if> </if>
<if test="no != null and no != '' "> <if test="no != null and no != '' ">
and b1.no like CONCAT ("%", #{no}, "%") and orderNo like CONCAT ("%", #{no}, "%")
</if> </if>
<if test="plateNumber != null and plateNumber != '' "> <if test="plateNumber != null and plateNumber != '' ">
and v1.number_plate like CONCAT ("%", #{plateNumber}, "%") and numberPlate like CONCAT ("%", #{plateNumber}, "%")
</if> </if>
<if test="vehicleCode != null"> <if test="vehicleCode != null">
and v1.code = #{vehicleCode} and vehicleCode = #{vehicleCode}
</if> </if>
<if test="startTime != null"> <if test="startTime != null">
and o1.start_time between #{startTime} and #{endTime} and startTime between #{startTime} and #{endTime}
</if> </if>
<if test="companyIds != null and companyIds.size > 0"> <if test="companyIds != null and companyIds.size > 0">
and (o1.start_company_id in and (startCompanyId in
<foreach collection="companyIds" item="id" open="(" separator="," close=")"> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
or or
o1.end_company_id in endCompanyId in
<foreach collection="companyIds" item="id" open="(" separator="," close=")"> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
) )
</if> </if>
<if test="zoneId != null"> <if test="zoneId != null">
and (bc1.zone_id = #{zoneId} or bc2.zone_id = #{zoneId}) and (startZoneId = #{zoneId} or endZoneId = #{zoneId})
</if> </if>
</where> </where>
order by b1.crt_time desc order by crtTime desc
</select> </select>
......
...@@ -21,8 +21,8 @@ public class BranchCompanyVehicleCount { ...@@ -21,8 +21,8 @@ public class BranchCompanyVehicleCount {
/** /**
* 公司名称 * 公司名称
*/ */
@Column(name = "company_name") @Column(name = "company_id")
private String companyName; private String companyId;
/** /**
* 当前停靠车辆数量 * 当前停靠车辆数量
...@@ -40,5 +40,21 @@ public class BranchCompanyVehicleCount { ...@@ -40,5 +40,21 @@ public class BranchCompanyVehicleCount {
) )
private Date countDate; private Date countDate;
/**
* 统计年
*/
@Column(name = "count_year")
private Integer countYear;
/**
* 统计月
*/
@Column(name = "count_month")
private Integer countMonth;
/**
* 统计周
*/
@Column(name = "count_week")
private Integer countWeek;
} }
\ No newline at end of file
package com.xxfc.platform.vehicle.pojo; package com.xxfc.platform.vehicle.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data @Data
public class BranchCompanyVehicleCountVo { public class BranchCompanyVehicleCountVo {
private String parkBranchCompanyName; //分公司ID
private Integer count;
private Integer companyId; private Integer companyId;
//统计年
private Integer countYear;
//统计月
private Integer countMonth;
//统计周
private Integer countWeek;
//统计日期
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd"
)
private Date countDate;
//统计数量
private Integer vehicleNum;
//公司名称
private String companyName;
//周开始时间
private String weekStartDate;
//周结束时间
private String weekEndDate;
} }
package com.xxfc.platform.vehicle.pojo;
import lombok.Data;
import java.util.Date;
@Data
public class VehicleWeekCountVo {
private Integer week;
private Date dateTime;
private Integer count;
}
...@@ -11,9 +11,8 @@ public class BranchCompanyVehicleCountDTO extends PageParam { ...@@ -11,9 +11,8 @@ public class BranchCompanyVehicleCountDTO extends PageParam {
//结束时间 //结束时间
private String endTime; private String endTime;
private String companyName; private Integer companyId;
//统计类型,日月年, 1、日,2、月,3、年 //统计类型,日月年, 1、日,2、月,3、年
private Integer type; private Integer type;
//需要除去的天数
private Integer dayNum;
} }
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.Utils.OrderDateUtils;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount; import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper; import com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Calendar; import java.util.List;
@Service @Service
@Slf4j @Slf4j
public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCountMapper, BranchCompanyVehicleCount> { public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCountMapper, BranchCompanyVehicleCount> {
@Autowired @Autowired
VehicleInformationDownloadBiz vehicleInformationDownloadBiz; VehicleBiz vehicleBiz;
public ObjectRestResponse add(BranchCompanyVehicleCount branchCompanyVehicleCount) { public ObjectRestResponse add(BranchCompanyVehicleCount branchCompanyVehicleCount) {
if (branchCompanyVehicleCount == null) { if (branchCompanyVehicleCount == null) {
...@@ -30,32 +36,78 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo ...@@ -30,32 +36,78 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse<PageDataVO<BranchCompanyVehicleCount>> findAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) { public ObjectRestResponse addAll(List<BranchCompanyVehicleCountVo> list) {
vehicleInformationDownloadBiz.addAll(); if (list != null && list.size() > 0) {
Integer pageNo = branchCompanyVehicleCountDTO.getPage() == null ? 1 : branchCompanyVehicleCountDTO.getPage(); list.parallelStream().forEach(result -> {
Integer pageSize = branchCompanyVehicleCountDTO.getLimit() == null ? 10 : branchCompanyVehicleCountDTO.getLimit(); BranchCompanyVehicleCount branchCompanyVehicleCount = new BranchCompanyVehicleCount();
Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType(); BeanUtil.copyProperties(result, branchCompanyVehicleCount, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
branchCompanyVehicleCountDTO.setPage(pageNo); add(branchCompanyVehicleCount);
branchCompanyVehicleCountDTO.setLimit(pageSize); });
branchCompanyVehicleCountDTO.setType(type);
if (type == 1) {
branchCompanyVehicleCountDTO.setDayNum(1);
} else if (type == 2) {
branchCompanyVehicleCountDTO.setDayNum(7);
} else if (type == 3) {
branchCompanyVehicleCountDTO.setDayNum(getCurrentMonthLastDay());
}
Query query = new Query(branchCompanyVehicleCountDTO);
PageDataVO<BranchCompanyVehicleCount> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getAllByParam(query.getSuper()));
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} else {
return ObjectRestResponse.paramIsEmpty();
}
}
@Scheduled(cron = "0 0 2 * * *")
public void addAll() {
addAll(vehicleBiz.getAllVehicleInfo());
}
/**
* 按天统计
* @param query
* @return
*/
public PageDataVO<BranchCompanyVehicleCountVo> countByDay(Query query) {
return PageDataVO.pageInfo(query, () -> mapper.getAllCountInfo(query.getSuper()));
}
/**
* 按月统计
* @param query
* @return
*/
public PageDataVO<BranchCompanyVehicleCountVo> countByMonth(Query query) {
return PageDataVO.pageInfo(query, () -> mapper.countByMonth(query.getSuper()));
}
/**
* 按周统计
* @param query
* @return
*/
public PageDataVO<BranchCompanyVehicleCountVo> countByWeek(Query query) {
return PageDataVO.pageInfo(query, () -> mapper.countByWeek(query.getSuper()));
} }
public int getCurrentMonthLastDay() { public ObjectRestResponse<PageDataVO<BranchCompanyVehicleCountVo>> getAllCountInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
Calendar a = Calendar.getInstance(); if (branchCompanyVehicleCountDTO == null) {
a.set(Calendar.DATE, 1);//把日期设置为当月第一天 return ObjectRestResponse.paramIsEmpty();
a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天 }
int maxDate = a.get(Calendar.DATE); Integer page = branchCompanyVehicleCountDTO.getPage() == null ? 1 : branchCompanyVehicleCountDTO.getPage();
return maxDate; Integer limit = branchCompanyVehicleCountDTO.getLimit() == null ? 10 : branchCompanyVehicleCountDTO.getLimit();
Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType();
branchCompanyVehicleCountDTO.setPage(page);
branchCompanyVehicleCountDTO.setLimit(limit);
Query query = new Query(branchCompanyVehicleCountDTO);
if (type == 1) {//按天
return ObjectRestResponse.succ(countByDay(query));
}
if (type == 2) {//按周
PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = countByWeek(query);
if (pageDataVO != null && pageDataVO.getData() != null && pageDataVO.getData().size() > 0) {
pageDataVO.getData().parallelStream().forEach(result -> {
String weekStartDate = OrderDateUtils.getStartDayOfWeekNo(result.getCountYear(), result.getCountWeek());
String weekEndDate = OrderDateUtils.getEndDayOfWeekNo(result.getCountYear(), result.getCountWeek());
result.setWeekStartDate(weekStartDate);
result.setWeekEndDate(weekEndDate);
});
}
return ObjectRestResponse.succ(pageDataVO);
}
if (type == 3) {//按月
return ObjectRestResponse.succ(countByMonth(query));
}
return ObjectRestResponse.succ(new PageDataVO<>());
} }
} }
...@@ -236,6 +236,8 @@ public class VehicleActiveService { ...@@ -236,6 +236,8 @@ public class VehicleActiveService {
if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态 if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
vehicle.setStatus(VehicleStatus.NORMAL.getCode()); vehicle.setStatus(VehicleStatus.NORMAL.getCode());
} }
//2019-11-22 16:30 还原还车时修改车辆停靠分公司需求
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleMapper.updateByPrimaryKeySelective(vehicle); vehicleMapper.updateByPrimaryKeySelective(vehicle);
DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate()); DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate());
......
...@@ -1516,8 +1516,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -1516,8 +1516,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList()); return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList());
} }
public List<BranchCompanyVehicleCountVo> getAllVehicleInfo(Map<String, Object> param) { public List<BranchCompanyVehicleCountVo> getAllVehicleInfo() {
return mapper.getAllVehicleInfo(param); return mapper.getAllVehicleInfo();
} }
} }
...@@ -256,14 +256,15 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -256,14 +256,15 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
//出行中才修改车辆停靠分公司 //出行中才修改车辆停靠分公司
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId()); //2019-11-22 16:30 取消修改还车地点同时修改停靠分公司需求
if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) { // VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
Vehicle vehicle = vehicleBiz.selectById(vehicleBookRecord.getVehicleId()); // if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
if (vehicle != null) { // Vehicle vehicle = vehicleBiz.selectById(vehicleBookRecord.getVehicleId());
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany()); // if (vehicle != null) {
vehicleBiz.updateSelectiveByIdRe(vehicle); // vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
} // vehicleBiz.updateSelectiveByIdRe(vehicle);
} // }
// }
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog); return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else { } else {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
......
...@@ -4,25 +4,24 @@ import com.alibaba.fastjson.JSON; ...@@ -4,25 +4,24 @@ import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.entity.Vehicle; import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.mapper.VehicleMapper; import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.ResultVehicleVo; import com.xxfc.platform.vehicle.pojo.ResultVehicleVo;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo; import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.VehiclePageQueryVo; import com.xxfc.platform.vehicle.pojo.VehiclePageQueryVo;
import com.xxfc.platform.vehicle.util.DateUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean; import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service @Service
@Slf4j @Slf4j
...@@ -100,41 +99,4 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl ...@@ -100,41 +99,4 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
} }
public void getAllVehicleInfo() {
Map<String, Object> map = new HashMap<>();
map.put("startTime", DateTime.now().withMillis(DateUtils.getStartOfDay()).toString(DEFAULT_DATE_TIME_FORMATTER));
map.put("endTime", DateTime.now().withMillis(DateUtils.getEndOfDay()).toString(DEFAULT_DATE_TIME_FORMATTER));
add(map);
}
public void addAll() {
DateTime dateTime = DateTime.parse("2019-10-01 00:00:00", DEFAULT_DATE_TIME_FORMATTER);
DateTime dateTime1 = DateTime.parse("2019-10-01 23:59:59", DEFAULT_DATE_TIME_FORMATTER);
for (int i = 0; i < 52; i++) {
Map<String, Object> map = new HashMap<>();
map.put("startTime", dateTime.plusDays(i).toString(DEFAULT_DATE_TIME_FORMATTER));
map.put("endTime", dateTime1.plusDays(i).toString(DEFAULT_DATE_TIME_FORMATTER));
add(map);
}
}
public void add(Map<String, Object> param) {
List<BranchCompanyVehicleCountVo> branchCompanyVehicleCountVos = vehicleBiz.getAllVehicleInfo(param);
branchCompanyVehicleCountVos.forEach(result->{
try {
if (result != null) {
BranchCompanyVehicleCount branchCompanyVehicleCount = new BranchCompanyVehicleCount();
branchCompanyVehicleCount.setCompanyName(result.getParkBranchCompanyName());
branchCompanyVehicleCount.setVehicleNum(result.getCount());
branchCompanyVehicleCount.setCountDate(DateTime.parse(param.get("startTime").toString().split(" ")[0]).toDate());
branchCompanyVehicleCountBiz.add(branchCompanyVehicleCount);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
}
} }
package com.xxfc.platform.vehicle.mapper; package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount; import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
...@@ -8,5 +9,10 @@ import java.util.Map; ...@@ -8,5 +9,10 @@ import java.util.Map;
public interface BranchCompanyVehicleCountMapper extends Mapper<BranchCompanyVehicleCount> { public interface BranchCompanyVehicleCountMapper extends Mapper<BranchCompanyVehicleCount> {
List<BranchCompanyVehicleCount> getAllByParam(Map<String, Object> param); List<BranchCompanyVehicleCountVo> getAllCountInfo(Map<String, Object> param);
List<BranchCompanyVehicleCountVo> countByMonth(Map<String, Object> param);
List<BranchCompanyVehicleCountVo> countByWeek(Map<String, Object> param);
} }
\ No newline at end of file
...@@ -54,5 +54,5 @@ public interface VehicleMapper extends Mapper<Vehicle> { ...@@ -54,5 +54,5 @@ public interface VehicleMapper extends Mapper<Vehicle> {
@Select("select `id` from `vehicle` where `is_del`=0") @Select("select `id` from `vehicle` where `is_del`=0")
List<String> findExistVehicleIds(); List<String> findExistVehicleIds();
List<BranchCompanyVehicleCountVo> getAllVehicleInfo(Map<String, Object> params); List<BranchCompanyVehicleCountVo> getAllVehicleInfo();
} }
\ No newline at end of file
...@@ -338,14 +338,15 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -338,14 +338,15 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
bookRecordUpdateLog.setOperaterId(userDTO.getId()); bookRecordUpdateLog.setOperaterId(userDTO.getId());
bookRecordUpdateLog.setOperaterName(userDTO.getName()); bookRecordUpdateLog.setOperaterName(userDTO.getName());
bookRecordUpdateLog.setCreateTime(new Date()); bookRecordUpdateLog.setCreateTime(new Date());
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(oldValue.getId()); //2019-11-22 16:30 取消修改还车地点同时修改停靠分公司需求
if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) { // VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(oldValue.getId());
Vehicle vehicle = vehicleBiz.selectById(oldValue.getVehicleId()); // if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
if (vehicle != null) { // Vehicle vehicle = vehicleBiz.selectById(oldValue.getVehicleId());
vehicle.setParkBranchCompanyId(oldValue.getRetCompany()); // if (vehicle != null) {
vehicleBiz.updateSelectiveByIdRe(vehicle); // vehicle.setParkBranchCompanyId(oldValue.getRetCompany());
} // vehicleBiz.updateSelectiveByIdRe(vehicle);
} // }
// }
vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord); vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord);
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog); return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else { } else {
......
package com.xxfc.platform.vehicle.rest.admin; package com.xxfc.platform.vehicle.rest.admin;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz; import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@Controller @Controller
@RequestMapping(value = "/bg-vehicle/count") @RequestMapping(value = "/bg-vehicle/count")
public class BranchCompanyVehicleCountController extends BaseController<BranchCompanyVehicleCountBiz> { public class BranchCompanyVehicleCountController extends BaseController<BranchCompanyVehicleCountBiz> {
@Autowired
private HttpServletResponse response;
@GetMapping(value = "/getAll") @GetMapping(value = "/getAll")
@ResponseBody @ResponseBody
public ObjectRestResponse getAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) { public ObjectRestResponse getAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
return baseBiz.findAll(branchCompanyVehicleCountDTO); return baseBiz.getAllCountInfo(branchCompanyVehicleCountDTO);
}
@GetMapping("/app/unauth/export")
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception {
PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = baseBiz.getAllCountInfo(branchCompanyVehicleCountDTO).getData();
if (pageDataVO != null && pageDataVO.getData() != null) {
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("companyId", "公司ID");
writer.addHeaderAlias("companyName", "公司名");
writer.addHeaderAlias("countYear", "年");
writer.addHeaderAlias("countMonth", "月");
writer.addHeaderAlias("countWeek", "周");
writer.addHeaderAlias("weekStartDate", "开始日期");
writer.addHeaderAlias("weekEndDate", "结束日期");
writer.addHeaderAlias("countDate", "日期");
writer.addHeaderAlias("vehicleNum", "数量");
writer.setColumnWidth(7, 17);
writer.setColumnWidth(5, 17);
writer.setColumnWidth(6, 17);
writer.setColumnWidth(1, 17);
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(pageDataVO.getData(), true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=vehicleInfo.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
} }
} }
...@@ -7,15 +7,11 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign; ...@@ -7,15 +7,11 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz; import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz; import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo; import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -76,31 +72,9 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle ...@@ -76,31 +72,9 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
IoUtil.close(out); IoUtil.close(out);
} }
@GetMapping("/app/unauth/export") @GetMapping("/app/unauth/addAll")
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception { public void addAll() {
PageDataVO<BranchCompanyVehicleCount> pageDataVO = branchCompanyVehicleCountBiz.findAll(branchCompanyVehicleCountDTO).getData(); branchCompanyVehicleCountBiz.addAll(vehicleBiz.getAllVehicleInfo());
if (pageDataVO == null || pageDataVO.getData() == null) {
throw new BaseException(ResultCode.getMsg(ResultCode.NOTEXIST_CODE), ResultCode.NOTEXIST_CODE);
}
List<BranchCompanyVehicleCount> rows = pageDataVO.getData();
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("id", "ID");
writer.addHeaderAlias("countDate", "日期");
writer.addHeaderAlias("companyName", "停靠分公司");
writer.addHeaderAlias("vehicleNum", "车辆数量");
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(rows, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=vehicleInfo.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
} }
} }
<?xml version="1.0" encoding="UTF-8" ?> <?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" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper" > <mapper namespace="com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper" >
<resultMap id="BaseResultMap" type="com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="BIGINT" />
<result column="company_name" property="companyName" jdbcType="VARCHAR" />
<result column="vehicle_num" property="vehicleNum" jdbcType="INTEGER" />
<result column="count_date" property="countDate" jdbcType="TIMESTAMP" />
<result column="company_id" property="companyId" jdbcType="INTEGER" />
</resultMap>
<select id="getAllByParam" parameterType="Map" resultType="com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount"> <select id="getAllCountInfo" parameterType="Map" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo">
SELECT company_name, CEILING(( SELECT
CASE c.*,
WHEN #{type} = 1 THEN b.`name` AS companyName
sum(vehicle_num) / #{dayNum} FROM
WHEN #{type} = 2 THEN branch_company_vehicle_count c
sum(vehicle_num) / #{dayNum} LEFT JOIN branch_company b ON b.id = c.company_id
WHEN #{type} = 3 THEN
sum(vehicle_num) / #{dayNum}
END
))
AS vehicleNum from branch_company_vehicle_count
<where> <where>
<if test="companyName != null and companyName != ''"> <if test = "companyId != null">
and company_name like concat('%', #{companyName}, '%') and c.company_id = #{companyId}
</if> </if>
<if test="startTime != null and startTime != ''"> <if test="startTime != null and startTime != ''">
and count_date &gt; #{startTime} and count_date &lt; #{endTime} and c.count_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and c.count_date &lt;= #{endTime}
</if>
</where>
GROUP BY c.id
ORDER BY c.company_id
</select>
<select id="countByMonth" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo" parameterType="Map">
SELECT c.company_id, c.count_year, c.count_month, b.`name` as companyName, sum(c.vehicle_num) as vehicle_num from branch_company_vehicle_count c
LEFT JOIN branch_company b on b.id = c.company_id
<where>
<if test = "companyId != null">
and c.company_id = #{companyId}
</if>
<if test="startTime != null and startTime != ''">
and c.count_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and c.count_date &lt;= #{endTime}
</if> </if>
</where> </where>
GROUP BY company_name GROUP BY c.company_id,c.count_year,c.count_month
</select> </select>
<select id="countByWeek" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo" parameterType="Map">
SELECT c.company_id, c.count_year, c.count_week, b.`name` as companyName, sum(c.vehicle_num) as vehicle_num from branch_company_vehicle_count c
LEFT JOIN branch_company b on b.id = c.company_id
<where>
<if test = "companyId != null">
and c.company_id = #{companyId}
</if>
<if test="startTime != null and startTime != ''">
and c.count_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and c.count_date &lt;= #{endTime}
</if>
</where>
GROUP BY c.company_id,c.count_year,c.count_week
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -591,16 +591,10 @@ ...@@ -591,16 +591,10 @@
</select> </select>
<!--导出分公司停靠所有车辆--> <!--导出分公司停靠所有车辆-->
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo" parameterType="Map"> <select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo">
select tmp.name as parkBranchCompanyName, COUNT(0) as count from ( select b.id as companyId, DATE_FORMAT(now(),'%Y') as countYear, DATE_FORMAT(now(),'%m') as countMonth,DATE_FORMAT(now(),'%u') as countWeek,DATE_FORMAT(now(),'%Y-%m-%d') as countDate,count(*) as vehicleNum from vehicle v
select v1.number_plate, b.name from vehicle_book_record v LEFT JOIN branch_company b on b.id = v.park_branch_company_id
LEFT JOIN branch_company b on b.id = v.lift_company GROUP BY b.id
LEFT JOIN vehicle v1 on v1.id = v.vehicle_id
where v.`status` != 4 and v.`status` != 6
and v.book_start_date &gt; #{startTime} and v.book_start_date &lt; #{endTime}
ORDER BY v.vehicle_id, v.book_start_date DESC
) tmp
GROUP BY name
</select> </select>
<select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle" <select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle"
......
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