feat: 全面代码更新 - ECharts 5.4.2 重构、新增量化分析模块、前端库升级
- 升级 ECharts 到 5.4.2,重构 lib/ 目录结构 - 新增 DataTables 2.x 和 FixedColumns 插件 - 新增 quant/ 宏观研究报告模块 - 重构图表页面:stock_trend、hkholdbycode 等采用 JS fetch API.doorcome.cn 模式 - 新增 CLAUDE.md 补充页面文档和新数据流说明 - 更新 inc/config.php TuShare API 配置 - 更新新闻联播分析模块 news/ 和相关研究报告 research/ - 新增 api_document/ 参考文档 - 清理 .gitignore,排除 uploads/xls/.mcp.json/ source maps 等非代码文件 - 所有 PHP 文件通过 php -l 语法检查 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+62
-62
@@ -1,63 +1,63 @@
|
||||
<?php
|
||||
define('TUSHARE_API_TOKEN', '1bc28452ba375da19320cda845ae6307578964cb3ae473d0dc702aea');
|
||||
|
||||
function get_db_config() {
|
||||
return [
|
||||
'host' => 'localhost',
|
||||
'username' => 'myquant',
|
||||
'password' => '_H(lU1_fF*9baRTp',
|
||||
'database' => 'myquant',
|
||||
'charset' => 'utf8mb4'
|
||||
];
|
||||
}
|
||||
|
||||
function get_mysqli_connection() {
|
||||
$db_config = get_db_config();
|
||||
$mysqli = new mysqli(
|
||||
$db_config['host'],
|
||||
$db_config['username'],
|
||||
$db_config['password'],
|
||||
$db_config['database']
|
||||
);
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die("Connection failed: " . $mysqli->connect_error);
|
||||
}
|
||||
|
||||
$mysqli->set_charset($db_config['charset']);
|
||||
return $mysqli;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数化查询,防止SQL注入。返回mysqli_result或false。
|
||||
* @param mysqli $mysqli
|
||||
* @param string $sql 带 ? 占位符的SQL
|
||||
* @param array $params 参数值数组
|
||||
* @return \mysqli_result|false
|
||||
*/
|
||||
function db_query($mysqli, $sql, $params = []) {
|
||||
$stmt = $mysqli->prepare($sql);
|
||||
if (!$stmt) return false;
|
||||
if ($params) {
|
||||
$types = str_repeat('s', count($params));
|
||||
$stmt->bind_param($types, ...$params);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一JSON响应格式
|
||||
* @param mixed $data 响应数据
|
||||
* @param string $status ok|error
|
||||
* @param string $message 错误信息
|
||||
*/
|
||||
function jsonResponse($data = null, $status = 'ok', $message = '') {
|
||||
$response = ['status' => $status];
|
||||
if ($data !== null) $response['data'] = $data;
|
||||
if ($message) $response['message'] = $message;
|
||||
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
exit();
|
||||
<?php
|
||||
define('TUSHARE_API_TOKEN', '1bc28452ba375da19320cda845ae6307578964cb3ae473d0dc702aea');
|
||||
|
||||
function get_db_config() {
|
||||
return [
|
||||
'host' => 'localhost',
|
||||
'username' => 'myquant',
|
||||
'password' => '_H(lU1_fF*9baRTp',
|
||||
'database' => 'myquant',
|
||||
'charset' => 'utf8mb4'
|
||||
];
|
||||
}
|
||||
|
||||
function get_mysqli_connection() {
|
||||
$db_config = get_db_config();
|
||||
$mysqli = new mysqli(
|
||||
$db_config['host'],
|
||||
$db_config['username'],
|
||||
$db_config['password'],
|
||||
$db_config['database']
|
||||
);
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die("Connection failed: " . $mysqli->connect_error);
|
||||
}
|
||||
|
||||
$mysqli->set_charset($db_config['charset']);
|
||||
return $mysqli;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数化查询,防止SQL注入。返回mysqli_result或false。
|
||||
* @param mysqli $mysqli
|
||||
* @param string $sql 带 ? 占位符的SQL
|
||||
* @param array $params 参数值数组
|
||||
* @return \mysqli_result|false
|
||||
*/
|
||||
function db_query($mysqli, $sql, $params = []) {
|
||||
$stmt = $mysqli->prepare($sql);
|
||||
if (!$stmt) return false;
|
||||
if ($params) {
|
||||
$types = str_repeat('s', count($params));
|
||||
$stmt->bind_param($types, ...$params);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一JSON响应格式
|
||||
* @param mixed $data 响应数据
|
||||
* @param string $status ok|error
|
||||
* @param string $message 错误信息
|
||||
*/
|
||||
function jsonResponse($data = null, $status = 'ok', $message = '') {
|
||||
$response = ['status' => $status];
|
||||
if ($data !== null) $response['data'] = $data;
|
||||
if ($message) $response['message'] = $message;
|
||||
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
exit();
|
||||
}
|
||||
+177
-121
@@ -1,122 +1,178 @@
|
||||
<?php
|
||||
/**
|
||||
* 宁波各区县List
|
||||
*/
|
||||
function districtList(){
|
||||
?>
|
||||
<select name='district' id='district'>
|
||||
<option value='北仑区'>北仑区</option>
|
||||
<option value='余姚市'>余姚市</option>
|
||||
<option value='海曙区'>海曙区</option>
|
||||
<option value='江北区'>江北区</option>
|
||||
<option value='镇海区'>镇海区</option>
|
||||
<option value='鄞州区'>鄞州区</option>
|
||||
<option value='奉化区'>奉化区</option>
|
||||
<option value='慈溪市'>慈溪市</option>
|
||||
<option value='宁海县'>宁海县</option>
|
||||
<option value='象山县'>象山县</option>
|
||||
<option value='合计'>合计</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
function indexList($id='code'): void{
|
||||
?>
|
||||
<select name='<?=$id?>' id='<?=$id?>'>
|
||||
<option value='000001.SH'>上证指数</option>
|
||||
<option value='399001.SZ'>深圳成指</option>
|
||||
<option value='399005.SZ'>中小板指</option>
|
||||
<option value='399006.SZ'>创业板指</option>
|
||||
<option value='000016.SH'>上证50</option>
|
||||
<option value='399300.SZ'>沪深300</option>
|
||||
<option value='399905.SZ'>中证500</option>
|
||||
<option value='899050.BJ'>北证50</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/* 证券交易所list */
|
||||
function seList($id='se'): void{
|
||||
?>
|
||||
<select name='<?=$id?>' id='<?=$id?>'>
|
||||
<option value='SSE'>上交所</option>
|
||||
<option value='SZSE'>深交所</option>
|
||||
<option value='BSE'>北交所</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/* select list by Day month */
|
||||
function byDM($id,$oid,$nid){
|
||||
$str=<<<EOF
|
||||
<select name='{$id}' id='{$id}' onchange="dmChange('{$id}','{$oid}','{$nid}');">
|
||||
<option value='Daily'>Daily</option>
|
||||
<option value='Monthly'>Monthly</option>
|
||||
</select>
|
||||
EOF;
|
||||
echo $str;
|
||||
}
|
||||
|
||||
|
||||
// 辅助函数:调用TuShare API
|
||||
function callTushareApi($method, $params){
|
||||
$token = TUSHARE_API_TOKEN;
|
||||
// 将参数编码为JSON格式
|
||||
$postData = json_encode([
|
||||
"api_name" => $method,
|
||||
"token" => $token,
|
||||
"params" => $params,
|
||||
"fields" => "" // 其他字段需要根据具体API调整
|
||||
]);
|
||||
// 初始化cURL会话
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://api.tushare.pro');
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($postData)
|
||||
]);
|
||||
|
||||
// 执行cURL请求
|
||||
$response = curl_exec($ch);
|
||||
$err = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// 调试输出:打印请求和响应信息
|
||||
if (debug_enabled()) { // 假设这是一个函数,用于检查是否启用了调试模式
|
||||
error_log("TuShare API Request: " . $postData);
|
||||
error_log("TuShare API Response: " . $response);
|
||||
}
|
||||
|
||||
// 错误处理
|
||||
if ($err) {
|
||||
error_log("cURL error: " . $err);
|
||||
return "cURL error: " . $err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
// 检查API调用是否成功
|
||||
if (isset($responseData['code']) && $responseData['code'] != 200) {
|
||||
error_log("TuShare API Error: " . $responseData['msg']);
|
||||
return "TuShare API Error: " . $responseData['msg'];
|
||||
}
|
||||
|
||||
if (isset($responseData['data']) && isset($responseData['data']['items'])) {
|
||||
return $responseData['data']['items'];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 假设的调试模式开关函数
|
||||
function debug_enabled()
|
||||
{
|
||||
// 这里可以根据实际情况来设置调试模式的开关条件
|
||||
// 例如,可以检查环境变量、配置文件或HTTP请求头等
|
||||
return true; // 或者返回一个条件表达式的结果
|
||||
}
|
||||
<?php
|
||||
include_once __DIR__ . "/config.php";
|
||||
/**
|
||||
* 宁波各区县List
|
||||
*/
|
||||
function districtList(){
|
||||
?>
|
||||
<select name='district' id='district'>
|
||||
<option value='北仑区'>北仑区</option>
|
||||
<option value='余姚市'>余姚市</option>
|
||||
<option value='海曙区'>海曙区</option>
|
||||
<option value='江北区'>江北区</option>
|
||||
<option value='镇海区'>镇海区</option>
|
||||
<option value='鄞州区'>鄞州区</option>
|
||||
<option value='奉化区'>奉化区</option>
|
||||
<option value='慈溪市'>慈溪市</option>
|
||||
<option value='宁海县'>宁海县</option>
|
||||
<option value='象山县'>象山县</option>
|
||||
<option value='合计'>合计</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
function indexList($id='code'): void{
|
||||
?>
|
||||
<select name='<?=$id?>' id='<?=$id?>'>
|
||||
<option value='000001.SH'>上证指数</option>
|
||||
<option value='399001.SZ'>深圳成指</option>
|
||||
<option value='399005.SZ'>中小板指</option>
|
||||
<option value='399006.SZ'>创业板指</option>
|
||||
<option value='000016.SH'>上证50</option>
|
||||
<option value='399300.SZ'>沪深300</option>
|
||||
<option value='399905.SZ'>中证500</option>
|
||||
<option value='899050.BJ'>北证50</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/* 证券交易所list */
|
||||
function seList($id='se'): void{
|
||||
?>
|
||||
<select name='<?=$id?>' id='<?=$id?>'>
|
||||
<option value='SSE'>上交所</option>
|
||||
<option value='SZSE'>深交所</option>
|
||||
<option value='BSE'>北交所</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/* select list by Day month */
|
||||
function byDM($id,$oid,$nid){
|
||||
$str=<<<EOF
|
||||
<select name='{$id}' id='{$id}' onchange="dmChange('{$id}','{$oid}','{$nid}');">
|
||||
<option value='Daily'>Daily</option>
|
||||
<option value='Monthly'>Monthly</option>
|
||||
</select>
|
||||
EOF;
|
||||
echo $str;
|
||||
}
|
||||
|
||||
|
||||
// 辅助函数:调用TuShare API
|
||||
function callTushareApi($method, $params){
|
||||
$token = TUSHARE_API_TOKEN;
|
||||
// 将参数编码为JSON格式
|
||||
$postData = json_encode([
|
||||
"api_name" => $method,
|
||||
"token" => $token,
|
||||
"params" => $params,
|
||||
"fields" => "" // 其他字段需要根据具体API调整
|
||||
]);
|
||||
// 初始化cURL会话
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://api.tushare.pro');
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($postData)
|
||||
]);
|
||||
|
||||
// 执行cURL请求
|
||||
$response = curl_exec($ch);
|
||||
$err = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// 调试输出:打印请求和响应信息
|
||||
if (debug_enabled()) { // 假设这是一个函数,用于检查是否启用了调试模式
|
||||
error_log("TuShare API Request: " . $postData);
|
||||
error_log("TuShare API Response: " . $response);
|
||||
}
|
||||
|
||||
// 错误处理
|
||||
if ($err) {
|
||||
error_log("cURL error: " . $err);
|
||||
return "cURL error: " . $err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
// 检查API调用是否成功
|
||||
if (isset($responseData['code']) && $responseData['code'] != 200) {
|
||||
error_log("TuShare API Error: " . $responseData['msg']);
|
||||
return "TuShare API Error: " . $responseData['msg'];
|
||||
}
|
||||
|
||||
if (isset($responseData['data']) && isset($responseData['data']['items'])) {
|
||||
return $responseData['data']['items'];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 假设的调试模式开关函数
|
||||
function debug_enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录页面访问日志
|
||||
*/
|
||||
function log_pv(){
|
||||
$mysqli = get_mysqli_connection();
|
||||
$vpage = $_SERVER['PHP_SELF'];
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$qs = $_SERVER['QUERY_STRING'];
|
||||
$vtime = date("Y-m-d H:i:s");
|
||||
$sql = "insert into pv_log(vpage,querystring,remoteip,ua,vtime) values (?,?,?,?,?)";
|
||||
db_query($mysqli, $sql, [$vpage, $qs, $ip, $ua, $vtime]);
|
||||
$mysqli->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面访问计数器,输出命中数
|
||||
*/
|
||||
function pv_counter($user=''){
|
||||
$mysqli = get_mysqli_connection();
|
||||
$page = $_SERVER['PHP_SELF'];
|
||||
$lmtime = date("Y-m-d H:i:s");
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$result = db_query($mysqli, "select hits from pv_counter where page_name = ?", [$page]);
|
||||
$rt = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$n = count($rt);
|
||||
|
||||
if($n < 1){
|
||||
db_query($mysqli,
|
||||
"insert into pv_counter(page_id,Page_name,hits,lm_date,lm_ip,lm_user) values (null,?,1,?,?,?)",
|
||||
[$page, $lmtime, $ip, $user]);
|
||||
$hits = 1;
|
||||
} elseif($n == 1){
|
||||
$hits = $rt[0]['hits'] + 1;
|
||||
db_query($mysqli,
|
||||
"update pv_counter set hits = ?, lm_date = ?, lm_ip = ?, lm_user = ? where page_name = ?",
|
||||
[$hits, $lmtime, $ip, $user, $page]);
|
||||
} else {
|
||||
$mysqli->close();
|
||||
return "<p align='center'>There is error on pv_counter</p>";
|
||||
}
|
||||
|
||||
$result = db_query($mysqli, "select sum(hits) hits_all from pv_counter");
|
||||
$hits_all = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$mysqli->close();
|
||||
echo "Page hits: " . $hits . " Total: " . $hits_all[0]['hits_all'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面访问统计(日志+计数器)
|
||||
*/
|
||||
function page_counter(){
|
||||
log_pv();
|
||||
pv_counter();
|
||||
}
|
||||
?>
|
||||
+95
-95
@@ -1,96 +1,96 @@
|
||||
<?php
|
||||
include_once __DIR__."/config.php";
|
||||
function getEstateData($city, $fDate, $toDate){
|
||||
$mysqli = get_mysqli_connection();
|
||||
$sql = "SELECT city, listdate, sum(nums) as num FROM estate_listing where listdate >= ? and listdate <= ? and city = ? group by listdate";
|
||||
$result = db_query($mysqli, $sql, [$fDate, $toDate, $city]);
|
||||
$data=array();
|
||||
if($result && $result->num_rows>0) {
|
||||
while($row = $result->fetch_assoc()){
|
||||
array_push($data,array("value"=>array($row['listdate'],$row['num'])));
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function esfTradeDaily(){
|
||||
global $mysqli;
|
||||
$district = $_REQUEST['district'];
|
||||
$t_start = $_REQUEST['t_start'];
|
||||
$t_end = $_REQUEST['t_end'];
|
||||
if($_REQUEST['dm']=='Daily'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m-%d') td, eje.val district, eje1.val qty, eje2.val area
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+4
|
||||
where ej.data_type='5' and ej.tdate >= ? and ej.tdate <= ?
|
||||
order by ej.tdate asc";
|
||||
$params = [$district, $t_start, $t_end];
|
||||
}
|
||||
if($_REQUEST['dm']=='Monthly'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m') td, eje.val district, sum(eje1.val) qty, sum(eje2.val) area
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+4
|
||||
where ej.data_type='5'";
|
||||
$params = [$district];
|
||||
if($t_start) {
|
||||
$sql .= " and ej.tdate >= ?";
|
||||
$params[] = $t_start . '-01';
|
||||
}
|
||||
if($t_end) {
|
||||
$endDate = new DateTime($t_end);
|
||||
$endDate->modify('last day of this month');
|
||||
$sql .= " and ej.tdate <= ?";
|
||||
$params[] = $endDate->format('Y-m-d');
|
||||
}
|
||||
$sql .= " group by date_format(tdate,'%Y-%m') order by date_format(tdate,'%Y-%m') asc";
|
||||
}
|
||||
$result = db_query($mysqli, $sql, $params);
|
||||
$data = $result->fetch_all(MYSQLI_ASSOC);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function esfListDaily(){
|
||||
global $mysqli;
|
||||
$district = $_REQUEST['district'];
|
||||
$t_start = $_REQUEST['t_start'];
|
||||
$t_end = $_REQUEST['t_end'];
|
||||
if($_REQUEST['dm']=='Daily'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m-%d') td, eje.val district, eje1.val qty, eje2.val price
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+5
|
||||
where ej.data_type='8' and ej.tdate >= ? and ej.tdate <= ?
|
||||
order by ej.tdate asc";
|
||||
$params = [$district, $t_start, $t_end];
|
||||
}
|
||||
if($_REQUEST['dm']=='Monthly'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m') td, eje.val district, sum(eje1.val) qty, sum(eje2.val) price
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+5
|
||||
where ej.data_type='8'";
|
||||
$params = [$district];
|
||||
if($t_start) {
|
||||
$sql .= " and ej.tdate >= ?";
|
||||
$params[] = $t_start . '-01';
|
||||
}
|
||||
if($t_end) {
|
||||
$endDate = new DateTime($t_end);
|
||||
$endDate->modify('last day of this month');
|
||||
$sql .= " and ej.tdate <= ?";
|
||||
$params[] = $endDate->format('Y-m-d');
|
||||
}
|
||||
$sql .= " group by date_format(tdate,'%Y-%m') order by date_format(tdate,'%Y-%m') asc";
|
||||
}
|
||||
$result = db_query($mysqli, $sql, $params);
|
||||
$data = $result->fetch_all(MYSQLI_ASSOC);
|
||||
return $data;
|
||||
}
|
||||
<?php
|
||||
include_once __DIR__."/config.php";
|
||||
function getEstateData($city, $fDate, $toDate){
|
||||
$mysqli = get_mysqli_connection();
|
||||
$sql = "SELECT city, listdate, sum(nums) as num FROM estate_listing where listdate >= ? and listdate <= ? and city = ? group by listdate";
|
||||
$result = db_query($mysqli, $sql, [$fDate, $toDate, $city]);
|
||||
$data=array();
|
||||
if($result && $result->num_rows>0) {
|
||||
while($row = $result->fetch_assoc()){
|
||||
array_push($data,array("value"=>array($row['listdate'],$row['num'])));
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function esfTradeDaily(){
|
||||
global $mysqli;
|
||||
$district = $_REQUEST['district'];
|
||||
$t_start = $_REQUEST['t_start'];
|
||||
$t_end = $_REQUEST['t_end'];
|
||||
if($_REQUEST['dm']=='Daily'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m-%d') td, eje.val district, eje1.val qty, eje2.val area
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+4
|
||||
where ej.data_type='5' and ej.tdate >= ? and ej.tdate <= ?
|
||||
order by ej.tdate asc";
|
||||
$params = [$district, $t_start, $t_end];
|
||||
}
|
||||
if($_REQUEST['dm']=='Monthly'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m') td, eje.val district, sum(eje1.val) qty, sum(eje2.val) area
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+4
|
||||
where ej.data_type='5'";
|
||||
$params = [$district];
|
||||
if($t_start) {
|
||||
$sql .= " and ej.tdate >= ?";
|
||||
$params[] = $t_start . '-01';
|
||||
}
|
||||
if($t_end) {
|
||||
$endDate = new DateTime($t_end);
|
||||
$endDate->modify('last day of this month');
|
||||
$sql .= " and ej.tdate <= ?";
|
||||
$params[] = $endDate->format('Y-m-d');
|
||||
}
|
||||
$sql .= " group by date_format(tdate,'%Y-%m') order by date_format(tdate,'%Y-%m') asc";
|
||||
}
|
||||
$result = db_query($mysqli, $sql, $params);
|
||||
$data = $result->fetch_all(MYSQLI_ASSOC);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function esfListDaily(){
|
||||
global $mysqli;
|
||||
$district = $_REQUEST['district'];
|
||||
$t_start = $_REQUEST['t_start'];
|
||||
$t_end = $_REQUEST['t_end'];
|
||||
if($_REQUEST['dm']=='Daily'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m-%d') td, eje.val district, eje1.val qty, eje2.val price
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+5
|
||||
where ej.data_type='8' and ej.tdate >= ? and ej.tdate <= ?
|
||||
order by ej.tdate asc";
|
||||
$params = [$district, $t_start, $t_end];
|
||||
}
|
||||
if($_REQUEST['dm']=='Monthly'){
|
||||
$sql = "SELECT distinct(ej.uuid) uid, date_format(tdate,'%Y-%m') td, eje.val district, sum(eje1.val) qty, sum(eje2.val) price
|
||||
FROM estate_json ej
|
||||
left join estate_json_ext eje on ej.uuid=eje.uuid and eje.val = ?
|
||||
left join estate_json_ext eje1 on eje1.id=eje.id+3
|
||||
left join estate_json_ext eje2 on eje2.id=eje.id+5
|
||||
where ej.data_type='8'";
|
||||
$params = [$district];
|
||||
if($t_start) {
|
||||
$sql .= " and ej.tdate >= ?";
|
||||
$params[] = $t_start . '-01';
|
||||
}
|
||||
if($t_end) {
|
||||
$endDate = new DateTime($t_end);
|
||||
$endDate->modify('last day of this month');
|
||||
$sql .= " and ej.tdate <= ?";
|
||||
$params[] = $endDate->format('Y-m-d');
|
||||
}
|
||||
$sql .= " group by date_format(tdate,'%Y-%m') order by date_format(tdate,'%Y-%m') asc";
|
||||
}
|
||||
$result = db_query($mysqli, $sql, $params);
|
||||
$data = $result->fetch_all(MYSQLI_ASSOC);
|
||||
return $data;
|
||||
}
|
||||
?>
|
||||
+110
-110
@@ -1,111 +1,111 @@
|
||||
<?php
|
||||
ob_start();
|
||||
include_once "../include/config.inc.php"; //Include config file;
|
||||
$db = new ora();
|
||||
$title="计划设置";
|
||||
include_once "head.php"; //include head file
|
||||
echo $hr;
|
||||
|
||||
$t = 1; //initial type to 1;
|
||||
if($_REQUEST['doSubmit']) bom_op($_REQUEST['t']); //operate when submit
|
||||
if($_REQUEST['bomid'] and !$_REQUEST['doSubmit']) {
|
||||
$bom = bom_data_by_id();
|
||||
$_REQUEST["bom"] = $bom['BOMNAME'];
|
||||
$_REQUEST["bomid"] = $bom['BOMID'];
|
||||
$_REQUEST["bomnote"] = $bom['FNOTE'];
|
||||
$_REQUEST["flowid"] = $bom['FLOWID'];
|
||||
$_REQUEST["ver"] = $bom['VER'];
|
||||
$t = 0;
|
||||
}
|
||||
?>
|
||||
<link rel="stylesheet" href="../lib/layui/css/layui.min.css">
|
||||
|
||||
<div id="mainContent">
|
||||
<h2><?php echo $title; ?></h2>
|
||||
<form name="formhead" id="formhead" method="post" enctype="multipart/form-data" >
|
||||
<div class="layui-inline">
|
||||
<input type="file" id="file" name="file" class="layui-btn">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button type="button" class="layui-btn" id="btnUpload">
|
||||
<i class="layui-icon"></i>EXCEL上传验证
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<form name="form2" id="form2" method="post" >
|
||||
<div class="stay_center" id="fblock" style="display: none">
|
||||
<div style="margin-top:10px;" id="ftext" class="layui-col-md12"></div>
|
||||
<input type="hidden" name="fpath" id="fpath" value="">
|
||||
<div class="layui-inline">
|
||||
<input type="button" id="btnExcel" value="处理上传文件" class="layui-btn">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#btnUpload").click(function () {
|
||||
console.log("Upload button clicked!");
|
||||
var formData = new FormData($('#formhead')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "http://192.168.10.21/cimv2/cim/bom/upload.php", //上传文件的请求路径必须是绝对路劲
|
||||
data: formData,
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
}).success(function (data) {
|
||||
afterUpload(data);
|
||||
}).error(function () {
|
||||
alert("上传失败");
|
||||
});
|
||||
});
|
||||
});
|
||||
function afterUpload(data){
|
||||
var arr = $.parseJSON(data);
|
||||
if(arr['status']!=1) {
|
||||
alert(arr.msg);
|
||||
return false;
|
||||
}
|
||||
$("#file").val(''); //set input(file) to null
|
||||
$("#fblock").css("display","block");
|
||||
$("#ftext").html("文件上传成功!点击下面按钮开始执行<br />"+arr['fpath']+"<br />");
|
||||
$("#fpath").val(arr['fpath']);
|
||||
}
|
||||
$(function () {
|
||||
$("#btnExcel").click(function () {
|
||||
console.log("Process excel button clicked!");
|
||||
$("#btnExcel").attr("disabled",true);
|
||||
console.log("Button disabled!");
|
||||
var formData = new FormData($('#form2')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "http://192.168.10.21/cimv2/cim/bom/excel.php", //上传文件的请求路径必须是绝对路劲
|
||||
data: formData,
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
}).success(function (data) {
|
||||
excelProcess(data);
|
||||
$("#btnExcel").attr("disabled",false);
|
||||
console.log("Button enabled!");
|
||||
console.log("Done everything!");
|
||||
}).error(function () {
|
||||
alert("处理失败");
|
||||
});
|
||||
});
|
||||
});
|
||||
function excelProcess(data){
|
||||
console.log("Excel data upload successful!");
|
||||
console.log(data);
|
||||
var arr = $.parseJSON(data);
|
||||
var htmlmsg;
|
||||
for(i = 0;i < arr.msg.length;i++) htmlmsg += arr['msg'][i];
|
||||
console.log("htmlmsg proceed!");
|
||||
$("#ftext").html(htmlmsg);
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
include_once "foot.php";
|
||||
<?php
|
||||
ob_start();
|
||||
include_once "../include/config.inc.php"; //Include config file;
|
||||
$db = new ora();
|
||||
$title="计划设置";
|
||||
include_once "head.php"; //include head file
|
||||
echo $hr;
|
||||
|
||||
$t = 1; //initial type to 1;
|
||||
if($_REQUEST['doSubmit']) bom_op($_REQUEST['t']); //operate when submit
|
||||
if($_REQUEST['bomid'] and !$_REQUEST['doSubmit']) {
|
||||
$bom = bom_data_by_id();
|
||||
$_REQUEST["bom"] = $bom['BOMNAME'];
|
||||
$_REQUEST["bomid"] = $bom['BOMID'];
|
||||
$_REQUEST["bomnote"] = $bom['FNOTE'];
|
||||
$_REQUEST["flowid"] = $bom['FLOWID'];
|
||||
$_REQUEST["ver"] = $bom['VER'];
|
||||
$t = 0;
|
||||
}
|
||||
?>
|
||||
<link rel="stylesheet" href="../lib/layui/css/layui.min.css">
|
||||
|
||||
<div id="mainContent">
|
||||
<h2><?php echo $title; ?></h2>
|
||||
<form name="formhead" id="formhead" method="post" enctype="multipart/form-data" >
|
||||
<div class="layui-inline">
|
||||
<input type="file" id="file" name="file" class="layui-btn">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button type="button" class="layui-btn" id="btnUpload">
|
||||
<i class="layui-icon"></i>EXCEL上传验证
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<form name="form2" id="form2" method="post" >
|
||||
<div class="stay_center" id="fblock" style="display: none">
|
||||
<div style="margin-top:10px;" id="ftext" class="layui-col-md12"></div>
|
||||
<input type="hidden" name="fpath" id="fpath" value="">
|
||||
<div class="layui-inline">
|
||||
<input type="button" id="btnExcel" value="处理上传文件" class="layui-btn">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#btnUpload").click(function () {
|
||||
console.log("Upload button clicked!");
|
||||
var formData = new FormData($('#formhead')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "http://192.168.10.21/cimv2/cim/bom/upload.php", //上传文件的请求路径必须是绝对路劲
|
||||
data: formData,
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
}).success(function (data) {
|
||||
afterUpload(data);
|
||||
}).error(function () {
|
||||
alert("上传失败");
|
||||
});
|
||||
});
|
||||
});
|
||||
function afterUpload(data){
|
||||
var arr = $.parseJSON(data);
|
||||
if(arr['status']!=1) {
|
||||
alert(arr.msg);
|
||||
return false;
|
||||
}
|
||||
$("#file").val(''); //set input(file) to null
|
||||
$("#fblock").css("display","block");
|
||||
$("#ftext").html("文件上传成功!点击下面按钮开始执行<br />"+arr['fpath']+"<br />");
|
||||
$("#fpath").val(arr['fpath']);
|
||||
}
|
||||
$(function () {
|
||||
$("#btnExcel").click(function () {
|
||||
console.log("Process excel button clicked!");
|
||||
$("#btnExcel").attr("disabled",true);
|
||||
console.log("Button disabled!");
|
||||
var formData = new FormData($('#form2')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "http://192.168.10.21/cimv2/cim/bom/excel.php", //上传文件的请求路径必须是绝对路劲
|
||||
data: formData,
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
}).success(function (data) {
|
||||
excelProcess(data);
|
||||
$("#btnExcel").attr("disabled",false);
|
||||
console.log("Button enabled!");
|
||||
console.log("Done everything!");
|
||||
}).error(function () {
|
||||
alert("处理失败");
|
||||
});
|
||||
});
|
||||
});
|
||||
function excelProcess(data){
|
||||
console.log("Excel data upload successful!");
|
||||
console.log(data);
|
||||
var arr = $.parseJSON(data);
|
||||
var htmlmsg;
|
||||
for(i = 0;i < arr.msg.length;i++) htmlmsg += arr['msg'][i];
|
||||
console.log("htmlmsg proceed!");
|
||||
$("#ftext").html(htmlmsg);
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
include_once "foot.php";
|
||||
?>
|
||||
+71
-71
@@ -1,71 +1,71 @@
|
||||
<?php
|
||||
ini_set("display_errors","1");
|
||||
header("content-type:text/html;charset=utf-8");
|
||||
//设置时区
|
||||
date_default_timezone_set('PRC');
|
||||
//获取文件名
|
||||
$filename = $_FILES['file']['name'];
|
||||
//获取文件临时路径
|
||||
$temp_name = $_FILES['file']['tmp_name'];
|
||||
//获取大小
|
||||
$size = $_FILES['file']['size'];
|
||||
//获取文件上传码,0代表文件上传成功
|
||||
$error = $_FILES['file']['error'];
|
||||
//判断文件大小是否超过设置的最大上传限制
|
||||
if ($size > 20*1024*1024){
|
||||
//
|
||||
//echo "<script>alert('文件大小超过20M大小');window.history.go(-1);</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "-2",
|
||||
"data"=> $_FILES['file'],
|
||||
"msg" => "文件大小超过20MB!",
|
||||
));
|
||||
exit();
|
||||
}
|
||||
//phpinfo函数会以数组的形式返回关于文件路径的信息
|
||||
//[dirname]:目录路径[basename]:文件名[extension]:文件后缀名[filename]:不包含后缀的文件名
|
||||
$arr = pathinfo($filename);
|
||||
//获取文件的后缀名
|
||||
$ext_suffix = $arr['extension'];
|
||||
|
||||
//设置允许上传文件的后缀
|
||||
$allow_suffix = array('xls');
|
||||
//判断上传的文件是否在允许的范围内(后缀)==>白名单判断
|
||||
if(!in_array($ext_suffix, $allow_suffix)){
|
||||
//window.history.go(-1)表示返回上一页并刷新页面
|
||||
//echo "<script>alert('上传的文件类型只能是jpg,gif,jpeg,png,xls');window.history.go(-1);</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "-1",
|
||||
"rows"=>$arr,
|
||||
"msg" => "仅支持上传文件类型: xls!",
|
||||
));
|
||||
exit();
|
||||
}
|
||||
//检测存放上传文件的路径是否存在,如果不存在则新建目录
|
||||
$uploadDir = __DIR__ . '/../uploads/';
|
||||
if (!file_exists($uploadDir)){
|
||||
mkdir($uploadDir);
|
||||
}
|
||||
//为上传的文件新起一个名字,保证更加安全
|
||||
$new_filename = date('YmdHis',time()).rand(100,1000).'.'.$ext_suffix;
|
||||
//将文件从临时路径移动到磁盘
|
||||
if (move_uploaded_file($temp_name, $uploadDir.$new_filename)){
|
||||
//echo "<script>alert('文件上传成功!');window.history.go(-1);</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "1",
|
||||
"data"=>$arr,
|
||||
"fpath"=>$uploadDir.$new_filename,
|
||||
"msg" => "File upload success!",
|
||||
));
|
||||
}else{
|
||||
//echo "<script>alert('文件上传失败,错误码:$error');</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "-1",
|
||||
"data"=>$ext_suffix,
|
||||
"fpath"=>$uploadDir,
|
||||
"file"=>$_FILES['file'],
|
||||
"msg" => "文件上传失败,错误码:$error",
|
||||
"e"=>"error",
|
||||
));
|
||||
}
|
||||
|
||||
<?php
|
||||
ini_set("display_errors","1");
|
||||
header("content-type:text/html;charset=utf-8");
|
||||
//设置时区
|
||||
date_default_timezone_set('PRC');
|
||||
//获取文件名
|
||||
$filename = $_FILES['file']['name'];
|
||||
//获取文件临时路径
|
||||
$temp_name = $_FILES['file']['tmp_name'];
|
||||
//获取大小
|
||||
$size = $_FILES['file']['size'];
|
||||
//获取文件上传码,0代表文件上传成功
|
||||
$error = $_FILES['file']['error'];
|
||||
//判断文件大小是否超过设置的最大上传限制
|
||||
if ($size > 20*1024*1024){
|
||||
//
|
||||
//echo "<script>alert('文件大小超过20M大小');window.history.go(-1);</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "-2",
|
||||
"data"=> $_FILES['file'],
|
||||
"msg" => "文件大小超过20MB!",
|
||||
));
|
||||
exit();
|
||||
}
|
||||
//phpinfo函数会以数组的形式返回关于文件路径的信息
|
||||
//[dirname]:目录路径[basename]:文件名[extension]:文件后缀名[filename]:不包含后缀的文件名
|
||||
$arr = pathinfo($filename);
|
||||
//获取文件的后缀名
|
||||
$ext_suffix = $arr['extension'];
|
||||
|
||||
//设置允许上传文件的后缀
|
||||
$allow_suffix = array('xls');
|
||||
//判断上传的文件是否在允许的范围内(后缀)==>白名单判断
|
||||
if(!in_array($ext_suffix, $allow_suffix)){
|
||||
//window.history.go(-1)表示返回上一页并刷新页面
|
||||
//echo "<script>alert('上传的文件类型只能是jpg,gif,jpeg,png,xls');window.history.go(-1);</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "-1",
|
||||
"rows"=>$arr,
|
||||
"msg" => "仅支持上传文件类型: xls!",
|
||||
));
|
||||
exit();
|
||||
}
|
||||
//检测存放上传文件的路径是否存在,如果不存在则新建目录
|
||||
$uploadDir = __DIR__ . '/../uploads/';
|
||||
if (!file_exists($uploadDir)){
|
||||
mkdir($uploadDir);
|
||||
}
|
||||
//为上传的文件新起一个名字,保证更加安全
|
||||
$new_filename = date('YmdHis',time()).rand(100,1000).'.'.$ext_suffix;
|
||||
//将文件从临时路径移动到磁盘
|
||||
if (move_uploaded_file($temp_name, $uploadDir.$new_filename)){
|
||||
//echo "<script>alert('文件上传成功!');window.history.go(-1);</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "1",
|
||||
"data"=>$arr,
|
||||
"fpath"=>$uploadDir.$new_filename,
|
||||
"msg" => "File upload success!",
|
||||
));
|
||||
}else{
|
||||
//echo "<script>alert('文件上传失败,错误码:$error');</script>";
|
||||
echo json_encode(array(
|
||||
"status" => "-1",
|
||||
"data"=>$ext_suffix,
|
||||
"fpath"=>$uploadDir,
|
||||
"file"=>$_FILES['file'],
|
||||
"msg" => "文件上传失败,错误码:$error",
|
||||
"e"=>"error",
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user