Commit 8d9ff4a9 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents a909e51b 57aa1978
......@@ -11,6 +11,7 @@ import com.xxfc.platform.im.entity.CustomerService;
import com.xxfc.platform.im.mapper.CustomerServiceMapper;
import com.xxfc.platform.im.vo.CustomerServiceVO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -54,32 +55,32 @@ public class CustomerServiceBiz extends BaseBiz<CustomerServiceMapper, CustomerS
CustomerService customerService = new CustomerService();
BeanUtils.copyProperties(customerServiceDTO, customerService);
if (Objects.isNull(customerServiceDTO.getId())){
customerService.setCreateTime(Instant.now().toEpochMilli());
customerService.setName(String.format("%s%s", NICK_PRE_NAME, customerServiceDTO.getTelphone()));
customerService.setIsDel(false);
customerService.setPassword(INIT_PASSWORD);
Map<String, Object> imMap = new HashMap<>(2);
imMap.put("telephone", customerServiceDTO.getTelphone());
imMap.put("password", INIT_PASSWORD);
imMap.put("nickname", customerService.getName());
BaseResponse imResponse = userBiz.register(imMap);
String imResult = imResponse.getMessage();
JSONObject jsonObject = JSON.parseObject(imResult);
Map<String, Object> data = (Map<String, Object>) jsonObject.get("data");
Object userId = data.get("userId");
if (Objects.isNull(userId)) {
throw new BaseException("注册失败");
}
customerService.setImUserId((Integer) userId);
mapper.insertSelective(customerService);
}else {
customerService.setUpdateTime(Instant.now().toEpochMilli());
if (!StringUtils.isEmpty(customerServiceDTO.getPassword())){
userBiz.updatePasswordByPhone(customerServiceDTO.getTelphone(),customerServiceDTO.getPassword());
}
mapper.updateByPrimaryKeySelective(customerService);
}
if (Objects.isNull(customerServiceDTO.getId())) {
customerService.setCreateTime(Instant.now().toEpochMilli());
customerService.setName(String.format("%s%s", NICK_PRE_NAME, customerServiceDTO.getTelphone()));
customerService.setIsDel(false);
customerService.setPassword(StringUtils.isEmpty(customerServiceDTO.getPassword()) ? INIT_PASSWORD : customerServiceDTO.getPassword().trim().length() > 0 ? customerServiceDTO.getPassword() : INIT_PASSWORD);
Map<String, Object> imMap = new HashMap<>(2);
imMap.put("telephone", customerServiceDTO.getTelphone());
imMap.put("password", DigestUtils.md5Hex(customerService.getPassword()));
imMap.put("nickname", customerService.getName());
BaseResponse imResponse = userBiz.register(imMap);
String imResult = imResponse.getMessage();
JSONObject jsonObject = JSON.parseObject(imResult);
Map<String, Object> data = (Map<String, Object>) jsonObject.get("data");
Object userId = data.get("userId");
if (Objects.isNull(userId)) {
throw new BaseException("注册失败");
}
customerService.setImUserId((Integer) userId);
mapper.insertSelective(customerService);
} else {
customerService.setUpdateTime(Instant.now().toEpochMilli());
if (!StringUtils.isEmpty(customerServiceDTO.getPassword())) {
userBiz.updatePasswordByPhone(customerServiceDTO.getTelphone(), customerServiceDTO.getPassword());
}
mapper.updateByPrimaryKeySelective(customerService);
}
}
......@@ -121,24 +122,24 @@ public class CustomerServiceBiz extends BaseBiz<CustomerServiceMapper, CustomerS
public void updatePasswordByPhone(String telphone, String password) {
Example example = new Example(CustomerService.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("telphone",telphone);
criteria.andEqualTo("telphone", telphone);
CustomerService customerService = new CustomerService();
customerService.setPassword(password);
customerService.setPassword(DigestUtils.md5Hex(password));
customerService.setUpdateTime(Instant.now().toEpochMilli());
mapper.updateByExampleSelective(customerService,example);
mapper.updateByExampleSelective(customerService, example);
}
public PageDataVO<CustomerServiceVO> findCustomerServiceWithPage(Integer page, Integer limit) {
PageDataVO<CustomerServiceVO> dataVO = new PageDataVO<>();
PageDataVO<CustomerServiceVO> dataVO = new PageDataVO<>();
Example example = new Example(CustomerService.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isDel",false);
criteria.andEqualTo("isDel", false);
PageDataVO<CustomerService> pageDataVO = PageDataVO.pageInfo(page,limit,()->mapper.selectByExample(example));
PageDataVO<CustomerService> pageDataVO = PageDataVO.pageInfo(page, limit, () -> mapper.selectByExample(example));
List<CustomerService> data = pageDataVO.getData();
if (CollectionUtils.isEmpty(data)){
if (CollectionUtils.isEmpty(data)) {
return dataVO;
}
......@@ -146,22 +147,22 @@ public class CustomerServiceBiz extends BaseBiz<CustomerServiceMapper, CustomerS
CustomerServiceVO customerServiceVO;
for (CustomerService customerService : data) {
customerServiceVO = new CustomerServiceVO();
BeanUtils.copyProperties(customerService,customerServiceVO);
BeanUtils.copyProperties(customerService, customerServiceVO);
customerServiceVOS.add(customerServiceVO);
}
dataVO.setPageSize(pageDataVO.getPageSize());
dataVO.setPageNum(pageDataVO.getPageNum());
dataVO.setTotalPage(pageDataVO.getTotalPage());
dataVO.setTotalCount(pageDataVO.getTotalCount());
dataVO.setData(customerServiceVOS);
dataVO.setPageSize(pageDataVO.getPageSize());
dataVO.setPageNum(pageDataVO.getPageNum());
dataVO.setTotalPage(pageDataVO.getTotalPage());
dataVO.setTotalCount(pageDataVO.getTotalCount());
dataVO.setData(customerServiceVOS);
return dataVO;
}
public CustomerServiceDTO findCustomerServiceById(Long id) {
CustomerServiceDTO customerServiceDTO = new CustomerServiceDTO();
CustomerServiceDTO customerServiceDTO = new CustomerServiceDTO();
CustomerService customerService = mapper.selectByPrimaryKey(id);
BeanUtils.copyProperties(customerService,customerServiceDTO);
BeanUtils.copyProperties(customerService, customerServiceDTO);
return customerServiceDTO;
}
}
......@@ -7,9 +7,9 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.order.contant.enumerate.AccountTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.DailyTravelOrderStatistics;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.entity.OrderStatistics;
......@@ -197,7 +197,7 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
private void refundAndDeductions(Map<Integer, List<OrderAccountDTO>> map, DailyTravelOrderStatistics orderStatistics) {
ArrayList<OrderAccountDTO> arrayList = Lists.newArrayList();
for (Integer key : map.keySet()) {
if (!key.equals(RefundTypeEnum.ORDER_FUND.getCode())) {
if (!key.equals(AccountTypeEnum.IN_ORDER_PAY.getCode())) {
arrayList.addAll(map.get(key));
}
}
......@@ -222,7 +222,7 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
private DailyTravelOrderStatistics getGmvAndSecurityDeposit(Map<Integer, List<OrderAccountDTO>> map) {
DailyTravelOrderStatistics orderStatistics = new DailyTravelOrderStatistics();
List<OrderAccountDTO> orderAccountDTOS = map.get(RefundTypeEnum.ORDER_FUND.getCode());
List<OrderAccountDTO> orderAccountDTOS = map.get(AccountTypeEnum.IN_ORDER_PAY.getCode());
if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(orderAccountDTOS);
......@@ -276,9 +276,7 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
*/
private List<OrderAccountDeduction> gettDeductions(ArrayList<OrderAccountDetail> orderAccountDetails) {
ArrayList<OrderAccountDeduction> arrayList = Lists.newArrayList();
for (OrderAccountDetail orderAccountDetail : orderAccountDetails) {
arrayList.addAll(orderAccountDetail.getDeductions());
}
orderAccountDetails.parallelStream().map(OrderAccountDetail::getDeductions).forEach(e->arrayList.addAll(e));
return arrayList;
}
......@@ -286,14 +284,14 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
/**
* 根据type获取对应的金额总和
*
* @param OrderAccountDeduction
* @param list
* @param type 金额类型
* @return
*/
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, List<Integer> type) {
return OrderAccountDeduction.parallelStream()
.filter(el -> el.getType().equals(type))
.map(com.xxfc.platform.order.pojo.account.OrderAccountDeduction::getAmount)
private BigDecimal get(List<OrderAccountDeduction> list, List<Integer> type) {
return list.parallelStream()
.filter(el ->type.contains(el.getType()))
.map(OrderAccountDeduction::getAmount)
.reduce(BigDecimal.ZERO,BigDecimal::add);
}
......
......@@ -4,9 +4,9 @@ import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.order.contant.enumerate.AccountTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.DailyVehicleOrderStatistics;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.entity.OrderStatistics;
......@@ -208,14 +208,14 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
/**
* 根据type获取对应的金额总和
*
* @param OrderAccountDeduction
* @param list
* @param types 金额类型
* @return
*/
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, List<Integer> types) {
return OrderAccountDeduction.parallelStream()
.filter(el -> types.contains(el))
.map(com.xxfc.platform.order.pojo.account.OrderAccountDeduction::getAmount)
private BigDecimal get(List<OrderAccountDeduction> list, List<Integer> types) {
return list.parallelStream()
.filter(el -> types.contains(el.getType()))
.map(OrderAccountDeduction::getAmount)
.reduce(BigDecimal.ZERO,BigDecimal::add);
}
......@@ -241,7 +241,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
* @return
*/
@Transactional(rollbackFor = Exception.class)
public boolean saveDailyVehicleOrderRecord() {
public boolean saveDailyVehicleOrderRecord() {
try {
//获取每日订单统计
......@@ -342,7 +342,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
private void refundAndDeductions(Map<Integer, List<OrderAccountDTO>> map, DailyVehicleOrderStatistics orderStatistics) {
ArrayList<OrderAccountDTO> arrayList = Lists.newArrayList();
for (Integer key : map.keySet()) {
if (!key.equals(RefundTypeEnum.ORDER_FUND.getCode())) {
if (!key.equals(AccountTypeEnum.IN_ORDER_PAY.getCode())) {
arrayList.addAll(map.get(key));
}
}
......@@ -387,7 +387,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
*/
private DailyVehicleOrderStatistics getGmvAndSecurityDeposit(Map<Integer, List<OrderAccountDTO>> map) {
DailyVehicleOrderStatistics orderStatistics = new DailyVehicleOrderStatistics();
List<OrderAccountDTO> orderAccountDTOS = map.get(RefundTypeEnum.ORDER_FUND.getCode());
List<OrderAccountDTO> orderAccountDTOS = map.get(AccountTypeEnum.IN_ORDER_PAY.getCode());
if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(orderAccountDTOS);
......@@ -437,9 +437,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
*/
private List<OrderAccountDeduction> gettDeductions(ArrayList<OrderAccountDetail> orderAccountDetails) {
ArrayList<OrderAccountDeduction> arrayList = Lists.newArrayList();
for (OrderAccountDetail orderAccountDetail : orderAccountDetails) {
arrayList.addAll(orderAccountDetail.getDeductions());
}
orderAccountDetails.parallelStream().map(OrderAccountDetail::getDeductions).forEach(e->arrayList.addAll(e));
return arrayList;
}
......
......@@ -43,7 +43,7 @@
resultMap="order">
SELECT
<if test="type==2">
DATE_FORMAT(date( FROM_UNIXTIME( a.account_time / 1000 ) ),'%Y-%v') AS period,
DATE_FORMAT(date( FROM_UNIXTIME( a.account_time / 1000 ) ),'%x-%v') AS period,
</if>
<if test="type==3">
DATE_FORMAT(date( FROM_UNIXTIME( a.account_time / 1000 ) ),'%Y-%m') AS period,
......@@ -70,7 +70,7 @@
</if>
GROUP BY
<if test="type==2">
DATE_FORMAT(date( FROM_UNIXTIME( a.account_time / 1000 ) ),'%Y-%v'),
DATE_FORMAT(date( FROM_UNIXTIME( a.account_time / 1000 ) ),'%x-%v'),
</if>
<if test="type==3">
DATE_FORMAT(date( FROM_UNIXTIME( a.account_time / 1000 ) ),'%Y-%m'),
......
package com.xxfc.platform.vehicle.pojo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.entity.VehicleDepartureLog;
import lombok.Data;
@Data
public class DepartureLogVo extends VehicleDepartureLog {
VehicleBookRecord vehicleBookRecord;
}
......@@ -12,6 +12,7 @@ import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleDepartureLog;
import com.xxfc.platform.vehicle.mapper.VehicleDepartureLogMapper;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.DepartureLogVo;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureStatisticDataVo;
import lombok.extern.slf4j.Slf4j;
......@@ -24,6 +25,7 @@ import tk.mybatis.mapper.weekend.WeekendSqls;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
......@@ -103,6 +105,9 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
}
public Integer selectAllDepartureLog(Map<String, Object> param) {
return mapper.selectAllDepartureLog(param);
}
public ObjectRestResponse findOne(Integer vid) throws Exception {
Example exm = Example.builder(VehicleDepartureLog.class)
......
......@@ -10,4 +10,5 @@ public interface VehicleCountRecordMapper extends Mapper<VehicleCountRecord> {
List<VehicleCountRecord> countDepartureVehicle(VehicleCountRecord vehicleCountRecord);
List<VehicleCountRecord> selectByTypeAndTime(Map<String, Object> param);
List<VehicleCountRecord> selectByTime(Map<String, Object> param);
}
\ No newline at end of file
package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.VehicleDepartureLog;
import com.xxfc.platform.vehicle.pojo.DepartureLogVo;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.BaseMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
public interface VehicleDepartureLogMapper extends BaseMapper<VehicleDepartureLog>, Mapper<VehicleDepartureLog> {
......@@ -32,4 +34,5 @@ public interface VehicleDepartureLogMapper extends BaseMapper<VehicleDepartureLo
String selectDayByVehicleId(String vehicleId);
VehicleDepartureLogVo selectByBookRecordId(Long bookRecordId);
Integer selectAllDepartureLog(Map<String, Object> param);
}
......@@ -30,7 +30,7 @@ public class VehicleCountRecordController {
@GetMapping("/app/unauth/get")
@ResponseBody
public ObjectRestResponse getByTypeAndDate(VehicleCountRecord vehicleCountRecord) {
return vehicleCountRecordBiz.countDepartureVehicle(vehicleCountRecord);
return vehicleCountRecordBiz.selectByTime(vehicleCountRecord);
}
@PostMapping("/app/unauth/export")
......@@ -43,4 +43,10 @@ public class VehicleCountRecordController {
public void download(ExcelParamDto excelParamDto, HttpServletRequest request,HttpServletResponse response) {
DownloadUtil.downloadFile(excelParamDto.getPath(), "export.xls", response,request);
}
@GetMapping("/app/unauth/selectByTime")
public ObjectRestResponse selectByTime(VehicleCountRecord vehicleCountRecord) {
return vehicleCountRecordBiz.selectByTime(vehicleCountRecord);
}
}
......@@ -35,4 +35,12 @@
order by id DESC
</select>
<select id="selectByTime" parameterType = "Map" resultType="com.xxfc.platform.vehicle.entity.VehicleCountRecord">
select * from vehicle_count_record
where count_date &gt;= #{startTime} and count_date &lt;= #{endTime}
<if test="type != null">
and type = #{type}
</if>
order by id DESC
</select>
</mapper>
\ No newline at end of file
......@@ -2,7 +2,11 @@
<!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.VehicleDepartureLogMapper" >
<resultMap id="searchBookRecord" type="com.xxfc.platform.vehicle.pojo.DepartureLogVo">
<result column="book_record_id" property="bookRecordId" jdbcType="INTEGER" javaType="java.lang.Integer"/>
<association property="vehicleBookRecord" column="id"
select="com.xxfc.platform.vehicle.mapper.VehicleBookRecordMapper.selectOne"/>
</resultMap>
<select id="selectLastByVehicleId" resultType="com.xxfc.platform.vehicle.entity.VehicleDepartureLog">
select * from vehicle_departure_log
where vehicle_id = #{vehicleId}
......@@ -30,7 +34,55 @@
where vehicle_departure_log.book_record_id = #{id}
order by create_time desc
</select>
<select id="selectAllDepartureLog" resultType="java.lang.Integer" parameterType="Map">
SELECT
count(*)
FROM
vehicle_departure_log v1
LEFT JOIN vehicle_book_record v2 on v1.book_record_id = v2.id
<where>
<if test="startTime != null and status == 1">
and (v1.departure_time between #{startTime} and #{endTime})
</if>
<if test="startTime != null and status == 2">
and (v1.arrival_time between #{startTime} and #{endTime})
</if>
<!--正常出车-->
<if test="startTime != null and status == 1 and type == 1">
and (v2.book_start_date between #{startTime} and #{endTime})
</if>
<!--提前出车-->
<if test="endTime != null and status == 1 and type == 2">
and v2.book_start_date &gt;= #{endTime}
</if>
<!--延期出车-->
<if test="startTime != null and status == 1 and type == 3">
and v2.book_start_date &lt;= #{startTime}
</if>
<!--正常还车-->
<if test="startTime != null and status == 2 and type == 1">
and (v2.book_start_date between #{startTime} and #{endTime})
</if>
<!--提前还车-->
<if test="endTime != null and status == 2 and type == 2">
and v2.book_start_date &gt;= #{endTime}
</if>
<!--延期还车-->
<if test="startTime != null and status == 2 and type == 3">
and v2.book_start_date &lt;= #{startTime}
</if>
<!--统计客户用车-->
<if test="bookUser != null">
and v2.book_user = #{bookUser}
</if>
<if test="bookUser == null">
and v2.book_user != -2
</if>
</where>
</select>
<select id="selectVoAll" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.*,vehicle.number_plate,
/* IFNULL(DATEDIFF(vehicle_departure_log.arrival_time,vehicle_departure_log.departure_time),0)*/
......
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