| | |
| | | import com.bstek.dorado.data.entity.EntityState; |
| | | import com.bstek.dorado.data.entity.EntityUtils; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.fzzy.common.constant.BizTypeEnum; |
| | | import com.fzzy.igds.data.DeviceIotParam; |
| | | import com.fzzy.igds.domain.DeviceIot; |
| | | import com.fzzy.igds.service.DeviceIotService; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | |
| | | @Component |
| | | public class DeviceIotPR { |
| | | |
| | | @Resource |
| | | private DeviceIotService deviceIotService; |
| | | @Resource |
| | | private DeviceIotService deviceIotService; |
| | | |
| | | /** |
| | | * 查询设备,将操作信息调整为空 |
| | | * |
| | | * deviceIotPR#loadDeviceIotPage |
| | | * |
| | | * @param page |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public void loadDeviceIotPage(Page<DeviceIot> page, DeviceIotParam param) { |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page<DeviceIot> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNo(), page.getPageSize()); |
| | | /** |
| | | * 查询设备,将操作信息调整为空 |
| | | * <p> |
| | | * deviceIotPR#loadDeviceIotPage |
| | | * |
| | | * @param page |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public void loadDeviceIotPage(Page<DeviceIot> page, DeviceIotParam param) { |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page<DeviceIot> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNo(), page.getPageSize()); |
| | | |
| | | if(null == param) { |
| | | param = new DeviceIotParam(); |
| | | } |
| | | deviceIotService.listPageData(corePage, param); |
| | | if (null == param) { |
| | | param = new DeviceIotParam(); |
| | | } |
| | | deviceIotService.listPageData(corePage, param); |
| | | |
| | | // 重新封装 |
| | | page.setEntities(corePage.getRecords()); |
| | | page.setEntityCount(Integer.parseInt(String.valueOf(corePage.getTotal()))); |
| | | } |
| | | // 重新封装 |
| | | page.setEntities(corePage.getRecords()); |
| | | page.setEntityCount(Integer.parseInt(String.valueOf(corePage.getTotal()))); |
| | | } |
| | | |
| | | /** |
| | | * 保存 devicePR#saveAll |
| | | * |
| | | * @param depotDeviceIots |
| | | * @return |
| | | */ |
| | | @DataResolver |
| | | @Transactional |
| | | public String saveAll(List<DeviceIot> depotDeviceIots) { |
| | | String msg = ""; |
| | | DeviceIot deviceIot; |
| | | for (DeviceIot depotDeviceIot : depotDeviceIots) { |
| | | EntityState state = EntityUtils.getState(depotDeviceIot); |
| | | deviceIot = new DeviceIot(); |
| | | BeanUtils.copyProperties(depotDeviceIot, deviceIot); |
| | | if (state == EntityState.NEW) { |
| | | deviceIotService.updateDeviceIot(deviceIot); |
| | | msg = "添加成功!"; |
| | | } |
| | | if (state == EntityState.DELETED) { |
| | | deviceIotService.delDepotDeviceIot(deviceIot); |
| | | msg = "删除成功!"; |
| | | } |
| | | if (state == EntityState.MODIFIED) { |
| | | deviceIotService.updateDeviceIot(deviceIot); |
| | | msg = "修改成功!"; |
| | | } |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * devicePR#refreshCache |
| | | */ |
| | | @Expose |
| | | public void refreshCache(){ |
| | | deviceIotService.refreshCache(null); |
| | | } |
| | | /** |
| | | * 保存 devicePR#saveAll |
| | | * |
| | | * @param depotDeviceIots |
| | | * @return |
| | | */ |
| | | @DataResolver |
| | | @Transactional |
| | | @Log(title = "Iot设备配置", businessType = BusinessType.OTHER, bizType = BizTypeEnum.SYS) |
| | | public String saveAll(List<DeviceIot> depotDeviceIots) { |
| | | String msg = ""; |
| | | DeviceIot deviceIot; |
| | | for (DeviceIot depotDeviceIot : depotDeviceIots) { |
| | | EntityState state = EntityUtils.getState(depotDeviceIot); |
| | | deviceIot = new DeviceIot(); |
| | | BeanUtils.copyProperties(depotDeviceIot, deviceIot); |
| | | if (state == EntityState.NEW) { |
| | | deviceIotService.updateDeviceIot(deviceIot); |
| | | msg = "添加成功!"; |
| | | } |
| | | if (state == EntityState.DELETED) { |
| | | deviceIotService.delDepotDeviceIot(deviceIot); |
| | | msg = "删除成功!"; |
| | | } |
| | | if (state == EntityState.MODIFIED) { |
| | | deviceIotService.updateDeviceIot(deviceIot); |
| | | msg = "修改成功!"; |
| | | } |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * devicePR#refreshCache |
| | | */ |
| | | @Expose |
| | | public void refreshCache() { |
| | | deviceIotService.refreshCache(null); |
| | | } |
| | | } |