Commit 5b555442 authored by hezhen's avatar hezhen

添加车辆排班

parent 1191470b
...@@ -1626,6 +1626,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -1626,6 +1626,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
vehicle.setManageCompanyId(vehicleApply.getSubordinateBranch()); vehicle.setManageCompanyId(vehicleApply.getSubordinateBranch());
insertSelective(vehicle); insertSelective(vehicle);
vehicleId=vehicle.getId(); vehicleId=vehicle.getId();
vehicleBookInfoBiz.addVehicleBookInfo(vehicleId);
setGoodsTypes(vehicle); setGoodsTypes(vehicle);
} }
......
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.constant.RedisKey; import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo; import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper; import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper;
...@@ -15,7 +18,7 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -15,7 +18,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -34,6 +37,13 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -34,6 +37,13 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
@Autowired @Autowired
private RedisTemplate customRedisTemplate; private RedisTemplate customRedisTemplate;
@Autowired
ThirdFeign thirdFeign;
private static final String DIC_VEHICLE_TYPE="VEHICLE";
private static final String DIC_VEHICLE_CODE="VEHICLE_JOB";
/** /**
* 迁移数据到历史表 * 迁移数据到历史表
* 每年一张表 * 每年一张表
...@@ -136,4 +146,24 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -136,4 +146,24 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
public int update(VehicleBookInfo vehicleBookInfo) { public int update(VehicleBookInfo vehicleBookInfo) {
return mapper.updateById(vehicleBookInfo); return mapper.updateById(vehicleBookInfo);
} }
public void addVehicleBookInfo(String vehicleId) {
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DIC_VEHICLE_TYPE, DIC_VEHICLE_CODE);
Integer months = Integer.valueOf(dictionary.getDetail());
LocalDate date = LocalDate.now();
for (int i = 0; i <= months; i++) {
if (i > 0){
date = date.plusMonths(i);
}
int year = date.getYear();
int month = date.getMonthValue();
String yearAndMonth = String.format("%d-%02d", year, month);
VehicleBookInfo vehicleBookInfo = new VehicleBookInfo();
vehicleBookInfo.setVehicle(vehicleId);
vehicleBookInfo.setYearMonth(yearAndMonth);
insertSelective(vehicleBookInfo);
}
}
} }
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
LEFT JOIN vehicle_category c ON v.category_id=c.id LEFT JOIN vehicle_category c ON v.category_id=c.id
LEFT JOIN branch_company i on v.subordinate_branch=i.id LEFT JOIN branch_company i on v.subordinate_branch=i.id
<where> <where>
v.is_del = 0 v.is_del = 0
<if test="dataCompanyIds != null and dataCompanyIds.size > 0"> <if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and i.id in and i.id in
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")"> <foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
......
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