Browse Source

简单录入

xieshengjie 1 year ago
parent
commit
b9f576166f

+ 28 - 0
common/src/main/java/com/gyee/common/util/MD5Utils.java

@@ -0,0 +1,28 @@
+package com.gyee.common.util;/*
+@author   谢生杰
+@date   2023/5/16-11:33
+*/
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class MD5Utils {
+
+    public static String getMD5Str(String str) {
+        byte[] digest = null;
+        try {
+            MessageDigest md5 = MessageDigest.getInstance("md5");
+            digest = md5.digest(str.getBytes("utf-8"));
+        }catch (NoSuchAlgorithmException e){
+            e.printStackTrace();
+        }catch (UnsupportedEncodingException e){
+            e.printStackTrace();
+        }
+        //16是表示转换16进制数
+        String md5str = new BigInteger(1,digest).toString(16);
+        return md5str;
+
+    }
+}

+ 20 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/ProBasicUserController.java

@@ -0,0 +1,20 @@
+package com.gyee.runeconomy.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+@RestController
+@RequestMapping("//pro-basic-user")
+public class ProBasicUserController {
+
+}

+ 20 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/ProEconTargetdataController.java

@@ -0,0 +1,20 @@
+package com.gyee.runeconomy.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+@RestController
+@RequestMapping("//pro-econ-targetdata")
+public class ProEconTargetdataController {
+
+}

+ 98 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/update/TargetEnterController.java

