|
@ -2,10 +2,9 @@ package com.yihu.iot.controller.device;
|
|
|
|
|
|
import com.yihu.iot.service.device.IotDeviceInventoryService;
|
|
|
import com.yihu.iot.service.device.IotDeviceInventoryWarningService;
|
|
|
import com.yihu.iot.service.excelImport.DeviceInventoryExcelReader;
|
|
|
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
|
|
|
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryWarningVO;
|
|
|
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.rm.iot.IotRequestMapping;
|
|
@ -14,6 +13,10 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @author humingfen on 2020.4.29
|
|
@ -27,6 +30,8 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
|
|
|
private IotDeviceInventoryService deviceInventoryService;
|
|
|
@Autowired
|
|
|
private IotDeviceInventoryWarningService deviceInventoryWarningService;
|
|
|
@Autowired
|
|
|
private DeviceInventoryExcelReader deviceInventoryExcelReader;
|
|
|
|
|
|
@GetMapping(value = IotRequestMapping.Device.getDeviceInventoryList)
|
|
|
@ApiOperation(value = "获取设备库存列表", notes = "获取设备库存列表")
|
|
@ -102,7 +107,7 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
|
|
|
@ApiOperation(value = "库存预警,获取单位接口", notes = "库存预警,获取单位接口")
|
|
|
public MixEnvelop getInventoryWarningHospital() {
|
|
|
try {
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryService.getInventoryWarningHospital());
|
|
|
return deviceInventoryService.getInventoryWarningHospital();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return MixEnvelop.getError(e.getMessage());
|
|
@ -114,12 +119,32 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
|
|
|
public MixEnvelop getInventoryWarningName(@ApiParam(name = "hospital", value = "单位code")
|
|
|
@RequestParam(value = "hospital", required = true) String hospital) {
|
|
|
try {
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryService.getInventoryWarningName(hospital));
|
|
|
return deviceInventoryService.getInventoryWarningName(hospital);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return MixEnvelop.getError(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = IotRequestMapping.Device.deviceInventoryImport)
|
|
|
@ApiOperation(value = "设备入库sn导入")
|
|
|
public MixEnvelop deviceInventoryImport(
|
|
|
@ApiParam(value = "文件", required = true)
|
|
|
@RequestParam(value = "file") MultipartFile file,
|
|
|
HttpServletRequest request) {
|
|
|
try {
|
|
|
request.setCharacterEncoding("UTF-8");
|
|
|
deviceInventoryExcelReader.read(file);
|
|
|
List<String> errorLs = deviceInventoryExcelReader.getErrorLs();
|
|
|
List<String> correctLs = deviceInventoryExcelReader.getCorrectLs();
|
|
|
if(correctLs.size()>0){
|
|
|
|
|
|
}
|
|
|
return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_import, correctLs);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return MixEnvelop.getError("导入异常,请检查导入文件格式" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|