| | |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiCommonDevice; |
| | | import com.fzzy.api.data.GatewayDeviceType; |
| | | import com.fzzy.gateway.data.GrainCableData; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static GrainCableData getCableData(GatewayDevice gatewayDevice) { |
| | | String cableRule = gatewayDevice.getCableRule(); |
| | | String cableCir = gatewayDevice.getCableCir(); |
| | | |
| | | GrainCableData result = new GrainCableData(); |
| | | |
| | | int cableY, cableX; |
| | | String[] attCable = cableRule.split("-"); |
| | | int cableZ = Integer.valueOf(attCable[0]); |
| | | if (StringUtils.isEmpty(cableCir)) { |
| | | cableY = Integer.valueOf(attCable[1]); |
| | | cableX = Integer.valueOf(attCable[2]); |
| | | } else { |
| | | String[] attCir = cableCir.split("-"); |
| | | cableZ = Integer.valueOf(attCir[0]); |
| | | cableY = 1; |
| | | cableX = 0; |
| | | //针对多圈计算 |
| | | for (int i = 0; i < cableCir.length(); i++) { |
| | | cableX += Integer.valueOf(attCir[i]); |
| | | } |
| | | |
| | | result.setCir(true); |
| | | } |
| | | |
| | | result.setCableY(cableY); |
| | | result.setCableZ(cableZ); |
| | | result.setCableX(cableX); |
| | | result.setSumNum(cableZ * cableY * cableX); |
| | | |
| | | return result; |
| | | } |
| | | } |