Parcourir la source

修改设备出入库功能

humingfen il y a 4 ans
Parent
commit
8257e6a280

+ 1 - 1
app/app-iot-server/src/main/java/com/yihu/iot/util/excel/reader/IotDeviceImportVOReader.java

@ -16,7 +16,7 @@ public class IotDeviceImportVOReader extends AExcelReader {
            Sheet sheet = rwb.getSheet(0) ;
            for (int i = 1; i < sheet.getRows(); i++) {
                IotDeviceImportVO device = new IotDeviceImportVO();
                device.setSn(getCellCont(sheet, i, 0));
                device.setDeviceSn(getCellCont(sheet, i, 0));
                device.setHospital(getCellCont(sheet, i, 1));
                device.setSim(getCellCont(sheet, i, 2).trim());

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -63,6 +63,7 @@ public class IotRequestMapping {
        public static final String message_fail_upload = "上传失败";
        public static final String message_fail_upload_format = "不支持该文件格式上传";
        public static final String message_fail_jsonData_is_null = "jsonData is null";
        public static final String message_success_download= "下载成功";
    }
    /**
@ -230,6 +231,7 @@ public class IotRequestMapping {
        public static final String importDevice = "importDevice";
        public static final String isImportDevice = "isImportDevice";
        public static final String uploadDeviceInfo = "uploadDeviceInfo";
        public static final String downloadTemplate = "downloadTemplate";
        public static final String queryImportRecordPage = "queryImportRecordPage";

+ 15 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java

@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -280,7 +281,7 @@ public class IotDeviceController extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = IotRequestMapping.Device.uploadDeviceInfo)
    /*@PostMapping(value = IotRequestMapping.Device.uploadDeviceInfo)
    @ApiOperation(value = "导入设备sn码相关信息", notes = "导入设备sn码相关信息")
    public MixEnvelop<IotDeviceImportVO, IotDeviceImportVO> uploadStream(@ApiParam(value = "文件", required = true)
                                                                                     @RequestParam(value = "file", required = true) MultipartFile file,
@ -289,7 +290,19 @@ public class IotDeviceController extends EnvelopRestEndpoint {
            return iotDeviceService.uploadStream(file, request);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload);
        }
    }
    @PostMapping(value = IotRequestMapping.Device.downloadTemplate)
    @ApiOperation(value = "下载导入sn码相关信息模板", notes = "下载导入sn码相关信息模板")
    public MixEnvelop downloadTemplate(HttpServletRequest request, HttpServletResponse response) {
        try {
            iotDeviceService.downloadTemplate(request, response);
            return MixEnvelop.getSuccess(IotRequestMapping.FileUpload.message_success_download);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload);
        }
    }*/
}

+ 2 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceImportRecordService.java

@ -76,7 +76,7 @@ public class IotDeviceImportRecordService extends BaseJpaService<IotDeviceImport
        HSSFCell cell2 = row.createCell(2);
        HSSFCell cell3 = row.createCell(3);
        //设置单元格的值
        cell0.setCellValue(vo.getSn());
        cell0.setCellValue(vo.getDeviceSn());
        cell1.setCellValue(vo.getHospital());
        cell2.setCellValue(vo.getSim());
        cell3.setCellValue(msg);
@ -103,7 +103,7 @@ public class IotDeviceImportRecordService extends BaseJpaService<IotDeviceImport
                    addRow(sheet,rowNum,iotDeviceImportVO,errorMsg);
                    continue;
                }
                String sn = iotDeviceImportVO.getSn();
                String sn = iotDeviceImportVO.getDeviceSn();
                String hos = iotDeviceImportVO.getHospital();
                String sim = iotDeviceImportVO.getSim();

+ 8 - 8
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java

@ -109,10 +109,16 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
            for (IotDeviceDO deviceDO : deviceDOS) {
                String deviceSn = deviceDO.getDeviceSn();
                Integer type = deviceInventoryLogDO.getType();//调拨类型(1入库 2设备调拨出库 3核销出库)
                //设备出库,更换相关信息
                if (type.equals("1")) {
                    deviceDO.setSaasId(getCode());
                } else {
                    deviceDO.setProductId(jsonObject.getString("productId"));
                    deviceDO.setName(jsonObject.getString("name"));
                    deviceDO.setCategoryCode(jsonObject.getString("categoryCode"));
                    deviceDO.setCategoryName(jsonObject.getString("categoryName"));
                    deviceDO.setManufacturerId(jsonObject.getString("manufacturerId"));
                    deviceDO.setManufacturerName(jsonObject.getString("manufacturerName"));
                } else {//设备出库,更换相关信息
                    deviceDO = iotDeviceDao.findByDeviceSn(deviceSn);
                    if (type.equals("3")) {
                        deviceDO.setDel(0);
@ -123,12 +129,6 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
                        continue;
                    }
                }
                deviceDO.setProductId(jsonObject.getString("productId"));
                deviceDO.setName(jsonObject.getString("name"));
                deviceDO.setCategoryCode(jsonObject.getString("categoryCode"));
                deviceDO.setCategoryName(jsonObject.getString("categoryName"));
                deviceDO.setManufacturerId(jsonObject.getString("manufacturerId"));
                deviceDO.setManufacturerName(jsonObject.getString("manufacturerName"));
                deviceDO.setHospital(jsonObject.getString("hospital"));
                deviceDO.setHospitalName(jsonObject.getString("hospitalName"));
                if (StringUtils.isNotBlank(orderId)) {

+ 22 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -29,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -491,4 +493,24 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
//        IotDeviceImportRecordVO vo = this.importDevice(null,fileName,null,importVOList);
        return MixEnvelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, importVOList);
    }
    public void downloadTemplate(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String path = IotDeviceService.class.getResource("/").getPath().replace("/WEB-INF/classes/", "")
                + File.separator + "deviceTemplate.xls";
        InputStream inputStream = new FileInputStream(path);
        OutputStream outputStream = response.getOutputStream();
        byte[] b = new byte[2048];
        int length = 0;
        while ((length = inputStream.read(b)) > 0) {
            outputStream.write(b, 0, length);
        }
        outputStream.flush();
        if (outputStream != null) {
            outputStream.close();
        }
        if (inputStream != null) {
            inputStream.close();
        }
    }
}