gaodd преди 3 години
родител
ревизия
9ed9f9b414

+ 41 - 26
src/main/java/com/unissoft/interaction/service/impl/SquareServiceImpl.java

@@ -32,7 +32,7 @@ public class SquareServiceImpl implements SquareService {
32 32
 
33 33
     private static final Logger logger = LoggerFactory.getLogger(SquareServiceImpl.class);
34 34
 
35
-    static String base_url = "http://192.168.0.61:4017/";
35
+    //static String base_url = "http://192.168.0.61:4017/";
36 36
     static boolean flag = true;
37 37
     /*static double houseWideOn;
38 38
     static double houseWideUnder;
@@ -96,8 +96,11 @@ public class SquareServiceImpl implements SquareService {
96 96
             teData.setRotationxy(rotationxy);
97 97
             logger.info("第一次打点数据{}",teData);
98 98
 
99
+            //ip地址
100
+            String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
101
+            
99 102
             //发送给硬件
100
-            postHelper(teData);
103
+            postHelper(teData,base_url);
101 104
             //第一次打点标识
102 105
             flag = true;
103 106
         }else{
@@ -123,31 +126,43 @@ public class SquareServiceImpl implements SquareService {
123 126
             //根据仓房id查询其信息
124 127
         	String taskId = teData.getTaskID();
125 128
         	String houseId = taskId.split(",")[0];//仓房id
126
-        	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------待完
127 129
         	
128
-        	double houseWideOn = 0;
129
-            double houseWideUnder = 0;
130
-            double houseLengthLeft = 0;
131
-            double houseLengthRight = 0;
132
-            double houseHight = 0;
133
-            
134
-            
135
-        	//计算以粮面为基准面的高
136
-            List<Double> zlist = SquareAlg.zHeight(teData.getRotationxy(),houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
137
-            double zHeight = Collections.max(zlist);//纵坐标的最大值
138
-            double secondH = houseHight - zHeight;//仓房的高-点的纵坐标
139
-            logger.info("以粮面为基准面的高secondH {}",secondH);
140
-
141
-            //打点
142
-            String rotationxy = SquareAlg.getAveragePosition(houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight, secondH);
143
-            teData.setRotationxy(rotationxy);
144
-            teData.setStime(new Date());//第二次开始的时间
130
+        	//查询设备的ip和端口
131
+            QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
132
+            queryWrapper.eq("house_id", Integer.parseInt(houseId));
133
+            List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
145 134
             
146
-            //发送给硬件
147
-            postHelper(teData);
148
-
149
-            //打点次数的标识
150
-            flag = false;
135
+            if(hardList.size()>0){
136
+            	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));//--------------------待完
137
+            	
138
+            	double houseWideOn = 0;
139
+                double houseWideUnder = 0;
140
+                double houseLengthLeft = 0;
141
+                double houseLengthRight = 0;
142
+                double houseHight = 0;
143
+                
144
+                
145
+            	//计算以粮面为基准面的高
146
+                List<Double> zlist = SquareAlg.zHeight(teData.getRotationxy(),houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight,houseHight);
147
+                double zHeight = Collections.max(zlist);//纵坐标的最大值
148
+                double secondH = houseHight - zHeight;//仓房的高-点的纵坐标
149
+                logger.info("以粮面为基准面的高secondH {}",secondH);
150
+
151
+                //打点
152
+                String rotationxy = SquareAlg.getAveragePosition(houseWideOn,houseWideUnder,houseLengthLeft,houseLengthRight, secondH);
153
+                teData.setRotationxy(rotationxy);
154
+                teData.setStime(new Date());//第二次开始的时间
155
+                
156
+                //IP地址
157
+                String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
158
+                
159
+                //发送给硬件
160
+                postHelper(teData,base_url);
161
+
162
+                //打点次数的标识
163
+                flag = false;
164
+            }
165
+        	
151 166
         } else { 
152 167
         	//打点两次完毕 计算体积
153 168
             double v = this.calculateVolume(teData.getTaskID());
@@ -165,7 +180,7 @@ public class SquareServiceImpl implements SquareService {
165 180
         return teDataMapper.insert(teData);
166 181
     }
167 182
 
168
-    public ReMsg postHelper(TeData teData) {
183
+    public ReMsg postHelper(TeData teData,String base_url) {
169 184
 
170 185
         logger.info("in ...... postHelper teData{}",teData);
171 186
 

+ 43 - 26
src/main/java/com/unissoft/interaction/service/impl/TeDataServiceImpl.java

@@ -39,7 +39,7 @@ public class TeDataServiceImpl implements TeDataService {
39 39
 
40 40
     private static final Logger logger = LoggerFactory.getLogger(TeDataServiceImpl.class);
41 41
 
42
-    static String base_url = "http://192.168.0.61:4017/";
42
+    //static String base_url = "http://192.168.0.61:4017/";
43 43
     static boolean flag = true;
44 44
     static double h1 = 6; //h1 圆锥的高
45 45
     static double h2 = 3; //h2 水平地面到圆锥尖的高
@@ -81,6 +81,7 @@ public class TeDataServiceImpl implements TeDataService {
81 81
      */
82 82
     @Override
83 83
     public void scanTask(double diameter, double high) {
84
+    	String base_url = "http://192.168.0.61:4017/";
84 85
         logger.info("圆筒仓第一次打点的直径和高: {},{}",diameter,high);
85 86
         STask task = new STask();
86 87
         Date date = new Date();
@@ -100,7 +101,7 @@ public class TeDataServiceImpl implements TeDataService {
100 101
 
101 102
         logger.info("scanTask sTaskMapper teDataMapper {},{}",task,teData);
102 103
 
103
-        postHelper(teData);
104
+        postHelper(teData,base_url);
104 105
         //equipmentTestingEnd
105 106
         flag = true;
106 107
 
@@ -129,6 +130,8 @@ public class TeDataServiceImpl implements TeDataService {
129 130
             teData.setEquipmentID(hardList.get(0).getDeviceCode());//设备id
130 131
             teData.setTaskID(cfId+","+ task.getId());//拼接一个仓房id
131 132
             teData.setStime(date);
133
+            //IP地址
134
+            String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
132 135
 
133 136
             // 第一次待打点
134 137
             String rotationxy = CylinderAlg.getAveragePosition(diameter, h);
@@ -136,7 +139,7 @@ public class TeDataServiceImpl implements TeDataService {
136 139
             logger.info("第一次打点的数据{}",teData);
137 140
             
138 141
             //发送给硬件
139
-            postHelper(teData);
142
+            postHelper(teData,base_url);
140 143
            
141 144
             flag = true;
142 145
             
@@ -168,29 +171,43 @@ public class TeDataServiceImpl implements TeDataService {
168 171
         	
169 172
         	String taskId = teData.getTaskID();
170 173
         	String houseId = taskId.split(",")[0];//仓房id
171
-        	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
172
-        	String high = orgInfoHouse.getHigh();//仓房的高
173
-    		String radius = orgInfoHouse.getRadius();//仓房的半径
174
-    		Double diameter = Double.parseDouble(radius)*2;//直径
175
-    		Double h = Double.parseDouble(high);
176
-    		
177
-            //double zHeight = CylinderAlg.zHeight(teData.getRotationxy(), diameter, h);
178 174
             
179
-    		List<Double> zList = CylinderAlg.getValidZ(teData.getRotationxy(), diameter, h);
180
-    		double z = Collections.max(zList);//纵坐标的最大值
181
-    		//第二次打点的高
182
-    		double secondH = h - z;//仓房的高-点的纵坐标
183
-            logger.info("z {} ,diameter {},secondH {}",z,diameter,secondH);
184
-
185
-            //打点
186
-            String rotationxy = CylinderAlg.getAveragePosition(diameter, secondH);
187
-            teData.setRotationxy(rotationxy);
188
-            teData.setStime(new Date());//第二次开始的时间
175
+            //查询设备的ip和端口
176
+            QueryWrapper<HardwareParameter> queryWrapper = new QueryWrapper<>();
177
+            queryWrapper.eq("house_id", Integer.parseInt(houseId));
178
+            List<HardwareParameter> hardList = hardwareParameterMapper.selectList(queryWrapper);
179
+            
180
+            if(hardList.size()>0){
181
+            	
182
+            	OrgInfo orgInfoHouse = orgInfoMapper.selectById(Integer.parseInt(houseId));
183
+            	String high = orgInfoHouse.getHigh();//仓房的高
184
+        		String radius = orgInfoHouse.getRadius();//仓房的半径
185
+        		Double diameter = Double.parseDouble(radius)*2;//直径
186
+        		Double h = Double.parseDouble(high);
187
+        		
188
+                //double zHeight = CylinderAlg.zHeight(teData.getRotationxy(), diameter, h);
189
+                
190
+        		List<Double> zList = CylinderAlg.getValidZ(teData.getRotationxy(), diameter, h);
191
+        		double z = Collections.max(zList);//纵坐标的最大值
192
+        		//第二次打点的高
193
+        		double secondH = h - z;//仓房的高-点的纵坐标
194
+                logger.info("z {} ,diameter {},secondH {}",z,diameter,secondH);
195
+
196
+                //打点
197
+                String rotationxy = CylinderAlg.getAveragePosition(diameter, secondH);
198
+                teData.setRotationxy(rotationxy);
199
+                teData.setStime(new Date());//第二次开始的时间
200
+                
201
+            	//IP地址
202
+                String base_url = "http://"+hardList.get(0).getIpAdress()+":"+hardList.get(0).getPort()+"/";
203
+                
204
+            	//发送给硬件打点数据
205
+                postHelper(teData,base_url);
206
+
207
+                flag = false;
208
+            }
209
+            
189 210
             
190
-            //发送给硬件打点数据
191
-            postHelper(teData);
192
-
193
-            flag = false;
194 211
         } else { 
195 212
         	//打点两次完毕 计算体积
196 213
             double v = this.calculateVolume(teData.getTaskID());
@@ -207,7 +224,7 @@ public class TeDataServiceImpl implements TeDataService {
207 224
         return teDataMapper.insert(teData);
208 225
     }
209 226
 
210
-    public ReMsg postHelper(TeData teData) {
227
+    public ReMsg postHelper(TeData teData,String base_url) {
211 228
 
212 229
         logger.info("in ...... postHelper teData{}",teData);
213 230
 
@@ -391,7 +408,7 @@ public class TeDataServiceImpl implements TeDataService {
391 408
     	JSONArray jsonArray=JSONArray.parseArray(xyz);
392 409
     	for(int i=0;i<jsonArray.size();i++){
393 410
 		    double z = Double.parseDouble(jsonArray.get(i).toString().split(",")[2].split("]")[0])/1000;//单位转化为米
394
-		    System.out.println(z);
411
+		    //System.out.println(z);
395 412
 		}
396 413
     	
397 414
 	}