|
@@ -17,6 +17,7 @@ import com.slibra.business.mapper.TXinyiLaboratoryMapper;
|
|
|
import com.slibra.business.mapper.TXinyiRobotMapper;
|
|
|
import com.slibra.common.core.controller.BaseController;
|
|
|
import com.slibra.common.utils.DateUtils;
|
|
|
+import com.slibra.common.utils.StringUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -449,6 +450,89 @@ public class HandleDataController extends BaseController
|
|
|
// }
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * 从Excel读取数据 将新增的列数据更新到新的日报字段中
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/dailyAddDataByExcel")
|
|
|
+ public String dailyAddDataByExcel() {
|
|
|
+ log.info("从Excel读取数据 将新增的列数据更新到新的日报字段中~~~~~~~~");
|
|
|
+ File file = new File("/home/slibra/绝干泥量.xlsx");
|
|
|
+// File file = new File("C:\\Users\\10109\\Documents\\WeChat Files\\mz1010995810\\FileStorage\\File\\2024-05\\绝干泥量.xlsx");
|
|
|
+ // 输入目录
|
|
|
+ ExcelReader reader = ExcelUtil.getReader(file);
|
|
|
+ List<List<Object>> readAll = reader.read();
|
|
|
+// log.info("Excel解析的结果为{}", JSON.toJSONString(readAll));
|
|
|
+ if(!CollectionUtils.isEmpty(readAll)){
|
|
|
+ for (int i = 1; i < readAll.size(); i++) {
|
|
|
+ //解析数据
|
|
|
+ List<Object> objects = readAll.get(i);
|
|
|
+ String date = (String) objects.get(0);
|
|
|
+ date = date.replaceAll("\\.", "/");
|
|
|
+ date = handleDate(date);
|
|
|
+
|
|
|
+ //用时间去查询 如果存在就更新,否则跳过
|
|
|
+ List<TXinyiDaily> tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(date).build());
|
|
|
+ if(CollectionUtils.isEmpty(tXinyiDailies)){
|
|
|
+ log.error("没有查询到对应的历史数据,跳过~~~~~~{}", date);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //目前集合就一个对象 以后可能会多个
|
|
|
+ TXinyiDaily tXinyiDaily = tXinyiDailies.get(0);
|
|
|
+
|
|
|
+ //出泥量
|
|
|
+ Object o1 = objects.get(1);
|
|
|
+ BigDecimal CHUNILIANG = null;
|
|
|
+ if(o1 instanceof String){
|
|
|
+ log.error("数据异常,解析为null");
|
|
|
+ CHUNILIANG = null;
|
|
|
+ }else if(o1 instanceof Double){
|
|
|
+ CHUNILIANG = new BigDecimal((Double) o1);
|
|
|
+ }else {
|
|
|
+ log.error("错误的类型,不用解析了");
|
|
|
+ CHUNILIANG = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //出泥含水率
|
|
|
+ BigDecimal CNHSL = null;
|
|
|
+ Object o2 = objects.get(2);
|
|
|
+ if(o2 instanceof String){
|
|
|
+ log.error("数据异常,解析为null");
|
|
|
+ CNHSL = null;
|
|
|
+ }else if(o2 instanceof Double){
|
|
|
+ CNHSL = new BigDecimal((Double) o2);
|
|
|
+ }else {
|
|
|
+ log.error("错误的类型,不用解析了");
|
|
|
+ CNHSL = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //干污泥量
|
|
|
+ Object o3 = objects.get(3);
|
|
|
+ BigDecimal GWNL = null;
|
|
|
+ if(o3 instanceof String){
|
|
|
+ log.error("数据异常,解析为null");
|
|
|
+ GWNL = null;
|
|
|
+ }else if(o3 instanceof Double){
|
|
|
+ GWNL = new BigDecimal((Double) o3);
|
|
|
+ }else {
|
|
|
+ log.error("错误的类型,不用解析了");
|
|
|
+ GWNL = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新数据
|
|
|
+ tXinyiDaily.setCHUNILIANG(CHUNILIANG);
|
|
|
+ tXinyiDaily.setCNHSL(CNHSL);
|
|
|
+ tXinyiDaily.setGWNL(GWNL);
|
|
|
+ this.xinyiDailyMapper.updateTXinyiDaily(tXinyiDaily);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 手动处理日报数据 增加两个字段 时间和小时
|
|
|
* @return
|