package com.ld.igds.view;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.ld.igds.view.manager.SysGrainMacManager;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.bstek.dorado.annotation.DataProvider;
|
import com.bstek.dorado.annotation.DataResolver;
|
import com.bstek.dorado.annotation.Expose;
|
import com.ld.igds.models.DeviceSer;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.view.service.DeviceSerService;
|
|
/**
|
* 当前业务使用两个入口DeviceSerPR 和 DeviceSerPR2
|
*
|
* @author: andy.jia
|
* @description:
|
* @version:
|
* @data:2019年12月21日
|
*
|
*/
|
@Component
|
public class DeviceSerPR {
|
|
@Autowired
|
private DeviceSerService deviceService;
|
@Autowired
|
private SysGrainMacManager sysGrainMacManager;
|
|
// deviceSerPR#getAllSer
|
@DataProvider
|
public List<DeviceSer> getAllSer() throws Exception {
|
return deviceService.getAllSer(null);
|
}
|
|
// deviceSerPR#updateSer
|
@DataResolver
|
public void updateSer(DeviceSer data) throws Exception {
|
deviceService.saveSer(data);
|
}
|
|
// ${dorado.getDataProvider("deviceSerPR#getAllSerCache").getResult()}
|
@DataProvider
|
public List<DeviceSer> getAllSerCache() {
|
return deviceService.getAllSerCache(ContextUtil.getCompanyId());
|
}
|
|
// ${dorado.getDataProvider("deviceSerPR#getSerCacheByType").getResult("01")}
|
@DataProvider
|
public List<DeviceSer> getSerCacheByType(String type) {
|
List<DeviceSer> listAll = deviceService.getAllSerCache(ContextUtil.getCompanyId());
|
if (null == listAll || listAll.isEmpty())
|
return null;
|
|
if (null == type)
|
return listAll;
|
|
List<DeviceSer> result = new ArrayList<DeviceSer>();
|
for (DeviceSer ser : listAll) {
|
if (ser.getType().equals(type))
|
result.add(ser);
|
}
|
return result;
|
}
|
|
/**
|
* 根据分机id和名称删除分机
|
*
|
*/
|
@Expose
|
@Transactional
|
public void delSerById(String id) {
|
DeviceSer ser = this.getDataById(id);
|
sysGrainMacManager.destoryCon(ser);
|
|
deviceService.delSerById(id);
|
}
|
|
/**
|
* deviceSerPR#getDataById
|
*
|
*/
|
@Expose
|
public DeviceSer getDataById(String id) {
|
return deviceService.getDataById(ContextUtil.getCompanyId(),id);
|
}
|
|
/**
|
* deviceSerPR#refreshCache
|
*
|
* @Title: refreshCache
|
* @Description: 刷新缓存 void
|
* @throws
|
*/
|
@Expose
|
public void refreshCache() {
|
deviceService.refreshCache(ContextUtil.getCompanyId());
|
}
|
}
|