Commit fc117367 authored by hezhen's avatar hezhen

添加调度

parent 3a401855
...@@ -29,6 +29,8 @@ public interface ConfigFeign { ...@@ -29,6 +29,8 @@ public interface ConfigFeign {
public static final int TYPE_COMPANY_CATH=89; public static final int TYPE_COMPANY_CATH=89;
public static final int TYPE_VEHICLE_PUBLISH=96;
@RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET) @RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET)
ObjectRestResponse<List<Cofig>> getAllByType(@RequestParam("types") String types); ObjectRestResponse<List<Cofig>> getAllByType(@RequestParam("types") String types);
......
...@@ -3,11 +3,9 @@ package com.xxfc.platform.vehicle.entity; ...@@ -3,11 +3,9 @@ package com.xxfc.platform.vehicle.entity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
...@@ -60,6 +58,11 @@ public class VehiclePublish implements Serializable { ...@@ -60,6 +58,11 @@ public class VehiclePublish implements Serializable {
private Integer waitConfirmNumber; private Integer waitConfirmNumber;
@Column(name = "publish_end_time")
@ApiModelProperty(value = "需求结束时间")
private Long publishEndTime;
@Column(name = "start_time") @Column(name = "start_time")
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
private Long startTime; private Long startTime;
...@@ -93,6 +96,10 @@ public class VehiclePublish implements Serializable { ...@@ -93,6 +96,10 @@ public class VehiclePublish implements Serializable {
@Column(name = "is_del") @Column(name = "is_del")
@ApiModelProperty(value = "是否删除:0-正常;1-删除") @ApiModelProperty(value = "是否删除:0-正常;1-删除")
private Integer isDel; private Integer isDel;
@Transient
@ApiModelProperty(value = "调出信息")
private List<VehiclePublishGoods> publishGoodsList;
} }
package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/23 16:27
*/
@Data
public class VehiclePublishFindDTO extends PageParam implements DataInter {
@ApiModelProperty("商品类型 1--房车;2--机车;3--游艇;4-豪车")
private Integer goodsType;
@ApiModelProperty("类型:1-我要车;2-我有车")
private Integer type;
@ApiModelProperty("类型:1-调度信息;2-我的发布")
private Integer selectType;
@ApiModelProperty("店铺id")
private Integer companyId;
@ApiModelProperty("需求id")
private Integer publishId;
@ApiModelProperty("当前时间")
private Long nowTime;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
Integer bizType;
}
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.VehiclePublishGoods;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class VehiclePublishGoodsVo extends VehiclePublishGoods {
@ApiModelProperty("品牌名称")
String brandName;
@ApiModelProperty("型号名称")
String categoryName;
private List<VehicleExtensionVO> extensionVOS;
}
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.VehiclePublish;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class VehiclePublishVo extends VehiclePublish {
@ApiModelProperty("店铺名称")
String companyName;
@ApiModelProperty("需求商品")
List<VehiclePublishGoodsVo> publishGoodsVos;
}
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
<artifactId>xx-order-api</artifactId> <artifactId>xx-order-api</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-app-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -2,20 +2,99 @@ package com.xxfc.platform.vehicle.biz; ...@@ -2,20 +2,99 @@ package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
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.app.entity.Cofig;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.vehicle.entity.VehiclePublish; import com.xxfc.platform.vehicle.entity.VehiclePublish;
import com.xxfc.platform.vehicle.entity.VehiclePublishGoods;
import com.xxfc.platform.vehicle.mapper.VehiclePublishMapper; import com.xxfc.platform.vehicle.mapper.VehiclePublishMapper;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehiclePublishVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
@Slf4j @Slf4j
public class VehiclePublishBiz extends BaseBiz<VehiclePublishMapper, VehiclePublish> { public class VehiclePublishBiz extends BaseBiz<VehiclePublishMapper, VehiclePublish> {
public void addOrUpd(){
@Autowired
VehiclePublishGoodsBiz publishGoodsBiz;
@Autowired
ConfigFeign configFeign;
public void addOrUpd(VehiclePublish vehiclePublish){
List<VehiclePublishGoods> goodsList = vehiclePublish.getPublishGoodsList();
if (CollectionUtils.isEmpty(goodsList)){
throw new BaseException("参数不能为空", ResultCode.FAILED_CODE);
}
vehiclePublish.setId(null);
insertSelective(vehiclePublish);
Integer id = vehiclePublish.getId();
JSONObject config = getConfig();
for (VehiclePublishGoods publishGoods : goodsList){
publishGoods.setId(null);
publishGoods.setPublishId(id);
publishGoods.setGoodsType(vehiclePublish.getGoodsType());
publishGoods.setPublishAmount(config.getBigDecimal("publishAmount"));
publishGoods.setReceiveAmount(config.getBigDecimal("receiveAmount"));
publishGoodsBiz.insertSelective(publishGoods);
}
}
public List<VehiclePublishVo> getList(VehiclePublishFindDTO publishFindDTO){
return mapper.selectList(publishFindDTO);
}
public PageDataVO<VehiclePublishVo> selectList(VehiclePublishFindDTO publishFindDTO){
Integer page = publishFindDTO.getPage() == null ? 1 : publishFindDTO.getPage();
Integer limit = publishFindDTO.getLimit() == null ? 10 : publishFindDTO.getLimit();
PageHelper.startPage(page, limit);
PageInfo<VehiclePublishVo> pageInfo = new PageInfo<>(getList(publishFindDTO));
PageDataVO<VehiclePublishVo> pageDataVO = PageDataVO.pageInfo(pageInfo);
List<VehiclePublishVo> list = pageDataVO.getData();
if (CollectionUtils.isNotEmpty(list)){
for (VehiclePublishVo publishVo : list){
publishFindDTO.setPublishId(publishVo.getId());
publishVo.setPublishGoodsVos(publishGoodsBiz.getList(publishFindDTO));
}
}
return pageDataVO;
}
//入驻规则管理
public JSONObject getConfig(){
try {
List<Cofig> list=configFeign.getAllByType(ConfigFeign.TYPE_VEHICLE_PUBLISH+"").getData();
if (list!=null && list.size()>0){
String params=list.get(0).getParams();
JSONObject object = JSONObject.parseObject(params);
return object;
}
}catch (Exception e){
log.error(e.getMessage(), e);;
}
return null;
} }
......
...@@ -5,15 +5,53 @@ package com.xxfc.platform.vehicle.biz; ...@@ -5,15 +5,53 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.vehicle.entity.VehiclePublishGoods; import com.xxfc.platform.vehicle.entity.VehiclePublishGoods;
import com.xxfc.platform.vehicle.mapper.VehiclePublishGoodsMapper; import com.xxfc.platform.vehicle.mapper.VehiclePublishGoodsMapper;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO;
import com.xxfc.platform.vehicle.pojo.vo.VehiclePublishGoodsVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class VehiclePublishGoodsBiz extends BaseBiz<VehiclePublishGoodsMapper, VehiclePublishGoods> { public class VehiclePublishGoodsBiz extends BaseBiz<VehiclePublishGoodsMapper, VehiclePublishGoods> {
@Autowired
VehicleExtensionBiz extensionBiz;
public List<VehiclePublishGoodsVo> getList(VehiclePublishFindDTO publishFindDTO){
List<VehiclePublishGoodsVo> list = mapper.selectList(publishFindDTO);
if (CollectionUtils.isNotEmpty(list)){
for (VehiclePublishGoodsVo publishGoodsVo : list){
String vehicleId = publishGoodsVo.getVehicleId();
List<VehicleExtensionVO> extensionVOS = new ArrayList<>();
if (StringUtils.isNotBlank(vehicleId)){
extensionVOS=extensionBiz.getTree(vehicleId);
}else {
String extensionList = publishGoodsVo.getExtensionList();
if (StringUtils.isNotBlank(extensionList)){
extensionVOS=extensionBiz.getTreeByApply(Arrays.asList(extensionList.split(",")).parallelStream().map(s -> Integer.valueOf(s)).collect(Collectors.toList()));
}
}
publishGoodsVo.setExtensionVOS(extensionVOS);
}
}
return list;
}
......
...@@ -2,9 +2,16 @@ package com.xxfc.platform.vehicle.mapper; ...@@ -2,9 +2,16 @@ package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.VehiclePublishGoods; import com.xxfc.platform.vehicle.entity.VehiclePublishGoods;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehiclePublishGoodsVo;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper; import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface VehiclePublishGoodsMapper extends Mapper<VehiclePublishGoods>, SelectByIdListMapper<VehiclePublishGoods,Integer> { public interface VehiclePublishGoodsMapper extends Mapper<VehiclePublishGoods>, SelectByIdListMapper<VehiclePublishGoods,Integer> {
List<VehiclePublishGoodsVo> selectList(VehiclePublishFindDTO publishFindDTO);
} }
\ No newline at end of file
...@@ -2,9 +2,16 @@ package com.xxfc.platform.vehicle.mapper; ...@@ -2,9 +2,16 @@ package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.VehiclePublish; import com.xxfc.platform.vehicle.entity.VehiclePublish;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehiclePublishVo;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper; import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface VehiclePublishMapper extends Mapper<VehiclePublish>, SelectByIdListMapper<VehiclePublish,Integer> { public interface VehiclePublishMapper extends Mapper<VehiclePublish>, SelectByIdListMapper<VehiclePublish,Integer> {
List<VehiclePublishVo> selectList(VehiclePublishFindDTO publishFindDTO);
} }
\ No newline at end of file
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.BeanUtils;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.VehicleApplyBiz;
import com.xxfc.platform.vehicle.biz.VehiclePublishBiz;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleApply;
import com.xxfc.platform.vehicle.entity.VehiclePublish;
import com.xxfc.platform.vehicle.pojo.dto.VehicleApplyFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehiclePublishVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("app/publish")
@Api(tags = {"商品需求"})
public class AppVehiclePublishController extends BaseController<VehiclePublishBiz> {
@PostMapping("save")
@ApiModelProperty("发布需求")
public ObjectRestResponse apply(@RequestBody VehiclePublish vehiclePublish) {
if (vehiclePublish.getCompanyId() == null || vehiclePublish.getCompanyId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
vehiclePublish.setCompanyId(companyIds.get(0));
}
}
baseBiz.addOrUpd(vehiclePublish);
return ObjectRestResponse.succ();
}
@GetMapping("app/unauth/selectList")
@ApiModelProperty("需求列表")
@IgnoreUserToken
public ObjectRestResponse selectList(VehiclePublishFindDTO publishFindDTO) {
publishFindDTO.setSelectType(1);
return ObjectRestResponse.succ(baseBiz.selectList(publishFindDTO));
}
@GetMapping("selectListByCompany")
@ApiModelProperty("我的发布")
public ObjectRestResponse selectListByCompany(VehiclePublishFindDTO publishFindDTO) {
if (publishFindDTO.getCompanyId() == null || publishFindDTO.getCompanyId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
publishFindDTO.setCompanyId(companyIds.get(0));
}
}
publishFindDTO.setSelectType(2);
return ObjectRestResponse.succ(baseBiz.selectList(publishFindDTO));
}
@GetMapping("app/unauth/detail")
@ApiModelProperty("详情")
@IgnoreUserToken
public ObjectRestResponse detail(VehiclePublishFindDTO publishFindDTO) {
PageDataVO<VehiclePublishVo> pageDataVO = baseBiz.selectList(publishFindDTO);
List<VehiclePublishVo> list = pageDataVO.getData();
VehiclePublishVo publishVo = new VehiclePublishVo();
if (CollectionUtils.isNotEmpty(list)){
publishVo=list.get(0);
}
return ObjectRestResponse.succ(publishVo);
}
}
<?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" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.VehiclePublishGoodsMapper">
<select id="selectList" resultType="com.xxfc.platform.vehicle.pojo.vo.VehiclePublishGoodsVo" parameterType="com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO">
SELECT g.*, IFNULL(b1.cn_name,b.cn_name) as brandName,IFNULL(c1.`name`,c.`name`) as categoryName FROM vehicle_publish_goods g
LEFT JOIN vehicle v ON g.vehicle_id=v.id
LEFT JOIN vehicle_brand b1 ON v.brand_id=b1.id
LEFT JOIN vehicle_category c1 ON v.category_id=c1.id
LEFT JOIN vehicle_brand b ON g.brand_id=b.id
LEFT JOIN vehicle_category c ON g.category_id=c.id
<where>
g.is_del = 0
<if test="publishId != null and publishId > 0">
AND g.`publish_id`= #{publishId}
</if>
</where>
order by g.number DESC
</select>
</mapper>
\ No newline at end of file
<?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" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.VehiclePublishMapper">
<select id="selectList" resultType="com.xxfc.platform.vehicle.pojo.vo.VehiclePublishVo" parameterType="com.xxfc.platform.vehicle.pojo.dto.VehiclePublishFindDTO">
SELECT p.*,c.`name` as companyName FROM vehicle_publish p
LEFT JOIN branch_company c ON p.company_id = c.id
<where>
p.is_del = 0
<if test="type != null ">
AND p.`type`= #{type}
</if>
<if test="companyId != null and companyId > 0">
AND p.`company_id`= #{companyId}
</if>
<if test="goodsType != null ">
AND p.`goods_type`= #{goodsType}
</if>
<if test="nowTime != null and nowTime > 0">
AND p.`publish_end_time` >= #{nowTime}
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and p.id in
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and p.company_id in
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
<if test="selectType != null ">
<choose>
<when test="selectType == 1">
order by p.publish_end_time ASC
</when>
<when test="selectType == 2">
order by p.wait_confirm_number DESC,p.publish_end_time ASC
</when>
<otherwise>
order by p.id DESC
</otherwise>
</choose>
</if>
</select>
</mapper>
\ No newline at end of file
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