自动化立体仓库 - WCS系统
#
tqs
2022-09-07 470962be1cfdbf75b734ab8f78e28a7b23a06964
src/main/java/com/zy/core/thread/ScaleThread.java
@@ -1,6 +1,9 @@
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;
@@ -43,6 +46,19 @@
                    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);