numofperact.php 15 KB

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