|
@@ -415,7 +415,7 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
}
|
|
|
|
|
|
//上料
|
|
|
- else if(currentTime.isAfter(liaoStartTime) && currentTime.isBefore(liaoEndTime)){
|
|
|
+ /*else if(currentTime.isAfter(liaoStartTime) && currentTime.isBefore(liaoEndTime)){
|
|
|
BigDecimal lastWeight2 = lastWeight;
|
|
|
BigDecimal maxWeight = null;
|
|
|
for (int i = 0; i < 60; i++) {
|
|
@@ -550,215 +550,8 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
rawData.setLastWeight(minWeight);
|
|
|
rawDataMapper.updateById(rawData);
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// try {
|
|
|
-// BigDecimal bigDecimal3 = new BigDecimal(3);
|
|
|
-// BigDecimal bigDecimala3 = new BigDecimal(-3);
|
|
|
-// BigDecimal bigDecimal0 = new BigDecimal(0);
|
|
|
-//
|
|
|
-// BigDecimal bigDecimal800 = new BigDecimal(-800);
|
|
|
-// BigDecimal bigDecimal1600 = new BigDecimal(1600);
|
|
|
-// BigDecimal bigDecimal2 = new BigDecimal(2);
|
|
|
-// Boolean flag = true;
|
|
|
- //循环获取体重
|
|
|
- /* for (int i = 0; i < 60; i++) {
|
|
|
- String str1 = s[i * 2 + 11] + s[i * 2 + 10];
|
|
|
- BigDecimal weight = new BigDecimal(Integer.parseInt(str1,16));
|
|
|
- if (flag){
|
|
|
- //当时时间
|
|
|
-// Date thenTime = new Date(l - ((60-i)*10000));
|
|
|
- Date thenTime = new Date(l - ((60-i)*10000));
|
|
|
- //
|
|
|
- String str2 = "";
|
|
|
- BigDecimal weight2 ;
|
|
|
- if(i<59){
|
|
|
- str2 = s[(i+1) * 2 + 11] + s[(i+1) * 2 + 10];
|
|
|
- weight2 = new BigDecimal(Integer.parseInt(str2,16));
|
|
|
- BigDecimal subtract2 = weight2.subtract(lastWeight);
|
|
|
- if (subtract2.compareTo(bigDecimal800) < 0){
|
|
|
- System.out.println("连续两次减重之和小于-80,舍弃");
|
|
|
- flag = false;
|
|
|
- lastWeight = weight;
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal subtract = weight.subtract(lastWeight);
|
|
|
-
|
|
|
-
|
|
|
- if (subtract.compareTo(bigDecimal3)<0&& subtract.compareTo(bigDecimal0)>0){
|
|
|
- System.out.println("波动小于0.3g,舍弃");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (subtract.compareTo(bigDecimala3)>0 && subtract.compareTo(bigDecimal0)<0){
|
|
|
- System.out.println("波动小于0.3g,舍弃");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- int compare = subtract.compareTo(new BigDecimal(1500));
|
|
|
- System.out.println(subtract +"------>"+weight+"----------->"+lastWeight);
|
|
|
- EnvRegularCallFeeding envRegularCallFeeding = new EnvRegularCallFeeding();
|
|
|
- envRegularCallFeeding.setBattery(batStr);
|
|
|
- envRegularCallFeeding.setCallDate(thenTime);
|
|
|
- envRegularCallFeeding.setCallCode(decId+"");
|
|
|
- envRegularCallFeeding.setCallName(envDevice.getDeviceName());
|
|
|
- envRegularCallFeeding.setDuckId(baseDuckInfo.getId());
|
|
|
- envRegularCallFeeding.setDuckNum(baseDuckInfo.getDuckNum());
|
|
|
- envRegularCallFeeding.setFarmId(baseDuckInfo.getFarmId());
|
|
|
- envRegularCallFeeding.setUnitId(baseDuckInfo.getUnitId());
|
|
|
- envRegularCallFeeding.setUnitName(baseDuckInfo.getUnitName());
|
|
|
- if (weight.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallFeeding.setDuckFeedingOriginal(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeeding.setDuckFeedingOriginal(weight.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- if (subtract.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallFeeding.setDuckWeight(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeeding.setDuckWeight(subtract.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
-
|
|
|
- //加料
|
|
|
- if (compare>0){
|
|
|
-
|
|
|
- EnvRegularCallFeedingCopy envRegularCallFeedingCopy = new EnvRegularCallFeedingCopy();
|
|
|
- envRegularCallFeedingCopy.setBattery(new BigDecimal(Integer.parseInt(bat, 16)).divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
- envRegularCallFeedingCopy.setCallDate(thenTime);
|
|
|
- envRegularCallFeedingCopy.setCallCode(decId+"");
|
|
|
- envRegularCallFeedingCopy.setCallName(envDevice.getDeviceName());
|
|
|
- envRegularCallFeedingCopy.setDuckId(baseDuckInfo.getId());
|
|
|
- envRegularCallFeedingCopy.setDuckNum(baseDuckInfo.getDuckNum());
|
|
|
- envRegularCallFeedingCopy.setFarmId(baseDuckInfo.getFarmId());
|
|
|
- envRegularCallFeedingCopy.setUnitId(baseDuckInfo.getUnitId());
|
|
|
- envRegularCallFeedingCopy.setUnitName(baseDuckInfo.getUnitName());
|
|
|
- if (weight.compareTo(bigDecimal0)==0){
|
|
|
- envRegularCallFeedingCopy.setDuckFeedingOriginal(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeedingCopy.setDuckFeedingOriginal(weight.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- if (subtract.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallFeedingCopy.setDuckWeight(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeedingCopy.setDuckWeight(subtract.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
-
|
|
|
- envRegularCallFeedingCopy.setEventType(1);
|
|
|
- envRegularCallFeedingCopyMapper.insert(envRegularCallFeedingCopy);
|
|
|
- lastWeight =weight;
|
|
|
- continue;
|
|
|
- }
|
|
|
- int compare50 = subtract.compareTo(new BigDecimal(800));
|
|
|
- //下蛋
|
|
|
- if (compare50>0){
|
|
|
- EnvRegularCallEgg envRegularCallEgg = new EnvRegularCallEgg();
|
|
|
- envRegularCallEgg.setBattery(bat);
|
|
|
- envRegularCallEgg.setCallDate(thenTime);
|
|
|
- envRegularCallEgg.setCallCode(decId+"");
|
|
|
- envRegularCallEgg.setCallName(envDevice.getDeviceName());
|
|
|
- envRegularCallEgg.setDuckId(baseDuckInfo.getId());
|
|
|
- envRegularCallEgg.setDuckNum(baseDuckInfo.getDuckNum());
|
|
|
- envRegularCallEgg.setFarmId(baseDuckInfo.getFarmId());
|
|
|
- envRegularCallEgg.setUnitId(baseDuckInfo.getUnitId());
|
|
|
- envRegularCallEgg.setUnitName(baseDuckInfo.getUnitName());
|
|
|
- envRegularCallEgg.setEggNum(1);
|
|
|
- if (weight.compareTo(bigDecimal0)==0){
|
|
|
- envRegularCallEgg.setDuckFeedingOriginal(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallEgg.setDuckFeedingOriginal(weight.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- if (subtract.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallEgg.setDuckWeight(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallEgg.setDuckWeight(subtract.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- envRegularCallEggMapper.insert(envRegularCallEgg);
|
|
|
- lastWeight =weight;
|
|
|
- continue;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- int compare1600 = subtract.compareTo(bigDecimal1600);
|
|
|
- //两枚下蛋
|
|
|
- if (compare1600>0){
|
|
|
- EnvRegularCallEgg envRegularCallEgg = new EnvRegularCallEgg();
|
|
|
- envRegularCallEgg.setBattery(bat);
|
|
|
- envRegularCallEgg.setCallDate(thenTime);
|
|
|
- envRegularCallEgg.setCallCode(decId+"");
|
|
|
- envRegularCallEgg.setCallName(envDevice.getDeviceName());
|
|
|
- envRegularCallEgg.setDuckId(baseDuckInfo.getId());
|
|
|
- envRegularCallEgg.setDuckNum(baseDuckInfo.getDuckNum());
|
|
|
- envRegularCallEgg.setFarmId(baseDuckInfo.getFarmId());
|
|
|
- envRegularCallEgg.setUnitId(baseDuckInfo.getUnitId());
|
|
|
- envRegularCallEgg.setUnitName(baseDuckInfo.getUnitName());
|
|
|
- envRegularCallEgg.setEggNum(2);
|
|
|
- if (weight.compareTo(bigDecimal0)==0){
|
|
|
- envRegularCallEgg.setDuckFeedingOriginal(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallEgg.setDuckFeedingOriginal(weight.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- if (subtract.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallEgg.setDuckWeight(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallEgg.setDuckWeight(subtract.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- envRegularCallEggMapper.insert(envRegularCallEgg);
|
|
|
- lastWeight =weight;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- int compare0 = subtract.compareTo(bigDecimal0);
|
|
|
- //小于零大于负八十
|
|
|
- int compare80 = subtract.compareTo(bigDecimal800);
|
|
|
- //吃料
|
|
|
- if (compare0<0 && compare80 >=0){
|
|
|
- if (subtract.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallFeeding.setDuckWeight(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeeding.setDuckWeight(subtract.subtract(subtract.multiply(bigDecimal2)).divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- envRegularCallFeeding.setEventType(0);
|
|
|
- envRegularCallFeedingMapper.insert(envRegularCallFeeding);
|
|
|
- lastWeight =weight;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //其它
|
|
|
- EnvRegularCallFeedingCopy envRegularCallFeedingCopy = new EnvRegularCallFeedingCopy();
|
|
|
- envRegularCallFeedingCopy.setBattery(new BigDecimal(Integer.parseInt(bat, 16)).divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
- envRegularCallFeedingCopy.setCallDate(thenTime);
|
|
|
- envRegularCallFeedingCopy.setCallCode(decId+"");
|
|
|
- envRegularCallFeedingCopy.setCallName(envDevice.getDeviceName());
|
|
|
- envRegularCallFeedingCopy.setDuckId(baseDuckInfo.getId());
|
|
|
- envRegularCallFeedingCopy.setDuckNum(baseDuckInfo.getDuckNum());
|
|
|
- envRegularCallFeedingCopy.setFarmId(baseDuckInfo.getFarmId());
|
|
|
- envRegularCallFeedingCopy.setUnitId(baseDuckInfo.getUnitId());
|
|
|
- envRegularCallFeedingCopy.setUnitName(baseDuckInfo.getUnitName());
|
|
|
- if (weight.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallFeedingCopy.setDuckFeedingOriginal(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeedingCopy.setDuckFeedingOriginal(weight.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
- if (subtract.compareTo(bigDecimal0 )==0){
|
|
|
- envRegularCallFeedingCopy.setDuckWeight(bigDecimal0);
|
|
|
- }else {
|
|
|
- envRegularCallFeedingCopy.setDuckWeight(subtract.divide(bigDecimal10, 1, BigDecimal.ROUND_HALF_UP) );
|
|
|
- }
|
|
|
-
|
|
|
- envRegularCallFeedingCopy.setEventType(2);
|
|
|
- envRegularCallFeedingCopyMapper.insert(envRegularCallFeedingCopy);
|
|
|
- continue;
|
|
|
- }
|
|
|
- lastWeight = weight;
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println(e);
|
|
|
- }
|
|
|
-*/
|
|
|
}
|
|
|
|
|
|
|