|
@ -10,15 +10,16 @@ import com.yihu.jw.entity.care.device.DeviceCategory;
|
|
|
import com.yihu.jw.entity.care.device.DeviceDetail;
|
|
|
import com.yihu.jw.hospital.utils.ExcelData;
|
|
|
import com.yihu.jw.hospital.utils.QrcodeUtil;
|
|
|
import com.yihu.jw.hospital.utils.ReadExcelUtil;
|
|
|
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
|
|
|
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.date.DateTimeUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import jxl.Sheet;
|
|
|
import jxl.Workbook;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
@ -71,17 +72,16 @@ public class DeviceService {
|
|
|
private QrcodeUtil qrcodeUtil;
|
|
|
|
|
|
public boolean importData(Workbook workbook) {
|
|
|
Sheet[] sheets = workbook.getSheets();
|
|
|
Sheet sheet = sheets[0];
|
|
|
int rows = ReadExcelUtil.getRightRows(sheet);
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
int rows = sheet.getLastRowNum()+1;
|
|
|
|
|
|
List<DeviceDetail> deviceList = new ArrayList<>();
|
|
|
for (int row = 1; row < rows; row++) { //索引从0开始,第一行为标题
|
|
|
Row sheetRow = sheet.getRow(row);
|
|
|
DeviceDetail device = new DeviceDetail();
|
|
|
Map<Integer, ExcelData> mapping = mappingDevice(device);
|
|
|
int finalRow = row;
|
|
|
mapping.forEach((index, excelData) -> {
|
|
|
String value = sheet.getCell(index, finalRow).getContents().trim();
|
|
|
String value = (getExcelValue(sheetRow.getCell(index, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK))+"").trim();
|
|
|
excelData.transform(value);
|
|
|
});
|
|
|
device.setIsGrant(0);
|
|
@ -98,6 +98,21 @@ public class DeviceService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public static Object getExcelValue(Cell xssfCell) {
|
|
|
if(xssfCell==null){
|
|
|
return null;
|
|
|
}else if (xssfCell.getCellType() == xssfCell.CELL_TYPE_BOOLEAN) {
|
|
|
// 返回布尔类型的值
|
|
|
return xssfCell.getBooleanCellValue();
|
|
|
} else if (xssfCell.getCellType() == xssfCell.CELL_TYPE_NUMERIC) {
|
|
|
// 返回数值类型的值
|
|
|
return (int)xssfCell.getNumericCellValue();
|
|
|
} else {
|
|
|
// 返回字符串类型的值
|
|
|
return xssfCell.getStringCellValue();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private Map<Integer, ExcelData> mappingDevice(DeviceDetail device) {
|
|
|
Map<Integer, ExcelData> dataMap = new HashMap<>();
|
|
|
//设备名称
|