| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.product.admin.config.CmnConst; |
| | | import com.product.core.config.Global; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.device.config.DeviceConst; |
| | | import com.product.module.sys.service.UserService; |
| | | |
| | |
| | | |
| | | /** |
| | | * 设备管理 |
| | | * @Author |
| | | * @Author |
| | | * @Date 2022/3/8 16:33 |
| | | * @Desc 功能相关 service |
| | | */ |
| | |
| | | /** |
| | | * 获取设备信息 包括子设备 |
| | | * @param uuid |
| | | * @param device_sn |
| | | * @return |
| | | */ |
| | | public FieldSetEntity findDeviceAndSub(String uuid,String asset_code) { |
| | | FieldSetEntity dev=findDevice(uuid,asset_code); |
| | | if(dev !=null) { |
| | | DataTableEntity dt=baseDao.listTable(DeviceConst.TABLE_PRODUCT_DEVICE_ARCHIVE,"parent_sn=?", new String[] {asset_code},new String[]{"uuid","device_name","asset_code","device_version","device_status"}); |
| | | public FieldSetEntity findDeviceAndSub(String uuid,String device_number) { |
| | | FieldSetEntity dev=findDevice(uuid); |
| | | if(dev !=null && "device".equals(Global.getSystemConfig("system_platform_type", "")) ) { |
| | | DataTableEntity dt=baseDao.listTable(DeviceConst.PRODUCT_DEVICE_INFO,"uuid=?", new String[] {uuid},new String[]{}); |
| | | if(!DataTableEntity.isEmpty(dt)) { |
| | | baseDao.loadPromptData(dt); |
| | | Map <String,DataTableEntity> sub=new HashMap<>(); |
| | |
| | | //dev.addSubDataTable(dt); |
| | | } |
| | | } |
| | | |
| | | |
| | | return dev; |
| | | } |
| | | /** |
| | | * 获取设备信息 包括子设备 |
| | | * @param uuid |
| | | * @param device_sn |
| | | * @param asset_code |
| | | * @return |
| | | */ |
| | | public FieldSetEntity findDevice(String uuid,String asset_code) { |
| | | public FieldSetEntity findDevice(String uuid) { |
| | | StringBuilder st=new StringBuilder(); |
| | | List<String> pa=new ArrayList<String>(); |
| | | if(!StringUtils.isEmpty(asset_code)) { |
| | | st.append("asset_code=?"); |
| | | pa.add(asset_code); |
| | | } |
| | | if(!StringUtils.isEmpty(uuid)) { |
| | | if(st.length()>0) { |
| | | st.append(" and "); |
| | | } |
| | | st.append("uuid=?"); |
| | | pa.add(uuid); |
| | | }else { |
| | | return null; |
| | | } |
| | | |
| | | FieldSetEntity dev=baseDao.getFieldSetEntityByFilter(DeviceConst.TABLE_PRODUCT_DEVICE_ARCHIVE, new String[]{"uuid","device_name","asset_code","device_version","device_status"}, st.toString(), pa.toArray(), false, null); |
| | | FieldSetEntity dev=baseDao.getFieldSetEntityByFilter(DeviceConst.PRODUCT_DEVICE_INFO, new String[]{}, st.toString(), pa.toArray(), false, null); |
| | | baseDao.loadPromptData(dev); |
| | | return dev; |
| | | } |
| | |
| | | * 如果有子设备,需要把子设备状态一起变更 |
| | | * @return |
| | | */ |
| | | public boolean deviceStatusChange(String asset_code,String status) { |
| | | return baseDao.executeUpdate("update product_device_archives set device_status=? where asset_code=? or parent_sn=?",new String[] {status,asset_code,asset_code}); |
| | | public boolean deviceStatusChange(String device_number,String status) { |
| | | return baseDao.executeUpdate("update product_device_info set device_status=? where device_number=?",new String[] {status,device_number}); |
| | | } |
| | | /** |
| | | * 添加设备运行记录 |
| | |
| | | * @return |
| | | */ |
| | | public boolean appendDeivceManageLog(String asset_code,String user,String type,String log,String table,String uuid ) { |
| | | |
| | | |
| | | return true; |
| | | } |
| | | /** |
| | |
| | | sql.append("\nselect technician ,'技术负责人' from product_device_archives where asset_code='").append(asset_code).append("' union"); |
| | | sql.append("\nselect safety_manager ,'安全管理员' from product_device_archives where asset_code='").append(asset_code).append("'"); |
| | | sql.append("\n) b left join product_sys_users a on b.userid=a.user_id"); |
| | | |
| | | |
| | | DataTableEntity dte = baseDao.listTable(sql.toString(), new Object[]{}); |
| | | // dte.getMeta().addAliasTable("product_sys_users", "a"); |
| | | // dte.getMeta().addAliasTable("product_device_archives", "b"); |
| | |
| | | } |
| | | |
| | | return dte; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |