58 lines
2.5 KiB
Bash
58 lines
2.5 KiB
Bash
#res=$(curl -i -X POST -H "Content-Type: application/json" -H 'x-username:proc' -H 'x-password:pr0c2022#tc3l' http://localhost:8083/PoiWord/authentification/sync.sh 2>/dev/null)
|
|
cd /home/nodejs/wsproc/services/
|
|
p=/home/nodejs/wsproc/services/process.txt
|
|
if [ -f $p ];
|
|
then
|
|
echo "another process detected, Exiting.."
|
|
exit 1;
|
|
fi
|
|
echo "Starting Time : "`date` > $p
|
|
# printf "\n" >> $p
|
|
# ==== GET TOken
|
|
rm -rf r.json
|
|
curl -s -X POST -H "Content-Type: application/json" -H 'x-username:proc' -H 'x-password:pr0c2022#tc3l' http://localhost:8083/PoiWord82/authentification/sync.sh > r.json
|
|
token=$(cat r.json | jq -r '.response.token')
|
|
# echo $token
|
|
|
|
# ==== Merge Docx
|
|
# curl -s -X POST -H "Content-Type: application/" -H 'x-token:'$token -d '{"idxjustification":"0"}' http://localhost:8083/PoiWord/main/sync.sh/mergedoc > m.json
|
|
# idxjustification=$(echo "SELECT _idx FROM dbproc.tbl_justification where ismergedoc=0 order by _idx asc limit 1" | mysql -h172.17.12.71 -ussotcel -pssotcel#20i7)
|
|
idxjustification=`mysql -h172.17.12.71 -ussotcel -pssotcel#20i7 -s -N -e "SELECT _idx FROM dbproc.tbl_justification where ismergedoc=0 and status=2 order by _idx asc limit 1"`
|
|
|
|
if [ -z "$idxjustification" ]
|
|
then
|
|
echo "\$idxjustification is empty"
|
|
else
|
|
# == Merge Doc Original to dbproc
|
|
curl -s --location --request POST "http://localhost:8083/PoiWord82/main/sync.sh/mergedoc" \
|
|
--header "x-token: "$token \
|
|
--header "Content-Type: application/x-www-form-urlencoded" \
|
|
--data-urlencode "idxjustification=$idxjustification" > m.json
|
|
# cat m.json
|
|
filedocmerge=$(cat m.json | jq -r '.response.filedocmerge[0]')
|
|
|
|
mysql -h172.17.12.71 -ussotcel -pssotcel#20i7 -e "update dbproc.tbl_justification set ismergedoc=1,filedocmerge='$filedocmerge' where _idx=$idxjustification"
|
|
|
|
# === Create Docx to PDF
|
|
curl -s --location --request POST "http://localhost:8083/PoiWord82/main/sync.sh/docxtopdf" \
|
|
--header "x-token: "$token \
|
|
--header "Content-Type: application/x-www-form-urlencoded" \
|
|
--data-urlencode "docxfilename=$filedocmerge" > m.json
|
|
|
|
filedocxpdf=$(cat m.json | jq -r '.response.filepdf[0]')
|
|
mysql -h172.17.12.71 -ussotcel -pssotcel#20i7 -e "update dbproc.tbl_justification set filepdf='$filedocxpdf' where _idx=$idxjustification"
|
|
|
|
cat m.json >> $p
|
|
printf "\n" >> $p
|
|
echo "End Time : "`date` >> $p
|
|
cat $p > lastprocess.txt
|
|
|
|
fi
|
|
|
|
rm -rf $p
|
|
rm -rf *.json
|
|
|
|
# === check proc justification
|
|
sh procmergedocx.sh
|
|
# === check Bast
|
|
sh bastmergedocx.sh |