Commit 260bab35 authored by hezhen's avatar hezhen

123

parent a32ce978
...@@ -40,4 +40,43 @@ public class StringToolsUtil { ...@@ -40,4 +40,43 @@ public class StringToolsUtil {
String REGEX_ID_CARD = "(^\\d{18}$)|(^\\d{15}$)"; String REGEX_ID_CARD = "(^\\d{18}$)|(^\\d{15}$)";
return Pattern.matches(REGEX_ID_CARD, idCard); return Pattern.matches(REGEX_ID_CARD, idCard);
} }
public static boolean isNumer( String str){
boolean flag = false;
try{
if(StringUtils.isBlank(str)) {
flag = false;
}
Pattern regex =Pattern.compile("[0-9]*");
Matcher m = regex .matcher(str);
flag = m.matches();
}catch(Exception e){
flag = false;
}
return flag;
}
public static boolean isBigDecimal(String str) {
if (str == null || str.trim().length() == 0) {
return false;
}
char[] chars = str.toCharArray();
int sz = chars.length;
int i = (chars[0] == '-') ? 1 : 0;
if (i == sz) return false;
if (chars[i] == '.') return false;//除了负号,第一位不能为'小数点'
boolean radixPoint = false;
for (; i < sz; i++) {
if (chars[i] == '.') {
if (radixPoint) return false;
radixPoint = true;
} else if (!(chars[i] >= '0' && chars[i] <= '9')) {
return false;
}
}
return true;
}
} }
package com.xxfc.platform.vehicle.biz;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.vehicle.constant.BranchCompanyStockApplyState;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockRight;
import com.xxfc.platform.vehicle.mapper.BranchCompanyStockApplyInfoMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyInfoVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
@Service
public class BranchCompanyStockApplyInfoBiz extends BaseBiz<BranchCompanyStockApplyInfoMapper, BranchCompanyStockApplyInfo> {
@Autowired
BranchCompanyStockRightBiz branchCompanyStockRightBiz;
/**
* 申请购买
* @param applyVo
*/
public void apply(BranchCompanyStockApplyVo applyVo) {
BranchCompanyStockRight stockInfo = branchCompanyStockRightBiz.selectById(applyVo.getCompanyId());
if (stockInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getDesc(), ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getCode());
}
if (stockInfo.getBalance() <= 0) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_NO_BALANCE.getDesc(), ResCode.BRANCH_COMPANY_STOCK_NO_BALANCE.getCode());
}
if (stockInfo.getBalance() < applyVo.getCount()) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getDesc(), ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getCode());
}
BranchCompanyStockApplyInfo applyInfo = new BranchCompanyStockApplyInfo();
BeanUtils.copyProperties(applyVo, applyInfo);
applyInfo.setState(BranchCompanyStockApplyState.Apply.getCode());
applyInfo.setCreateTime(new Date());
mapper.insertSelective(applyInfo);
}
public PageInfo<BranchCompanyStockApplyInfoVo> selectApplyAll(Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(mapper.selectVoAll());
}
/**
* 取消申请,修改申请状态
* @param applyId
*/
public void cancelApply(Integer applyId) {
BranchCompanyStockApplyInfo applyInfo = mapper.selectByPrimaryKey(applyId);
if (applyInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getDesc(),
ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getCode());
}
applyInfo.setState(BranchCompanyStockApplyState.Cancel.getCode());
applyInfo.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(applyInfo);
}
/**
* 确认申请购买股权,修改库存
* @param applyId
*/
@Transactional
public void buy(Integer applyId) {
BranchCompanyStockApplyInfo applyInfo = mapper.selectByPrimaryKey(applyId);
if (applyInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getDesc(),
ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getCode());
}
if (!applyInfo.getState().equals(BranchCompanyStockApplyState.Apply.getCode())) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_STATE_LOCKED.getDesc(),
ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_STATE_LOCKED.getCode());
}
BranchCompanyStockRight stockInfo = branchCompanyStockRightBiz.selectById(applyInfo.getCompanyId());
if (stockInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getDesc(), ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getCode());
}
if (stockInfo.getBalance() < applyInfo.getCount()) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getDesc(), ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getCode());
}
int result = branchCompanyStockRightBiz.updateBalance(applyInfo.getCompanyId(), stockInfo.getBalance() - applyInfo.getCount(), stockInfo.getBalance());
if (result == 0) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getDesc(), ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getCode());
}
applyInfo.setState(BranchCompanyStockApplyState.Buy.getCode());
applyInfo.setUpdateTime(new Date());
mapper.updateByPrimaryKey(applyInfo);
}
public BranchCompanyStockApplyInfo getApplyById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
public void updateApply(BranchCompanyStockApplyInfo applyInfo) {
mapper.updateByPrimaryKeySelective(applyInfo);
}
public void deleteApply(Integer id) {
mapper.deleteByPrimaryKey(id);
}
}
...@@ -3,84 +3,47 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,84 +3,47 @@ package com.xxfc.platform.vehicle.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.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; 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.util.process.ResultCode;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.BranchCompanyStockApplyState;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockInfo;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockRight; import com.xxfc.platform.vehicle.entity.BranchCompanyStockRight;
import com.xxfc.platform.vehicle.mapper.*; import com.xxfc.platform.vehicle.mapper.*;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyInfoVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockInfoVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo; import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import com.xxfc.platform.vehicle.util.excel.ExcelImport; import com.xxfc.platform.vehicle.util.excel.ExcelImport;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
@Service @Service
public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightMapper, BranchCompanyStockRight> { public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightMapper, BranchCompanyStockRight> {
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public static final DateTimeFormatter YEARMONTH_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM");
@Value("${branchCompanyStockPic.baseUploadPath:/data/branchCompanyStock/upload/}")
private String baseUploadPath;
@Autowired @Autowired
private RedisTemplate customRedisTemplate; BranchCompanyBiz branchCompanyBiz;
@Autowired @Autowired
BranchCompanyStockInfoMapper branchCompanyStockInfoMapper; BranchCompanyStockApplyInfoBiz branchCompanyStockApplyInfoBiz;
@Autowired
BranchCompanyMapper branchCompanyMapper;
@Autowired @Value("${branchCompanyPic.stock}")
BranchCompanyStockApplyInfoMapper branchCompanyStockApplyInfoMapper; private String companyPic;
@Autowired
SysRegionMapper sysRegionMapper;
public PageInfo<BranchCompanyStockInfoVo> selectAll(Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(branchCompanyStockInfoMapper.selectVoAll());
}
//获取股权列表
public PageInfo<BranchCompanyStockInfoRightVo> search(BranchCompanyStockSearchVo searchVo) { public PageInfo<BranchCompanyStockInfoRightVo> search(BranchCompanyStockSearchVo searchVo) {
PageHelper.startPage(searchVo.getPage(), searchVo.getLimit()); PageHelper.startPage(searchVo.getPage(), searchVo.getLimit());
return new PageInfo<>(mapper.search(searchVo)); return new PageInfo<>(mapper.search(searchVo));
} }
//更新股权
public ObjectRestResponse updStockInfo(BranchCompanyStockInfoRightVo stockInfoVo) { public ObjectRestResponse updStockInfo(BranchCompanyStockInfoRightVo stockInfoVo) {
if (stockInfoVo==null||stockInfoVo.getCompanyId()==null||stockInfoVo.getCompanyId()==0){ if (stockInfoVo==null||stockInfoVo.getCompanyId()==null||stockInfoVo.getCompanyId()==0){
...@@ -105,96 +68,42 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM ...@@ -105,96 +68,42 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
/** //检查是否存在分公司
* 申请购买 public boolean checkInfo(Integer id,Integer companyId) {
* @param applyVo Example example=new Example(BranchCompanyStockRight.class);
*/ Example.Criteria criteria=example.createCriteria();
public void apply(BranchCompanyStockApplyVo applyVo) { criteria.andEqualTo("companyId",companyId);
BranchCompanyStockInfo stockInfo = branchCompanyStockInfoMapper.selectByPrimaryKey(applyVo.getCompanyId()); if (id!=null&&id>0){
if (stockInfo == null) { criteria.andNotEqualTo("id",id);
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getDesc(), ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getCode());
}
if (stockInfo.getBalance() <= 0) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_NO_BALANCE.getDesc(), ResCode.BRANCH_COMPANY_STOCK_NO_BALANCE.getCode());
}
if (stockInfo.getBalance() < applyVo.getCount()) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getDesc(), ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getCode());
} }
BranchCompanyStockApplyInfo applyInfo = new BranchCompanyStockApplyInfo(); List<BranchCompanyStockRight> list=mapper.selectByExample(example);
BeanUtils.copyProperties(applyVo, applyInfo); if (list.size()>0)
applyInfo.setState(BranchCompanyStockApplyState.Apply.getCode()); return false;
applyInfo.setCreateTime(new Date()); return true;
branchCompanyStockApplyInfoMapper.insertSelective(applyInfo);
} }
public PageInfo<BranchCompanyStockApplyInfoVo> selectApplyAll(Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(branchCompanyStockApplyInfoMapper.selectVoAll());
}
/** //获取股权信息
* 取消申请,修改申请状态 public BranchCompanyStockInfoRightVo getInfoById(Integer id) {
* @param applyId return mapper.selectInfoById(id);
*/
public void cancelApply(Integer applyId) {
BranchCompanyStockApplyInfo applyInfo = branchCompanyStockApplyInfoMapper.selectByPrimaryKey(applyId);
if (applyInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getDesc(),
ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getCode());
}
applyInfo.setState(BranchCompanyStockApplyState.Cancel.getCode());
applyInfo.setUpdateTime(new Date());
branchCompanyStockApplyInfoMapper.updateByPrimaryKey(applyInfo);
} }
/**
* 确认申请购买股权,修改库存
* @param applyId
*/
@Transactional
public void buy(Integer applyId) {
BranchCompanyStockApplyInfo applyInfo = branchCompanyStockApplyInfoMapper.selectByPrimaryKey(applyId);
if (applyInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getDesc(),
ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST.getCode());
}
if (!applyInfo.getState().equals(BranchCompanyStockApplyState.Apply.getCode())) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_STATE_LOCKED.getDesc(),
ResCode.BRANCH_COMPANY_STOCK_APPLY_INFO_STATE_LOCKED.getCode());
}
BranchCompanyStockInfo stockInfo = branchCompanyStockInfoMapper.selectByPrimaryKey(applyInfo.getCompanyId());
if (stockInfo == null) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getDesc(), ResCode.BRANCH_COMPANY_STOCK_UNEXIST.getCode());
}
if (stockInfo.getBalance() < applyInfo.getCount()) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getDesc(), ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getCode());
}
int result = branchCompanyStockInfoMapper.updateBalance(applyInfo.getCompanyId(), stockInfo.getBalance() - applyInfo.getCount(), stockInfo.getBalance());
if (result == 0) {
throw new BaseException(ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getDesc(), ResCode.BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH.getCode());
}
applyInfo.setState(BranchCompanyStockApplyState.Buy.getCode());
applyInfo.setUpdateTime(new Date());
branchCompanyStockApplyInfoMapper.updateByPrimaryKey(applyInfo);
}
/** /**
* 获取所有的股权单价 * 获取所有的股权单价
* @return * @return
*/ */
public List<Integer> getAllPrice() { public List<Integer> getAllPrice() {
return branchCompanyStockInfoMapper.selectAllPrice(); return mapper.selectAllPrice();
} }
public BranchCompanyStockInfo selectById(Integer id) { //更新股份
return branchCompanyStockInfoMapper.selectByPrimaryKey(id); public int updateBalance(Integer companyId,Integer balance,Integer lastBalance){
} return mapper.updateBalance(companyId,balance,lastBalance);
}
//删除股权
public void delete(Integer id) { public void delete(Integer id) {
BranchCompanyStockRight stockRight=new BranchCompanyStockRight(); BranchCompanyStockRight stockRight=new BranchCompanyStockRight();
stockRight.setId(id); stockRight.setId(id);
...@@ -202,110 +111,54 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM ...@@ -202,110 +111,54 @@ public class BranchCompanyStockRightBiz extends BaseBiz<BranchCompanyStockRightM
mapper.updateByPrimaryKeySelective(stockRight); mapper.updateByPrimaryKeySelective(stockRight);
} }
public BranchCompanyStockApplyInfo getApplyById(Integer id) { //导入
return branchCompanyStockApplyInfoMapper.selectByPrimaryKey(id); public ObjectRestResponse<String> importExcel(MultipartFile multipartfile, HttpServletRequest request){
}
public void updateApply(BranchCompanyStockApplyInfo applyInfo) {
branchCompanyStockApplyInfoMapper.updateByPrimaryKeySelective(applyInfo);
}
public void deleteApply(Integer id) {
branchCompanyStockApplyInfoMapper.deleteByPrimaryKey(id);
}
/**
* 写入上传文件,返回相对路径
* @param file
* @return
*/
public RestResponse<String> uploadCompanyPic(MultipartFile file) throws Exception{
//创建本日存放目录
DateTime now = DateTime.now();
String dirPathToday = File.separator + now.toString(DEFAULT_DATE_TIME_FORMATTER);
String redisNoKey = RedisKey.UPLOAD_FILE_NO_PREFIX + now.toString(DEFAULT_DATE_TIME_FORMATTER);
Long no = customRedisTemplate.opsForValue().increment(redisNoKey);
if(no.equals(1l)){
customRedisTemplate.expire(redisNoKey,1, TimeUnit.DAYS);
}
String fileName = file.getOriginalFilename();
String realFileRelPath = dirPathToday + File.separator + no + fileName.substring(fileName.lastIndexOf("."));
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return RestResponse.suc(realFileRelPath);
}
public ResponseEntity<byte[]> downloadCompanyPic(String realFileRelPath) throws IOException {
String filePath = baseUploadPath + realFileRelPath;
File file = new File(filePath);//新建一个文件
HttpHeaders headers = new HttpHeaders();//http头信息
String downloadFileName = new String(file.getName());//设置编码
headers.setContentDispositionFormData("attachment", downloadFileName);
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
}
public RestResponse<String> importExcel(MultipartFile multipartfile, HttpServletRequest request){
try { try {
List<String[]> readExcel = ExcelImport.getExcelData(multipartfile); List<String[]> readExcel = ExcelImport.getExcelData(multipartfile);
if(readExcel.size()<4){ if(readExcel.size()<4){
return RestResponse.codeAndMessage(1001,"导入不能没数据!!!"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"导入不能没数据!!!");
} }
List<BranchCompanyStockInfo> list=new ArrayList<>(); List<BranchCompanyStockRight> list=new ArrayList<>();
for (int i = 3; i < readExcel.size(); i++) { for (int i = 3; i < readExcel.size(); i++) {
BranchCompanyStockInfo stockInfoVo=new BranchCompanyStockInfo(); BranchCompanyStockRight stockInfoVo = new BranchCompanyStockRight();
String[] str = readExcel.get(i); String[] str = readExcel.get(i);
String province = str[2]; String companyName = str[2];
String city = str[3]; Integer companyId = mapper.getCompanyInfo(companyName);
Integer addr_province=sysRegionMapper.getNumber(province); if (companyId == null || companyId == 0) {
Integer addr_city=sysRegionMapper.getNumber(city); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的" + companyName + "不匹配");
String company_name = str[5]; }
String str6=str[6]; String str3 = str[3];
if(StringUtils.isNotBlank(str6)){ if (StringUtils.isBlank(str3)) {
if(str6.contains("万港币/股")){ return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的股价不能为空");
str6=str6.replace("万港币/股",""); }
}else { if (str3.contains("万港币/股")) {
str6=str6.replace("万/股",""); str3 = str3.replace("万港币/股", "");
} } else {
str3 = str3.replace("万/股", "");
}else{ }
str6="0"; if (!StringToolsUtil.isBigDecimal(str3)||!StringToolsUtil.isNumer(str[4])||!StringToolsUtil.isNumer(str[5])){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "第" + (i + 1) + "行的数据格式不对");
} }
BigDecimal price = new BigDecimal(str6); BigDecimal price = new BigDecimal(str3);
price=price.multiply(new BigDecimal("10000")); price=price.multiply(new BigDecimal("10000"));
Integer balance = Integer.parseInt(str[8]); Integer balance = Integer.parseInt(str[4]);
Integer total =Integer.parseInt(str[7])+balance; Integer total =Integer.parseInt(str[5])+balance;
stockInfoVo.setCompanyName(company_name);
stockInfoVo.setPrice(price); stockInfoVo.setPrice(price);
stockInfoVo.setBalance(balance); stockInfoVo.setBalance(balance);
stockInfoVo.setTotal(total); stockInfoVo.setTotal(total);
stockInfoVo.setState(2); stockInfoVo.setState(2);
stockInfoVo.setAddrProvince(addr_province); stockInfoVo.setCompanyPic(companyPic);
stockInfoVo.setAddrCity(addr_city); stockInfoVo.setCompanyId(companyId);
stockInfoVo.setCompanyPic("/2019-04-30/2.jpg");
list.add(stockInfoVo); list.add(stockInfoVo);
//branchCompanyStockInfoMapper.insertSelective(stockInfoVo);
} }
branchCompanyStockInfoMapper.addCompamyList(list); mapper.addCompamyList(list);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return RestResponse.codeAndMessage(10001,"网络异常!"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"网络异常!");
} }
return RestResponse.suc(); 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);
}
List<BranchCompanyStockRight> list=mapper.selectByExample(example);
if (list.size()>0)
return false;
return true;
}
} }
...@@ -4,13 +4,25 @@ package com.xxfc.platform.vehicle.mapper; ...@@ -4,13 +4,25 @@ package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockRight; import com.xxfc.platform.vehicle.entity.BranchCompanyStockRight;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo; import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
public interface BranchCompanyStockRightMapper extends Mapper<BranchCompanyStockRight> { public interface BranchCompanyStockRightMapper extends Mapper<BranchCompanyStockRight> {
//获取股权列表
List<BranchCompanyStockInfoRightVo> search(BranchCompanyStockSearchVo searchVo); List<BranchCompanyStockInfoRightVo> search(BranchCompanyStockSearchVo searchVo);
//获取股价列表
List<Integer> selectAllPrice();
//获取一条记录
BranchCompanyStockInfoRightVo selectInfoById(@Param("id")Integer id);
//修改股权
int updateBalance(@Param("companyId") Integer companyId, @Param("balance") Integer balance, @Param("lastBalance") Integer lastBalance);
//批量添加
int addCompamyList(@Param("list") List<BranchCompanyStockRight> list);
Integer getCompanyInfo(@Param("name")String name);
} }
\ No newline at end of file
...@@ -4,8 +4,8 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; ...@@ -4,8 +4,8 @@ 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.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.biz.BranchCompanyStockApplyInfoBiz;
import com.xxfc.platform.vehicle.biz.BranchCompanyStockRightBiz; import com.xxfc.platform.vehicle.biz.BranchCompanyStockRightBiz;
import com.xxfc.platform.vehicle.biz.BranchCompanyStockService;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
...@@ -13,8 +13,8 @@ import com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo; ...@@ -13,8 +13,8 @@ import com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo; import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -26,31 +26,18 @@ import javax.servlet.http.HttpServletRequest; ...@@ -26,31 +26,18 @@ import javax.servlet.http.HttpServletRequest;
@RequestMapping("branchCompany/stock/right") @RequestMapping("branchCompany/stock/right")
public class BranchCompanyStockRightController extends BaseController<BranchCompanyStockRightBiz> { public class BranchCompanyStockRightController extends BaseController<BranchCompanyStockRightBiz> {
private static Integer MAX_DRIVING_LICENSE_SIZE = 10*1024*1024;//10M
@Autowired @Autowired
BranchCompanyStockService branchCompanyStockService; BranchCompanyStockApplyInfoBiz branchCompanyStockApplyInfoBiz;
/**
* 分页获取
* @param page
* @param limit
* @return
*/
@GetMapping("page")
public RestResponse page(Integer page, Integer limit) {
if (page == null || limit == null) {
page = 1;
limit = 10;
}
return RestResponse.suc(baseBiz.selectAll(page, limit));
}
/** /**
* 搜索 * 搜索
* @param searchVo * @param searchVo
* @return * @return
*/ */
@ApiOperation(value = "获取股权列表")
@GetMapping("search") @GetMapping("search")
public RestResponse search(BranchCompanyStockSearchVo searchVo) { public RestResponse search(BranchCompanyStockSearchVo searchVo) {
if (searchVo.getPage() == null || searchVo.getLimit() == null) { if (searchVo.getPage() == null || searchVo.getLimit() == null) {
...@@ -60,26 +47,18 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -60,26 +47,18 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.suc(baseBiz.search(searchVo)); return RestResponse.suc(baseBiz.search(searchVo));
} }
@GetMapping("{id}") @ApiOperation(value = "获取股权信息")
public RestResponse get(@PathVariable("id") Integer id) {
if (id == null) {
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc());
}
return RestResponse.suc(branchCompanyStockService.selectById(id));
}
@GetMapping("info/{id}") @GetMapping("info/{id}")
public RestResponse getInfo(@PathVariable("id") Integer id) { public RestResponse getInfo(@PathVariable("id") Integer id) {
if (id == null) { if (id == null) {
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
return RestResponse.suc(branchCompanyStockService.getInfoById(id)); return RestResponse.suc(baseBiz.getInfoById(id));
} }
/** /**
* 更新 * 编辑
* @return * @return
*/ */
@RequestMapping(value ="/updStockInfo",method = RequestMethod.POST) @RequestMapping(value ="/updStockInfo",method = RequestMethod.POST)
...@@ -91,7 +70,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -91,7 +70,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
} }
/** /**
* 更新 * 新增
* @return * @return
*/ */
@RequestMapping(value ="/addStockInfo",method = RequestMethod.POST) @RequestMapping(value ="/addStockInfo",method = RequestMethod.POST)
...@@ -113,24 +92,6 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -113,24 +92,6 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
@RequestMapping(value ="/upload/companyPic",method = RequestMethod.POST)
public RestResponse uploadCompanyPic(@RequestParam("file") MultipartFile file)
throws Exception{
String contentType = file.getContentType(); //图片文件类型
if(!contentType.equals("image/jpeg") && !contentType.equals("image/gif")){
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
}
if(file.getSize() > MAX_DRIVING_LICENSE_SIZE){
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
}
return branchCompanyStockService.uploadCompanyPic(file);
}
@IgnoreUserToken
@RequestMapping(value="/download/companyPic",method=RequestMethod.GET)
public ResponseEntity<byte[]> downloadDrivingLicense(@RequestParam("realFileRelPath") String realFileRelPath) throws Exception {
return branchCompanyStockService.downloadCompanyPic(realFileRelPath);
}
/** /**
* 申请购买 * 申请购买
...@@ -143,7 +104,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -143,7 +104,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
branchCompanyStockService.apply(applyVo); branchCompanyStockApplyInfoBiz.apply(applyVo);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -153,7 +114,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -153,7 +114,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
page = 1; page = 1;
limit = 10; limit = 10;
} }
return RestResponse.suc(branchCompanyStockService.selectApplyAll(page, limit)); return RestResponse.suc(branchCompanyStockApplyInfoBiz.selectApplyAll(page, limit));
} }
@GetMapping("apply/{id}") @GetMapping("apply/{id}")
...@@ -162,7 +123,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -162,7 +123,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
return RestResponse.suc(branchCompanyStockService.getApplyById(id)); return RestResponse.suc(branchCompanyStockApplyInfoBiz.getApplyById(id));
} }
@PutMapping("apply") @PutMapping("apply")
...@@ -171,7 +132,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -171,7 +132,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
branchCompanyStockService.updateApply(applyInfo); branchCompanyStockApplyInfoBiz.updateApply(applyInfo);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -181,7 +142,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -181,7 +142,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
branchCompanyStockService.deleteApply(id); branchCompanyStockApplyInfoBiz.deleteApply(id);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -195,7 +156,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -195,7 +156,7 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
branchCompanyStockService.cancelApply(applyId); branchCompanyStockApplyInfoBiz.cancelApply(applyId);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -208,13 +169,13 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -208,13 +169,13 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
branchCompanyStockService.buy(applyId); branchCompanyStockApplyInfoBiz.buy(applyId);
return RestResponse.suc(); return RestResponse.suc();
} }
@GetMapping("allPrice") @GetMapping("allPrice")
public RestResponse getAllPrice() { public RestResponse getAllPrice() {
return RestResponse.suc(branchCompanyStockService.getAllPrice()); return RestResponse.suc(baseBiz.getAllPrice());
} }
...@@ -225,9 +186,9 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp ...@@ -225,9 +186,9 @@ public class BranchCompanyStockRightController extends BaseController<BranchComp
* @return * @return
*/ */
@PostMapping("importExcel") @PostMapping("importExcel")
public RestResponse importExcel(@RequestParam(value = "file") MultipartFile multipartfile, public ObjectRestResponse<String> importExcel(@RequestParam(value = "file") MultipartFile multipartfile,
HttpServletRequest request) { HttpServletRequest request) {
return branchCompanyStockService.importExcel(multipartfile,request); return baseBiz.importExcel(multipartfile,request);
} }
} }
...@@ -3,14 +3,11 @@ ...@@ -3,14 +3,11 @@
<mapper namespace="com.xxfc.platform.vehicle.mapper.BranchCompanyStockRightMapper"> <mapper namespace="com.xxfc.platform.vehicle.mapper.BranchCompanyStockRightMapper">
<update id="updateBalance"> <update id="updateBalance">
update branch_company_stock_info update branch_company_stock_info_right
set balance = #{balance} set balance = #{balance}
where id = #{companyId} and balance = #{lastBalance} where id = #{companyId} and balance = #{lastBalance}
</update> </update>
<select id="selectVoAll" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyStockInfoVo">
select *
from branch_company_stock_info
</select>
<select id="search" resultType="com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo"> <select id="search" resultType="com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo">
SELECT SELECT
distinct r.company_id as companyId, distinct r.company_id as companyId,
...@@ -29,7 +26,7 @@ ...@@ -29,7 +26,7 @@
branch_company_stock_info_right r branch_company_stock_info_right r
LEFT JOIN branch_company c ON r.company_id = c.id LEFT JOIN branch_company c ON r.company_id = c.id
<trim prefix="where" suffixOverrides="and"> <trim prefix="where" suffixOverrides="and">
c.is_del = 0 c.is_del = 0 and
<if test="companyName != null"> <if test="companyName != null">
c.name like CONCAT('%',#{companyName},'%') c.name like CONCAT('%',#{companyName},'%')
</if> </if>
...@@ -46,21 +43,41 @@ ...@@ -46,21 +43,41 @@
r.price &lt;= #{priceEnd} and r.price &lt;= #{priceEnd} and
</if> </if>
</trim> </trim>
order by rank desc order by rank DESC,price DESC
</select> </select>
<select id="selectAllPrice" resultType="int"> <select id="selectAllPrice" resultType="int">
select distinct price from branch_company_stock_info order by price select distinct price from branch_company_stock_info_right where is_del=0 order by price
</select>
<select id="selectInfoById" resultType="com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo">
SELECT
distinct r.company_id as companyId,
r.id,
r.balance,
r.company_pic as companyPic,
r.info,
r.price,
r.rank,
r.total,
r.state,
c.addr_city AS addrCity,
c.addr_province AS addrProvince,
c.`name` AS companyName
FROM
branch_company_stock_info_right r
LEFT JOIN branch_company c ON r.company_id = c.id
where c.is_del = 0 and r.id=#{id} and r.is_del=0
</select> </select>
<select id="selectInfoById" resultType="String">
select info from branch_company_stock_info where id = #{id} <select id="getCompanyInfo" resultType="Integer">
SELECT id FROM branch_company WHERE `name`=#{name} and is_del=0 limit 1
</select> </select>
<insert id="addCompamyList" parameterType="java.util.List"> <insert id="addCompamyList" parameterType="java.util.List">
insert into branch_company_stock_info ( insert into branch_company_stock_info_right (
balance,total,price,company_name,addr_province,addr_city,state,company_pic company_id,balance,total,price,state,company_pic,crt_time,upd_time
) VALUES ) VALUES
<foreach collection ="list" item="item" index="index" separator =","> <foreach collection ="list" item="item" index="index" separator =",">
(#{item.balance},#{item.total},#{item.price},#{item.companyName},#{item.addrProvince},#{item.addrCity},#{item.state},#{item.companyPic}) (#{item.companyId},#{item.balance},#{item.total},#{item.price},#{item.state},#{item.companyPic},#{item.crtTime},#{item.updTime})
</foreach> </foreach>
</insert> </insert>
</mapper> </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