¶Ô±ÈÐÂÎļþ |
| | |
| | | // |
| | | // 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.ExcelUtils; |
| | | import com.flow.util.result; |
| | | import com.flow.util.resultutil; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.DateFormat; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import javax.crypto.Mac; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.poi.hssf.usermodel.HSSFCell; |
| | | import org.apache.poi.hssf.usermodel.HSSFRow; |
| | | import org.apache.poi.hssf.usermodel.HSSFSheet; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | @RestController |
| | | @RequestMapping({"/hxzk"}) |
| | | public class IndexController { |
| | | @Autowired |
| | | CardService cardService; |
| | | @Autowired |
| | | CompanyService companyService; |
| | | |
| | | @Autowired |
| | | CardMapper cardMapper; |
| | | |
| | | @Autowired |
| | | OperationLogMapper operationLogMapper; |
| | | |
| | | @Autowired |
| | | OperationLogService operationLogService; |
| | | |
| | | 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; |
| | | } |
| | | |
| | | @PostMapping({"FindCard"}) |
| | | public result<List<Card>> FindCard(Integer page, Integer limit, String daoqi, String entry) throws Exception { |
| | | |
| | | PageInfo<Card> cz = this.cardService.FindCarda(page, limit, daoqi, entry); |
| | | 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)); |
| | | // } |
| | | // double twoDecimalPlaces = Double.parseDouble(String.format("%.2f", ((Card) cz.getList().get(i)).getUnitprice())); |
| | | // System.out.println(twoDecimalPlaces); |
| | | |
| | | double num = Double.parseDouble(((Card) cz.getList().get(i)).getUnitprice().toString()); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String result = df.format(num); |
| | | // System.out.println(result); |
| | | ((Card) cz.getList().get(i)).setUnitprice(Double.parseDouble(result)); |
| | | 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, String daoqi) throws Exception { |
| | | PageInfo<Card> cz = this.cardService.FindCardaZi(card, page, limit, daoqi); |
| | | 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) { |
| | | card.setCardnumber(card.getCardnumber().replaceAll(" ", "")); |
| | | 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.setCaozuoname(card.getCaozuoname()); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | */ |
| | | @RequestMapping("/excel") |
| | | // @IgnoreAuth |
| | | public void exportToExcel(HttpServletResponse response, Card card) throws IOException { |
| | | // è·åéè¦å¯¼åºçæ°æ® |
| | | List<Card> dataList = this.cardService.FindCard(); |
| | | |
| | | // å建Excelæä»¶ |
| | | HSSFWorkbook workbook = new HSSFWorkbook(); |
| | | HSSFSheet sheet = workbook.createSheet("å¡ç管ç表"); |
| | | |
| | | // å建表头 |
| | | HSSFRow headerRow = sheet.createRow(0); |
| | | String[] headers = {"æå±å
¬å¸", "å¡å·", "ç¶æ", "æµé", "å©ä½å¤©æ°", "å¼å§æ¥æ", "è¿è¥å", "åä»·", "ç»å®è®¾å¤", "ç»ææ¥æ", "å½å
¥æ¥æ", "æè¿å
弿¥æ", "å
å¼éé¢", "夿³¨"}; // æ ¹æ®ä½ çæ°æ®è°æ´åå |
| | | for (int i = 0; i < headers.length; i++) { |
| | | HSSFCell headerCell = headerRow.createCell(i); |
| | | headerCell.setCellValue(headers[i]); |
| | | } |
| | | |
| | | // å¡«å
æ°æ® |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | HSSFRow dataRow = sheet.createRow(i + 1); |
| | | Card data = dataList.get(i); |
| | | |
| | | dataRow.createCell(0).setCellValue(data.getCompany()); // å设YourDataægetField1()æ¹æ³ |
| | | dataRow.createCell(1).setCellValue(data.getCardnumber()); // å设YourDataægetField2()æ¹æ³ |
| | | dataRow.createCell(2).setCellValue(data.getStatus()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(3).setCellValue(data.getFlow()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(4).setCellValue(data.getRemainingdays()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(5).setCellValue(data.getCarddate()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(6).setCellValue(data.getOperator()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(7).setCellValue(data.getUnitprice()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(8).setCellValue(data.getBindid()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(9).setCellValue(data.getEnddate()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(10).setCellValue(data.getEnterdate()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(11).setCellValue(data.getRechargedate()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(12).setCellValue(data.getRechargemoney()); // å设YourDataægetField3()æ¹æ³ |
| | | dataRow.createCell(13).setCellValue(data.getNotes()); // å设YourDataægetField3()æ¹æ³ |
| | | // æ ¹æ®å®é
æ
åµå¡«å
å
¶ä»å段 |
| | | } |
| | | |
| | | // 设置ååºç±»ååå
容å¤ç½® |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | // response.setHeader("Content-Disposition", "attachment; filename=å¦çè¯ææ°æ®å¯¼åºè¡¨.xls"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode("å¡ç管ç表.xls", "UTF-8")); |
| | | |
| | | |
| | | // å°Excelåå
¥ååºè¾åºæµ |
| | | try (ServletOutputStream outputStream = response.getOutputStream()) { |
| | | workbook.write(outputStream); |
| | | } |
| | | |
| | | // å
³éå·¥ä½ç°¿ |
| | | // workbook.close(); |
| | | } |
| | | |
| | | @PostMapping({"addCard"}) |
| | | public ModelAndView addCard(Card card) throws Exception { |
| | | String[] str = card.getCardnumber().replaceAll(" ", "").split(";"); |
| | | String[] str1 = card.getBindid().split(";"); |
| | | System.out.println(card.getEnddate()); |
| | | 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()); |
| | | card1.setEnddate(card.getEnddate()); |
| | | card1.setEntryclerk(card.getEntryclerk()); |
| | | 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()); |
| | | card1.setEnddate(card.getEnddate()); |
| | | card1.setEntryclerk(card.getEntryclerk()); |
| | | 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(str1[i]); |
| | | card1.setLocation(card.getLocation()); |
| | | card1.setNotes(card.getNotes()); |
| | | card1.setEnterdate(card.getEnddate()); |
| | | card1.setEnddate(card.getEnddate()); |
| | | card1.setEntryclerk(card.getEntryclerk()); |
| | | 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(); |
| | | System.out.println(cz.getList().get(i).getEnddate()); |
| | | |
| | | if (cz.getList().get(i) != null) { |
| | | if (cz.getList().get(i).getEnddate() != null && !Objects.equals(cz.getList().get(i).getEnddate(), "")) { |
| | | 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 + "天"); |
| | | System.out.println(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); |
| | | } |
| | | |
| | | @GetMapping({"getcardinfo"}) |
| | | public JSONObject getcardinfo(Integer id) throws Exception { |
| | | |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("num", id); |
| | | Card card = cardMapper.selectOne(queryWrapper); |
| | | System.out.println(); |
| | | 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/detail/query?cNo=" + card.getCardnumber(); |
| | | 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"); |
| | | if (code!=0){ |
| | | |
| | | }else{ |
| | | result.set("eStatus", this.getEquipmentstatus(id)); |
| | | result.set("oStatus", this.getcardonline(id)); |
| | | } |
| | | |
| | | return jsonObject; |
| | | } |
| | | |
| | | public String getcardonline(Integer id) throws Exception { |
| | | |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("num", id); |
| | | Card card = cardMapper.selectOne(queryWrapper); |
| | | System.out.println(); |
| | | 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/online/status/query?cNo=" + card.getCardnumber(); |
| | | 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"); |
| | | |
| | | if (code!=0){ |
| | | return ""; |
| | | }else{ |
| | | return result.get("status").toString(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public String getEquipmentstatus(Integer id) throws Exception { |
| | | |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("num", id); |
| | | Card card = cardMapper.selectOne(queryWrapper); |
| | | System.out.println(); |
| | | 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/device/status/query?cNo=" + card.getCardnumber(); |
| | | 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"); |
| | | if (code!=0){ |
| | | return ""; |
| | | }else{ |
| | | return result.get("status").toString(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @PostMapping({"rebind"}) |
| | | public JSONObject rebind(String iccid,Integer bindType) throws Exception { |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("num", iccid); |
| | | Card card = cardMapper.selectOne(queryWrapper); |
| | | 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/rebind"; |
| | | URL url = new URL(targetUrl); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("POST"); |
| | | connection.setDoOutput(true); |
| | | 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); |
| | | |
| | | // æé 请æ±ä½ |
| | | JSONObject requestBody = new JSONObject(); |
| | | requestBody.put("iccid",card.getCardnumber() ); |
| | | requestBody.put("bindType", bindType); |
| | | |
| | | // å°è¯·æ±ä½åå
¥è¾åºæµ |
| | | OutputStream os = connection.getOutputStream(); |
| | | os.write(requestBody.toString().getBytes("UTF-8")); |
| | | os.flush(); |
| | | os.close(); |
| | | |
| | | 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); |
| | | // } |
| | | // if (code!=0){ |
| | | // return message; |
| | | // }else{ |
| | | return jsonObject; |
| | | // } |
| | | |
| | | } |
| | | |
| | | |
| | | @GetMapping({"conversioncard"}) |
| | | public JSONObject conversioncard(String id) throws Exception { |
| | | |
| | | |
| | | System.out.println(); |
| | | 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/detail/query?cNo=" + id; |
| | | 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"); |
| | | |
| | | |
| | | return jsonObject; |
| | | } |
| | | } |