ALL_INVOICE="fhhh0B|114100 fhhh0B|4000 fhhh0A|1000 fhhh0A|1000"
declare -A map=()
array=(`echo $ALL_INVOICE | tr ' ' ' '` )
echo "数组=======>"${array[*]}
for var in ${array[@]}
do
temp_array=(`echo $var | tr '|' ' '` )
if [ -z "${map["${temp_array[0]}"]}"]
then
map["${temp_array[0]}"]="${temp_array[1]}"
else
old_fee=${map["${temp_array[0]}"]}
new_fee=${temp_array[1]}
map["${temp_array[0]}"]=`expr ${old_fee} + ${new_fee}`
fi
done
str=""
LIMIT_VALUE="10000"
flag="0"
for key in ${!map[@]}
do
value=${map[$key]}
if [ ${value} -gt ${LIMIT_VALUE} ]
then
str=${str}"工号${key}昨日开票${value}元,"
flag="1"
fi
done
if [ -n "${str}" ]
then
aa=`echo "sclae=2; ${LIMIT_VALUE}/100" | bc`
str=${str}"超过阈值${aa}元,请关注!"
fi
echo ${str}
echo ${flag}