Commit 354631d5 authored by 廖旭伟's avatar 廖旭伟

应用信息改为从基础平台获取

parent a4c0c563
package com.mortals.xhx.common.pdu.app;
import com.mortals.framework.model.BaseEntityLong;
import java.util.ArrayList;
import java.util.List;
/**
* 基础平台自助终端应用
*/
public class AppPdu extends BaseEntityLong {
private static final long serialVersionUID = 1L;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点名称
*/
private String siteName;
/**
* 应用编码
*/
private String appCode;
/**
* 应用名称
*/
private String appName;
/**
* 应用图标
*/
private String appIconPath;
/**
* 应用主题名称
*/
private String appThemeName;
/**
* 类型(1.终端应用,2.移动端应用)
*/
private Integer type;
/**
* 链接地址
*/
private String url;
/**
* 服务接口地址
*/
private String serviceApi;
/**
* 下发设备次数
*/
private Integer downDevCount;
/**
* 是否上架(0.下架,1.上架)
*/
private Integer shelves;
/**
* 类型(1.应用程序,2.url)
*/
private Integer appType;
/**
* 文件名称
*/
private String fileName;
/**
* 文件相对路径地址
*/
private String filePath;
/**
* 文件部署路径地址
*/
private String distributeFilePath;
/**
* 当前版本
*/
private Integer version;
/**
* 简介
*/
private String summary;
/**
* 更新说明
*/
private String notes;
/**
* 是否部署(0.否,1.是)
*/
private Integer distribute;
/**
* 是否数据更新(0.否,1.是)
*/
private Integer dataUpdate;
public AppPdu(){}
/**
* 获取 站点Id
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 站点名称
* @return String
*/
public String getSiteName(){
return siteName;
}
/**
* 设置 站点名称
* @param siteName
*/
public void setSiteName(String siteName){
this.siteName = siteName;
}
/**
* 获取 应用编码
* @return String
*/
public String getAppCode(){
return appCode;
}
/**
* 设置 应用编码
* @param appCode
*/
public void setAppCode(String appCode){
this.appCode = appCode;
}
/**
* 获取 应用名称
* @return String
*/
public String getAppName(){
return appName;
}
/**
* 设置 应用名称
* @param appName
*/
public void setAppName(String appName){
this.appName = appName;
}
/**
* 获取 应用图标
* @return String
*/
public String getAppIconPath(){
return appIconPath;
}
/**
* 设置 应用图标
* @param appIconPath
*/
public void setAppIconPath(String appIconPath){
this.appIconPath = appIconPath;
}
/**
* 获取 应用主题名称
* @return String
*/
public String getAppThemeName(){
return appThemeName;
}
/**
* 设置 应用主题名称
* @param appThemeName
*/
public void setAppThemeName(String appThemeName){
this.appThemeName = appThemeName;
}
/**
* 获取 类型(1.终端应用,2.移动端应用)
* @return Integer
*/
public Integer getType(){
return type;
}
/**
* 设置 类型(1.终端应用,2.移动端应用)
* @param type
*/
public void setType(Integer type){
this.type = type;
}
/**
* 获取 链接地址
* @return String
*/
public String getUrl(){
return url;
}
/**
* 设置 链接地址
* @param url
*/
public void setUrl(String url){
this.url = url;
}
/**
* 获取 服务接口地址
* @return String
*/
public String getServiceApi(){
return serviceApi;
}
/**
* 设置 服务接口地址
* @param serviceApi
*/
public void setServiceApi(String serviceApi){
this.serviceApi = serviceApi;
}
/**
* 获取 下发设备次数
* @return Integer
*/
public Integer getDownDevCount(){
return downDevCount;
}
/**
* 设置 下发设备次数
* @param downDevCount
*/
public void setDownDevCount(Integer downDevCount){
this.downDevCount = downDevCount;
}
/**
* 获取 是否上架(0.下架,1.上架)
* @return Integer
*/
public Integer getShelves(){
return shelves;
}
/**
* 设置 是否上架(0.下架,1.上架)
* @param shelves
*/
public void setShelves(Integer shelves){
this.shelves = shelves;
}
/**
* 获取 类型(1.应用程序,2.url)
* @return Integer
*/
public Integer getAppType(){
return appType;
}
/**
* 设置 类型(1.应用程序,2.url)
* @param appType
*/
public void setAppType(Integer appType){
this.appType = appType;
}
/**
* 获取 文件名称
* @return String
*/
public String getFileName(){
return fileName;
}
/**
* 设置 文件名称
* @param fileName
*/
public void setFileName(String fileName){
this.fileName = fileName;
}
/**
* 获取 文件相对路径地址
* @return String
*/
public String getFilePath(){
return filePath;
}
/**
* 设置 文件相对路径地址
* @param filePath
*/
public void setFilePath(String filePath){
this.filePath = filePath;
}
/**
* 获取 文件部署路径地址
* @return String
*/
public String getDistributeFilePath(){
return distributeFilePath;
}
/**
* 设置 文件部署路径地址
* @param distributeFilePath
*/
public void setDistributeFilePath(String distributeFilePath){
this.distributeFilePath = distributeFilePath;
}
/**
* 获取 当前版本
* @return Integer
*/
public Integer getVersion(){
return version;
}
/**
* 设置 当前版本
* @param version
*/
public void setVersion(Integer version){
this.version = version;
}
/**
* 获取 简介
* @return String
*/
public String getSummary(){
return summary;
}
/**
* 设置 简介
* @param summary
*/
public void setSummary(String summary){
this.summary = summary;
}
/**
* 获取 更新说明
* @return String
*/
public String getNotes(){
return notes;
}
/**
* 设置 更新说明
* @param notes
*/
public void setNotes(String notes){
this.notes = notes;
}
/**
* 获取 是否部署(0.否,1.是)
* @return Integer
*/
public Integer getDistribute(){
return distribute;
}
/**
* 设置 是否部署(0.否,1.是)
* @param distribute
*/
public void setDistribute(Integer distribute){
this.distribute = distribute;
}
/**
* 获取 是否数据更新(0.否,1.是)
* @return Integer
*/
public Integer getDataUpdate(){
return dataUpdate;
}
/**
* 设置 是否数据更新(0.否,1.是)
* @param dataUpdate
*/
public void setDataUpdate(Integer dataUpdate){
this.dataUpdate = dataUpdate;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof AppPdu) {
AppPdu tmp = (AppPdu) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",siteId:").append(getSiteId());
sb.append(",siteName:").append(getSiteName());
sb.append(",appCode:").append(getAppCode());
sb.append(",appName:").append(getAppName());
sb.append(",appIconPath:").append(getAppIconPath());
sb.append(",appThemeName:").append(getAppThemeName());
sb.append(",type:").append(getType());
sb.append(",url:").append(getUrl());
sb.append(",serviceApi:").append(getServiceApi());
sb.append(",downDevCount:").append(getDownDevCount());
sb.append(",shelves:").append(getShelves());
sb.append(",appType:").append(getAppType());
sb.append(",fileName:").append(getFileName());
sb.append(",filePath:").append(getFilePath());
sb.append(",distributeFilePath:").append(getDistributeFilePath());
sb.append(",version:").append(getVersion());
sb.append(",summary:").append(getSummary());
sb.append(",notes:").append(getNotes());
sb.append(",distribute:").append(getDistribute());
sb.append(",dataUpdate:").append(getDataUpdate());
return sb.toString();
}
public void initAttrValue(){
this.siteId = null;
this.siteName = null;
this.appCode = "";
this.appName = "";
this.appIconPath = "";
this.appThemeName = "";
this.type = 1;
this.url = null;
this.serviceApi = "";
this.downDevCount = 0;
this.shelves = 0;
this.appType = 1;
this.fileName = "";
this.filePath = "";
this.distributeFilePath = "";
this.version = 0;
this.summary = "";
this.notes = null;
this.distribute = 0;
this.dataUpdate = 0;
}
}
package com.mortals.xhx.feign.app;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.app.AppPdu;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.feign.device.IDeviceFeign;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 自助终端应用
*/
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = AppFeignFallbackFactory.class)
public interface IAppFeign extends IFeign {
/**
* 查看自助终端应用列表
*
* @param appPdu
* @return
*/
@PostMapping(value = "/app/list")
Rest<RespData<List<AppPdu>>> list(@RequestBody AppPdu appPdu);
/**
* 查看自助终端应用
*
* @param id
* @return
*/
@GetMapping(value = "/app/info")
Rest<AppPdu> info(@RequestParam(value = "id") Long id);
}
@Slf4j
@Component
class AppFeignFallbackFactory implements FallbackFactory<IAppFeign> {
@Override
public IAppFeign create(Throwable throwable) {
return new IAppFeign(){
@Override
public Rest<RespData<List<AppPdu>>> list(AppPdu appPdu) {
return Rest.fail("暂时无法获取自助终端应用列表,请稍后再试!");
}
@Override
public Rest<AppPdu> info(Long id) {
return Rest.fail("暂时无法获取自助终端应用,请稍后再试!");
}
};
}
}
\ No newline at end of file
package com.mortals.xhx.module.apps.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.apps.model.AppsInfoEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -9,6 +11,7 @@ import java.util.List;
* @author zxfei
* @date 2022-12-26
*/
@Data
public class AppsInfoVo extends BaseEntityLong {
private Long siteId;
}
\ No newline at end of file
package com.mortals.xhx.module.apps.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.app.AppPdu;
import com.mortals.xhx.feign.app.IAppFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,6 +12,12 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.apps.dao.AppsInfoDao;
import com.mortals.xhx.module.apps.model.AppsInfoEntity;
import com.mortals.xhx.module.apps.service.AppsInfoService;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* AppsInfoService
* 应用信息 service实现
......@@ -16,4 +28,72 @@ import com.mortals.xhx.module.apps.service.AppsInfoService;
@Service("appsInfoService")
public class AppsInfoServiceImpl extends AbstractCRUDServiceImpl<AppsInfoDao, AppsInfoEntity, Long> implements AppsInfoService {
@Autowired
private IAppFeign appFeign;
@Override
public AppsInfoEntity save(AppsInfoEntity entity, Context context) throws AppException {
return null;
}
@Override
public int save(List<AppsInfoEntity> list, Context context) throws AppException {
return 0;
}
@Override
public AppsInfoEntity update(AppsInfoEntity entity, Context context) throws AppException {
return null;
}
@Override
public int update(List<AppsInfoEntity> list, Context context) throws AppException {
return 0;
}
@Override
public AppsInfoEntity get(Long key, Context context) throws AppException {
return null;
}
@Override
public List<AppsInfoEntity> find(AppsInfoEntity entity) throws AppException {
AppPdu appPdu = new AppPdu();
appPdu.setSiteId(entity.getSiteId());
appPdu.setSize(999);
Rest<RespData<List<AppPdu>>> rest = appFeign.list(appPdu);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
List<AppsInfoEntity> appsInfoEntities = new ArrayList<>();
for(AppPdu pdu:rest.getData().getData()){
appsInfoEntities.add(conversion(pdu));
}
return appsInfoEntities;
}else {
return Collections.emptyList();
}
}
@Override
public AppsInfoEntity get(Long id) throws AppException {
Rest<AppPdu> rest = appFeign.info(id);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
return conversion(rest.getData());
}else {
return null;
}
}
private AppsInfoEntity conversion(AppPdu pdu){
if(pdu==null){
return null;
}
AppsInfoEntity appsInfoEntity = new AppsInfoEntity();
appsInfoEntity.setId(pdu.getId());
appsInfoEntity.setName(pdu.getAppName());
appsInfoEntity.setDescribe(pdu.getSummary());
appsInfoEntity.setIcon(pdu.getAppIconPath());
appsInfoEntity.setUrl(pdu.getUrl());
return appsInfoEntity;
}
}
\ No newline at end of file
......@@ -35,7 +35,9 @@ public class SstAppsServiceImpl extends AbstractCRUDServiceImpl<SstAppsDao, SstA
if(siteId == null){
throw new AppException("站点id不能为空");
}
List<AppsInfoEntity> allApps = appsInfoService.find(new AppsInfoEntity());
AppsInfoEntity appsInfoQuery = new AppsInfoEntity();
appsInfoQuery.setSiteId(siteId);
List<AppsInfoEntity> allApps = appsInfoService.find(appsInfoQuery);
SstAppsEntity query = new SstAppsEntity();
query.setSiteId(siteId);
List<SstAppsEntity> appsEntities = this.find(query);
......
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