|
@@ -12,6 +12,7 @@ import com.huimv.admin.entity.zengxindto.*;
|
|
import com.huimv.admin.service.*;
|
|
import com.huimv.admin.service.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -25,12 +26,12 @@ import java.security.MessageDigest;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
+import java.time.ZonedDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@EnableScheduling
|
|
@EnableScheduling
|
|
-@RestController
|
|
|
|
-@RequestMapping("/test")
|
|
|
|
public class ShenChanTimer {
|
|
public class ShenChanTimer {
|
|
|
|
|
|
//生产数据
|
|
//生产数据
|
|
@@ -52,20 +53,20 @@ public class ShenChanTimer {
|
|
|
|
|
|
|
|
|
|
// @Scheduled(cron = "0 * * * * ? ")
|
|
// @Scheduled(cron = "0 * * * * ? ")
|
|
-// @Scheduled(cron = "1 0 * * * ?")
|
|
|
|
- @GetMapping("/test")
|
|
|
|
|
|
+ @Scheduled(cron = "1 0 * * * ?")
|
|
|
|
+// @GetMapping("/test")
|
|
@Transactional
|
|
@Transactional
|
|
public void getShenChan() throws Exception {
|
|
public void getShenChan() throws Exception {
|
|
StockLoginDto stockLoginDto = login();
|
|
StockLoginDto stockLoginDto = login();
|
|
-// DateTime dateTime = DateUtil.beginOfDay(new Date());
|
|
|
|
|
|
+ DateTime dateTime = DateUtil.beginOfDay(new Date());
|
|
String data = getList(stockLoginDto.getToken(),stockLoginDto.getApp_secret());
|
|
String data = getList(stockLoginDto.getToken(),stockLoginDto.getApp_secret());
|
|
ProdStockDto prodStockDto = JSONUtil.toBean(data, ProdStockDto.class);
|
|
ProdStockDto prodStockDto = JSONUtil.toBean(data, ProdStockDto.class);
|
|
List<List<Object>> stockData = prodStockDto.getData();
|
|
List<List<Object>> stockData = prodStockDto.getData();
|
|
- DateTime beginOfYear = DateUtil.beginOfYear(DateUtil.offsetMonth(new Date(), -10));
|
|
|
|
- System.out.println(beginOfYear);
|
|
|
|
- for (int i = 0; i < 390; i++) {
|
|
|
|
- DateTime dateTime = DateUtil.offsetDay(beginOfYear, i);
|
|
|
|
- System.out.println("dateTime--"+dateTime);
|
|
|
|
|
|
+// DateTime beginOfYear = DateUtil.beginOfYear(DateUtil.offsetMonth(new Date(), -10));
|
|
|
|
+// System.out.println(beginOfYear);
|
|
|
|
+// for (int i = 0; i < 390; i++) {
|
|
|
|
+// DateTime dateTime = DateUtil.offsetDay(beginOfYear, i);
|
|
|
|
+// System.out.println("dateTime--"+dateTime);
|
|
|
|
|
|
for (List stock : stockData) {
|
|
for (List stock : stockData) {
|
|
System.out.println("stock -->"+stock);
|
|
System.out.println("stock -->"+stock);
|
|
@@ -112,7 +113,7 @@ public class ShenChanTimer {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
//保存存栏
|
|
//保存存栏
|
|
@@ -243,13 +244,16 @@ public class ShenChanTimer {
|
|
prodMonthOutPig = new ProdMonthOutPig();
|
|
prodMonthOutPig = new ProdMonthOutPig();
|
|
prodMonthOutPig.setDateTime(beginOfMonth);
|
|
prodMonthOutPig.setDateTime(beginOfMonth);
|
|
prodMonthOutPig.setFarmId(farmId);
|
|
prodMonthOutPig.setFarmId(farmId);
|
|
- prodMonthOutPig.setOutPig(monthOutPig);
|
|
|
|
- prodMonthOutPig.setOutPigCz(monthOutPig -zyOutPig);
|
|
|
|
|
|
+ prodMonthOutPig.setOutPig(monthOutPig +intsw+intsx);
|
|
|
|
+ prodMonthOutPig.setOutPigCz(monthOutPig +intsw+intsx -zyOutPig);
|
|
prodMonthOutPig.setZrPig(zyOutPig);
|
|
prodMonthOutPig.setZrPig(zyOutPig);
|
|
prodMonthOutPigService.save(prodMonthOutPig);
|
|
prodMonthOutPigService.save(prodMonthOutPig);
|
|
}else {
|
|
}else {
|
|
- prodMonthOutPig.setOutPig(monthOutPig);
|
|
|
|
- prodMonthOutPig.setOutPigCz(monthOutPig -zyOutPig);
|
|
|
|
|
|
+ if (monthInPig >0){
|
|
|
|
+ System.out.println(monthInPig);
|
|
|
|
+ }
|
|
|
|
+ prodMonthOutPig.setOutPig(monthOutPig +intsw+intsx);
|
|
|
|
+ prodMonthOutPig.setOutPigCz(monthOutPig +intsw+intsx -zyOutPig);
|
|
prodMonthOutPig.setZrPig(zyOutPig);
|
|
prodMonthOutPig.setZrPig(zyOutPig);
|
|
prodMonthOutPigService.updateById(prodMonthOutPig);
|
|
prodMonthOutPigService.updateById(prodMonthOutPig);
|
|
}
|
|
}
|
|
@@ -278,8 +282,10 @@ public class ShenChanTimer {
|
|
ProdWarningInfo prodWarningInfo = prodWarningInfoService.getOne(new QueryWrapper<ProdWarningInfo>().ge("date", dateTime).eq("farm_id", farmId).orderByDesc("date").last("limit 1"));
|
|
ProdWarningInfo prodWarningInfo = prodWarningInfoService.getOne(new QueryWrapper<ProdWarningInfo>().ge("date", dateTime).eq("farm_id", farmId).orderByDesc("date").last("limit 1"));
|
|
if (ObjectUtil.isEmpty(prodWarningInfo)){
|
|
if (ObjectUtil.isEmpty(prodWarningInfo)){
|
|
prodWarningInfo = new ProdWarningInfo();
|
|
prodWarningInfo = new ProdWarningInfo();
|
|
-
|
|
|
|
- prodWarningInfo.setDate( LocalDateTime.now());
|
|
|
|
|
|
+ ZoneId zoneId = ZoneId.of("Asia/Shanghai");
|
|
|
|
+ ZonedDateTime zonedDateTime = dateTime.toInstant().atZone(zoneId);
|
|
|
|
+ // 从 ZonedDateTime 转换到 LocalDateTime,此时已经没有时区信息
|
|
|
|
+ prodWarningInfo.setDate(zonedDateTime.toLocalDateTime());
|
|
prodWarningInfo.setFarmId(farmId);
|
|
prodWarningInfo.setFarmId(farmId);
|
|
prodWarningInfo.setWarningContent("今日淘汰"+intsw+"头猪");
|
|
prodWarningInfo.setWarningContent("今日淘汰"+intsw+"头猪");
|
|
prodWarningInfo.setWarningType(1);
|
|
prodWarningInfo.setWarningType(1);
|