Commit 38f5d3fa authored by “yiyousong”'s avatar “yiyousong”
parents e93a2fca 6ae3e085
......@@ -86,10 +86,34 @@ public class DevicePdu extends BaseEntityLong {
*/
private Integer source;
/**
* 设备生产厂商ID
*/
private Long deviceFirmId;
/**
* 设备生产厂商名称
*/
private String deviceFirmname;
/**
* 设备访问ip
*/
private String ip;
/**
* 端口
*/
private String port;
/**
* 启用状态 (0.停止,1.启用)
*/
private Integer enabled;
/**
* 最近上线时间
*/
private Date onlineTime;
/**
* 最近离线时间
*/
private Date offlineTime;
public void initAttrValue(){
......
package com.mortals.xhx.common.pdu.product;
import lombok.Data;
/**
* 产品实体对象
*
* @author zxfei
* @date 2022-11-09
*/
@Data
public class ProductPdu {
/**
* id
*/
private Long id;
/**
* 关联平台
*/
private Long platformId;
/**
* 产品名称,名称唯一
*/
private String productName;
/**
* 产品编码
*/
private String productCode;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.device.DeviceReq;
import com.mortals.xhx.common.pdu.product.ProductPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
......@@ -74,6 +75,17 @@ public interface IDeviceFeign extends IFeign {
@PostMapping(value = "/api/receive")
Rest<String> deviceCall(@RequestBody DeviceReq deviceReq);
/**
* 查看设备列表
*
* @param productPdu
* @return
*/
@PostMapping(value = "/product/interlist")
Rest<RespData<List<ProductPdu>>> list(@RequestBody ProductPdu productPdu);
}
......@@ -107,6 +119,11 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
public Rest<String> deviceCall(DeviceReq deviceReq) {
return Rest.fail("暂时无法保存设备,请稍后再试!");
}
@Override
public Rest<RespData<List<ProductPdu>>> list(ProductPdu productPdu) {
return Rest.fail("请稍后再试!");
}
};
}
}
......
......@@ -64,4 +64,7 @@ ALTER TABLE mortals_xhx_device
ADD COLUMN `deviceInBuilding` tinyint(4) COMMENT '所属楼栋';
ALTER TABLE mortals_xhx_device
ADD COLUMN `deviceInFloor` tinyint(4) COMMENT '所属楼层';
\ No newline at end of file
ADD COLUMN `deviceInFloor` tinyint(4) COMMENT '所属楼层';
ALTER TABLE mortals_xhx_device
ADD COLUMN `resolution` varchar(64) COMMENT '分辨率';
......@@ -14,9 +14,18 @@
<packaging>jar</packaging>
<description>样表服务管理平台</description>
<properties>
<!-- 默认值 -->
<profiles.server.debug></profiles.server.debug>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.filepath>/mortals/app/data</profiles.filepath>
</properties>
<profiles>
<profile>
<id>develop</id>
......@@ -25,8 +34,6 @@
</activation>
<properties>
<profiles.active>develop</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
......@@ -38,8 +45,6 @@
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
......@@ -51,8 +56,6 @@
<id>product</id>
<properties>
<profiles.active>product</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>192.168.0.250:8848</profiles.nacos.server-addr>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
......@@ -65,8 +68,6 @@
<id>yibin</id>
<properties>
<profiles.active>yibin</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>172.15.28.120:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
......@@ -79,7 +80,6 @@
<id>xuanhan</id>
<properties>
<profiles.active>xuanhan</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>D:/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
......@@ -93,8 +93,6 @@
<id>yanyuan</id>
<properties>
<profiles.active>yanyuan</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
......@@ -107,8 +105,6 @@
<id>pengxi</id>
<properties>
<profiles.active>pengxi</profiles.active>
<profiles.server.port>17002</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.nacos.server-addr>192.168.106.6:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
......
#!/bin/sh
PORT="@profiles.server.port@"
DEBUG=@profiles.server.debug@
BASEDIR=`dirname $0`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
PROJECT_NAME="@project.artifactId@";
......@@ -55,12 +56,12 @@ cd "$BASEDIR/boot";
echo "starting application $PROJECT_NAME......"
exec "$JAVACMD" $JAVA_OPTS \
$DEBUG \
$EXTRA_JVM_ARGUMENTS \
-Dapp.name="$PROJECT_NAME" \
-Dapp.port="$PORT" \
-Dbasedir="$BASEDIR" \
-Djava.io.tmpdir=$TEMP_PATH \
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15689 \
-jar $MAIN_CLASS \
> /dev/null &
......
......@@ -10,6 +10,7 @@ import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.pdu.product.ProductPdu;
import com.mortals.xhx.common.pdu.site.SiteMatterPdu;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.skin.SkinBasePdu;
......@@ -72,17 +73,30 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}
private void syncDevice() {
Long productId = null;
ProductPdu productPdu = new ProductPdu();
productPdu.setProductCode("ybj");
Rest<RespData<List<ProductPdu>>> rest = deviceFeign.list(productPdu);
if (rest.getCode() == YesNoEnum.YES.getValue() && !ObjectUtils.isEmpty(rest.getData())) {
if (!ObjectUtils.isEmpty(rest.getData().getData())) {
ProductPdu pdu = rest.getData().getData().get(0);
productId = pdu.getId();
}
}
SitePdu sitePdu = new SitePdu();
sitePdu.setId(1L);
Rest<List<SitePdu>> siteRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if (siteRest.getCode() == YesNoEnum.YES.getValue()) {
log.info("站点总数量:{}", siteRest.getData().size());
siteRest.getData().forEach(site -> {
for (SitePdu site : siteRest.getData()) {
log.info("站点名称:{}", site.getSiteName());
DevicePdu devicePdu = new DevicePdu();
//devicePdu.setProductCode("ybj");
//devicePdu.setProductId(10L);
devicePdu.setProductName("样表机");
if (!ObjectUtils.isEmpty(productId)) {
devicePdu.setProductId(productId);
} else {
devicePdu.setProductName("样表机");
}
devicePdu.setSiteId(site.getId());
devicePdu.setSize(-1);
Rest<RespData<List<DevicePdu>>> deviceRest = deviceFeign.list(devicePdu);
......@@ -95,6 +109,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
DeviceEntity deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue();
BeanUtils.copyProperties(newDevice, deviceEntity, BeanUtil.getNullPropertyNames(newDevice));
deviceEntity.setDeviceId(newDevice.getId());
return deviceEntity;
}).collect(Collectors.toList());
......@@ -109,7 +124,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
List<DeviceEntity> updateDeviceLsit = newDeviceList.stream().map(item -> {
if (oldDeviceMap.containsKey(item.getDeviceCode())) {
item.setId(oldDeviceMap.get(item.getDeviceCode()).getId());
item.setDeviceId(item.getId());
// item.setDeviceId(item.getId());
item.setProductCode(oldDeviceMap.get(item.getDeviceCode()).getProductCode());
item.setProductName(oldDeviceMap.get(item.getDeviceCode()).getProductName());
item.setUpdateTime(new Date());
......@@ -121,7 +136,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
List<DeviceEntity> saveDeviceList = newDeviceList.stream().map(item -> {
//log.info("deviceCode:{},oldDeviceMap:{}",item.getDeviceCode(),oldDeviceMap.containsKey(item.getDeviceCode()));
if (!oldDeviceMap.containsKey(item.getDeviceCode())) {
item.setDeviceId(item.getId());
// item.setDeviceId(item.getId());
item.setCreateUserId(1L);
item.setProductName("样表机");
item.setCreateUserName("系统管理员");
......@@ -141,7 +156,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
if (!ObjectUtils.isEmpty(updateDeviceLsit)) {
log.info("设备更新,size:{}", updateDeviceLsit.size());
deviceService.update(updateDeviceLsit);
deviceService.update(updateDeviceLsit);
}
if (!ObjectUtils.isEmpty(saveDeviceList)) {
......@@ -157,84 +172,12 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
} else {
log.info("设备列表查询异常,{}", JSON.toJSONString(deviceRest));
}
});
}
} else {
log.info("站点列表查询异常,{}", JSON.toJSONString(siteRest));
}
}
/* private void syncSkin() {
SkinBasePdu skinBasePdu = new SkinBasePdu();
skinBasePdu.setProductName("样表机");
skinBasePdu.setSize(-1);
Rest<RespData<List<SkinBasePdu>>> skinBaseRest = skinBaseFeign.list(skinBasePdu);
if (skinBaseRest.getCode() == YesNoEnum.YES.getValue()) {
List<SkinBasePdu> skinBasePduList = skinBaseRest.getData().getData();
log.info("样表机皮肤总数量:{}", skinBasePduList.size());
if (!ObjectUtils.isEmpty(skinBasePduList)) {
List<SkinEntity> newSkinList = skinBasePduList.stream().map(newSkin -> {
SkinEntity skinEntity = new SkinEntity();
skinEntity.initAttrValue();
//存相对地址
newSkin.setCssFilePath("/"+StrUtil.subAfter(newSkin.getCssFilePath(), "/", true));
newSkin.setPreviewImagePath("/"+StrUtil.subAfter(newSkin.getPreviewImagePath(), "/", true));
BeanUtils.copyProperties(newSkin, skinEntity, BeanUtil.getNullPropertyNames(newSkin));
return skinEntity;
}).collect(Collectors.toList());
List<SkinEntity> oldSkinList = skinService.find(new SkinQuery());
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));
List<SkinEntity> updateSkinLsit = newSkinList.stream().map(item -> {
if (oldSkinMap.containsKey(item.getId())) {
item.setUsed(oldSkinMap.get(item.getId()).getUsed());
item.setUpdateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
List<SkinEntity> saveSkinList = newSkinList.stream().map(item -> {
if (!oldSkinMap.containsKey(item.getId())) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
item.setCreateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
//做差集
List<Long> delSkinList = oldSkinList.stream().map(item -> {
if (!newSkinMap.containsKey(item.getId())) {
return item.getId();
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
// if (!ObjectUtils.isEmpty(updateSkinLsit)) {
// log.info("皮肤更新,size:{}", updateSkinLsit.size());
// skinService.update(updateSkinLsit);
// }
if (!ObjectUtils.isEmpty(saveSkinList)) {
log.info("皮肤新增,size:{}", saveSkinList.size());
skinService.save(saveSkinList);
}
if (!ObjectUtils.isEmpty(delSkinList)) {
log.info("皮肤删除,size:{}", delSkinList.size());
skinService.remove(delSkinList, null);
}
}
}
}*/
@Override
public void stopTask(ITask task) throws AppException {
......
......@@ -160,7 +160,7 @@ public class DeviceEntity extends DeviceVo {
this.deviceFirmname = "";
this.ip = "";
this.port = "";
this.enabled = 0;
this.enabled = 1;
this.productCode = "";
this.productName = "";
this.deviceSrc = 2;
......
......@@ -28,5 +28,14 @@ public class MatterDatumVo extends BaseEntityLong {
private Integer pub;
/**
* 分类id
*/
private Long categoryId;
/**
* 分类名称
*/
private String categoryName;
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrSplitter;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.config.ConfigureBuilder;
import com.deepoove.poi.data.PictureRenderData;
import com.deepoove.poi.data.PictureType;
import com.deepoove.poi.data.Pictures;
import com.deepoove.poi.plugin.table.MultipleRowTableRenderPolicy;
import com.deepoove.poi.template.MetaTemplate;
import com.deepoove.poi.util.RegexUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.code.MatterSourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.formdesign.*;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.common.pdu.gen.component.ComponentCons;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.common.utils.ExportDocUtil;
import com.mortals.xhx.common.utils.WordUtil;
import com.mortals.xhx.module.matter.dao.MatterDao;
import com.mortals.xhx.module.datum.model.DatumCategoryEntity;
import com.mortals.xhx.module.datum.model.DatumCategoryQuery;
import com.mortals.xhx.module.datum.service.DatumCategoryService;
import com.mortals.xhx.module.matter.dao.MatterDatumDao;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
import com.mortals.xhx.module.matter.model.MatterDatumQuery;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterDatumService;
import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.pubdatum.model.PubdatumEntity;
import com.mortals.xhx.module.pubdatum.service.PubdatumService;
import com.mortals.xhx.module.sheet.model.SheetMatterEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.http.entity.ContentType;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.matter.dao.MatterDatumDao;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
import com.mortals.xhx.module.matter.service.MatterDatumService;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -80,6 +54,8 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
private MatterService matterService;
@Autowired
private PubdatumService pubdatumService;
@Autowired
private DatumCategoryService datumCategoryService;
public static String word[] = {"doc", "dot", "wps", "wpt", "docx", "dotx", "docm", "dotm"};
......@@ -289,7 +265,7 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
for (MatterEntity matterEntity : matterEntities) {
recommendCount += this.count(new MatterDatumQuery().matterId(matterEntity.getId()).isRecommend(YesNoEnum.YES.getValue()), context);
}
if (!ObjectUtils.isEmpty(matterDatumEntity.getIsRecommend() )&&matterDatumEntity.getIsRecommend() == YesNoEnum.NO.getValue()) {
if (!ObjectUtils.isEmpty(matterDatumEntity.getIsRecommend()) && matterDatumEntity.getIsRecommend() == YesNoEnum.NO.getValue()) {
if (recommendCount >= GlobalSysInfo.getParamIntValue(Constant.PARAMS_RECOMMEND_COUNT, 7)) {
throw new AppException("超过推荐个数!");
}
......@@ -304,11 +280,28 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
@Override
protected void findAfter(MatterDatumEntity params, PageInfo pageInfo, Context context, List<MatterDatumEntity> list) throws AppException {
List<Long> matterIdList = list.stream().map(item -> item.getMatterId()).collect(Collectors.toList());
MatterQuery matterQuery = new MatterQuery();
matterQuery.setIdList(matterIdList);
Map<Long, MatterEntity> matterEntityMap = matterService.find(matterQuery).stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
DatumCategoryQuery datumCategoryQuery = new DatumCategoryQuery();
datumCategoryQuery.setMaterialIdList(matterIdList);
Map<Long, DatumCategoryEntity> collect = datumCategoryService.find(datumCategoryQuery).stream().collect(Collectors.toMap(x -> x.getMaterialId(), y -> y, (o, n) -> n));
list.stream().forEach(entity -> {
MatterEntity matterEntity = matterService.get(entity.getMatterId(), context);
if (!ObjectUtils.isEmpty(matterEntity)) {
entity.setMatterNo(matterEntity.getMatterNo());
entity.setMatterName(matterEntity.getMatterName());
if (!ObjectUtils.isEmpty(matterEntityMap)) {
MatterEntity matterEntity = matterEntityMap.get(entity.getMatterId());
if (!ObjectUtils.isEmpty(matterEntity)) {
entity.setMatterNo(matterEntity.getMatterNo());
entity.setMatterName(matterEntity.getMatterName());
}
}
if (!ObjectUtils.isEmpty(collect)) {
DatumCategoryEntity datumCategoryEntity = collect.get(entity.getId());
if (!ObjectUtils.isEmpty(datumCategoryEntity)) {
entity.setCategoryId(datumCategoryEntity.getCategoryId());
entity.setCategoryName(datumCategoryEntity.getCategoryName());
}
}
});
super.findAfter(params, pageInfo, context, list);
......
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