| | |
| | | package com.zy.core.thread; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.core.Slave; |
| | | import com.zy.core.ThreadHandler; |
| | | import lombok.Data; |
| | |
| | | String s = new String(read); |
| | | if (!Cools.isEmpty(s) && s.startsWith("=")) { |
| | | scale = Double.parseDouble(s.substring(1)); |
| | | |
| | | //将称重重量写入设备基础数据中的gross_wt字段 |
| | | if(scale > 20) { |
| | | BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); |
| | | Integer staNo = slave.getId() == 1 ? 101 : 201; |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | if(!Cools.isEmpty(basDevp)) { |
| | | basDevp.setGrossWt(scale); |
| | | if (null != basDevpService && !basDevpService.updateById(basDevp)) { |
| | | throw new Exception("更新数据库数据失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Thread.sleep(100); |