Commit f6f93ed0 authored by jiaorz's avatar jiaorz

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

# Conflicts:
#	xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleActiveService.java
parents 89266e66 d74c428f
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
<artifactId>spring-boot</artifactId> <artifactId>spring-boot</artifactId>
<version>2.1.3.RELEASE</version> <version>2.1.3.RELEASE</version>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId> <artifactId>spring-cloud-openfeign-core</artifactId>
<version>2.1.0.RELEASE</version> <version>2.1.0.RELEASE</version>
...@@ -226,12 +226,12 @@ ...@@ -226,12 +226,12 @@
<artifactId>feign-core</artifactId> <artifactId>feign-core</artifactId>
<version>10.1.0</version> <version>10.1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>-->
<!-- <dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency>--> </dependency>
</dependencies> </dependencies>
......
...@@ -40,8 +40,8 @@ public class RandomUtil ...@@ -40,8 +40,8 @@ public class RandomUtil
* @param n * @param n
* @param set * @param set
*/ */
public static void randomSet(int max, int n, Set<Integer> set) { public static void randomSet(int max, int n, Set<Integer> set, int total) {
if (n > (max + 1) || max < 0) { if (n > (max) || max < 0) {
return; return;
} }
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
...@@ -50,8 +50,8 @@ public class RandomUtil ...@@ -50,8 +50,8 @@ public class RandomUtil
} }
int setSize = set.size(); int setSize = set.size();
// 如果存入的数小于指定生成的个数,则调用递归再生成剩余个数的随机数,如此循环,直到达到指定大小 // 如果存入的数小于指定生成的个数,则调用递归再生成剩余个数的随机数,如此循环,直到达到指定大小
if (setSize < n) { if (setSize < total) {
randomSet( max, n-setSize, set);// 递归 randomSet(max, total - setSize, set, total);// 递归
} }
} }
...@@ -63,9 +63,9 @@ public class RandomUtil ...@@ -63,9 +63,9 @@ public class RandomUtil
public static void main(String[] args) { public static void main(String[] args) {
int max = 20; int max = 20;
int n = 5; int n = 20;
Set<Integer> set = new HashSet<>(); Set<Integer> set = new HashSet<>();
randomSet(max, n, set); randomSet(max, n, set, n);
for(Integer a : set) { for(Integer a : set) {
System.out.println(a); System.out.println(a);
} }
......
...@@ -347,7 +347,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> { ...@@ -347,7 +347,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
return ObjectRestResponse.succ(list); return ObjectRestResponse.succ(list);
} }
Set<Integer> set = new HashSet<>(); Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set); RandomUtil.randomSet(list.size(), number, set, number);
for(Integer i : set) { for(Integer i : set) {
resultList.add(list.get(i)); resultList.add(list.get(i));
} }
......
...@@ -338,7 +338,7 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> { ...@@ -338,7 +338,7 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
return ObjectRestResponse.succ(list); return ObjectRestResponse.succ(list);
} }
Set<Integer> set = new HashSet<>(); Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set); RandomUtil.randomSet(list.size(), number, set, number);
for(Integer i : set) { for(Integer i : set) {
resultList.add(list.get(i)); resultList.add(list.get(i));
} }
......
package com.xxfc.platform.uccn.comstnt;
/**
* 访问路径
* @author Administrator
*/
public enum UrlType {
OFFICIAL_WEBSITE("官网访问",1),BACKGROUND_MANAGEMENT("后台访问",2);
private String name;
private Integer code;
UrlType(String name, Integer code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public Integer getCode() {
return code;
}
}
...@@ -10,6 +10,7 @@ import tk.mybatis.mapper.annotation.KeySql; ...@@ -10,6 +10,7 @@ import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect; import tk.mybatis.mapper.code.IdentityDialect;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.util.Date; import java.util.Date;
...@@ -26,6 +27,7 @@ public class Article { ...@@ -26,6 +27,7 @@ public class Article {
@Id @Id
@KeySql(dialect = IdentityDialect.MYSQL) @KeySql(dialect = IdentityDialect.MYSQL)
// @GeneratedValue(generator = "JDBC")
private Integer id; private Integer id;
/** /**
* 标题 * 标题
......
package com.xxfc.platform.uccn.vo;
import lombok.Data;
/**
* 新闻文章查询条件
* @author Administrator
*/
@Data
public class ArticleQuery {
private Integer page;
private Integer limit;
// private String newsContent;
}
...@@ -3,8 +3,10 @@ package com.xxfc.platform.uccn.biz; ...@@ -3,8 +3,10 @@ package com.xxfc.platform.uccn.biz;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.uccn.comstnt.UrlType;
import com.xxfc.platform.uccn.entity.Article; import com.xxfc.platform.uccn.entity.Article;
import com.xxfc.platform.uccn.mapper.ArticleMapper; import com.xxfc.platform.uccn.mapper.ArticleMapper;
import com.xxfc.platform.uccn.vo.ArticleQuery;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
...@@ -21,16 +23,17 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -21,16 +23,17 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/** /**
* 随机文章条数 * 随机文章条数
*/ */
private final Integer RANDOM_NUMBER=3; private final Integer RANDOM_NUMBER = 3;
/** /**
* 首页文章条数 * 首页文章条数
*/ */
private final Integer HOME_PAGE_NUMBER=4; private final Integer HOME_PAGE_NUMBER = 4;
/** /**
* 文章列表 * 文章列表
*
* @param page * @param page
* @param limit * @param limit
* @param type * @param type
...@@ -43,24 +46,28 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -43,24 +46,28 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
} }
/** /**
* 获取一条数据 * 获取一条数据
*
* @param id * @param id
* @param urlType
* @return * @return
*/ */
public Article getOne(Integer id) { public Article getOne(Integer id, Integer urlType) {
Example example = Example.builder(Article.class).where(
WeekendSqls.<Article>custom() Example example = new Example(Article.class);
.andEqualTo(Article::getId,id) Example.Criteria criteria = example.createCriteria();
.andEqualTo(Article::getIsDel, 0) criteria.andEqualTo("id", id);
.andEqualTo(Article::getStatus, 1) criteria.andEqualTo("isDel", 0);
).build(); if (UrlType.OFFICIAL_WEBSITE.getCode().equals(urlType)) {
Article article = mapper.selectOneByExample(example); criteria.andEqualTo("status", 1);
return article; }
return mapper.selectOneByExample(example);
} }
/** /**
* 随机获取三条连续的文章 * 随机获取三条连续的文章
*
* @param type * @param type
* @return * @return
*/ */
...@@ -69,14 +76,14 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -69,14 +76,14 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
List<Article> articleList = mapper.getArticleList(type); List<Article> articleList = mapper.getArticleList(type);
if (!Objects.isNull(articleList)) { if (!Objects.isNull(articleList)) {
int size = articleList.size(); int size = articleList.size();
if (RANDOM_NUMBER>=size) { if (RANDOM_NUMBER >= size) {
return articleList; return articleList;
}else { } else {
Random random = new Random(); Random random = new Random();
int r = random.nextInt(size -RANDOM_NUMBER+1); int r = random.nextInt(size - RANDOM_NUMBER + 1);
List<Article> result = new ArrayList<>(); List<Article> result = new ArrayList<>();
for (int i=0;i<RANDOM_NUMBER.intValue();i++){ for (int i = 0; i < RANDOM_NUMBER.intValue(); i++) {
int index= i+r; int index = i + r;
result.add(articleList.get(index)); result.add(articleList.get(index));
} }
return result; return result;
...@@ -88,17 +95,18 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -88,17 +95,18 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/** /**
* 首页文章列表 * 首页文章列表
*
* @param type * @param type
* @return * @return
*/ */
public List getHomePageArticle(Integer type){ public List getHomePageArticle(Integer type) {
List<Article> articleList = mapper.getArticleList(type); List<Article> articleList = mapper.getArticleList(type);
if (Objects.isNull(articleList)) { if (Objects.isNull(articleList)) {
return new ArrayList(); return new ArrayList();
}else { } else {
if (articleList.size()>HOME_PAGE_NUMBER) { if (articleList.size() > HOME_PAGE_NUMBER) {
return articleList.subList(0,HOME_PAGE_NUMBER); return articleList.subList(0, HOME_PAGE_NUMBER);
}else { } else {
return articleList; return articleList;
} }
} }
...@@ -106,19 +114,64 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -106,19 +114,64 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void add(Article article) { public void add(Article article) {
if (article==null) { if (article == null) {
return; return;
} }
article.setIsDel(0); article.setIsDel(0);
if (article.getStatus()==null){ if (article.getStatus() == null) {
article.setStatus(0); article.setStatus(0);
} }
if (article.getType()==null){ if (article.getType() == null) {
article.setType(0); article.setType(0);
} }
article.setCreTime(new Date()); article.setCreTime(new Date());
mapper.insertSelective(article); mapper.insertSelective(article);
} }
public PageInfo findAll(ArticleQuery query) {
PageHelper.startPage(query.getPage(),query.getLimit());
Example exa = Example.builder(Article.class).where(
WeekendSqls.<Article>custom()
.andEqualTo(Article::getIsDel,0)
).orderByAsc("weight").orderByDesc("addTime").build();
List<Article> articles = mapper.selectByExample(exa);
return PageInfo.of(articles);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int updateSelectiveByIdRe(Article article){
article.setUpdTime(new Date());
return mapper.updateByPrimaryKeySelective(article);
}
public int putaway(Integer id) {
Article article = new Article();
article.setId(id);
article.setUpdTime(new Date());
article.setAddTime(new Date());
article.setStatus(1);
return mapper.updateByPrimaryKeySelective(article);
}
public int soldOut(Integer id) {
Article article = new Article();
article.setId(id);
article.setUpdTime(new Date());
article.setStatus(0);
return mapper.updateByPrimaryKeySelective(article);
}
public int remove(Integer id) {
Article article = new Article();
article.setId(id);
article.setUpdTime(new Date());
article.setIsDel(1);
return mapper.updateByPrimaryKeySelective(article);
}
} }
...@@ -194,7 +194,7 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv ...@@ -194,7 +194,7 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
} }
} else { } else {
Set<Integer> resultSet = new HashSet<>(); Set<Integer> resultSet = new HashSet<>();
RandomUtil.randomSet(summitActivities.size(), num, resultSet); RandomUtil.randomSet(summitActivities.size(), num, resultSet, num);
for (Integer i : resultSet) { for (Integer i : resultSet) {
summitActivityVo = new SummitActivityVo(); summitActivityVo = new SummitActivityVo();
SummitActivity summitActivity = summitActivities.get(i); SummitActivity summitActivity = summitActivities.get(i);
......
...@@ -4,12 +4,11 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -4,12 +4,11 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.uccn.biz.ArticleBiz; import com.xxfc.platform.uccn.biz.ArticleBiz;
import com.xxfc.platform.uccn.entity.Article; import com.xxfc.platform.uccn.entity.Article;
import com.xxfc.platform.uccn.vo.ArticleQuery;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map;
/** /**
* 文章 * 文章
...@@ -21,29 +20,30 @@ import java.util.Map; ...@@ -21,29 +20,30 @@ import java.util.Map;
@Api(tags = {"文章"}) @Api(tags = {"文章"})
public class ArticleController extends BaseController<ArticleBiz, Article> { public class ArticleController extends BaseController<ArticleBiz, Article> {
@GetMapping("/list") @GetMapping("/app/unauth/list")
@ApiOperation(value = "获取文章列表") @ApiOperation(value = "获取文章列表")
public ObjectRestResponse getArticleList( public ObjectRestResponse getArticleList(
@RequestParam(name = "page", defaultValue = "1") Integer page, @RequestParam(name = "page", defaultValue = "1") Integer page,
@RequestParam(name = "limit", defaultValue = "10") Integer limit, @RequestParam(name = "limit", defaultValue = "10") Integer limit,
@RequestParam(name = "type", defaultValue = "0") Integer type) { @RequestParam(name = "type", defaultValue = "1") Integer type) {
return ObjectRestResponse.succ(baseBiz.getArticleList(page, limit, type)); return ObjectRestResponse.succ(baseBiz.getArticleList(page, limit, type));
} }
@GetMapping("/one/{id}") @GetMapping("/app/unauth/one")
@ApiOperation(value = "获取一条数据") @ApiOperation(value = "获取一条数据")
public ObjectRestResponse getOne(@PathVariable Integer id) { public ObjectRestResponse getOne(@RequestParam Integer id,
return ObjectRestResponse.succ(baseBiz.getOne(id)); @RequestParam(required = false) Integer urlType) {
return ObjectRestResponse.succ(baseBiz.getOne(id,urlType));
} }
@GetMapping("/three/{type}") @GetMapping("/app/unauth/three/{type}")
@ApiOperation(value = "随机获取三条数据") @ApiOperation(value = "随机获取三条数据")
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type){ public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type){
return ObjectRestResponse.succ(baseBiz.getThree(type)); return ObjectRestResponse.succ(baseBiz.getThree(type));
} }
@GetMapping("/homePage/{type}") @GetMapping("/app/unauth/homePage/{type}")
@ApiOperation(value = "获取首页文章列表") @ApiOperation(value = "获取首页文章列表")
public ObjectRestResponse getHomePageArticle(@PathVariable Integer type){ public ObjectRestResponse getHomePageArticle(@PathVariable Integer type){
return ObjectRestResponse.succ(baseBiz.getHomePageArticle(type)); return ObjectRestResponse.succ(baseBiz.getHomePageArticle(type));
...@@ -51,11 +51,58 @@ public class ArticleController extends BaseController<ArticleBiz, Article> { ...@@ -51,11 +51,58 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
@Override @Override
@PostMapping("/add") @PostMapping("/add")
@ApiOperation(value = "获取首页文章列表") @ApiOperation(value = "添加")
public ObjectRestResponse add(@RequestBody Article article){ public ObjectRestResponse add(@RequestBody Article article){
baseBiz.add(article); baseBiz.add(article);
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
@PostMapping("/all")
@ApiOperation(value = "获取新闻列表")
public ObjectRestResponse<Article> findAll(@RequestBody ArticleQuery query){
return ObjectRestResponse.succ(baseBiz.findAll(query));
}
@Override
@PutMapping("/update")
@ApiOperation(value = "修改")
public ObjectRestResponse update(@RequestBody Article article){
int flag = baseBiz.updateSelectiveByIdRe(article);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@PutMapping("/putaway/{id}")
@ApiOperation(value = "上架")
public ObjectRestResponse putaway(@PathVariable Integer id){
int flag = baseBiz.putaway(id);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@PutMapping("/soldOut/{id}")
@ApiOperation(value = "下架")
public ObjectRestResponse soldOut(@PathVariable Integer id){
int flag = baseBiz.soldOut(id);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@PutMapping("/remove/{id}")
@ApiOperation(value = "删除")
public ObjectRestResponse remove(@PathVariable Integer id){
int flag = baseBiz.remove(id);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
} }
...@@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/tour") @RequestMapping("app/unauth/tour")
@Slf4j @Slf4j
@IgnoreClientToken @IgnoreClientToken
public class GwTourController extends CommonBaseController { public class GwTourController extends CommonBaseController {
......
...@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; ...@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController; import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.VModelDetailVO; import com.xxfc.platform.vehicle.pojo.VModelDetailVO;
...@@ -52,9 +53,10 @@ public class VehicleModelController extends CommonBaseController { ...@@ -52,9 +53,10 @@ public class VehicleModelController extends CommonBaseController {
* @return * @return
*/ */
@ApiOperation("车型列表") @ApiOperation("车型列表")
@PostMapping(value = "/findVehicleModelPage") @GetMapping(value = "/findVehicleModelPage")
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<VehicleModelVo> findVehicleModelPageUnauthfind(@RequestBody VehicleModelQueryCondition vmqc) { public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(VehicleModelQueryCondition vmqc) {
return vehicleFeign.findVehicleModelPageUnauthfind(vmqc); ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc);
return objectRestResponse;
} }
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<select id="getArticleList" resultType="com.xxfc.platform.uccn.entity.Article"> <select id="getArticleList" resultType="com.xxfc.platform.uccn.entity.Article">
select title,epitome,add_time,cover_image from article select title,epitome,add_time,cover_image from article
where is_del=0 and status=1 and (type=#{type} or type=0) order by weight DESC,add_time DESC where is_del=0 and status=1 and (type=#{type} or type=0) order by weight ASC ,add_time DESC
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.feign; ...@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.pojo.*; import com.xxfc.platform.vehicle.pojo.*;
...@@ -133,5 +134,5 @@ public interface VehicleFeign { ...@@ -133,5 +134,5 @@ public interface VehicleFeign {
ObjectRestResponse<VModelDetailVO> detailByParam(@RequestParam("vehicleModel") Map<String, Object> vehicleModel); ObjectRestResponse<VModelDetailVO> detailByParam(@RequestParam("vehicleModel") Map<String, Object> vehicleModel);
@PostMapping("/vehicleModel/app/unauth/findVehicleModelPage") @PostMapping("/vehicleModel/app/unauth/findVehicleModelPage")
public ObjectRestResponse<VehicleModelVo> findVehicleModelPageUnauthfind(@RequestBody VehicleModelQueryCondition vmqc); public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(@RequestBody VehicleModelQueryCondition vmqc);
} }
...@@ -85,7 +85,6 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -85,7 +85,6 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
private VehicleBiz vehicleBiz; private VehicleBiz vehicleBiz;
/** /**
* 按主键获取公司 * 按主键获取公司
* *
...@@ -120,7 +119,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -120,7 +119,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
* @param id * @param id
* @return * @return
*/ */
@Cache(key = RedisKey.BRANCH_COMPANY_CACHE+ "{1}") @Cache(key = RedisKey.BRANCH_COMPANY_CACHE + "{1}")
public CompanyDetail getDetailById(Integer id) { public CompanyDetail getDetailById(Integer id) {
BranchCompany branchCompany = this.getById(id); BranchCompany branchCompany = this.getById(id);
CompanyDetail detail = null; CompanyDetail detail = null;
...@@ -161,35 +160,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -161,35 +160,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
} }
public PageDataVO<BranchCompany> getAll(Integer page, Integer limit, Integer addrProvince, Integer addrCity, public PageDataVO<BranchCompany> getAll(Integer page, Integer limit, Integer addrProvince, Integer addrCity,
Integer addrTown,Integer zoneId, UserDTO userDTO) { Integer addrTown, Integer zoneId, UserDTO userDTO) {
Example example = new Example(BranchCompany.class); Example example = new Example(BranchCompany.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
String provinceIds=""; String provinceIds = "";
if (Objects.nonNull(zoneId)){ if (Objects.nonNull(zoneId)) {
Area area = areaBiz.selectById(zoneId); Area area = areaBiz.selectById(zoneId);
provinceIds = area.getProvinceIds(); provinceIds = area.getProvinceIds();
} }
if (StringUtils.isNotEmpty(provinceIds)){ if (StringUtils.isNotEmpty(provinceIds)) {
List<String> provinceIdList = Arrays.asList(provinceIds.split(",")); List<String> provinceIdList = Arrays.asList(provinceIds.split(","));
if (Objects.nonNull(addrProvince)){ if (Objects.nonNull(addrProvince)) {
if (provinceIdList.contains(String.valueOf(addrProvince))){ if (provinceIdList.contains(String.valueOf(addrProvince))) {
criteria.andEqualTo("addrProvince",addrProvince); criteria.andEqualTo("addrProvince", addrProvince);
}else { } else {
return new PageDataVO<BranchCompany>(); return new PageDataVO<BranchCompany>();
} }
}else { } else {
criteria.andIn("addrProvince",provinceIdList); criteria.andIn("addrProvince", provinceIdList);
} }
}else { } else {
if (addrProvince != null) { if (addrProvince != null) {
criteria.andEqualTo("addrProvince",addrProvince); criteria.andEqualTo("addrProvince", addrProvince);
} }
} }
if (addrCity != null) { if (addrCity != null) {
criteria.andEqualTo("addrCity",addrCity); criteria.andEqualTo("addrCity", addrCity);
} }
if (addrTown != null) { if (addrTown != null) {
criteria.andEqualTo("addrTown",addrTown); criteria.andEqualTo("addrTown", addrTown);
} }
if (userDTO != null && DATA_ALL_FALSE.equals(userDTO.getDataAll())) { if (userDTO != null && DATA_ALL_FALSE.equals(userDTO.getDataAll())) {
if (StringUtils.isNotBlank(userDTO.getDataZone())) { if (StringUtils.isNotBlank(userDTO.getDataZone())) {
...@@ -361,15 +360,15 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -361,15 +360,15 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
} }
public Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(List<Integer> companyIds) { public Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(List<Integer> companyIds) {
Map<Integer,BranComanyLeaderVo> companyIdAndLeaderMap = new HashMap<>(companyIds.size()); Map<Integer, BranComanyLeaderVo> companyIdAndLeaderMap = new HashMap<>(companyIds.size());
List<BranchCompany> branchCompanies = mapper.selectByIdList(companyIds); List<BranchCompany> branchCompanies = mapper.selectByIdList(companyIds);
if (CollectionUtils.isEmpty(branchCompanies)){ if (CollectionUtils.isEmpty(branchCompanies)) {
return companyIdAndLeaderMap; return companyIdAndLeaderMap;
} }
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,branchCompany -> { return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId, branchCompany -> {
BranComanyLeaderVo branComanyLeaderVo = new BranComanyLeaderVo(); BranComanyLeaderVo branComanyLeaderVo = new BranComanyLeaderVo();
BeanUtils.copyProperties(branchCompany,branComanyLeaderVo); BeanUtils.copyProperties(branchCompany, branComanyLeaderVo);
return branComanyLeaderVo; return branComanyLeaderVo;
})); }));
} }
...@@ -377,14 +376,14 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -377,14 +376,14 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
PageDataVO<BranchCompanyListVO> pageDataVO = new PageDataVO<>(); PageDataVO<BranchCompanyListVO> pageDataVO = new PageDataVO<>();
PageDataVO<BranchCompanyListDTO> dataVO = PageDataVO.pageInfo(branchCompanyFindDTO.getPage(), branchCompanyFindDTO.getLimit(), () -> mapper.findBranchCompanys(branchCompanyFindDTO.getAddrProvince(), branchCompanyFindDTO.getAddrCity())); PageDataVO<BranchCompanyListDTO> dataVO = PageDataVO.pageInfo(branchCompanyFindDTO.getPage(), branchCompanyFindDTO.getLimit(), () -> mapper.findBranchCompanys(branchCompanyFindDTO.getAddrProvince(), branchCompanyFindDTO.getAddrCity()));
List<BranchCompanyListDTO> data = dataVO.getData(); List<BranchCompanyListDTO> data = dataVO.getData();
if (CollectionUtils.isEmpty(data)){ if (CollectionUtils.isEmpty(data)) {
return pageDataVO; return pageDataVO;
} }
List<BranchCompanyListVO> branchCompanyListVOS = new ArrayList<>(); List<BranchCompanyListVO> branchCompanyListVOS = new ArrayList<>();
BranchCompanyListVO branchCompanyListVO; BranchCompanyListVO branchCompanyListVO;
for (BranchCompanyListDTO companyListDTO : data) { for (BranchCompanyListDTO companyListDTO : data) {
branchCompanyListVO = new BranchCompanyListVO(); branchCompanyListVO = new BranchCompanyListVO();
BeanUtils.copyProperties(companyListDTO,branchCompanyListVO); BeanUtils.copyProperties(companyListDTO, branchCompanyListVO);
branchCompanyListVOS.add(branchCompanyListVO); branchCompanyListVOS.add(branchCompanyListVO);
} }
pageDataVO.setData(branchCompanyListVOS); pageDataVO.setData(branchCompanyListVOS);
......
...@@ -41,19 +41,19 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -41,19 +41,19 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd"); public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate, Boolean notCheckTimeLegal) { public Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate, Boolean notCheckTimeLegal) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null; Date startDate = null;
Date endDate = null; Date endDate = null;
try{ try {
startDate = simpleDateFormat.parse(bookStartDate); startDate = simpleDateFormat.parse(bookStartDate);
endDate = simpleDateFormat.parse(bookEndDate); endDate = simpleDateFormat.parse(bookEndDate);
}catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//判定时间是否合法 //判定时间是否合法
if(!Boolean.TRUE.equals(notCheckTimeLegal)) { if (!Boolean.TRUE.equals(notCheckTimeLegal)) {
if (bookStartDate.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER)) < 0) { if (bookStartDate.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER)) < 0) {
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY); throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
} }
...@@ -78,17 +78,17 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -78,17 +78,17 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
} }
DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
if(startPredictableHour == 0) { //如果是0点就直接预订全天 if (startPredictableHour == 0) { //如果是0点就直接预订全天
startPredictableHour = 16777215; startPredictableHour = 16777215;
} }
if(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定 if (DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定
//如果开始时间是0点开始 //如果开始时间是0点开始
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour);
} else { //非同一天开始 } else { //非同一天开始
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour); predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour);
} }
if(endDay.getMillis() - startDay.getMillis() > 24 * 3600 * 1000 ){ // if (endDay.getMillis() - startDay.getMillis() > 24 * 3600 * 1000) { //
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) { for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
String curDateStr = curDate.toString(DATE_TIME_FORMATTER); String curDateStr = curDate.toString(DATE_TIME_FORMATTER);
//全天预定 //全天预定
...@@ -115,14 +115,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -115,14 +115,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
@Transactional @Transactional
@CacheClear(key = "vehicle.hourInfo") @CacheClear(key = "vehicle.hourInfo")
public ObjectRestResponse save(VehicleBookHourInfoDto vehicleBookHourInfoDto) { public ObjectRestResponse save(VehicleBookHourInfoDto vehicleBookHourInfoDto) {
if(vehicleBookHourInfoDto == null) { if (vehicleBookHourInfoDto == null) {
return ObjectRestResponse.paramIsEmpty(); return ObjectRestResponse.paramIsEmpty();
} }
List<VehicleBookHourInfo> vehicleBookHourInfos = mapper.selectByVehicleAndDate(vehicleBookHourInfoDto); List<VehicleBookHourInfo> vehicleBookHourInfos = mapper.selectByVehicleAndDate(vehicleBookHourInfoDto);
//有数据直接更新 //有数据直接更新
if(vehicleBookHourInfos.size() >=1) { if (vehicleBookHourInfos.size() >= 1) {
for(VehicleBookHourInfo vehicleBookHourInfo : vehicleBookHourInfos) { for (VehicleBookHourInfo vehicleBookHourInfo : vehicleBookHourInfos) {
if(vehicleBookHourInfo.getBookedHour().equals(vehicleBookHourInfoDto.getBookedHour())) { if (vehicleBookHourInfo.getBookedHour().equals(vehicleBookHourInfoDto.getBookedHour())) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_IS_BOOKED_TODAY.getCode(), ResCode.VEHICLE_IS_BOOKED_TODAY.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_IS_BOOKED_TODAY.getCode(), ResCode.VEHICLE_IS_BOOKED_TODAY.getDesc());
} else { } else {
vehicleBookHourInfo.setBookedHour(vehicleBookHourInfo.getBookedHour() | vehicleBookHourInfoDto.getBookedHour()); vehicleBookHourInfo.setBookedHour(vehicleBookHourInfo.getBookedHour() | vehicleBookHourInfoDto.getBookedHour());
...@@ -138,6 +138,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -138,6 +138,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
/** /**
* 删除预定车辆小时记录信息 * 删除预定车辆小时记录信息
*
* @param vehicleId 车辆Id * @param vehicleId 车辆Id
* @param dateList 日期列表 * @param dateList 日期列表
* @return * @return
...@@ -145,7 +146,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -145,7 +146,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
@Transactional @Transactional
@CacheClear(key = "vehicle.hourInfo") @CacheClear(key = "vehicle.hourInfo")
public ObjectRestResponse delete(String vehicleId, List<String> dateList) { public ObjectRestResponse delete(String vehicleId, List<String> dateList) {
if(StringUtils.isBlank(vehicleId) || dateList.size() <= 0) { if (StringUtils.isBlank(vehicleId) || dateList.size() <= 0) {
return ObjectRestResponse.paramIsEmpty(); return ObjectRestResponse.paramIsEmpty();
} }
Map<String, Object> param = Maps.newHashMap(); Map<String, Object> param = Maps.newHashMap();
...@@ -156,15 +157,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -156,15 +157,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse checkBookHourInfo() { public ObjectRestResponse checkBookHourInfo() {
List<VehicleBookHourInfoDto> vehicleBookHourInfos = new ArrayList<>(); List<VehicleBookHourInfoDto> vehicleBookHourInfos = new ArrayList<>();
List<VehicleBookRecord> list = vehicleBookRecordBiz.selectListAll(); List<VehicleBookRecord> list = vehicleBookRecordBiz.selectListAll();
if(CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
for(VehicleBookRecord vehicleBookRecord : list) { for (VehicleBookRecord vehicleBookRecord : list) {
VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId()); VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
if((vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) && (vehicleBookRecord.getStatus() == 2 || vehicleBookRecord.getStatus() == 1)) { //未出车或未还车 if ((vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) && (vehicleBookRecord.getStatus() == 2 || vehicleBookRecord.getStatus() == 1)) { //未出车或未还车
Map<String, Integer> map = getPredictableHours(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER), new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER), Boolean.TRUE); Map<String, Integer> map = getPredictableHours(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER), new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER), Boolean.TRUE);
for(Map.Entry<String, Integer> entry : map.entrySet()) { for (Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(vehicleBookRecord.getVehicleId()); vehicleBookHourInfoDto.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey()); vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
...@@ -204,10 +205,10 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -204,10 +205,10 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception {
VehicleBookHourInfoBiz vehicleBookHourInfoBiz = new VehicleBookHourInfoBiz(); VehicleBookHourInfoBiz vehicleBookHourInfoBiz = new VehicleBookHourInfoBiz();
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours("2019-08-26 10:00:00", "2019-08-27 10:00:00", Boolean.TRUE); Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours("2019-08-26 10:00:00", "2019-08-27 10:00:00", Boolean.TRUE);
for(Map.Entry<String, Integer> entry : map.entrySet()) { for (Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey()); System.out.println(entry.getKey());
System.out.println(entry.getValue()); System.out.println(entry.getValue());
} }
......
...@@ -29,7 +29,7 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -29,7 +29,7 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
public static final DateTimeFormatter YEARMONTH_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM"); public static final DateTimeFormatter YEARMONTH_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM");
public static final Integer DEL_BATCH_SIZE = 1000; public static final Integer DEL_BATCH_SIZE = 1000;
public static final Integer COPY_BATCH_SIZE = 100; public static final Integer COPY_BATCH_SIZE = 100;
public static final int MONTH_INTERVAL=2; public static final int MONTH_INTERVAL = 2;
@Autowired @Autowired
private RedisTemplate customRedisTemplate; private RedisTemplate customRedisTemplate;
...@@ -40,14 +40,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -40,14 +40,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
*/ */
@Scheduled(cron = "0 0 0 1 * ?")//每月1号0点触发 @Scheduled(cron = "0 0 0 1 * ?")//每月1号0点触发
@Transactional @Transactional
public void transfer2HistoryTb(){ public void transfer2HistoryTb() {
//获取表格名称 //获取表格名称
String tbName = getTbNameNow(); String tbName = getTbNameNow();
DateTime now = DateTime.now();//当前获取的时间为标准 DateTime now = DateTime.now();//当前获取的时间为标准
log.info("开始预定信息迁移至历史表的定时任务。"); log.info("开始预定信息迁移至历史表的定时任务。");
//每月初将上月数据复制到历史表 //每月初将上月数据复制到历史表
Boolean needRun= copyDataLastMoth(now,tbName); Boolean needRun = copyDataLastMoth(now, tbName);
if(needRun) { if (needRun) {
//每月初将上上月数据从当前信息表中删除 //每月初将上上月数据从当前信息表中删除
delDataTheMonthBeforeLast(now, tbName); delDataTheMonthBeforeLast(now, tbName);
} }
...@@ -57,14 +57,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -57,14 +57,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
* 获取上月数据,并复制到历史表 * 获取上月数据,并复制到历史表
*/ */
@Transactional @Transactional
public Boolean copyDataLastMoth(DateTime now,String tbName){ public Boolean copyDataLastMoth(DateTime now, String tbName) {
String lastMonthStr = now.plusMonths(-1).toString(YEARMONTH_DATE_TIME_FORMATTER); String lastMonthStr = now.plusMonths(-1).toString(YEARMONTH_DATE_TIME_FORMATTER);
String redisKey = RedisKey.DEL_BOOK_INFO_LOCK_PREFIX +lastMonthStr; String redisKey = RedisKey.DEL_BOOK_INFO_LOCK_PREFIX + lastMonthStr;
Boolean hasSuc = customRedisTemplate.opsForValue().setIfAbsent(redisKey,String.valueOf(DateTime.now().getMillis())); Boolean hasSuc = customRedisTemplate.opsForValue().setIfAbsent(redisKey, String.valueOf(DateTime.now().getMillis()));
if(hasSuc){//设置1天后过期 if (hasSuc) {//设置1天后过期
customRedisTemplate.expire(redisKey,1, TimeUnit.DAYS); customRedisTemplate.expire(redisKey, 1, TimeUnit.DAYS);
}else{ } else {
log.info("[预定信息迁移]乐观锁获取失败,该线程不执行任务。"); log.info("[预定信息迁移]乐观锁获取失败,该线程不执行任务。");
return Boolean.FALSE; return Boolean.FALSE;
} }
...@@ -78,9 +78,9 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -78,9 +78,9 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
params.put("pageStart", (curPageNo - 1) * COPY_BATCH_SIZE); params.put("pageStart", (curPageNo - 1) * COPY_BATCH_SIZE);
params.put("pageSize", COPY_BATCH_SIZE); params.put("pageSize", COPY_BATCH_SIZE);
vehicleBookInfoList = mapper.getByPage4YearMonth(params); vehicleBookInfoList = mapper.getByPage4YearMonth(params);
if(CollectionUtils.isNotEmpty(vehicleBookInfoList)){ if (CollectionUtils.isNotEmpty(vehicleBookInfoList)) {
//插入数据到历史表 //插入数据到历史表
for(VehicleBookInfo vehicleBookInfo : vehicleBookInfoList){ for (VehicleBookInfo vehicleBookInfo : vehicleBookInfoList) {
Map<String, Object> insertHisParams = Maps.newHashMap(); Map<String, Object> insertHisParams = Maps.newHashMap();
insertHisParams.put("tbName", tbName); insertHisParams.put("tbName", tbName);
insertHisParams.put("id", vehicleBookInfo.getId()); insertHisParams.put("id", vehicleBookInfo.getId());
...@@ -91,17 +91,18 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -91,17 +91,18 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
} }
} }
curPageNo++; curPageNo++;
log.info("【复制上月预定信息至历史表中】,当前复制页【"+curPageNo+"】,页大小【"+COPY_BATCH_SIZE+"】"); log.info("【复制上月预定信息至历史表中】,当前复制页【" + curPageNo + "】,页大小【" + COPY_BATCH_SIZE + "】");
}while(CollectionUtils.isNotEmpty(vehicleBookInfoList)); } while (CollectionUtils.isNotEmpty(vehicleBookInfoList));
log.info("复制上月预定信息至历史表中完成,总页数【"+(curPageNo-1)+"】"); log.info("复制上月预定信息至历史表中完成,总页数【" + (curPageNo - 1) + "】");
; return Boolean.TRUE; ;
return Boolean.TRUE;
} }
/** /**
* 删除上上月数据 * 删除上上月数据
*/ */
@Transactional @Transactional
public void delDataTheMonthBeforeLast(DateTime now,String tbName){ public void delDataTheMonthBeforeLast(DateTime now, String tbName) {
String theMonthBeforeLastStr = now.plusMonths(-2).toString(YEARMONTH_DATE_TIME_FORMATTER); String theMonthBeforeLastStr = now.plusMonths(-2).toString(YEARMONTH_DATE_TIME_FORMATTER);
Integer effected = 0; Integer effected = 0;
Integer total = 0; Integer total = 0;
...@@ -110,21 +111,21 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo ...@@ -110,21 +111,21 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
params.put("batchSize", DEL_BATCH_SIZE); params.put("batchSize", DEL_BATCH_SIZE);
do { do {
effected = mapper.del4YearMoth(params); effected = mapper.del4YearMoth(params);
total+=effected; total += effected;
log.info("开始删除预定信息数据,删除总数【"+total+"】"); log.info("开始删除预定信息数据,删除总数【" + total + "】");
}while(effected!=0); } while (effected != 0);
log.info("删除预定信息数据完成"); log.info("删除预定信息数据完成");
} }
private String getTbNameNow(){ private String getTbNameNow() {
return TB_NAME_PREFIX+ DateTime.now().toString(YEAR_DATE_TIME_FORMATTER); return TB_NAME_PREFIX + DateTime.now().toString(YEAR_DATE_TIME_FORMATTER);
} }
/** /**
* 创建当年相关表格 * 创建当年相关表格
*/ */
private void createTbIfNotExists(String tbName){ private void createTbIfNotExists(String tbName) {
mapper.createTbIfNotExists(tbName); mapper.createTbIfNotExists(tbName);
} }
......
...@@ -201,7 +201,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -201,7 +201,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo); PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo); vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize); vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long)vehicleBookRecordVoPageInfo.getList().size()); vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize); vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize)); vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO); return RestResponse.suc(vehicleBookRecordVoPageDataVO);
...@@ -212,7 +212,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -212,7 +212,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
} }
public void removeStatus2(List<VehicleBookRecordVo> list) { public void removeStatus2(List<VehicleBookRecordVo> list) {
if(list != null && list.size() > 0) { if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator(); Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
if (iterator.next().getVehicleDepartureLogVo() != null) { if (iterator.next().getVehicleDepartureLogVo() != null) {
...@@ -360,29 +360,30 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -360,29 +360,30 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
/** /**
* 检验数据库预定记录日期是否和时间,日期表中的二进制数据一致 * 检验数据库预定记录日期是否和时间,日期表中的二进制数据一致
*
* @return * @return
*/ */
public ObjectRestResponse checkDateInvalide(){ public ObjectRestResponse checkDateInvalide() {
List<VehicleBookRecord> list = mapper.selectAll(); List<VehicleBookRecord> list = mapper.selectAll();
List<VehicleBookRecord> unRightList = new ArrayList<>(); List<VehicleBookRecord> unRightList = new ArrayList<>();
if(list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for(VehicleBookRecord vehicleBookRecord : list) { for (VehicleBookRecord vehicleBookRecord : list) {
log.info("vehicleBookRecord = {}", vehicleBookRecord); log.info("vehicleBookRecord = {}", vehicleBookRecord);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(DateUtil.dateToStr(vehicleBookRecord.getBookStartDate(), "yyyy-MM-dd HH:mm:ss"), DateUtil.dateToStr(vehicleBookRecord.getBookStartDate(), "yyyy-MM-dd HH:mm:ss"), Boolean.TRUE); Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(DateUtil.dateToStr(vehicleBookRecord.getBookStartDate(), "yyyy-MM-dd HH:mm:ss"), DateUtil.dateToStr(vehicleBookRecord.getBookStartDate(), "yyyy-MM-dd HH:mm:ss"), Boolean.TRUE);
log.info("转换为时间二进制:map = {}", map); log.info("转换为时间二进制:map = {}", map);
//检验数据有效性 //检验数据有效性
if(vehicleBookRecord.getStatus() == 2) { if (vehicleBookRecord.getStatus() == 2) {
VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId()); VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
if(vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) { //未出车或未还车 if (vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) { //未出车或未还车
for(Map.Entry<String, Integer> entry : map.entrySet()) { for (Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(vehicleBookRecord.getVehicleId()); vehicleBookHourInfoDto.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey()); vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto); List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
log.info("预定时间信息:vehicleBookHourInfos = {}", vehicleBookHourInfos); log.info("预定时间信息:vehicleBookHourInfos = {}", vehicleBookHourInfos);
if(vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) { if (vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) {
//检验数据是否存在 //检验数据是否存在
if((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) == entry.getValue()) { if ((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) == entry.getValue()) {
log.info("时间正确,已经存在"); log.info("时间正确,已经存在");
} else { } else {
log.info("时间不正确"); log.info("时间不正确");
......
...@@ -86,7 +86,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, ...@@ -86,7 +86,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
} else { } else {
vehicleDepartureLog.setUpdateTime(new Date()); vehicleDepartureLog.setUpdateTime(new Date());
VehicleDepartureLog oldValue = mapper.selectByPrimaryKey(vehicleDepartureLog); VehicleDepartureLog oldValue = mapper.selectByPrimaryKey(vehicleDepartureLog);
if(oldValue != null) { if (oldValue != null) {
log.info("更新出行记录: vehicleDepartureLog = {}", oldValue); log.info("更新出行记录: vehicleDepartureLog = {}", oldValue);
BeanUtil.copyProperties(vehicleDepartureLog, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(vehicleDepartureLog, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
oldValue.setUpdateTime(new Date()); oldValue.setUpdateTime(new Date());
...@@ -104,7 +104,6 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, ...@@ -104,7 +104,6 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
} }
public ObjectRestResponse findOne(Integer vid) throws Exception { public ObjectRestResponse findOne(Integer vid) throws Exception {
Example exm = Example.builder(VehicleDepartureLog.class) Example exm = Example.builder(VehicleDepartureLog.class)
.where(WeekendSqls.<VehicleDepartureLog>custom() .where(WeekendSqls.<VehicleDepartureLog>custom()
...@@ -116,7 +115,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, ...@@ -116,7 +115,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
List<VehicleDepartureLog> vehicleDepartureLogs = mapper.selectByExample(exm); List<VehicleDepartureLog> vehicleDepartureLogs = mapper.selectByExample(exm);
if (vehicleDepartureLogs.size() == 1) { if (vehicleDepartureLogs.size() == 1) {
VehicleDepartureLog vehicleDepartureLog = vehicleDepartureLogs.get(0); VehicleDepartureLog vehicleDepartureLog = vehicleDepartureLogs.get(0);
if (vehicleDepartureLog!=null) { if (vehicleDepartureLog != null) {
return ObjectRestResponse.succ(vehicleDepartureLog); return ObjectRestResponse.succ(vehicleDepartureLog);
} }
} }
...@@ -124,11 +123,11 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, ...@@ -124,11 +123,11 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
} }
@Transactional @Transactional
public ObjectRestResponse collect(VehicleDepartureLog vdl){ public ObjectRestResponse collect(VehicleDepartureLog vdl) {
vdl.setArrivalTime(new Date()); vdl.setArrivalTime(new Date());
vdl.setState(1); vdl.setState(1);
updateSelectiveById(vdl); updateSelectiveById(vdl);
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
......
...@@ -87,7 +87,7 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> { ...@@ -87,7 +87,7 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> {
return ObjectRestResponse.succ(list); return ObjectRestResponse.succ(list);
} }
Set<Integer> set = new HashSet<>(); Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set); RandomUtil.randomSet(list.size(), number, set, number);
for(Integer i : set) { for(Integer i : set) {
resultList.add(list.get(i)); resultList.add(list.get(i));
} }
......
...@@ -46,12 +46,10 @@ public class VehicleJobHandler extends IJobHandler { ...@@ -46,12 +46,10 @@ public class VehicleJobHandler extends IJobHandler {
List<String> existVehicleIds = vehicleBiz.findExistVehicleIds(); List<String> existVehicleIds = vehicleBiz.findExistVehicleIds();
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DIC_VEHICLE_TYPE, DIC_VEHICLE_CODE); Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DIC_VEHICLE_TYPE, DIC_VEHICLE_CODE);
LocalDate date = LocalDate.now(); LocalDate date = LocalDate.now();
date = date.plusMonths(Integer.valueOf(dictionary.getDetail()));
int year = date.getYear(); int year = date.getYear();
int nowMonth = date.getMonthValue(); int month = date.getMonthValue();
int betweenMonth = Integer.valueOf(dictionary.getDetail()).intValue(); String yearAndMonth = String.format("%d-%02d", year,month);
int month = nowMonth + betweenMonth> 12 ? (betweenMonth + nowMonth) - 12 : nowMonth + betweenMonth;
year = month > nowMonth ? year : year + 1;
String yearAndMonth = String.format("%d-%s", year, month>=10?month:"0"+month);
XxlJobLogger.log("----查询到的车型ids:【{}】",existVehicleIds); XxlJobLogger.log("----查询到的车型ids:【{}】",existVehicleIds);
if (CollectionUtils.isNotEmpty(existVehicleIds)) { if (CollectionUtils.isNotEmpty(existVehicleIds)) {
List<VehicleBookInfo> bookInfos = existVehicleIds.stream().map(vehicleId -> { List<VehicleBookInfo> bookInfos = existVehicleIds.stream().map(vehicleId -> {
......
...@@ -11,6 +11,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -11,6 +11,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.VehicleCataBiz; import com.xxfc.platform.vehicle.biz.VehicleCataBiz;
import com.xxfc.platform.vehicle.biz.VehicleModelBiz; import com.xxfc.platform.vehicle.biz.VehicleModelBiz;
import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz; import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
...@@ -133,7 +134,7 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi ...@@ -133,7 +134,7 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
@ApiOperation("车型列表") @ApiOperation("车型列表")
@PostMapping(value = "/app/unauth/findVehicleModelPage") @PostMapping(value = "/app/unauth/findVehicleModelPage")
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<VehicleModelVo> findVehicleModelPageUnauthfind( public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(
@RequestBody @ApiParam("查询条件") VehicleModelQueryCondition vmqc, HttpServletRequest request) { @RequestBody @ApiParam("查询条件") VehicleModelQueryCondition vmqc, HttpServletRequest request) {
if (vmqc.getIsDel() == null) { if (vmqc.getIsDel() == null) {
vmqc.setIsDel(0); vmqc.setIsDel(0);
......
...@@ -380,7 +380,7 @@ ...@@ -380,7 +380,7 @@
</select> </select>
<select id="selectByVehicleId" parameterType="java.lang.String" <select id="selectByVehicleId" parameterType="java.lang.String"
resultType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo"> resultMap="searchBookRecord">
SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1 SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2 where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2
......
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