DeviceService.java
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.common.constants.Constants;
import cn.com.glsx.stdinterface.modules.entity.Device;
import cn.com.glsx.stdinterface.modules.mapper.DeviceMapper;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @BelongsProject: ne-shield-standard-interfaces
* @BelongsPackage: cn.com.glsx.stdinterface.modules.service
* @Author: dell_xw
* @CreateTime: 2022-04-19 13:26
* @Description: TODO
* @Version: 1.0
*/
@Slf4j
@Service
public class DeviceService {
@Autowired
private DeviceMapper deviceMapper;
public boolean updateDeviceActived(String sn, Integer actived) {
if (StringUtils.isBlank(sn) || actived==null) {
return false;
}
log.info("update device actived status sn:{},status:{}", sn, actived);
Device selectCondition = new Device();
selectCondition.setSn(sn);
Device device = deviceMapper.selectOne(selectCondition);
log.info("update device actived status device:{}", JSONObject.toJSONString(device));
if (device!=null) {
device.setActivateStatus((byte) Constants.DeviceActived.ACTIVED);
device.setActivateTime(new Date());
device.setUpdatedDate(new Date());
deviceMapper.updateByPrimaryKeySelective(device);
}
return true;
}
}