Commit f40f0336 authored by 廖旭伟's avatar 廖旭伟

设备管理导入模板

parent 4cdbd23e
...@@ -9,8 +9,10 @@ import com.mortals.xhx.feign.IFeign; ...@@ -9,8 +9,10 @@ import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
/** /**
...@@ -77,8 +79,8 @@ public interface IDeviceFeign extends IFeign { ...@@ -77,8 +79,8 @@ public interface IDeviceFeign extends IFeign {
@PostMapping(value = "/notify/downMsg") @PostMapping(value = "/notify/downMsg")
Rest<String> downMsg(@RequestBody DeviceNotifyPdu deviceNotifyPdu); Rest<String> downMsg(@RequestBody DeviceNotifyPdu deviceNotifyPdu);
@PostMapping(value = "/device/downloadTemplate") @PostMapping(value = "/device/importData",consumes= MediaType.MULTIPART_FORM_DATA_VALUE)
void downloadTemplate(); String importData(@RequestPart MultipartFile file,@RequestHeader("Authorization") String authorization);
} }
...@@ -122,9 +124,13 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> { ...@@ -122,9 +124,13 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
} }
@Override @Override
public void downloadTemplate() { public String importData(MultipartFile file, String authorization) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", -1);
jsonObject.put("msg", "暂时无法导入设备,请稍后再试!");
return jsonObject.toJSONString();
} }
}; };
} }
} }
......
...@@ -15,5 +15,42 @@ import java.util.List; ...@@ -15,5 +15,42 @@ import java.util.List;
*/ */
@Data @Data
public class DeviceVo extends BaseEntityLong { public class DeviceVo extends BaseEntityLong {
/**
* 唯一标识
*/
private String token;
/**
* 平台编码
*/
private String platformCode;
/**
* 是否通知第三方
*/
private Boolean switchSend=true;
/**
* 设备图片附件
*/
@Excel(name = "设备图片", type = Excel.Type.IMPORT, cellType = Excel.ColumnType.IMAGE)
@JSONField(deserialize = false,serialize = false)
@JsonIgnore
private PictureData picObj;
/** 主键ID,主键,自增长列表 */
private List <Long> idList;
/**
* 产品列表
*/
private List <Long> productIdList;
private List <Integer> deviceStatusList;
} }
\ No newline at end of file
...@@ -32,6 +32,7 @@ import org.springframework.beans.BeanUtils; ...@@ -32,6 +32,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -323,7 +324,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -323,7 +324,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
Context context = this.getContext(); Context context = this.getContext();
String busiDesc = "保存" + this.getModuleDesc(); String busiDesc = "保存" + this.getModuleDesc();
int code=1; int code = 1;
try { try {
Rest<RespData<DevicePdu>> rest = deviceFeign.save(devicePdu,authorization); Rest<RespData<DevicePdu>> rest = deviceFeign.save(devicePdu,authorization);
...@@ -332,6 +333,9 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -332,6 +333,9 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
model.put("entity", rest.getData().getData()); model.put("entity", rest.getData().getData());
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + devicePdu.getId() + "]"); this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + devicePdu.getId() + "]");
}else {
code = -1;
model.put("message_info", rest.getMsg());
} }
} catch (Exception var9) { } catch (Exception var9) {
...@@ -397,26 +401,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -397,26 +401,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
} }
@PostMapping({"m/downloadTemplate"}) @PostMapping({"m/importData"})
public void mdownloadTemplate() { public String importData(MultipartFile file,@RequestHeader("Authorization") String authorization) {
try {
deviceFeign.downloadTemplate();
} catch (Exception var4) {
this.doException(this.request, "导出模板异常", new HashMap(), var4);
}
return deviceFeign.importData(file,authorization);
} }
// @PostMapping({"downloadTemplate"})
// public void downloadTemplate() {
// try {
// Class<DeviceEntity> tClass = ReflectUtils.getClassGenricType(this.getClass(), 1);
// ExcelUtil<DeviceEntity, Long> util = new ExcelUtil(tClass);
// byte[] data = util.importTemplateExcel("模板数据");
// this.responseStream(this.response, data, "template.xlsx");
// } catch (Exception var4) {
// this.doException(this.request, "导出模板异常", new HashMap(), var4);
// }
//
// }
} }
\ 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