Commit 48872986 authored by 赵啸非's avatar 赵啸非

添加样表皮肤管理

parent 723ce08e
......@@ -8,6 +8,7 @@ import com.mortals.framework.util.DateUtils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
......@@ -19,7 +20,7 @@ import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@CommonsLog
@Slf4j
public class WordUtil {
private Configuration configure = null;
......@@ -71,7 +72,7 @@ public class WordUtil {
public static String convertWordToJPEG(String inputFile, String jpegPath) {
try {
System.out.println(String.format("文件转换开始:%s", DateUtils.getCurrStrDateTime()));
log.info(String.format("文件转换开始:%s", DateUtils.getCurrStrDateTime()));
// 转换开始前时间
long old = System.currentTimeMillis();
// 新建的PDF文件路径
......@@ -82,9 +83,6 @@ public class WordUtil {
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换
//doc.save(os, SaveFormat.JPEG);
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);
options.setPrettyFormat(true);
options.setUseAntiAliasing(true);
......@@ -106,7 +104,7 @@ public class WordUtil {
// 转换结束后时间
long now = System.currentTimeMillis();
//os.close();
System.out.println("文件转换结束,共耗时:" + ((now - old) / 1000.0) + "秒");
log.info("文件转换结束,共耗时:" + ((now - old) / 1000.0) + "秒");
return jpegPath;
} catch (Exception e) {
e.printStackTrace();
......
......@@ -61,6 +61,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
......@@ -165,6 +166,29 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
private String genPreviewPath(String rootPath, String prePath, String tempPath) {
//生成样表预览图片
String samplePath = rootPath + tempPath;
//todo 由于分布式 生成预览图片 需判断当前文件是否已经同步到本节点上
boolean exist = FileUtil.exist(samplePath);
int count = 0;
if (!exist) {
while (true) {
try {
Thread.sleep(2000);
boolean bool = FileUtil.exist(samplePath);
if (bool) {
break;
}
} catch (InterruptedException e) {
log.error("中断异常!");
}
count++;
if (count > 3) {
break;
}
}
}
String filePath = rootPath + prePath;
File pathDir = new File(filePath);
if (!pathDir.exists()) {
......@@ -176,11 +200,11 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
String extName = FileUtil.getSuffix(samplePath);
if (this.isExsitArry(extName, word)) {
WordUtil.convertWordToJPEG(samplePath, filePathAll);
}else if(this.isExsitArry(extName, pdf)){
WordUtil.pdfToImages(samplePath,filePathAll);
}else if(this.isExsitArry(extName,imgs)){
} else if (this.isExsitArry(extName, pdf)) {
WordUtil.pdfToImages(samplePath, filePathAll);
} else if (this.isExsitArry(extName, imgs)) {
try {
com.mortals.framework.util.FileUtil.copyFile(samplePath,filePathAll);
com.mortals.framework.util.FileUtil.copyFile(samplePath, filePathAll);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
......
......@@ -26,9 +26,6 @@ import com.mortals.xhx.module.skin.service.SkinService;
@Slf4j
public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity, Long> implements SkinService {
@Autowired
private IDeviceMessageFeign deviceMessageFeign;
@Override
protected void updateBefore(SkinEntity entity, Context context) throws AppException {
......@@ -45,16 +42,4 @@ public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity
}
}
@Override
protected void updateAfter(SkinEntity entity, Context context) throws AppException {
//推送皮肤更新消息
DeviceMsgReqPdu deviceMsgReqPdu = new DeviceMsgReqPdu();
deviceMsgReqPdu.setSiteid(entity.getSiteId());
deviceMsgReqPdu.setProductCode("ybj");
deviceMsgReqPdu.setMessageType("edition");
deviceMsgReqPdu.setData("W10=");
deviceMsgReqPdu.setTimestamp(System.currentTimeMillis());
Rest<String> rest = deviceMessageFeign.callbackByProduct(deviceMsgReqPdu);
log.info("send device message==>{}", JSON.toJSONString(rest));
}
}
\ No newline at end of file
package com.mortals.xhx.module.skin.web;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.pdu.device.DeviceMsgReqPdu;
import com.mortals.xhx.feign.device.IDeviceMessageFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -31,11 +37,15 @@ import static com.mortals.framework.ap.SysConstains.*;
*/
@RestController
@RequestMapping("skin")
@Slf4j
public class SkinController extends BaseCRUDJsonBodyMappingController<SkinService,SkinEntity,Long> {
@Autowired
private ParamService paramService;
@Autowired
private IDeviceMessageFeign deviceMessageFeign;
public SkinController(){
super.setModuleDesc( "皮肤");
}
......@@ -47,5 +57,18 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic
super.init(model, context);
}
@Override
protected int saveAfter(SkinEntity entity, Map<String, Object> model, Context context) throws AppException {
//推送皮肤更新消息
DeviceMsgReqPdu deviceMsgReqPdu = new DeviceMsgReqPdu();
deviceMsgReqPdu.setSiteid(entity.getSiteId());
deviceMsgReqPdu.setProductCode("tdj");
deviceMsgReqPdu.setMessageType("edition");
deviceMsgReqPdu.setData("W10=");
deviceMsgReqPdu.setTimestamp(System.currentTimeMillis());
Rest<String> rest = deviceMessageFeign.callbackByProduct(deviceMsgReqPdu);
log.info("send device message==>{}", JSON.toJSONString(rest));
return super.saveAfter(entity, model, context);
}
}
\ 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