<?php
//合并itemsearch的结果
private function mergeList(&$arr)
{
$data = array();
$n = &$arr;
foreach ($n as $key => $value) {
if(!$value)
continue;
array_push($data,$this->getItem($value,$n));
}
return array_filter($data);
}
private function getItem(&$item,&$arr){
foreach ($arr as $key => $value) {
if(!$value) {
continue;
};
if($item["itemTypeName"] == $value["itemTypeName"]
&& $item["weight"] == $value["weight"]
&& $item["type"] == $value["type"]){
if($item["itemTypeId"] == $value["itemTypeId"]
&& $item["warehouseId"] == $value["warehouseId"]){
continue;
}else{
$item["stockIn"] += $value["stockIn"];
$item["remain"] += $value["remain"];
$item["stockOut"] += $value["stockOut"];
$item["stockIn"] = sprintf("%.4f",$item["stockIn"]);
$item["remain"] = sprintf("%.4f",$item["remain"]);
$item["stockOut"] = sprintf("%.4f",$item["stockOut"]);
$arr[$key] = "";
}
}
}
return $item;
}