@@ -0,0 +1,98 @@
+package com.gyee.runeconomy.controller.update;/*
+@author   谢生杰
+@date   2023/5/16-9:54
+*/
+
+import com.gyee.common.model.StringUtils;
+import com.gyee.runeconomy.dto.R;
+import com.gyee.runeconomy.dto.ResultMsg;
+import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
+import com.gyee.runeconomy.model.auto.ProBasicUser;
+import com.gyee.runeconomy.model.auto.ProEconTargetdata;
+import com.gyee.runeconomy.service.update.TargetEnterService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("//target")
+public class TargetEnterController {
+    @Resource
+    private TargetEnterService targetEnterService;
+
+    @PostMapping(value = "/login")
+    @ApiOperation(value = "登录", notes = "登录")
+    public R login(@RequestBody ProBasicUser user
+                                    ) {
+        ProBasicUser proBasicUser = targetEnterService.login(user);
+        if (StringUtils.isNotNull(proBasicUser)) {
+            return R.data(ResultMsg.ok(proBasicUser));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+
+    @PostMapping(value = "/target")
+    @ApiOperation(value = "增", notes = "增")
+    public R save(@RequestBody ProEconTargetdata data) {
+        boolean b = targetEnterService.save(data);
+        if (b) {
+            return R.data(ResultMsg.ok(b));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+
+    @PutMapping(value = "/target")
+    @ApiOperation(value = "改", notes = "改")
+    public R update(@RequestBody ProEconTargetdata data) {
+        boolean b = targetEnterService.update(data);
+        if (b) {
+            return R.data(ResultMsg.ok(b));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+    @DeleteMapping(value = "/target")
+    @ApiOperation(value = "删", notes = "删")
+    public R delete(@RequestBody ProEconTargetdata data) {
+        boolean b = targetEnterService.delete(data);
+        if (b) {
+            return R.data(ResultMsg.ok(b));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+    @GetMapping(value = "/target")
+    @ApiOperation(value = "查", notes = "查")
+    public R get(@RequestParam(value = "wpid", required = true) String wpid,
+                 @RequestParam(value = "date", required = true) String date) {
+        List<ProEconTargetdata> resultList  = targetEnterService.get(wpid,date);
+        if (StringUtils.isNotNull(resultList)) {
+            return R.data(ResultMsg.ok(resultList));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+
+    @GetMapping(value = "/wpls")
+    @ApiOperation(value = "查", notes = "查")
+    public R wpls(@RequestParam(value = "wpid", required = true) String wpid) {
+        List<ProBasicPowerstation> resultList  = targetEnterService.wpls(wpid);
+        if (StringUtils.isNotNull(resultList)) {
+            return R.data(ResultMsg.ok(resultList));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+
+
+}

+ 16 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/mapper/auto/ProBasicUserMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.mapper.auto;
+
+import com.gyee.runeconomy.model.auto.ProBasicUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+public interface ProBasicUserMapper extends BaseMapper<ProBasicUser> {
+
+}

+ 16 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/mapper/auto/ProEconTargetdataMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.mapper.auto;
+
+import com.gyee.runeconomy.model.auto.ProEconTargetdata;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+public interface ProEconTargetdataMapper extends BaseMapper<ProEconTargetdata> {
+
+}

+ 32 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProBasicUser.java

@@ -0,0 +1,32 @@
+package com.gyee.runeconomy.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProBasicUser extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String username;
+
+    private String password;
+
+    private String windpowerstationId;
+
+    private Integer isOpen;
+
+
+}

+ 44 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProEconTargetdata.java

@@ -0,0 +1,44 @@
+package com.gyee.runeconomy.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconTargetdata extends Model {
+
+    private static final long serialVersionUID = 1L;
+    @TableId(value = "id",type = IdType.INPUT)
+    private String id;
+
+    private String windpowerstationId;
+
+    private String windpowerstationName;
+
+    private Date recordDate;
+
+    private Double generationDay;
+
+    private Double generationMonth;
+
+    private Double generationYear;
+
+    private Double power;
+
+    private Double speedOrBeam;
+
+
+}

+ 16 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProBasicUserService.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.service.auto;
+
+import com.gyee.runeconomy.model.auto.ProBasicUser;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+public interface IProBasicUserService extends IService<ProBasicUser> {
+
+}

+ 16 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconTargetdataService.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.service.auto;
+
+import com.gyee.runeconomy.model.auto.ProEconTargetdata;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+public interface IProEconTargetdataService extends IService<ProEconTargetdata> {
+
+}

+ 20 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProBasicUserServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.runeconomy.service.auto.impl;
+
+import com.gyee.runeconomy.model.auto.ProBasicUser;
+import com.gyee.runeconomy.mapper.auto.ProBasicUserMapper;
+import com.gyee.runeconomy.service.auto.IProBasicUserService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+@Service
+public class ProBasicUserServiceImpl extends ServiceImpl<ProBasicUserMapper, ProBasicUser> implements IProBasicUserService {
+
+}

+ 20 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconTargetdataServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.runeconomy.service.auto.impl;
+
+import com.gyee.runeconomy.model.auto.ProEconTargetdata;
+import com.gyee.runeconomy.mapper.auto.ProEconTargetdataMapper;
+import com.gyee.runeconomy.service.auto.IProEconTargetdataService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-16
+ */
+@Service
+public class ProEconTargetdataServiceImpl extends ServiceImpl<ProEconTargetdataMapper, ProEconTargetdata> implements IProEconTargetdataService {
+
+}

+ 78 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/update/TargetEnterService.java

@@ -0,0 +1,78 @@
+package com.gyee.runeconomy.service.update;/*
+@author   谢生杰
+@date   2023/5/16-10:10
+*/
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.util.CommonUtils;
+import com.gyee.common.util.MD5Utils;
+import com.gyee.runeconomy.init.CacheContext;
+import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
+import com.gyee.runeconomy.model.auto.ProBasicUser;
+import com.gyee.runeconomy.model.auto.ProEconTargetdata;
+import com.gyee.runeconomy.service.auto.IProBasicUserService;
+import com.gyee.runeconomy.service.auto.IProEconTargetdataService;
+import com.gyee.runeconomy.util.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+@Service
+public class TargetEnterService {
+    @Resource
+    private IProBasicUserService proBasicUserService;
+    @Resource
+    private IProEconTargetdataService proEconTargetdataService;
+
+    public ProBasicUser login(ProBasicUser user) {
+
+        String md5Str = MD5Utils.getMD5Str(user.getPassword());
+
+        QueryWrapper<ProBasicUser> query = new QueryWrapper<>();
+        query.lambda().eq(ProBasicUser::getUsername,user.getUsername()).eq(ProBasicUser::getPassword,md5Str).eq(ProBasicUser::getIsOpen,1);
+        Optional<ProBasicUser> first = proBasicUserService.list(query).stream().findFirst();
+        if (first.isPresent()){
+            return first.get();
+        }else {
+            return null;
+        }
+    }
+
+    public boolean save(ProEconTargetdata data) {
+        data.setId(CommonUtils.getUUID());
+        return proEconTargetdataService.save(data);
+    }
+
+    public boolean update(ProEconTargetdata data) {
+        return proEconTargetdataService.saveOrUpdate(data);
+    }
+
+    public boolean delete(ProEconTargetdata data) {
+        return proEconTargetdataService.removeById(data.getId());
+    }
+
+    public List<ProEconTargetdata> get(String wpid, String date) {
+        Date date1 = DateUtils.parseDate(date);
+        QueryWrapper<ProEconTargetdata> query = new QueryWrapper<>();
+
+        query.lambda().eq(ProEconTargetdata::getRecordDate,date1);
+        if (!wpid.equals("0")){
+            query.lambda().eq(ProEconTargetdata::getWindpowerstationId,wpid);
+        }
+        List<ProEconTargetdata> list = proEconTargetdataService.list(query);
+        return list;
+    }
+
+    public List<ProBasicPowerstation> wpls(String wpid) {
+        List<ProBasicPowerstation> wpls = CacheContext.wpls;
+        if (!wpid.equals("0")){
+            return wpls.stream().filter(wp->wp.getId().equals(wpid)).collect(Collectors.toList());
+        }else {
+            return wpls;
+        }
+    }
+}