|
@@ -5,6 +5,11 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.huimv.eartag2.manage2.mapper.BaseFarmerMapper;
|
|
|
+import com.huimv.eartag2.manage2.mapper.EartagDeviceRegisterMapper;
|
|
|
+import com.huimv.eartag2.manage2.mapper.EartagEartagRegister2Mapper;
|
|
|
+import com.huimv.eartag2.manage2.mapper.EartagResetMapper;
|
|
|
+import com.huimv.eartag2.manage2.pojo.BaseFarmer;
|
|
|
import com.huimv.eartag2.manage2.pojo.EartagDeviceRegister;
|
|
|
import com.huimv.eartag2.manage2.pojo.SysBaseConfig;
|
|
|
import com.huimv.eartag2.manage2.service.EartagDeviceRegisterService;
|
|
@@ -19,6 +24,7 @@ import java.io.IOException;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -33,15 +39,20 @@ import java.util.concurrent.Executors;
|
|
|
@Configuration //1.主要用于标记配置类,兼备Component的效果。
|
|
|
@EnableScheduling // 2.开启定时任务
|
|
|
public class EartagTask {
|
|
|
-
|
|
|
@Autowired
|
|
|
private IEartagService eartagService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SysBaseConfigService baseConfigService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private EartagDeviceRegisterService deviceRegisterService;
|
|
|
+ @Autowired
|
|
|
+ private EartagResetMapper eartagResetMapper;
|
|
|
+ @Autowired
|
|
|
+ private EartagEartagRegister2Mapper eartagEartagRegister2Mapper;
|
|
|
+ @Autowired
|
|
|
+ private BaseFarmerMapper baseFarmerMapper;
|
|
|
+ @Autowired
|
|
|
+ private EartagDeviceRegisterMapper eartagDeviceRegisterMapper;
|
|
|
|
|
|
/**
|
|
|
* @Method : countEartagOnlineTimes
|
|
@@ -108,4 +119,38 @@ public class EartagTask {
|
|
|
|
|
|
System.out.println("测试数据");
|
|
|
}
|
|
|
+
|
|
|
+ @Scheduled(cron = "0/5 * * * * ? ")
|
|
|
+ private void countAssetInEveryMonth() {
|
|
|
+ com.huimv.eartag2.common.utils.DateUtil dateUtil = new com.huimv.eartag2.common.utils.DateUtil();
|
|
|
+ String month = dateUtil.getThisMonth();
|
|
|
+// eartagResetMapper.
|
|
|
+// eartagEartagRegister2Mapper.get
|
|
|
+ //--读取所有农户和采集器
|
|
|
+ List<BaseFarmer> baseFarmerList = baseFarmerMapper.getFarmer();
|
|
|
+
|
|
|
+ //--用采集器读取所有数据计算可售和不可售资源
|
|
|
+ for(BaseFarmer baseFarmer:baseFarmerList){
|
|
|
+ //--
|
|
|
+ _countAssetByFarmer(baseFarmer);
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("month="+month);
|
|
|
+ }
|
|
|
+
|
|
|
+ //--
|
|
|
+ private void _countAssetByFarmer(BaseFarmer baseFarmer) {
|
|
|
+ Integer farmerId = baseFarmer.getId();
|
|
|
+ System.out.println("farmerId="+farmerId);
|
|
|
+ //--读取采集器
|
|
|
+ String deviceCode = eartagDeviceRegisterMapper.getDeviceIdByFarmerId(String.valueOf(farmerId));
|
|
|
+ System.out.println("deviceCode="+deviceCode);
|
|
|
+ //--读取注册耳标
|
|
|
+
|
|
|
+// System.out.println("deviceCodeList.size="+deviceCodeList.size());
|
|
|
+// for(int a=0;a<deviceCodeList.size();a++)
|
|
|
+// {
|
|
|
+// System.out.println(""+deviceCodeList.get(a)+"");
|
|
|
+// }
|
|
|
+ }
|
|
|
}
|