Commit 342fa36d authored by “yiyousong”'s avatar “yiyousong”
parents 0c73ae16 48872986
...@@ -13,6 +13,7 @@ import com.mortals.framework.model.Result; ...@@ -13,6 +13,7 @@ import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.framework.service.IUser; import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.menu.model.MenuEntity; import com.mortals.xhx.base.system.menu.model.MenuEntity;
import com.mortals.xhx.base.system.user.dao.UserDao;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import java.util.List; import java.util.List;
...@@ -112,4 +113,8 @@ public interface UserService extends ICRUDService<UserEntity,Long> { ...@@ -112,4 +113,8 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @throws AppException * @throws AppException
*/ */
public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException; public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
UserDao getUserDao();
} }
\ No newline at end of file
...@@ -330,4 +330,9 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -330,4 +330,9 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
dao.update(sysUser); dao.update(sysUser);
return true; return true;
} }
@Override
public UserDao getUserDao() {
return this.getDao();
}
} }
\ No newline at end of file
...@@ -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();
......
...@@ -77,6 +77,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -77,6 +77,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
log.info("站点名称:{}",site.getSiteName()); log.info("站点名称:{}",site.getSiteName());
DevicePdu devicePdu = new DevicePdu(); DevicePdu devicePdu = new DevicePdu();
devicePdu.setProductCode("ybj"); devicePdu.setProductCode("ybj");
devicePdu.setSiteId(site.getId());
devicePdu.setSize(-1); devicePdu.setSize(-1);
Rest<RespData<List<DevicePdu>>> deviceRest = deviceFeign.list(devicePdu); Rest<RespData<List<DevicePdu>>> deviceRest = deviceFeign.list(devicePdu);
log.info("deviceRest:{}",JSON.toJSONString(deviceRest)); log.info("deviceRest:{}",JSON.toJSONString(deviceRest));
...@@ -92,9 +93,13 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -92,9 +93,13 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
List<DeviceEntity> oldDeviceList = deviceService.find(new DeviceQuery().siteId(site.getId())); List<DeviceEntity> oldDeviceList = deviceService.find(new DeviceQuery().siteId(site.getId()));
log.info("siteId:{} oldDeviceList size:{}",site.getId(), oldDeviceList.size());
Map<String, DeviceEntity> oldDeviceMap = oldDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n)); Map<String, DeviceEntity> oldDeviceMap = oldDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n));
Map<String, DeviceEntity> newDeviceMap = newDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n)); Map<String, DeviceEntity> newDeviceMap = newDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n));
//log.info("oldDeviceMap:{}", JSON.toJSONString(oldDeviceMap));
List<DeviceEntity> updateDeviceLsit = newDeviceList.stream().map(item -> { List<DeviceEntity> updateDeviceLsit = newDeviceList.stream().map(item -> {
if (oldDeviceMap.containsKey(item.getDeviceCode())) { if (oldDeviceMap.containsKey(item.getDeviceCode())) {
item.setId(oldDeviceMap.get(item.getDeviceCode()).getId()); item.setId(oldDeviceMap.get(item.getDeviceCode()).getId());
...@@ -108,6 +113,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -108,6 +113,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
List<DeviceEntity> saveDeviceList = newDeviceList.stream().map(item -> { List<DeviceEntity> saveDeviceList = newDeviceList.stream().map(item -> {
//log.info("deviceCode:{},oldDeviceMap:{}",item.getDeviceCode(),oldDeviceMap.containsKey(item.getDeviceCode()));
if (!oldDeviceMap.containsKey(item.getDeviceCode())) { if (!oldDeviceMap.containsKey(item.getDeviceCode())) {
item.setDeviceId(item.getId()); item.setDeviceId(item.getId());
item.setCreateUserId(1L); item.setCreateUserId(1L);
...@@ -128,7 +134,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -128,7 +134,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
if (!ObjectUtils.isEmpty(updateDeviceLsit)) { if (!ObjectUtils.isEmpty(updateDeviceLsit)) {
log.info("设备更新,size:{}", updateDeviceLsit.size()); log.info("设备更新,size:{}", updateDeviceLsit.size());
deviceService.update(updateDeviceLsit); // deviceService.update(updateDeviceLsit);
} }
if (!ObjectUtils.isEmpty(saveDeviceList)) { if (!ObjectUtils.isEmpty(saveDeviceList)) {
...@@ -172,8 +178,6 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -172,8 +178,6 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
Map<Long, SkinEntity> oldSkinMap = oldSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n)); Map<Long, SkinEntity> oldSkinMap = oldSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
Map<Long, SkinEntity> newSkinMap = newSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n)); Map<Long, SkinEntity> newSkinMap = newSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
List<SkinEntity> updateSkinLsit = newSkinList.stream().map(item -> { List<SkinEntity> updateSkinLsit = newSkinList.stream().map(item -> {
if (oldSkinMap.containsKey(item.getId())) { if (oldSkinMap.containsKey(item.getId())) {
item.setUsed(oldSkinMap.get(item.getId()).getUsed()); item.setUsed(oldSkinMap.get(item.getId()).getUsed());
...@@ -203,10 +207,10 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -203,10 +207,10 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(updateSkinLsit)) { // if (!ObjectUtils.isEmpty(updateSkinLsit)) {
log.info("皮肤更新,size:{}", updateSkinLsit.size()); // log.info("皮肤更新,size:{}", updateSkinLsit.size());
skinService.update(updateSkinLsit); // skinService.update(updateSkinLsit);
} // }
if (!ObjectUtils.isEmpty(saveSkinList)) { if (!ObjectUtils.isEmpty(saveSkinList)) {
log.info("皮肤新增,size:{}", saveSkinList.size()); log.info("皮肤新增,size:{}", saveSkinList.size());
......
...@@ -51,6 +51,7 @@ public class SyncSiteMatterTaskImpl implements ITaskExcuteService { ...@@ -51,6 +51,7 @@ public class SyncSiteMatterTaskImpl implements ITaskExcuteService {
int pageNum=100; int pageNum=100;
for(int i=1;i<=page;i++){ for(int i=1;i<=page;i++){
SiteMatterPdu siteMatterPdu = new SiteMatterPdu(); SiteMatterPdu siteMatterPdu = new SiteMatterPdu();
siteMatterPdu.setSiteId(site.getId());
siteMatterPdu.setPage(i); siteMatterPdu.setPage(i);
siteMatterPdu.setSize(pageNum); siteMatterPdu.setSize(pageNum);
log.info("请求列表:"+i); log.info("请求列表:"+i);
......
package com.mortals.xhx.daemon.task;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.List;
/**
* 同步用户,唯一标识为用户名。
*/
@Slf4j
@Service("SyncUserTask")
@ConditionalOnExpression("'${platform.type:null}'=='cloud'")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private IUserFeign userFeign;
@Autowired
private UserService userService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步用户任务");
UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> resp = userFeign.list(userPdu);
if (resp.getCode() == YesNoEnum.YES.getValue()) {
//同步更新用户,以loginname为唯一标识,密码默认与用户相同
resp.getData().getData().forEach(user -> {
log.info("loginName:{}", user.getLoginName());
UserEntity tempEntity = userService.selectOne(new UserQuery().loginName(user.getLoginName()));
if (ObjectUtils.isEmpty(tempEntity)) {
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(user, userEntity, new String[]{"id","lastLoginTime", "lastLoginAddress"});
log.info("新增:{}", JSON.toJSONString(userEntity));
userService.getUserDao().insert(userEntity);
}else {
//更新基本信息
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(user, userEntity, new String[]{"loginPwd","userType","status","lastLoginTime", "lastLoginAddress"});
log.info("更新:{}", JSON.toJSONString(userEntity));
userService.getUserDao().update(userEntity);
}
});
}
// log.info("syncUserResp:{}", JSON.toJSONString(resp));
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.module.device.service.impl; package com.mortals.xhx.module.device.service.impl;
import com.mortals.xhx.module.matter.service.MatterDatumService;
import com.mortals.xhx.module.matter.service.MatterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.device.dao.DeviceDao; import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import org.springframework.stereotype.Service;
/** /**
* DeviceService * DeviceService
* 设备 service实现 * 设备 service实现
...@@ -19,13 +15,4 @@ import com.mortals.xhx.module.device.service.DeviceService; ...@@ -19,13 +15,4 @@ import com.mortals.xhx.module.device.service.DeviceService;
@Service("deviceService") @Service("deviceService")
public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService { public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService {
@Autowired
private MatterService matterService;
@Autowired
private MatterDatumService matterDatumService;
@Override
protected void saveBefore(DeviceEntity entity, Context context) throws AppException {
super.saveBefore(entity, context);
}
} }
\ No newline at end of file
...@@ -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);
} }
......
...@@ -6,8 +6,11 @@ import com.mortals.framework.model.OrderCol; ...@@ -6,8 +6,11 @@ import com.mortals.framework.model.OrderCol;
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.key.ParamKey; import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.sample.model.SampleBillEntity; import com.mortals.xhx.module.sample.model.SampleBillEntity;
import com.mortals.xhx.module.sample.service.SampleBillService; import com.mortals.xhx.module.sample.service.SampleBillService;
import org.apache.commons.lang3.ObjectUtils;
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;
...@@ -46,6 +49,8 @@ public class MatterDatumController extends BaseCRUDJsonBodyMappingController<Mat ...@@ -46,6 +49,8 @@ public class MatterDatumController extends BaseCRUDJsonBodyMappingController<Mat
private ParamService paramService; private ParamService paramService;
@Autowired @Autowired
private SampleBillService sampleBillService; private SampleBillService sampleBillService;
@Autowired
private MatterService matterService;
public MatterDatumController() { public MatterDatumController() {
super.setModuleDesc("事项申请材料"); super.setModuleDesc("事项申请材料");
...@@ -125,8 +130,13 @@ public class MatterDatumController extends BaseCRUDJsonBodyMappingController<Mat ...@@ -125,8 +130,13 @@ public class MatterDatumController extends BaseCRUDJsonBodyMappingController<Mat
sampleBillEntity.initAttrValue(); sampleBillEntity.initAttrValue();
sampleBillEntity.setSiteId(entity.getSiteId()); sampleBillEntity.setSiteId(entity.getSiteId());
sampleBillEntity.setMaterialName(entity.getMaterialName()); sampleBillEntity.setMaterialName(entity.getMaterialName());
sampleBillEntity.setMaterialFullName(entity.getMateriaFullName());
sampleBillEntity.setMatterName(entity.getMatterName()); if(!ObjectUtils.isEmpty(entity.getMatterId())){
MatterEntity matterEntity = matterService.get(entity.getMatterId());
sampleBillEntity.setMatterName(matterEntity.getMatterName());
sampleBillEntity.setMatterFullName(matterEntity.getMatterFullName());
}
sampleBillEntity.setMatterFullName(entity.getMatterName()); sampleBillEntity.setMatterFullName(entity.getMatterName());
sampleBillEntity.setOperTime(new Date()); sampleBillEntity.setOperTime(new Date());
sampleBillService.save(sampleBillEntity,context); sampleBillService.save(sampleBillEntity,context);
......
...@@ -235,6 +235,6 @@ public class SampleBillEntity extends SampleBillVo { ...@@ -235,6 +235,6 @@ public class SampleBillEntity extends SampleBillVo {
this.deviceName = ""; this.deviceName = "";
this.operTime = null; this.operTime = new Date();
} }
} }
\ No newline at end of file
package com.mortals.xhx.module.sample.web; package com.mortals.xhx.module.sample.web;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
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.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import org.apache.commons.lang3.ObjectUtils;
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;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.sample.model.SampleBillEntity; import com.mortals.xhx.module.sample.model.SampleBillEntity;
import com.mortals.xhx.module.sample.service.SampleBillService; import com.mortals.xhx.module.sample.service.SampleBillService;
...@@ -19,26 +26,31 @@ import com.mortals.framework.util.StringUtils; ...@@ -19,26 +26,31 @@ import com.mortals.framework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*; import static com.mortals.framework.ap.SysConstains.*;
/** /**
* * 样报服务
* 样报服务 *
* * @author zxfei
* @author zxfei * @date 2023-02-23
* @date 2023-02-23 */
*/
@RestController @RestController
@RequestMapping("sample/bill") @RequestMapping("sample/bill")
public class SampleBillController extends BaseCRUDJsonBodyMappingController<SampleBillService,SampleBillEntity,Long> { public class SampleBillController extends BaseCRUDJsonBodyMappingController<SampleBillService, SampleBillEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
public SampleBillController(){ @Autowired
super.setModuleDesc( "样报服务"); public DeviceService deviceService;
public SampleBillController() {
super.setModuleDesc("样报服务");
} }
@Override @Override
...@@ -57,7 +69,14 @@ public class SampleBillController extends BaseCRUDJsonBodyMappingController<Samp ...@@ -57,7 +69,14 @@ public class SampleBillController extends BaseCRUDJsonBodyMappingController<Samp
@Override @Override
@UnAuth @UnAuth
public String save(SampleBillEntity entity) { public String save(@RequestBody SampleBillEntity entity) {
if (ObjectUtils.isEmpty(entity.getDeviceName()) && !ObjectUtils.isEmpty(entity.getDeviceCode())) {
DeviceEntity deviceEntity = deviceService.selectOne(new DeviceQuery().deviceCode(entity.getDeviceCode()));
entity.setDeviceName(deviceEntity.getDeviceName());
}
entity.setMatterFullName(entity.getMaterialName());
entity.setMaterialFullName(entity.getMaterialFullName());
return super.save(entity); return super.save(entity);
} }
} }
\ No newline at end of file
...@@ -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,21 +42,4 @@ public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity ...@@ -45,21 +42,4 @@ public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity
} }
} }
@Override
protected void updateAfter(SkinEntity entity, Context context) throws AppException {
super.updateAfter(entity, context);
//推送皮肤更新消息
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