numofperact.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <?php
  2. Doo::loadModel('numofper');
  3. /**
  4. * Description of numofperact
  5. *
  6. * @author zongheng
  7. */
  8. class NumofperAct
  9. {
  10. private $__numofperact;
  11. function __construct()
  12. {
  13. $this->__numofperact = new Numofper();
  14. }
  15. public function insert($pid, $uid, $tenderid, $stid, $phaseno, $currcontractval, $currchangeval, $stopnowtotal, $currdone, $curralltotal, $times = 0)
  16. {
  17. $this->__numofperact->iszero = 0;
  18. $this->__numofperact->uid = $uid;
  19. $this->__numofperact->pid = $pid;
  20. $this->__numofperact->pmid = $tenderid;
  21. $this->__numofperact->stid = $stid;
  22. $this->__numofperact->numpname = $phaseno;
  23. $this->__numofperact->times = $times;
  24. $this->__numofperact->currcontractval = $currcontractval;
  25. $this->__numofperact->currchangeval = $currchangeval;
  26. $this->__numofperact->stopnowtotal = $stopnowtotal;
  27. $this->__numofperact->currdone = $currdone;
  28. $this->__numofperact->curralltotal = $curralltotal;
  29. $this->__numofperact->currstatus = 'checking';
  30. $this->__numofperact->audittime = 0;
  31. $this->__numofperact->intime = time();
  32. return $this->__numofperact->insert();
  33. }
  34. public function redoRow($pid, $tenderid, $stid, $phaseno, $times)
  35. {
  36. $this->__numofperact->pid = $pid;
  37. $this->__numofperact->pmid = $tenderid;
  38. $this->__numofperact->stid = $stid;
  39. $this->__numofperact->numpname = $phaseno;
  40. if ($times > 0)
  41. $this->__numofperact->times = $times;
  42. $this->__numofperact->currcontractval = 0;
  43. $this->__numofperact->currchangeval = 0;
  44. $this->__numofperact->stopnowtotal = 0;
  45. $this->__numofperact->currdone = 0;
  46. $this->__numofperact->curralltotal = 0;
  47. $this->__numofperact->currstatus = 'checking';
  48. $this->__numofperact->audittime = time();
  49. return $this->__numofperact->insert();
  50. }
  51. public function getRowByMpid($mpid)
  52. {
  53. return $this->__numofperact->getOne(array('where' => 'mpid=?', 'param' => array($mpid), 'asArray' => TRUE));
  54. }
  55. public function getCountTotalnum($pmid)
  56. {
  57. return $this->__numofperact->count(array('where' => 'pmid=? and currstatus != \'checkno\' ', 'param' => array($pmid), 'asArray' => TRUE));
  58. }
  59. public function getCountTotalnum2($pmid)
  60. {
  61. return $this->__numofperact->getOne(array('select' => 'numpname', 'where' => 'pmid=?', 'param' => array($pmid), 'groupby' => 'numpname', 'desc' => 'numpname', 'asArray' => TRUE));
  62. }
  63. public function getMaxStatusTimes($pmid, $numpname)
  64. {
  65. return $this->__numofperact->getOne(array('select' => 'currstatus', 'where' => 'pmid=? and numpname=?', 'param' => array($pmid, $numpname), 'desc' => 'times', 'asArray' => TRUE));
  66. }
  67. // for API
  68. public function getMaxTimes($pmid, $numpname)
  69. {
  70. return $this->__numofperact->getOne(array('select' => 'times,currstatus', 'where' => 'pmid=? and numpname=?', 'param' => array($pmid, $numpname), 'desc' => 'times', 'asArray' => TRUE));
  71. }
  72. public function getCountTotalplus($pmid)
  73. {
  74. return $this->__numofperact->getOne(array('select' => 'sum(curralltotal) as totalplus', 'where' => 'pmid=?', 'groupby' => 'numpname', 'desc' => 'times', 'param' => array($pmid), 'asArray' => TRUE));
  75. }
  76. public function getStopNow($pmid)
  77. {
  78. return $this->__numofperact->getOne(array('select' => 'sum(stopnowtotal) as sntotal', 'where' => 'pmid=?', 'groupby' => 'numpname', 'desc' => 'times', 'param' => array($pmid), 'asArray' => TRUE));
  79. }
  80. public function getStopNowTotal($pmid)
  81. {
  82. return $this->__numofperact->getOne(array('select' => 'stopnowtotal as sntotal', 'where' => 'pmid=?', 'groupby' => 'pmid,numpname', 'desc' => 'numpname', 'param' => array($pmid), 'asArray' => TRUE));
  83. }
  84. public function getStopNowSt($stid)
  85. {
  86. return $this->__numofperact->getOne(array('select' => 'sum(stopnowtotal) as sntotal', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  87. }
  88. public function getStopNowT($pmid)
  89. {
  90. return $this->__numofperact->getOne(array('select' => 'sum(stopnowtotal) as sntotal', 'where' => 'pmid=?', 'param' => array($pmid), 'DESC' => 'audittime', 'asArray' => TRUE));
  91. }
  92. public function getCurrDoneSt($stid)
  93. {
  94. return $this->__numofperact->getOne(array('select' => 'sum(currdone) as currdone', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  95. }
  96. public function getCurrDonePmid($pmid)
  97. {
  98. return $this->__numofperact->getOne(array('select' => 'currdone as currdone', 'where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE));
  99. }
  100. public function getCurrTotal($pmid)
  101. {
  102. return $this->__numofperact->getOne(array('select' => 'sum(currcontractval) as currtotal', 'where' => 'pmid=?', 'groupby' => 'numpname', 'desc' => 'times', 'param' => array($pmid), 'asArray' => TRUE));
  103. }
  104. public function getCurrAlltotal($pmid)
  105. {
  106. return $this->__numofperact->getOne(array('select' => 'currdone as currtotal', 'where' => 'pmid=?', 'param' => array($pmid), 'groupby' => 'pmid,numpname', 'desc' => 'numpname', 'asArray' => TRUE));
  107. }
  108. public function getCurrdoneNew($pmid)
  109. {
  110. return $this->__numofperact->getOne(array('select' => 'currdone as currtotal', 'where' => 'pmid=?', 'param' => array($pmid), 'desc' => 'mpid', 'asArray' => TRUE));
  111. }
  112. public function getCountTotalSTID($stid)
  113. {
  114. return $this->__numofperact->getOne(array('select' => 'sum(curralltotal) as totalplus', 'where' => 'stid=? and currstatus != \'checkno\'', 'param' => array($stid), 'asArray' => TRUE));
  115. }
  116. public function getCountTotalSTID2($stid)
  117. {
  118. $pdArray = NULL;
  119. $pdArray = $this->getPMID($stid);
  120. if ($pdArray)
  121. foreach ($pdArray as $value) {
  122. $t = $this->getMaxNumORTimes($value['pmid']);
  123. $totalPlus = $totalPlus + $t;
  124. }
  125. return array('totalplus' => $totalPlus);
  126. }
  127. // 根据条件STID获取分组后的PMID
  128. public function getPMID($stid)
  129. {
  130. return $this->__numofperact->find(array('select' => 'pmid', 'where' => 'stid=? and currstatus != \'checkno\'', 'groupby' => 'pmid', 'param' => array($stid), 'asArray' => TRUE));
  131. }
  132. // 根据条件STID获取分组后的PMID
  133. public function getMaxNumORTimes($pmid)
  134. {
  135. $pmidArray = $this->__numofperact->getOne(array('where' => 'pmid=?', 'param' => array($pmid), 'desc' => 'mpid', 'asArray' => TRUE));
  136. return $pmidArray['curralltotal'];
  137. }
  138. public function getNumByStid($stid)
  139. {
  140. return $this->__numofperact->find(array('where' => 'stid=?', 'param' => array($stid), 'desc' => 'mpid', 'asArray' => TRUE));
  141. }
  142. public function getRowByPmid($pmid)
  143. {
  144. return $this->__numofperact->find(array('where' => 'pmid=? and currstatus != \'checkno\'', 'param' => array($pmid), 'asArray' => TRUE));
  145. }
  146. public function getGroupByLastOne($pmid)
  147. {
  148. return $this->__numofperact->find(array('where' => 'pmid=? and currstatus!=\'checkno\'', 'groupby' => 'numpname', 'desc' => 'numpname,times', 'param' => array($pmid), 'asArray' => TRUE));
  149. }
  150. public function getGroupByLastOne2($pmid)
  151. {
  152. return $this->__numofperact->find(array('where' => 'pmid=?', 'groupby' => 'numpname', 'desc' => 'numpname,times', 'param' => array($pmid), 'asArray' => TRUE));
  153. }
  154. public function getRowByPmid2($pmid)
  155. {
  156. return $this->__numofperact->find(array('where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE));
  157. }
  158. public function getRowTender($pmid)
  159. {
  160. return $this->__numofperact->find(array('where' => 'pmid=?', 'orderby' => 'numpname', 'param' => array($pmid), 'desc' => 'mpid', 'asArray' => TRUE));
  161. }
  162. public function getRowTender2($pmid)
  163. {
  164. return $this->__numofperact->getOne(array('where' => 'pmid=?', 'orderby' => 'numpname', 'param' => array($pmid), 'desc' => 'mpid', 'asArray' => TRUE));
  165. }
  166. public function getRowTenderCurr($pmid)
  167. {
  168. return $this->__numofperact->find(array('where' => 'numpname=(SELECT max(numpname) FROM jl_measure_numofper where pmid=?) and pmid=?', 'orderby' => 'numpname', 'param' => array($pmid, $pmid), 'desc' => 'mpid', 'asArray' => TRUE));
  169. }
  170. public function getAlluserMeasureAudit($bid, $num)
  171. {
  172. return $this->__numofperact->getOne(array('select' => 'mpid', 'where' => 'pmid=? and numpname=?', 'param' => array($bid, $num), 'asArray' => TRUE));
  173. }
  174. public function getNumOfStatus($bid, $num)
  175. {
  176. return $this->__numofperact->getOne(array('where' => 'pmid=? and numpname=?', 'param' => array($bid, $num), 'asArray' => TRUE));
  177. }
  178. public function getCurrStatus($mpid)
  179. {
  180. return $this->__numofperact->getOne(array('where' => 'mpid=?', 'param' => array($mpid), 'asArray' => TRUE));
  181. }
  182. public function getRow($pmid, $numpname, $times = 0)
  183. {
  184. return $this->__numofperact->getOne(array('where' => 'pmid=? and numpname=? and times=?', 'param' => array($pmid, $numpname, $times), 'asArray' => TRUE));
  185. }
  186. public function hasTheTimesRow($pmid, $numpname, $times = 0)
  187. {
  188. return $this->__numofperact->count(array('where' => 'pmid=? and numpname=? and times=?', 'param' => array($pmid, $numpname, $times), 'asArray' => TRUE));
  189. }
  190. public function getMaxRowStatus($pmid, $numpname)
  191. {
  192. return $this->__numofperact->getOne(array('where' => 'pmid=? and numpname=?', 'param' => array($pmid, $numpname), 'desc' => 'times', 'asArray' => TRUE));
  193. }
  194. public function getChecknoRow($pmid, $numpname)
  195. {
  196. return $this->__numofperact->getOne(array('where' => 'pmid=? and numpname=?', 'desc' => 'times', 'param' => array($pmid, $numpname), 'asArray' => TRUE));
  197. }
  198. // public function getMaxCurrStatus($pid, $pmid, $stid) {
  199. // return $this->__numofperact->getOne(array('where' => 'numpname=(SELECT max(numpname) FROM jl_measure_numofper where pid=? and pmid=? and stid=?)', 'param' => array($pid, $pmid, $stid), 'asArray' => TRUE));
  200. // }
  201. public function getLastStatus($pid, $pmid)
  202. {
  203. return $this->__numofperact->getOne(array('where' => 'pid=? and pmid=? and currstatus != \'checkno\'', 'desc' => 'numpname', 'param' => array($pid, $pmid), 'asArray' => TRUE));
  204. }
  205. public function getLastStatus2($pid, $pmid)
  206. {
  207. return $this->__numofperact->getOne(array('where' => 'pid=? and pmid=?', 'groupby' => 'pmid,numpname,times', 'desc' => 'times', 'param' => array($pid, $pmid), 'asArray' => TRUE));
  208. }
  209. public function getLastStatus3($pid, $pmid)
  210. {
  211. return $this->__numofperact->getOne(array('where' => 'pid=? and pmid=?', 'desc' => 'numpname', 'param' => array($pid, $pmid), 'asArray' => TRUE));
  212. }
  213. public function getLastRow($pid, $pmid)
  214. {
  215. return $this->__numofperact->getOne(array('where' => 'pid=? and pmid=?', 'groupby' => 'numpname,times', 'desc' => 'mpid', 'param' => array($pid, $pmid), 'asArray' => TRUE));
  216. }
  217. public function getChangTotal($pid)
  218. {
  219. return $this->__numofperact->getOne(array('select' => 'sum(currchangeval) as changtotal', 'where' => 'pid=? and currstatus != \'checkno\'', 'param' => array($pid), 'asArray' => TRUE))['changtotal'];
  220. }
  221. public function getCurrDone($pid)
  222. {
  223. return $this->__numofperact->getOne(array('select' => 'sum(currdone) as currdone', 'where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE))['currdone'];
  224. }
  225. public function getCurrDoneNow($pid)
  226. {
  227. return $this->__numofperact->getOne(array('select' => 'sum(currdone) as currdone', 'where' => 'pid=? and currstatus!=\'checkno\'', 'param' => array($pid), 'asArray' => TRUE))['currdone'];
  228. }
  229. public function getCheckedCurrdone($stid)
  230. {
  231. return $this->__numofperact->getOne(array('select' => 'sum(currdone) as currdone', 'where' => 'stid = ?', 'param' => array($stid), 'asArray' => TRUE))['currdone'];
  232. }
  233. public function getMaxCurrStatus($pid, $pmid, $stid)
  234. {
  235. return $this->__numofperact->getOne(array('where' => 'numpname = (SELECT max(numpname) FROM jl_measure_numofper where pid = ? and pmid = ? and stid = ?)', 'param' => array($pid, $pmid, $stid), 'asArray' => TRUE));
  236. }
  237. //标段下最新一期
  238. public function getLastNew($pmid)
  239. {
  240. return $this->__numofperact->getOne(array('select' => 'stopnowtotal, currdone', 'where' => 'pmid = ?', 'groupby' => 'pmid, numpname', 'desc' => 'numpname', 'param' => array($pmid), 'asArray' => TRUE));
  241. // return $this->__numofperact->getOne(array('select' => 'stopnowtotal, currdone', 'where' => 'pmid = ? and currstatus!=\'checkno\'', 'orderby' => 'numpname', 'desc' => 'numpname', 'param' => array($pmid), 'asArray' => TRUE));
  242. }
  243. //标段下最新一期
  244. public function getLastNew2($pmid)
  245. {
  246. return $this->__numofperact->getOne(array('where' => 'pmid = ?', 'groupby' => 'pmid, numpname', 'desc' => 'numpname', 'param' => array($pmid), 'asArray' => TRUE));
  247. // return $this->__numofperact->getOne(array('select' => 'stopnowtotal, currdone', 'where' => 'pmid = ? and currstatus!=\'checkno\'', 'orderby' => 'numpname', 'desc' => 'numpname', 'param' => array($pmid), 'asArray' => TRUE));
  248. }
  249. //更新数据
  250. public function updateNumofper($tenderid, $phaseno, $itemArray, $times = 0)
  251. {
  252. if (!is_array($itemArray)) {
  253. return FALSE;
  254. }
  255. $this->__numofperact->currcontractval = $itemArray['BQHTJL'];
  256. $this->__numofperact->currchangeval = $itemArray['BQSLBGJL'];
  257. $this->__numofperact->stopnowtotal = $itemArray['JZSQLJWC'];
  258. $this->__numofperact->currdone = $itemArray['BQWCJL'];
  259. $this->__numofperact->curralltotal = $itemArray['LJWCJL'];
  260. return $this->__numofperact->update(array('where' => 'pmid=? and numpname=? and times=?', 'param' => array($tenderid, $phaseno, $times)));
  261. }
  262. //更新数据
  263. public function updateAuditStatus($tenderid, $phaseno, $statuno = 'checking', $times = 0)
  264. {
  265. $this->__numofperact->currstatus = $statuno;
  266. $this->__numofperact->audittime = time();
  267. return $this->__numofperact->update(array('where' => 'pmid=? and numpname=? and times=?', 'param' => array($tenderid, $phaseno, $times)));
  268. }
  269. // public function getCurrdoneSTID($stid) {
  270. // return $this->__numofperact->getOne(array('select' => 'sum(currdone) as totalplus', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  271. // }
  272. public function getCurrdoneSTID($stid)
  273. {
  274. return $this->__numofperact->getOne(array('select' => 'sum(currdone) as totalplus', 'where' => 'stid=? and currstatus!=\'checkno\'', 'param' => array($stid), 'asArray' => TRUE));
  275. }
  276. public function getCurrDoneSMontht($stid)
  277. {
  278. return $this->__numofperact->find(array('select' => 'sum(currdone) as currdone,FROM_UNIXTIME(audittime,"%Y-%m") as month', 'where' => 'stid=?'
  279. , 'param' => array($stid), 'groupby' => 'FROM_UNIXTIME(audittime,"%Y-%m")', 'asc' => 'audittime', 'asArray' => TRUE));
  280. }
  281. public function getStopNowStMonth($stid)
  282. {
  283. return $this->__numofperact->find(array('select' => 'sum(stopnowtotal) as sntotal,FROM_UNIXTIME(audittime,"%Y-%m") as month', 'where' => 'stid=? '
  284. , 'param' => array($stid), 'groupby' => 'FROM_UNIXTIME(audittime,"%Y-%m")', 'asc' => 'audittime', 'asArray' => TRUE));
  285. }
  286. public function getCountTimes($pmid, $numpname, $times)
  287. {
  288. return $this->__numofperact->count(array('where' => 'pmid=? and numpname=? and times=?', 'param' => array($pmid, $numpname, $times)));
  289. }
  290. public function getCountNumpname($pmid, $numpname)
  291. {
  292. return $this->__numofperact->count(array('where' => 'pmid=? and numpname=?', 'param' => array($pmid, $numpname)));
  293. }
  294. }