LAPTOP-KB9HII50\70708 преди 1 година
родител
ревизия
200261a1f3

+ 10 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java

@ -26,6 +26,7 @@ import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
@ -38,10 +39,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
@Transactional
@ -713,7 +714,11 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
            if(rs.get("obj") instanceof JSONObject){
                object = rs.getJSONObject("obj");
            }else {
                throw new ServiceException(rs.getString("obj"));
            }
        }
        return object;
    }

+ 7 - 9
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DeviceController.java

@ -16,18 +16,18 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.excel.poi.ExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.*;
import org.apache.poi.ss.usermodel.Workbook;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@ -126,12 +126,10 @@ public class DeviceController extends BaseController {
    //导入设备报表
    @PostMapping(value = "importData")
    public Envelop importData(HttpServletRequest request) {
    public Envelop importData(@ApiParam(value = "文件", required = true)
                              @RequestParam(value = "file", required = true) MultipartFile file) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            Workbook workbook = ExcelUtils.getWorkBook(file);
            deviceService.importData(workbook);
            return Envelop.getSuccess("操作成功");
        } catch (Exception e) {
@ -177,7 +175,7 @@ public class DeviceController extends BaseController {
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
        write(jxl.Workbook.createWorkbook(os), ls);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {

+ 23 - 8
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceService.java

@ -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<>();
		//设备名称