You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
2.1 KiB

<?php
require_once "database.php";
if($_POST['type']=='facility'){
$contractno = $_POST["contractno"];//合同号
$customerid = $_POST["customerid"];//客户编号
$creater = $_POST["creater"];//建档人
$create_at = date('Y/m/d H:i:s');//创建时间
$facilitynos=json_decode($_POST['facilitynos'], true);
$weights=json_decode($_POST['weights'], true);
$numberofstops=json_decode($_POST['numberofstops'], true);
$numberoffloors=json_decode($_POST['numberoffloors'], true);
$opentypes=json_decode($_POST['opentypes'], true);
$speeds=json_decode($_POST['speeds'], true);
$repairtypes=json_decode($_POST['repairtypes'], true);
$longitudes=json_decode($_POST['longitudes'], true);
$latitudes=json_decode($_POST['latitudes'], true);
$addresss=json_decode($_POST['addresss'], true);
$repairerids=json_decode($_POST['repairerids'], true);
$repairernames=json_decode($_POST['repairernames'], true);
$num=0;
for ($i = 0; $i<sizeof($facilitynos); $i++) {
//判断是否已经存在
$facilitsql = "SELECT * FROM facility where facilityno='$facilitynos[$i]'";
$facilit_nums_rows=mysqli_num_rows(mysqli_query($link,$facilitsql));
if($facilit_nums_rows==0){
$db_query3 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofstop, numberoffloor,opentype,speed,repairtype,longitude, latitude, address,repairerid,repairername,creater, create_at) VALUES
('$contractno', '$facilitynos[$i]', '$customerid', '$weights[$i]','$numberofstops[$i]', '$numberoffloors[$i]','$opentypes[$i]','$speeds[$i]','$repairtypes[$i]','$longitudes[$i]', '$latitudes[$i]', '$addresss[$i]','$repairerids[$i]','$repairernames[$i]','$creater', '$create_at')";
mysqli_query($link,$db_query3);
if (mysqli_affected_rows($link)>0) {
$num++;
}
}
}
if ($num>0) {
$jsonres['code']='200';
$jsonres['num']=$num;
echo json_encode($jsonres);
}else{
$jsonres['code']='1';
$jsonres['num']=0;
echo json_encode($jsonres);
}
}
?>