DeviceParmServiceImpl.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.huaxu.service.impl;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.huaxu.dao.DeviceParmMapper;
  5. import com.huaxu.entity.DeviceParmEntity;
  6. import com.huaxu.model.LoginUser;
  7. import com.huaxu.service.DeviceParmService;
  8. import com.huaxu.util.UserUtil;
  9. import org.springframework.stereotype.Service;
  10. import javax.annotation.Resource;
  11. import java.util.Collection;
  12. import java.util.Date;
  13. import java.util.List;
  14. /**
  15. * @description 设备参数
  16. * @auto wangli
  17. * @data 2020-11-17 11:02
  18. */
  19. @Service
  20. public class DeviceParmServiceImpl implements DeviceParmService {
  21. @Resource
  22. private DeviceParmMapper deviceParmMapper;
  23. @Override
  24. public DeviceParmEntity selectById(Integer id) {
  25. return deviceParmMapper.selectById(id);
  26. }
  27. @Override
  28. public List<DeviceParmEntity> selectByDeviceId(Integer id) {
  29. return deviceParmMapper.selectByDeviceId(id);
  30. }
  31. @Override
  32. public Integer insert(DeviceParmEntity deviceParmEntity) {
  33. LoginUser loginUser = UserUtil.getCurrentUser();
  34. deviceParmEntity.setDateUpdate(new Date());
  35. deviceParmEntity.setUpdateBy(loginUser.getUsername());
  36. deviceParmEntity.setDateCreate(new Date());
  37. deviceParmEntity.setCreateBy(loginUser.getUsername());
  38. deviceParmEntity.setStatus(1);
  39. deviceParmEntity.setTenantId(loginUser.getTenantId());
  40. return deviceParmMapper.insert(deviceParmEntity);
  41. }
  42. @Override
  43. public Integer batchInsert(List<DeviceParmEntity> deviceParmEntities){
  44. LoginUser loginUser = UserUtil.getCurrentUser();
  45. for(DeviceParmEntity deviceParmEntity:deviceParmEntities){
  46. deviceParmEntity.setDateUpdate(new Date());
  47. deviceParmEntity.setUpdateBy(loginUser.getUsername());
  48. deviceParmEntity.setDateCreate(new Date());
  49. deviceParmEntity.setCreateBy(loginUser.getUsername());
  50. deviceParmEntity.setStatus(1);
  51. deviceParmEntity.setTenantId(loginUser.getTenantId());
  52. }
  53. return deviceParmMapper.batchInsert(deviceParmEntities);
  54. }
  55. @Override
  56. public Integer delete(Integer id) {
  57. return deviceParmMapper.deleteById(id);
  58. }
  59. @Override
  60. public Integer update(DeviceParmEntity deviceParmEntity) {
  61. return deviceParmMapper.update(deviceParmEntity);
  62. }
  63. @Override
  64. public void batchUpdate(List<DeviceParmEntity> deviceParmEntities) {
  65. LoginUser loginUser = UserUtil.getCurrentUser();
  66. for(DeviceParmEntity deviceParmEntity:deviceParmEntities){
  67. deviceParmEntity.setDateUpdate(new Date());
  68. deviceParmEntity.setUpdateBy(loginUser.getUsername());
  69. deviceParmMapper.update(deviceParmEntity);
  70. }
  71. }
  72. @Override
  73. public boolean saveOrUpdateBatch(Collection<DeviceParmEntity> entityList) {
  74. for (DeviceParmEntity item : entityList) {
  75. if (item.getId() == null) {
  76. this.insert(item);
  77. } else {
  78. this.update(item);
  79. }
  80. }
  81. return true;
  82. }
  83. @Override
  84. public List<DeviceParmEntity> selectList(DeviceParmEntity deviceParmEntity) {
  85. return deviceParmMapper.selectList(deviceParmEntity);
  86. }
  87. @Override
  88. public IPage<DeviceParmEntity> selectPage(IPage<DeviceParmEntity> page, DeviceParmEntity deviceParmEntity) {
  89. return deviceParmMapper.selectPage(page,deviceParmEntity);
  90. }
  91. }