Commit f07e3fdb by lili

版权保护优化

parent 7caddf92
......@@ -5,6 +5,7 @@ package com.pcloud.book.book.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.Date;
......@@ -397,6 +398,8 @@ public class BookDto extends BaseDto {
*/
private String qrRemark;
@ApiModelProperty("图书状态")
private Integer bookStatus;
public String getQrRemark() {
return qrRemark;
......@@ -1006,29 +1009,94 @@ public class BookDto extends BaseDto {
this.typeCodeNames = typeCodeNames;
}
public Integer getBookStatus() {
return bookStatus;
}
public void setBookStatus(Integer bookStatus) {
this.bookStatus = bookStatus;
}
@Override
public String toString() {
return "BookDto [bookId=" + bookId + ", typeCode=" + typeCode + ", typeName=" + typeName + ", isbn=" + isbn
+ ", bookName=" + bookName + ", bookPrice=" + bookPrice + ", originName=" + originName + ", remark="
+ remark + ", author=" + author + ", publish=" + publish + ", publishDate=" + publishDate
+ ", coverImg=" + coverImg + ", detail=" + detail + ", sponsor=" + sponsor + ", organizer=" + organizer
+ ", cn=" + cn + ", releaseCycle=" + releaseCycle + ", bookNum=" + bookNum + ", programa=" + programa
+ ", mailCode=" + mailCode + ", address=" + address + ", telephone=" + telephone + ", mail=" + mail
+ ", purpose=" + purpose + ", adviserId=" + adviserId + ", adviserName=" + adviserName + ", channelId="
+ channelId + ", channelName=" + channelName + ", qrcodeCount=" + qrcodeCount + ", appCount=" + appCount
+ ", productCount=" + productCount + ", latestQrcode=" + latestQrcode + ", apps=" + apps + ", products="
+ products + ", resourceFiles=" + resourceFiles + ", firstScanDate=" + firstScanDate
+ ", firstSceneName=" + firstSceneName + ", issn=" + issn + ", appId=" + appId + ", serialNumber="
+ serialNumber + ", isSelect=" + isSelect + ", adImg=" + adImg + ", isMainEditor=" + isMainEditor
+ ", mainEditorName=" + mainEditorName + ", mainEditorPic=" + mainEditorPic + ", isHaveAdviser="
+ isHaveAdviser + ", isFundSupport=" + isFundSupport + ", isHaveFund=" + isHaveFund + ", bookScanCount="
+ bookScanCount + ", bookQrCount=" + bookQrCount + ", readerCount=" + readerCount + ", bookIncome="
+ bookIncome + ", fundMoney=" + fundMoney + ", bookFunds=" + bookFunds + ", agentType=" + agentType
+ ", startTime=" + startTime + ", endTime=" + endTime + ", sceneId=" + sceneId + ", templeParentId="
+ templeParentId + ", templetId=" + templetId + ", templetName=" + templetName + ", browseCounts="
+ browseCounts + ", browserCounts=" + browserCounts + ", scanCount=" + scanCount + ", FreezeStatus="
+ FreezeStatus + ", income=" + income + ", bookAdviserId=" + bookAdviserId + ", relationQrcode="
+ relationQrcode + "]";
return "BookDto{" +
"bookId=" + bookId +
", typeCode='" + typeCode + '\'' +
", typeName='" + typeName + '\'' +
", isbn='" + isbn + '\'' +
", bookName='" + bookName + '\'' +
", bookPrice='" + bookPrice + '\'' +
", originName='" + originName + '\'' +
", remark='" + remark + '\'' +
", author='" + author + '\'' +
", publish='" + publish + '\'' +
", publishDate=" + publishDate +
", coverImg='" + coverImg + '\'' +
", detail='" + detail + '\'' +
", sponsor='" + sponsor + '\'' +
", organizer='" + organizer + '\'' +
", cn='" + cn + '\'' +
", releaseCycle='" + releaseCycle + '\'' +
", bookNum='" + bookNum + '\'' +
", programa='" + programa + '\'' +
", mailCode='" + mailCode + '\'' +
", address='" + address + '\'' +
", telephone='" + telephone + '\'' +
", mail='" + mail + '\'' +
", purpose='" + purpose + '\'' +
", adviserId=" + adviserId +
", adviserName='" + adviserName + '\'' +
", channelId=" + channelId +
", channelName='" + channelName + '\'' +
", qrcodeCount=" + qrcodeCount +
", appCount=" + appCount +
", productCount=" + productCount +
", latestQrcode='" + latestQrcode + '\'' +
", apps=" + apps +
", products=" + products +
", resourceFiles=" + resourceFiles +
", firstScanDate=" + firstScanDate +
", firstSceneName='" + firstSceneName + '\'' +
", issn='" + issn + '\'' +
", appId=" + appId +
", serialNumber='" + serialNumber + '\'' +
", isSelect=" + isSelect +
", adImg='" + adImg + '\'' +
", isMainEditor=" + isMainEditor +
", mainEditorName='" + mainEditorName + '\'' +
", mainEditorPic='" + mainEditorPic + '\'' +
", isHaveAdviser=" + isHaveAdviser +
", isFundSupport=" + isFundSupport +
", isHaveFund=" + isHaveFund +
", bookScanCount=" + bookScanCount +
", bookQrCount=" + bookQrCount +
", readerCount=" + readerCount +
", bookIncome=" + bookIncome +
", fundMoney=" + fundMoney +
", bookFunds=" + bookFunds +
", agentType=" + agentType +
", startTime=" + startTime +
", endTime=" + endTime +
", sceneId=" + sceneId +
", templeParentId=" + templeParentId +
", templetId=" + templetId +
", templetName='" + templetName + '\'' +
", browseCounts=" + browseCounts +
", browserCounts=" + browserCounts +
", scanCount=" + scanCount +
", FreezeStatus=" + FreezeStatus +
", income=" + income +
", bookAdviserId=" + bookAdviserId +
", relationQrcode=" + relationQrcode +
", noAuditNum=" + noAuditNum +
", transferor='" + transferor + '\'' +
", qrcodeUrl='" + qrcodeUrl + '\'' +
", messageCount=" + messageCount +
", typeCodeNames=" + typeCodeNames +
", location='" + location + '\'' +
", sceneName='" + sceneName + '\'' +
", qrRemark='" + qrRemark + '\'' +
", bookStatus=" + bookStatus +
'}';
}
}
......@@ -136,7 +136,8 @@ public interface BookFacade {
@ApiImplicitParam(name = "isMainEditor", value = "只看我是主编辑", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "isFundSupport", value = "只看基金支持", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "bookId", value = "书籍标识", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "templetId", value = "图书类型标识", dataType = "long", paramType = "query")})
@ApiImplicitParam(name = "templetId", value = "图书类型标识", dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "bookStatus", value = "图书版权保护状态", dataType = "Integer", paramType = "query")})
@RequestMapping(value = "listPage4Adviser", method = RequestMethod.GET)
ResponseDto<PageBean> getListPage4Adviser(@RequestHeader("token") String token,
@RequestParam(value = "name", required = false) String name,
......@@ -149,7 +150,8 @@ public interface BookFacade {
@RequestParam(value = "isMainEditor", required = false) Integer isMainEditor,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "templetId", required = false) Long templetId)
@RequestParam(value = "templetId", required = false) Long templetId,
@RequestParam(value = "bookStatus", required = false) Integer bookStatus)
throws BizException, PermissionException;
@ApiOperation(value = "首页获取正在做的图书", httpMethod = "GET")
......
......@@ -252,7 +252,8 @@ public class BookFacadeImpl implements BookFacade {
@RequestParam(value = "isMainEditor", required = false) Integer isMainEditor,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "templetId", required = false) Long templetId)
@RequestParam(value = "templetId", required = false) Long templetId,
@RequestParam(value = "bookStatus", required = false) Integer bookStatus)
throws BizException, PermissionException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage < 0) {
......@@ -269,6 +270,7 @@ public class BookFacadeImpl implements BookFacade {
paramMap.put("typeCode", typeCode != null && "".equals(typeCode.trim()) ? null : typeCode);
paramMap.put("bookId", bookId);
paramMap.put("templetId", templetId);
paramMap.put("bookStatus", bookStatus);
PageBean pageBean = bookBiz.getListPage4Adviser(paramMap, new PageParam(currentPage, numPerPage), adviserId);
return new ResponseDto<>(pageBean);
}
......
......@@ -92,8 +92,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
@Autowired
private ExportConsr exportConsr;
private static final ExecutorService EXECUTOR_SINGLE_SERVICE = Executors.newSingleThreadExecutor();
private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(2);
@Override
@Transactional(rollbackFor = Exception.class)
public void setBookAuthOpen(SetAuthOpenParam setAuthOpenParam, Long adviserId) {
......@@ -124,7 +123,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
@ParamLog("异步导出")
private void asynExport(Long bookId, Long channelId, Long adviserId, Integer codeCount) {
EXECUTOR_SINGLE_SERVICE.execute(() -> {
EXECUTOR_SERVICE.execute(() -> {
String commitTime = DateUtils.formatDate(new Date());
try {
if(codeCount == null || codeCount == 0) {
......@@ -152,11 +151,12 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
bookAuthCodeBiz.insert(bookAuthCodes);
String url = generateExcel(bookAuthCodes, bookDto.getBookName());
String zipUrl = CopyrightTools.generateBar4Zip(bookAuthCodes, bookDto.getBookName(), url);
//发送站内信
sendLetter(adviserId, bookDto.getBookName(), url, commitTime);
sendLetter(adviserId, bookDto.getBookName(), zipUrl, commitTime);
//新增导出记录
insertExportRecord(bookId, channelId, adviserId, num, url);
LOGGER.info("url" + url);
insertExportRecord(bookId, channelId, adviserId, num, zipUrl);
LOGGER.info("url" + zipUrl);
} catch (Exception e) {
LOGGER.error("导出条形码失败" + e.getMessage(), e);
}
......
package com.pcloud.book.copyright.tools;
import com.pcloud.book.BookApplication;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.copyright.dto.DateDTO;
import com.pcloud.channelcenter.base.constants.ChannelConstants;
import com.pcloud.book.copyright.entity.BookAuthCode;
import com.pcloud.common.constant.OSConstant;
import com.pcloud.common.entity.UploadResultInfo;
import com.pcloud.common.enums.ImageTypeEnum;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.exceptions.FileException;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.FileUtils;
import com.pcloud.common.utils.LocalDateUtils;
import com.pcloud.common.utils.UUIDUitl;
import com.pcloud.common.utils.aliyun.OssUtils;
import com.pcloud.common.utils.zip.CompressUtils;
import org.jbarcode.JBarcode;
import org.jbarcode.encode.Code128Encoder;
import org.jbarcode.paint.BaseLineTextPainter;
import org.jbarcode.paint.EAN13TextPainter;
import org.jbarcode.paint.WidthCodedPainter;
import org.springframework.boot.SpringApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -38,7 +44,9 @@ import java.util.UUID;
*/
@Component("copyrightTools")
public class CopyrightTools {
private static final Logger LOGGER = LoggerFactory.getLogger(CopyrightTools.class);
private static String ZIP_FILE_PATH = OSConstant.USERDIR + "/zip/";
private static String FILE_LOCAL_PATH = OSConstant.USERDIR + "/download/";
private static String[] chars = new String[]{"a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
......@@ -100,13 +108,52 @@ public class CopyrightTools {
}
}
public static String generateBar4Zip(List<BookAuthCode> bookAuthCodes, String fileName, String excelUrl) {
fileName = FileUtils.formatName(fileName);
String tempZipName = fileName + "_" + LocalDateUtils.getYmdhmss();
String zipFilePath = ZIP_FILE_PATH + tempZipName + ".zip";
String fileFolderPath = FILE_LOCAL_PATH + tempZipName;
FileUtils.isDir(fileFolderPath);
UploadResultInfo uploadResultInfo = null;
try {
for (BookAuthCode bookAuthCode : bookAuthCodes) {
BufferedImage bi = null;
JBarcode productBarcode = new JBarcode(Code128Encoder.getInstance(), WidthCodedPainter.getInstance(), EAN13TextPainter.getInstance());
productBarcode.setXDimension(Double.valueOf(0.5));
productBarcode.setBarHeight(Double.valueOf(30));
productBarcode.setWideRatio(Double.valueOf(30.0D));
productBarcode.setShowText(true);
productBarcode.setTextPainter(BaseLineTextPainter.getInstance());
bi = productBarcode.createBarcode(bookAuthCode.getFullCode());
paintText(bi, bookAuthCode.getFullCode());
File file = new File(fileFolderPath + "/" + bookAuthCode.getFullCode() + ".png");
ImageIO.write(bi, ImageTypeEnum.PNG.value, file);
}
String downloadLocalPath = fileFolderPath + "/" + fileName + ".xls";
FileUtils.downloadFileFromUrl(excelUrl, downloadLocalPath);
// 检查压缩包临时文件夹是否存在,不存在就创建
FileUtils.isDir(ZIP_FILE_PATH);
CompressUtils.zip(fileFolderPath, zipFilePath);
// 上传文件到服务器中
uploadResultInfo = OssUtils.uploadLocalFile4CustomName(zipFilePath, fileName);
} catch (Exception e) {
LOGGER.error("【压缩】压缩失败,<ERROR>:" + e.getMessage(), e);
throw new FileException(FileException.ZIP_ERROR, "压缩失败!");
} finally {
// 删除产生的文件
FileUtils.deleteDirectory(fileFolderPath);
FileUtils.deleteFile(zipFilePath);
}
return uploadResultInfo == null ? null : uploadResultInfo.getUrl();
}
public static String uploadImage(BufferedImage image) throws BizException {
UploadResultInfo uploadResultInfo = null;
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, ImageTypeEnum.JPG.value, os);
uploadResultInfo = OssUtils.uploadFileByte(os.toByteArray(), UUIDUitl.taskName(), ImageTypeEnum.JPG.value);
ImageIO.write(image, ImageTypeEnum.PNG.value, os);
uploadResultInfo = OssUtils.uploadFileByte(os.toByteArray(), UUIDUitl.taskName(), ImageTypeEnum.PNG.value);
os.close();
return uploadResultInfo == null ? null : uploadResultInfo.getUrl();
} catch (Exception e) {
......@@ -137,11 +184,26 @@ public class CopyrightTools {
List<String> last6Months = new ArrayList<>(6);
Calendar cal = Calendar.getInstance();
for (int i = 1; i < 7; i++) {
last6Months.add(cal.get(Calendar.YEAR) + "-" + df.format(cal.get(Calendar.MONTH)+1)) ;
last6Months.add(cal.get(Calendar.YEAR) + "-" + df.format(cal.get(Calendar.MONTH) + 1));
// 逐次往前推1个月
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1);
}
return last6Months;
}
public static void paintText(BufferedImage barCodeImage, String text) {
//绘图
Graphics g2d = barCodeImage.getGraphics();
//创建字体
Font font = new Font("console", Font.PLAIN, 15 );
g2d.setFont(font);
FontMetrics fm = g2d.getFontMetrics();
int height = fm.getHeight();
int center = (barCodeImage.getWidth() - fm.stringWidth(text)) / 2;
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, barCodeImage.getWidth(), barCodeImage.getHeight() * 1 / 20);
g2d.fillRect(0, barCodeImage.getHeight() - (height * 9 / 10), barCodeImage.getWidth(), (height * 9 / 10));
g2d.setColor(Color.BLACK);
g2d.drawString(text, center, barCodeImage.getHeight() - (height / 10) - 2);
}
}
......@@ -47,6 +47,7 @@
<result column="END_TIME" property="endTime" jdbcType="TIMESTAMP" />
<result column="TEMPLET_ID" property="templetId" jdbcType="BIGINT" />
<result column="IS_DELETE" property="isDelete" jdbcType="BIT" />
<result column="BOOK_STATUS" property="bookStatus" jdbcType="BIT" />
<result column="LAST_MODIFIED_DATE" property="lastModifiedDate" jdbcType="TIMESTAMP" />
<result column="BOOK_ADVISER_ID" property="bookAdviserId" jdbcType="BIGINT" />
</resultMap>
......@@ -445,21 +446,13 @@
SELECT
A.BOOK_ID, A.CHANNEL_ID, A.ADVISER_ID, A.IS_MAIN_EDITOR, T.TYPE_CODE, T.TYPE_NAME, B.ISBN, B.BOOK_NAME, B.REMARK,
B.AUTHOR, B.PUBLISH, B.PUBLISH_DATE, B.COVER_IMG, B.ORIGIN_NAME, B.BOOK_PRICE, B.ISSN, B.BOOK_NUM, B.SERIAL_NUMBER,
IF(ISNULL(BF.BOOK_FUND_ID),0,1) IS_FUND_SUPPORT,A.TEMPLET_ID, A.LAST_MODIFIED_DATE, A.BOOK_ADVISER_ID
IF(ISNULL(BF.BOOK_FUND_ID),0,1) IS_FUND_SUPPORT,A.TEMPLET_ID, A.LAST_MODIFIED_DATE, A.BOOK_ADVISER_ID,I.BOOK_STATUS
FROM
BOOK_ADVISER A
INNER JOIN
BOOK B
ON
A.BOOK_ID = B.BOOK_ID AND A.ADVISER_ID = #{adviserId} AND A.IS_DELETE = 0 AND B.IS_DELETE = 0
LEFT JOIN
BOOK_TYPE T
ON
B.TYPE_CODE = T.TYPE_CODE
LEFT JOIN
BOOK_FUND BF
ON
BF.BOOK_ID = A.BOOK_ID AND BF.END_TIME <![CDATA[ > ]]> NOW() AND BF.START_TIME <![CDATA[ < ]]> NOW()
INNER JOIN BOOK B ON A.BOOK_ID = B.BOOK_ID AND A.ADVISER_ID = #{adviserId} AND A.IS_DELETE = 0 AND B.IS_DELETE = 0
LEFT JOIN BOOK_TYPE T ON B.TYPE_CODE = T.TYPE_CODE
LEFT JOIN BOOK_FUND BF ON BF.BOOK_ID = A.BOOK_ID AND BF.END_TIME <![CDATA[ > ]]> NOW() AND BF.START_TIME <![CDATA[ < ]]> NOW()
LEFT JOIN book_auth_info I ON I.BOOK_ID = A.BOOK_ID AND I.ADVISER_ID = #{adviserId}
WHERE
1=1
<if test="bookId!=null">
......@@ -505,6 +498,10 @@
AND
B.ISBN <![CDATA[ <> ]]> ${isbns}
</if>
<if test="bookStatus != null">
AND
I.book_status = #{bookStatus}
</if>
GROUP BY A.BOOK_ID, A.CHANNEL_ID
ORDER BY
A.LAST_MODIFIED_DATE DESC
......
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