|
|
|
@ -9,6 +9,7 @@ import com.psdc.mapper.PsdcControlLogMapper; |
|
|
|
|
import com.psdc.mapper.PsdcDeviceMapper; |
|
|
|
|
import com.psdc.service.IPsdcDeviceService; |
|
|
|
|
import com.psdc.utils.SecurityUtils; |
|
|
|
|
import com.psdc.utils.poi.ExcelUtil; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
@ -114,11 +116,23 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = REQUIRES_NEW) |
|
|
|
|
public boolean daoruDevicesData(MultipartFile file) { |
|
|
|
|
public boolean daoruDevicesData(MultipartFile file, String cjr) { |
|
|
|
|
try { |
|
|
|
|
//需要将上传文件转成Stream流
|
|
|
|
|
// 需要将上传文件转成Stream流
|
|
|
|
|
InputStream in = file.getInputStream(); |
|
|
|
|
// EasyExcel.read(in, PsdcDevice.class, new DevicesDataListener(psdcDeviceMapper)).sheet().sheetNo(0).doRead();
|
|
|
|
|
ExcelUtil<PsdcDevice> util = new ExcelUtil<>(PsdcDevice.class); |
|
|
|
|
List<PsdcDevice> devices = util.importExcel(in); |
|
|
|
|
for (PsdcDevice pd : devices){ |
|
|
|
|
pd.setCreateBy(cjr); |
|
|
|
|
pd.setCreateTime(new Date()); |
|
|
|
|
pd.setDeviceType(Integer.parseInt(pd.getDevType())); |
|
|
|
|
// 新导入的设备默认状态为: 未激活
|
|
|
|
|
// 新导入的设备默认启动时间为null,请在设备激活后手动修改!
|
|
|
|
|
pd.setDeviceStatus(1); |
|
|
|
|
// 新导入的设备默认运行状态为: 关闭
|
|
|
|
|
pd.setDeviceRunstatus(2); |
|
|
|
|
} |
|
|
|
|
psdcDeviceMapper.saveDevicesData(devices); |
|
|
|
|
return true; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|