Commit 6c08f365 authored by 赵啸非's avatar 赵啸非

添加设备大厅分配

parent a9fc228e
package com.mortals.xhx.common.pdu.site;
import java.util.Date;
import java.util.List;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
/**
* 站点大厅信息Pdu对象
*
* @author zxfei
* @date 2023-04-26
*/
@Data
public class SiteHallPdu extends BaseEntityLong {
private static final long serialVersionUID = 1L;
/**
* 站点ID
*/
private Long siteId;
/**
* 站点名称
*/
private String siteName;
/**
* 大厅名称
*/
private String hallName;
/**
* 地址
*/
private String address;
/**
* 楼层
*/
private Integer floor;
/**
* 楼栋
*/
private Integer build;
/**
* 备注
*/
private String remark;
public void initAttrValue(){
this.siteId = null;
this.siteName = "";
this.hallName = "";
this.address = "";
this.floor = 1;
this.build = 1;
this.remark = "";
}
}
\ No newline at end of file
package com.mortals.xhx.feign.site;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SiteHallPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 站点大厅信息 Feign接口
*
* @author zxfei
* @date 2023-04-26
*/
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = SiteHallFeignFallbackFactory.class)
public interface ISiteHallFeign extends IFeign {
/**
* 查看站点大厅信息列表
*
* @param siteHallPdu
* @return
*/
@PostMapping(value = "/site/hall/list")
Rest<RespData<List<SiteHallPdu>>> list(@RequestBody SiteHallPdu siteHallPdu);
/**
* 查看站点大厅信息
*
* @param id
* @return
*/
@GetMapping(value = "/site/hall/info")
Rest<SiteHallPdu> info(@RequestParam(value = "id") Long id);
/**
* 删除站点大厅信息
*
* @param ids
* @return
*/
@GetMapping(value = "/site/hall/delete")
Rest<Void> delete(Long[] ids, @RequestHeader("Authorization") String authorization);
/**
* 站点大厅信息保存更新
*
* @param siteHallPdu
* @return
*/
@PostMapping(value = "/site/hall/save")
Rest<RespData<SiteHallPdu>> save(@RequestBody SiteHallPdu siteHallPdu, @RequestHeader("Authorization") String authorization);
}
@Slf4j
@Component
class SiteHallFeignFallbackFactory implements FallbackFactory<ISiteHallFeign> {
@Override
public ISiteHallFeign create(Throwable t) {
return new ISiteHallFeign() {
@Override
public Rest<RespData<List<SiteHallPdu>>> list(SiteHallPdu siteHallPdu) {
return Rest.fail("暂时无法获取站点大厅信息列表,请稍后再试!");
}
@Override
public Rest<SiteHallPdu> info(Long id) {
return Rest.fail("暂时无法获取站点大厅信息详细,请稍后再试!");
}
@Override
public Rest<Void> delete(Long[] ids, String authorization) {
return Rest.fail("暂时无法删除站点大厅信息,请稍后再试!");
}
@Override
public Rest<RespData<SiteHallPdu>> save(SiteHallPdu siteHallPdu, String authorization) {
return Rest.fail("暂时无法保存站点大厅信息,请稍后再试!");
}
};
}
}
...@@ -119,6 +119,14 @@ export default { ...@@ -119,6 +119,14 @@ export default {
// toView(row) { // toView(row) {
// this.$refs.dialogform.view(row); // this.$refs.dialogform.view(row);
// }, // },
handAdd(row){
this.$router.push({
path: this.pageInfo.add,
query: {},
})
}
}, },
data() { data() {
return { return {
......
...@@ -19,4 +19,12 @@ ALTER TABLE mortals_xhx_device ADD COLUMN `deviceVersion` varchar (64) COMME ...@@ -19,4 +19,12 @@ ALTER TABLE mortals_xhx_device ADD COLUMN `deviceVersion` varchar (64) COMME
-- ---------------------------- -- ----------------------------
2023-02-2 2023-02-2
-- ---------------------------- -- ----------------------------
ALTER TABLE mortals_xhx_device ADD COLUMN `productCode` varchar (64) default '' COMMENT '产品编码' AFTER productId; ALTER TABLE mortals_xhx_device ADD COLUMN `productCode` varchar (64) default '' COMMENT '产品编码' AFTER productId;
\ No newline at end of file
-- ----------------------------
2023-04-26
-- ----------------------------
ALTER TABLE mortals_xhx_device ADD COLUMN `hallId` bigint(20) COMMENT '大厅Id' AFTER skinName;
ALTER TABLE mortals_xhx_device ADD COLUMN `hallName` varchar(256) default '' COMMENT '大厅名称' AFTER hallId;
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<profiles.active>develop</profiles.active> <profiles.active>develop</profiles.active>
<profiles.server.port>18222</profiles.server.port> <profiles.server.port>18222</profiles.server.port>
<!-- <profiles.platform.type>standalone</profiles.platform.type>--> <!-- <profiles.platform.type>standalone</profiles.platform.type>-->
<profiles.platform.type>cloud</profiles.platform.type> <profiles.platform.type>standalone</profiles.platform.type>
<profiles.datasource.uri> <profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.98:3306/device-new-platform?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri> <![CDATA[jdbc:mysql://192.168.0.98:3306/device-new-platform?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username> <profiles.datasource.username>root</profiles.datasource.username>
......
...@@ -603,7 +603,7 @@ public class DeviceApiController { ...@@ -603,7 +603,7 @@ public class DeviceApiController {
@PostMapping("callbackByProduct") @PostMapping("callbackByProduct")
@UnAuth @UnAuth
public String callbackByProduct(@RequestBody DeviceMsgReq deviceMsgReq) { public String callbackByProduct(@RequestBody DeviceMsgReq deviceMsgReq) {
log.info("【设备数据消息接收】【请求体】--> " + JSONObject.toJSONString(deviceMsgReq)); log.info("【设备产品数据消息接收】【请求体】--> " + JSONObject.toJSONString(deviceMsgReq));
ApiResp<String> rsp = new ApiResp<>(); ApiResp<String> rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel()); rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue()); rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
......
...@@ -85,37 +85,6 @@ public class DownMsgTask implements Runnable { ...@@ -85,37 +85,6 @@ public class DownMsgTask implements Runnable {
TimeUnit.SECONDS.sleep(1); TimeUnit.SECONDS.sleep(1);
} }
/*
list.stream().sorted(Comparator.comparing(DeviceMsgReq::getTimestamp)).forEach(item -> {
//根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceCode());
if (!ObjectUtils.isEmpty(deviceEntity)) {
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, item.getMessageType());
header.put(MessageHeader.DEVICECODE, item.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, item.getTimestamp().toString());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), item.getData(), header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE,Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,null);
} else {
log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
}
});*/
} catch (Exception e) { } catch (Exception e) {
log.error("异常:", e); log.error("异常:", e);
} }
......
package com.mortals.xhx.module.device.model; package com.mortals.xhx.module.device.model;
import java.util.Date;
import java.util.List; import java.util.List;
import com.mortals.xhx.module.device.model.DeviceEntity;
/** /**
* 设备查询对象 * 设备查询对象
* *
* @author zxfei * @author zxfei
* @date 2023-02-25 * @date 2023-04-26
*/ */
public class DeviceQuery extends DeviceEntity { public class DeviceQuery extends DeviceEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
...@@ -413,6 +415,26 @@ public class DeviceQuery extends DeviceEntity { ...@@ -413,6 +415,26 @@ public class DeviceQuery extends DeviceEntity {
/** 产品编码排除列表 */ /** 产品编码排除列表 */
private List <String> productCodeNotList; private List <String> productCodeNotList;
/** 开始 大厅Id */
private Long hallIdStart;
/** 结束 大厅Id */
private Long hallIdEnd;
/** 增加 大厅Id */
private Long hallIdIncrement;
/** 大厅Id列表 */
private List <Long> hallIdList;
/** 大厅Id排除列表 */
private List <Long> hallIdNotList;
/** 大厅名称 */
private List<String> hallNameList;
/** 大厅名称排除列表 */
private List <String> hallNameNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<DeviceQuery> orConditionList; private List<DeviceQuery> orConditionList;
...@@ -2726,6 +2748,119 @@ public class DeviceQuery extends DeviceEntity { ...@@ -2726,6 +2748,119 @@ public class DeviceQuery extends DeviceEntity {
this.productCodeNotList = productCodeNotList; this.productCodeNotList = productCodeNotList;
} }
/**
* 获取 开始 大厅Id
* @return hallIdStart
*/
public Long getHallIdStart(){
return this.hallIdStart;
}
/**
* 设置 开始 大厅Id
* @param hallIdStart
*/
public void setHallIdStart(Long hallIdStart){
this.hallIdStart = hallIdStart;
}
/**
* 获取 结束 大厅Id
* @return $hallIdEnd
*/
public Long getHallIdEnd(){
return this.hallIdEnd;
}
/**
* 设置 结束 大厅Id
* @param hallIdEnd
*/
public void setHallIdEnd(Long hallIdEnd){
this.hallIdEnd = hallIdEnd;
}
/**
* 获取 增加 大厅Id
* @return hallIdIncrement
*/
public Long getHallIdIncrement(){
return this.hallIdIncrement;
}
/**
* 设置 增加 大厅Id
* @param hallIdIncrement
*/
public void setHallIdIncrement(Long hallIdIncrement){
this.hallIdIncrement = hallIdIncrement;
}
/**
* 获取 大厅Id
* @return hallIdList
*/
public List<Long> getHallIdList(){
return this.hallIdList;
}
/**
* 设置 大厅Id
* @param hallIdList
*/
public void setHallIdList(List<Long> hallIdList){
this.hallIdList = hallIdList;
}
/**
* 获取 大厅Id
* @return hallIdNotList
*/
public List<Long> getHallIdNotList(){
return this.hallIdNotList;
}
/**
* 设置 大厅Id
* @param hallIdNotList
*/
public void setHallIdNotList(List<Long> hallIdNotList){
this.hallIdNotList = hallIdNotList;
}
/**
* 获取 大厅名称
* @return hallNameList
*/
public List<String> getHallNameList(){
return this.hallNameList;
}
/**
* 设置 大厅名称
* @param hallNameList
*/
public void setHallNameList(List<String> hallNameList){
this.hallNameList = hallNameList;
}
/**
* 获取 大厅名称
* @return hallNameNotList
*/
public List<String> getHallNameNotList(){
return this.hallNameNotList;
}
/**
* 设置 大厅名称
* @param hallNameNotList
*/
public void setHallNameNotList(List<String> hallNameNotList){
this.hallNameNotList = hallNameNotList;
}
/** /**
* 设置 主键ID,主键,自增长 * 设置 主键ID,主键,自增长
* @param id * @param id
...@@ -4105,6 +4240,79 @@ public class DeviceQuery extends DeviceEntity { ...@@ -4105,6 +4240,79 @@ public class DeviceQuery extends DeviceEntity {
return this; return this;
} }
/**
* 设置 大厅Id
* @param hallId
*/
public DeviceQuery hallId(Long hallId){
setHallId(hallId);
return this;
}
/**
* 设置 开始 大厅Id
* @param hallIdStart
*/
public DeviceQuery hallIdStart(Long hallIdStart){
this.hallIdStart = hallIdStart;
return this;
}
/**
* 设置 结束 大厅Id
* @param hallIdEnd
*/
public DeviceQuery hallIdEnd(Long hallIdEnd){
this.hallIdEnd = hallIdEnd;
return this;
}
/**
* 设置 增加 大厅Id
* @param hallIdIncrement
*/
public DeviceQuery hallIdIncrement(Long hallIdIncrement){
this.hallIdIncrement = hallIdIncrement;
return this;
}
/**
* 设置 大厅Id
* @param hallIdList
*/
public DeviceQuery hallIdList(List<Long> hallIdList){
this.hallIdList = hallIdList;
return this;
}
/**
* 设置 大厅Id
* @param hallIdNotList
*/
public DeviceQuery hallIdNotList(List<Long> hallIdNotList){
this.hallIdNotList = hallIdNotList;
return this;
}
/**
* 设置 大厅名称
* @param hallName
*/
public DeviceQuery hallName(String hallName){
setHallName(hallName);
return this;
}
/**
* 设置 大厅名称
* @param hallNameList
*/
public DeviceQuery hallNameList(List<String> hallNameList){
this.hallNameList = hallNameList;
return this;
}
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
...@@ -48,6 +48,9 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -48,6 +48,9 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/ */
void restartApp(DeviceEntity deviceEntity,Context context); void restartApp(DeviceEntity deviceEntity,Context context);
void batchUpdateHall(DeviceEntity deviceEntity,Context context);
/** /**
* 设备启用停用 * 设备启用停用
* @param id * @param id
......
...@@ -73,7 +73,7 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D ...@@ -73,7 +73,7 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D
//RuntimeUtil //RuntimeUtil
//部署路径是否存在 如果不存在 创建目录, //部署路径是否存在 如果不存在 创建目录,
String path = GlobalSysInfo.getParamValue(Constant.DISTRIBUTE_PATH, "/home/publish/device-manager-ui/homeDeviceUrl"); String path = GlobalSysInfo.getParamValue(Constant.DISTRIBUTE_PATH, "/home/publish/app/homeDeviceUrl");
String code = distributeEntity.getProductCode(); String code = distributeEntity.getProductCode();
String imageRe = distributeEntity.getImageResolutionValue(); String imageRe = distributeEntity.getImageResolutionValue();
String disPath = "/" + path + "/" + code + "/" + imageRe; String disPath = "/" + path + "/" + code + "/" + imageRe;
......
...@@ -261,6 +261,27 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -261,6 +261,27 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
} }
@Override
public void batchUpdateHall(DeviceEntity deviceEntity, Context context) {
if (ObjectUtils.isEmpty(deviceEntity.getIdList())) {
throw new AppException("请选择需要更新大厅的设备!");
}
if(ObjectUtils.isEmpty(deviceEntity.getHallId())){
throw new AppException("设备所属大厅不能为空!");
}
DeviceQuery condition = new DeviceQuery();
condition.setIdList(deviceEntity.getIdList());
DeviceQuery deviceQuery = new DeviceQuery();
deviceQuery.setHallId(deviceEntity.getHallId());
deviceQuery.setHallName(deviceEntity.getHallName());
deviceQuery.setUpdateTime(new Date());
this.getDeviceDao().update(deviceQuery, condition);
}
@Override @Override
public void deviceEnabled(Long id, Integer enabled, Context context) { public void deviceEnabled(Long id, Integer enabled, Context context) {
DeviceEntity deviceEntity = this.get(id, context); DeviceEntity deviceEntity = this.get(id, context);
......
...@@ -14,10 +14,12 @@ import com.mortals.xhx.base.system.param.service.ParamService; ...@@ -14,10 +14,12 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService; import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SiteHallPdu;
import com.mortals.xhx.common.pdu.site.SitePdu; import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.skin.SkinBasePdu; import com.mortals.xhx.common.pdu.skin.SkinBasePdu;
import com.mortals.xhx.common.utils.QRCodeUtil; import com.mortals.xhx.common.utils.QRCodeUtil;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.site.ISiteHallFeign;
import com.mortals.xhx.feign.skin.ISkinBaseFeign; import com.mortals.xhx.feign.skin.ISkinBaseFeign;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceMapEntity; import com.mortals.xhx.module.device.model.DeviceMapEntity;
...@@ -73,6 +75,8 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -73,6 +75,8 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
private String platFormType;//版本,默认云服务版本 private String platFormType;//版本,默认云服务版本
@Autowired @Autowired
private SiteService siteService; private SiteService siteService;
@Autowired
public ISiteHallFeign siteHallFeign;
public DeviceController() { public DeviceController() {
...@@ -100,6 +104,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -100,6 +104,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
this.addDict(model, "skinProductCodeMap", skinProductCodeMap); this.addDict(model, "skinProductCodeMap", skinProductCodeMap);
} }
} }
//siteHallFeign.list(new SiteHallPdu().setSiteId(context.g);)
super.init(model, context); super.init(model, context);
} }
...@@ -108,6 +113,14 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -108,6 +113,14 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
List<OrderCol> orderColList = new ArrayList<>(); List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("createTime", OrderCol.DESCENDING)); orderColList.add(new OrderCol("createTime", OrderCol.DESCENDING));
query.setOrderColList(orderColList); query.setOrderColList(orderColList);
SiteHallPdu siteHallPdu = new SiteHallPdu();
siteHallPdu.setSiteId(query.getSiteId());
Rest<RespData<List<SiteHallPdu>>> rest = siteHallFeign.list(siteHallPdu);
if(rest.getCode()==YesNoEnum.YES.getValue()){
Map<String, String> hallMap = rest.getData().getData().stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getHallName(), (o, n) -> n));
this.addDict(model, "hallId", hallMap);
}
super.doListBefore(query, model, context); super.doListBefore(query, model, context);
} }
...@@ -328,6 +341,25 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -328,6 +341,25 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return Rest.ok(model); return Rest.ok(model);
} }
/**
* 设备批量更新设备所属大厅
*/
@PostMapping(value = "batchUpdateHall")
public Rest<Void> batchUpdateHall(@RequestBody DeviceEntity deviceEntity) {
log.info("批量设备重启", deviceEntity.getDeviceCode());
String busiDesc = this.getModuleDesc() + "批量更新所属大厅";
Rest<Void> rest = Rest.ok(busiDesc + " 【成功】");
try {
this.service.batchUpdateHall(deviceEntity,getContext());
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("批量更新所属大厅", e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
@Override @Override
public void doImportDataBefore(List<DeviceEntity> list, boolean updateSupport, Context context) throws AppException { public void doImportDataBefore(List<DeviceEntity> list, boolean updateSupport, Context context) throws AppException {
......
...@@ -666,6 +666,9 @@ key|String|消息唯一标识|是|- ...@@ -666,6 +666,9 @@ key|String|消息唯一标识|是|-
} }
``` ```
## 码表 ## 码表
### 响应结果码表 ### 响应结果码表
......
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