numofperact.php 15 KB

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