Inspect.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use \think\Request;
  5. use \think\Db;
  6. /**
  7. * 检验计件单据维护接口
  8. */
  9. class Inspect extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 首页
  15. *
  16. */
  17. public function index()
  18. {
  19. $this->success('请求成功');
  20. }
  21. /**
  22. * 获取手工检验左侧菜单栏
  23. *
  24. * @ApiMethod GET
  25. */
  26. public function getInspectCount(){
  27. if (Request::instance()->isGet() == false){
  28. $this->error('非法请求');
  29. }
  30. $sql = 'SELECT DISTINCT DATE(sys_rq) AS sys_rq FROM `db_手工检验` ORDER BY sys_rq DESC LIMIT 30 ';
  31. $list = Db::query($sql);
  32. foreach ($list as $key => $value){
  33. $where = [$value['sys_rq'].'00:00:00',$value['sys_rq'].'24:00:00'];
  34. $dataCount = Db::name('db_手工检验')->where('sys_rq','between time',$where)->field('rtrim(sys_id) as sys_id')->order('sys_id asc')->select();
  35. $list[$key]['count'] = count($dataCount);
  36. // 提取 sys_id 列成新数组
  37. $sysIds = array_column($dataCount, 'sys_id');
  38. //统计每个不同的 sys_id 的数量
  39. $counts = array_count_values($sysIds);
  40. $i = 0;
  41. foreach ($counts as $k=>$v){
  42. $list[$key]['sys'][$i]['sys_id'] = $k;
  43. $list[$key]['sys'][$i]['count'] = $v;
  44. $i++;
  45. }
  46. }
  47. $this->success('请求成功',$list);
  48. }
  49. /**
  50. * 获取某个日期手工单据
  51. *
  52. * @ApiMethod GET
  53. * @params string date
  54. */
  55. public function getDateList(){
  56. if (Request::instance()->isGet() == false){
  57. $this->error('非法请求');
  58. }
  59. $params = Request::instance()->param();
  60. $date = $params['date'];
  61. if (!isset($date)){
  62. $this->error('参数不能为空');
  63. }
  64. $limit = $params['limit'];
  65. if (empty($limit)){
  66. $limit = 15;
  67. }
  68. $pages = $params['page'];
  69. if (empty($pages)){
  70. $pages = 1;
  71. }
  72. $field = 'a.sczl_gdbh,a.sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_dedh,a.sczl_废品率系数,a.sczl_检验类别,a.sczl_bh0,
  73. rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c.员工姓名) as 员工姓名,rtrim(d.yj_yjmc) as yj_yjmc';
  74. $where = [$date.' 00:00:00',$date.'24:00:00'];
  75. $list = Db::name('db_手工检验')->alias('a')
  76. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  77. ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
  78. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  79. ->where('a.sys_rq','between time',$where)
  80. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  81. ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq,a.UniqId asc')->select();
  82. $option['sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
  83. $count = Db::name('db_手工检验')->where($option)->count();
  84. $data['data'] = $list;
  85. $data['total'] = $count;
  86. $this->success('请求成功',$data);
  87. }
  88. /**
  89. * 获取机器检验左侧菜单栏
  90. *
  91. * @ApiMethod GET
  92. */
  93. public function getMachineCount(){
  94. if (Request::instance()->isGet() == false){
  95. $this->error('非法请求');
  96. }
  97. $sql = 'SELECT DISTINCT DATE(sys_rq) AS sys_rq FROM `db_机器检验` ORDER BY sys_rq DESC LIMIT 30 ';
  98. $list = Db::query($sql);
  99. foreach ($list as $key => $value){
  100. $where = [$value['sys_rq'].'00:00:00',$value['sys_rq'].'24:00:00'];
  101. $dataCount = Db::name('db_机器检验')->where('sys_rq','between time',$where)->field('rtrim(sys_id) as sys_id')->order('sys_id asc')->select();
  102. $list[$key]['count'] = count($dataCount);
  103. // 提取 sys_id 列成新数组
  104. $sysIds = array_column($dataCount, 'sys_id');
  105. //统计每个不同的 sys_id 的数量
  106. $counts = array_count_values($sysIds);
  107. $i = 0;
  108. foreach ($counts as $k=>$v){
  109. $list[$key]['sys'][$i]['sys_id'] = $k;
  110. $list[$key]['sys'][$i]['count'] = $v;
  111. $i++;
  112. }
  113. }
  114. $this->success('请求成功',$list);
  115. }
  116. /**
  117. * 获取某个日期机器单据
  118. *
  119. * @ApiMethod GET
  120. * @params string date
  121. */
  122. public function getDateMachine(){
  123. if (Request::instance()->isGet() == false){
  124. $this->error('非法请求');
  125. }
  126. $params = Request::instance()->param();
  127. $date = $params['date'];
  128. if (!isset($date)){
  129. $this->error('参数不能为空');
  130. }
  131. $limit = $params['limit'];
  132. if (empty($limit)){
  133. $limit = 15;
  134. }
  135. $pages = $params['page'];
  136. if (empty($pages)){
  137. $pages = 1;
  138. }
  139. $where['a.sczl_单据类型'] = '初检单';
  140. $where['a.sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
  141. $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,rtrim(a.sczl_单据类型) as sczl_单据类型,
  142. a.sczl_设备运行工时,a.sczl_dedh,a.sczl_废品率系数,rtrim(a.sczl_检验类别) as sczl_检验类别,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.qczl_NumDesc,rtrim(a.sys_id) as sys_id,
  143. a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,rtrim(c3.员工姓名) as sczl_bh3_name,
  144. rtrim(c4.员工姓名) as sczl_bh4_name,rtrim(d.yj_yjmc) as yj_yjmc';
  145. $list = Db::name('db_机器检验')->alias('a')
  146. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  147. ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
  148. ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
  149. ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
  150. ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
  151. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  152. ->where($where)
  153. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  154. ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq asc,a.UniqId desc')->select();
  155. $option['sczl_单据类型'] = '初检单';
  156. $option['sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
  157. $count = Db::name('db_机器检验')->where($option)->count();
  158. $data['data'] = $list;
  159. $data['total'] = $count;
  160. $this->success('请求成功',$data);
  161. }
  162. /**
  163. * 定位
  164. * @ApiMethod (GET)
  165. * @param string $gdbh 工单编号
  166. * @param string $cpmc 产品名称
  167. * @param string $page 页码
  168. * @param string $limit 数量
  169. */
  170. public function locate()
  171. {
  172. //get请求
  173. if(!$this->request->isGet()){
  174. $this->error('请求方式错误');
  175. }
  176. $req = $this->request->param();
  177. $page = 1;
  178. $limit = 15;
  179. if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
  180. if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
  181. if (isset($req['gdbh']) && !empty($req['gdbh'])){
  182. $where = [
  183. 'a.sczl_gdbh'=>[ 'like', '%' . $req['gdbh'] . '%']
  184. ];
  185. $field = 'a.sczl_gdbh,a.sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_dedh,a.sczl_废品率系数,a.sczl_检验类别,a.sczl_bh0,
  186. rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c.员工姓名) as 员工姓名,rtrim(d.yj_yjmc) as yj_yjmc';
  187. $rows = Db::name('db_手工检验')->alias('a')
  188. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  189. ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
  190. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  191. ->where($where)
  192. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  193. ->field($field)->page($page,$limit)->order('a.sczl_rq,a.UniqId asc')->select();
  194. $option['sczl_gdbh'] = [ 'like', '%' . $req['gdbh'] . '%'];
  195. $total = Db::name('db_手工检验')->where($option)->count();
  196. }else{
  197. if (isset($req['cpmc']) && !empty($req['cpmc'])){
  198. //查询工单表
  199. $gd = db()->table('工单_基本资料')
  200. ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
  201. ->column('Gd_gdbh');
  202. $where = [
  203. 'a.sczl_gdbh'=>['in', $gd]
  204. ];
  205. $field = 'a.sczl_gdbh,a.sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_dedh,a.sczl_废品率系数,a.sczl_检验类别,a.sczl_bh0,
  206. rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c.员工姓名) as 员工姓名,rtrim(d.yj_yjmc) as yj_yjmc';
  207. $rows = Db::name('db_手工检验')->alias('a')
  208. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  209. ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
  210. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  211. ->where($where)
  212. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  213. ->field($field)->page($page,$limit)->order('a.sczl_rq,a.UniqId asc')->select();
  214. $option['sczl_gdbh'] = ['in', $gd];
  215. $total = Db::name('db_手工检验')->where($option)->count();
  216. }else{
  217. $this->error('参数错误');
  218. }
  219. }
  220. $data = [
  221. 'total' => $total,
  222. 'rows' => $rows,
  223. ];
  224. $this->success('成功',$data);
  225. }
  226. /**
  227. * 定位
  228. * @ApiMethod (GET)
  229. * @param string $gdbh 工单编号
  230. * @param string $cpmc 产品名称
  231. * @param string $page 页码
  232. * @param string $limit 数量
  233. */
  234. public function machineLocate()
  235. {
  236. //get请求
  237. if(!$this->request->isGet()){
  238. $this->error('请求方式错误');
  239. }
  240. $req = $this->request->param();
  241. $page = 1;
  242. $limit = 15;
  243. if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
  244. if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
  245. if (isset($req['gdbh']) && !empty($req['gdbh'])){
  246. $where = [
  247. 'sczl_gdbh'=>[ 'like', '%' . $req['gdbh'] . '%']
  248. ];
  249. $where['a.sczl_单据类型'] = '初检单';
  250. $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,rtrim(a.sczl_单据类型) as sczl_单据类型,
  251. a.sczl_设备运行工时,a.sczl_dedh,a.sczl_废品率系数,rtrim(a.sczl_检验类别) as sczl_检验类别,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.qczl_NumDesc,rtrim(a.sys_id) as sys_id,
  252. a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,rtrim(c3.员工姓名) as sczl_bh3_name,
  253. rtrim(c4.员工姓名) as sczl_bh4_name,rtrim(d.yj_yjmc) as yj_yjmc';
  254. $rows = Db::name('db_机器检验')->alias('a')
  255. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  256. ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
  257. ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
  258. ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
  259. ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
  260. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  261. ->where($where)
  262. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  263. ->field($field)->page($page,$limit)->order('a.sczl_rq asc,a.UniqId desc')->select();
  264. $option['sczl_单据类型'] = '初检单';
  265. $option['sczl_gdbh'] = [ 'like', '%' . $req['gdbh'] . '%'];
  266. $total = Db::name('db_机器检验')->where($option)->count();
  267. }else{
  268. if (isset($req['cpmc']) && !empty($req['cpmc'])){
  269. //查询工单表
  270. $gd = db()->table('工单_基本资料')
  271. ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
  272. ->column('Gd_gdbh');
  273. $where = [
  274. 'sczl_gdbh'=>['in', $gd]
  275. ];
  276. $where['a.sczl_单据类型'] = '初检单';
  277. $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,rtrim(a.sczl_单据类型) as sczl_单据类型,
  278. a.sczl_设备运行工时,a.sczl_dedh,a.sczl_废品率系数,rtrim(a.sczl_检验类别) as sczl_检验类别,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.qczl_NumDesc,rtrim(a.sys_id) as sys_id,
  279. a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,rtrim(c3.员工姓名) as sczl_bh3_name,
  280. rtrim(c4.员工姓名) as sczl_bh4_name,rtrim(d.yj_yjmc) as yj_yjmc';
  281. $rows = Db::name('db_机器检验')->alias('a')
  282. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  283. ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
  284. ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
  285. ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
  286. ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
  287. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  288. ->where($where)
  289. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  290. ->field($field)->page($page,$limit)->order('a.sczl_rq asc,a.UniqId desc')->select();
  291. $option['sczl_单据类型'] = '初检单';
  292. $option['sczl_gdbh'] = ['in', $gd];
  293. $total = Db::name('db_机器检验')->where($option)->count();
  294. }else{
  295. $this->error('参数错误');
  296. }
  297. }
  298. $data = [
  299. 'total' => $total,
  300. 'rows' => $rows,
  301. ];
  302. $this->success('成功',$data);
  303. }
  304. /**
  305. * 获取信息
  306. * @ApiMethod (GET)
  307. * @param string $UniqId UniqId
  308. */
  309. public function getInfo()
  310. {
  311. //get请求
  312. if(!$this->request->isGet()){
  313. $this->error('请求方式错误');
  314. }
  315. $req = $this->request->param();
  316. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  317. $UniqId = $req['UniqId'];
  318. }else{
  319. $this->error('参数错误');
  320. }
  321. $where['a.UniqId'] = $UniqId;
  322. $field = 'DATE(a.sczl_rq) as sczl_rq, a.sczl_bzdh,a.sczl_bh0, rtrim(c0.员工姓名) as sczl_bh0_name, a.sczl_cl0, a.sczl_fp0,
  323. a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,rtrim(d.yj_yjmc) as yj_yjmc,
  324. a.sczl_cl,rtrim(a.sczl_dedh) as sczl_dedh,rtrim(a.sczl_检验类别) as sczl_检验类别,a.sczl_废品率系数,
  325. a.sczl_jsss,a.sczl_冲定额,a.qczl_Num as 流程单号1,a.qczl_NumDesc1 as 流程单号2,a.qczl_NumDesc2 as 流程单号3,
  326. a.qczl_NumDesc3 as 流程单号4,a.qczl_NumDesc4 as 流程单号5,a.qczl_NumDesc5 as 流程单号6,
  327. a.qczl_NumDesc6 as 流程单号7,a.qczl_NumDesc7 as 流程单号8,a.qczl_NumDesc8 as 流程单号9,
  328. rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sczl_desc) as sczl_desc,
  329. a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.sczl_bh5, a.sczl_bh6,
  330. a.sczl_bh7,a.sczl_bh8,a.sczl_bh9,a.sczl_bh10,a.sczl_bh11, a.sczl_bh12,
  331. rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,
  332. rtrim(c3.员工姓名) as sczl_bh3_name,rtrim(c4.员工姓名) as sczl_bh4_name,
  333. rtrim(c5.员工姓名) as sczl_bh5_name,rtrim(c6.员工姓名) as sczl_bh6_name,
  334. rtrim(c7.员工姓名) as sczl_bh7_name,rtrim(c8.员工姓名) as sczl_bh8_name,
  335. rtrim(c9.员工姓名) as sczl_bh9_name,rtrim(c10.员工姓名) as sczl_bh10_name,
  336. rtrim(c11.员工姓名) as sczl_bh11_name,rtrim(c12.员工姓名) as sczl_bh12_name,
  337. a.sczl_cl1,a.sczl_cl2,a.sczl_cl3,a.sczl_cl4,a.sczl_cl5,a.sczl_cl6,
  338. a.sczl_cl7,a.sczl_cl8,a.sczl_cl9,a.sczl_cl10,a.sczl_cl11,a.sczl_cl12,
  339. a.sczl_fp1,a.sczl_fp2,a.sczl_fp3,a.sczl_fp4,a.sczl_fp5,a.sczl_fp6,
  340. a.sczl_fp7,a.sczl_fp8,a.sczl_fp9,a.sczl_fp10,a.sczl_fp11,a.sczl_fp12';
  341. $rows = Db::name('db_手工检验')->alias('a')
  342. ->join('人事_基本资料 c0','a.sczl_bh0 = c0.员工编号','left')
  343. ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
  344. ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
  345. ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
  346. ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
  347. ->join('人事_基本资料 c5','a.sczl_bh5 = c5.员工编号','left')
  348. ->join('人事_基本资料 c6','a.sczl_bh6 = c6.员工编号','left')
  349. ->join('人事_基本资料 c7','a.sczl_bh7 = c7.员工编号','left')
  350. ->join('人事_基本资料 c8','a.sczl_bh8 = c8.员工编号','left')
  351. ->join('人事_基本资料 c9','a.sczl_bh9 = c9.员工编号','left')
  352. ->join('人事_基本资料 c10','a.sczl_bh10 = c10.员工编号','left')
  353. ->join('人事_基本资料 c11','a.sczl_bh11 = c11.员工编号','left')
  354. ->join('人事_基本资料 c12','a.sczl_bh12 = c12.员工编号','left')
  355. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  356. ->where($where)
  357. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  358. ->field($field)->find();
  359. $this->success('成功',$rows);
  360. }
  361. /**
  362. * 获取信息
  363. * @ApiMethod (GET)
  364. * @param string $UniqId UniqId
  365. */
  366. public function getMachineInfo()
  367. {
  368. //get请求
  369. if(!$this->request->isGet()){
  370. $this->error('请求方式错误');
  371. }
  372. $req = $this->request->param();
  373. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  374. $UniqId = $req['UniqId'];
  375. }else{
  376. $this->error('参数错误');
  377. }
  378. $where['a.UniqId'] = $UniqId;
  379. $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,
  380. a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_PgCl,
  381. rtrim(a.sczl_单据类型) as sczl_单据类型,rtrim(a.sczl_dedh) as sczl_dedh,
  382. a.sczl_装版工时,a.sczl_保养工时,a.sczl_异常停机工时,a.sczl_设备运行工时,
  383. a.sczl_废品率系数,rtrim(a.sczl_检验类别) as sczl_检验类别,
  384. a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.sczl_bh5, a.sczl_bh6,a.sczl_bh7,a.sczl_bh8,
  385. a.qczl_Num as 流程单号1,a.qczl_NumDesc1 as 流程单号2,a.qczl_NumDesc2 as 流程单号3,
  386. a.qczl_NumDesc3 as 流程单号4,a.qczl_NumDesc4 as 流程单号5,a.qczl_NumDesc5 as 流程单号6,
  387. a.qczl_NumDesc6 as 流程单号7,a.qczl_NumDesc7 as 流程单号8,a.qczl_NumDesc8 as 流程单号9,
  388. a.qczl_NumDesc,a.sczl_desc,
  389. rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,
  390. rtrim(c3.员工姓名) as sczl_bh3_name,rtrim(c4.员工姓名) as sczl_bh4_name,
  391. rtrim(c5.员工姓名) as sczl_bh5_name,rtrim(c6.员工姓名) as sczl_bh6_name,
  392. rtrim(c7.员工姓名) as sczl_bh7_name,rtrim(c8.员工姓名) as sczl_bh8_name,
  393. rtrim(d.yj_yjmc) as yj_yjmc';
  394. $rows = Db::name('db_机器检验')->alias('a')
  395. ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
  396. ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
  397. ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
  398. ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
  399. ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
  400. ->join('人事_基本资料 c5','a.sczl_bh5 = c5.员工编号','left')
  401. ->join('人事_基本资料 c6','a.sczl_bh6 = c6.员工编号','left')
  402. ->join('人事_基本资料 c7','a.sczl_bh7 = c7.员工编号','left')
  403. ->join('人事_基本资料 c8','a.sczl_bh8 = c8.员工编号','left')
  404. ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
  405. ->where($where)
  406. ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
  407. ->field($field)->find();
  408. $this->success('成功',$rows);
  409. }
  410. /**
  411. * 查询印件工序及产品名称
  412. * @ApiMethod (GET)
  413. * @param string $gdbh 工单编号
  414. * @param string $gxmc 工序名称
  415. */
  416. public function getGxMc()
  417. {
  418. //get请求
  419. if(!$this->request->isGet()){
  420. $this->error('请求方式错误');
  421. }
  422. $req = $this->request->param();
  423. if (isset($req['gdbh']) && !empty($req['gdbh'])){
  424. $gdbh = $req['gdbh'];
  425. }else{
  426. $this->error('参数错误');
  427. }
  428. $gxmc = ['手检','手检(圆切)','次品检','抽检','大张翻检'];
  429. $gxmcs = [];
  430. foreach ($gxmc as $k=>$v){
  431. array_push($gxmcs,['like','%'.$v.'%']);
  432. }
  433. array_push($gxmcs,'OR');
  434. $rows = db()->table('工单_基本资料')->alias('g')
  435. ->field('rtrim(g.Gd_cpmc) as Gd_cpmc, c.Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc')
  436. ->where(['g.Gd_gdbh'=>$gdbh])
  437. ->where(['c.Gy0_gxmc'=>$gxmcs])
  438. ->join(['产品_印件资料'=>'j'],'g.Gd_cpdh=j.yj_yjdh and g.成品代号=j.yj_cpdh')
  439. ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Gd_gdbh and c.Gy0_yjno=j.yj_yjno')
  440. ->select();
  441. foreach ($rows as $key=>$value){
  442. $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
  443. }
  444. $this->success('成功',$rows);
  445. }
  446. /**
  447. * 查询印件工序及产品名称
  448. * @ApiMethod (GET)
  449. * @param string $gdbh 工单编号
  450. * @param string $gxmc 工序名称
  451. */
  452. public function getMachineGxMc()
  453. {
  454. //get请求
  455. if(!$this->request->isGet()){
  456. $this->error('请求方式错误');
  457. }
  458. $req = $this->request->param();
  459. if (isset($req['gdbh']) && !empty($req['gdbh'])){
  460. $gdbh = $req['gdbh'];
  461. }else{
  462. $this->error('参数错误');
  463. }
  464. $gxmc = ['机检'];
  465. $gxmcs = [];
  466. foreach ($gxmc as $k=>$v){
  467. array_push($gxmcs,['like','%'.$v.'%']);
  468. }
  469. array_push($gxmcs,'OR');
  470. $rows = db()->table('工单_基本资料')->alias('g')
  471. ->field('rtrim(g.Gd_cpmc) as Gd_cpmc, c.Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc')
  472. ->where(['g.Gd_gdbh'=>$gdbh])
  473. ->where(['c.Gy0_gxmc'=>$gxmcs])
  474. ->join(['产品_印件资料'=>'j'],'g.Gd_cpdh=j.yj_yjdh and g.成品代号=j.yj_cpdh')
  475. ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Gd_gdbh and c.Gy0_yjno=j.yj_yjno')
  476. ->select();
  477. foreach ($rows as $key=>$value){
  478. $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
  479. }
  480. $this->success('成功',$rows);
  481. }
  482. /**
  483. * 查询定额代号
  484. * @ApiMethod (GET)
  485. */
  486. public function getDedh()
  487. {
  488. //get请求
  489. if(!$this->request->isGet()){
  490. $this->error('请求方式错误');
  491. }
  492. $row = db()->table('dic_lzde')
  493. ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
  494. ->where('sys_mc','初检(手工)')
  495. ->find();
  496. $rows = db()->table('dic_lzde')
  497. ->field('sys_bh, rtrim(sys_mc) as sys_mc')
  498. ->where('Parent',$row['Key_'])
  499. ->select();
  500. $row['bh_mc'] = $rows;
  501. $this->success('成功',$row);
  502. }
  503. /**
  504. * 查询定额代号
  505. * @ApiMethod (GET)
  506. */
  507. public function getMachineDedh()
  508. {
  509. //get请求
  510. if(!$this->request->isGet()){
  511. $this->error('请求方式错误');
  512. }
  513. // $req = $this->request->param();
  514. // if (isset($req['sys_mc']) && !empty($req['sys_mc'])){
  515. // $sys_mc = $req['sys_mc'];
  516. // }else{
  517. // $this->error('参数错误');
  518. // }
  519. $row = db()->table('dic_lzde')
  520. ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
  521. ->where('适用机型','JP01#')
  522. ->find();
  523. $rows = db()->table('dic_lzde')
  524. ->field('sys_bh, rtrim(sys_mc) as sys_mc')
  525. ->where('Parent',$row['Key_'])
  526. ->select();
  527. $row['bh_mc'] = $rows;
  528. $this->success('成功',$row);
  529. }
  530. /**
  531. * 查询废品系数
  532. * @ApiMethod (GET)
  533. */
  534. public function getScrapFactor()
  535. {
  536. //get请求
  537. if(!$this->request->isGet()){
  538. $this->error('请求方式错误');
  539. }
  540. $req = $this->request->param();
  541. isset($req['gdbh']) && !empty($req['gdbh']) ? $gdbh = $req['gdbh'] : $this->error('参数错误');
  542. isset($req['yjno']) && !empty($req['yjno']) ? $yjno = $req['yjno'] : $this->error('参数错误');
  543. isset($req['gxh']) && !empty($req['gxh']) ? $gxh = $req['gxh'] : $this->error('参数错误');
  544. isset($req['type']) && !empty($req['type']) ? $type = $req['type'] : $this->error('参数错误');
  545. switch ($type){
  546. case '正品板':
  547. $field = '人工检_正品板 as num';
  548. case '次品板':
  549. $field = '人工检_次品板 as num';
  550. case '废品板':
  551. $field = '人工检_废检 as num';
  552. }
  553. $rows = db()->table('工单_工艺资料')
  554. ->field($field)
  555. ->where(['Gy0_gdbh'=>$gdbh, 'Gy0_yjno'=>$yjno, 'Gy0_gxh'=>$gxh])
  556. ->find();
  557. $this->success('成功',$rows);
  558. }
  559. /**
  560. * 查询废品系数
  561. * @ApiMethod (GET)
  562. */
  563. public function getMachineScrapFactor()
  564. {
  565. //get请求
  566. if(!$this->request->isGet()){
  567. $this->error('请求方式错误');
  568. }
  569. $req = $this->request->param();
  570. isset($req['gdbh']) && !empty($req['gdbh']) ? $gdbh = $req['gdbh'] : $this->error('参数错误');
  571. isset($req['yjno']) && !empty($req['yjno']) ? $yjno = $req['yjno'] : $this->error('参数错误');
  572. isset($req['gxh']) && !empty($req['gxh']) ? $gxh = $req['gxh'] : $this->error('参数错误');
  573. isset($req['type']) && !empty($req['type']) ? $type = $req['type'] : $this->error('参数错误');
  574. switch ($type){
  575. case '正品板':
  576. $field = '机检_正品板 as num';
  577. case '次品板':
  578. $field = '机检_次品板 as num';
  579. case '废品板':
  580. $field = '机检_废检 as num';
  581. }
  582. $rows = db()->table('工单_工艺资料')
  583. ->field($field)
  584. ->where(['Gy0_gdbh'=>$gdbh, 'Gy0_yjno'=>$yjno, 'Gy0_gxh'=>$gxh])
  585. ->find();
  586. $this->success('成功',$rows);
  587. }
  588. /**
  589. * 查询机台
  590. * @ApiMethod (GET)
  591. */
  592. public function getJtbh()
  593. {
  594. //get请求
  595. if(!$this->request->isGet()){
  596. $this->error('请求方式错误');
  597. }
  598. $req = $this->request->param();
  599. if (isset($req['sys_mc']) && !empty($req['sys_mc'])){
  600. $sys_mc = $req['sys_mc'];
  601. }else{
  602. $this->error('参数错误');
  603. }
  604. $row = db()->table('dic_lzde')
  605. ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
  606. ->where('sys_mc',$sys_mc)
  607. ->find();
  608. $rows = db()->table('dic_lzde')->alias('d')
  609. ->field('rtrim(s.设备编号) as jtbh, rtrim(s.设备名称) as jtmc')
  610. ->where('Parent',$row['Key_'])
  611. ->join(['设备_基本资料'=>'s'],'d.适用机型=s.设备编号')
  612. ->select();
  613. $this->success('成功',$rows);
  614. }
  615. /**
  616. * 新增
  617. * @ApiMethod (POST)
  618. * @param string
  619. */
  620. public function add()
  621. {
  622. if(!$this->request->isPost()){
  623. $this->error('请求方式错误');
  624. }
  625. $req = $this->request->param();
  626. //sczl_num, sczl_gs, sczl_fp
  627. $arr = [
  628. 'sys_id','sczl_rq','sczl_bzdh','sczl_bh0','sczl_cl0','sczl_fp0',
  629. 'sczl_gdbh','sczl_yjgx','sczl_gxmc',
  630. 'sczl_cl','sczl_dedh','sczl_检验类别','sczl_废品率系数',
  631. 'sczl_jsss','sczl_冲定额',
  632. 'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
  633. 'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
  634. 'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6',
  635. 'sczl_bh7','sczl_bh8','sczl_bh9','sczl_bh10','sczl_bh11', 'sczl_bh12',
  636. 'sczl_cl1','sczl_cl2','sczl_cl3','sczl_cl4','sczl_cl5','sczl_cl6',
  637. 'sczl_cl7','sczl_cl8','sczl_cl9','sczl_cl10','sczl_cl11','sczl_cl12',
  638. 'sczl_fp1','sczl_fp2','sczl_fp3','sczl_fp4','sczl_fp5','sczl_fp6',
  639. 'sczl_fp7','sczl_fp8','sczl_fp9','sczl_fp10','sczl_fp11','sczl_fp12','sczl_desc'
  640. ];
  641. $data = [];
  642. foreach ($arr as $key => $value){
  643. if (!(isset($req[$value]))){
  644. $this->error('参数错误',$value,$key+1);
  645. }
  646. $data[$value] = $req[$value];
  647. }
  648. $data['sys_rq'] = date('Y-m-d H:i:s');
  649. //开启事务
  650. db()->startTrans();
  651. try{
  652. $sql = db()->table('db_手工检验')->fetchSql(true)->insert($data);
  653. $bool = db()->query($sql);
  654. // 提交事务
  655. db()->commit();
  656. } catch (\Exception $e) {
  657. // 回滚事务
  658. db()->rollback();
  659. $this->error($e->getMessage());
  660. }
  661. if($bool===false) $this->error('失败');
  662. $this->success('成功');
  663. }
  664. /**
  665. * 新增
  666. * @ApiMethod (POST)
  667. * @param string
  668. */
  669. public function machineAdd()
  670. {
  671. if(!$this->request->isPost()){
  672. $this->error('请求方式错误');
  673. }
  674. $req = $this->request->param();
  675. //sczl_num, sczl_NumDesc, sczl_fp
  676. $arr = [
  677. 'sys_id','sczl_rq','sczl_bzdh',
  678. 'sczl_gdbh','sczl_yjgx','sczl_gxmc',
  679. 'sczl_jtbh','sczl_单据类型','sczl_检验类别','sczl_废品率系数',
  680. 'sczl_cl','sczl_PgCl','sczl_dedh',
  681. 'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
  682. 'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
  683. 'sczl_装版工时','sczl_保养工时','sczl_异常停机工时','sczl_设备运行工时',
  684. 'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6','sczl_bh7','sczl_bh8',
  685. 'sczl_desc'
  686. ];
  687. $data = [];
  688. foreach ($arr as $key => $value){
  689. if (!(isset($req[$value]))){
  690. $this->error('参数错误',$value,$key+1);
  691. }
  692. $data[$value] = $req[$value];
  693. }
  694. $data['sys_rq'] = date('Y-m-d H:i:s');
  695. //开启事务
  696. db()->startTrans();
  697. try{
  698. $sql = db()->table('db_机器检验')->fetchSql(true)->insert($data);
  699. $bool = db()->query($sql);
  700. // 提交事务
  701. db()->commit();
  702. } catch (\Exception $e) {
  703. // 回滚事务
  704. db()->rollback();
  705. $this->error($e->getMessage());
  706. }
  707. if($bool===false) $this->error('失败');
  708. $this->success('成功');
  709. }
  710. /**
  711. * 修改
  712. * @ApiMethod (POST)
  713. * @param string 'UniqId'
  714. */
  715. public function edit()
  716. {
  717. if(!$this->request->isPost()){
  718. $this->error('请求方式错误');
  719. }
  720. $req = $this->request->param();
  721. $arr = [
  722. 'sczl_rq','sczl_bzdh','sczl_bh0','sczl_cl0','sczl_fp0',
  723. 'sczl_gdbh','sczl_yjgx','sczl_gxmc',
  724. 'sczl_cl','sczl_dedh','sczl_检验类别','sczl_废品率系数',
  725. 'sczl_jsss','sczl_冲定额',
  726. 'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
  727. 'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
  728. 'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6',
  729. 'sczl_bh7','sczl_bh8','sczl_bh9','sczl_bh10','sczl_bh11', 'sczl_bh12',
  730. 'sczl_cl1','sczl_cl2','sczl_cl3','sczl_cl4','sczl_cl5','sczl_cl6',
  731. 'sczl_cl7','sczl_cl8','sczl_cl9','sczl_cl10','sczl_cl11','sczl_cl12',
  732. 'sczl_fp1','sczl_fp2','sczl_fp3','sczl_fp4','sczl_fp5','sczl_fp6',
  733. 'sczl_fp7','sczl_fp8','sczl_fp9','sczl_fp10','sczl_fp11','sczl_fp12','sczl_desc'
  734. ];
  735. $data = [];
  736. foreach ($arr as $key => $value){
  737. if (!(isset($req[$value]))){
  738. continue;
  739. }
  740. $data[$value] = $req[$value];
  741. }
  742. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  743. $this->error('参数错误','UniqId',100);
  744. }
  745. $data['mod_rq'] = date('Y-m-d H:i:s');
  746. //开启事务
  747. db()->startTrans();
  748. try{
  749. $sql = db()->table('db_手工检验')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
  750. $bool = db()->query($sql);
  751. // 提交事务
  752. db()->commit();
  753. } catch (\Exception $e) {
  754. // 回滚事务
  755. db()->rollback();
  756. $this->error($e->getMessage());
  757. }
  758. if($bool===false) $this->error('失败');
  759. $this->success('成功');
  760. }
  761. /**
  762. * 修改
  763. * @ApiMethod (POST)
  764. * @param string 'UniqId'
  765. */
  766. public function machineEdit()
  767. {
  768. if(!$this->request->isPost()){
  769. $this->error('请求方式错误');
  770. }
  771. $req = $this->request->param();
  772. $arr = [
  773. 'sys_id','sczl_rq','sczl_bzdh',
  774. 'sczl_gdbh','sczl_yjgx','sczl_gxmc',
  775. 'sczl_jtbh','sczl_单据类型','sczl_检验类别','sczl_废品率系数',
  776. 'sczl_cl','sczl_PgCl','sczl_dedh',
  777. 'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
  778. 'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
  779. 'sczl_装版工时','sczl_保养工时','sczl_异常停机工时','sczl_设备运行工时',
  780. 'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6','sczl_bh7','sczl_bh8',
  781. 'sczl_desc'
  782. ];
  783. $data = [];
  784. foreach ($arr as $key => $value){
  785. if (!(isset($req[$value]))){
  786. continue;
  787. }
  788. $data[$value] = $req[$value];
  789. }
  790. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  791. $this->error('参数错误','UniqId',100);
  792. }
  793. $data['mod_rq'] = date('Y-m-d H:i:s');
  794. //开启事务
  795. db()->startTrans();
  796. try{
  797. $sql = db()->table('db_机器检验')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
  798. $bool = db()->query($sql);
  799. // 提交事务
  800. db()->commit();
  801. } catch (\Exception $e) {
  802. // 回滚事务
  803. db()->rollback();
  804. $this->error($e->getMessage());
  805. }
  806. if($bool===false) $this->error('失败');
  807. $this->success('成功');
  808. }
  809. /**
  810. * 修改
  811. * @ApiMethod (POST)
  812. * @param string 'UniqId'
  813. */
  814. public function del()
  815. {
  816. if(!$this->request->isPost()){
  817. $this->error('请求方式错误');
  818. }
  819. $req = $this->request->param();
  820. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  821. $this->error('参数错误','UniqId',100);
  822. }
  823. //开启事务
  824. db()->startTrans();
  825. try{
  826. $bool = db()->table('db_手工检验')->where('UniqId',$req['UniqId'])->delete();
  827. // 提交事务
  828. db()->commit();
  829. } catch (\Exception $e) {
  830. // 回滚事务
  831. db()->rollback();
  832. $this->error($e->getMessage());
  833. }
  834. if($bool===false) $this->error('失败');
  835. $this->success('成功');
  836. }
  837. /**
  838. * 修改
  839. * @ApiMethod (POST)
  840. * @param string 'UniqId'
  841. */
  842. public function machineDel()
  843. {
  844. if(!$this->request->isPost()){
  845. $this->error('请求方式错误');
  846. }
  847. $req = $this->request->param();
  848. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  849. $this->error('参数错误','UniqId',100);
  850. }
  851. //开启事务
  852. db()->startTrans();
  853. try{
  854. $bool = db()->table('db_机器检验')->where('UniqId',$req['UniqId'])->delete();
  855. // 提交事务
  856. db()->commit();
  857. } catch (\Exception $e) {
  858. // 回滚事务
  859. db()->rollback();
  860. $this->error($e->getMessage());
  861. }
  862. if($bool===false) $this->error('失败');
  863. $this->success('成功');
  864. }
  865. }