202 changed files with 5334 additions and 382 deletions
@ -0,0 +1,42 @@ |
|||
package io.renren.dto.stock; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "") |
|||
public class DailySentimentIndexDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "主键") |
|||
private Integer sentimentIndexId; |
|||
|
|||
@ApiModelProperty(value = "购买表主键") |
|||
private Integer purchaseInfoId; |
|||
|
|||
@ApiModelProperty(value = "") |
|||
private Integer dailySentimentIndex; |
|||
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
@ApiModelProperty(value = "") |
|||
private Date dateTime; |
|||
|
|||
@ApiModelProperty(value = "") |
|||
private String remark; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package io.renren.dto.stock; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "") |
|||
public class PurchaseDetailsDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "主键") |
|||
private Integer purchaseDetailsId; |
|||
|
|||
@ApiModelProperty(value = "购买表主键") |
|||
private Integer purchaseInfoId; |
|||
|
|||
@ApiModelProperty(value = "购买价格") |
|||
private Double purchasePrice; |
|||
|
|||
@ApiModelProperty(value = "购买数量") |
|||
private Integer stockNumber; |
|||
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
@ApiModelProperty(value = "购买时间") |
|||
private Date purchaseDate; |
|||
|
|||
@ApiModelProperty(value = "预期盈利百分比") |
|||
private Double expectProfitPercent; |
|||
|
|||
@ApiModelProperty(value = "预期止损百分比") |
|||
private Double expectLossPercent; |
|||
|
|||
@ApiModelProperty(value = "预期盈利") |
|||
private Double expectProfit; |
|||
|
|||
@ApiModelProperty(value = "预期止损") |
|||
private Double expectLoss; |
|||
|
|||
@ApiModelProperty(value = "股票名字") |
|||
private String stockName; |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
package io.renren.dto.stock; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "") |
|||
public class PurchaseInfoDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "主键") |
|||
private Integer purchaseInfoId; |
|||
|
|||
@ApiModelProperty(value = "股票代码") |
|||
private String stockCode; |
|||
|
|||
@ApiModelProperty(value = "股票名称") |
|||
private String stockName; |
|||
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
// @JsonFormat(shape = JsonFormat.Shape.STRING,pattern="yyyy-MM-dd'T'HH:mm:ss", timezone="GMT+8")
|
|||
// @DateTimeFormat(pattern="yyyy-MM-dd'T'HH:mm:ss")
|
|||
@ApiModelProperty(value = "购买时间") |
|||
private Date purchaseDate; |
|||
|
|||
@ApiModelProperty(value = "购买股票价格") |
|||
private Double stockAveragePrice; |
|||
|
|||
@ApiModelProperty(value = "是否进行基本面分析1:是,0:否") |
|||
private String fundamentalAnalysis; |
|||
|
|||
@ApiModelProperty(value = "VCP周期") |
|||
private String vcpPeriod; |
|||
|
|||
@ApiModelProperty(value = "购买类型1:上升中的调整,2:突破买入,3下跌结束") |
|||
private String purchaseType; |
|||
|
|||
@ApiModelProperty(value = "购买原因") |
|||
private String purchaseReason; |
|||
|
|||
@ApiModelProperty(value = "是否平仓1:平仓,0:未平仓") |
|||
private String closePosition; |
|||
|
|||
@ApiModelProperty(value = "是否盈利1:盈利,0:损失") |
|||
private String profitOrLoss; |
|||
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
@ApiModelProperty(value = "卖出时间") |
|||
private Date sellDate; |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.dto.stock; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "") |
|||
public class TbImportInfoDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "import_id") |
|||
private Integer importId; |
|||
|
|||
@ApiModelProperty(value = "我的和老婆的账户") |
|||
private String capitalAccount; |
|||
|
|||
@ApiModelProperty(value = "导入时间") |
|||
private Date importTime; |
|||
|
|||
@ApiModelProperty(value = "交易开始日期") |
|||
private String transStartDate; |
|||
|
|||
@ApiModelProperty(value = "交易结束日期") |
|||
private String transEndDate; |
|||
|
|||
@ApiModelProperty(value = "总仓位") |
|||
private Float stockPosition; |
|||
|
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.dto.stock; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
@ApiModel(value = "股票盈亏汇总") |
|||
public class TbStockReportDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "卖出周期") |
|||
private String sellPeriod; |
|||
|
|||
@ApiModelProperty(value = "平均盈利百分比") |
|||
private Float gainPercent; |
|||
|
|||
@ApiModelProperty(value = "平均亏损百分比") |
|||
private Float lossPercent; |
|||
|
|||
@ApiModelProperty(value = "盈利交易数") |
|||
private Integer gainCount; |
|||
|
|||
@ApiModelProperty(value = "亏损交易数") |
|||
private Integer lossCount; |
|||
|
|||
@ApiModelProperty(value = "总交易数") |
|||
private Integer totalCount; |
|||
|
|||
@ApiModelProperty(value = "成功百分比") |
|||
private Float successPercent; |
|||
|
|||
@ApiModelProperty(value = "盈利亏损百分比") |
|||
private Float gainLossPercent; |
|||
|
|||
@ApiModelProperty(value = "乘积") |
|||
private Float product; |
|||
|
|||
@ApiModelProperty(value = "总收益") |
|||
@JsonFormat(shape =JsonFormat.Shape.STRING) |
|||
private Float totalProfitAmount; |
|||
|
|||
@ApiModelProperty(value = "最大盈利百分比") |
|||
private Float maxGainPercent; |
|||
|
|||
@ApiModelProperty(value = "最大亏损百分比") |
|||
private Float maxLossPercent; |
|||
|
|||
@ApiModelProperty(value = "盈利总天数") |
|||
private Integer sumGainDays; |
|||
|
|||
@ApiModelProperty(value = "亏损总天数") |
|||
private Integer sumLossDays; |
|||
|
|||
@ApiModelProperty(value = "盈利股票最长持有天数") |
|||
private Integer maxGainDays; |
|||
|
|||
@ApiModelProperty(value = "亏损股票最长持有天数") |
|||
private Integer maxLossDays; |
|||
|
|||
@ApiModelProperty(value = "平均成交量((买入+卖出)/2)") |
|||
private Integer averTradingVolume; |
|||
|
|||
@ApiModelProperty(value = "成交量与全仓占比") |
|||
private BigDecimal tradingVolumeRatioWithWhole; |
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.dto.stock; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-03 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "各个股票盈亏") |
|||
public class TbStockResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "stockId") |
|||
private Integer stockId; |
|||
|
|||
@ApiModelProperty(value = "买入日期") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8") |
|||
private Date buyTransDate; |
|||
|
|||
@ApiModelProperty(value = "卖出日期") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8") |
|||
private Date sellTransDate; |
|||
|
|||
@ApiModelProperty(value = "持仓天数") |
|||
private Integer holdDays; |
|||
|
|||
@ApiModelProperty(value = "证券代码") |
|||
private String stockCode; |
|||
|
|||
@ApiModelProperty(value = "证券名称") |
|||
private String stockName; |
|||
|
|||
@ApiModelProperty(value = "成本价格") |
|||
private Float costPrice; |
|||
|
|||
@ApiModelProperty(value = "卖出价格") |
|||
private Float sellPrice; |
|||
|
|||
@ApiModelProperty(value = "成交数量") |
|||
private Integer transQuantity; |
|||
|
|||
@ApiModelProperty(value = "成本总金额") |
|||
private Float costAmount; |
|||
|
|||
@ApiModelProperty(value = "卖出总金额") |
|||
private Float sellAmount; |
|||
|
|||
@ApiModelProperty(value = "盈利/亏损") |
|||
private Float gainLossAmount; |
|||
|
|||
@ApiModelProperty(value = "盈利/亏损百分比") |
|||
private Float gainLossPercent; |
|||
|
|||
@ApiModelProperty(value = "总费用") |
|||
private Float totalCharge; |
|||
|
|||
@ApiModelProperty(value = "股东代码") |
|||
private String shareholderCode; |
|||
|
|||
@ApiModelProperty(value = "资金帐号") |
|||
private String capitalAccount; |
|||
|
|||
@ApiModelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
@ApiModelProperty(value = "总结教训") |
|||
private String summary; |
|||
|
|||
@ApiModelProperty(value = "创建时间") |
|||
private Date createDate; |
|||
|
|||
@ApiModelProperty(value = "修改时间") |
|||
private Date updateDate; |
|||
|
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.dto.stock; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-21 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "") |
|||
public class TbTransDetailDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@TableId(type = IdType.INPUT) |
|||
@ApiModelProperty(value = "id") |
|||
private Integer transId; |
|||
|
|||
@ApiModelProperty(value = "导入id") |
|||
private Integer importId; |
|||
|
|||
@ApiModelProperty(value = "发生日期") |
|||
private String transDate; |
|||
|
|||
@ApiModelProperty(value = "成交时间") |
|||
private String transTime; |
|||
|
|||
@ApiModelProperty(value = "证券买入,证券卖出") |
|||
private String busiType; |
|||
|
|||
@ApiModelProperty(value = "证券代码") |
|||
private String stockCode; |
|||
|
|||
@ApiModelProperty(value = "证券名称") |
|||
private String stockName; |
|||
|
|||
@ApiModelProperty(value = "成交价格") |
|||
private Float transPrice; |
|||
|
|||
@ApiModelProperty(value = "成交数量") |
|||
private Integer transQuantity; |
|||
|
|||
@ApiModelProperty(value = "成交金额") |
|||
private Float transAmount; |
|||
|
|||
@ApiModelProperty(value = "股份余额") |
|||
private Integer shareBalance; |
|||
|
|||
@ApiModelProperty(value = "手续费") |
|||
private Float serviceCharge; |
|||
|
|||
@ApiModelProperty(value = "印花税") |
|||
private Float stampDuty; |
|||
|
|||
@ApiModelProperty(value = "过户费") |
|||
private Float transferFee; |
|||
|
|||
@ApiModelProperty(value = "附加费") |
|||
private Float additionalCharge; |
|||
|
|||
@ApiModelProperty(value = "交易所清算费") |
|||
private Float exchangeFees; |
|||
|
|||
@ApiModelProperty(value = "发生金额") |
|||
private Float occurrenceAmount; |
|||
|
|||
@ApiModelProperty(value = "资金本次余额") |
|||
private Float capitalBalance; |
|||
|
|||
@ApiModelProperty(value = "委托编号") |
|||
private String entrustingSerial; |
|||
|
|||
@ApiModelProperty(value = "流水号") |
|||
private String serialNumber; |
|||
|
|||
@ApiModelProperty(value = "股东代码") |
|||
private String shareholderCode; |
|||
|
|||
@ApiModelProperty(value = "资金帐号") |
|||
private String capitalAccount; |
|||
|
|||
@ApiModelProperty(value = "币种") |
|||
private String currency; |
|||
|
|||
@ApiModelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
@ApiModelProperty(value = "创建时间") |
|||
private Date createDate; |
|||
|
|||
@ApiModelProperty(value = "修改时间") |
|||
private Date updateDate; |
|||
|
|||
@ApiModelProperty(value = "买入原因") |
|||
private String reason; |
|||
|
|||
@ApiModelProperty(value = "汇总标识:0,未汇总,1,已汇总") |
|||
private Integer gatherFlag; |
|||
|
|||
@ApiModelProperty(value = "持股天数") |
|||
private String holdDays; |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd" |
|||
> |
|||
<formats> |
|||
<format>zip</format> |
|||
<!-- format>tar.gz</format --> |
|||
<!-- format>dir</format --> |
|||
</formats> |
|||
<dependencySets> |
|||
|
|||
<dependencySet> |
|||
<unpack>false</unpack> |
|||
<outputDirectory>lib</outputDirectory> |
|||
<useTransitiveFiltering>true</useTransitiveFiltering> |
|||
<useStrictFiltering>true</useStrictFiltering> |
|||
<fileMode>666</fileMode> |
|||
<includes> |
|||
<include>com.gooddeep.dev:gooddeep-service</include> |
|||
</includes> |
|||
</dependencySet> |
|||
</dependencySets> |
|||
<fileSets> |
|||
<fileSet> |
|||
<directory>/home/lhy/Workspaces/MyEclipse_data/gooddeep-dev/dev-core/target/dubbo</directory> |
|||
<outputDirectory>dubbo/</outputDirectory> |
|||
<filtered>false</filtered> |
|||
</fileSet> |
|||
<fileSet> |
|||
<directory>/home/lhy/Workspaces/MyEclipse_data/gooddeep-dev/dev-elasticsearch/target/dubbo</directory> |
|||
<outputDirectory>dubbo/</outputDirectory> |
|||
<filtered>false</filtered> |
|||
</fileSet> |
|||
</fileSets> |
|||
</assembly> |
|||
@ -0,0 +1,26 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package io.renren.stock.config; |
|||
|
|||
import io.renren.commons.tools.config.ModuleConfig; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 模块配置信息 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Service |
|||
public class StockConfigImpl implements ModuleConfig { |
|||
@Override |
|||
public String getName() { |
|||
return "stock"; |
|||
} |
|||
} |
|||
@ -0,0 +1,176 @@ |
|||
package io.renren.stock.controller; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import io.renren.commons.tools.annotation.LogOperation; |
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ExcelUtils; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.commons.tools.validator.AssertUtils; |
|||
import io.renren.commons.tools.validator.ValidatorUtils; |
|||
import io.renren.commons.tools.validator.group.AddGroup; |
|||
import io.renren.commons.tools.validator.group.DefaultGroup; |
|||
import io.renren.commons.tools.validator.group.UpdateGroup; |
|||
import io.renren.dto.stock.DailySentimentIndexDTO; |
|||
import io.renren.dto.stock.PurchaseInfoDTO; |
|||
import io.renren.stock.excel.DailySentimentIndexExcel; |
|||
import io.renren.stock.service.DailySentimentIndexService; |
|||
import io.renren.stock.service.PurchaseInfoService; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "dailysentimentindex") |
|||
@Api(tags="") |
|||
public class DailySentimentIndexController { |
|||
@Autowired |
|||
private DailySentimentIndexService dailySentimentIndexService; |
|||
|
|||
@Autowired |
|||
PurchaseInfoService purchaseInfoService; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") |
|||
}) |
|||
|
|||
public Result<PageData<DailySentimentIndexDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
PageData<DailySentimentIndexDTO> page = dailySentimentIndexService.page(params); |
|||
|
|||
return new Result<PageData<DailySentimentIndexDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("echartdata") |
|||
public Result<List<DailySentimentIndexDTO>> getEchartData(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
List<DailySentimentIndexDTO> list = dailySentimentIndexService.list(params); |
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|||
PurchaseInfoDTO purchaseInfoDTO = purchaseInfoService.list(params).get(0); |
|||
|
|||
// 给折线中没有值的日期加默认的0值
|
|||
List<DailySentimentIndexDTO> allDataList = new ArrayList<>(); |
|||
try{ |
|||
//起始日期
|
|||
Date start = purchaseInfoDTO.getPurchaseDate(); |
|||
//结束日期
|
|||
Date end; |
|||
if(ObjectUtil.isNotNull(purchaseInfoDTO.getSellDate())){ |
|||
end = purchaseInfoDTO.getSellDate(); |
|||
}else { |
|||
end = sdf.parse(sdf.format(new Date())); |
|||
} |
|||
Date temp = start; |
|||
Calendar calendar = Calendar.getInstance(); |
|||
calendar.setTime(start); |
|||
DailySentimentIndexDTO dsiDTO = null; |
|||
boolean exist = false; |
|||
while(temp.getTime()<end.getTime()){ |
|||
exist = false; |
|||
// 周6,日跳过
|
|||
if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ |
|||
calendar.add(Calendar.DAY_OF_MONTH,1); |
|||
continue; |
|||
} |
|||
temp = calendar.getTime(); |
|||
System.out.println("所得到的日期:"+sdf.format(temp)); |
|||
dsiDTO = new DailySentimentIndexDTO(); |
|||
for (DailySentimentIndexDTO dailySentimentIndexDTO : list) { |
|||
if(sdf.format(temp).equals(sdf.format(dailySentimentIndexDTO.getDateTime()))){ |
|||
dsiDTO.setDateTime(temp); |
|||
dsiDTO.setDailySentimentIndex(dailySentimentIndexDTO.getDailySentimentIndex()); |
|||
dsiDTO.setPurchaseInfoId(dailySentimentIndexDTO.getPurchaseInfoId()); |
|||
dsiDTO.setRemark(dailySentimentIndexDTO.getRemark()); |
|||
exist = true; |
|||
break; |
|||
} |
|||
} |
|||
if(!exist){ |
|||
dsiDTO.setDailySentimentIndex(0); |
|||
dsiDTO.setDateTime(temp); |
|||
} |
|||
allDataList.add(dsiDTO); |
|||
|
|||
//天数+1
|
|||
calendar.add(Calendar.DAY_OF_MONTH,1); |
|||
} |
|||
|
|||
}catch(Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
return new Result<List<DailySentimentIndexDTO>>().ok(allDataList); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@ApiOperation("信息") |
|||
public Result<DailySentimentIndexDTO> get(@PathVariable("id") Long id){ |
|||
DailySentimentIndexDTO data = dailySentimentIndexService.get(id); |
|||
|
|||
return new Result<DailySentimentIndexDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("保存") |
|||
@LogOperation("保存") |
|||
public Result save(@RequestBody DailySentimentIndexDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
|
|||
dailySentimentIndexService.save(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@ApiOperation("修改") |
|||
@LogOperation("修改") |
|||
public Result update(@RequestBody DailySentimentIndexDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
|
|||
dailySentimentIndexService.update(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
@LogOperation("删除") |
|||
public Result delete(@RequestBody Long[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
|
|||
dailySentimentIndexService.delete(ids); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
@ApiOperation("导出") |
|||
@LogOperation("导出") |
|||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<DailySentimentIndexDTO> list = dailySentimentIndexService.list(params); |
|||
|
|||
ExcelUtils.exportExcelToTarget(response, null, list, DailySentimentIndexExcel.class); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
package io.renren.stock.controller; |
|||
|
|||
import io.renren.commons.tools.annotation.LogOperation; |
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ExcelUtils; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.commons.tools.validator.AssertUtils; |
|||
import io.renren.commons.tools.validator.ValidatorUtils; |
|||
import io.renren.commons.tools.validator.group.AddGroup; |
|||
import io.renren.commons.tools.validator.group.DefaultGroup; |
|||
import io.renren.commons.tools.validator.group.UpdateGroup; |
|||
import io.renren.dto.stock.PurchaseDetailsDTO; |
|||
import io.renren.stock.excel.PurchaseDetailsExcel; |
|||
import io.renren.stock.service.PurchaseDetailsService; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "purchasedetails") |
|||
@Api(tags="") |
|||
public class PurchaseDetailsController { |
|||
@Autowired |
|||
private PurchaseDetailsService purchaseDetailsService; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") |
|||
}) |
|||
public Result<PageData<PurchaseDetailsDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
PageData<PurchaseDetailsDTO> page = purchaseDetailsService.page(params); |
|||
|
|||
return new Result<PageData<PurchaseDetailsDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@ApiOperation("信息") |
|||
public Result<PurchaseDetailsDTO> get(@PathVariable("id") Long id){ |
|||
PurchaseDetailsDTO data = purchaseDetailsService.get(id); |
|||
|
|||
return new Result<PurchaseDetailsDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("保存") |
|||
@LogOperation("保存") |
|||
public Result save(@RequestBody PurchaseDetailsDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
|
|||
purchaseDetailsService.save(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@ApiOperation("修改") |
|||
@LogOperation("修改") |
|||
public Result update(@RequestBody PurchaseDetailsDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
|
|||
purchaseDetailsService.update(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
@LogOperation("删除") |
|||
public Result delete(@RequestBody Long[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
|
|||
purchaseDetailsService.delete(ids); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
@ApiOperation("导出") |
|||
@LogOperation("导出") |
|||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PurchaseDetailsDTO> list = purchaseDetailsService.list(params); |
|||
|
|||
ExcelUtils.exportExcelToTarget(response, null, list, PurchaseDetailsExcel.class); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,193 @@ |
|||
package io.renren.stock.controller; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import io.renren.commons.tools.annotation.LogOperation; |
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ExcelUtils; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.commons.tools.validator.AssertUtils; |
|||
import io.renren.commons.tools.validator.ValidatorUtils; |
|||
import io.renren.commons.tools.validator.group.AddGroup; |
|||
import io.renren.commons.tools.validator.group.DefaultGroup; |
|||
import io.renren.commons.tools.validator.group.UpdateGroup; |
|||
import io.renren.dto.stock.DailySentimentIndexDTO; |
|||
import io.renren.dto.stock.PurchaseDetailsDTO; |
|||
import io.renren.dto.stock.PurchaseInfoDTO; |
|||
import io.renren.dto.sys.SysDictDTO; |
|||
import io.renren.remote.DictRemoteService; |
|||
import io.renren.stock.entity.PurchaseInfoEntity; |
|||
import io.renren.stock.enums.DictTypeEnum; |
|||
import io.renren.stock.excel.PurchaseInfoExcel; |
|||
import io.renren.stock.service.DailySentimentIndexService; |
|||
import io.renren.stock.service.PurchaseDetailsService; |
|||
import io.renren.stock.service.PurchaseInfoService; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.text.DecimalFormat; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "purchaseinfo") |
|||
@Api(tags="") |
|||
public class PurchaseInfoController { |
|||
@Autowired |
|||
private PurchaseInfoService purchaseInfoService; |
|||
|
|||
@Autowired |
|||
private PurchaseDetailsService purchaseDetailsService; |
|||
|
|||
@Autowired |
|||
private DictRemoteService dictRemoteService; |
|||
@Autowired |
|||
private DailySentimentIndexService dailySentimentIndexService; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") |
|||
}) |
|||
public Result<PageData<PurchaseInfoDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
PageData<PurchaseInfoDTO> page = purchaseInfoService.page(params); |
|||
//字典分类数据
|
|||
Map parasList = new HashMap<String, Object>(); |
|||
parasList.put("dictType", DictTypeEnum.purchase_type); |
|||
Map<String, String> purchaseType = ((List<SysDictDTO>)dictRemoteService.list(parasList).getData()) |
|||
.stream().collect(Collectors.toMap(o->o.getDictValue(),o -> o.getDictName())); |
|||
|
|||
parasList.clear(); |
|||
parasList.put("dictType", DictTypeEnum.close_position); |
|||
Map<String, String> closePosition = ((List<SysDictDTO>)dictRemoteService.list(parasList).getData()) |
|||
.stream().collect(Collectors.toMap(o->o.getDictValue(),o -> o.getDictName())); |
|||
|
|||
parasList.clear(); |
|||
parasList.put("dictType", DictTypeEnum.profit_or_loss); |
|||
Map<String, String> profitOrLoss = ((List<SysDictDTO>)dictRemoteService.list(parasList).getData()) |
|||
.stream().collect(Collectors.toMap(o->o.getDictValue(),o -> o.getDictName())); |
|||
|
|||
parasList.clear(); |
|||
parasList.put("dictType", DictTypeEnum.fundamental_analysis); |
|||
Map<String, String> fundamental_analysis = ((List<SysDictDTO>)dictRemoteService.list(parasList).getData()) |
|||
.stream().collect(Collectors.toMap(o->o.getDictValue(),o -> o.getDictName())); |
|||
|
|||
|
|||
page.getList().forEach(purchaseInfoDTO -> { |
|||
purchaseInfoDTO.setPurchaseType(purchaseType.get(purchaseInfoDTO.getPurchaseType())); |
|||
purchaseInfoDTO.setClosePosition(closePosition.get(purchaseInfoDTO.getClosePosition())); |
|||
purchaseInfoDTO.setProfitOrLoss(profitOrLoss.get(purchaseInfoDTO.getProfitOrLoss())); |
|||
purchaseInfoDTO.setFundamentalAnalysis(fundamental_analysis.get(purchaseInfoDTO.getFundamentalAnalysis())); |
|||
// 求购买评价价格
|
|||
Map paras = new HashMap<String,String>(); |
|||
paras.put("purchaseInfoId", purchaseInfoDTO.getPurchaseInfoId().toString()); |
|||
List<PurchaseDetailsDTO> list = purchaseDetailsService.list(paras); |
|||
if(CollUtil.isNotEmpty(list) && list.size() != 0){ |
|||
// Double sum = list.stream().filter(x -> x.getPurchasePrice()!=null).collect(
|
|||
// Collectors.summingDouble((PurchaseDetailsDTO::getPurchasePrice)));
|
|||
Integer totalCounts = 0; |
|||
Double totalCost = 0.0; |
|||
for (PurchaseDetailsDTO purchaseDetailsDTO : list) { |
|||
totalCounts += purchaseDetailsDTO.getStockNumber(); |
|||
totalCost += purchaseDetailsDTO.getStockNumber() * purchaseDetailsDTO.getPurchasePrice(); |
|||
} |
|||
purchaseInfoDTO.setStockAveragePrice(Double.parseDouble(new DecimalFormat("#.00").format(totalCost/totalCounts))); |
|||
}else { |
|||
purchaseInfoDTO.setStockAveragePrice(new Double(0)); |
|||
} |
|||
}); |
|||
|
|||
return new Result<PageData<PurchaseInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@ApiOperation("信息") |
|||
public Result<PurchaseInfoDTO> get(@PathVariable("id") Long id){ |
|||
PurchaseInfoDTO data = purchaseInfoService.get(id); |
|||
return new Result<PurchaseInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("保存") |
|||
@LogOperation("保存") |
|||
public Result save(@RequestBody PurchaseInfoDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
|
|||
PurchaseInfoEntity purchaseInfoEntity = purchaseInfoService.saveReturn(dto); |
|||
DailySentimentIndexDTO dailySentimentIndexDTO = new DailySentimentIndexDTO(); |
|||
// 默认情绪指数是1 情绪好
|
|||
dailySentimentIndexDTO.setDailySentimentIndex(1); |
|||
dailySentimentIndexDTO.setPurchaseInfoId(purchaseInfoEntity.getPurchaseInfoId()); |
|||
dailySentimentIndexDTO.setDateTime(dto.getPurchaseDate()); |
|||
dailySentimentIndexService.save(dailySentimentIndexDTO); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@ApiOperation("修改") |
|||
@LogOperation("修改") |
|||
public Result update(@RequestBody PurchaseInfoDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
|
|||
purchaseInfoService.update(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
@LogOperation("删除") |
|||
public Result delete(@RequestBody Long[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
for (Long id : ids) { |
|||
purchaseDetailsService.deleteBypurchaseInfoId(id.intValue()); |
|||
dailySentimentIndexService.deleteBypurchaseInfoId(id.intValue()); |
|||
} |
|||
purchaseInfoService.delete(ids); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
@ApiOperation("导出") |
|||
@LogOperation("导出") |
|||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
|
|||
List<PurchaseInfoDTO> list = purchaseInfoService.list(params); |
|||
|
|||
ExcelUtils.exportExcelToTarget(response, null, list, PurchaseInfoExcel.class); |
|||
} |
|||
|
|||
@GetMapping("stockCodeName") |
|||
@ApiOperation("代码和名字数据") |
|||
public Result<Map<String, String>> stockCodeName(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
//字典分类数据
|
|||
Map<String, String> collect = purchaseInfoService.list(params) |
|||
.stream().collect(Collectors.toMap(o -> o.getStockCode(), o -> o.getStockName(), (v1, v2) -> v2)); |
|||
|
|||
return new Result<Map<String, String>>().ok(collect); |
|||
} |
|||
} |
|||
@ -0,0 +1,157 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.controller; |
|||
|
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.exception.RenException; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.commons.tools.utils.ExcelUtils; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.commons.tools.validator.AssertUtils; |
|||
import io.renren.commons.tools.validator.ValidatorUtils; |
|||
import io.renren.commons.tools.validator.group.AddGroup; |
|||
import io.renren.commons.tools.validator.group.DefaultGroup; |
|||
import io.renren.commons.tools.validator.group.UpdateGroup; |
|||
import io.renren.dto.stock.TbImportInfoDTO; |
|||
import io.renren.stock.entity.TbImportInfoEntity; |
|||
import io.renren.stock.excel.TbImportInfoExcel; |
|||
import io.renren.stock.service.TbImportInfoService; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.apache.commons.collections4.map.HashedMap; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "importinfo") |
|||
@Api(tags="") |
|||
public class TbImportInfoController { |
|||
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TbImportInfoController.class); |
|||
@Autowired |
|||
private TbImportInfoService tbImportInfoService; |
|||
|
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") |
|||
}) |
|||
public Result<PageData<TbImportInfoDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
PageData<TbImportInfoDTO> page = tbImportInfoService.page(params); |
|||
|
|||
return new Result<PageData<TbImportInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@ApiOperation("信息") |
|||
public Result<TbImportInfoDTO> get(@PathVariable("id") String id){ |
|||
TbImportInfoDTO data = tbImportInfoService.get(id); |
|||
|
|||
return new Result<TbImportInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("保存") |
|||
public Result save(@RequestBody TbImportInfoDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
|
|||
tbImportInfoService.save(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("one") |
|||
@ApiOperation("保存") |
|||
private Result one(@RequestBody TbImportInfoDTO dto) { |
|||
Integer importId = null; |
|||
if (dto.getCapitalAccount() != null && !dto.getCapitalAccount().equals("-1")){ |
|||
Map<String, Object> params = new HashedMap<>(); |
|||
params.put("capitalAccount", dto.getCapitalAccount()); |
|||
params.put("transStartDate", dto.getTransStartDate()); |
|||
params.put("transEndDate", dto.getTransEndDate()); |
|||
List<TbImportInfoDTO> list = tbImportInfoService.list(params); |
|||
|
|||
if (list != null && list.size() > 0) { |
|||
importId = list.get(0).getImportId(); |
|||
} else { |
|||
TbImportInfoEntity importInfoEntity = ConvertUtils.sourceToTarget(dto, TbImportInfoEntity.class); |
|||
tbImportInfoService.insertImportInfo(importInfoEntity); |
|||
LOGGER.info("ImportId:::" + importInfoEntity.getImportId() + ""); |
|||
LOGGER.info("存储数据库成功!"); |
|||
importId = importInfoEntity.getImportId(); |
|||
} |
|||
}else{ |
|||
throw new RenException(10017); |
|||
} |
|||
return new Result().ok(importId); |
|||
} |
|||
|
|||
@PutMapping |
|||
@ApiOperation("修改") |
|||
public Result update(@RequestBody TbImportInfoDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
|
|||
tbImportInfoService.update(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
|
|||
tbImportInfoService.delete(ids); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
@ApiOperation("导出") |
|||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<TbImportInfoDTO> list = tbImportInfoService.list(params); |
|||
|
|||
ExcelUtils.exportExcelToTarget(response, null, list, TbImportInfoExcel.class); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.controller; |
|||
|
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.dto.stock.TbStockReportDTO; |
|||
import io.renren.stock.service.TbStockReportService; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "stockreport") |
|||
@Api(tags="") |
|||
public class TbStockReportController { |
|||
@Autowired |
|||
private TbStockReportService stockReportService; |
|||
|
|||
|
|||
@GetMapping("/page") |
|||
@ApiOperation("报表搜索(分页)") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = "capitalAccount", value = "搜索字段", paramType = "query",required = true, dataType="String"), |
|||
@ApiImplicitParam(name = "transStartDate", value = "卖出开始日期", paramType = "query",required = false, dataType="String"), |
|||
@ApiImplicitParam(name = "transEndDate", value = "卖出结束日期", paramType = "query",required = false, dataType="String") |
|||
}) |
|||
public Result<PageData<TbStockReportDTO>> selStockReportBySearch(@ApiIgnore @RequestParam Map<String,Object> params) throws ParseException { |
|||
|
|||
if(params.get(Constant.PAGE)!=null){ |
|||
PageData<TbStockReportDTO> dtoList = stockReportService.sumStockReport(params); |
|||
return new Result<PageData<TbStockReportDTO>>().ok(dtoList); |
|||
} |
|||
return new Result<PageData<TbStockReportDTO>>().ok(null); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,123 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.controller; |
|||
|
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ExcelUtils; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.commons.tools.validator.AssertUtils; |
|||
import io.renren.commons.tools.validator.ValidatorUtils; |
|||
import io.renren.commons.tools.validator.group.AddGroup; |
|||
import io.renren.commons.tools.validator.group.DefaultGroup; |
|||
import io.renren.commons.tools.validator.group.UpdateGroup; |
|||
import io.renren.dto.stock.TbStockResultDTO; |
|||
import io.renren.stock.excel.TbStockResultExcel; |
|||
import io.renren.stock.service.TbStockResultService; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "stockresult") |
|||
@Api(tags="") |
|||
public class TbStockResultController { |
|||
|
|||
@Autowired |
|||
private TbStockResultService tbStockResultService; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") |
|||
}) |
|||
public Result<PageData<TbStockResultDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
PageData<TbStockResultDTO> page = tbStockResultService.page(params); |
|||
|
|||
return new Result<PageData<TbStockResultDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{stockId}") |
|||
@ApiOperation("信息") |
|||
public Result<TbStockResultDTO> get(@PathVariable("stockId") String stockId){ |
|||
TbStockResultDTO data = tbStockResultService.get(stockId); |
|||
|
|||
return new Result<TbStockResultDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("保存") |
|||
public Result save(@RequestBody TbStockResultDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
|
|||
tbStockResultService.save(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@ApiOperation("修改") |
|||
public Result update(@RequestBody TbStockResultDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
|
|||
tbStockResultService.update(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
|
|||
tbStockResultService.delete(ids); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
@ApiOperation("导出") |
|||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<TbStockResultDTO> list = tbStockResultService.list(params); |
|||
|
|||
ExcelUtils.exportExcelToTarget(response, null, list, TbStockResultExcel.class); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,192 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.controller; |
|||
|
|||
import com.alibaba.excel.EasyExcel; |
|||
import com.alibaba.excel.ExcelReader; |
|||
import com.alibaba.excel.read.metadata.ReadSheet; |
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ExcelUtils; |
|||
import io.renren.commons.tools.utils.Result; |
|||
import io.renren.commons.tools.validator.AssertUtils; |
|||
import io.renren.commons.tools.validator.ValidatorUtils; |
|||
import io.renren.commons.tools.validator.group.AddGroup; |
|||
import io.renren.commons.tools.validator.group.DefaultGroup; |
|||
import io.renren.commons.tools.validator.group.UpdateGroup; |
|||
import io.renren.dto.stock.TbImportInfoDTO; |
|||
import io.renren.dto.stock.TbTransDetailDTO; |
|||
import io.renren.remote.DictRemoteService; |
|||
import io.renren.stock.entity.TbTransDetailEntity; |
|||
import io.renren.stock.excel.TbTransDetailExcel; |
|||
import io.renren.stock.listener.TransDetailDataListener; |
|||
import io.renren.stock.service.TbTransDetailService; |
|||
import io.renren.stock.utils.RestResponse; |
|||
import io.renren.stock.utils.StockConstant; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.apache.commons.collections4.map.HashedMap; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(StockConstant.MODULE_PREFIX + "transdetail") |
|||
@Api(tags="明细表")//股票交易
|
|||
public class TbTransDetailController { |
|||
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TbTransDetailController.class); |
|||
|
|||
@Autowired |
|||
private DictRemoteService dictRemoteService; |
|||
@Autowired |
|||
private TbTransDetailService tbTransDetailService; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") |
|||
}) |
|||
public Result<PageData<TbTransDetailDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
|
|||
// Map<String, Object> dictParams = new HashedMap<>();
|
|||
// Result<List<SysDictDTO>> list = dictRemoteService.list(dictParams);
|
|||
|
|||
PageData<TbTransDetailDTO> page = tbTransDetailService.page(params); |
|||
|
|||
return new Result<PageData<TbTransDetailDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@ApiOperation("信息") |
|||
public Result<TbTransDetailDTO> get(@PathVariable("id") String id){ |
|||
TbTransDetailDTO data = tbTransDetailService.get(id); |
|||
|
|||
return new Result<TbTransDetailDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("保存") |
|||
public Result save(@RequestBody TbTransDetailDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
|
|||
tbTransDetailService.save(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@ApiOperation("修改") |
|||
public Result update(@RequestBody TbTransDetailDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
|
|||
tbTransDetailService.update(dto); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
|
|||
tbTransDetailService.delete(ids); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
@ApiOperation("导出") |
|||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<TbTransDetailDTO> list = tbTransDetailService.list(params); |
|||
|
|||
ExcelUtils.exportExcelToTarget(response, "股票交易明细表_"+null, list, TbTransDetailExcel.class); |
|||
} |
|||
|
|||
@PostMapping("upload") |
|||
@ResponseBody |
|||
@ApiOperation("上传EXCEL") |
|||
public RestResponse upload(MultipartFile file, String importId) throws IOException { |
|||
|
|||
// 初始化ajax返回对象 默认是操作成功
|
|||
RestResponse build = RestResponse.buildSuccess(null); |
|||
|
|||
ExcelReader excelReader = null; |
|||
try { |
|||
|
|||
// excelReader = EasyExcel.read(file.getInputStream(), TbImportInfoEntity.class, new ImportInfoDataListener(build,tbImportInfoService)).build();
|
|||
// ReadSheet readSheet = EasyExcel.readSheet(0).build();
|
|||
// excelReader.read(readSheet);
|
|||
//
|
|||
// if(build.getStatus()==200) {
|
|||
|
|||
excelReader = EasyExcel.read(file.getInputStream(), TbTransDetailEntity.class, new TransDetailDataListener(build,tbTransDetailService,importId)).build(); |
|||
ReadSheet readSheet = EasyExcel.readSheet(0).build(); |
|||
excelReader.read(readSheet); |
|||
// }
|
|||
|
|||
} finally { |
|||
if (excelReader != null) { |
|||
// 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的
|
|||
excelReader.finish(); |
|||
} |
|||
} |
|||
|
|||
return build; |
|||
} |
|||
|
|||
@PostMapping("combine") |
|||
@ResponseBody |
|||
@ApiOperation("合并买卖的股票") |
|||
public Result combine(@RequestBody TbImportInfoDTO dto){ |
|||
|
|||
Map<String, Object> map = new HashedMap<String, Object>(); |
|||
if(dto.getCapitalAccount() != null && dto.getTransStartDate() != null && dto.getTransEndDate() != null) { |
|||
map.put("p_capital_account", dto.getCapitalAccount()); |
|||
map.put("p_trans_start_date", dto.getTransStartDate().replaceAll("-","")); |
|||
map.put("p_trans_end_date", dto.getTransEndDate().replaceAll("-","")); |
|||
tbTransDetailService.combineStock(map); |
|||
System.out.println(map.get("p_completed_count")); |
|||
} |
|||
return new Result().ok(map); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.stock.entity.DailySentimentIndexEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Mapper |
|||
public interface DailySentimentIndexDao extends BaseDao<DailySentimentIndexEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.stock.entity.PurchaseDetailsEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Mapper |
|||
public interface PurchaseDetailsDao extends BaseDao<PurchaseDetailsEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.stock.entity.PurchaseInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Mapper |
|||
public interface PurchaseInfoDao extends BaseDao<PurchaseInfoEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.stock.entity.TbImportInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@Mapper |
|||
public interface TbImportInfoDao extends BaseDao<TbImportInfoEntity> { |
|||
|
|||
void insertImportInfo(TbImportInfoEntity importInfoEntity); |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.dto.stock.TbStockReportDTO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@Mapper |
|||
public interface TbStockReportDao extends BaseDao<TbStockReportDTO> { |
|||
|
|||
List<TbStockReportDTO> selStockReportByPeriod(Map<String, Object> params); |
|||
|
|||
List<TbStockReportDTO> sumStockReportByPeriod(Map<String, Object> params); |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.stock.entity.TbStockResultEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@Mapper |
|||
public interface TbStockResultDao extends BaseDao<TbStockResultEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.dao; |
|||
|
|||
import io.renren.commons.mybatis.dao.BaseDao; |
|||
import io.renren.stock.entity.TbTransDetailEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
@Mapper |
|||
public interface TbTransDetailDao extends BaseDao<TbTransDetailEntity> { |
|||
|
|||
void combineStock(Map<String, Object> map); |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package io.renren.stock.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
@TableName("tb_daily_sentiment_index") |
|||
public class DailySentimentIndexEntity { |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer sentimentIndexId; |
|||
/** |
|||
* 购买表主键 |
|||
*/ |
|||
private Integer purchaseInfoId; |
|||
/** |
|||
* 情绪指使-10至10 |
|||
*/ |
|||
private Integer dailySentimentIndex; |
|||
/** |
|||
* 当天时间 |
|||
*/ |
|||
private Date dateTime; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package io.renren.stock.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
@TableName("tb_purchase_details") |
|||
public class PurchaseDetailsEntity { |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer purchaseDetailsId; |
|||
/** |
|||
* 购买表主键 |
|||
*/ |
|||
private Integer purchaseInfoId; |
|||
/** |
|||
* 购买价格 |
|||
*/ |
|||
private Double purchasePrice; |
|||
/** |
|||
* 购买数量 |
|||
*/ |
|||
private Integer stockNumber; |
|||
/** |
|||
* 购买时间 |
|||
*/ |
|||
private Date purchaseDate; |
|||
/** |
|||
* 预期盈利百分比 |
|||
*/ |
|||
private Double expectProfitPercent; |
|||
/** |
|||
* 预期止损百分比 |
|||
*/ |
|||
private Double expectLossPercent; |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
package io.renren.stock.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
@TableName("tb_purchase_info") |
|||
public class PurchaseInfoEntity { |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer purchaseInfoId; |
|||
/** |
|||
* 股票代码 |
|||
*/ |
|||
private String stockCode; |
|||
/** |
|||
* 股票名称 |
|||
*/ |
|||
private String stockName; |
|||
/** |
|||
* 购买时间 |
|||
*/ |
|||
private Date purchaseDate; |
|||
/** |
|||
* 购买股票平均价格 |
|||
*/ |
|||
private BigDecimal stockAveragePrice; |
|||
/** |
|||
* 是否进行基本面分析1:是,0:否 |
|||
*/ |
|||
private String fundamentalAnalysis; |
|||
/** |
|||
* VCP周期 |
|||
*/ |
|||
private String vcpPeriod; |
|||
/** |
|||
* 购买类型1:上升中的调整,2:突破买入,3下跌结束 |
|||
*/ |
|||
private String purchaseType; |
|||
/** |
|||
* 购买原因 |
|||
*/ |
|||
private String purchaseReason; |
|||
/** |
|||
* 是否平仓1:平仓,0:未平仓 |
|||
*/ |
|||
private String closePosition; |
|||
/** |
|||
* 是否盈利1:盈利,0:损失 |
|||
*/ |
|||
private String profitOrLoss; |
|||
/** |
|||
* 卖出时间 |
|||
*/ |
|||
private Date sellDate; |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("tb_import_info") |
|||
public class TbImportInfoEntity { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* import_id |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer importId; |
|||
/** |
|||
* 我的和老婆的账户 |
|||
*/ |
|||
private String capitalAccount; |
|||
/** |
|||
* 导入时间 |
|||
*/ |
|||
private Date importTime; |
|||
/** |
|||
* 交易开始日期 |
|||
*/ |
|||
private String transStartDate; |
|||
/** |
|||
* 交易结束日期 |
|||
*/ |
|||
private String transEndDate; |
|||
/** |
|||
* 总仓位 |
|||
*/ |
|||
private Float stockPosition; |
|||
} |
|||
@ -0,0 +1,124 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-03 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("tb_stock_result") |
|||
public class TbStockResultEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
/** |
|||
* id |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer stockId; |
|||
/** |
|||
* 买入日期 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8") |
|||
private Date buyTransDate; |
|||
/** |
|||
* 卖出日期 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8") |
|||
private Date sellTransDate; |
|||
/** |
|||
* 持仓天数 |
|||
*/ |
|||
private Integer holdDays; |
|||
/** |
|||
* 证券代码 |
|||
*/ |
|||
private String stockCode; |
|||
/** |
|||
* 证券名称 |
|||
*/ |
|||
private String stockName; |
|||
/** |
|||
* 成本价格 |
|||
*/ |
|||
private Float costPrice; |
|||
/** |
|||
* 卖出价格 |
|||
*/ |
|||
private Float sellPrice; |
|||
/** |
|||
* 成交数量 |
|||
*/ |
|||
private Integer transQuantity; |
|||
/** |
|||
* 成本总金额 |
|||
*/ |
|||
private Float costAmount; |
|||
/** |
|||
* 卖出总金额 |
|||
*/ |
|||
private Float sellAmount; |
|||
/** |
|||
* 盈利/亏损 |
|||
*/ |
|||
private Float gainLossAmount; |
|||
/** |
|||
* 盈利/亏损百分比 |
|||
*/ |
|||
private Float gainLossPercent; |
|||
/** |
|||
* 总费用 |
|||
*/ |
|||
private Float totalCharge; |
|||
/** |
|||
* 股东代码 |
|||
*/ |
|||
private String shareholderCode; |
|||
/** |
|||
* 资金帐号 |
|||
*/ |
|||
private String capitalAccount; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
/** |
|||
* 总结教训 |
|||
*/ |
|||
private String summary; |
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createDate; |
|||
/** |
|||
* 修改时间 |
|||
*/ |
|||
private Date updateDate; |
|||
} |
|||
@ -0,0 +1,195 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.entity; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelIgnore; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("tb_trans_detail") |
|||
public class TbTransDetailEntity{ |
|||
private static final long serialVersionUID = 1L; |
|||
/** |
|||
* id |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
@ExcelIgnore |
|||
private Integer transId; |
|||
/** |
|||
* 导入id |
|||
*/ |
|||
@ExcelIgnore |
|||
private Integer importId; |
|||
/** |
|||
* 发生日期 |
|||
*/ |
|||
@ExcelProperty("发生日期") |
|||
private String transDate; |
|||
/** |
|||
* 成交时间 |
|||
*/ |
|||
@ExcelProperty("成交时间") |
|||
private String transTime; |
|||
/** |
|||
* 证券代码 |
|||
*/ |
|||
@ExcelProperty("证券代码") |
|||
private String stockCode; |
|||
/** |
|||
* 证券名称 |
|||
*/ |
|||
@ExcelProperty("证券名称") |
|||
private String stockName; |
|||
/** |
|||
* 业务名称 :证券买入,证券卖出 |
|||
*/ |
|||
@ExcelProperty("业务名称") |
|||
private String busiType; |
|||
/** |
|||
* 成交价格 |
|||
*/ |
|||
@ExcelProperty("成交价格") |
|||
private Float transPrice; |
|||
/** |
|||
* 成交数量 |
|||
*/ |
|||
@ExcelProperty("成交数量") |
|||
private Integer transQuantity; |
|||
/** |
|||
* 成交金额 |
|||
*/ |
|||
@ExcelProperty("成交金额") |
|||
private Float transAmount; |
|||
/** |
|||
* 股份余额 |
|||
*/ |
|||
@ExcelProperty("股份余额") |
|||
private Integer shareBalance; |
|||
/** |
|||
* 手续费 |
|||
*/ |
|||
@ExcelProperty("手续费") |
|||
private Float serviceCharge; |
|||
/** |
|||
* 印花税 |
|||
*/ |
|||
@ExcelProperty("印花税") |
|||
private Float stampDuty; |
|||
/** |
|||
* 过户费 |
|||
*/ |
|||
@ExcelProperty("过户费") |
|||
private Float transferFee; |
|||
/** |
|||
* 附加费 |
|||
*/ |
|||
@ExcelProperty("附加费") |
|||
private Float additionalCharge; |
|||
/** |
|||
* 交易所清算费 |
|||
*/ |
|||
@ExcelProperty("交易所清算费") |
|||
private Float exchangeFees; |
|||
/** |
|||
* 发生金额 |
|||
*/ |
|||
@ExcelProperty("发生金额") |
|||
private Float occurrenceAmount; |
|||
/** |
|||
* 资金本次余额 |
|||
*/ |
|||
@ExcelProperty("资金本次余额") |
|||
private Float capitalBalance; |
|||
/** |
|||
* 委托编号 |
|||
*/ |
|||
@ExcelProperty("委托编号") |
|||
private String entrustingSerial; |
|||
/** |
|||
* 流水号 |
|||
*/ |
|||
@ExcelProperty("流水号") |
|||
private String serialNumber; |
|||
/** |
|||
* 股东代码 |
|||
*/ |
|||
@ExcelProperty("股东代码") |
|||
private String shareholderCode; |
|||
/** |
|||
* 资金帐号 |
|||
*/ |
|||
@ExcelProperty("资金帐号") |
|||
private String capitalAccount; |
|||
/** |
|||
* 币种 |
|||
*/ |
|||
@ExcelProperty("币种") |
|||
private String currency; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@ExcelProperty("备注") |
|||
private String remark; |
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
@ExcelIgnore |
|||
@ExcelProperty(value = "创建时间") |
|||
private Date createDate; |
|||
/** |
|||
* 修改时间 |
|||
*/ |
|||
@ExcelIgnore |
|||
@ExcelProperty(value = "修改时间") |
|||
private Date updateDate; |
|||
/** |
|||
* 买入原因 |
|||
*/ |
|||
@ExcelIgnore |
|||
@ExcelProperty(value = "买入原因") |
|||
private String reason; |
|||
|
|||
/** |
|||
* 汇总标识 |
|||
*/ |
|||
@ExcelIgnore |
|||
@ExcelProperty("汇总标识") |
|||
private Integer gatherFlag; |
|||
|
|||
/** |
|||
* 持股天数 |
|||
*/ |
|||
@TableField(exist=false) |
|||
@ExcelProperty("持股天数") |
|||
private String holdDays; |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package io.renren.stock.enums; |
|||
|
|||
/** |
|||
* 账号枚举 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public enum CapitalAccountEnum { |
|||
I("1790235186"), |
|||
WIFE("880003186998"); |
|||
|
|||
private String value; |
|||
|
|||
CapitalAccountEnum(String value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
public String value() { |
|||
return this.value; |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
package io.renren.stock.enums; |
|||
|
|||
/** |
|||
* 用户类型枚举 |
|||
* |
|||
* @author yk |
|||
* @date 2023/03/10 |
|||
*/ |
|||
public enum DictTypeEnum { |
|||
/** |
|||
* purchase_type |
|||
*/ |
|||
purchase_type("purchase_type"), |
|||
/** |
|||
* close_position |
|||
*/ |
|||
close_position("close_position"), |
|||
/** |
|||
* profit_or_loss |
|||
*/ |
|||
profit_or_loss("profit_or_loss"), |
|||
/** |
|||
* fundamental_analysis |
|||
*/ |
|||
fundamental_analysis("fundamental_analysis"), |
|||
|
|||
/** |
|||
* daily_sentiment_index |
|||
*/ |
|||
daily_sentiment_index( "daily_sentiment_index"); |
|||
|
|||
private String value; |
|||
|
|||
private DictTypeEnum(String value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
public String getValue() { |
|||
return value; |
|||
} |
|||
|
|||
public void setValue(String value) { |
|||
this.value = value; |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
public class DailySentimentIndexExcel { |
|||
@Excel(name = "") |
|||
private Long id; |
|||
@Excel(name = "") |
|||
private String stockCode; |
|||
@Excel(name = "") |
|||
private Integer dailySentimentIndex; |
|||
@Excel(name = "") |
|||
private Date dateTime; |
|||
@Excel(name = "") |
|||
private String remark; |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
public class PurchaseDetailsExcel { |
|||
@Excel(name = "主键") |
|||
private Integer id; |
|||
@Excel(name = "股票代码") |
|||
private String stockCode; |
|||
@Excel(name = "购买价格") |
|||
private BigDecimal purchasePrice; |
|||
@Excel(name = "购买时间") |
|||
private Date purchaseDate; |
|||
@Excel(name = "预期盈利百分比") |
|||
private Integer expectProfitPercent; |
|||
@Excel(name = "预期止损百分比") |
|||
private Integer expectLossPercent; |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Data |
|||
public class PurchaseInfoExcel { |
|||
@Excel(name = "主键") |
|||
private Integer id; |
|||
@Excel(name = "股票代码") |
|||
private String stockCode; |
|||
@Excel(name = "股票名称") |
|||
private String stockName; |
|||
@Excel(name = "购买时间") |
|||
private Date purchaseDate; |
|||
@Excel(name = "购买股票价格") |
|||
private BigDecimal stockPrice; |
|||
@Excel(name = "VCP周期") |
|||
private String vcpPeriod; |
|||
@Excel(name = "购买类型1:上升中的调整,2:突破买入,3下跌结束") |
|||
private Integer purchaseType; |
|||
@Excel(name = "购买原因") |
|||
private String purchaseReason; |
|||
@Excel(name = "是否平仓1:平仓,0:未平仓") |
|||
private String closePosition; |
|||
@Excel(name = "是否盈利1:盈利,0:损失") |
|||
private String profitOrLoss; |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@Data |
|||
public class TbImportInfoExcel { |
|||
@Excel(name = "import_id") |
|||
private Integer importId; |
|||
@Excel(name = "我的和老婆的账户") |
|||
private String capitalAccount; |
|||
@Excel(name = "导入时间") |
|||
private Date importTime; |
|||
@Excel(name = "交易开始日期") |
|||
private String transStartDate; |
|||
@Excel(name = "交易结束日期") |
|||
private String transEndDate; |
|||
@Excel(name = "总仓位") |
|||
private Float stockPosition; |
|||
|
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@Data |
|||
public class TbStockReportExcel { |
|||
@Excel(name = "stockId") |
|||
private Integer stockId; |
|||
@Excel(name = "买入日期") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
private Date buyTransDate; |
|||
@Excel(name = "卖出日期") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
private Date sellTransDate; |
|||
@Excel(name = "持仓天数") |
|||
private Integer holdDays; |
|||
@Excel(name = "证券代码") |
|||
private String stockCode; |
|||
@Excel(name = "证券名称") |
|||
private String stockName; |
|||
@Excel(name = "成本价格") |
|||
private Float costPrice; |
|||
@Excel(name = "卖出价格") |
|||
private Float sellPrice; |
|||
@Excel(name = "成交数量") |
|||
private Integer transQuantity; |
|||
@Excel(name = "成本总金额 ") |
|||
private Float costAmount; |
|||
@Excel(name = "卖出总金额 ") |
|||
private Float sellAmount; |
|||
@Excel(name = "盈利/亏损") |
|||
private Float gainLossAmount; |
|||
@Excel(name = "盈利/亏损百分比") |
|||
private Float gainLossPercent; |
|||
@Excel(name = "总费用") |
|||
private Float totalCharge; |
|||
@Excel(name = "股东代码") |
|||
private String shareholderCode; |
|||
@Excel(name = "资金帐号") |
|||
private String capitalAccount; |
|||
@Excel(name = "备注") |
|||
private String remark; |
|||
@Excel(name = "总结教训") |
|||
private String summary; |
|||
@Excel(name = "创建时间") |
|||
private String createDate; |
|||
@Excel(name = "修改时间") |
|||
private String updateDate; |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@Data |
|||
public class TbStockResultExcel { |
|||
@Excel(name = "stockId") |
|||
private Integer stockId; |
|||
@Excel(name = "买入日期") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
private Date buyTransDate; |
|||
@Excel(name = "卖出日期") |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
private Date sellTransDate; |
|||
@Excel(name = "持仓天数") |
|||
private Integer holdDays; |
|||
@Excel(name = "证券代码") |
|||
private String stockCode; |
|||
@Excel(name = "证券名称") |
|||
private String stockName; |
|||
@Excel(name = "成本价格") |
|||
private Float costPrice; |
|||
@Excel(name = "卖出价格") |
|||
private Float sellPrice; |
|||
@Excel(name = "成交数量") |
|||
private Integer transQuantity; |
|||
@Excel(name = "成本总金额 ") |
|||
private Float costAmount; |
|||
@Excel(name = "卖出总金额 ") |
|||
private Float sellAmount; |
|||
@Excel(name = "盈利/亏损") |
|||
private Float gainLossAmount; |
|||
@Excel(name = "盈利/亏损百分比") |
|||
private Float gainLossPercent; |
|||
@Excel(name = "总费用") |
|||
private Float totalCharge; |
|||
@Excel(name = "股东代码") |
|||
private String shareholderCode; |
|||
@Excel(name = "资金帐号") |
|||
private String capitalAccount; |
|||
@Excel(name = "备注") |
|||
private String remark; |
|||
@Excel(name = "总结教训") |
|||
private String summary; |
|||
@Excel(name = "创建时间") |
|||
private String createDate; |
|||
@Excel(name = "修改时间") |
|||
private String updateDate; |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
@Data |
|||
public class TbTransDetailExcel { |
|||
|
|||
@Excel(name = "id") |
|||
private Integer transId; |
|||
@Excel(name = "导入id") |
|||
private Integer importId; |
|||
@Excel(name = "发生日期") |
|||
private String transDate; |
|||
@Excel(name = "成交时间") |
|||
private String transTime; |
|||
@Excel(name = "证券买入,证券卖出") |
|||
private String busiType; |
|||
@Excel(name = "证券代码") |
|||
private String stockCode; |
|||
@Excel(name = "证券名称") |
|||
private String stockName; |
|||
@Excel(name = "成交价格") |
|||
private Float transPrice; |
|||
@Excel(name = "成交数量") |
|||
private Integer transQuantity; |
|||
@Excel(name = "成交金额") |
|||
private Float transAmount; |
|||
@Excel(name = "股份余额") |
|||
private Integer shareBalance; |
|||
@Excel(name = "手续费") |
|||
private Float serviceCharge; |
|||
@Excel(name = "印花税") |
|||
private Float stampDuty; |
|||
@Excel(name = "过户费") |
|||
private Float transferFee; |
|||
@Excel(name = "附加费") |
|||
private Float additionalCharge; |
|||
@Excel(name = "交易所清算费") |
|||
private Float exchangeFees; |
|||
@Excel(name = "发生金额") |
|||
private Float occurrenceAmount; |
|||
@Excel(name = "资金本次余额") |
|||
private Float capitalBalance; |
|||
@Excel(name = "委托编号") |
|||
private String entrustingSerial; |
|||
@Excel(name = "流水号") |
|||
private String serialNumber; |
|||
@Excel(name = "股东代码") |
|||
private String shareholderCode; |
|||
@Excel(name = "资金帐号") |
|||
private String capitalAccount; |
|||
@Excel(name = "币种") |
|||
private String currency; |
|||
@Excel(name = "备注") |
|||
private String remark; |
|||
@Excel(name = "汇总标识:0,未汇总,1,已汇总") |
|||
private Integer gatherFlag; |
|||
@Excel(name = "持股天数") |
|||
private String holdDays; |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package io.renren.stock.exception; |
|||
|
|||
import io.renren.commons.tools.exception.ErrorCode; |
|||
|
|||
/** |
|||
* 模块错误编码,由9位数字组成,前6位为模块编码,后3位为业务编码 |
|||
* <p> |
|||
* 如:100001001(100001代表模块,001代表业务代码) |
|||
* </p> |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public interface StockErrorCode extends ErrorCode { |
|||
|
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
package io.renren.stock.listener; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.alibaba.fastjson.JSON; |
|||
import io.renren.stock.entity.TbImportInfoEntity; |
|||
import io.renren.stock.service.TbImportInfoService; |
|||
import io.renren.stock.utils.RestResponse; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
// 有个很重要的点 DemoDataListener 不能被spring管理,要每次读取excel都要new,然后里面用到spring可以构造方法传进去
|
|||
public class ImportInfoDataListener extends AnalysisEventListener<TbImportInfoEntity> { |
|||
|
|||
private TbImportInfoService tbImportInfoService; |
|||
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(ImportInfoDataListener.class); |
|||
/** |
|||
* 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 |
|||
*/ |
|||
private static final int BATCH_COUNT = 5; |
|||
List<TbImportInfoEntity> tbImportInfoEntityList = new ArrayList<>(); |
|||
|
|||
/**ajax返回对象*/ |
|||
private RestResponse build; |
|||
|
|||
/** |
|||
* 假设这个是一个DAO,当然有业务逻辑这个也可以是一个service。当然如果不用存储这个对象没用。 |
|||
*/ |
|||
// private TbImportInfoDao tbImportInfoDao;
|
|||
//
|
|||
// public ImportInfoDataListener() {
|
|||
// // 这里是demo,所以随便new一个。实际使用如果到了spring,请使用下面的有参构造函数
|
|||
// tbImportInfoDao = new TbImportInfoDao();
|
|||
|
|||
// }
|
|||
/** |
|||
* 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来 |
|||
* |
|||
* @param build |
|||
*/ |
|||
// public ImportInfoDataListener(TbImportInfoDao stockDAO) {
|
|||
// this.tbImportInfoDao = stockDAO;
|
|||
// }
|
|||
|
|||
public ImportInfoDataListener(RestResponse build,TbImportInfoService tbImportInfoService) { |
|||
this.build = build; |
|||
this.tbImportInfoService = tbImportInfoService; |
|||
} |
|||
/** |
|||
* 这个每一条数据解析都会来调用 |
|||
* |
|||
* @param data |
|||
* one row value. Is is same as {@link AnalysisContext#readRowHolder()} |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void invoke(TbImportInfoEntity data, AnalysisContext context) { |
|||
LOGGER.info("解析到一条数据:{}", JSON.toJSONString(data)); |
|||
data.setImportTime(new Date()); |
|||
tbImportInfoEntityList.add(data); |
|||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
|||
if (tbImportInfoEntityList.size() >= BATCH_COUNT) { |
|||
saveData(); |
|||
// 存储完成清理 list
|
|||
tbImportInfoEntityList.clear(); |
|||
} |
|||
} |
|||
/** |
|||
* 所有数据解析完成了 都会来调用 |
|||
* |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
|||
Integer importId = saveData(); |
|||
if(importId==null) { |
|||
|
|||
// 将返回对象code改为错误状态码
|
|||
build.setStatus(2); |
|||
// 存入错误信息
|
|||
build.setMessage("插入失败!"); |
|||
}else { |
|||
build.setData(importId); |
|||
} |
|||
LOGGER.info("所有数据解析完成!"); |
|||
} |
|||
/** |
|||
* 加上存储数据库 |
|||
*/ |
|||
private Integer saveData() { |
|||
Integer importId = null; |
|||
LOGGER.info("{}条数据,开始存储数据库!", tbImportInfoEntityList.size()); |
|||
TbImportInfoEntity importInfoEntity = tbImportInfoEntityList.get(0); |
|||
tbImportInfoService.insertImportInfo(importInfoEntity); |
|||
LOGGER.info("ImportId:::"+importInfoEntity.getImportId()+""); |
|||
LOGGER.info("存储数据库成功!"); |
|||
importId = importInfoEntity.getImportId(); |
|||
return importId; |
|||
} |
|||
} |
|||
@ -0,0 +1,146 @@ |
|||
package io.renren.stock.listener; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.alibaba.fastjson.JSON; |
|||
import io.renren.stock.entity.TbTransDetailEntity; |
|||
import io.renren.stock.service.TbTransDetailService; |
|||
import io.renren.stock.utils.RestResponse; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
// 有个很重要的点 DemoDataListener 不能被spring管理,要每次读取excel都要new,然后里面用到spring可以构造方法传进去
|
|||
public class TransDetailDataListener extends AnalysisEventListener<TbTransDetailEntity> { |
|||
|
|||
private TbTransDetailService tbTransDetailService; |
|||
|
|||
/**ajax返回对象*/ |
|||
private RestResponse build; |
|||
|
|||
String importId; |
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TransDetailDataListener.class); |
|||
/** |
|||
* 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 |
|||
*/ |
|||
private static final int BATCH_COUNT = 1000; |
|||
List<TbTransDetailEntity> transDetailDTOList = new ArrayList<>(); |
|||
/** |
|||
* 假设这个是一个DAO,当然有业务逻辑这个也可以是一个service。当然如果不用存储这个对象没用。 |
|||
*/ |
|||
// private StockDAO stockDAO;
|
|||
//
|
|||
// public TransDetailDataListener() {
|
|||
// // 这里是demo,所以随便new一个。实际使用如果到了spring,请使用下面的有参构造函数
|
|||
// stockDAO = new StockDAO();
|
|||
// }
|
|||
/** |
|||
* 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来 |
|||
* |
|||
* @param build |
|||
*/ |
|||
public TransDetailDataListener(RestResponse build, TbTransDetailService tbTransDetailService, String importId) { |
|||
this.build = build; |
|||
this.tbTransDetailService = tbTransDetailService; |
|||
this.importId = importId; |
|||
} |
|||
/** |
|||
* 这个每一条数据解析都会来调用 |
|||
* |
|||
* @param data |
|||
* one row value. Is is same as {@link AnalysisContext#readRowHolder()} |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void invoke(TbTransDetailEntity data, AnalysisContext context) { |
|||
LOGGER.info("解析到一条数据:{}", JSON.toJSONString(data)); |
|||
if(StringUtils.isNotEmpty(data.getBusiType()) && |
|||
(data.getBusiType().equals("证券买入") || data.getBusiType().equals("证券卖出") )) { |
|||
data.setImportId(Integer.parseInt(importId)); |
|||
//stockCode补零
|
|||
if (data.getStockCode() != null) { |
|||
int codeLength = data.getStockCode().length(); |
|||
String quantityOfZero = ""; |
|||
if (codeLength != 6) { |
|||
for (int i = 0; i < 6 - codeLength; i++) { |
|||
quantityOfZero += "0"; |
|||
} |
|||
data.setStockCode(quantityOfZero + data.getStockCode()); |
|||
} |
|||
} |
|||
data.setCreateDate(new Date()); |
|||
data.setUpdateDate(new Date()); |
|||
data.setGatherFlag(0); |
|||
transDetailDTOList.add(data); |
|||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
|||
if (transDetailDTOList.size() >= BATCH_COUNT) { |
|||
saveData(); |
|||
// 存储完成清理 list
|
|||
transDetailDTOList.clear(); |
|||
} |
|||
} |
|||
} |
|||
/** |
|||
* 所有数据解析完成了 都会来调用 |
|||
* |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
|||
try { |
|||
List<TbTransDetailEntity> list = saveData(); |
|||
|
|||
if(transDetailDTOList.size()>0 && list.size()>0){ |
|||
// 将返回对象code改为错误状态码
|
|||
build.setStatus(2); |
|||
// 存入错误信息
|
|||
build.setMessage("导入的数据有已经存在的数据!"); |
|||
build.setData(list); |
|||
}else{ |
|||
build.setStatus(0); |
|||
// 存入错误信息
|
|||
build.setMessage("导入数据成功!"); |
|||
} |
|||
} catch (Exception e) { |
|||
// 将返回对象code改为错误状态码
|
|||
build.setStatus(1); |
|||
// 存入错误信息
|
|||
build.setMessage("操作数据库异常!"); |
|||
build.setData(null); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
LOGGER.info("所有数据解析完成!"); |
|||
} |
|||
/** |
|||
* 加上存储数据库 |
|||
*/ |
|||
private List<TbTransDetailEntity> saveData() { |
|||
LOGGER.info("{}条数据,开始存储数据库!", transDetailDTOList.size()); |
|||
List<TbTransDetailEntity> list = tbTransDetailService.saveAll(transDetailDTOList); |
|||
|
|||
if( transDetailDTOList.size()>0 && list.size()>0 ) { |
|||
LOGGER.info("有重复数据,无法存储数据库!"); |
|||
} |
|||
else { |
|||
LOGGER.info("存储数据库成功!"); |
|||
} |
|||
|
|||
return list; |
|||
} |
|||
|
|||
/** |
|||
*解析出现错误会进入该方法 具体看源代码或文档 |
|||
*/ |
|||
@Override |
|||
public void onException(Exception exception, AnalysisContext context) throws Exception { |
|||
System.out.println("hello"); |
|||
throw exception; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.redis; |
|||
|
|||
import io.renren.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@Component |
|||
public class TbImportInfoRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.redis; |
|||
|
|||
import io.renren.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@Component |
|||
public class TbStockResultRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.redis; |
|||
|
|||
import io.renren.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
@Component |
|||
public class TbTransDetailRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package io.renren.stock.service; |
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.DailySentimentIndexDTO; |
|||
import io.renren.stock.entity.DailySentimentIndexEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
public interface DailySentimentIndexService extends BaseService<DailySentimentIndexEntity> { |
|||
|
|||
PageData<DailySentimentIndexDTO> page(Map<String, Object> params); |
|||
|
|||
List<DailySentimentIndexDTO> list(Map<String, Object> params); |
|||
|
|||
DailySentimentIndexDTO get(Long id); |
|||
|
|||
void save(DailySentimentIndexDTO dto); |
|||
|
|||
void update(DailySentimentIndexDTO dto); |
|||
|
|||
void delete(Long[] ids); |
|||
|
|||
void deleteBypurchaseInfoId(Integer id); |
|||
|
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package io.renren.stock.service; |
|||
|
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.PurchaseDetailsDTO; |
|||
import io.renren.stock.entity.PurchaseDetailsEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
public interface PurchaseDetailsService extends BaseService<PurchaseDetailsEntity> { |
|||
|
|||
PageData<PurchaseDetailsDTO> page(Map<String, Object> params); |
|||
|
|||
List<PurchaseDetailsDTO> list(Map<String, Object> params); |
|||
|
|||
PurchaseDetailsDTO get(Long id); |
|||
|
|||
void save(PurchaseDetailsDTO dto); |
|||
|
|||
void update(PurchaseDetailsDTO dto); |
|||
|
|||
void delete(Long[] ids); |
|||
|
|||
void deleteBypurchaseInfoId(Integer id); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package io.renren.stock.service; |
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.PurchaseInfoDTO; |
|||
import io.renren.stock.entity.PurchaseInfoEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
public interface PurchaseInfoService extends BaseService<PurchaseInfoEntity> { |
|||
|
|||
PageData<PurchaseInfoDTO> page(Map<String, Object> params); |
|||
|
|||
List<PurchaseInfoDTO> list(Map<String, Object> params); |
|||
|
|||
PurchaseInfoDTO get(Long id); |
|||
|
|||
void save(PurchaseInfoDTO dto); |
|||
|
|||
PurchaseInfoEntity saveReturn(PurchaseInfoDTO dto); |
|||
|
|||
void update(PurchaseInfoDTO dto); |
|||
|
|||
void delete(Long[] ids); |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service; |
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.TbImportInfoDTO; |
|||
import io.renren.stock.entity.TbImportInfoEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
public interface TbImportInfoService extends BaseService<TbImportInfoEntity> { |
|||
|
|||
PageData<TbImportInfoDTO> page(Map<String, Object> params); |
|||
|
|||
List<TbImportInfoDTO> list(Map<String, Object> params); |
|||
|
|||
TbImportInfoDTO get(String id); |
|||
|
|||
void save(TbImportInfoDTO dto); |
|||
|
|||
void update(TbImportInfoDTO dto); |
|||
|
|||
void delete(String[] ids); |
|||
|
|||
void insertImportInfo(TbImportInfoEntity importInfoEntity); |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service; |
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.TbStockReportDTO; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
public interface TbStockReportService extends BaseService<TbStockReportDTO> { |
|||
|
|||
PageData<TbStockReportDTO> sumStockReport(Map<String, Object> params) throws ParseException; |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service; |
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.TbStockResultDTO; |
|||
import io.renren.stock.entity.TbStockResultEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
public interface TbStockResultService extends BaseService<TbStockResultEntity> { |
|||
|
|||
PageData<TbStockResultDTO> page(Map<String, Object> params); |
|||
|
|||
List<TbStockResultDTO> list(Map<String, Object> params); |
|||
|
|||
TbStockResultDTO get(String id); |
|||
|
|||
void save(TbStockResultDTO dto); |
|||
|
|||
void update(TbStockResultDTO dto); |
|||
|
|||
void delete(String[] ids); |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service; |
|||
|
|||
import io.renren.commons.mybatis.service.BaseService; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.dto.stock.TbTransDetailDTO; |
|||
import io.renren.stock.entity.TbTransDetailEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
public interface TbTransDetailService extends BaseService<TbTransDetailEntity> { |
|||
|
|||
PageData<TbTransDetailDTO> page(Map<String, Object> params); |
|||
|
|||
List<TbTransDetailDTO> list(Map<String, Object> params); |
|||
|
|||
TbTransDetailDTO get(String id); |
|||
|
|||
List<TbTransDetailEntity> saveAll(List<TbTransDetailEntity> list); |
|||
|
|||
void save(TbTransDetailDTO dto); |
|||
|
|||
void update(TbTransDetailDTO dto); |
|||
|
|||
void delete(String[] ids); |
|||
|
|||
void combineStock(Map<String, Object> map); |
|||
} |
|||
@ -0,0 +1,113 @@ |
|||
package io.renren.stock.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.dto.stock.DailySentimentIndexDTO; |
|||
import io.renren.stock.dao.DailySentimentIndexDao; |
|||
import io.renren.stock.entity.DailySentimentIndexEntity; |
|||
import io.renren.stock.service.DailySentimentIndexService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Service |
|||
public class DailySentimentIndexServiceImpl extends BaseServiceImpl<DailySentimentIndexDao, DailySentimentIndexEntity> implements DailySentimentIndexService { |
|||
|
|||
public QueryWrapper<DailySentimentIndexEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get("id"); |
|||
String purchaseInfoId = (String)params.get("purchaseInfoId"); |
|||
String dateTime = (String)params.get("dateTime"); |
|||
|
|||
|
|||
QueryWrapper<DailySentimentIndexEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), "id", id); |
|||
if(StringUtils.isNotBlank(purchaseInfoId) && !purchaseInfoId.equals("null")) { |
|||
wrapper.eq(StringUtils.isNotBlank(purchaseInfoId), "purchase_info_id", Long.parseLong(purchaseInfoId)); |
|||
} |
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|||
if(StringUtils.isNotBlank(dateTime) && !dateTime.equals("null")) { |
|||
try { |
|||
wrapper.eq(StringUtils.isNotBlank(dateTime), "date_time", sdf.parse(dateTime)); |
|||
} catch (ParseException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PageData<DailySentimentIndexDTO> page(Map<String, Object> params) { |
|||
IPage<DailySentimentIndexEntity> page = baseDao.selectPage( |
|||
getPage(params, "date_time", false), |
|||
getWrapper(params) |
|||
); |
|||
|
|||
return getPageData(page, DailySentimentIndexDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<DailySentimentIndexDTO> list(Map<String, Object> params) { |
|||
List<DailySentimentIndexEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, DailySentimentIndexDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public DailySentimentIndexDTO get(Long id) { |
|||
DailySentimentIndexEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, DailySentimentIndexDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(DailySentimentIndexDTO dto) { |
|||
DailySentimentIndexEntity entity = ConvertUtils.sourceToTarget(dto, DailySentimentIndexEntity.class); |
|||
|
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(DailySentimentIndexDTO dto) { |
|||
DailySentimentIndexEntity entity = ConvertUtils.sourceToTarget(dto, DailySentimentIndexEntity.class); |
|||
|
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(Long[] ids) { |
|||
//逻辑删除
|
|||
//logicDelete(ids, DailySentimentIndexEntity.class);
|
|||
|
|||
//物理删除
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void deleteBypurchaseInfoId(Integer id) { |
|||
//物理删除
|
|||
DailySentimentIndexEntity delete = new DailySentimentIndexEntity(); |
|||
delete.setPurchaseInfoId(id); |
|||
baseDao.delete(new UpdateWrapper<>(delete)); |
|||
} |
|||
} |
|||
@ -0,0 +1,140 @@ |
|||
package io.renren.stock.service.impl; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.dto.stock.PurchaseDetailsDTO; |
|||
import io.renren.dto.stock.PurchaseInfoDTO; |
|||
import io.renren.stock.dao.PurchaseDetailsDao; |
|||
import io.renren.stock.entity.PurchaseDetailsEntity; |
|||
import io.renren.stock.service.PurchaseDetailsService; |
|||
import io.renren.stock.service.PurchaseInfoService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.text.DecimalFormat; |
|||
import java.util.Arrays; |
|||
import java.util.Comparator; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Service |
|||
public class PurchaseDetailsServiceImpl extends BaseServiceImpl<PurchaseDetailsDao, PurchaseDetailsEntity> implements PurchaseDetailsService { |
|||
|
|||
@Autowired |
|||
PurchaseInfoService purchaseInfoService; |
|||
|
|||
public QueryWrapper<PurchaseDetailsEntity> getWrapper(Map<String, Object> params){ |
|||
QueryWrapper<PurchaseDetailsEntity> wrapper = new QueryWrapper<>(); |
|||
if(ObjectUtil.isNotNull(params)) { |
|||
String purchaseDetailsId = (String) params.get("purchaseDetailsId"); |
|||
Integer purchaseInfoId = Integer.parseInt(params.get("purchaseInfoId").toString()); |
|||
wrapper.eq(StringUtils.isNotBlank(purchaseDetailsId), "purchase_details_id", purchaseDetailsId); |
|||
wrapper.eq(ObjectUtil.isNotNull(purchaseInfoId), "purchase_info_id", purchaseInfoId); |
|||
|
|||
} |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public PageData<PurchaseDetailsDTO> page(Map<String, Object> params) { |
|||
IPage<PurchaseDetailsEntity> page = baseDao.selectPage( |
|||
getPage(params, "purchase_date", true), |
|||
getWrapper(params) |
|||
); |
|||
// 获得购买股票表购买数据
|
|||
Long purchaseInfoId = Long.parseLong(params.get("purchaseInfoId").toString()); |
|||
PurchaseInfoDTO purchaseInfoDTO = purchaseInfoService.get(purchaseInfoId); |
|||
PageData<PurchaseDetailsDTO> pageData = getPageData(page, PurchaseDetailsDTO.class); |
|||
|
|||
// 将购买数据添加到明细购买列表
|
|||
/* PurchaseDetailsDTO dto = new PurchaseDetailsDTO(); |
|||
dto.setExpectLossPercent(purchaseInfoDTO.getExpectLossPercent()); |
|||
dto.setExpectProfitPercent(purchaseInfoDTO.getExpectProfitPercent()); |
|||
dto.setPurchaseDate(purchaseInfoDTO.getPurchaseDate()); |
|||
pageData.getList().add(dto);*/ |
|||
|
|||
// 计算预期的收益和损失
|
|||
pageData.getList().forEach(purchaseDetailsDTO -> { |
|||
if(ObjectUtil.isNotNull(purchaseDetailsDTO.getPurchasePrice())){ |
|||
if(ObjectUtil.isNotNull(purchaseDetailsDTO.getExpectLossPercent())){ |
|||
purchaseDetailsDTO.setExpectLoss( |
|||
(Double.parseDouble(new DecimalFormat("#.00").format(purchaseDetailsDTO.getPurchasePrice().doubleValue() * (purchaseDetailsDTO.getExpectLossPercent()*0.01+1))))); |
|||
} |
|||
if(ObjectUtil.isNotNull(purchaseDetailsDTO.getExpectProfitPercent())){ |
|||
purchaseDetailsDTO.setExpectProfit( |
|||
(Double.parseDouble(new DecimalFormat("#.00").format(purchaseDetailsDTO.getPurchasePrice().doubleValue() * (purchaseDetailsDTO.getExpectProfitPercent()*0.01+1))))); |
|||
} |
|||
purchaseDetailsDTO.setStockName(purchaseInfoDTO.getStockName()); |
|||
} |
|||
}); |
|||
|
|||
// 排序
|
|||
pageData.getList().sort(Comparator.comparing(PurchaseDetailsDTO::getPurchaseDate)); |
|||
return pageData; |
|||
} |
|||
|
|||
@Override |
|||
public List<PurchaseDetailsDTO> list(Map<String, Object> params) { |
|||
List<PurchaseDetailsEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PurchaseDetailsDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public PurchaseDetailsDTO get(Long id) { |
|||
PurchaseDetailsEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, PurchaseDetailsDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(PurchaseDetailsDTO dto) { |
|||
PurchaseDetailsEntity entity = ConvertUtils.sourceToTarget(dto, PurchaseDetailsEntity.class); |
|||
|
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PurchaseDetailsDTO dto) { |
|||
PurchaseDetailsEntity entity = ConvertUtils.sourceToTarget(dto, PurchaseDetailsEntity.class); |
|||
|
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(Long[] ids) { |
|||
//逻辑删除
|
|||
//logicDelete(ids, PurchaseDetailsEntity.class);
|
|||
|
|||
//物理删除
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void deleteBypurchaseInfoId(Integer id) { |
|||
//物理删除
|
|||
PurchaseDetailsEntity delete = new PurchaseDetailsEntity(); |
|||
delete.setPurchaseInfoId(id); |
|||
baseDao.delete(new UpdateWrapper<>(delete)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
package io.renren.stock.service.impl; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.dto.stock.PurchaseInfoDTO; |
|||
import io.renren.stock.dao.PurchaseInfoDao; |
|||
import io.renren.stock.entity.PurchaseInfoEntity; |
|||
import io.renren.stock.service.PurchaseInfoService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 2023-03-01 |
|||
*/ |
|||
@Service |
|||
public class PurchaseInfoServiceImpl extends BaseServiceImpl<PurchaseInfoDao, PurchaseInfoEntity> implements PurchaseInfoService { |
|||
|
|||
public QueryWrapper<PurchaseInfoEntity> getWrapper(Map<String, Object> params){ |
|||
String closePosition = (String)params.get("closePosition"); |
|||
String stockCode = (String)params.get("stockCode"); |
|||
String purchaseInfoId = (String)params.get("purchaseInfoId"); |
|||
|
|||
QueryWrapper<PurchaseInfoEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(closePosition)&& !StrUtil.equals(closePosition,Constant.DICT_ALL), "close_position", closePosition); |
|||
wrapper.eq(StringUtils.isNotBlank(stockCode)&& !StrUtil.equals(stockCode,Constant.DICT_ALL), "stock_code", stockCode); |
|||
wrapper.eq(StringUtils.isNotBlank(purchaseInfoId), "purchase_info_id", purchaseInfoId); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PageData<PurchaseInfoDTO> page(Map<String, Object> params) { |
|||
IPage<PurchaseInfoEntity> page = baseDao.selectPage( |
|||
getPage(params, "purchase_date", false), |
|||
getWrapper(params) |
|||
); |
|||
|
|||
return getPageData(page, PurchaseInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PurchaseInfoDTO> list(Map<String, Object> params) { |
|||
List<PurchaseInfoEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PurchaseInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public PurchaseInfoDTO get(Long id) { |
|||
PurchaseInfoEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, PurchaseInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(PurchaseInfoDTO dto) { |
|||
PurchaseInfoEntity entity = ConvertUtils.sourceToTarget(dto, PurchaseInfoEntity.class); |
|||
|
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public PurchaseInfoEntity saveReturn(PurchaseInfoDTO dto) { |
|||
PurchaseInfoEntity entity = ConvertUtils.sourceToTarget(dto, PurchaseInfoEntity.class); |
|||
insert(entity); |
|||
return entity; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PurchaseInfoDTO dto) { |
|||
PurchaseInfoEntity entity = ConvertUtils.sourceToTarget(dto, PurchaseInfoEntity.class); |
|||
|
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(Long[] ids) { |
|||
//逻辑删除
|
|||
//logicDelete(ids, PurchaseInfoEntity.class);
|
|||
//物理删除
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,120 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.constant.Constant; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.dto.stock.TbImportInfoDTO; |
|||
import io.renren.stock.dao.TbImportInfoDao; |
|||
import io.renren.stock.entity.TbImportInfoEntity; |
|||
import io.renren.stock.redis.TbImportInfoRedis; |
|||
import io.renren.stock.service.TbImportInfoService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-06 |
|||
*/ |
|||
@Service |
|||
public class TbImportInfoServiceImpl extends BaseServiceImpl<TbImportInfoDao, TbImportInfoEntity> implements TbImportInfoService { |
|||
@Autowired |
|||
private TbImportInfoRedis tbImportInfoRedis; |
|||
|
|||
@Override |
|||
public PageData<TbImportInfoDTO> page(Map<String, Object> params) { |
|||
IPage<TbImportInfoEntity> page = baseDao.selectPage( |
|||
getPage(params, Constant.CREATE_DATE, false), |
|||
getWrapper(params) |
|||
); |
|||
|
|||
return getPageData(page, TbImportInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<TbImportInfoDTO> list(Map<String, Object> params) { |
|||
List<TbImportInfoEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, TbImportInfoDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<TbImportInfoEntity> getWrapper(Map<String, Object> params){ |
|||
String capitalAccount = (String)params.get("capitalAccount"); |
|||
String transStartDate = (String)params.get("transStartDate"); |
|||
String transEndDate = (String)params.get("transEndDate"); |
|||
QueryWrapper<TbImportInfoEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(capitalAccount), "capital_account", capitalAccount); |
|||
wrapper.eq(StringUtils.isNotBlank(transStartDate), "trans_start_date", transStartDate); |
|||
wrapper.eq(StringUtils.isNotBlank(transEndDate), "trans_end_date", transEndDate); |
|||
//wrapper.eq(Constant.DEL_FLAG, DelFlagEnum.NORMAL.value());
|
|||
wrapper.orderByAsc("trans_end_date"); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public TbImportInfoDTO get(String id) { |
|||
TbImportInfoEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, TbImportInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(TbImportInfoDTO dto) { |
|||
TbImportInfoEntity entity = ConvertUtils.sourceToTarget(dto, TbImportInfoEntity.class); |
|||
|
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(TbImportInfoDTO dto) { |
|||
TbImportInfoEntity entity = ConvertUtils.sourceToTarget(dto, TbImportInfoEntity.class); |
|||
|
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
//逻辑删除
|
|||
//logicDelete(ids, TbImportInfoEntity.class);
|
|||
|
|||
//物理删除
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public void insertImportInfo(TbImportInfoEntity importInfoEntity) { |
|||
baseDao.insertImportInfo(importInfoEntity); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service.impl; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.DateUtils; |
|||
import io.renren.dto.stock.TbImportInfoDTO; |
|||
import io.renren.dto.stock.TbStockReportDTO; |
|||
import io.renren.stock.dao.TbStockReportDao; |
|||
import io.renren.stock.enums.CapitalAccountEnum; |
|||
import io.renren.stock.service.TbImportInfoService; |
|||
import io.renren.stock.service.TbStockReportService; |
|||
import org.apache.commons.collections4.map.HashedMap; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Calendar; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class TbStockReportServiceImpl extends BaseServiceImpl<TbStockReportDao, TbStockReportDTO> implements TbStockReportService { |
|||
|
|||
@Autowired |
|||
TbImportInfoService tbImportInfoService; |
|||
|
|||
@Override |
|||
public PageData<TbStockReportDTO> sumStockReport(Map<String, Object> params) throws ParseException { |
|||
//分页
|
|||
getPageWithTotal(params, "sell_period", true,false); |
|||
|
|||
//按周期统计的数据
|
|||
List<TbStockReportDTO> list = baseDao.selStockReportByPeriod(params); |
|||
String periodEndDate = null, capitalAccount = ""; |
|||
Map<String, Object> importInfoParams = new HashedMap<>(); |
|||
if(params.get("capitalAccount")!=null) { |
|||
capitalAccount = params.get("capitalAccount").toString(); |
|||
} |
|||
|
|||
//选择了资金账号根据账号进行查询
|
|||
if(!capitalAccount.equals("-1")) { |
|||
importInfoParams.put("capitalAccount", capitalAccount); |
|||
} |
|||
List<TbImportInfoDTO> importInfoDTOList = tbImportInfoService.list(importInfoParams); |
|||
|
|||
String period = params.get("period").toString(); |
|||
Float closedStockPosition = null; |
|||
BigDecimal tradingVolumeRatioWithWhole; |
|||
//如果选择的是按星期汇总,计算设置每周的开始和结束时间
|
|||
if(period.equals("2")) { |
|||
for (TbStockReportDTO tbStockReportDTO : list) { |
|||
Integer year = Integer.parseInt(tbStockReportDTO.getSellPeriod().split("-")[0]); |
|||
Integer week = Integer.parseInt(tbStockReportDTO.getSellPeriod().split("-")[1]); |
|||
//按周汇总得到开始结束日期
|
|||
tbStockReportDTO.setSellPeriod(getWeekDays(year, week)); |
|||
|
|||
//得到汇总每周周期的结束日期
|
|||
periodEndDate = tbStockReportDTO.getSellPeriod().split("~")[1]; |
|||
//查找股票导入表的结束日期进行比较得到最近的日期取出总持仓量
|
|||
closedStockPosition = getClosedStockPosition(importInfoDTOList, periodEndDate, capitalAccount); |
|||
//周期平均成交量除以总仓位
|
|||
if(tbStockReportDTO.getAverTradingVolume()!=null && closedStockPosition!=null) { |
|||
System.out.println("AverTradingVolume():::" + tbStockReportDTO.getAverTradingVolume() * 100); |
|||
System.out.println("closedStockPosition:::" + closedStockPosition); |
|||
tradingVolumeRatioWithWhole = new BigDecimal(tbStockReportDTO.getAverTradingVolume() * 100).divide |
|||
(new BigDecimal(closedStockPosition), 2, BigDecimal.ROUND_HALF_UP); |
|||
tbStockReportDTO.setTradingVolumeRatioWithWhole(tradingVolumeRatioWithWhole); |
|||
} |
|||
} |
|||
//得到汇总每月周期的结束日期
|
|||
}else if(period.equals("1")) { |
|||
|
|||
for (TbStockReportDTO tbStockReportDTO : list) { |
|||
|
|||
periodEndDate = DateUtils.getLastDayOfMonth(tbStockReportDTO.getSellPeriod()); |
|||
//查找股票导入表的结束日期进行比较得到最近的日期取出总持仓量
|
|||
closedStockPosition = getClosedStockPosition(importInfoDTOList, periodEndDate, capitalAccount); |
|||
//周期平均成交量除以总仓位
|
|||
if(tbStockReportDTO.getAverTradingVolume()!=null && closedStockPosition!=null) { |
|||
System.out.println("AverTradingVolume():::" + tbStockReportDTO.getAverTradingVolume() * 100); |
|||
System.out.println("closedStockPosition:::" + closedStockPosition); |
|||
tradingVolumeRatioWithWhole = new BigDecimal(tbStockReportDTO.getAverTradingVolume() * 100).divide |
|||
(new BigDecimal(closedStockPosition), 2, BigDecimal.ROUND_HALF_UP); |
|||
tbStockReportDTO.setTradingVolumeRatioWithWhole(tradingVolumeRatioWithWhole); |
|||
} |
|||
} |
|||
} |
|||
|
|||
//把周期所有的的数据汇总
|
|||
List<TbStockReportDTO> sumList = baseDao.sumStockReportByPeriod(params); |
|||
if(params.get("transEndDate")!=null) { |
|||
String transEndDate = params.get("transEndDate").toString(); |
|||
//查找股票导入表的结束日期进行比较得到最近的日期取出总持仓量
|
|||
closedStockPosition = getClosedStockPosition(importInfoDTOList, transEndDate, capitalAccount); |
|||
//总共平均成交量除以总仓位
|
|||
for (TbStockReportDTO tbStockReportDTO : sumList) { |
|||
if (tbStockReportDTO.getAverTradingVolume() != null && closedStockPosition != null) { |
|||
tradingVolumeRatioWithWhole = new BigDecimal(tbStockReportDTO.getAverTradingVolume() * 100).divide |
|||
(new BigDecimal(closedStockPosition), 2, BigDecimal.ROUND_HALF_UP); |
|||
tbStockReportDTO.setTradingVolumeRatioWithWhole(tradingVolumeRatioWithWhole); |
|||
} |
|||
} |
|||
} |
|||
|
|||
//周期和汇总数据放到一起
|
|||
list.addAll(sumList); |
|||
|
|||
return getPageData(list, list.size(), TbStockReportDTO.class); |
|||
} |
|||
|
|||
//得到一周的开始日期和结束日期
|
|||
public String getWeekDays(Integer year,Integer week){ |
|||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
|||
Calendar cal=Calendar.getInstance(); |
|||
cal.setFirstDayOfWeek(Calendar.MONDAY); |
|||
cal.set(Calendar.YEAR, year); |
|||
cal.set(Calendar.WEEK_OF_YEAR, week); |
|||
cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek()); |
|||
String beginDate = sdf.format(cal.getTime()); |
|||
cal.add(Calendar.DAY_OF_WEEK, 6); |
|||
String endDate = sdf.format(cal.getTime()); |
|||
return beginDate+"~"+endDate; |
|||
} |
|||
|
|||
//得到离交易周期结束日期最近的在ImportInfo里导入周期的结束日期总金额
|
|||
public static Float getClosedStockPosition(List<TbImportInfoDTO> importInfoDTOList,String periodEndDate, String capitalAccount) throws ParseException { |
|||
|
|||
Float iStockPosition = 0F, wifeStockPosition = 0F; |
|||
Date transEndDate, periodEndDate1; |
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|||
|
|||
for (TbImportInfoDTO tbImportInfoDTO : importInfoDTOList) { |
|||
if(tbImportInfoDTO.getCapitalAccount().equals(CapitalAccountEnum.I.value())) { |
|||
transEndDate = sdf.parse(tbImportInfoDTO.getTransEndDate()); |
|||
periodEndDate1 = sdf.parse(periodEndDate); |
|||
//SQL里按trans_end_date排序的,循环到两个日期最近的结束循环
|
|||
if (transEndDate.before(periodEndDate1)) { |
|||
if(ObjectUtil.isNotNull(tbImportInfoDTO.getStockPosition())) { |
|||
iStockPosition = tbImportInfoDTO.getStockPosition(); |
|||
} |
|||
} |
|||
} |
|||
if(tbImportInfoDTO.getCapitalAccount().equals(CapitalAccountEnum.WIFE.value())) { |
|||
transEndDate = sdf.parse(tbImportInfoDTO.getTransEndDate()); |
|||
periodEndDate1 = sdf.parse(periodEndDate); |
|||
//SQL里按trans_end_date排序的,循环到两个日期最近的结束循环
|
|||
if (transEndDate.before(periodEndDate1)) { |
|||
if(ObjectUtil.isNotNull(tbImportInfoDTO.getStockPosition())) { |
|||
wifeStockPosition = tbImportInfoDTO.getStockPosition(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return iStockPosition + wifeStockPosition; |
|||
} |
|||
} |
|||
@ -0,0 +1,115 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.dto.stock.TbStockResultDTO; |
|||
import io.renren.stock.dao.TbStockResultDao; |
|||
import io.renren.stock.entity.TbStockResultEntity; |
|||
import io.renren.stock.service.TbStockResultService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-10-01 |
|||
*/ |
|||
@Service |
|||
public class TbStockResultServiceImpl extends BaseServiceImpl<TbStockResultDao, TbStockResultEntity> implements TbStockResultService { |
|||
|
|||
@Override |
|||
public PageData<TbStockResultDTO> page(Map<String, Object> params) { |
|||
IPage<TbStockResultEntity> page = baseDao.selectPage( |
|||
getPage(params, "sell_trans_date", false), |
|||
getWrapper(params) |
|||
); |
|||
|
|||
return getPageData(page, TbStockResultDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<TbStockResultDTO> list(Map<String, Object> params) { |
|||
List<TbStockResultEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, TbStockResultDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<TbStockResultEntity> getWrapper(Map<String, Object> params){ |
|||
String capitalAccount = (String)params.get("capitalAccount"); |
|||
String stockCode = (String)params.get("stockCode"); |
|||
String transStartDate = (String)params.get("transStartDate"); |
|||
String transEndDate = (String)params.get("transEndDate"); |
|||
|
|||
QueryWrapper<TbStockResultEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(capitalAccount) && !capitalAccount.equals("-1"), "capital_account", capitalAccount); |
|||
wrapper.eq(StringUtils.isNotBlank(stockCode), "stock_code", stockCode); |
|||
if(StringUtils.isNotBlank(transStartDate)) { |
|||
wrapper.ge(StringUtils.isNotBlank(transStartDate), "sell_trans_date", transStartDate.replace("-", "")); |
|||
} |
|||
if(StringUtils.isNotBlank(transEndDate)) { |
|||
wrapper.le(StringUtils.isNotBlank(transEndDate), "sell_trans_date", transEndDate.replace("-", "")); |
|||
} |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public TbStockResultDTO get(String id) { |
|||
TbStockResultEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, TbStockResultDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(TbStockResultDTO dto) { |
|||
TbStockResultEntity entity = ConvertUtils.sourceToTarget(dto, TbStockResultEntity.class); |
|||
|
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(TbStockResultDTO dto) { |
|||
TbStockResultEntity entity = ConvertUtils.sourceToTarget(dto, TbStockResultEntity.class); |
|||
|
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
//逻辑删除
|
|||
//logicDelete(ids, TbStockResultEntity.class);
|
|||
|
|||
//物理删除
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,179 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package io.renren.stock.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.renren.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import io.renren.commons.tools.page.PageData; |
|||
import io.renren.commons.tools.utils.ConvertUtils; |
|||
import io.renren.dto.stock.TbTransDetailDTO; |
|||
import io.renren.stock.dao.TbTransDetailDao; |
|||
import io.renren.stock.entity.TbTransDetailEntity; |
|||
import io.renren.stock.redis.TbTransDetailRedis; |
|||
import io.renren.stock.service.TbTransDetailService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
import static io.renren.commons.tools.utils.DateUtils.calculateTimeDifferenceByChronoUnit; |
|||
|
|||
/** |
|||
* 股票交易明细表 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since v1.0.0 2021-08-19 |
|||
*/ |
|||
@Service |
|||
public class TbTransDetailServiceImpl extends BaseServiceImpl<TbTransDetailDao, TbTransDetailEntity> implements TbTransDetailService { |
|||
@Autowired |
|||
private TbTransDetailRedis tbTransDetailRedis; |
|||
|
|||
@Override |
|||
public PageData<TbTransDetailDTO> page(Map<String, Object> params) { |
|||
IPage<TbTransDetailEntity> page = baseDao.selectPage( |
|||
getPage(params, "trans_date", true), |
|||
getWrapper(params) |
|||
); |
|||
|
|||
//设置未卖出的股票的持仓时间
|
|||
for (TbTransDetailEntity record : page.getRecords()) { |
|||
if(record.getBusiType().equals("证券买入") && record.getGatherFlag()==0){ |
|||
Date startDate = null; |
|||
try { |
|||
startDate = new SimpleDateFormat("yyyyMMdd").parse(record.getTransDate()); |
|||
} catch (ParseException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
long diffDays = calculateTimeDifferenceByChronoUnit(startDate, new Date()); |
|||
record.setHoldDays(String.valueOf(diffDays)); |
|||
}else { |
|||
record.setHoldDays("--"); |
|||
} |
|||
} |
|||
return getPageData(page, TbTransDetailDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<TbTransDetailDTO> list(Map<String, Object> params) { |
|||
List<TbTransDetailEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, TbTransDetailDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<TbTransDetailEntity> getWrapper(Map<String, Object> params){ |
|||
String capitalAccount = (String)params.get("capitalAccount"); |
|||
String stockCode = (String)params.get("stockCode"); |
|||
String transStartDate = (String)params.get("transStartDate"); |
|||
String transEndDate = (String)params.get("transEndDate"); |
|||
String gatherFlag = (String)params.get("gatherFlag"); |
|||
|
|||
QueryWrapper<TbTransDetailEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(capitalAccount) && !capitalAccount.equals("-1"), "capital_account", capitalAccount); |
|||
wrapper.eq(StringUtils.isNotBlank(stockCode), "stock_code", stockCode); |
|||
if(StringUtils.isNotBlank(transStartDate)) { |
|||
wrapper.ge(StringUtils.isNotBlank(transStartDate), "trans_date", transStartDate.replace("-", "")); |
|||
} |
|||
if(StringUtils.isNotBlank(transEndDate)) { |
|||
wrapper.le(StringUtils.isNotBlank(transEndDate), "trans_date", transEndDate.replace("-", "")); |
|||
} |
|||
wrapper.eq(StringUtils.isNotBlank(gatherFlag) && !gatherFlag.equals("-1"), "gather_flag", gatherFlag); |
|||
//wrapper.eq(Constant.DEL_FLAG, DelFlagEnum.NORMAL.value());
|
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
private QueryWrapper<TbTransDetailEntity> getRepeatStockWrapper(Map<String, Object> params){ |
|||
String capitalAccount = (String)params.get("capitalAccount"); |
|||
String stockCode = (String)params.get("stockCode"); |
|||
String transDate = (String)params.get("transDate"); |
|||
String transTime = (String)params.get("transTime"); |
|||
|
|||
QueryWrapper<TbTransDetailEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(capitalAccount) && !capitalAccount.equals("0"), "capital_account", capitalAccount); |
|||
wrapper.eq(StringUtils.isNotBlank(stockCode), "stock_code", stockCode); |
|||
wrapper.eq(StringUtils.isNotBlank(transDate), "trans_date", transDate); |
|||
wrapper.eq(StringUtils.isNotBlank(transTime), "trans_time", transTime); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public TbTransDetailDTO get(String id) { |
|||
TbTransDetailEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, TbTransDetailDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<TbTransDetailEntity> saveAll(List<TbTransDetailEntity> list) { |
|||
List<TbTransDetailEntity> repeatEntityList = new ArrayList<>(); |
|||
Map<String, Object> params = new HashMap<>(4); |
|||
for (TbTransDetailEntity newTransDetail : list) { |
|||
params.put("capitalAccount",newTransDetail.getCapitalAccount()); |
|||
params.put("stockCode",newTransDetail.getStockCode()); |
|||
params.put("transDate",newTransDetail.getTransDate()); |
|||
params.put("transTime",newTransDetail.getTransTime()); |
|||
List<TbTransDetailEntity> entityList = baseDao.selectList(getRepeatStockWrapper(params)); |
|||
if(entityList!=null && entityList.size()>0){ |
|||
repeatEntityList.addAll(entityList); |
|||
} |
|||
} |
|||
if(repeatEntityList.size()==0){ |
|||
this.insertBatch(list); |
|||
} |
|||
return repeatEntityList; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(TbTransDetailDTO dto) { |
|||
TbTransDetailEntity entity = ConvertUtils.sourceToTarget(dto, TbTransDetailEntity.class); |
|||
|
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(TbTransDetailDTO dto) { |
|||
TbTransDetailEntity entity = ConvertUtils.sourceToTarget(dto, TbTransDetailEntity.class); |
|||
|
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
//逻辑删除
|
|||
//logicDelete(ids, TbTransDetailEntity.class);
|
|||
|
|||
//物理删除
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public void combineStock(Map<String, Object> map) { |
|||
baseDao.combineStock(map); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,129 @@ |
|||
package io.renren.stock.utils; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* @author wangyushuai@fang.com |
|||
* @date 2018/9/26 |
|||
* REST请求响应工具类 ,在controller控制器中,做为接口返回值 return RestResponse.buildSuccess(articles); |
|||
*/ |
|||
public class RestResponse implements Serializable { |
|||
|
|||
private final static long serialVersionUID = 1L; |
|||
/** |
|||
* 成功 |
|||
*/ |
|||
private final static int STATUS_SUCCESS = 200; |
|||
|
|||
/** |
|||
* 代码错误 |
|||
*/ |
|||
private final static int STATUS_ERROR_INTERNAL_SERVER_ERROR = 500; |
|||
|
|||
/** |
|||
* 服务不可用(针对熔断&服务降级的情况) |
|||
*/ |
|||
private final static int STATUS_ERROR_SERVICE_UNAVAILIABLE = 503; |
|||
|
|||
|
|||
private int status; |
|||
//@JsonInclude(JsonInclude.Include.NON_NULL)//不为空时,返回
|
|||
private Object data; |
|||
private String message; |
|||
|
|||
/** |
|||
* 时间戳并格式化 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",locale = "lz",timezone = "GMT+8") |
|||
private Date timestamp; |
|||
|
|||
/** |
|||
* 程序耗时 |
|||
*/ |
|||
//@JsonIgnore//不返回注解
|
|||
private long time; |
|||
|
|||
public RestResponse(int code, String message, Object data) { |
|||
super(); |
|||
this.status = code; |
|||
this.message = message; |
|||
this.data = data; |
|||
} |
|||
|
|||
/** |
|||
* 请求成功 |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public static RestResponse buildSuccess(Object data) { |
|||
return new RestResponse(STATUS_SUCCESS, "success", data); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 代码错误 |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public static RestResponse buildErrorInternalServerError(Object data) { |
|||
return new RestResponse(STATUS_ERROR_INTERNAL_SERVER_ERROR, "error", data); |
|||
} |
|||
|
|||
/** |
|||
* 返回错误码(服务不可用时,返回此方法),但推荐直接使用异常类 |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public static RestResponse buildErrorServiceUnavailable(Object data) { |
|||
return new RestResponse(STATUS_ERROR_SERVICE_UNAVAILIABLE, "error", data); |
|||
} |
|||
|
|||
// public static RestResponse buildError(Object data) {
|
|||
// return new RestResponse(STATUS_SUCCESS, "success", data);
|
|||
// }
|
|||
|
|||
public int getStatus() { |
|||
return status; |
|||
} |
|||
|
|||
public void setStatus(int status) { |
|||
this.status = status; |
|||
} |
|||
|
|||
public Object getData() { |
|||
return data; |
|||
} |
|||
|
|||
public void setData(Object data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
|
|||
public void setMessage(String message) { |
|||
this.message = message; |
|||
} |
|||
|
|||
public Date getTimestamp() { |
|||
return new Date(); |
|||
} |
|||
|
|||
public void setTimestamp(Date timestamp) { |
|||
this.timestamp = timestamp; |
|||
} |
|||
|
|||
public String getTime() { |
|||
return time + "ms"; |
|||
} |
|||
|
|||
public void setTime(long time) { |
|||
this.time = time; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package io.renren.stock.utils; |
|||
|
|||
import io.renren.commons.tools.constant.Constant; |
|||
|
|||
/** |
|||
* 模块常量 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.1.0 |
|||
*/ |
|||
public interface StockConstant extends Constant { |
|||
|
|||
String MODULE_PREFIX = "stock/"; |
|||
|
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue