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

添加样表皮肤管理

parent 723ce08e
...@@ -8,6 +8,7 @@ import com.mortals.framework.util.DateUtils; ...@@ -8,6 +8,7 @@ import com.mortals.framework.util.DateUtils;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import lombok.extern.apachecommons.CommonsLog; import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer; import org.apache.pdfbox.rendering.PDFRenderer;
...@@ -19,7 +20,7 @@ import java.io.*; ...@@ -19,7 +20,7 @@ import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@CommonsLog @Slf4j
public class WordUtil { public class WordUtil {
private Configuration configure = null; private Configuration configure = null;
...@@ -71,7 +72,7 @@ public class WordUtil { ...@@ -71,7 +72,7 @@ public class WordUtil {
public static String convertWordToJPEG(String inputFile, String jpegPath) { public static String convertWordToJPEG(String inputFile, String jpegPath) {
try { try {
System.out.println(String.format("文件转换开始:%s", DateUtils.getCurrStrDateTime())); log.info(String.format("文件转换开始:%s", DateUtils.getCurrStrDateTime()));
// 转换开始前时间 // 转换开始前时间
long old = System.currentTimeMillis(); long old = System.currentTimeMillis();
// 新建的PDF文件路径 // 新建的PDF文件路径
...@@ -82,9 +83,6 @@ public class WordUtil { ...@@ -82,9 +83,6 @@ public class WordUtil {
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换 // 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换
//doc.save(os, SaveFormat.JPEG); //doc.save(os, SaveFormat.JPEG);
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG); ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);
options.setPrettyFormat(true); options.setPrettyFormat(true);
options.setUseAntiAliasing(true); options.setUseAntiAliasing(true);
...@@ -106,7 +104,7 @@ public class WordUtil { ...@@ -106,7 +104,7 @@ public class WordUtil {
// 转换结束后时间 // 转换结束后时间
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
//os.close(); //os.close();
System.out.println("文件转换结束,共耗时:" + ((now - old) / 1000.0) + "秒"); log.info("文件转换结束,共耗时:" + ((now - old) / 1000.0) + "秒");
return jpegPath; return jpegPath;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -61,6 +61,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -61,6 +61,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -165,6 +166,29 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD ...@@ -165,6 +166,29 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
private String genPreviewPath(String rootPath, String prePath, String tempPath) { private String genPreviewPath(String rootPath, String prePath, String tempPath) {
//生成样表预览图片 //生成样表预览图片
String samplePath = rootPath + 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; String filePath = rootPath + prePath;
File pathDir = new File(filePath); File pathDir = new File(filePath);
if (!pathDir.exists()) { if (!pathDir.exists()) {
...@@ -176,11 +200,11 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD ...@@ -176,11 +200,11 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
String extName = FileUtil.getSuffix(samplePath); String extName = FileUtil.getSuffix(samplePath);
if (this.isExsitArry(extName, word)) { if (this.isExsitArry(extName, word)) {
WordUtil.convertWordToJPEG(samplePath, filePathAll); WordUtil.convertWordToJPEG(samplePath, filePathAll);
}else if(this.isExsitArry(extName, pdf)){ } else if (this.isExsitArry(extName, pdf)) {
WordUtil.pdfToImages(samplePath,filePathAll); WordUtil.pdfToImages(samplePath, filePathAll);
}else if(this.isExsitArry(extName,imgs)){ } else if (this.isExsitArry(extName, imgs)) {
try { try {
com.mortals.framework.util.FileUtil.copyFile(samplePath,filePathAll); com.mortals.framework.util.FileUtil.copyFile(samplePath, filePathAll);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
......
...@@ -26,9 +26,6 @@ import com.mortals.xhx.module.skin.service.SkinService; ...@@ -26,9 +26,6 @@ import com.mortals.xhx.module.skin.service.SkinService;
@Slf4j @Slf4j
public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity, Long> implements SkinService { public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity, Long> implements SkinService {
@Autowired
private IDeviceMessageFeign deviceMessageFeign;
@Override @Override
protected void updateBefore(SkinEntity entity, Context context) throws AppException { protected void updateBefore(SkinEntity entity, Context context) throws AppException {
...@@ -45,16 +42,4 @@ public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity ...@@ -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; 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.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -31,11 +37,15 @@ import static com.mortals.framework.ap.SysConstains.*; ...@@ -31,11 +37,15 @@ import static com.mortals.framework.ap.SysConstains.*;
*/ */
@RestController @RestController
@RequestMapping("skin") @RequestMapping("skin")
@Slf4j
public class SkinController extends BaseCRUDJsonBodyMappingController<SkinService,SkinEntity,Long> { public class SkinController extends BaseCRUDJsonBodyMappingController<SkinService,SkinEntity,Long> {
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private IDeviceMessageFeign deviceMessageFeign;
public SkinController(){ public SkinController(){
super.setModuleDesc( "皮肤"); super.setModuleDesc( "皮肤");
} }
...@@ -47,5 +57,18 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic ...@@ -47,5 +57,18 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic
super.init(model, context); 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