Browse Source

增加首页数据录入

shilin 1 year ago
parent
commit
8b52334bde

+ 2 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/config/GeneratorCodeConfig.java

@@ -61,8 +61,8 @@ public class GeneratorCodeConfig {
 
         dsc.setDriverName("org.postgresql.Driver");
         dsc.setUsername("postgres");
-        dsc.setPassword("gd123");
-        dsc.setUrl("jdbc:postgresql://127.0.0.1:5432/IMS_NEM_JN");
+        dsc.setPassword("postgres");
+        dsc.setUrl("jdbc:postgresql://10.81.3.151:5432/IMS_NEM_JN");
 
         mpg.setDataSource(dsc);
 

+ 12 - 5
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/update/TargetdataFristController.java

@@ -26,10 +26,10 @@ public class TargetdataFristController {
 
 
 
-
     @PostMapping(value = "/save")
     @ApiOperation(value = "增", notes = "增")
     public R save(@RequestBody ProEconTargetdataFrist data) {
+        data.setOperationTime(new Date());
         boolean b = targetdataFristService.save(data);
         if (b) {
             return R.data(ResultMsg.ok(b));
@@ -42,6 +42,7 @@ public class TargetdataFristController {
     @PutMapping(value = "/update")
     @ApiOperation(value = "改", notes = "改")
     public R update(@RequestBody ProEconTargetdataFrist data) {
+        data.setOperationTime(new Date());
         boolean b = targetdataFristService.update(data);
         if (b) {
             return R.data(ResultMsg.ok(b));
@@ -64,7 +65,7 @@ public class TargetdataFristController {
     @GetMapping(value = "/get")
     @ApiOperation(value = "查", notes = "查")
     public R get(
-                 @RequestParam(value = "date", required = true) String date) {
+            @RequestParam(value = "date", required = true) String date) {
         List<ProEconTargetdataFrist> resultList  = targetdataFristService.get(date);
         if (StringUtils.isNotNull(resultList)) {
             return R.data(ResultMsg.ok(resultList));
@@ -82,7 +83,7 @@ public class TargetdataFristController {
 
                 ProEconTargetdataFrist.builder().id("").name("光伏").type("GF").rfdl(1.0).yfdl(2.0).nfdl(3.0).recordDate(DateUtils.truncate(new Date())).build()
 
-                );
+        );
 
         // 输出
         ExcelUtils.write(response, "导入模板.xls", "导入模板", ProEconTargetdataFrist.class, list);
@@ -93,13 +94,19 @@ public class TargetdataFristController {
     public R importExcel(@RequestParam("file") MultipartFile file) throws Exception {
         List<ProEconTargetdataFrist> list = ExcelUtils.read(file, ProEconTargetdataFrist.class);
 
-        if(StringUtils.notEmp(list) && list.isEmpty())
+        if(StringUtils.notEmp(list) && !list.isEmpty())
         {
             for(ProEconTargetdataFrist vo:list)
             {
                 vo.setId(StringUtils.getUUID());
                 vo.setOperationTime(new Date());
-                targetdataFristService.save(vo);
+
+                List<ProEconTargetdataFrist > ls=targetdataFristService.getByDateAndName(vo.getName(),vo.getRecordDate());
+                if(ls.isEmpty())
+                {
+                    targetdataFristService.save(vo);
+                }
+
             }
         }
         if (StringUtils.isNotNull(list)) {

+ 16 - 15
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProEconTargetdataFrist.java

@@ -1,15 +1,15 @@
 package com.gyee.runeconomy.model.auto;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Builder;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
+import lombok.*;
+import lombok.experimental.Accessors;
 
 import java.util.Date;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author wang
@@ -17,27 +17,28 @@ import java.util.Date;
  */
 @Data
 @Builder
-@EqualsAndHashCode(callSuper = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
 public class ProEconTargetdataFrist extends Model {
 
     private static final long serialVersionUID = 1L;
-
+    @ExcelProperty("编号")
     private String id;
-
+    @ExcelProperty("名称")
     private String name;
-
+    @ExcelProperty("类型")
     private String type;
-
+    @ExcelProperty("日期")
+    private Date recordDate;
+    @ExcelProperty("日发电量")
     private Double rfdl;
-
+    @ExcelProperty("月发电量")
     private Double yfdl;
-
+    @ExcelProperty("年发电量")
     private Double nfdl;
 
-
-    private Date recordDate;
-
-
+    @ExcelProperty("操作时间")
     private Date operationTime;
 
 

+ 16 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/update/TargetdataFristService.java

@@ -4,6 +4,7 @@ package com.gyee.runeconomy.service.update;/*
 */
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.model.StringUtils;
 import com.gyee.common.util.CommonUtils;
 import com.gyee.runeconomy.model.auto.ProEconTargetdataFrist;
 import com.gyee.runeconomy.service.auto.IProEconTargetdataFristService;
@@ -11,6 +12,7 @@ import com.gyee.runeconomy.util.DateUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -48,5 +50,19 @@ public class TargetdataFristService {
         return list;
     }
 
+    public List<ProEconTargetdataFrist> getByDateAndName(String name, Date date) {
 
+        List<ProEconTargetdataFrist> list =new ArrayList<>();
+        if(StringUtils.notEmp(name) && StringUtils.notEmp(date))
+        {
+
+            QueryWrapper<ProEconTargetdataFrist> query = new QueryWrapper<>();
+
+            query.lambda().eq(ProEconTargetdataFrist::getRecordDate,date);
+            query.lambda().eq(ProEconTargetdataFrist::getName, name);
+            list = proEconTargetdataFristService.list(query);
+        }
+
+        return list;
+    }
 }