Commit 5f32768f by 郑勇

feat: [1008302] 出版基金项目状态线上化

parent b9e91335
package com.pcloud.book.book.dto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class BookFundDetailDto implements Serializable {
/**
* 书刊ID
*/
@ApiModelProperty(value = "书刊ID")
private Long bookId;
/**
* 基金名字
*/
@ApiModelProperty(value = "基金名字")
private String fundName;
/**
* 转让方名字
*/
@ApiModelProperty(value = "转让方名字")
private String transferor;
/**
* 购买金额
*/
@ApiModelProperty(value = "购买金额")
private BigDecimal purchaseMoney;
/**
* 开始时间
*/
@ApiModelProperty(value = "开始时间")
private Date startTime;
/**
* 结束时间
*/
@ApiModelProperty(value = "结束时间")
private Date endTime;
/**
* 书刊是否有编辑关联
*/
private Boolean isHaveAdviser;
/**
* 书刊是否有基金支持
*/
private Boolean isFundSupport;
/**
* 书刊是否有基金
*/
private Boolean isHaveFund;
/**
* 冻结状态
*/
private Integer FreezeStatus;
@ApiModelProperty("冻结时间")
private Date freezeTime;
@ApiModelProperty("解冻时间")
private Date thawTime;
}
......@@ -60,6 +60,16 @@ public class BookFreeze extends BaseEntity{
*/
private String transferor;
private Integer fromErp;
public Integer getFromErp() {
return fromErp;
}
public void setFromErp(Integer fromErp) {
this.fromErp = fromErp;
}
public Long getId() {
return id;
}
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.book.entity;
import com.pcloud.common.entity.BaseEntity;
import java.math.BigDecimal;
import java.util.List;
/**
* @描述:书刊基金实体
......@@ -79,6 +80,26 @@ public class BookFund extends BaseEntity {
*/
private Integer isTransferor;
private Integer fromErp;
private List<Long> bookIds;
public List<Long> getBookIds() {
return bookIds;
}
public void setBookIds(List<Long> bookIds) {
this.bookIds = bookIds;
}
public Integer getFromErp() {
return fromErp;
}
public void setFromErp(Integer fromErp) {
this.fromErp = fromErp;
}
public Integer getIsTransferor() {
return isTransferor;
}
......@@ -185,8 +206,22 @@ public class BookFund extends BaseEntity {
@Override
public String toString() {
return "BookFund [bookFundId=" + bookFundId + ", bookId=" + bookId + ", fundName=" + fundName
+ ", purchaseMoney=" + purchaseMoney + ", startTime=" + startTime + ", endTime=" + endTime
+ ", createdUser=" + createdUser + ", lastModifiedUser=" + lastModifiedUser + "]";
return "BookFund{" +
"bookFundId=" + bookFundId +
", bookId=" + bookId +
", fundName='" + fundName + '\'' +
", purchaseMoney=" + purchaseMoney +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
", createdUser=" + createdUser +
", lastModifiedUser=" + lastModifiedUser +
", proxyMode=" + proxyMode +
", transferor='" + transferor + '\'' +
", contractNo='" + contractNo + '\'' +
", batchNumber='" + batchNumber + '\'' +
", isTransferor=" + isTransferor +
", fromErp=" + fromErp +
", bookIds=" + bookIds +
'}';
}
}
......@@ -37,6 +37,16 @@ public class ThawEarning extends BaseEntity {
*/
private BookFund bookFund;
private Integer fromErp;
public Integer getFromErp() {
return fromErp;
}
public void setFromErp(Integer fromErp) {
this.fromErp = fromErp;
}
public Long getBookId() {
return bookId;
}
......
package com.pcloud.book.book.biz;
import com.pcloud.book.book.dto.BookFundDetailDto;
import com.pcloud.book.book.dto.BookFundDto;
import com.pcloud.book.book.dto.BookFundInfoDto;
import com.pcloud.book.book.entity.BookFund;
......@@ -169,4 +170,14 @@ public interface BookFundBiz {
* * @param null
*/
Integer getFundBookCount();
/**
* 批量创建书刊基金状态
*/
void batchCreate(BookFund bookFund);
/**
* 同步旧数据
*/
Map<Long, BookFundDetailDto> synOldFundData(List<Long> bookIds);
}
......@@ -11,6 +11,7 @@ import com.pcloud.book.book.entity.BookFund;
import com.pcloud.book.book.entity.ThawEarning;
import com.pcloud.book.book.vo.BookFreezeFilterVO;
import com.pcloud.book.book.vo.BookFreezeInfoDto;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
......@@ -29,6 +30,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import cn.hutool.core.date.DateUtil;
/**
* 图书冻结业务层实现类
*
......@@ -48,6 +51,8 @@ public class BookFreezeBizImpl implements BookFreezeBiz {
private BookFundBiz bookFundBiz;
@Autowired
private AmqpTemplate amqpTemplate;
@Autowired
private ErpConsr erpConsr;
/**
* 获取图书是否被冻结
......@@ -73,6 +78,8 @@ public class BookFreezeBizImpl implements BookFreezeBiz {
}
try {
bookFreezeDao.insert(bookFreeze);
//同步到erp
erpConsr.freezeFund(bookFreeze.getBookId(),bookFreeze.getFreezetime());
} catch (Exception e) {
LOGGER.error("【图书收益冻结管理(平台端)】冻结收益,<ERROR>.[bookFreezeDao.insert]" + e.getMessage(), e);
throw new BookBizException(BookBizException.DB_DML_FAIL, "冻结收益失败!");
......@@ -109,6 +116,7 @@ public class BookFreezeBizImpl implements BookFreezeBiz {
BookFund bookFund = thawEarning.getBookFund();
if (thawEarning.getIsFund().equals(1)) {// 被基金购买
// 校验参数
bookFund.setFromErp(thawEarning.getFromErp());
this.checkFundParam(bookFund, bookFreezeDto.getFreezetime());
bookFund.setProxyMode(bookFreezeDto.getProxyMode());
bookFund.setTransferor(bookFreezeDto.getTransferor());
......@@ -119,6 +127,7 @@ public class BookFreezeBizImpl implements BookFreezeBiz {
Long bookFundId = bookFund == null ? null : bookFund.getBookFundId();
try {
bookFreezeDao.thaw(bookFundId,thawEarning.getBookId(), partyId);
erpConsr.thawFund(thawEarning.getBookId(), DateUtil.now());
} catch (Exception e) {
LOGGER.error("【图书收益冻结管理(平台端)】解冻收益,<ERROR>.[bookFreezeDao.thaw]" + e.getMessage(), e);
throw new BookBizException(BookBizException.DB_DML_FAIL, "解冻收益失败!");
......@@ -191,6 +200,9 @@ public class BookFreezeBizImpl implements BookFreezeBiz {
if (fundStartTime.before(freezetime)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "基金开始日期必须大于冻结开始日期!");
}
if(null!=bookFund.getFromErp()){
return;
}
if(StringUtil.isEmpty(bookFund.getContractNo())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "挂牌/合同编号不能为空!");
}
......@@ -261,6 +273,8 @@ public class BookFreezeBizImpl implements BookFreezeBiz {
this.checkFundParam(bookFreeze);
try {
bookFreezeDao.insert(bookFreeze);
//同步到erp
erpConsr.freezeFund(bookFreeze.getBookId(),bookFreeze.getFreezetime());
} catch (Exception e) {
LOGGER.error("【图书收益冻结(ERP)】冻结收益,<ERROR>.[bookFreezeDao.insert]" + e.getMessage(), e);
return false;
......
package com.pcloud.book.book.biz.impl;
import com.pcloud.book.base.enums.BookFreezeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookFreezeBiz;
import com.pcloud.book.book.biz.BookFundBiz;
import com.pcloud.book.book.dao.BookFreezeDao;
import com.pcloud.book.book.dao.BookFundDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.dto.BookFreezeDto;
import com.pcloud.book.book.dto.BookFundDetailDto;
import com.pcloud.book.book.dto.BookFundDto;
import com.pcloud.book.book.dto.BookFundInfoDto;
import com.pcloud.book.book.entity.BookFund;
import com.pcloud.book.book.entity.ThawEarning;
import com.pcloud.book.book.vo.BookFreezeInfoDto;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.elasticsearch7.domain.entity.Es7BookFreeze;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageParam;
......@@ -14,17 +25,27 @@ import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.apache.commons.lang.BooleanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
/**
* @描述:书刊基金业务实现层
......@@ -38,6 +59,12 @@ public class BookFundBizImpl implements BookFundBiz {
@Autowired
private BookFundDao bookFundDao;
@Autowired
private ErpConsr erpConsr;
@Autowired
private BookFreezeDao bookFreezeDao;
@Autowired
private AmqpTemplate amqpTemplate;
/**
* 创建书刊基金状态
......@@ -52,12 +79,27 @@ public class BookFundBizImpl implements BookFundBiz {
this.timeIsExsit(bookFund);
try {
bookFundDao.insert(bookFund);
//同步到erp,找endTime最大的一个
synErp(bookFund.getBookId());
} catch (Exception e) {
LOGGER.error("【书刊管理(平台端)】创建书刊基金状态,<ERROR>.[bookFundDao.insert]" + e.getMessage(), e);
throw new BookBizException(BookBizException.DB_DML_FAIL, "创建书刊基金状态失败!");
}
}
private void synErp(Long bookId) {
BookFundDto dto=bookFundDao.getMaxEndTimeByBookId(bookId);
if(null!=dto) {
//如果endTime最大的一个复合要求就同步
if (new Date().before(dto.getStartTime()) || (new Date().after(dto.getStartTime()) && new Date().before(dto.getEndTime())) ) {
erpConsr.addFund(bookId, DateUtil.formatDateTime(dto.getStartTime()), DateUtil.formatDateTime(dto.getEndTime()), dto.getFundName(), dto.getPurchaseMoney());
} else {
//否则删除
erpConsr.deleteFund(bookId);
}
}
}
/**
* 修改刊基金状态
*/
......@@ -80,6 +122,8 @@ public class BookFundBizImpl implements BookFundBiz {
this.timeIsExsit(bookFund);
try {
bookFundDao.update(bookFund);
//同步到erp,找endTime最大的一个
synErp(bookFund.getBookId());
} catch (Exception e) {
LOGGER.error("【书刊管理(平台端)】修改刊基金状态,<ERROR>.[bookFundDao.insert]" + e.getMessage(), e);
throw new BookBizException(BookBizException.DB_DML_FAIL, "修改刊基金状态失败!");
......@@ -106,6 +150,9 @@ public class BookFundBizImpl implements BookFundBiz {
if (null == bookFund.getEndTime()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "基金结束时间不能为空!");
}
if(null!=bookFund.getFromErp()){
return;
}
if(StringUtil.isEmpty(bookFund.getContractNo())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "挂牌/合同编号不能为空!");
}
......@@ -310,7 +357,17 @@ public class BookFundBizImpl implements BookFundBiz {
if (null == bookFundId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "基金标识不能为空!");
}
BookFundDto bookFundDto = bookFundDao.getByBookFundId(bookFundId);
bookFundDao.deleteById(bookFundId);
//同步到erp
List<BookFundDto> list = bookFundDao.getByBookId(bookFundDto.getBookId());
if(CollUtil.isEmpty(list)){
//如果都没有了
erpConsr.deleteFund(bookFundDto.getBookId());
}else{
//如果还有就同步最后一个
synErp(bookFundDto.getBookId());
}
}
/**
......@@ -360,4 +417,109 @@ public class BookFundBizImpl implements BookFundBiz {
public Integer getFundBookCount() {
return bookFundDao.getFundBookCount();
}
@Override
public void batchCreate(BookFund bookFund) {
LOGGER.info("【书刊管理(平台端)】批量创建书刊基金状态,<START>.[bookFund]:{}" , bookFund);
if(CollUtil.isEmpty(bookFund.getBookIds())){
return;
}
// erp逻辑,此处先解冻。
List<BookFund> list=new ArrayList<>();
BookFund build=null;
for (Long bookId : bookFund.getBookIds()) {
//此处先解冻
Boolean operate=true;
BookFreezeDto bookFreezeDto = bookFreezeDao.getBaseById(bookId);
if (bookFreezeDto!= null) {
ThawEarning thawEarning= new ThawEarning();
thawEarning.setBookId(bookId);
thawEarning.setIsFund(0);
try {
bookFreezeDao.thaw(null,thawEarning.getBookId(), null);
} catch (Exception e) {
LOGGER.error("【图书收益冻结管理(erp端)】解冻收益,<ERROR>.[bookFreezeDao.thaw]" + e.getMessage(), e);
operate=false;
}
if(operate) {
thawEarning.setFreezetime(bookFreezeDto.getFreezetime());
amqpTemplate.convertAndSend(MQTopicProducer.EXCHAGE, MQTopicProducer.BOOK_THAW, thawEarning);
}
}
build=new BookFund();
BeanUtil.copyProperties(bookFund,build,false);
build.setBookId(bookId);
try {
timeIsExsit(build);
} catch (BizException e) {
continue;
}
list.add(build);
}
try {
if(CollUtil.isNotEmpty(list)) {
bookFundDao.insert(list);
}
} catch (Exception e) {
LOGGER.error("【书刊管理(平台端)】批量创建书刊基金状态,<ERROR>.[bookFundDao.insert]" + e.getMessage(), e);
throw new BookBizException(BookBizException.DB_DML_FAIL, "批量创建书刊基金状态失败!");
}
}
@Override
public Map<Long, BookFundDetailDto> synOldFundData(List<Long> bookIds) {
if(CollUtil.isEmpty(bookIds)){
return new HashMap<>();
}
Map<Long, BookFundDetailDto> result=new HashMap<>();
List<BookFundDto> listByBookIds = bookFundDao.getListByBookIds(bookIds);
Map<Long, List<BookFundDto>> bookFundMap =CollUtil.isEmpty(listByBookIds) ? new HashMap<>() : listByBookIds.stream().collect(Collectors.groupingBy(a -> a.getBookId()));
List<BookFreezeInfoDto> bookFreezeInfoDtos = bookFreezeDao.listBookFreezeInfo(bookIds);
Map<Long, List<BookFreezeInfoDto>> bookFreezeMap =CollUtil.isEmpty(bookFreezeInfoDtos) ? new HashMap<>() : bookFreezeInfoDtos.stream().collect(Collectors.groupingBy(a -> a.getBookId()));
for (Long bookId : bookIds) {
boolean isFundSupport = false;
Integer freezeStatus = BookFreezeEnum.WAIT_FREEZE.value;
BookFundDetailDto dto=new BookFundDetailDto();
if(CollUtil.isNotEmpty(bookFundMap) && bookFundMap.containsKey(bookId)){
List<BookFundDto> bookFundDtos = bookFundMap.get(bookId);
bookFundDtos.sort(Comparator.comparing(BookFundDto::getEndTime));
for (BookFundDto bookFundDto : bookFundDtos) {
Date startTime = bookFundDto.getStartTime();
Date endTime = bookFundDto.getEndTime();
if (new Date().before(startTime)) {
freezeStatus = BookFreezeEnum.NO_FREEZE.value;
} else if (new Date().after(startTime) && new Date().before(endTime)) {
freezeStatus = BookFreezeEnum.NO_FREEZE.value;
}
if (new Date().before(endTime)) {
isFundSupport = true;
}
//这些字段取最后一个
if(BookFreezeEnum.NO_FREEZE.value.equals(freezeStatus)) {
dto.setStartTime(startTime);
dto.setEndTime(endTime);
dto.setFundName(bookFundDto.getFundName());
dto.setTransferor(bookFundDto.getTransferor());
dto.setPurchaseMoney(bookFundDto.getPurchaseMoney());
}
}
dto.setIsHaveFund(true);
}
if(CollUtil.isNotEmpty(bookFreezeMap) && bookFreezeMap.containsKey(bookId)){
List<BookFreezeInfoDto> listFreeze = bookFreezeMap.get(bookId);
listFreeze.sort(Comparator.comparing(BookFreezeInfoDto::getId).reversed());
BookFreezeInfoDto bookFreezeInfoDto = listFreeze.get(0);
if(bookFreezeInfoDto.getFreezeStatus().equals(BookFreezeEnum.FREEZE.value.intValue())){
dto.setFreezeTime(null!=bookFreezeInfoDto.getFreezeTime() ? DateUtil.parse(bookFreezeInfoDto.getFreezeTime(), DatePattern.NORM_DATE_FORMAT) : null);
}else{
dto.setThawTime(null!=bookFreezeInfoDto.getThawTime() ? DateUtil.parse(bookFreezeInfoDto.getThawTime(), DatePattern.NORM_DATE_FORMAT) : null);
}
}
dto.setIsFundSupport(isFundSupport);
dto.setFreezeStatus(BooleanUtils.toIntegerObject(dto.getFreezeTime() == null,
freezeStatus, BookFreezeEnum.FREEZE.value));
result.put(bookId,dto);
}
return result;
}
}
......@@ -137,4 +137,8 @@ public interface BookFundDao extends BaseDao<BookFund> {
* * @param null
*/
Integer getFundBookCount();
List<BookFundDto> getListByBookIds(List<Long> bookIds);
BookFundDto getMaxEndTimeByBookId(Long bookId);
}
package com.pcloud.book.book.dao.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -129,4 +130,18 @@ public class BookFundDaoImpl extends BaseDaoImpl<BookFund> implements BookFundDa
public Integer getFundBookCount() {
return getSessionTemplate().selectOne(getStatement("getFundBookCount"));
}
@Override
public List<BookFundDto> getListByBookIds(List<Long> bookIds) {
Map<String, Object> paramMap=new HashMap<>();
paramMap.put("bookIds",bookIds);
return super.getSqlSession().selectList(this.getStatement("getListByBookIds"), paramMap);
}
@Override
public BookFundDto getMaxEndTimeByBookId(Long bookId) {
Map<String, Object> paramMap=new HashMap<>();
paramMap.put("bookId",bookId);
return super.getSqlSession().selectOne(this.getStatement("getMaxEndTimeByBookId"), paramMap);
}
}
......@@ -36,7 +36,7 @@ public interface BookFreezeFacade {
@ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", dataType = "string", paramType = "header"),
@ApiImplicitParam(name = "bookFreeze", value = "图书冻结实体", dataType = "BookFreeze", paramType = "body") })
@RequestMapping(value = "create", method = RequestMethod.POST)
ResponseDto<?> create(@RequestHeader("token") String token, @RequestBody BookFreeze bookFreeze)
ResponseDto<?> create(@RequestHeader(value = "token",required = false) String token, @RequestBody BookFreeze bookFreeze)
throws BizException, PermissionException, JsonParseException;
/**
......@@ -70,7 +70,7 @@ public interface BookFreezeFacade {
@ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", dataType = "string", paramType = "header"),
@ApiImplicitParam(name = "thawEarning", value = "图书解冻实体", dataType = "ThawEarning", paramType = "body") })
@RequestMapping(value = "thaw", method = RequestMethod.POST)
ResponseDto<?> thaw(@RequestHeader("token") String token, @RequestBody ThawEarning thawEarning)
ResponseDto<?> thaw(@RequestHeader(value = "token",required = false) String token, @RequestBody ThawEarning thawEarning)
throws BizException, PermissionException, JsonParseException;
/**
......
......@@ -44,10 +44,12 @@ public class BookFreezeFacadeImpl implements BookFreezeFacade {
*/
@Override
@RequestMapping(value = "create", method = RequestMethod.POST)
public ResponseDto<?> create(@RequestHeader("token") String token, @RequestBody BookFreeze bookFreeze)
public ResponseDto<?> create(@RequestHeader(value = "token",required = false) String token, @RequestBody BookFreeze bookFreeze)
throws BizException, PermissionException, JsonParseException {
if(null!=bookFreeze && null==bookFreeze.getFromErp()) {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookFreeze.setCreatedUser(partyId);
}
bookFreezeBiz.create(bookFreeze);
return new ResponseDto<>();
}
......@@ -83,9 +85,12 @@ public class BookFreezeFacadeImpl implements BookFreezeFacade {
*/
@Override
@RequestMapping(value = "thaw", method = RequestMethod.POST)
public ResponseDto<?> thaw(@RequestHeader("token") String token, @RequestBody ThawEarning thawEarning)
public ResponseDto<?> thaw(@RequestHeader(value = "token",required = false) String token, @RequestBody ThawEarning thawEarning)
throws BizException, PermissionException, JsonParseException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
Long partyId =null;
if(null!=thawEarning && null==thawEarning.getFromErp()) {
partyId =(Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
}
bookFreezeBiz.thaw(thawEarning, partyId);
return new ResponseDto<>();
}
......
......@@ -126,4 +126,23 @@ public class BookFundFacadeImpl implements BookFundFacade {
return new ResponseDto<>();
}
/**
* 批量创建书刊基金状态,接口给erp调用。逻辑不一样。请勿用
*/
@RequestMapping(value = "batchCreate", method = RequestMethod.POST)
public ResponseDto<?> batchCreate(@RequestBody BookFund bookFund)
throws BizException, PermissionException, JsonParseException {
bookFundBiz.batchCreate(bookFund);
return new ResponseDto<>();
}
/**
* 同步旧数据
*/
@RequestMapping(value = "synOldFundData", method = RequestMethod.POST)
public ResponseDto<?> synOldFundData(@RequestBody List<Long> bookIds)
throws BizException, PermissionException, JsonParseException {
return new ResponseDto<>(bookFundBiz.synOldFundData(bookIds));
}
}
......@@ -13,6 +13,8 @@ import lombok.ToString;
@AllArgsConstructor
public class BookFreezeInfoDto {
private Long id;
private Long bookId;
private String freezeTime;
......
......@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
......@@ -427,4 +428,73 @@ public class ErpConsr {
}
}
/**
* 冻结书刊收益
*/
public void freezeFund(Long bookId,String freezetime) {
Map<String, String> querys = new HashMap<>();
querys.put("bookId", bookId.toString());
querys.put("freezetime", freezetime);
try {
HttpResponse response = HttpUtils.doGet(domain, "/erp/project4Third/freezeFund", "GET", new HashMap<>(), querys);
String entityString = EntityUtils.toString(response.getEntity());
LOGGER.info("冻结书刊收益[project4Third.freezeFund]:" + entityString);
} catch (Exception e){
LOGGER.error("erp冻结书刊收益失败[project4Third.freezeFund]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "冻结erp书刊收益失败~!");
}
}
/**
* 解冻书刊收益
*/
public void thawFund(Long bookId,String thawTime) {
Map<String, String> querys = new HashMap<>();
querys.put("bookId", bookId.toString());
querys.put("thawTime", thawTime);
try {
HttpResponse response = HttpUtils.doGet(domain, "/erp/project4Third/thawFund", "GET", new HashMap<>(), querys);
String entityString = EntityUtils.toString(response.getEntity());
LOGGER.info("解冻书刊收益[project4Third.thawFund]:" + entityString);
} catch (Exception e){
LOGGER.error("erp冻结书刊收益失败[project4Third.thawFund]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "冻结erp书刊收益失败~!");
}
}
/**
* 添加基金书刊
*/
public void addFund(Long bookId, String startTime, String endTime, String fundName, BigDecimal purchaseMoney) {
Map<String, String> querys = new HashMap<>();
querys.put("bookId", bookId.toString());
querys.put("startTime", startTime);
querys.put("endTime", endTime);
querys.put("fundName", fundName);
querys.put("purchaseMoney", purchaseMoney.toString());
try {
HttpResponse response = HttpUtils.doGet(domain, "/erp/project4Third/addFund", "GET", new HashMap<>(), querys);
String entityString = EntityUtils.toString(response.getEntity());
LOGGER.info("添加基金书刊[project4Third.addFund]:" + entityString);
} catch (Exception e){
LOGGER.error("erp设置基金信息失败[project4Third.addFund]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "erp设置基金信息失败~!");
}
}
/**
* 删除基金设置
*/
public void deleteFund(Long bookId) {
Map<String, String> querys = new HashMap<>();
querys.put("bookId", bookId.toString());
try {
HttpResponse response = HttpUtils.doGet(domain, "/erp/project4Third/deleteFund", "GET", new HashMap<>(), querys);
String entityString = EntityUtils.toString(response.getEntity());
LOGGER.info("删除基金设置[project4Third.deleteFund]:" + entityString);
} catch (Exception e){
LOGGER.error("erp删除基金信息失败[project4Third.deleteFund]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "erp删除基金信息失败~!");
}
}
}
......@@ -190,6 +190,7 @@
<select id="listBookFreezeInfo" parameterType="map" resultType="com.pcloud.book.book.vo.BookFreezeInfoDto">
SELECT
id id,
BOOK_ID bookId,
DATE_FORMAT( FREEZETIME, '%Y-%m-%d' ) freezeTime,
IS_FREEZE freezeStatus,
......
......@@ -58,6 +58,22 @@
#{proxyMode,jdbcType=BIT},#{transferor,jdbcType=VARCHAR},#{isTransferor,jdbcType=BIT})
</insert>
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="bookFundId" flushCache="true">
insert into book_fund (BOOK_ID, FUND_NAME,
PURCHASE_MONEY, START_TIME, END_TIME,
CREATED_USER, CREATED_DATE, LAST_MODIFIED_USER,
LAST_MODIFIED_DATE, VERSION,CONTRACT_NO,BATCH_NUMBER,PROXY_MODE,TRANSFEROR,IS_TRANSFEROR)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.bookId,jdbcType=BIGINT}, #{item.fundName,jdbcType=VARCHAR},
#{item.purchaseMoney,jdbcType=DECIMAL}, #{item.startTime,jdbcType=TIMESTAMP},
#{item.endTime,jdbcType=TIMESTAMP},#{item.createdUser,jdbcType=BIGINT},
now(), #{item.createdUser,jdbcType=BIGINT},now(),1,
#{item.contractNo,jdbcType=VARCHAR},#{item.batchNumber,jdbcType=VARCHAR},
#{item.proxyMode,jdbcType=BIT},#{item.transferor,jdbcType=VARCHAR},#{item.isTransferor,jdbcType=BIT})
</foreach>
</insert>
<!-- 修改书籍基金信息-->
<!--michael 修改于20180807-->
<update id="update" parameterType="bookFund" flushCache="true">
......@@ -274,4 +290,25 @@
AND bf.BOOK_FUND_ID IS NOT NULL
</select>
<select id="getListByBookIds" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from book_fund
WHERE
BOOK_ID IN
<foreach collection="bookIds" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
</select>
<select id="getMaxEndTimeByBookId" parameterType="map" resultMap="BaseResultMap">
SELECT
BOOK_FUND_ID, BOOK_ID, FUND_NAME, PURCHASE_MONEY,
START_TIME, END_TIME,VERSION,CONTRACT_NO,BATCH_NUMBER,PROXY_MODE,TRANSFEROR,IS_TRANSFEROR
FROM BOOK_FUND
WHERE BOOK_ID = #{bookId,jdbcType=BIGINT}
ORDER BY END_TIME DESC
limit 1
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment