This commit is contained in:
mmm8955405 2024-03-05 12:02:00 +08:00
parent b38264a5ed
commit 04e6ddb753
5 changed files with 169 additions and 40 deletions

View File

@ -152,18 +152,39 @@ public class ContractInfoController {
List<ContractInfoStatuScribeStore> list = contractInfoSelectMapper.selectStroeMany(provider); List<ContractInfoStatuScribeStore> list = contractInfoSelectMapper.selectStroeMany(provider);
//-------涨跌
List<String> ids = list.stream() List<String> ids = list.stream()
.map(ContractInfoStatuScribeStore::getTs_code) .map(ContractInfoStatuScribeStore::getTs_code)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<FutDaily> futs = var f =
futDailyMapper.select(s-> selectDistinct(FutDailyDynamicSqlSupport.futDaily.allColumns())
s.where(FutDailyDynamicSqlSupport.ts_code,SqlBuilder.isIn(ids)) .from(FutDailyDynamicSqlSupport.futDaily)
.groupBy(FutDailyDynamicSqlSupport.ts_code) .where(FutDailyDynamicSqlSupport.ts_code,SqlBuilder.isIn(ids))
.orderBy(FutDailyDynamicSqlSupport.trade_date.descending()) .orderBy(FutDailyDynamicSqlSupport.trade_date.descending())
); ;
var s = select(FutDailyDynamicSqlSupport.futDaily.allColumns())
.from(f,"f")
.groupBy(FutDailyDynamicSqlSupport.ts_code.qualifiedWith("f"))
.build()
.render(RenderingStrategies.MYBATIS3);
List<FutDaily> futs =
futDailyMapper.selectMany(s);
list.forEach(i->{
futs.forEach(d->{
if(d.getTs_code().equals(d.getTs_code())) {
i.setFutDaily(d);
}
});
});
//------
SelectStatementProvider count = function.apply(select(count())) SelectStatementProvider count = function.apply(select(count()))
.applyWhere(applier) .applyWhere(applier)
@ -381,16 +402,23 @@ public class ContractInfoController {
BasicColumn[] basic = ArrayUtils.addAll(allContractInfo,store); BasicColumn[] basic = ArrayUtils.addAll(allContractInfo,store);
Function<QueryExpressionDSL.FromGatherer<SelectModel>, QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher> function =
s -> {
var from = s
.from(ContractInfoDynamicSqlSupport.contractInfo, "contractInfo")
.leftJoin(contractInfoUser,"contractInfoUser")
.on(ContractInfoDynamicSqlSupport.ts_code.qualifiedWith("contractInfo"),
equalTo(ContractInfoUserDynamicSqlSupport.ts_code.qualifiedWith("contractInfoUser")))
.leftJoin(ContractInfoStatusDynamicSqlSupport.contractInfoStatus)
.on(ContractInfoDynamicSqlSupport.ts_code.qualifiedWith("contractInfo"),
equalTo(ContractInfoStatusDynamicSqlSupport.ts_code.qualifiedWith("contract_info_status")))
;
return from;
};
var from = select(basic)
.from(ContractInfoDynamicSqlSupport.contractInfo, "contractInfo")
.leftJoin(contractInfoUser,"contractInfoUser")
.on(ContractInfoDynamicSqlSupport.ts_code.qualifiedWith("contractInfo"),
equalTo(ContractInfoUserDynamicSqlSupport.ts_code.qualifiedWith("contractInfoUser")))
.leftJoin(ContractInfoStatusDynamicSqlSupport.contractInfoStatus)
.on(ContractInfoDynamicSqlSupport.ts_code.qualifiedWith("contractInfo"),
equalTo(ContractInfoStatusDynamicSqlSupport.ts_code.qualifiedWith("contract_info_status")))
;
var where = SqlBuilder.where(); var where = SqlBuilder.where();
where.and( where.and(
ContractInfoStatusDynamicSqlSupport.contract_status.qualifiedWith("contract_info_status"), isNull(), ContractInfoStatusDynamicSqlSupport.contract_status.qualifiedWith("contract_info_status"), isNull(),
@ -398,31 +426,51 @@ public class ContractInfoController {
where.and(ContractInfoUserDynamicSqlSupport.userid.qualifiedWith("contractInfoUser"), isEqualTo(user.getId())); where.and(ContractInfoUserDynamicSqlSupport.userid.qualifiedWith("contractInfoUser"), isEqualTo(user.getId()));
WhereApplier applier = where.toWhereApplier(); WhereApplier applier = where.toWhereApplier();
SelectStatementProvider provider = from SelectStatementProvider provider = function.apply(select(basic))
.applyWhere(applier) .applyWhere(applier)
.limit(p.getPageSize()) .limit(p.getPageSize())
.offset(p.limitStart()) .offset(p.limitStart())
.build() .build()
.render(RenderingStrategies.MYBATIS3); .render(RenderingStrategies.MYBATIS3);
var list = contractInfoSelectMapper.selectStroeMany(provider); var list = contractInfoSelectMapper.selectStroeMany(provider);
//-------涨跌
List<String> ids = list.stream()
.map(ContractInfoStatuScribeStore::getTs_code)
.collect(Collectors.toList());
var count = select(count()) var f =
.from(ContractInfoDynamicSqlSupport.contractInfo, "contractInfo") selectDistinct(FutDailyDynamicSqlSupport.futDaily.allColumns())
.leftJoin(contractInfoUser,"contractInfoUser") .from(FutDailyDynamicSqlSupport.futDaily)
.on(ContractInfoDynamicSqlSupport.ts_code.qualifiedWith("contractInfo"), .where(FutDailyDynamicSqlSupport.ts_code,SqlBuilder.isIn(ids))
equalTo(ContractInfoUserDynamicSqlSupport.ts_code.qualifiedWith("contractInfoUser"))) .orderBy(FutDailyDynamicSqlSupport.trade_date.descending())
.leftJoin(ContractInfoStatusDynamicSqlSupport.contractInfoStatus) ;
.on(ContractInfoDynamicSqlSupport.ts_code.qualifiedWith("contractInfo"), var s = select(FutDailyDynamicSqlSupport.futDaily.allColumns())
equalTo(ContractInfoStatusDynamicSqlSupport.ts_code.qualifiedWith("contract_info_status"))) .from(f,"f")
.where( .groupBy(FutDailyDynamicSqlSupport.ts_code.qualifiedWith("f"))
ContractInfoStatusDynamicSqlSupport.contract_status.qualifiedWith("contract_info_status"), isNull(),
or(ContractInfoStatusDynamicSqlSupport.contract_status.qualifiedWith("contract_info_status"), isEqualTo(0)))
.and(ContractInfoUserDynamicSqlSupport.userid.qualifiedWith("contractInfoUser"), isEqualTo(user.getId()))
.build() .build()
.render(RenderingStrategies.MYBATIS3); .render(RenderingStrategies.MYBATIS3);
List<FutDaily> futs =
futDailyMapper.selectMany(s);
list.forEach(i->{
futs.forEach(d->{
if(d.getTs_code().equals(d.getTs_code())) {
i.setFutDaily(d);
}
});
});
//------
SelectStatementProvider count = function.apply(select(count()))
.applyWhere(applier)
.build().render(RenderingStrategies.MYBATIS3);
long total = selectMapper.count(count); long total = selectMapper.count(count);
p.setList(list); p.setList(list);
p.setTotal(total); p.setTotal(total);

View File

@ -32,14 +32,19 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jj.tech.finance.biz.web.dao.ContractInfoSelectMapper; import jj.tech.finance.biz.web.dao.ContractInfoSelectMapper;
import jj.tech.finance.biz.webadmin.dao.SelectMapper; import jj.tech.finance.biz.webadmin.dao.SelectMapper;
import jj.tech.finance.biz.webadmin.vo.ContractInfoStatuScribe;
import jj.tech.finance.biz.webadmin.vo.ContractInfoStatuScribeStore;
import jj.tech.finance.biz.webadmin.vo.parm.Contract; import jj.tech.finance.biz.webadmin.vo.parm.Contract;
import jj.tech.finance.biz.webadmin.vo.parm.Ids; import jj.tech.finance.biz.webadmin.vo.parm.Ids;
import jj.tech.finance.repository.mybatis.dao.ContractInfoMapper; import jj.tech.finance.repository.mybatis.dao.ContractInfoMapper;
import jj.tech.finance.repository.mybatis.dao.ContractInfoStatusMapper; import jj.tech.finance.repository.mybatis.dao.ContractInfoStatusMapper;
import jj.tech.finance.repository.mybatis.dao.FutDailyMapper;
import jj.tech.finance.repository.mybatis.dao.support.ContractInfoDynamicSqlSupport; import jj.tech.finance.repository.mybatis.dao.support.ContractInfoDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.dao.support.ContractInfoStatusDynamicSqlSupport; import jj.tech.finance.repository.mybatis.dao.support.ContractInfoStatusDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.dao.support.FutDailyDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.entity.ContractInfo; import jj.tech.finance.repository.mybatis.entity.ContractInfo;
import jj.tech.finance.repository.mybatis.entity.ContractInfoStatus; import jj.tech.finance.repository.mybatis.entity.ContractInfoStatus;
import jj.tech.finance.repository.mybatis.entity.FutDaily;
import jj.tech.finance.repository.mybatis.entity.SysAdmin; import jj.tech.finance.repository.mybatis.entity.SysAdmin;
import jj.tech.finance.utils.Page; import jj.tech.finance.utils.Page;
import jj.tech.finance.utils.R; import jj.tech.finance.utils.R;
@ -54,6 +59,7 @@ public class ContractInfoManageController {
@Autowired ContractInfoMapper contractInfoMapper; @Autowired ContractInfoMapper contractInfoMapper;
@Autowired ContractInfoStatusMapper contractInfoStatusMapper; @Autowired ContractInfoStatusMapper contractInfoStatusMapper;
@Autowired ContractInfoSelectMapper contractInfoSelectMapper; @Autowired ContractInfoSelectMapper contractInfoSelectMapper;
@Autowired FutDailyMapper futDailyMapper;
@Autowired SelectMapper selectMapper; @Autowired SelectMapper selectMapper;
@ -124,6 +130,40 @@ public class ContractInfoManageController {
var list = contractInfoSelectMapper.selectStatuMany(provider); var list = contractInfoSelectMapper.selectStatuMany(provider);
//-------涨跌
List<String> ids = list.stream()
.map(ContractInfoStatuScribe::getTs_code)
.collect(Collectors.toList());
var f =
selectDistinct(FutDailyDynamicSqlSupport.futDaily.allColumns())
.from(FutDailyDynamicSqlSupport.futDaily)
.where(FutDailyDynamicSqlSupport.ts_code,SqlBuilder.isIn(ids))
.orderBy(FutDailyDynamicSqlSupport.trade_date.descending())
;
var s = select(FutDailyDynamicSqlSupport.futDaily.allColumns())
.from(f,"f")
.groupBy(FutDailyDynamicSqlSupport.ts_code.qualifiedWith("f"))
.build()
.render(RenderingStrategies.MYBATIS3);
List<FutDaily> futs =
futDailyMapper.selectMany(s);
list.forEach(i->{
futs.forEach(d->{
if(d.getTs_code().equals(d.getTs_code())) {
i.setFutDaily(d);
}
});
});
//------
List l = List l =
list.stream().map(i->{ list.stream().map(i->{
Map<String,Object> m = objectMapper.convertValue(i, Map.class); Map<String,Object> m = objectMapper.convertValue(i, Map.class);
@ -131,6 +171,8 @@ public class ContractInfoManageController {
return m; return m;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
long total = contractInfoSelectMapper.count(count); long total = contractInfoSelectMapper.count(count);
p.setList(l); p.setList(l);
p.setTotal(total); p.setTotal(total);

View File

@ -36,6 +36,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jj.tech.finance.biz.web.dao.ContractInfoSelectMapper; import jj.tech.finance.biz.web.dao.ContractInfoSelectMapper;
import jj.tech.finance.biz.webadmin.dao.SelectMapper; import jj.tech.finance.biz.webadmin.dao.SelectMapper;
import jj.tech.finance.biz.webadmin.vo.ContractInfoStatuScribe;
import jj.tech.finance.biz.webadmin.vo.ScribeVo; import jj.tech.finance.biz.webadmin.vo.ScribeVo;
import jj.tech.finance.biz.webadmin.vo.parm.Contract; import jj.tech.finance.biz.webadmin.vo.parm.Contract;
import jj.tech.finance.biz.webadmin.vo.parm.Id; import jj.tech.finance.biz.webadmin.vo.parm.Id;
@ -43,12 +44,15 @@ import jj.tech.finance.biz.webadmin.vo.parm.Ids;
import jj.tech.finance.repository.mybatis.dao.ContractInfoMapper; import jj.tech.finance.repository.mybatis.dao.ContractInfoMapper;
import jj.tech.finance.repository.mybatis.dao.ContractInfoStatusMapper; import jj.tech.finance.repository.mybatis.dao.ContractInfoStatusMapper;
import jj.tech.finance.repository.mybatis.dao.ContractInfoStatusScribeMapper; import jj.tech.finance.repository.mybatis.dao.ContractInfoStatusScribeMapper;
import jj.tech.finance.repository.mybatis.dao.FutDailyMapper;
import jj.tech.finance.repository.mybatis.dao.support.ContractInfoDynamicSqlSupport; import jj.tech.finance.repository.mybatis.dao.support.ContractInfoDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.dao.support.ContractInfoStatusDynamicSqlSupport; import jj.tech.finance.repository.mybatis.dao.support.ContractInfoStatusDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.dao.support.ContractInfoStatusScribeDynamicSqlSupport; import jj.tech.finance.repository.mybatis.dao.support.ContractInfoStatusScribeDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.dao.support.FutDailyDynamicSqlSupport;
import jj.tech.finance.repository.mybatis.entity.ContractInfo; import jj.tech.finance.repository.mybatis.entity.ContractInfo;
import jj.tech.finance.repository.mybatis.entity.ContractInfoStatus; import jj.tech.finance.repository.mybatis.entity.ContractInfoStatus;
import jj.tech.finance.repository.mybatis.entity.ContractInfoStatusScribe; import jj.tech.finance.repository.mybatis.entity.ContractInfoStatusScribe;
import jj.tech.finance.repository.mybatis.entity.FutDaily;
import jj.tech.finance.repository.mybatis.entity.SysAdmin; import jj.tech.finance.repository.mybatis.entity.SysAdmin;
import jj.tech.finance.utils.Page; import jj.tech.finance.utils.Page;
import jj.tech.finance.utils.R; import jj.tech.finance.utils.R;
@ -64,6 +68,7 @@ public class ContractInfoScribeController {
@Autowired ContractInfoStatusMapper contractInfoStatusMapper; @Autowired ContractInfoStatusMapper contractInfoStatusMapper;
@Autowired ContractInfoStatusScribeMapper contractInfoStatusScribeMapper; @Autowired ContractInfoStatusScribeMapper contractInfoStatusScribeMapper;
@Autowired ContractInfoSelectMapper contractInfoSelectMapper; @Autowired ContractInfoSelectMapper contractInfoSelectMapper;
@Autowired FutDailyMapper futDailyMapper;
@Autowired SelectMapper selectMapper; @Autowired SelectMapper selectMapper;
@Operation(summary = "合约信息列表", description = "ts_code合约代码, symbol交易代码,exchange交易所") @Operation(summary = "合约信息列表", description = "ts_code合约代码, symbol交易代码,exchange交易所")
@ -131,6 +136,37 @@ public class ContractInfoScribeController {
var list = contractInfoSelectMapper.selectStatuMany(provider); var list = contractInfoSelectMapper.selectStatuMany(provider);
long total = contractInfoSelectMapper.count(count); long total = contractInfoSelectMapper.count(count);
//-------涨跌
List<String> ids = list.stream()
.map(ContractInfoStatuScribe::getTs_code)
.collect(Collectors.toList());
var f =
selectDistinct(FutDailyDynamicSqlSupport.futDaily.allColumns())
.from(FutDailyDynamicSqlSupport.futDaily)
.where(FutDailyDynamicSqlSupport.ts_code,SqlBuilder.isIn(ids))
.orderBy(FutDailyDynamicSqlSupport.trade_date.descending())
;
var s = select(FutDailyDynamicSqlSupport.futDaily.allColumns())
.from(f,"f")
.groupBy(FutDailyDynamicSqlSupport.ts_code.qualifiedWith("f"))
.build()
.render(RenderingStrategies.MYBATIS3);
List<FutDaily> futs =
futDailyMapper.selectMany(s);
list.forEach(i->{
futs.forEach(d->{
if(d.getTs_code().equals(d.getTs_code())) {
i.setFutDaily(d);
}
});
});
//------
var l = var l =
list.stream().map(i->{ list.stream().map(i->{

View File

@ -2,11 +2,15 @@ package jj.tech.finance.biz.webadmin.vo;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import jj.tech.finance.repository.mybatis.entity.FutDaily;
public class ContractInfoStatuScribe extends ContractInfoStatu{ public class ContractInfoStatuScribe extends ContractInfoStatu{
public Integer scribe_status; public Integer scribe_status;
public Integer scribe_number; public Integer scribe_number;
public LocalDateTime scribe_update_time; public LocalDateTime scribe_update_time;
public FutDaily futDaily;
public Integer getScribe_status() { public Integer getScribe_status() {
return scribe_status; return scribe_status;
@ -26,6 +30,12 @@ public class ContractInfoStatuScribe extends ContractInfoStatu{
public void setScribe_update_time(LocalDateTime scribe_update_time) { public void setScribe_update_time(LocalDateTime scribe_update_time) {
this.scribe_update_time = scribe_update_time; this.scribe_update_time = scribe_update_time;
} }
public FutDaily getFutDaily() {
return futDaily;
}
public void setFutDaily(FutDaily futDaily) {
this.futDaily = futDaily;
}

View File

@ -1,11 +1,9 @@
package jj.tech.finance.biz.webadmin.vo; package jj.tech.finance.biz.webadmin.vo;
import jj.tech.finance.repository.mybatis.entity.FutDaily;
public class ContractInfoStatuScribeStore extends ContractInfoStatuScribe { public class ContractInfoStatuScribeStore extends ContractInfoStatuScribe {
public Integer store; public Integer store;
public FutDaily futDaily;
public Integer getStore() { public Integer getStore() {
return store; return store;
@ -13,12 +11,7 @@ public class ContractInfoStatuScribeStore extends ContractInfoStatuScribe {
public void setStore(Integer store) { public void setStore(Integer store) {
this.store = store; this.store = store;
} }
public FutDaily getFutDaily() {
return futDaily;
}
public void setFutDaily(FutDaily futDaily) {
this.futDaily = futDaily;
}
} }