Commit 7e8c83dc authored by 廖旭伟's avatar 廖旭伟

增加设备修改接口,应用集市类型调整

parent b5426fa9
......@@ -310,5 +310,4 @@ public class DevicePdu extends BaseEntityLong {
this.showWechatQrCode = 1;
}
}
\ No newline at end of file
package com.mortals.xhx.feign.device;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DeviceNotifyPdu;
......@@ -59,6 +60,15 @@ public interface IDeviceFeign extends IFeign {
@PostMapping(value = "/device/save")
Rest<RespData<DevicePdu>> save(@RequestBody DevicePdu devicePdu,@RequestHeader("Authorization") String authorization);
/**
* 设备启用停用
*
* @param devicePdu
* @return
*/
@PostMapping(value = "/device/enable")
String deviceEnable(@RequestBody DevicePdu devicePdu,@RequestHeader("Authorization") String authorization);
/**
* 接收第三方平台下发设备消息
* @param deviceNotifyPdu
......@@ -95,6 +105,14 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
return Rest.fail("暂时无法保存设备,请稍后再试!");
}
@Override
public String deviceEnable(DevicePdu devicePdu, String authorization) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", -1);
jsonObject.put("msg", "暂时无法启用停用设备,请稍后再试!");
return jsonObject.toJSONString();
}
@Override
public Rest<String> downMsg(DeviceNotifyPdu deviceNotifyPdu) {
return Rest.fail("暂时无法接收第三方平台下发设备消息,请稍后再试!");
......
......@@ -62,9 +62,10 @@ public class AppsInfoServiceImpl extends AbstractCRUDServiceImpl<AppsInfoDao, Ap
public List<AppsInfoEntity> find(AppsInfoEntity entity) throws AppException {
AppPdu appPdu = new AppPdu();
appPdu.setSiteId(entity.getSiteId());
appPdu.setSize(999);
appPdu.setType(1);
appPdu.setShelves(1);
appPdu.setSize(-1);
appPdu.setType(1); //类型(1.终端应用,2.移动端应用)
appPdu.setShelves(1); //是否上架(0.下架,1.上架)
appPdu.setAppName(entity.getName());
Rest<RespData<List<AppPdu>>> rest = appFeign.list(appPdu);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
List<AppsInfoEntity> appsInfoEntities = new ArrayList<>();
......
package com.mortals.xhx.module.device.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntity;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.IUser;
import com.mortals.framework.utils.ReflectUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
......@@ -28,10 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -92,6 +93,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
model.put("notActive", not_active);
model.put("stopUsing", stop_using);
model.put("pageInfo", result.getPageInfo());
model.put("dict",result.getDict());
this.parsePageInfo(model, result.getPageInfo());
code = this.doListAfter(query, model, context);
model.put("message_info", busiDesc + "成功");
......@@ -109,7 +111,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return ret;
}
@RequestMapping(value = {"info"},method = {RequestMethod.POST, RequestMethod.GET})
@UnAuth
public String info(Long id) {
......@@ -313,4 +314,86 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return ret;
}
@PostMapping({"m/save"})
@RepeatSubmit
public String save(@RequestBody DevicePdu devicePdu,@RequestHeader("Authorization") String authorization) {
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "保存" + this.getModuleDesc();
int code=1;
try {
Rest<RespData<DevicePdu>> rest = deviceFeign.save(devicePdu,authorization);
if (rest.getCode()>0){
code = 1;
model.put("entity", rest.getData().getData());
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + devicePdu.getId() + "]");
}
} catch (Exception var9) {
this.doException(this.request, busiDesc, model, var9);
model.put("entity", devicePdu);
this.init(model, context);
code = -1;
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
@PostMapping({"m/list"})
@UnAuth
public Rest<Object> mlist(@RequestBody DevicePdu query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code;
try {
Rest<RespData<List<DevicePdu>>> rest = deviceFeign.list(query);
ret.setCode(rest.getCode());
ret.setMsg(rest.getMsg());
ret.setData(rest.getData());
ret.setDict(rest.getDict());
} catch (Exception var9) {
code = -1;
ret.setCode(code);
this.doException(this.request, busiDesc, model, var9);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
}
return ret;
}
/**
* 设备启用停用
*/
@PostMapping(value = "m/enable")
public String deviceEnable(@RequestBody DevicePdu devicePdu,@RequestHeader("Authorization") String authorization) {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>();
String busiDesc = "启用停用设备";
try {
String resp = deviceFeign.deviceEnable(devicePdu,authorization);
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
} catch (Exception e) {
log.error("设备启用停用消息", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
}
\ No newline at end of file
......@@ -24,6 +24,8 @@ public class SstBasicVo extends BaseEntityLong {
/** 设备编码 */
private String deviceCode;
private String appName;
public String getShowAppIds() {
return showAppIds;
}
......@@ -63,4 +65,12 @@ public class SstBasicVo extends BaseEntityLong {
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ public interface SstAppsDeskService extends ICRUDService<SstAppsDeskEntity,Long>
* @param siteId 站点ID
* @return
*/
Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host);
Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host,String appName);
/**
* 应用下架
......
......@@ -38,7 +38,7 @@ public interface SstAppsService extends ICRUDService<SstAppsEntity,Long>{
* @param siteId 站点ID
* @return
*/
Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host);
Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host,String appName);
/**
* 应用下架
......
......@@ -145,7 +145,7 @@ public class SstAppsDeskServiceImpl extends AbstractCRUDServiceImpl<SstAppsDeskD
}
@Override
public Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host) {
public Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host,String appName) {
SstAppsDeskEntity query = new SstAppsDeskEntity();
Map<String,String> orderCols = new HashMap<>();
orderCols.put("basicSort","DESC");
......@@ -168,6 +168,7 @@ public class SstAppsDeskServiceImpl extends AbstractCRUDServiceImpl<SstAppsDeskD
}
AppsInfoEntity appsInfoQuery = new AppsInfoEntity();
appsInfoQuery.setSiteId(siteId);
appsInfoQuery.setName(appName);
List<AppsInfoEntity> allApps = appsInfoService.find(appsInfoQuery);
for(AppsInfoEntity appsInfoEntity:allApps){
if(com.mortals.framework.util.StringUtils.isNotEmpty(host)) {
......@@ -180,15 +181,18 @@ public class SstAppsDeskServiceImpl extends AbstractCRUDServiceImpl<SstAppsDeskD
if(CollectionUtils.isNotEmpty(appsEntities)){
List<AppsInfoEntity> showApps = new ArrayList<>();
List<AppsInfoEntity> hotApps = new ArrayList<>();
for(SstAppsDeskEntity SstAppsDeskEntity:appsEntities){
if(black.containsKey(SstAppsDeskEntity.getAppId())){
for(SstAppsDeskEntity sstAppsDeskEntity:appsEntities){
if(black.containsKey(sstAppsDeskEntity.getAppId())){
continue;
}
if(SstAppsDeskEntity.getShowBasic()==1){
showApps.add(appInfoMap.get(SstAppsDeskEntity.getAppId()));
if(!appInfoMap.containsKey(sstAppsDeskEntity.getAppId())){
continue;
}
if(SstAppsDeskEntity.getShowHot()==1){
hotApps.add(appInfoMap.get(SstAppsDeskEntity.getAppId()));
if(sstAppsDeskEntity.getShowBasic()==1){
showApps.add(appInfoMap.get(sstAppsDeskEntity.getAppId()));
}
if(sstAppsDeskEntity.getShowHot()==1){
hotApps.add(appInfoMap.get(sstAppsDeskEntity.getAppId()));
}
}
siteApp.put("showApps", showApps);
......
......@@ -147,7 +147,7 @@ public class SstAppsServiceImpl extends AbstractCRUDServiceImpl<SstAppsDao, SstA
}
@Override
public Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host) {
public Map<String, Object> getAppListBySite(String deviceCode,Long siteId,String host,String appName) {
SstAppsEntity query = new SstAppsEntity();
Map<String,String> orderCols = new HashMap<>();
orderCols.put("basicSort","DESC");
......@@ -171,6 +171,7 @@ public class SstAppsServiceImpl extends AbstractCRUDServiceImpl<SstAppsDao, SstA
AppsInfoEntity appsInfoQuery = new AppsInfoEntity();
appsInfoQuery.setSiteId(siteId);
appsInfoQuery.setName(appName);
List<AppsInfoEntity> allApps = appsInfoService.find(appsInfoQuery);
for(AppsInfoEntity appsInfoEntity:allApps){
if(com.mortals.framework.util.StringUtils.isNotEmpty(host)) {
......@@ -187,6 +188,9 @@ public class SstAppsServiceImpl extends AbstractCRUDServiceImpl<SstAppsDao, SstA
if(black.containsKey(sstAppsEntity.getAppId())){
continue;
}
if(!appInfoMap.containsKey(sstAppsEntity.getAppId())){
continue;
}
if(sstAppsEntity.getShowBasic()==1){
showApps.add(appInfoMap.get(sstAppsEntity.getAppId()));
}
......
......@@ -358,8 +358,11 @@ public class SstBasicController extends BaseCRUDJsonBodyMappingController<SstBas
}else {
host="";
}
if(StringUtils.isNotEmpty(query.getAppName())){
query.setAppName("%"+query.getAppName()+"%");
}
log.info("server-name:"+serverName+",server-port:"+serverPort);
Map<String, Object> sstApps = sstAppsService.getAppListBySite(query.getDeviceCode(),query.getSiteId(),host);
Map<String, Object> sstApps = sstAppsService.getAppListBySite(query.getDeviceCode(),query.getSiteId(),host,query.getAppName());
model.put("showApps", sstApps.get("showApps"));
model.put("hotApps", sstApps.get("hotApps"));
model.put("allApps", sstApps.get("allApps"));
......@@ -407,8 +410,11 @@ public class SstBasicController extends BaseCRUDJsonBodyMappingController<SstBas
}else {
host="";
}
if(StringUtils.isNotEmpty(query.getAppName())){
query.setAppName("%"+query.getAppName()+"%");
}
log.info("server-name:"+serverName+",server-port:"+serverPort);
Map<String, Object> sstAppsDesk = sstAppsDeskService.getAppListBySite(query.getDeviceCode(),query.getSiteId(),host);
Map<String, Object> sstAppsDesk = sstAppsDeskService.getAppListBySite(query.getDeviceCode(),query.getSiteId(),host,query.getAppName());
model.put("showApps", sstAppsDesk.get("showApps"));
model.put("hotApps", sstAppsDesk.get("hotApps"));
model.put("allApps", sstAppsDesk.get("allApps"));
......
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