package com.ld.igds.modbus;
|
|
import com.bstek.dorado.annotation.DataProvider;
|
import com.bstek.dorado.annotation.DataResolver;
|
import com.bstek.dorado.annotation.Expose;
|
import com.ld.igds.constant.BizType;
|
import com.ld.igds.modbus.service.HModbusService;
|
import com.ld.igds.models.DeviceModbus;
|
import com.ld.igds.models.GasModbus;
|
import com.ld.igds.util.ContextUtil;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* MOOBUS-TCP设备参数配置
|
*/
|
@Component
|
public class GasModbusPR {
|
|
@Resource
|
private HModbusService modbusService;
|
|
/**
|
* gasModbusPR#getGasData
|
*
|
* @return
|
*/
|
@DataProvider
|
public DeviceModbus getGasData(String depotId) {
|
if (null == depotId) return new DeviceModbus();
|
|
String bizType = BizType.GAS.getCode();
|
|
String companyId = ContextUtil.getCompanyId();
|
|
DeviceModbus result = modbusService.getGasData(companyId, depotId, bizType);
|
|
if (null == result) {
|
result = new DeviceModbus();
|
result.setBizType(bizType);
|
result.setDeviceCode(depotId);
|
result.setListGas(new ArrayList<>());
|
}
|
|
return result;
|
}
|
|
/**
|
* gasModbusPR#listGasModBus
|
*
|
* @param depotId
|
* @return
|
*/
|
@DataProvider
|
public List<GasModbus> listGasModBus(String depotId) {
|
return modbusService.listGasModBus(depotId);
|
}
|
|
|
/**
|
* gasModbusPR#updateData
|
* @param data
|
*/
|
@DataResolver
|
public void updateData(DeviceModbus data){
|
modbusService.updateGasModbus(data);
|
}
|
|
/**
|
* gasModbusPR#flushCache
|
*
|
* @return
|
*/
|
@Expose
|
public void flushCache() {
|
String companyId = ContextUtil.getCompanyId();
|
modbusService.flushCacheGas(companyId);
|
}
|
|
/**
|
* deviceModbusPR#delData
|
*
|
* @return
|
*/
|
@Expose
|
public String delData(GasModbus data) {
|
if (null == data.getId()) return null;
|
return modbusService.delDataGas(data);
|
}
|
|
}
|