view.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. /*
  2. * @Author: dayan_hjm
  3. * @Date: 2023-10-25 10:32:44
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2024-10-17 10:46:43
  6. */
  7. /*
  8. * @Author: dayan_hjm
  9. * @Date: 2022-10-27 11:40:02
  10. * @Last Modified by: dayan_hjm
  11. * @Last Modified time: 2023-10-25 10:32:07
  12. */
  13. import React, { useState, useEffect, Component } from "react";
  14. import styles from "./style.less";
  15. import { useHistory, useLocation, withRouter } from "react-router-dom";
  16. import { observer, observable } from "mobx-react";
  17. import { message, Space, Form, Popconfirm, Modal, Tooltip, Icon, Button } from "antd";
  18. import mod from './mod';
  19. import { toJS } from "mobx";
  20. import BottomLineForSend from "./component/bottomLineForSend.jsx";
  21. import MoodSendView from "./component/moodSendView.jsx";
  22. import OneSendView from "./component/oneSendView.jsx";
  23. import LeftMenoyView from "./component/leftMenoyView.jsx";
  24. import RightBottomView from "./component/rightBottomView.jsx";
  25. import OneQualified from "./component/oneQualified.jsx";
  26. import MapView from "./component/mapView.jsx";
  27. import $store from "@store/";
  28. import {
  29. timeService,
  30. numberService,
  31. checkToken,
  32. updateTimeService
  33. } from "./api";
  34. import { getThousandNum, deleteCacheAndChangeUrl, timestampToTime, setWaterMark } from "@utils/util";
  35. import {
  36. fullscreen,
  37. } from "@ant-design/icons";
  38. import 'animate.css';
  39. @withRouter
  40. class Home extends Component {
  41. // 构造函数,组件的实例创建时,最先执行
  42. constructor(props, context) {
  43. super(props, context);
  44. this.store = mod;
  45. this.state = {
  46. updateTime: '',
  47. changGif: false,
  48. changNun: false,
  49. plannedCompletionData: [
  50. ],
  51. plannedCompletionNum: 1,
  52. manHourData: [
  53. ],
  54. manHourNum: 1,
  55. };
  56. this.timer = null //定时器,用于检测同步状态
  57. }
  58. componentWillMount() {
  59. if (window.location.host.indexOf("localhost") == -1) {
  60. this.getToken()
  61. }
  62. }
  63. async getToken() {
  64. if (!sessionStorage.getItem("tqcVToken")) {
  65. this.props.history.replace("/home/index");
  66. } else {
  67. await checkToken(sessionStorage.getItem("tqcVToken")).then(({ data, resultCode }) => {
  68. if (data?.userId) {
  69. sessionStorage.setItem("tqcUserName", data?.userId);
  70. $store.app.setMarkSrc(
  71. setWaterMark({
  72. toDataURL: true,
  73. waterMarkText: [data?.userId || sessionStorage.getItem("tqcUserName"), timestampToTime()],
  74. })
  75. );
  76. } else {
  77. window.location = window.location.origin + '/transfer.html#/login';
  78. // this.props.history.replace("/home/index");
  79. }
  80. });
  81. }
  82. }
  83. componentDidMount() {
  84. this.fontMsgChange();
  85. this.getUrl();
  86. this.getUrl2()
  87. this.getUrl3();
  88. setTimeout(() => {
  89. this.videoStart();
  90. }, 200)
  91. setTimeout(() => {
  92. //替换gif
  93. this.setState({ changGif: true });
  94. }, 2000);
  95. setTimeout(() => {
  96. this.setState({ changNun: true });
  97. }, 4500)
  98. }
  99. videoStart() {
  100. /* Chrome 浏览器的视频自动播放策略
  101. 1.始终允许静音模式下自动播放
  102. 2.在以下的情况中,带声音播放会被允许:
  103. ①用户已经与当前的域进行了交互(也就是click,tap事件)。
  104. ②在桌面设备上,用户的媒体参与度指数阈值已经超过,这意味着用户之前播放过有声视频。
  105. ③用户已经将网站添加到移动设备上的主屏幕或允在桌面上安装了PWA。
  106. 3.顶部帧可以将自动播放权限委派给其iframe,来允许自动播放声音
  107. 媒体参与度(Media Engagement)是指用户与媒体内容进行互动的程度,可以通过多个指标来衡量。这些指标主要包括观看时间、观看率、转化率、交互行为等。
  108. 可以通过:chrome://media-engagement/ 查看
  109. */
  110. const video = document.querySelector('.video2');
  111. console.log(video.play());
  112. const model = document.querySelector('.model')
  113. const btn = document.querySelector('button')
  114. // 第一种方法 引导用户去与页面交互实现播放
  115. async function play() {
  116. try {
  117. await video.play();
  118. //使用await的原因是因为video.play()方法返回的是一个Promise,所以在这里我们可以对他进行一些处理
  119. model.style.display = 'none';
  120. btn.removeEventListener('click', play);
  121. // 如果他自动播放了就隐藏按钮,消除点击事件
  122. } catch (err) {
  123. model.style.display = 'block';
  124. btn.addEventListener('click', play);
  125. // 如果Promise返回的是error就引导用户点击按钮,在调用play方法
  126. }
  127. }
  128. play();
  129. //第二种方法比较主流,类似的有网页版抖音以及B站
  130. function play() {
  131. video.muted = true;//设置视频为静音
  132. video.play();//调用播放方法
  133. const ctx = new AudioContext();
  134. const canAutoPlay = ctx.state === 'running'; //通过这个可以判断出视频能不能够自动播放 如何可以它的值就是“running” 否则为"suspended"
  135. // 如果是不能播放我们就执行下面的逻辑,其实就是类似于第一种方法,让用户与其交互
  136. ctx.close();
  137. if (canAutoPlay) {
  138. video.muted = false;
  139. model.style.display = 'none';
  140. btn.removeEventListener('click', play);
  141. }
  142. else {
  143. model.style.display = 'block';
  144. btn.addEventListener('click', play);
  145. }
  146. }
  147. play()
  148. }
  149. async getUrl() {
  150. await timeService().then(({ data = [], resultCode }) => {
  151. if (+resultCode === 0) {
  152. let plannedCompletionData = [], manHourData = [];
  153. data.map((x, i) => {
  154. if (x.indexValue || x.indexValue == 0) {
  155. if (x.indexName == '产量计划完成率') {
  156. plannedCompletionData.push({
  157. name: x.factoryName,
  158. value: Number((x.indexValue * 100).toFixed(2)),
  159. })
  160. } else {
  161. manHourData.push({
  162. name: x.factoryName,
  163. // value: Number((x.indexValue * 100).toFixed(2)),
  164. value: Number(x.indexValue),
  165. })
  166. }
  167. }
  168. });
  169. this.setState({ plannedCompletionData, manHourData, plannedCompletionNum: 1, manHourNum: 1 });
  170. }
  171. });
  172. }
  173. async getUrl2() {
  174. await numberService().then(({ data = [], resultCode }) => {
  175. if (+resultCode === 0) {
  176. let totalValue = 0, productInventory=0,yearDecline = 0, yearSend = 0, annualPlan = 0, implementationOfThePlan = 0;
  177. data.map((x, i) => {
  178. if (x.IndexCode == '1') {
  179. yearDecline = x.IndexValue
  180. } else if (x.IndexCode == '2') {
  181. productInventory = x.IndexValue
  182. } else if (x.IndexCode == '3') {
  183. yearSend = x.IndexValue
  184. } else if (x.IndexCode == '4') {
  185. annualPlan = x.IndexValue //年度产量完成率
  186. } else if (x.IndexCode == '5') {
  187. implementationOfThePlan = x.IndexValue //年度锂辉石执行率
  188. }
  189. });
  190. this.store.saveState({ totalValue, yearDecline, yearSend, productInventory,annualPlan,implementationOfThePlan });
  191. setTimeout(() => {
  192. $(".shu1").numScroll();
  193. }, 2500)
  194. }
  195. });
  196. }
  197. async getUrl3() {
  198. await updateTimeService().then(({ data = [], resultCode }) => {
  199. if (+resultCode === 0) {
  200. this.setState({ updateTime: data?.[0]?.etlTime || '' })
  201. }
  202. });
  203. }
  204. componentWillUnmount() {
  205. clearInterval(this.timer);
  206. this.timer = null;
  207. }
  208. fontMsgChange(type) {
  209. this.timer = setInterval(() => {
  210. const { plannedCompletionData, plannedCompletionNum, manHourData, manHourNum } = this.state;
  211. //产量计划完成率
  212. var p1 = document.getElementById('plannedCompletionBox');
  213. const datas_ = plannedCompletionData[plannedCompletionNum - 1];
  214. var res = "";
  215. if (datas_) {
  216. if (type) {
  217. res = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number">' + getThousandNum(datas_?.value.toFixed(2)) + '</span><span class="topMsg_number_2" style={{fontSize: "0.75em",color: "#fff"}}>%</span><p class="topMsg_number_p">' + datas_?.name + '</p></div>';
  218. } else {
  219. res = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number shu1">' + datas_?.value.toFixed(2) + '</span><span class="topMsg_number_2" style={{fontSize: "0.75em",color: "#fff"}}>%</span><p class="topMsg_number_p">' + datas_?.name + '</p></div>';
  220. }
  221. }
  222. p1.innerHTML = res;
  223. //百万工时损工率
  224. var p2 = document.getElementById('manHourBox');
  225. const datas_2 = manHourData[manHourNum - 1];
  226. var res2 = "";
  227. if (datas_2) {
  228. if (type) {
  229. res2 = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number">' + getThousandNum(datas_2?.value.toFixed(2)) + '</span><p class="topMsg_number_p">' + datas_2?.name + '</p></div>';//<span class="topMsg_number_2">%</span>
  230. } else {
  231. res2 = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number shu1">' + datas_2?.value.toFixed(2) + '</span><p class="topMsg_number_p">' + datas_2?.name + '</p></div>';
  232. }
  233. }
  234. p2.innerHTML = res2;
  235. const num_ = plannedCompletionNum + 1 > plannedCompletionData.length ? 1 : plannedCompletionNum + 1;
  236. const num_2 = manHourNum + 1 > manHourData.length ? 1 : manHourNum + 1;
  237. this.setState({ plannedCompletionNum: num_, manHourNum: num_2 })
  238. }, 4000)
  239. }
  240. render() {
  241. const stores = this.store.state;
  242. let { totalValue, yearDecline, yearSend, productInventory,annualPlan,implementationOfThePlan } = this.store.state;
  243. let { changGif, updateTime, changNun } = this.state;
  244. return (
  245. <div className={[styles.tlk_box + ' home_box ']}>
  246. {/* 水印 */}
  247. {
  248. window.urlConfig && window.urlConfig.SHOW_WATERMARK && <div className={"shuiYin"} style={{ backgroundImage: `url(${$store.app.markSrc})`, backgroundRepeat: 'repeat' }}></div>
  249. }
  250. {/* 右键切换大屏 */}
  251. <Tooltip placement="bottom" title={"运营数据中心"}>
  252. <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {
  253. deleteCacheAndChangeUrl("/home/operation", (url) => {
  254. this.props.history.replace(url);
  255. })
  256. }} />
  257. </Tooltip>
  258. <Tooltip placement="bottom" title={"产供销价值链"}>
  259. <img src={require("@assets/imgs/iconJpg/rightJL.png").default} alt="" className={"rightJ_png rightJ_png_L"} onClick={() => {
  260. deleteCacheAndChangeUrl("/home/gvc", (url) => {
  261. this.props.history.replace(url);
  262. })
  263. }} />
  264. </Tooltip>
  265. {/* 视频播放器 */}
  266. <MapView></MapView>
  267. <div className={"video_box"}>
  268. <video src={require("@assets/imgs/dataVImg/tlk2.mp4").default} autoplay="autoplay" loop="loop" class="video2 center_box2 animate__animated animate__fadeIn animate__delay-1s"></video>
  269. </div>
  270. <div className={[styles.home + " home cbHome"]}>
  271. <div className="leftContent">
  272. <div class="bottomContent2 animate__animated animate__fadeInDown animate__slower animate__delay-2s">
  273. <div className="bottomContent bigDivPd">
  274. <Tooltip placement="bottom" title={' ● 近六个月的产量和发货量的对比数据(含外加工),当月的数据计算至更新日期。'}>
  275. <p className="topMsg_title">产品月度产量 <span className="topMsg_tips">/ Monthly Net Production</span></p>
  276. </Tooltip>
  277. <div className="topMsg_content">
  278. <OneSendView></OneSendView>
  279. </div>
  280. </div>
  281. </div>
  282. <div class="bottomContent2 animate__animated animate__fadeInDown animate__slower animate__delay-2s">
  283. <div className="bottomContent bigDivPd">
  284. <Tooltip placement="bottom" title={' ● 近六个月的产量和发货量的对比数据(含外加工),当月的数据计算至更新日期。'}>
  285. <p className="topMsg_title">产品发货量 <span className="topMsg_tips">/ Lithium Shipment</span></p>
  286. </Tooltip>
  287. <div className="topMsg_content">
  288. <MoodSendView></MoodSendView>
  289. </div>
  290. </div>
  291. </div>
  292. <div class="center_box2 animate__animated animate__fadeInDown animate__slower animate__delay-1s">
  293. <div className="center_box">
  294. <Tooltip placement="bottom" title={<p className="titpeP">
  295. <p>● 截止更新日期的主产品库存金额,计算:</p>
  296. <img src={require("@assets/imgs/dataVimg/gongshi2.png").default} alt="" style={{ width: "1.3em", margin: " -0.3em 0.5em 0 0em" }} />
  297. 物料1库存数*物料1移动平均价+物料2*物料2移动平均价+…
  298. </p>}>
  299. <p className="topMsg_title" style={{ position: "relative", zIndex: 999999 }}>产品库存 <span className="topMsg_tips">/ Lithium Inventory</span></p>
  300. </Tooltip>
  301. <div className="topMsg_content">
  302. <LeftMenoyView></LeftMenoyView>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. <div className="centerCon">
  308. <div class="topMsg3 animate__animated animate__fadeInUp animate__slower">
  309. <div className="topMsg">
  310. <div className="topMsg2">
  311. <div className="topMsg_content">
  312. <div className="center_li">
  313. <div className="right_li">
  314. {
  315. !changNun && <span className="topMsg_number" class="shu1">{yearDecline}</span>
  316. }
  317. {
  318. changNun && <span className="topMsg_number">{getThousandNum(yearDecline)}</span>
  319. }
  320. <p className="topMsg_line"></p>
  321. <Tooltip placement="bottom" title={' ● 本年度截止更新日期的主产品(含外加工)的产量合计'}>
  322. <span className="topMsg_tip">年度发货量/吨</span>
  323. <span className="topMsg_tip topMsg_tip2">Annual Shipments / t</span>
  324. </Tooltip>
  325. </div>
  326. </div>
  327. <div className="center_li">
  328. <div className="right_li">
  329. {
  330. !changNun && <span className="topMsg_number" class="shu1">{productInventory}</span>
  331. }
  332. {
  333. changNun && <span className="topMsg_number">{getThousandNum(productInventory)}</span>
  334. }
  335. <p className="topMsg_line"></p>
  336. <Tooltip placement="bottom" title={' ● 本年度截止更新日期的主产品(含外加工)的发货量合计。'}>
  337. <span className="topMsg_tip">年度产量/吨</span>
  338. <span className="topMsg_tip topMsg_tip2">Annual Production / t</span>
  339. </Tooltip>
  340. </div>
  341. </div>
  342. <div className="center_li" style={{ marginTop: '-24px', height: '78%' }}>
  343. {
  344. !changNun && <span className="topMsg_number" class="shu1">{yearSend}</span>
  345. }
  346. {
  347. changNun && <span className="topMsg_number">{getThousandNum(yearSend,true)}%</span>
  348. }
  349. <p className="topMsg_line"></p>
  350. <Tooltip placement="bottom" title={' ● 截止更新日期的主产品库存数量。'}>
  351. <span className="topMsg_tip">年度产品一次合格率</span>
  352. <span className="topMsg_tip topMsg_tip2">Annual First Pass Yield</span>
  353. </Tooltip>
  354. </div>
  355. </div>
  356. </div>
  357. </div>
  358. </div>
  359. <div class="bottomContent3 animate__animated animate__fadeInUp animate__slower animate__delay-1s">
  360. <div className="bottomContent">
  361. <Tooltip placement="bottom" title={' ● 以更新日期为节点近30天的产量数据(含外加工)。'}>
  362. <p className="topMsg_title">近90天产量 <span className="topMsg_tips">/ Net Production in the last 90 days</span></p>
  363. </Tooltip>
  364. <div className="topMsg_content">
  365. <BottomLineForSend></BottomLineForSend>
  366. </div>
  367. </div>
  368. </div>
  369. </div>
  370. {/* 右侧信息栏 */}
  371. <div className="rightContent">
  372. <div class="topMsg2 animate__animated animate__fadeInDown animate__slower">
  373. <div className="topMsg bigDivPd">
  374. <Tooltip placement="bottom" title={' ● 近一年的百万工时损工率。'}>
  375. <p className="topMsg_title">计划完成率 <span className="topMsg_tips">/ Plan Completion Rate</span></p>
  376. </Tooltip>
  377. <div className={changGif ? "topMsg_content changBg_topMsg_content" : "topMsg_content"} id="manHourBox">
  378. <div className="topMsg_box">
  379. <p className="topMsg_number_p topMsg_number_p_big">年度产量计划完成率</p>
  380. <p className="topMsg_number_p">Completion rate of</p>
  381. <p className="topMsg_number_p" style={{marginBottom:'0.05rem'}}>annual production plan</p>
  382. <span className="topMsg_number" class="shu1">{getThousandNum(annualPlan,true)}</span>
  383. <span className="topMsg_number_2">%</span>
  384. </div>
  385. <div className="topMsg_box">
  386. <p className="topMsg_number_p topMsg_number_p_big">年度锂辉石计划执行率</p>
  387. <p className="topMsg_number_p">Annual lithium pyroxene</p>
  388. <p className="topMsg_number_p" style={{marginBottom:'0.05rem'}}>plan execution rate</p>
  389. <span className="topMsg_number" class="shu1">{getThousandNum(implementationOfThePlan,true)}</span>
  390. <span className="topMsg_number_2">%</span>
  391. </div>
  392. </div>
  393. </div>
  394. </div>
  395. <div class="topMsg_22 animate__animated animate__fadeInDown animate__slower">
  396. <div className="topMsg_2">
  397. <Tooltip placement="bottom" title={' ● 近六个月的主产品一次合格率,当月的数据计算至更新日期。'}>
  398. <p className="topMsg_title">锂辉石消耗量 <span className="topMsg_tips">/ Spodumene Consumption</span></p>
  399. </Tooltip>
  400. <div className="topMsg_content">
  401. <OneQualified></OneQualified>
  402. </div>
  403. </div>
  404. </div>
  405. <div class="bottomContent2 animate__animated animate__fadeInDown animate__slower animate__delay-1s">
  406. <div className="bottomContent bigDivPd">
  407. <Tooltip placement="bottom" title={' ● 近三年的碳排放总量、碳排放强度数据'}>
  408. <p className="topMsg_title">产品一次合格率 <span className="topMsg_tips">/ First Pass Yield</span></p>
  409. </Tooltip>
  410. <div className="topMsg_content">
  411. <RightBottomView></RightBottomView>
  412. </div>
  413. </div>
  414. </div>
  415. </div>
  416. <div className="bottom_box">
  417. <p style={{ color: "#6a818d", lineHeight: '2px' }}>
  418. 更新日期 : {updateTime ? updateTime.split(" ")[0] : updateTime}
  419. </p>
  420. </div>
  421. </div>
  422. </div>
  423. )
  424. }
  425. }
  426. export default Home;