From b9b58b9ef261cb290d93465f88a2cbd814b576f0 Mon Sep 17 00:00:00 2001
From: fei.wang <wf18701153496@163.com>
Date: 星期一, 13 五月 2024 17:51:44 +0800
Subject: [PATCH] 更改

---
 src/main/java/com/flow/controller/IndexController.java |  393 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 393 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/flow/controller/IndexController.java b/src/main/java/com/flow/controller/IndexController.java
new file mode 100644
index 0000000..03e3ba8
--- /dev/null
+++ b/src/main/java/com/flow/controller/IndexController.java
@@ -0,0 +1,393 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package com.flow.controller;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.flow.mapper.CardMapper;
+import com.flow.mapper.OperationLogMapper;
+import com.flow.pojo.Card;
+import com.flow.pojo.OperationLog;
+import com.flow.pojo.TbFuwuqi;
+import com.flow.service.CardService;
+import com.flow.service.CompanyService;
+import com.flow.service.OperationLogService;
+import com.flow.util.result;
+import com.flow.util.resultutil;
+import com.github.pagehelper.PageInfo;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+@RestController
+@RequestMapping({"/hxzk"})
+public class IndexController {
+    @Autowired
+    CardService cardService;
+    @Autowired
+    CompanyService companyService;
+
+    @Autowired
+    CardMapper cardMapper;
+
+    @Autowired
+    OperationLogMapper operationLogMapper;
+
+    public IndexController() {
+    }
+
+    @GetMapping({"index"})
+    public ModelAndView index() throws Exception {
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.addObject("suoshu", this.companyService.findSuoShu());
+        modelAndView.setViewName("/page/index1.jsp");
+        return modelAndView;
+    }
+
+    @GetMapping({"FindCard"})
+    public result<List<Card>> FindCard(Integer page, Integer limit) throws Exception {
+        PageInfo<Card> cz = this.cardService.FindCarda(page, limit);
+
+        for (int i = 0; i < cz.getSize(); ++i) {
+            if (((Card) cz.getList().get(i)).getCompany() != null) {
+//                ((Card) cz.getList().get(i)).setZflow(((Card) cz.getList().get(i)).getZflow() / 1024);
+//                ((Card) cz.getList().get(i)).setSyflow(((Card) cz.getList().get(i)).getSyflow() / 1024);
+//                ((Card) cz.getList().get(i)).setSyll(((Card) cz.getList().get(i)).getZflow() - ((Card) cz.getList().get(i)).getSyflow());
+
+                if (((Card) cz.getList().get(i)).getBindid() == null || ((Card) cz.getList().get(i)).getBindid().equals("undefined")) {
+                    ((Card) cz.getList().get(i)).setBindid("鏈煡");
+                }
+                SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
+                Date date = new Date();
+                if (cz.getList().get(i).getEnddate() != null) {
+                    if (cz.getList().get(i).getFlow() == null) {
+                        ((Card) cz.getList().get(i)).setFlow("12G/骞�");
+                        this.cardService.UpdateCard((Card) cz.getList().get(i));
+                    }
+                    if (cz.getList().get(i).getUnitprice() == null) {
+                        ((Card) cz.getList().get(i)).setUnitprice(80);
+                        this.cardService.UpdateCard((Card) cz.getList().get(i));
+                    }
+                    System.out.println(cz.getList().get(i).getEnddate());
+                    if (cz.getList().get(i).getEnddate() != null) {
+                        Date endDay = date2.parse(cz.getList().get(i).getEnddate());//缁撴潫鏃堕棿
+                        Long starTime = date.getTime();
+                        Long endTime = endDay.getTime();
+                        Long num11 = endTime - starTime;//鏃堕棿鎴�
+                        if ((num11 / 24 / 60 / 60 / 1000) < 0) {
+                            ((Card) cz.getList().get(i)).setRemainingdays("0澶�");
+                        } else {
+                            ((Card) cz.getList().get(i)).setRemainingdays(+num11 / 24 / 60 / 60 / 1000 + "澶�");
+                        }
+                        if (!((Card) cz.getList().get(i)).getRemainingdays().equals("0澶�") || !((Card) cz.getList().get(i)).getRemainingdays().equals(+num11 / 24 / 60 / 60 / 1000 + "澶�")) {
+                            this.cardService.UpdateCard((Card) cz.getList().get(i));
+                        }
+                    }
+
+                }
+
+
+            }
+        }
+
+        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
+    }
+
+    @PostMapping({"chaZi"})
+    public String chaZi(String Zong) throws Exception {
+        return this.companyService.chaZi(Zong);
+    }
+
+    @PostMapping({"FindCardZi"})
+    public result<List<Card>> FindCardZi(Card card, Integer page, Integer limit) throws Exception {
+        PageInfo<Card> cz = this.cardService.FindCardaZi(card, page, limit);
+
+        for (int i = 0; i < cz.getSize(); ++i) {
+            if (((Card) cz.getList().get(i)).getCompany() != null) {
+//                ((Card) cz.getList().get(i)).setZflow(((Card) cz.getList().get(i)).getZflow() / 1024);
+//                ((Card) cz.getList().get(i)).setSyflow(((Card) cz.getList().get(i)).getSyflow() / 1024);
+//                ((Card) cz.getList().get(i)).setSyll(((Card) cz.getList().get(i)).getZflow() - ((Card) cz.getList().get(i)).getSyflow());
+                SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
+                Date date = new Date();
+                if (cz.getList().get(i).getEnddate() != null) {
+                    Date endDay = date2.parse(cz.getList().get(i).getEnddate());//缁撴潫鏃堕棿
+                    Long starTime = date.getTime();
+                    Long endTime = endDay.getTime();
+                    Long num11 = endTime - starTime;//鏃堕棿鎴�
+                    if ((num11 / 24 / 60 / 60 / 1000) < 0) {
+                        ((Card) cz.getList().get(i)).setRemainingdays("0澶�");
+                    } else {
+                        ((Card) cz.getList().get(i)).setRemainingdays(+num11 / 24 / 60 / 60 / 1000 + "澶�");
+                    }
+                    if (!((Card) cz.getList().get(i)).getRemainingdays().equals("0澶�") || !((Card) cz.getList().get(i)).getRemainingdays().equals(+num11 / 24 / 60 / 60 / 1000 + "澶�")) {
+                        this.cardService.UpdateCard((Card) cz.getList().get(i));
+                    }
+                }
+            }
+        }
+
+        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
+    }
+
+    @PostMapping({"DeleteCard"})
+    public int DeleteCard(String num ,String caozuoname) {
+
+        return this.cardService.DeleteCard(num,caozuoname);
+    }
+
+    @PostMapping({"Update"})
+    public ModelAndView UpdateCard(Card card) {
+        this.cardService.UpdateCard(card);
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.setViewName("/page/index1.jsp");
+        return modelAndView;
+    }
+
+    @PostMapping({"UpdateChong"})
+    public ModelAndView UpdateChong(Card card) {
+        this.cardService.UpdateCardChong(card);
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("cardnumber", card.getCardnumber());
+        Card tbFuwuqi1 = cardMapper.selectOne(queryWrapper);
+        OperationLog operationLog = new OperationLog();
+        operationLog.setCaozuotype("淇敼");
+        operationLog.setCaozuocontent("淇敼鍗″彿锛�"+tbFuwuqi1.getCardnumber());
+//        operationLogMapper.addOperationLog(operationLog);
+        operationLog.setCaozuoname(card.getCaozuoname());
+        Date date = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        operationLog.setCaozuodate(formatter.format(date));
+        operationLogMapper.insert(operationLog);
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.setViewName("/page/index1.jsp");
+        modelAndView.addObject("operatornum", 2);
+        return modelAndView;
+    }
+    @PostMapping({"updateBatchById"})
+    @Transactional(rollbackFor = Exception.class)
+    public ModelAndView updateBatchById(Card card) {
+        this.cardService.updateBatchById(card);
+        OperationLog operationLog = new OperationLog();
+        operationLog.setCaozuotype("淇敼");
+        operationLog.setCaozuocontent("淇敼鍗″彿锛�"+card.getCardnumber());
+        Date date = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        operationLog.setCaozuodate(formatter.format(date));
+        operationLogMapper.insert(operationLog);
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.setViewName("/page/index1.jsp");
+        modelAndView.addObject("operatornum", 2);
+        return modelAndView;
+    }
+
+    @PostMapping({"addCard"})
+    public ModelAndView addCard(Card card) throws Exception {
+        String[] str = card.getCardnumber().split(";");
+        String[] str1 = card.getBindid().split(";");
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.setViewName("/page/index1.jsp");
+        modelAndView.addObject("suoshu", this.companyService.findSuoShu());
+        int i;
+        Card card1;
+        if (str.length > 1 && str1.length > 1) {
+            for (i = 0; i < str.length; ++i) {
+                card1 = new Card();
+                card1.setCompany(card.getCompany());
+                card1.setCardnumber(str[i]);
+                card1.setCarddate(card.getCarddate());
+                card1.setOperator(card.getOperator());
+                card1.setFlow(card.getFlow());
+                card1.setUnitprice(card.getUnitprice());
+                card1.setBindid(str1[i]);
+                card1.setLocation(card.getLocation());
+                card1.setNotes(card.getNotes());
+                card1.setEnterdate(card.getEnddate());
+                this.cardService.addCard(card1);
+            }
+        } else if (str.length > 1 && str1[0] == "") {
+            for (i = 0; i < str.length; ++i) {
+                card1 = new Card();
+                card1.setCompany(card.getCompany());
+                card1.setCardnumber(str[i]);
+                card1.setCarddate(card.getCarddate());
+                card1.setOperator(card.getOperator());
+                card1.setFlow(card.getFlow());
+                card1.setUnitprice(card.getUnitprice());
+                card1.setBindid("");
+                card1.setLocation(card.getLocation());
+                card1.setNotes(card.getNotes());
+                card1.setEnterdate(card.getEnddate());
+                this.cardService.addCard(card1);
+            }
+        } else if (str.length > 1 && str1.length == 1) {
+            for (i = 0; i < str.length; ++i) {
+                card1 = new Card();
+                card1.setCompany(card.getCompany());
+                card1.setCardnumber(str[i]);
+                card1.setCarddate(card.getCarddate());
+                card1.setOperator(card.getOperator());
+                card1.setFlow(card.getFlow());
+                card1.setUnitprice(card.getUnitprice());
+                card1.setBindid(String.valueOf(str1));
+                card1.setLocation(card.getLocation());
+                card1.setNotes(card.getNotes());
+                card1.setEnterdate(card.getEnddate());
+                this.cardService.addCard(card1);
+            }
+        } else {
+            if (card.getCardnumber() != null && card.getCardnumber() != "") {
+                card.setCompany(card.getCompany());
+                this.cardService.addCard(card);
+            }
+
+        }
+
+        return modelAndView;
+    }
+
+    @PostMapping({"tableSearch"})
+    public result<List<Card>> tableSearch(Card card, int page, int limit) throws Exception {
+        PageInfo<Card> cz = this.cardService.tableSearch(card, page, limit);
+
+        for (int i = 0; i < cz.getSize(); ++i) {
+            if (((Card) cz.getList().get(i)).getCompany().equals("鍗庢槦鏅烘帶")){
+                ((Card) cz.getList().get(i)).setCompany("鍖椾含鍗庢槦鍖楁枟鏅烘帶鎶�鏈湁闄愬叕鍙�");
+            }
+//            ((Card) cz.getList().get(i)).setZflow(((Card) cz.getList().get(i)).getZflow() / 1024);
+//            ((Card) cz.getList().get(i)).setSyflow(((Card) cz.getList().get(i)).getSyflow() / 1024);
+//            ((Card) cz.getList().get(i)).setSyll(((Card) cz.getList().get(i)).getSyll() / 1024);
+            SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
+            Date date = new Date();
+            if (cz.getList().get(i).getEnddate() != null) {
+                Date endDay = date2.parse(cz.getList().get(i).getEnddate());//缁撴潫鏃堕棿
+                Long starTime = date.getTime();
+                Long endTime = endDay.getTime();
+                Long num11 = endTime - starTime;//鏃堕棿鎴�
+                if ((num11 / 24 / 60 / 60 / 1000) < 0) {
+                    ((Card) cz.getList().get(i)).setRemainingdays("0澶�");
+                } else {
+                    ((Card) cz.getList().get(i)).setRemainingdays(+num11 / 24 / 60 / 60 / 1000 + "澶�");
+                }
+                if (!((Card) cz.getList().get(i)).getRemainingdays().equals("0澶�") || !((Card) cz.getList().get(i)).getRemainingdays().equals(+num11 / 24 / 60 / 60 / 1000 + "澶�")) {
+                    this.cardService.UpdateCard((Card) cz.getList().get(i));
+                }
+            }
+
+        }
+
+        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
+    }
+
+    @GetMapping({"chawu"})
+    public List chaWu() {
+        return this.cardService.chaWu();
+    }
+
+    @PostMapping({"chawu1"})
+    public List chaWu1(String qb) throws Exception {
+        return this.cardService.chaWu1(qb);
+    }
+
+    @GetMapping({"proxyCardList"})
+    public void proxyCardList() throws Exception {
+        String accessKey = "448c2cedcdce41428a290d144e81ab6e";
+        String str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+        String accessSecret = "RgoIWycMYGmQfrLwLuT2VWawAhwMO8w7P9zh2dZp";
+        String nonce = "";
+        Date now = new Date();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+        String Timestamp = dateFormat.format(now);
+        int length = 30;
+        Random random = new Random();
+
+        for (int i = length; i > 0; --i) {
+            int index = random.nextInt(str.length());
+            nonce = nonce + str.charAt(index);
+        }
+
+        String stringSignTemp = accessKey + nonce + Timestamp;
+        Mac sha256Hmac = Mac.getInstance("HmacSHA256");
+        SecretKeySpec secretKeySpec = new SecretKeySpec(accessSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
+        sha256Hmac.init(secretKeySpec);
+        byte[] hmacBytes = sha256Hmac.doFinal(stringSignTemp.getBytes(StandardCharsets.UTF_8));
+        String sign = Base64.getEncoder().encodeToString(hmacBytes);
+        String targetUrl = "https://api.spruceiot.cn/api/v1/sim/list/query?pageIndex=1&pageSize=1";
+        URL url = new URL(targetUrl);
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestProperty("Accept-Charset", "UTF-8");
+        connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+        connection.setRequestProperty("Access-Control-Allow-Origin", "http://localhost:8080");
+        connection.setRequestProperty("AccessKey", accessKey);
+        connection.setRequestProperty("Nonce", nonce);
+        connection.setRequestProperty("Timestamp", Timestamp);
+        connection.setRequestProperty("Sign", sign);
+        connection.connect();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        StringBuilder response1 = new StringBuilder();
+
+        String line;
+        while ((line = reader.readLine()) != null) {
+            response1.append(line);
+        }
+
+        reader.close();
+        connection.disconnect();
+        JSONObject jsonObject = new JSONObject(response1);
+        int code = jsonObject.getInt("code");
+        String message = jsonObject.getStr("message");
+        JSONObject result = jsonObject.getJSONObject("result");
+        int total1 = result.getInt("total");
+        JSONArray list = result.getJSONArray("list");
+
+        for (int i = 0; i < list.size(); ++i) {
+            JSONObject item = list.getJSONObject(i);
+            String msisdn = item.getStr("msisdn");
+            String iccid = item.getStr("iccid");
+            String imsi = item.getStr("imsi");
+            System.out.println("msisdn: " + msisdn + ", iccid: " + iccid + ", imsi: " + imsi);
+        }
+
+    }
+
+    @PostMapping({"proxyCardcompanyUp"})
+    public void proxyCardcompanyUp(String card, String name) throws Exception {
+        this.cardService.proxyCardcompanyUp(card, name);
+    }
+
+    @PostMapping({"proxyfindCard"})
+    public List proxyfindCard() {
+        return this.cardService.proxyfindCard();
+    }
+
+    @PostMapping({"proxyupXinXi"})
+    public int proxyupXinXi(Card card) {
+        return this.cardService.proxyupXinXi(card);
+    }
+
+    @PostMapping({"ifCard"})
+    public Card ifCard(Card card) {
+        return this.cardService.ifCard(card);
+    }
+}

--
Gitblit v1.9.3