Commit aca2b54b authored by libin's avatar libin

股权

parent 5628808e
package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/22 19:58
*/
@Data
public class BranchCompanyStockRightFindDTO extends PageParam {
private Integer provinceCode;
private Integer cityCode;
private BigDecimal price;
}
package com.xxfc.platform.vehicle.pojo.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/22 20:03
*/
@Data
public class BranchCompanyStockRightForWeChatOfficeVO {
private Integer id;
private String companyName;
private Integer balance;
private Integer total;
private BigDecimal price;
private String cover;
private Integer type;
}
......@@ -6,11 +6,15 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.StringToolsUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockRight;
import com.xxfc.platform.vehicle.mapper.*;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyStockRightFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockRightForWeChatOfficeVO;
import com.xxfc.platform.vehicle.util.excel.ExcelImport;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -18,6 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
......@@ -35,7 +40,7 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
@Value("${branchCompanyPic.stock}")
private String companyPic;
private String companyPic;
//获取股权列表
public PageInfo<BranchCompanyStockInfoRightVo> search(BranchCompanyStockSearchVo searchVo) {
......@@ -43,14 +48,14 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
return new PageInfo<>(mapper.search(searchVo));
}
//更新股权
//更新股权
public ObjectRestResponse updStockInfo(BranchCompanyStockInfoRightVo stockInfoVo) {
if (stockInfoVo==null||stockInfoVo.getCompanyId()==null||stockInfoVo.getCompanyId()==0){
if (stockInfoVo == null || stockInfoVo.getCompanyId() == null || stockInfoVo.getCompanyId() == 0) {
}
Integer id=stockInfoVo.getId();
if (!checkInfo(id,stockInfoVo.getCompanyId())){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"分公司已存在");
Integer id = stockInfoVo.getId();
if (!checkInfo(id, stockInfoVo.getCompanyId())) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "分公司已存在");
}
BranchCompanyStockRight stockInfo = new BranchCompanyStockRight();
BeanUtils.copyProperties(stockInfoVo, stockInfo);
......@@ -60,25 +65,25 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
if (stockInfoVo.getState() == null) {
stockInfo.setState(0);
}
if (id==null||id==0){
if (id == null || id == 0) {
mapper.insertSelective(stockInfo);
}else {
} else {
mapper.updateByPrimaryKeySelective(stockInfo);
}
return ObjectRestResponse.succ();
return ObjectRestResponse.succ();
}
//检查是否存在分公司
public boolean checkInfo(Integer id,Integer companyId) {
Example example=new Example(BranchCompanyStockRight.class);
Example.Criteria criteria=example.createCriteria();
criteria.andEqualTo("companyId",companyId);
if (id!=null&&id>0){
criteria.andNotEqualTo("id",id);
public boolean checkInfo(Integer id, Integer companyId) {
Example example = new Example(BranchCompanyStockRight.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("companyId", companyId);
if (id != null && id > 0) {
criteria.andNotEqualTo("id", id);
}
List<BranchCompanyStockRight> list=mapper.selectByExample(example);
if (list.size()>0)
return false;
List<BranchCompanyStockRight> list = mapper.selectByExample(example);
if (list.size() > 0)
return false;
return true;
}
......@@ -91,6 +96,7 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
/**
* 获取所有的股权单价
*
* @return
*/
public List<Integer> getAllPrice() {
......@@ -98,65 +104,88 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
}
//更新股份
public int updateBalance(Integer companyId,Integer balance,Integer lastBalance){
return mapper.updateBalance(companyId,balance,lastBalance);
}
//更新股份
public int updateBalance(Integer companyId, Integer balance, Integer lastBalance) {
return mapper.updateBalance(companyId, balance, lastBalance);
}
//删除股权
//删除股权
public void delete(Integer id) {
BranchCompanyStockRight stockRight=new BranchCompanyStockRight();
BranchCompanyStockRight stockRight = new BranchCompanyStockRight();
stockRight.setId(id);
stockRight.setIsDel(1);
mapper.updateByPrimaryKeySelective(stockRight);
}
//导入
public ObjectRestResponse<String> importExcel(MultipartFile multipartfile, HttpServletRequest request){
//导入
public ObjectRestResponse<String> importExcel(MultipartFile multipartfile, HttpServletRequest request) {
try {
List<String[]> readExcel = ExcelImport.getExcelData(multipartfile);
if(readExcel.size()<4){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"导入不能没数据!!!");
if (readExcel.size() < 4) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "导入不能没数据!!!");
}
List<BranchCompanyStockRight> list=new ArrayList<>();
for (int i = 3; i < readExcel.size(); i++) {
BranchCompanyStockRight stockInfoVo = new BranchCompanyStockRight();
String[] str = readExcel.get(i);
String companyName = str[2];
Integer companyId = mapper.getCompanyInfo(companyName);
if (companyId == null || companyId == 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的" + companyName + "不匹配");
}
String str3 = str[3];
if (StringUtils.isBlank(str3)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的股价不能为空");
}
if (str3.contains("万港币/股")) {
str3 = str3.replace("万港币/股", "");
} else {
str3 = str3.replace("万/股", "");
}
if (!StringToolsUtil.isBigDecimal(str3)||!StringToolsUtil.isNumer(str[4])||!StringToolsUtil.isNumer(str[5])){
List<BranchCompanyStockRight> list = new ArrayList<>();
for (int i = 3; i < readExcel.size(); i++) {
BranchCompanyStockRight stockInfoVo = new BranchCompanyStockRight();
String[] str = readExcel.get(i);
String companyName = str[2];
Integer companyId = mapper.getCompanyInfo(companyName);
if (companyId == null || companyId == 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的" + companyName + "不匹配");
}
String str3 = str[3];
if (StringUtils.isBlank(str3)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的股价不能为空");
}
if (str3.contains("万港币/股")) {
str3 = str3.replace("万港币/股", "");
} else {
str3 = str3.replace("万/股", "");
}
if (!StringToolsUtil.isBigDecimal(str3) || !StringToolsUtil.isNumer(str[4]) || !StringToolsUtil.isNumer(str[5])) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的数据格式不对");
}
BigDecimal price = new BigDecimal(str3);
price=price.multiply(new BigDecimal("10000"));
price = price.multiply(new BigDecimal("10000"));
Integer balance = Integer.parseInt(str[4]);
Integer total =Integer.parseInt(str[5])+balance;
Integer total = Integer.parseInt(str[5]) + balance;
stockInfoVo.setPrice(price);
stockInfoVo.setBalance(balance);
stockInfoVo.setTotal(total);
stockInfoVo.setState(2);
list.add(stockInfoVo);
}
mapper.addCompamyList(list);
}catch (Exception e){
mapper.addCompamyList(list);
} catch (Exception e) {
e.printStackTrace();
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"网络异常!");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "网络异常!");
}
return ObjectRestResponse.succ();
}
public PageDataVO<BranchCompanyStockRightForWeChatOfficeVO> findWithPageByPriceOrCode(BranchCompanyStockRightFindDTO branchCompanyStockRightFindDTO) {
PageDataVO<BranchCompanyStockRightForWeChatOfficeVO> dataPage = new PageDataVO<>();
PageDataVO<BranchCompanyStockRight> pageDataVO = PageDataVO.pageInfo(branchCompanyStockRightFindDTO.getPage(), branchCompanyStockRightFindDTO.getLimit(),
() -> mapper.findWithPageByPriceOrCode(branchCompanyStockRightFindDTO.getPrice(), branchCompanyStockRightFindDTO.getProvinceCode(), branchCompanyStockRightFindDTO.getCityCode()));
List<BranchCompanyStockRight> data = pageDataVO.getData();
if (CollectionUtils.isEmpty(data)){
return dataPage;
}
List<BranchCompanyStockRightForWeChatOfficeVO> stockRights = new ArrayList<>();
BranchCompanyStockRightForWeChatOfficeVO branchCompanyStockRightForWeChatOfficeVO;
for (BranchCompanyStockRight branchCompanyStockRight : data) {
branchCompanyStockRightForWeChatOfficeVO= new BranchCompanyStockRightForWeChatOfficeVO();
BeanUtils.copyProperties(branchCompanyStockRight,branchCompanyStockRightForWeChatOfficeVO);
stockRights.add(branchCompanyStockRightForWeChatOfficeVO);
}
dataPage.setTotalCount(pageDataVO.getTotalCount());
dataPage.setTotalPage(pageDataVO.getTotalPage());
dataPage.setPageNum(pageDataVO.getPageNum());
dataPage.setPageSize(pageDataVO.getPageSize());
dataPage.setData(stockRights);
return dataPage;
}
}
......@@ -51,7 +51,7 @@ public class VehicleJobHandler extends IJobHandler {
int betweenMonth = Integer.valueOf(dictionary.getDetail()).intValue();
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);
String yearAndMonth = String.format("%d-%s", year, month>=10?month:"0"+month);
XxlJobLogger.log("----查询到的车型ids:【{}】",existVehicleIds);
if (CollectionUtils.isNotEmpty(existVehicleIds)) {
List<VehicleBookInfo> bookInfos = existVehicleIds.stream().map(vehicleId -> {
......
......@@ -7,6 +7,7 @@ import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.List;
......@@ -25,4 +26,6 @@ public interface BranchCompanyStockRightMapper extends Mapper<BranchCompanyStock
int addCompamyList(@Param("list") List<BranchCompanyStockRight> list);
Integer getCompanyInfo(@Param("name")String name);
List<BranchCompanyStockRight> findWithPageByPriceOrCode(@Param("price") BigDecimal price,@Param("provinceCode") Integer provinceCode,@Param("cityCode") Integer cityCode);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyStockApplyInfoBiz;
import com.xxfc.platform.vehicle.biz.BranchCompanyStockRightBiz;
import com.xxfc.platform.vehicle.common.BaseController;
......@@ -12,7 +13,9 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyStockRightFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockRightForWeChatOfficeVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -191,4 +194,15 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return baseBiz.importExcel(multipartfile,request);
}
/**
* 微信公众号查询
* @param branchCompanyStockRightFindDTO
* @return
*/
@GetMapping("/webchat_office/stockrights")
public ObjectRestResponse<PageDataVO<BranchCompanyStockRightForWeChatOfficeVO>> findBranchCompanyStockRightsForWechatOffice(BranchCompanyStockRightFindDTO branchCompanyStockRightFindDTO){
PageDataVO<BranchCompanyStockRightForWeChatOfficeVO> branchCompanyStockRightForWeChatOfficeVOPageDataVO = baseBiz.findWithPageByPriceOrCode(branchCompanyStockRightFindDTO);
return ObjectRestResponse.succ(branchCompanyStockRightForWeChatOfficeVOPageDataVO);
}
}
......@@ -28,7 +28,7 @@
<trim prefix="where" suffixOverrides="and">
c.is_del = 0 and
<if test="companyName != null">
c.name like CONCAT('%',#{companyName},'%')
c.name like CONCAT('%',#{companyName},'%')
</if>
<if test="addrProvince != null">
c.addr_province = #{addrProvince} and
......@@ -43,7 +43,7 @@
r.price &lt;= #{priceEnd} and
</if>
</trim>
order by rank DESC,price DESC
order by rank DESC,price DESC
</select>
<select id="selectAllPrice" resultType="int">
select distinct price from branch_company_stock_info_right where is_del=0 order by price
......@@ -76,8 +76,34 @@
insert into branch_company_stock_info_right (
company_id,balance,total,price,state,company_pic,crt_time,upd_time
) VALUES
<foreach collection ="list" item="item" index="index" separator =",">
<foreach collection="list" item="item" index="index" separator=",">
(#{item.companyId},#{item.balance},#{item.total},#{item.price},#{item.state},#{item.companyPic},#{item.crtTime},#{item.updTime})
</foreach>
</insert>
<select id="findWithPageByPriceOrCode"
resultType="com.xxfc.platform.vehicle.entity.BranchCompanyStockRight">
SELECT
bcsir.id,
bcsir.balance,
bcsir.total,
bcsir.type,
bcsir.price,
cb.cover,
cb.name
FROM
( SELECT id, company_base_id, balance, total, price, type FROM `branch_company_stock_info_right` WHERE `state` =
2 AND `is_del`=0
<if test="price != null">
AND `price`=#{price}
</if>
) AS `bcsir`
INNER JOIN ( SELECT id, `name`, cover FROM `company_base` WHERE 1=1
<if test="provinceCode != null">
AND `addr_province`=#{provinceCode}
</if>
<if test="cityCode != null">
AND `addr_city`=#{provinceCode}
</if>
) AS `cb` ON cb.id = bcsir.company_base_id
</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