Facility.php 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Request;
  6. /**
  7. * 设备运行跟踪
  8. */
  9. class Facility extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 左侧菜单栏
  15. * @ApiMethod (GET)
  16. * @return void
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\ModelNotFoundException
  19. * @throws \think\exception\DbException
  20. */
  21. public function getTab()
  22. {
  23. if ($this->request->isGet() === false){
  24. $this->error('请求错误');
  25. }
  26. $param = $this->request->param();
  27. if (isset($param['sort'])){
  28. $where['使用部门'] = '智能车间';
  29. }else{
  30. $where['使用部门'] = ['<>','智能车间'];
  31. }
  32. $data = [];
  33. $date = date('Y-m-d 00:00:00',time()-3888000);
  34. $department = \db('设备_基本资料')
  35. ->distinct(true)
  36. ->where('使用部门','<>','研发中心')
  37. ->where('设备编组','<>','')
  38. ->where($where)
  39. ->order('设备编组,设备编号')
  40. ->column('rtrim(使用部门) as 使用部门');
  41. if (empty($department)){
  42. $this->success('为获取到机台数据');
  43. }
  44. $list = \db('设备_产量计酬')
  45. ->field([
  46. 'DISTINCT(sczl_rq)' => '时间',
  47. 'rtrim(sczl_jtbh)' => '机台编号'
  48. ])
  49. ->where('sczl_rq','>',$date)
  50. ->order('sczl_rq desc')
  51. ->select();
  52. if (empty($list)){
  53. $this->success('未找到机台生产记录');
  54. }
  55. foreach ($department as $value){
  56. $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
  57. foreach ($machine as $k=>$v){
  58. $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
  59. foreach ($list as $kk=>$vv){
  60. if ($v['设备编号'] === $vv['机台编号']){
  61. array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
  62. }
  63. }
  64. }
  65. }
  66. $this->success('成功',$data);
  67. }
  68. /**
  69. * 机台每日产量
  70. * @ApiMethod (GET)
  71. * @param string $machine 机台编号
  72. * @param string $date 日期
  73. * @return void
  74. * @throws \think\db\exception\DataNotFoundException
  75. * @throws \think\db\exception\ModelNotFoundException
  76. * @throws \think\exception\DbException
  77. */
  78. public function chanLiang()
  79. {
  80. if ($this->request->isGet() === false){
  81. $this->error('请求错误');
  82. }
  83. $machine = input('machine');
  84. $date = input('date');
  85. $where = [
  86. 'sczl_jtbh' => $machine,
  87. 'sczl_rq' => date('Y-m-d H:i:s',strtotime($date.' 00:00:00')),
  88. ];
  89. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_dedh) as dedh,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxh) as gxh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as num,rtrim(sczl_sj1) as sj1,
  90. rtrim(sczl_sj2) as sj2,rtrim(sczl_cl) as 产量,rtrim(sczl_bzdh) as bzdh,IF(sczl_zcfp = 0, "",sczl_zcfp) as 制程废品,IF(sczl_zccp = 0, "",sczl_zccp) as 制程次品,IF(sczl_前工序废 = 0, "",sczl_前工序废) as 前工序废,IF(sczl_来料少数 = 0, "",sczl_来料少数) as 来料异常,
  91. IF(sczl_装版工时 = 0, "",sczl_装版工时) as 装版工时, IF(sczl_保养工时 = 0, "",sczl_保养工时) as 保养工时,IF(sczl_打样工时 = 0, "",sczl_打样工时) as 打样工时,IF(sczl_异常停机工时 = 0, "",sczl_异常停机工时) as 异常总工时,IF(sczl_设备运行工时 = 0, "",sczl_设备运行工时) as 通电工时,
  92. IF(码开始行 = 0, "",码开始行) as 码开始行,IF(码结束行 = 0, "",码结束行) as 码结束行,IF(码包 = 0, "",码包) as 码包,IF(主电表 = 0, "",主电表) as 主电表,IF(辅电表 = 0, "",辅电表) as 辅电表,IF(sczl_ms = 0, "",sczl_ms) as 色度数,
  93. rtrim(sys_id) as 用户,rtrim(sys_rq) as 更新时间,IF(sczl_异常工时1 = 0, "",sczl_异常工时1) as 异常补时,IF(sczl_异常类型1 = 0, "",sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
  94. sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
  95. sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId,rtrim(sczl_工价系数) as 难度系数,rtrim(sczl_dedh) as 定额代号';
  96. //机台信息
  97. $machineDetail = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
  98. //组员信息
  99. $list = \db('设备_产量计酬')->where($where)->field($field)->order('bzdh desc')->select();
  100. $totalA = \db('设备_产量计酬')
  101. ->where($where)
  102. ->where('sczl_bzdh','like','A%')
  103. ->field('SUM(sczl_cl) as 产量, SUM(sczl_zcfp) as 制程废品, SUM(sczl_zccp) as 制程次品, SUM(sczl_来料少数) as 来料异常, SUM(sczl_装版工时) as 装版工时, SUM(sczl_保养工时) as 保养工时, SUM(sczl_打样工时) as 打样工时,SUM(sczl_异常停机工时) as 异常工时,SUM(sczl_异常工时1) as 异常补时工时,SUM(sczl_设备运行工时) as 通电工时,SUM(sczl_前工序废) as 前工序废')
  104. ->select();
  105. $totalB = \db('设备_产量计酬')
  106. ->where($where)
  107. ->where('sczl_bzdh','like','B%')
  108. ->field('SUM(sczl_cl) as 产量, SUM(sczl_zcfp) as 制程废品, SUM(sczl_zccp) as 制程次品, SUM(sczl_来料少数) as 来料异常, SUM(sczl_装版工时) as 装版工时, SUM(sczl_保养工时) as 保养工时, SUM(sczl_打样工时) as 打样工时,SUM(sczl_异常停机工时) as 异常工时,SUM(sczl_异常工时1) as 异常补时工时,SUM(sczl_设备运行工时) as 通电工时,SUM(sczl_前工序废) as 前工序废')
  109. ->select();
  110. if (empty($list)){
  111. $this->success('',[]);
  112. }
  113. foreach ($list as $key=>$value){
  114. //产品名称
  115. $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$value['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
  116. if (!empty($productName)){
  117. if (!empty($productName['成品名称'])){
  118. $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
  119. $list[$key]['cpmc'] = $productName['成品名称'];
  120. }else{
  121. $list[$key]['产品名称'] = $value['工单编号'];
  122. $list[$key]['cpmc'] = '';
  123. }
  124. }else{
  125. $list[$key]['产品名称'] = $value['工单编号'];
  126. $list[$key]['cpmc'] = '';
  127. }
  128. $process = \db('工单_工艺资料')
  129. ->where('Gy0_gdbh',$value['工单编号'])
  130. ->where('Gy0_yjno',$value['yjno'])
  131. ->where('Gy0_gxh',$value['gxh'])
  132. ->field('rtrim(工价系数) as 工价系数,rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距')
  133. ->find();
  134. if (!empty($process)){
  135. if ($value['难度系数'] == 0){
  136. $list[$key]['难度系数'] = $process['工价系数'];
  137. }else{
  138. $list[$key]['难度系数'] = $process['工价系数'].'x'.$value['难度系数'];
  139. }
  140. $list[$key]['印刷方式'] = $process['印刷方式'].' '.$process['版距'];
  141. }else{
  142. $list[$key]['难度系数'] = '';
  143. $list[$key]['印刷方式'] = '';
  144. }
  145. if ($value['yjno']<10){
  146. $list[$key]['yjno'] = '0'.$value['yjno'];
  147. }
  148. if (empty($value['定额代号'])){
  149. $list[$key]['千件工价'] = '';
  150. $list[$key]['日定额'] = '';
  151. $list[$key]['补产标准'] = '';
  152. }else{
  153. $row = \db('dic_lzde')->where('sys_bh',$value['定额代号'])->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额,rtrim(补产标准) as 补产标准')->find();
  154. $list[$key]['千件工价'] = $row['千件工价'];
  155. $list[$key]['日定额'] = $row['日定额'];
  156. $list[$key]['补产标准'] = $row['补产标准'];
  157. }
  158. $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxmc'];
  159. $list[$key]['备注'] = $value['bzdh'].'('.$value['num'].')'.date('H:i',strtotime($value['sj1'])).'<-->'.date('H:i',strtotime($value['sj2']));
  160. for ($i=1;$i<11;$i++){
  161. if (isset($value['sczl_bh'.$i])){
  162. $name = \db('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
  163. if (isset($name['name'])){
  164. $list[$key]['组员'.$i] = $value['sczl_bh'.$i].$name['name'].'('.((float)$value['sczl_rate'.$i]*100).'%'.')';
  165. }
  166. }
  167. unset($list[$key]['sczl_bh'.$i],$list[$key]['sczl_rate'.$i]);
  168. }
  169. }
  170. $list['totalA'] = $totalA[0]['产量'];
  171. $list['totalB'] = $totalB[0]['产量'];
  172. $list['制程废品A'] = $totalA[0]['制程废品'];
  173. $list['制程废品B'] = $totalB[0]['制程废品'];
  174. $list['制程次品A'] = $totalA[0]['制程次品'];
  175. $list['制程次品B'] = $totalB[0]['制程次品'];
  176. $list['来料异常A'] = $totalA[0]['来料异常'];
  177. $list['来料异常B'] = $totalB[0]['来料异常'];
  178. $list['装版工时A'] = $totalA[0]['装版工时'];
  179. $list['装版工时B'] = $totalB[0]['装版工时'];
  180. $list['保养工时A'] = $totalA[0]['保养工时'];
  181. $list['保养工时B'] = $totalB[0]['保养工时'];
  182. $list['打样工时A'] = $totalA[0]['打样工时'];
  183. $list['打样工时B'] = $totalB[0]['打样工时'];
  184. $list['异常工时A'] = $totalA[0]['异常工时'];
  185. $list['异常工时B'] = $totalB[0]['异常工时'];
  186. $list['异常补时工时A'] = $totalA[0]['异常补时工时'];
  187. $list['异常补时工时B'] = $totalB[0]['异常补时工时'];
  188. $list['通电工时A'] = $totalA[0]['通电工时'];
  189. $list['通电工时B'] = $totalB[0]['通电工时'];
  190. $list['前工序废A'] = $totalA[0]['前工序废'];
  191. $list['前工序废B'] = $totalB[0]['前工序废'];
  192. $this->success('成功',$list);
  193. }
  194. /**
  195. * 当日制程检验记录
  196. * @ApiMethod (GET)
  197. * @param string $machine 机台编号
  198. * @param string $date 日期
  199. * @return void
  200. * @throws \think\db\exception\DataNotFoundException
  201. * @throws \think\db\exception\ModelNotFoundException
  202. * @throws \think\exception\DbException
  203. */
  204. public function Inspect()
  205. {
  206. if ($this->request->isGet() === false){
  207. $this->error('请求错误');
  208. }
  209. $machine = input('machine');
  210. $date = input('date');
  211. if (empty($machine) || empty($date)){
  212. $this->error('参数错误');
  213. }
  214. $where = [
  215. '设备编号' => $machine,
  216. '开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
  217. '类别' => ['in',['IPQC检验','机台检验']],
  218. ];
  219. $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,提交时间,rtrim(检验项目) as 检验项目';
  220. $list = \db('制程检验_记录')
  221. ->where($where)
  222. ->field($field)
  223. ->select();
  224. if (empty($list)){
  225. $this->success('未找到检验记录');
  226. }
  227. $data = [];
  228. foreach ($list as $key=>$value)
  229. {
  230. $data['item'][$key] = $value['检验项目'];
  231. $data['InspectionTime'][$key] = date('H:i',strtotime($value['提交时间']));
  232. $data['工单编号'][$key] = $value['工单编号'];
  233. }
  234. $data['item'] = array_unique($data['item']);
  235. $data['InspectionTime'] = array_values(array_unique($data['InspectionTime']));
  236. $data['工单编号'] = array_values(array_unique($data['工单编号']));
  237. foreach ($data['工单编号'] as $key => $value){
  238. foreach ($data['item'] as $k=>$v){
  239. $time = '';
  240. foreach ($list as $kk=>$vv){
  241. if ($vv['工单编号'] === $value && $vv['检验项目'] === $v){
  242. $time = $time.date('H:i',strtotime($vv['提交时间'])).',';
  243. $data['row'][$key][$k] = [
  244. '工单编号' => $value,
  245. '印件号' => $vv['印件号'],
  246. '工序名称' => $vv['工序名称'],
  247. '检验项目' => $v,
  248. 'time' => substr($time,0,-1),
  249. ];
  250. }
  251. }
  252. }
  253. $data['row'][$key] = array_values($data['row'][$key]);
  254. }
  255. unset($data['item'],$data['工单编号']);
  256. $this->success('成功',$data);
  257. }
  258. /**
  259. * 设备生产中工单信息
  260. * @ApiMethod (GET)
  261. * @param string $machine 机台编号
  262. * @return void
  263. * @throws \think\Exception
  264. * @throws \think\db\exception\DataNotFoundException
  265. * @throws \think\db\exception\ModelNotFoundException
  266. * @throws \think\exception\DbException
  267. */
  268. public function Production()
  269. {
  270. if (Request::instance()->isGet() == false) {
  271. $this->error('非法请求');
  272. }
  273. $params = Request::instance()->param();
  274. if (!isset($params['machine']) || empty($params['machine'])) {
  275. $this->error('参数错误');
  276. }
  277. $machine = $params['machine'];
  278. $machineCode = \db('dic_lzde')->where('适用机型',$machine)->value('sys_bh');
  279. $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
  280. $list = [];
  281. $row = [];
  282. if (!empty($data['工单编号'])){
  283. $endTime = \db('工单_工艺资料')
  284. ->where('Gy0_gdbh',$data['工单编号'])
  285. ->where('Gy0_yjno',$data['印件号'])
  286. ->where('Gy0_gxh',$data['工序号'])
  287. ->find();
  288. $list['工单编号'] = $data['工单编号'];
  289. if (!empty($endTime)){
  290. $list['印件号'] = $data['印件号'];
  291. $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
  292. $code = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品代号');
  293. $list['产品名称'] = rtrim($name);
  294. $list['产品代号'] = rtrim($code);
  295. $list['工序名称'] = $data['工序名称'];
  296. }
  297. $list['状态'] = rtrim($data['当前状态']);
  298. }else{
  299. $list['工单编号'] = '';
  300. $list['印件号'] = 0;
  301. $list['产品名称'] = '';
  302. $list['工序名称'] = '';
  303. $list['产品代号'] = '';
  304. $list['状态'] = '';
  305. }
  306. $list['班组编号'] = rtrim($data['班组编号']);
  307. $list['班组Id'] = rtrim($data['班组ID']);
  308. $class = \db('设备_班组资料')->where('UniqId',$data['班组ID'])->field("rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
  309. rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
  310. rtrim(sczl_bh10) as bh10")->find();
  311. if (!empty($class)){
  312. for ($i=1;$i<11;$i++) {
  313. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  314. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  315. $row[$i] = [
  316. '编号' => $class['bh' . $i],
  317. '姓名' => $name['姓名']
  318. ];
  319. }
  320. }
  321. $row = array_values($row);
  322. }
  323. $list['班组成员'] = $row;
  324. $list['定额代号'] = $machineCode;
  325. $this->success('成功',$list);
  326. }
  327. /**
  328. * 设备工作清单
  329. * @ApiMethod (GET)
  330. * @param string $machine 机台编号
  331. * @return void
  332. * @throws \think\db\exception\DataNotFoundException
  333. * @throws \think\db\exception\ModelNotFoundException
  334. * @throws \think\exception\DbException
  335. */
  336. public function EquipmentWorklist()
  337. {
  338. if ($this->request->isGet() === false){
  339. $this->error('请求错误');
  340. }
  341. $machine = input('machine');
  342. if (empty($machine)){
  343. $this->error('参数错误');
  344. }
  345. $orderList = \db('工单_工艺资料')
  346. ->alias('a')
  347. // ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_yjno = b.sczl_yjno AND a.Gy0_gxh = b.sczl_gxh','LEFT')
  348. ->join('工单_基本资料 c','a.Gy0_gdbh = c.Gd_gdbh')
  349. ->join('工单_印件资料 d','a.Gy0_gdbh = d.Yj_Gdbh AND a.Gy0_yjno = d.yj_Yjno')
  350. ->field('a.Gy0_gdbh as gdbh,a.质量要求 as 质量信息,a.Gy0_yjno as yjno,a.Gy0_gxh as gxh,a.Gy0_sbbh as sbbh,
  351. a.Gy0_gxmc as gxmc,a.Add_gxmc as add_gxmc,a.Gy0_辅助工时 as 装版工时,a.Gy0_小时产能 as 工序产能,a.Gy0_生产工时 as 计划工时,
  352. a.Gy0_sj1 as sj1,a.Gy0_sj2 as sj2,a.工序备注 as 排产备注,d.yj_yjmc as 印件名称,c.成品名称 as 产品名称,c.成品代号 as 产品代号,
  353. a.Gy0_计划接货数 as 计划接货数,a.Gy0_ls as ls,a.Gy0_班次安排 as 班组,a.UniqId as UniqId,a.Gy0_最早开工时间 as 最早开工时间')
  354. ->where('a.Gy0_sbbh','like','%'.$machine.'%')
  355. ->where('a.PD_WG','1900-01-01 00:00:00')
  356. ->where('a.Gy0_sj1','<>','1900-01-01 00:00:00')
  357. ->where('c.gd_statu','2-生产中')
  358. ->group('a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh')
  359. ->order('a.Gy0_sj1')
  360. ->select();
  361. if (!empty($orderList)){
  362. $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
  363. foreach ($orderList as $key=>$value){
  364. $machineList = explode(' ',$value['sbbh']);
  365. $cl_data = \db('设备_产量计酬')
  366. ->field('SUM(sczl_cl) as 已完成,SUM(sczl_zcfp) as 制程废品')
  367. ->where('sczl_gdbh',$value['gdbh'])
  368. ->where('sczl_yjno',$value['yjno'])
  369. ->where('sczl_gxh',$value['gxh'])
  370. ->select();
  371. $orderList[$key]['status'] = 0;
  372. if (!empty($data)){
  373. if ($value['gdbh'] === $data['工单编号'] && $value['yjno'] === $data['印件号'] && $value['gxh'] === $data['工序号']) {
  374. $orderList[$key]['status'] = 1;
  375. }
  376. }
  377. $orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
  378. $orderList[$key]['印件号'] = $value['yjno'];
  379. $orderList[$key]['工序号'] = $value['gxh'];
  380. if ($value['yjno']<10){
  381. $orderList[$key]['yjno'] = '0'.$value['yjno'];
  382. }
  383. if ($value['gxh']<10){
  384. $orderList[$key]['gxh'] = '0'.$value['gxh'];
  385. }
  386. $orderList[$key]['印件资料'] = $orderList[$key]['yjno'].'-'.$value['印件名称'];
  387. $orderList[$key]['工序名称'] = $orderList[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  388. if ((int)$cl_data[0]['制程废品'] === 0){
  389. $orderList[$key]['计划产量/已完成'] = (int)$value['计划接货数'].'/'.$cl_data[0]['已完成']=null?'':(int)$cl_data[0]['已完成'];
  390. }else{
  391. $orderList[$key]['计划产量/已完成'] = (int)$value['计划接货数'].'/'.$cl_data[0]['已完成']=null?'':(int)$cl_data[0]['已完成'].'('.$cl_data[0]['制程废品'].')';
  392. }
  393. $orderList[$key]['计划生产时段'] =substr($value['sj1'],5,5).' '.substr($value['sj1'],11,5).'<-->'.substr($value['sj2'],5,5).' '.substr($value['sj2'],11,5);
  394. unset($orderList[$key]['gdbh'],$orderList[$key]['质量信息'],$orderList[$key]['gxh'],$orderList[$key]['yjno'],$orderList[$key]['gxmc'],$orderList[$key]['add_gxmc'],$orderList[$key]['计划接货数'],$orderList[$key]['已完成'],$orderList[$key]['印件名称'],$orderList[$key]['ls'],$orderList[$key]['制程废品']);
  395. if (in_array($machine,$machineList) === false){
  396. unset($orderList[$key]);
  397. }
  398. }
  399. }
  400. $this->success('成功',$orderList);
  401. }
  402. /**
  403. * 工序、印件、完成数量
  404. * @ApiMethod (GET)
  405. * @param string $workOrder 工单编号
  406. * @return void
  407. * @throws \think\Exception
  408. * @throws \think\db\exception\DataNotFoundException
  409. * @throws \think\db\exception\ModelNotFoundException
  410. * @throws \think\exception\DbException
  411. */
  412. public function Procedure()
  413. {
  414. if ($this->request->isGet() === false){
  415. $this->error('请求错误');
  416. }
  417. $workOrder = input('Gd_gdbh');
  418. $data = [];
  419. if (!empty($workOrder)){
  420. //右边工艺及完成数量
  421. $Process = \db('设备_产量计酬')->where('sczl_gdbh',$workOrder)
  422. ->distinct(true)->order('sczl_gxh')
  423. ->column('sczl_gxh');
  424. foreach ($Process as $k=>$v){
  425. $res= \db('设备_产量计酬')->where('sczl_gdbh',$workOrder)
  426. ->where('sczl_gxh',$v)
  427. ->field('rtrim(sczl_yjno) as sczl_yjno,rtrim(sczl_gxmc) as sczl_gxmc')
  428. ->find();
  429. if ($res['sczl_yjno']<10){
  430. $res['sczl_yjno'] = '0'.$res['sczl_yjno'];
  431. }
  432. $processList['process'] = $res['sczl_yjno'].'-'.$res['sczl_gxmc'];
  433. $processList['completed'] = \db('设备_产量计酬')
  434. ->where('sczl_gdbh',$workOrder)
  435. ->where('sczl_gxh',$v)
  436. ->count();
  437. array_push($data,$processList);
  438. }
  439. }
  440. $this->success('成功',$data);
  441. }
  442. /**
  443. * 班组人员及分配比例
  444. * @ApiMethod (GET)
  445. * @param string $machine 机台编号
  446. * @return void
  447. * @throws \think\db\exception\DataNotFoundException
  448. * @throws \think\db\exception\ModelNotFoundException
  449. * @throws \think\exception\DbException
  450. */
  451. public function Team()
  452. {
  453. if ($this->request->isGet() === false){
  454. $this->error('请求错误');
  455. }
  456. $machine = input('machine');
  457. if (empty($machine)){
  458. $this->error('参数错误');
  459. }
  460. $where = [
  461. 'sczl_jtbh' => $machine,
  462. ];
  463. $field = 'rtrim(sczl_bzdh) as 班组号,rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
  464. rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
  465. rtrim(sczl_bh10) as bh10,rtrim(sczl_rate1) as rate1,rtrim(sczl_rate2) as rate2,rtrim(sczl_rate3) as rate3,rtrim(sczl_rate4) as rate4,
  466. rtrim(sczl_rate5) as rate5,rtrim(sczl_rate6) as rate6,rtrim(sczl_rate7) as rate7,rtrim(sczl_rate8) as rate8,
  467. rtrim(sczl_rate9) as rate9,rtrim(sczl_rate10) as rate10,rtrim(UniqId) as ID';
  468. $team = \db('设备_产量计酬')
  469. ->where('sczl_jtbh',$machine)
  470. ->field($field)
  471. ->order('UniqId desc')
  472. ->find();
  473. $list = \db('设备_班组资料')->where($where)->field($field)->select();
  474. $data = [];
  475. foreach ($list as $k=>$v){
  476. if ($team == $v){
  477. $data[$k]['status'] = 1;
  478. }else{
  479. $data[$k]['status'] = 0;
  480. }
  481. $data[$k]['ID'] = $v['ID'];
  482. $data[$k]['班组号'] = $v['班组号'];
  483. for ($i=1;$i<11;$i++){
  484. if ($v['bh'.$i] != ''){
  485. $name = \db('人事_基本资料')->where('员工编号',$v['bh'.$i])->field('rtrim(员工姓名) as 姓名')->find();
  486. if ($v['rate'.$i] > 0){
  487. $data[$k][$i-1] = $v['bh'.$i].' '.$name['姓名'].' ('.number_format($v['rate'.$i]*100,2).'%'.')';
  488. }else{
  489. $data[$k][$i-1] = $v['bh'.$i].' '.$name['姓名'].' (0.00%'.')';
  490. }
  491. }
  492. }
  493. }
  494. $this->success('成功',$data);
  495. }
  496. /**
  497. * 当班产量明细
  498. * @ApiMethod (GET)
  499. * @param string $machine 机台编号
  500. * @param string $workOrder 工单编号
  501. * @param string $team 班次
  502. * @return void
  503. * @throws \think\db\exception\DataNotFoundException
  504. * @throws \think\db\exception\ModelNotFoundException
  505. * @throws \think\exception\DbException
  506. */
  507. public function OutputDetail()
  508. {
  509. if ($this->request->isGet() === false){
  510. $this->error('请求错误');
  511. }
  512. $machine = input('machine');
  513. $workOrder = input('Gd_gdbh');
  514. $team = substr(input('team'),0,1);
  515. if (empty($machine) || empty($team)){
  516. $this->success('');
  517. }
  518. $sczlTime = date('Y-m-d H:i:s',time());
  519. if ($sczlTime>date('Y-m-d 00:00:00') && $sczlTime<date('Y-m-d 08:30:00')){
  520. $time = date('Y-m-d 00:00:00',time()-86400);
  521. }else{
  522. $time = date('Y-m-d 00:00:00');
  523. }
  524. $where = [
  525. 'sczl_jtbh' => $machine,
  526. 'sczl_bzdh' => ['like',$team.'%'],
  527. 'sczl_rq' => $time,
  528. ];
  529. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_num) as 流程单号,rtrim(sczl_dedh) as dedh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as 标牌号,rtrim(sczl_cl) as 产量,
  530. rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,rtrim(sczl_装版工时) as 装版工时,
  531. rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常停机工时,rtrim(sczl_设备运行工时) as 通电工时,
  532. rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度,
  533. rtrim(sczl_sj1) as sj1,rtrim(sczl_sj2) as sj2,rtrim(UniqId) as UniqId,rtrim(sczl_bh98) as 拉料,rtrim(sczl_ls) as ls';
  534. $list = \db('设备_产量计酬')->where($where)->field($field)->order('UniqId desc')->select();
  535. if (!empty($list)){
  536. foreach ($list as $k=>$v){
  537. $name = \db('工单_印件资料')->where('Yj_Gdbh',$v['工单编号'])->where('yj_Yjno',$v['yjno'])->field('rtrim(yj_yjmc) as cpmc')->find();
  538. if ($v['yjno']<10){
  539. $list[$k]['yjno'] = '0'.$v['yjno'];
  540. }
  541. if (!empty($v['拉料'])){
  542. $list[$k]['拉料姓名'] = \db('人事_基本资料')->where('员工编号',$v['拉料'])->value('rtrim(员工姓名) as 员工姓名');
  543. }
  544. if (isset($list[$k]['拉料姓名']) === false){
  545. $list[$k]['拉料姓名'] = '';
  546. }
  547. $list[$k]['印件及工序'] = $list[$k]['yjno'].'-'.$v['gxmc'];
  548. $list[$k]['生产时间段'] = substr($v['sj1'],5,5).' '.substr($v['sj1'],11,5).'<-->'.substr($v['sj2'],5,5).' '.substr($v['sj2'],11,5);
  549. $list[$k]['产品名称'] = $name['cpmc'];
  550. }
  551. $field1 = 'SUM(sczl_cl) as 产量,SUM(sczl_zcfp) as 制程废品,SUM(sczl_zccp) as 制程次品,SUM(sczl_前工序废) as 前工序废,
  552. SUM(sczl_来料少数) as 来料异常,SUM(sczl_装版工时) as 装版工时,SUM(sczl_保养工时) as 保养工时,SUM(sczl_打样工时) as 打样工时,
  553. SUM(sczl_异常停机工时) as 异常停机工时,SUM(sczl_设备运行工时) as 通电工时,SUM(码开始行) as 码开始行,SUM(码结束行) as 码结束行,
  554. SUM(码包) as 码包,SUM(主电表) as 主电表,SUM(辅电表) as 辅电表';
  555. $total = \db('设备_产量计酬')->where($where)->field($field1)->order('UniqId desc')->select();
  556. $total[0]['版数'] = count($list);
  557. $list['total'] = $total[0];
  558. }
  559. $this->success('成功',$list);
  560. }
  561. /**
  562. * 检验记录
  563. * @ApiMethod (GET)
  564. * @param string $machine 机台编号
  565. * @param string $workOrder 工单编号
  566. * @param string $team 班次
  567. * @return void
  568. * @throws \think\db\exception\DataNotFoundException
  569. * @throws \think\db\exception\ModelNotFoundException
  570. * @throws \think\exception\DbException
  571. */
  572. public function InspectionRecord()
  573. {
  574. if ($this->request->isGet() === false){
  575. $this->error('请求失败');
  576. }
  577. $machine = input('machine');
  578. $workOrder = input('Gd_gdbh');
  579. $team = input('team');
  580. if (empty($machine) || empty($workOrder) || empty($team)){
  581. $this->success('');
  582. }
  583. $where = [
  584. '设备编号' => $machine,
  585. '工单编号' => $workOrder,
  586. '班组编号' => $team,
  587. '类别' => ['in',['IPQC检验','机台检验']],
  588. ];
  589. //检验项目筛选
  590. $item = \db('制程检验_记录')->where($where)->distinct(true)->column('rtrim(检验项目)');
  591. //检验时间
  592. $InspectionTime = \db('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
  593. foreach ($InspectionTime as $k=>$v){
  594. $InspectionTime[$k] = date('H:i',strtotime($v));
  595. }
  596. //检测记录详情
  597. $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
  598. $nameDetail = \db('制程检验_记录')->where($where)->field($field)->find();
  599. $data = [];
  600. //检测数据
  601. foreach ($item as $key=>$value){
  602. $SubmissionTime = \db('制程检验_记录')->where($where)
  603. ->where('检验项目',$value)
  604. ->where('检验结果','合格')
  605. ->field('rtrim(提交时间) as 提交时间')
  606. ->select();
  607. $time = [];
  608. foreach ($SubmissionTime as $k=>$v){
  609. $time[$k] = date('H:i',strtotime($v['提交时间']));
  610. }
  611. $data[$key] = [
  612. '工单编号' => $nameDetail['工单编号'],
  613. '印件号' => $nameDetail['印件号'],
  614. '工序名称' => $nameDetail['工序名称'],
  615. '检验项目' => $value,
  616. 'inspectresult' => implode(',',$time),
  617. ];
  618. }
  619. $data['inspectiontime'] = $InspectionTime;
  620. $this->success('成功',$data);
  621. }
  622. /**
  623. * 班组维护->班组添加
  624. * @ApiMethod (GET)
  625. * @param void
  626. * @return void
  627. * @throws \think\db\exception\DataNotFoundException
  628. * @throws \think\db\exception\ModelNotFoundException
  629. * @throws \think\exception\DbException
  630. */
  631. public function MachineTeamAdd()
  632. {
  633. if (Request::instance()->isPost() === false ){
  634. $this->error('请求错误');
  635. }
  636. $param = Request::instance()->post();
  637. if (empty($param)){
  638. $this->error('参数错误');
  639. }
  640. $lastId = \db('设备_班组资料')
  641. ->order('UniqId desc')
  642. ->value('UniqId');
  643. if (empty($lastId)){
  644. $lastId = 0;
  645. }
  646. for($i=1;$i<11;$i++){
  647. if (!empty($param['sczl_bh'.$i])){
  648. $name = \db('人事_基本资料')->where('员工编号',$param['sczl_bh'.$i])->value('员工编号');
  649. if (empty($name)){
  650. $this->error('未找到编号'.$param['sczl_bh'.$i].'员工信息,无法添加,请输入正确的员工编号');
  651. }
  652. }
  653. }
  654. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  655. $param['UniqId'] = $lastId + 1;
  656. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  657. $sql = \db('设备_班组资料')->fetchSql(true)->insert($param);
  658. $res = \db()->query($sql);
  659. if ($res !== false){
  660. $this->success('成功');
  661. }else{
  662. $this->error('失败');
  663. }
  664. }
  665. /**
  666. * 机台编号列表
  667. * @ApiMethod (GET)
  668. * @return void
  669. */
  670. public function MachineList()
  671. {
  672. if ($this->request->isGet() === false){
  673. $this->error('请求错误');
  674. }
  675. $list = \db('设备_基本资料')->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
  676. if (empty($list)){
  677. $this->success('未找到机台编号');
  678. }
  679. $data = [];
  680. foreach ($list as $key=>$value){
  681. $data[$key] = $value['设备编号'] . '||' . $value['设备名称'];
  682. }
  683. $this->success('成功',$data);
  684. }
  685. /**
  686. * 删除班组信息
  687. * @ApiMethod (GET)
  688. * @param void
  689. * @return void
  690. * @throws \think\Exception
  691. * @throws \think\exception\PDOException
  692. */
  693. public function teamDel()
  694. {
  695. if (Request::instance()->isPost() === false){
  696. $this->error('请求错误');
  697. }
  698. $param = Request::instance()->post();
  699. if (empty($param)){
  700. $this->error('参数错误');
  701. }
  702. $machine = \db('设备_班组资料')
  703. ->where('UniqId',$param['UniqId'])
  704. ->value('sczl_jtbh');
  705. $teamId = \db('设备_产量采集')
  706. ->where('设备编号',$machine)
  707. ->order('UniqId desc')
  708. ->value('班组ID');
  709. if ($teamId === (int)$param['UniqId']){
  710. $this->success('无法删除正在生产的班组资料,请先切换班组');
  711. }
  712. $res = \db('设备_班组资料')
  713. ->where('UniqId',$param['UniqId'])
  714. ->delete();
  715. if ($res !== false){
  716. $this->success('成功');
  717. }else{
  718. $this->error('失败');
  719. }
  720. }
  721. /**
  722. * 管理人员现场巡检记录->展示
  723. * @ApiMethod (GET)
  724. * @param void
  725. * @return void
  726. * @throws \think\db\exception\DataNotFoundException
  727. * @throws \think\db\exception\ModelNotFoundException
  728. * @throws \think\exception\DbException
  729. */
  730. public function FieldInspectionRecord()
  731. {
  732. if ($this->request->isGet() === false){
  733. $this->error('请求错误');
  734. }
  735. $param = $this->request->param();
  736. if (empty($param)){
  737. $this->error('参数错误');
  738. }
  739. $date = date('Y-m-d H:i:s',time());
  740. if (empty($param['start'])){
  741. $startTime = date('Y-m-d 08:30:00',time());
  742. }else{
  743. $startTime = date('Y-m-d H:i:s',strtotime($param['start']));
  744. }
  745. if ($date<$startTime){
  746. $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
  747. }
  748. $where = [
  749. '工单编号' => $param['workOrder'],
  750. '开工时间' => $startTime,
  751. '类别' => '现场巡查记录',
  752. '班组编号' => ['like',substr($param['team'],0,1).'%']
  753. ];
  754. $filed = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,rtrim(流程单号) as 流程单号,
  755. rtrim(设备编号) as 设备编号,rtrim(班组编号) as 班组编号,rtrim(检验项目) as 现场管理人员,rtrim(检验备注) as 检验备注,
  756. rtrim(提交时间) as 提交时间,rtrim(开工时间) as 开工时间';
  757. $list = \db('制程检验_记录')->where($where)
  758. ->field($filed)
  759. ->select();
  760. if (empty($list)){
  761. $this->success('',[]);
  762. }
  763. foreach ($list as $key=>$value){
  764. $number = floor((strtotime($value['提交时间'])-strtotime($value['开工时间']))/(15*60));
  765. $list[$key]['归属时段'] = $value['开工时间'];
  766. $list[$key]['分钟差数'] = $number;
  767. if ($number != 0){
  768. $list[$key]['归属时段'] = date('Y-m-d H:i:s',strtotime($value['开工时间'])+$number*15*60);
  769. }
  770. }
  771. $this->success('成功',$list);
  772. }
  773. /**
  774. * 管理人员现场巡检记录->添加
  775. * @ApiMethod (POST)
  776. * @param void
  777. * @return void
  778. */
  779. public function FieldInspectionRecordAdd()
  780. {
  781. if (Request::instance()->isPost() === false){
  782. $this->error('请求错误');
  783. }
  784. $param = Request::instance()->post();
  785. if (empty($param)){
  786. $this->error('参数错误');
  787. }
  788. if ($param['processCode']<10){
  789. $param['processCode'] = '0'.$param['processCode'];
  790. }
  791. $date = date('Y-m-d H:i:s',time());
  792. $startTime = date('Y-m-d 08:30:00',time());
  793. if ($date<$startTime){
  794. $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
  795. }
  796. $data = [
  797. '类别' => $param['category'],
  798. '工单编号' => $param['workOrder'],
  799. '印件号' => $param['printCode'],
  800. '工序名称' => $param['processCode'].'-'.$param['process'],
  801. '流程单号' => $param['flowCode'],
  802. '设备编号' => $param['machine'],
  803. '班组编号' => $param['team'],
  804. '检验项目' => '['.$param['employeeCode'].'/'.$param['employeeName'].']',
  805. '相关标准' => '',
  806. '量测仪器' => '',
  807. '检验结果' => '',
  808. '检验备注' => $param['remark'],
  809. '提交时间' => date('Y-m-d H:i:s',time()),
  810. '开工时间' => $startTime,
  811. 'sys_id' => '',
  812. 'sys_rq' => date('Y-m-d H:i:s',time()),
  813. 'mod_rq' => '0000-00-00 00:00:00',
  814. 'UniqId' => \db('制程检验_记录')->order('UniqId desc')->field('UniqId')->find()['UniqId']+1
  815. ];
  816. $sql = \db('制程检验_记录')->fetchSql(true)->insert($data);
  817. $res = Db::query($sql);
  818. if ($res !== false){
  819. $this->success('成功');
  820. }else{
  821. $this->error('失败');
  822. }
  823. }
  824. /**
  825. * 设备点检->左侧菜单栏
  826. * @ApiMethod (GET)
  827. * @param void
  828. * @return void
  829. */
  830. public function SpotCheckItem()
  831. {
  832. if ($this->request->isGet() === false){
  833. $this->error('请求错误');
  834. }
  835. $param = $this->request->param();
  836. if (empty($param)){
  837. $this->error('参数错误');
  838. }
  839. $list = \db('设备_点检项目')
  840. ->where('适用机型','LIKE','%;'.$param['machine'].';%')
  841. ->distinct(true)
  842. ->column('部件名称','部件编号');
  843. if (empty($list)){
  844. $this->success('');
  845. }
  846. $this->success('成功',$list);
  847. }
  848. /**
  849. * 设备点检->检测项目
  850. * @ApiMethod (GET)
  851. * @param void
  852. * @return void
  853. * @throws \think\db\exception\DataNotFoundException
  854. * @throws \think\db\exception\ModelNotFoundException
  855. * @throws \think\exception\DbException
  856. */
  857. public function InspectionItem()
  858. {
  859. if ($this->request->isGet() === false){
  860. $this->error('请求错误');
  861. }
  862. $param = $this->request->param();
  863. if (empty($param)){
  864. $this->error('参数错误');
  865. }
  866. $list = \db('设备_点检项目')
  867. ->where('部件名称',$param['unitName'])
  868. ->where('适用机型','like','%'.$param['machine'].'#%')
  869. ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
  870. ->select();
  871. if (empty($list)){
  872. $this->success('未找到检测项目');
  873. }
  874. $this->success('成功',$list);
  875. }
  876. /**
  877. * 设备点检->检测记录添加
  878. * @ApiMethod (POST)
  879. * @param void
  880. * @return void
  881. * @throws \think\db\exception\DataNotFoundException
  882. * @throws \think\db\exception\ModelNotFoundException
  883. * @throws \think\exception\DbException
  884. */
  885. public function InspectionItemAdd()
  886. {
  887. if (Request::instance()->isPost() === false){
  888. $this->error('请求错误');
  889. }
  890. $param = Request::instance()->post();
  891. if (empty($param)){
  892. $this->error('参数错误');
  893. }
  894. $lastNumber = \db("设备_点检记录")->field('Uniqid as ID')->order('Uniqid desc')->find()['ID'];
  895. if (empty($lastNumber)){
  896. $lastId = 0;
  897. }else{
  898. $lastId = $lastNumber;
  899. }
  900. $row = [];
  901. foreach ($param as $key=>$value){
  902. $unitCode = \db('设备_点检项目')->where('部件名称',$value['unitName'])->field('rtrim(部件编号) as 部件编号')->find();
  903. $row[$key] = [
  904. '日期' => date('Y-m-d 00:00:00',time()),
  905. '班组编号' => $value['team'],
  906. '点检设备' => $value['machine'],
  907. '部件编号' => $unitCode['部件编号'],
  908. '部件名称' => $value['unitName'],
  909. '检验项目' => $value['itemName'],
  910. '判定标准' => $value['standard'],
  911. '点检方法' => $value['method'],
  912. '点检结果' => $value['status'],
  913. '备注说明' => $value['remark'],
  914. 'Sys_id' =>'',
  915. 'Sys_rq' => date('Y-m-d H:i:s',time()),
  916. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  917. 'Uniqid' => $lastId+$key+1
  918. ];
  919. }
  920. $sql = \db('设备_点检记录')->fetchSql(true)->insertAll($row);
  921. $res = Db::query($sql);
  922. if ($res !== false){
  923. $this->success('成功');
  924. }else{
  925. $this->error('失败');
  926. }
  927. }
  928. /**
  929. * 机台印版领用->左侧菜单
  930. * @ApiMethod (GET)
  931. * @param void
  932. * @return void
  933. */
  934. public function PrintGetTab()
  935. {
  936. if ($this->request->isGet() === false){
  937. $this->error('请求错误');
  938. }
  939. $param = $this->request->param();
  940. if (empty($param)){
  941. $this->error('参数错误');
  942. }
  943. $productCode = $param['productCode'];
  944. $sql = "SELECT DISTINCT(RTRIM(b.`名称`)) as `印版分类`,RTRIM(b.`编号`) as `编号` FROM `产品_印版资料` as a
  945. JOIN `物料_存货结构` as b ON b.`编号` = SUBSTRING(a.`存货编码`,1,4)
  946. WHERE a.YB_Cpdh = '{$productCode}'";
  947. $res = Db::query($sql);
  948. if (empty($res)){
  949. $this->success('');
  950. }
  951. $this->success('成功',$res);
  952. }
  953. /**
  954. * 机台印版领用记录->数据详情
  955. * @ApiMethod (GET)
  956. * @param void
  957. * @return void
  958. */
  959. public function PrintDetail()
  960. {
  961. if ($this->request->isGet() === false){
  962. $this->error('请求失败');
  963. }
  964. $param = $this->request->param();
  965. if (empty($param)){
  966. $this->error('参数错误');
  967. }
  968. $productCode = $param['productCode'];
  969. $code = $param['code'].'%';
  970. $workOrder = $param['workOrder'];
  971. $sql = "SELECT
  972. RTRIM(a.`存货编码`) as `存货编码`,
  973. RTRIM(c.`物料名称`) as `存货名称`,
  974. RTRIM(b.`印版名称`) as `印版名称`,
  975. RTRIM(b.`供方批号`) as `供方批号`,
  976. RTRIM(b.`制造日期`) as `制造日期`,
  977. SUM(d.`Yb_印数`) as `印数`,
  978. RTRIM(e.`名称`) as `印版类别`,
  979. SUBSTRING(a.YB_Cpdh,1,4) as `客户编号`,
  980. RTRIM(f.`Gd_客户名称`) as `客户名称`,
  981. RTRIM(a.YB_Cpdh) as `产品编号`,
  982. RTRIM(f.Gd_cpmc) as `产品名称`,
  983. RTRIM(d.UniqID) as UniqId
  984. FROM `产品_印版资料` as a
  985. LEFT JOIN `产品_印版库` as b ON b.`存货编码` = a.`存货编码`
  986. JOIN `物料_存货编码` as c ON c.`物料代码` = a.`存货编码`
  987. LEFT JOIN `工单_印版领用记录` as d ON d.`Yb_供方批号` = b.`供方批号`
  988. JOIN `物料_存货结构` as e ON e.`编号` = SUBSTRING(a.`存货编码`,1,4)
  989. JOIN `工单_基本资料` as f ON a.YB_Cpdh = f.Gd_cpdh
  990. WHERE a.YB_Cpdh = '{$productCode}'
  991. AND a.`存货编码` LIKE '{$code}'
  992. AND f.Gd_gdbh = '{$workOrder}'
  993. AND b.`报废日期` = '1900-01-01 00:00:00'
  994. GROUP BY b.`供方批号`
  995. ORDER BY a.`存货编码`";
  996. $list = Db::query($sql);
  997. if (empty($list)){
  998. $this->success('');
  999. }
  1000. $this->success('成功',$list);
  1001. }
  1002. /**
  1003. * 换型清场->左侧菜单栏
  1004. * @ApiMethod (GET)
  1005. * @param void
  1006. * @return void
  1007. */
  1008. public function remodelGetTab()
  1009. {
  1010. if ($this->request->isGet() === false){
  1011. $this->error('请求错误');
  1012. }
  1013. $date = date('Y-m-d 00:00:00',time()-3456000);
  1014. $nowTime = date('Y-m-d H:i:s',time());
  1015. $list = \db('设备_基本资料')->where('使用状态',1)->order('设备编号')->column('设备编号');
  1016. if (empty($list)){
  1017. $this->error('失败');
  1018. }
  1019. $sql = "SELECT RTRIM(a.`设备编号`) as `设备编号`,RTRIM(b.`日期`) as `日期`,RTRIM(b.UniqId) as UniqId
  1020. FROM `设备_基本资料` as a
  1021. LEFT JOIN `制程_换型清场` as b ON b.`机台编号` = a.`设备编号`
  1022. WHERE b.`日期` > '{$date}' AND b.日期 < '{$nowTime}' AND b.`工单编号A` <> '' AND b.`工单编号B` <> '' ORDER BY b.`UniqId`";
  1023. $res = Db::query($sql);
  1024. $data = $result = [];
  1025. foreach ($list as $key=>$value){
  1026. $data[$value] = $result[$value]= $time = [];
  1027. foreach ($res as $k=>$v){
  1028. if ($value === $v['设备编号']){
  1029. $row = [
  1030. '日期' => $v['日期'],
  1031. 'id' => $v['UniqId']
  1032. ];
  1033. array_push($data[$value],$row);
  1034. }
  1035. }
  1036. foreach ($data[$value] as $m=>$n){
  1037. $time[$m] = $n['日期'];
  1038. }
  1039. $time = array_values(array_unique($time));
  1040. foreach ($time as $kk=>$vv){
  1041. $i=1;
  1042. foreach ($data[$value] as $kkk=>$vvv){
  1043. if ($kkk>=$kk && $vv === $vvv['日期']){
  1044. array_push($result[$value],date('Y-m-d',strtotime($vv)).'第'.$i.'次换型/'.$vvv['id']);
  1045. $i++;
  1046. }
  1047. }
  1048. }
  1049. }
  1050. $this->success('成功',$result);
  1051. }
  1052. /**
  1053. * 换型清场->详情
  1054. * @return void
  1055. * @throws \think\db\exception\DataNotFoundException
  1056. * @throws \think\db\exception\ModelNotFoundException
  1057. * @throws \think\exception\DbException
  1058. */
  1059. public function RemodelDetail()
  1060. {
  1061. if ($this->request->isGet() === false){
  1062. $this->error('请求错误');
  1063. }
  1064. $param = $this->request->param();
  1065. if (empty($param)){
  1066. $this->error('参数错误');
  1067. }
  1068. $field = 'rtrim(日期) as 日期,rtrim(班组) as 班组,rtrim(机台编号) as 机台编号,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
  1069. rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包B,
  1070. rtrim(清场项目A) as 项目1,rtrim(清场项目B) as 项目2,rtrim(清场项目C) as 项目3,rtrim(清场项目D) as 项目4,rtrim(清场项目E) as 项目5,
  1071. rtrim(机长) as 机长,rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员';
  1072. $list = \db('制程_换型清场')->where('UniqId',$param['UniqId'])->field($field)->find();
  1073. if (empty($list)){
  1074. $this->success('未找到该条清场记录');
  1075. }
  1076. $list['日期'] = date('Y-m-d',strtotime($list['日期']));
  1077. $printNameA = \db('工单_印件资料')->where('Yj_Gdbh',$list['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find();
  1078. if (empty($printNameA)){
  1079. $list['印件名称A'] = '';
  1080. }else{
  1081. $list['印件名称A'] = $printNameA['yjmc'];
  1082. }
  1083. $printNameB = \db('工单_印件资料')->where('Yj_Gdbh',$list['工单编号B'])->field('rtrim(yj_yjmc) as yjmc')->find();
  1084. if (empty($printNameB)){
  1085. $list['印件名称B'] = '';
  1086. }else{
  1087. $list['印件名称B'] = $printNameB['yjmc'];
  1088. }
  1089. $this->success('成功',$list);
  1090. }
  1091. /**
  1092. * 换型清场->当前设备清场记录
  1093. * @ApiMethod (GET)
  1094. * @param void
  1095. * @return void
  1096. * @throws \think\db\exception\DataNotFoundException
  1097. * @throws \think\db\exception\ModelNotFoundException
  1098. * @throws \think\exception\DbException
  1099. */
  1100. public function ModelChangeRecord()
  1101. {
  1102. if ($this->request->isGet() === false){
  1103. $this->error('请求错误');
  1104. }
  1105. $param = $this->request->param();
  1106. if (empty($param)){
  1107. $this->error('参数错误');
  1108. }
  1109. $date = date('Y-m-d 00:00:00',time()-3888000);
  1110. $nowTime = date('Y-m-d H:i:s',time());
  1111. $where = [
  1112. '日期' =>['between',[$date,$nowTime]],
  1113. '机台编号' => $param['machine'],
  1114. '工单编号A' => ['<>',''],
  1115. '工单编号B' => ['<>',''],
  1116. ];
  1117. $field = "rtrim(日期) as 日期,rtrim(机台编号) as 机台编号,rtrim(班组) as 班组,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
  1118. rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包号B,rtrim(清场项目A) as 清场项目A,
  1119. rtrim(清场项目B) as 清场项目B,rtrim(清场项目C) as 清场项目C,rtrim(清场项目D) as 清场项目D,rtrim(清场项目E) as 清场项目E,rtrim(机长) as 机长,
  1120. rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员,rtrim(sys_rq) as 创建时间,rtrim(UniqId) as UNIQID";
  1121. $list = \db('制程_换型清场')
  1122. ->where($where)
  1123. ->field($field)
  1124. ->select();
  1125. if (empty($list)){
  1126. $this->success('未找到换型记录');
  1127. }
  1128. foreach ($list as $key=>$value){
  1129. $printNameA = \db('工单_印件资料')->where('Yj_Gdbh',$value['工单编号A'])->value('rtrim(yj_yjmc) as yjmc');
  1130. if (empty($printNameA)){
  1131. $list[$key]['印件名称A'] = '';
  1132. }else{
  1133. $list[$key]['印件名称A'] = $printNameA;
  1134. }
  1135. $printNameB = \db('工单_印件资料')->where('Yj_Gdbh',$value['工单编号B'])->value('rtrim(yj_yjmc) as yjmc');
  1136. if (empty($printNameB)){
  1137. $list[$key]['印件名称B'] = '';
  1138. }else{
  1139. $list[$key]['印件名称B'] = $printNameB;
  1140. }
  1141. }
  1142. $this->success('成功',$list);
  1143. }
  1144. /**
  1145. * 车间机台状态列表展示
  1146. * @ApiMethod (GET)
  1147. * @param void
  1148. * @return void
  1149. * @throws \think\db\exception\BindParamException
  1150. * @throws \think\exception\PDOException
  1151. */
  1152. public function MachineDetailList()
  1153. {
  1154. if ($this->request->isGet() === false){
  1155. $this->error('请求错误');
  1156. }
  1157. $param = $this->request->param();
  1158. if (empty($param)){
  1159. $this->error('参数错误');
  1160. }
  1161. $workshop = $param['workshop'];
  1162. $sql = "SELECT
  1163. RTRIM( a.`设备编号` ) AS 设备编号,
  1164. RTRIM( a.`设备名称` ) AS 设备名称,
  1165. RTRIM( d.`当前状态` ) AS 状态
  1166. FROM
  1167. `设备_基本资料` AS a
  1168. JOIN (
  1169. SELECT
  1170. b.`设备编号`,
  1171. b.`当前状态`,
  1172. b.`开工时间`
  1173. FROM
  1174. `设备_产量采集` AS b
  1175. JOIN ( SELECT `设备编号`, MAX( `UniqId` ) AS `UniqId` FROM `设备_产量采集` GROUP BY `设备编号` ) AS c ON b.`设备编号` = c.`设备编号`
  1176. AND b.`UniqId` = c.`UniqId`
  1177. ) AS d ON a.`设备编号` = d.`设备编号`
  1178. WHERE
  1179. a.`使用部门` = '{$workshop}'
  1180. GROUP BY
  1181. a.`设备编号`
  1182. ORDER BY
  1183. a.UniqId";
  1184. $list = \db()->query($sql);
  1185. foreach ($list as $key=>$value){
  1186. if ($value['状态'] == ''){
  1187. $list[$key]['状态'] = '待单';
  1188. }
  1189. }
  1190. $this->success('成功',$list);
  1191. }
  1192. /**
  1193. * 机台当前参数展示
  1194. * @ApiMethod (GET)
  1195. * @return void
  1196. * @throws \think\db\exception\DataNotFoundException
  1197. * @throws \think\db\exception\ModelNotFoundException
  1198. * @throws \think\exception\DbException
  1199. */
  1200. public function MachineDetail()
  1201. {
  1202. if ($this->request->isGet() === false){
  1203. $this->error('请求错误');
  1204. }
  1205. $param = $this->request->param();
  1206. if (empty($param)){
  1207. $this->error('参数错误');
  1208. }
  1209. $data = [];
  1210. if ($param['start'] === ''){
  1211. if (date('Y-m-d H:i:s')>date('Y-m-d 08:30:00',time()) && date('Y-m-d H:i:s')<date('Y-m-d 20:30:00',time())){
  1212. $param['start'] = date('Y-m-d 08:30:00',time());
  1213. }elseif (date('Y-m-d H:i:s')>date('Y-m-d 20:30:00',time()) && date('Y-m-d H:i:s')<date('Y-m-d 23:59:59',time())){
  1214. $param['start'] = date('Y-m-d 20:30:00',time());
  1215. }else{
  1216. $param['start'] = date('Y-m-d 20:30:00',time()-86400);
  1217. }
  1218. }
  1219. $machineDetail = \db('设备_产量采集')
  1220. ->alias('a')
  1221. ->join('设备_基本资料 b','a.设备编号 = b.设备编号')
  1222. ->join('工单_工艺资料 c','a.工单编号 = c.Gy0_gdbh AND a.设备编号 = c.Gy0_sbbh')
  1223. ->join('工单_基本资料 d','a.工单编号 = d.Gd_gdbh')
  1224. ->field([
  1225. 'rtrim(a.开工时间)' => '开工时间',
  1226. 'rtrim(a.设备编号)' => '设备编号',
  1227. 'rtrim(a.工单编号)' => '工单编号',
  1228. 'rtrim(b.设备名称)' => '设备名称',
  1229. 'rtrim(c.Gy0_gxh)' => '工序号',
  1230. 'rtrim(c.Gy0_gxmc)' => '工序名称',
  1231. 'rtrim(d.Gd_cpmc)' => '产品名称'
  1232. ])
  1233. ->where('a.设备编号', $param['machine'])
  1234. ->order('a.UniqId desc')
  1235. ->find();
  1236. $data['machine'] = [
  1237. '日期' => $machineDetail['开工时间'],
  1238. '设备' => $machineDetail['设备编号'].'-->'.$machineDetail['设备名称'],
  1239. '工单' => $machineDetail['工单编号'].'-->'.$machineDetail['产品名称'],
  1240. '工艺' => ($machineDetail['工序号']<10?'0'.$machineDetail['工序号']:$machineDetail['工序号']).'--'.$machineDetail['工序名称']
  1241. ];
  1242. //机台状态时间
  1243. $startTime = \db('设备_产量采集')
  1244. ->where('设备编号',$param['machine'])
  1245. ->where('开工时间',$param['start'])
  1246. ->field('rtrim(时间) as 时间,当班产量,rtrim(当前状态) as 状态,MAX(时间) as 最大时间,MAX(当班产量) as 最大产量')
  1247. ->group('当前状态')
  1248. ->select();
  1249. if (!empty($startTime)){
  1250. foreach ($startTime as $key=>$value){
  1251. $data['timeDifference'][$key] = [
  1252. '时间' => round((strtotime($value['最大时间'])-strtotime($value['时间']))/3600,2),
  1253. '状态' => $value['状态'] = null?'待单':$value['状态'],
  1254. ];
  1255. if ($value['状态'] === '生产'){
  1256. $data['当班产量'] = $value['最大产量']-$value['当班产量'];
  1257. }
  1258. }
  1259. }else{
  1260. $data['timeDifference'][0] = [
  1261. '时间' => 0,
  1262. '状态' => '待单'
  1263. ];
  1264. $data['当班产量'] = 0;
  1265. }
  1266. //机台产能/时间明细
  1267. $row = \db('设备_产量采集')
  1268. ->where('设备编号',$param['machine'])
  1269. ->where('开工时间',$param['start'])
  1270. ->where('当班产量','<>',-1)
  1271. ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
  1272. ->select();
  1273. if (empty($row)){
  1274. $data['row'] = [];
  1275. }
  1276. foreach ($row as $key=>$value){
  1277. $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['时间']));
  1278. $data['row'][$key]['状态'] = $value['状态'];
  1279. if ($key<2){
  1280. $data['row'][$key]['产能'] = 0;
  1281. }else{
  1282. $data['row'][$key]['产能'] = ($row[$key-1]['产量']-$row[$key-2]['产量'])*60;
  1283. }
  1284. }
  1285. //机台状态
  1286. $status = end($row);
  1287. if (empty($status['状态'])){
  1288. $data['status'] = '待单';
  1289. }else{
  1290. $data['status'] = $status['状态'];
  1291. }
  1292. //检验数据
  1293. $list = \db('制程检验_记录')
  1294. ->where('开工时间',$param['start'])
  1295. ->where('设备编号',$param['machine'])
  1296. ->where('sys_rq','>',$param['start'])
  1297. ->where('工单编号',$machineDetail['工单编号'])
  1298. ->field('rtrim(类别) as 类别,提交时间')
  1299. ->select();
  1300. $data['首件'] = $data['自检'] = $data['IPQC'] = [];
  1301. if (!empty($list)){
  1302. foreach ($list as $key=>$value){
  1303. if ($value['类别'] == '首件与过程确认'){
  1304. array_push($data['首件'],$value['提交时间']);
  1305. }
  1306. if ($value['类别'] == '机台检验'){
  1307. array_push($data['自检'],$value['提交时间']);
  1308. }
  1309. if ($value['类别'] == 'IPQC检验'){
  1310. array_push($data['IPQC'],$value['提交时间']);
  1311. }
  1312. }
  1313. $data['首件'] = array_values(array_unique($data['首件']));
  1314. $data['自检'] = array_values(array_unique($data['自检']));
  1315. $data['IPQC'] = array_values(array_unique($data['IPQC']));
  1316. }else{
  1317. $data['首件'] = [];
  1318. $data['自检'] = [];
  1319. $data['IPQC'] = [];
  1320. }
  1321. $this->success('成功',$data);
  1322. }
  1323. /**
  1324. * 制程检验记录->检验项目
  1325. * @ApiMethod (GET)
  1326. * @param void
  1327. * @return void
  1328. * @throws \think\db\exception\DataNotFoundException
  1329. * @throws \think\db\exception\ModelNotFoundException
  1330. * @throws \think\exception\DbException
  1331. */
  1332. public function ProcessInspectionRecordsItem()
  1333. {
  1334. if ($this->request->isGet() === false){
  1335. $this->error('请求错误');
  1336. }
  1337. $param = $this->request->param();
  1338. if (empty($param)){
  1339. $this->error('参数错误');
  1340. }
  1341. $list = \db('制程检验_项目')
  1342. ->where('工序','like','%'.$param['process'].'%')
  1343. ->select();
  1344. if (empty($list)){
  1345. $this->success('未找到检测项目');
  1346. }
  1347. $data = [];
  1348. foreach ($list as $key=>$value){
  1349. $data['首件']['指标检验'][$key] = [
  1350. '检验项目' => rtrim($value['检测项目']),
  1351. '检测方法' => rtrim($value['检测方法']),
  1352. '检验频率' => rtrim($value['首件签样要求']),
  1353. '相关标准' => rtrim($value['技术要求'])
  1354. ];
  1355. $data['机台检验']['指标检验'][$key] = [
  1356. '检验项目' => rtrim($value['检测项目']),
  1357. '检测方法' => rtrim($value['检测方法']),
  1358. '检验频率' => rtrim($value['机台自检频率']),
  1359. '相关标准' => rtrim($value['技术要求'])
  1360. ];
  1361. $data['IPQC']['指标检验'][$key] = [
  1362. '检验项目' => rtrim($value['检测项目']),
  1363. '检测方法' => rtrim($value['检测方法']),
  1364. '检验频率' => rtrim($value['IPQC检验频率']),
  1365. '相关标准' => rtrim($value['技术要求'])
  1366. ];
  1367. }
  1368. $row = \db('制程检验_项目附加')
  1369. ->where('工序','like','%'.$param['process'].'%')
  1370. ->select();
  1371. foreach ($row as $key=>$value){
  1372. $data['首件']['附加'][$key] = [
  1373. '缺陷备注' => rtrim($value['缺陷备注']),
  1374. '编号' => rtrim($value['编号'])
  1375. ];
  1376. $data['机台检验']['附加'][$key] = [
  1377. '缺陷备注' => rtrim($value['缺陷备注']),
  1378. '编号' => rtrim($value['编号'])
  1379. ];
  1380. $data['IPQC']['附加'][$key] = [
  1381. '缺陷备注' => rtrim($value['缺陷备注']),
  1382. '编号' => rtrim($value['编号'])
  1383. ];
  1384. }
  1385. $this->success('成功',$data);
  1386. }
  1387. /**
  1388. * 制程检验记录->检测记录添加
  1389. * @ApiMethod (POST)
  1390. * @param void
  1391. * @return void
  1392. * @throws \think\db\exception\DataNotFoundException
  1393. * @throws \think\db\exception\ModelNotFoundException
  1394. * @throws \think\exception\DbException
  1395. */
  1396. public function ProcessInspectionRecordsItemAdd()
  1397. {
  1398. if (Request::instance()->isPost() === false){
  1399. $this->error('请求错误');
  1400. }
  1401. $param = Request::instance()->post();
  1402. if (empty($param)){
  1403. $this->error('参数错误');
  1404. }
  1405. $startID = \db('制程检验_记录')->order('UniqId desc')->value('UniqId');
  1406. if (empty($startID)){
  1407. $startID = 0;
  1408. }
  1409. $process = \db('工单_工艺资料')
  1410. ->where('Gy0_gdbh',$param[0]['workOrder'])
  1411. ->where('Gy0_sbbh','like','%'.$param[0]['machine'].'#'.'%')
  1412. ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
  1413. ->find();
  1414. $startTime = \db('设备_产量采集')
  1415. ->where('设备编号','like','%'.$param[0]['machine'].'#%')
  1416. ->where('工单编号',$param[0]['workOrder'])
  1417. ->order('UniqId desc')
  1418. ->find();
  1419. if ((int)$process['gxh']<10){
  1420. $process['gxh'] = '0'.$process['gxh'];
  1421. }
  1422. if ($process['add_gxmc'] !== ''){
  1423. $printName = $process['gxh'].'-'.$process['gxmc'].'【'.$process['add_gxmc'].'】';
  1424. }else{
  1425. $printName = $process['gxh'].'-'.$process['gxmc'];
  1426. }
  1427. if (empty($process)){
  1428. $this->success('数据错误');
  1429. }
  1430. $data = [];
  1431. foreach ($param as $key=>$value){
  1432. $data[$key] = [
  1433. '类别' => $value['category'],
  1434. '工单编号' => $value['workOrder'],
  1435. '印件号' => $value['yjno'],
  1436. '工序名称' => $printName,
  1437. '流程单号' => $value['flow'],
  1438. '设备编号' => $value['machine'].'#',
  1439. '班组编号' => $startTime['班组编号'],
  1440. '检验项目' => $value['item'],
  1441. '相关标准' => $value['standard'],
  1442. '量测仪器' => $value['instrument'],
  1443. '检验结果' => $value['result'],
  1444. '检验备注' => $value['remark'],
  1445. '提交时间' => date('Y-m-d H:i:s',time()),
  1446. '开工时间' => rtrim($startTime['开工时间']),
  1447. 'sys_id' => '',
  1448. 'sys_rq' => date('Y-m-d H:i:s',time()),
  1449. 'mod_rq' => '0000-00-00 00:00:00',
  1450. 'UniqId' => $startID + $key +1
  1451. ];
  1452. }
  1453. $res = \db('制程检验_记录')->insertAll($data);
  1454. if ($res !== false){
  1455. $this->success('成功');
  1456. }else{
  1457. $this->error('失败');
  1458. }
  1459. }
  1460. /**
  1461. * 制程检验记录->附加检验记录添加
  1462. * @ApiMethod (POST)
  1463. * @param void
  1464. * @return void
  1465. * @throws \think\db\exception\DataNotFoundException
  1466. * @throws \think\db\exception\ModelNotFoundException
  1467. * @throws \think\exception\DbException
  1468. */
  1469. public function AdditionalInspectionRecordAdd()
  1470. {
  1471. if (Request::instance()->isPost() === false){
  1472. $this->error('请求错误');
  1473. }
  1474. $param = Request::instance()->post();
  1475. if (empty($param)){
  1476. $this->error('参数错误');
  1477. }
  1478. $startID = \db('制程检验_记录附加')->order('UniqId desc')->value('UniqId');
  1479. if (empty($startID)){
  1480. $startID = 0;
  1481. }
  1482. $process = \db('工单_工艺资料')
  1483. ->where('Gy0_gdbh',$param[0]['workOrder'])
  1484. ->where('Gy0_sbbh','like','%'.$param[0]['machine'].'#'.'%')
  1485. ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
  1486. ->find();
  1487. $startTime = \db('设备_产量采集')
  1488. ->where('设备编号','like','%'.$param[0]['machine'].'#%')
  1489. ->where('工单编号',$param[0]['workOrder'])
  1490. ->order('UniqId desc')
  1491. ->find();
  1492. if ((int)$process['gxh']<10){
  1493. $process['gxh'] = '0'.$process['gxh'];
  1494. }
  1495. if ($process['add_gxmc'] !== ''){
  1496. $printName = $process['gxh'].'-'.$process['gxmc'].'【'.$process['add_gxmc'].'】';
  1497. }else{
  1498. $printName = $process['gxh'].'-'.$process['gxmc'];
  1499. }
  1500. if (empty($process)){
  1501. $this->success('数据错误');
  1502. }
  1503. $data = [];
  1504. foreach ($param as $key=>$value){
  1505. $data[$key] = [
  1506. '工单编号' => $value['workOrder'],
  1507. '印件号' => $value['yjno'],
  1508. '工序名称' => $printName,
  1509. '流程单号' => $value['flow'],
  1510. '设备编号' => $value['machine'],
  1511. '班组编号' => $startTime['班组编号'],
  1512. '缺陷备注' => $value['remark'],
  1513. '提交时间' => date('Y-m-d H:i:s',time()),
  1514. '开工时间' => rtrim($startTime['开工时间']),
  1515. 'sys_id' => '',
  1516. 'sys_rq' => date('Y-m-d H:i:s',time()),
  1517. 'mod_rq' => '0000-00-00 00:00:00',
  1518. 'UniqId' => $startID + $key +1
  1519. ];
  1520. }
  1521. $res = \db('制程检验_记录附加')->insertAll($data);
  1522. if ($res !== false){
  1523. $this->success('成功');
  1524. }else{
  1525. $this->error('失败');
  1526. }
  1527. }
  1528. /**
  1529. * 客诉记录
  1530. * @ApiMethod (GET)
  1531. * @param void
  1532. * @return void
  1533. * @throws \think\db\exception\DataNotFoundException
  1534. * @throws \think\db\exception\ModelNotFoundException
  1535. * @throws \think\exception\DbException
  1536. */
  1537. public function ComplaintRecord()
  1538. {
  1539. if ($this->request->isGet() === false){
  1540. $this->error('请求错误');
  1541. }
  1542. $param = $this->request->param();
  1543. if (isset($param['productCode'])){
  1544. $where['产品编号'] = $param['productCode'];
  1545. }
  1546. $filed = "rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,rtrim(客诉日期) as 客诉日期,rtrim(客诉单号) as 客诉单号,
  1547. rtrim(客诉方式) as 客诉方式,rtrim(订单编号) as 订单编号,rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,
  1548. rtrim(客诉描述) as 客诉描述,rtrim(缺陷关键字) as 缺陷关键字,rtrim(客诉性质) as 客诉性质,rtrim(扣分) as 扣分,
  1549. rtrim(主要责任部门) as 主要责任部门,rtrim(次要责任部门) as 次要责任部门";
  1550. $list = \db('db_客诉记录')
  1551. ->where($where)
  1552. ->field($filed)
  1553. ->select();
  1554. if (empty($list)){
  1555. $this->success('未找到该产品客诉记录');
  1556. }
  1557. $this->success('成功',$list);
  1558. }
  1559. /**
  1560. * 设置机台班组信息
  1561. * @return void
  1562. * @throws \think\db\exception\DataNotFoundException
  1563. * @throws \think\db\exception\ModelNotFoundException
  1564. * @throws \think\exception\DbException
  1565. */
  1566. public function setMachineTeam()
  1567. {
  1568. if (Request::instance()->isPost() == false) {
  1569. $this->error('非法请求');
  1570. }
  1571. $params = Request::instance()->post();
  1572. if (!isset($params['machine']) || empty($params['machine'] )) {
  1573. $this->error('参数不能为空');
  1574. }
  1575. if (empty($params['team_id']) || empty($params['sczl_bzdh'])){
  1576. $this->error('请先选择班组成员');
  1577. }
  1578. $machine = $params['machine'] . '#';
  1579. $data = [];
  1580. $lastData = \db('设备_产量采集')
  1581. ->order('UniqId desc')
  1582. ->find();
  1583. $id = $lastData['UniqId']+1;
  1584. $data['当前状态'] = $params['status'];
  1585. $data['时间'] = date('Y-m-d H:i:s');
  1586. $data['设备编号'] = $machine;
  1587. $data['工单编号'] = empty($params['order']) ? '':$params['order'];
  1588. $data['印件号'] = empty($params['yjno']) ? '':$params['yjno'];
  1589. $data['工序号'] = empty($params['gy_name']) ? '' : (int)substr($params['gy_name'], 0, 2);
  1590. $data['工序名称'] = empty($params['gy_name']) ? '' : $params['gy_name'];
  1591. $data['当班产量'] = $params['production_now'];
  1592. $data['累计产量'] = $params['production_all'];
  1593. $data['班组编号'] = $params['sczl_bzdh'];
  1594. $data['班组ID'] = $params['team_id'];
  1595. // 获取当前时间
  1596. $current_time = time();
  1597. // 设置时间范围
  1598. $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
  1599. $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
  1600. $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
  1601. $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
  1602. // 判断当前时间属于哪个时间范围
  1603. if ($current_time >= $start_time1 && $current_time <= $end_time1) {
  1604. $data['开工时间'] = date('Y-m-d') . ' 08:30:00';
  1605. } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
  1606. $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
  1607. } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
  1608. $data['开工时间'] = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
  1609. }
  1610. if (!empty($params['order']) && !empty($params['yjno'])){
  1611. $option['Gy0_gdbh'] = $params['order'];
  1612. $option['Gy0_yjno'] = $params['yjno'];
  1613. $option['Gy0_gxh'] = $data['工序号'];
  1614. $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
  1615. }else{
  1616. $data['任务ID'] = '';
  1617. }
  1618. $data['UniqId'] = $id;
  1619. $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
  1620. $res = Db::query($sql);
  1621. if ($res === false) {
  1622. $this->error('设置失败');
  1623. } else {
  1624. $this->success('设置成功');
  1625. }
  1626. }
  1627. /**
  1628. * 首页数据
  1629. * @return void
  1630. * @throws \think\Exception
  1631. * @throws \think\db\exception\DataNotFoundException
  1632. * @throws \think\db\exception\ModelNotFoundException
  1633. * @throws \think\exception\DbException
  1634. */
  1635. public function index()
  1636. {
  1637. if ($this->request->isGet() === false){
  1638. $this->error('请求错误');
  1639. }
  1640. $nowTime = date('Y-m-d H:i:s',time());
  1641. $oldTime = (date('Y')-1).'-'.date('m-d H:i:s');
  1642. $where =[
  1643. 'Mod_rq' => ['between',[$oldTime,$nowTime]],
  1644. '行号' => '1'
  1645. ];
  1646. $data = [];
  1647. //按状态查询工单信息
  1648. $orderList = \db('工单_基本资料')
  1649. ->where($where)
  1650. ->field('count(Gd_gdbh) as 数量,rtrim(gd_statu) as 状态')
  1651. ->group('gd_statu')
  1652. ->select();
  1653. foreach ($orderList as $value){
  1654. if ($value['状态'] === '1-已完工'){
  1655. $data['workOrderData']['已完工'] = $value['数量'];
  1656. }
  1657. if ($value['状态'] === '3-计划中'){
  1658. $data['workOrderData']['计划中'] = $value['数量'];
  1659. }
  1660. }
  1661. $data['workOrderData']['排程中'] = db('工单_基本资料')->alias('a')
  1662. ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
  1663. ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
  1664. ->where([
  1665. 'a.gd_statu' => '2-生产中',
  1666. 'a.行号' => '1',
  1667. 'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
  1668. 'b.PD_WG' => '1900-01-01 00:00:00',
  1669. 'b.Gy0_sj1' => '1900-01-01 00:00:00',
  1670. 'c.状态' => '',
  1671. ])
  1672. ->group('a.Gd_gdbh')
  1673. ->count();
  1674. $data['workOrderData']['制程中'] = db('工单_基本资料')->alias('a')
  1675. ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
  1676. ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
  1677. ->where([
  1678. 'a.gd_statu' => '2-生产中',
  1679. 'a.行号' => '1',
  1680. 'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
  1681. 'b.PD_WG' => '1900-01-01 00:00:00',
  1682. 'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
  1683. 'c.状态' => '',
  1684. ])
  1685. ->group('a.Gd_gdbh')
  1686. ->count();
  1687. //按月份查询工单信息
  1688. $data['monthData'] = \db('工单_基本资料')
  1689. ->where('Mod_rq', 'between', [$oldTime, $nowTime])
  1690. ->field('DATE_FORMAT(Mod_rq, "%Y-%m") as month, COUNT(*) as count')
  1691. ->group('month')
  1692. ->order('month')
  1693. ->select();
  1694. //查询最近十条客诉信息
  1695. $data['customer'] = \db('db_客诉记录')
  1696. ->field('rtrim(客诉描述) as 客诉描述,DATE_FORMAT(客诉日期, "%Y-%m-%d") as 日期,rtrim(UniqID) as UniqId')
  1697. ->limit(10)
  1698. ->order('Sys_rq desc')
  1699. ->select();
  1700. $this->success('成功',$data);
  1701. }
  1702. /**
  1703. * 员工信息获取
  1704. * @return void
  1705. * @throws \think\db\exception\DataNotFoundException
  1706. * @throws \think\db\exception\ModelNotFoundException
  1707. * @throws \think\exception\DbException
  1708. */
  1709. public function EmployeeData()
  1710. {
  1711. if ($this->request->isGet() === false){
  1712. $this->error('请求错误');
  1713. }
  1714. $param = $this->request->param();
  1715. if (isset($param['code']) === false){
  1716. $this->error('参数错误');
  1717. }
  1718. $res = \db('人事_基本资料')
  1719. ->where('员工编号','like',$param['code'].'%')
  1720. ->field('rtrim(员工编号) as 员工编号,rtrim(员工姓名) as 员工姓名')
  1721. ->select();
  1722. if (empty($res)){
  1723. $this->success('未找到该员工');
  1724. }
  1725. $this->success('成功',$res);
  1726. }
  1727. /**
  1728. * 换型清场添加
  1729. * @return void
  1730. * @throws \think\db\exception\BindParamException
  1731. * @throws \think\exception\PDOException
  1732. */
  1733. public function remodelDataAdd()
  1734. {
  1735. if (Request::instance()->isPost() === false){
  1736. $this->error('请求错误');
  1737. }
  1738. $param = Request::instance()->post();
  1739. if (empty($param)){
  1740. $this->error('参数错误');
  1741. }
  1742. $lastId = \db('制程_换型清场')->order('UniqId desc')->value('UniqId');
  1743. $param['sys_id'] = '['.$param['机台编号'].']';
  1744. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  1745. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  1746. $param['UniqId'] = $lastId + 1;
  1747. $sql = \db('制程_换型清场')->fetchSql(true)->insert($param);
  1748. $res = \db()->query($sql);
  1749. if ($res !== false){
  1750. $this->success('成功');
  1751. }else{
  1752. $this->error('失败');
  1753. }
  1754. }
  1755. /**
  1756. * 换型清场记录修改
  1757. * @return void
  1758. * @throws \think\Exception
  1759. * @throws \think\db\exception\BindParamException
  1760. * @throws \think\exception\PDOException
  1761. */
  1762. public function remodelDataEdit()
  1763. {
  1764. if (Request::instance()->isPost() === false){
  1765. $this->error('请求错误');
  1766. }
  1767. $param = Request::instance()->post();
  1768. if (empty($param)){
  1769. $this->error('参数错误');
  1770. }
  1771. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  1772. $sql = \db('制程_换型清场')->fetchSql(true)->update($param);
  1773. $res = \db()->query($sql);
  1774. if ($res !== false){
  1775. $this->success('成功');
  1776. }else{
  1777. $this->error('失败');
  1778. }
  1779. }
  1780. /**
  1781. * 换型清场记录删除
  1782. * @return void
  1783. * @throws \think\Exception
  1784. * @throws \think\exception\PDOException
  1785. */
  1786. public function remodelDataDel()
  1787. {
  1788. if ($this->request->isGet() === false){
  1789. $this->error('请求错误');
  1790. }
  1791. $param = $this->request->param();
  1792. if (empty($param)){
  1793. $this->error('参数错误');
  1794. }
  1795. $res = \db('制程_换型清场')->where('UniqId',$param['UniqId'])->delete();
  1796. if ($res !== false){
  1797. $this->success('删除成功');
  1798. }else{
  1799. $this->error('删除失败');
  1800. }
  1801. }
  1802. /**
  1803. * 印版领用记录添加
  1804. * @return void
  1805. * @throws \think\db\exception\BindParamException
  1806. * @throws \think\exception\PDOException
  1807. */
  1808. public function PrintDetailAdd()
  1809. {
  1810. if (Request::instance()->isPost() === false){
  1811. $this->error('请求错误');
  1812. }
  1813. $param = Request::instance()->post();
  1814. if (empty($param)){
  1815. $this->error('参数错误');
  1816. }
  1817. $lastId = \db('工单_印版领用记录')->order('UniqID desc')->value('UniqID');
  1818. foreach ($param as $key=>$value){
  1819. $param[$key]['Yb_领用日期'] = date('Y-m-d H:i:s',time());
  1820. $param[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1821. $param[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1822. $param[$key]['UniqID'] = $lastId + $key +1;
  1823. }
  1824. $sql = \db('工单_印版领用记录')->fetchSql(true)->insertAll($param);
  1825. $res = \db()->query($sql);
  1826. if ($res !== false){
  1827. $this->success('添加成功');
  1828. }else{
  1829. $this->error('添加失败');
  1830. }
  1831. }
  1832. /**
  1833. * 印版领用记录退还
  1834. * @return void
  1835. * @throws \think\Exception
  1836. * @throws \think\db\exception\BindParamException
  1837. * @throws \think\exception\PDOException
  1838. */
  1839. public function PrintDetailEdit()
  1840. {
  1841. if ($this->request->isGet() === false){
  1842. $this->error('请求错误');
  1843. }
  1844. $param = $this->request->param();
  1845. if (empty($param)){
  1846. $this->error('参数错误');
  1847. }
  1848. $idList = explode(',',$param['id']);
  1849. $i = 0;
  1850. foreach ($idList as $key=>$value){
  1851. $data['Yb_退还日期'] = date('Y-m-d H:i:s',time());
  1852. $data['Mod_rq'] = date('Y-m-d H:i:s',time());
  1853. $sql = \db('工单_印版领用记录')->where('UniqID',$value)->fetchSql(true)->update($data);
  1854. $res = \db()->query($sql);
  1855. if ($res === false){
  1856. $i++;
  1857. }
  1858. }
  1859. if ($i !== 0){
  1860. $this->error('退还失败');
  1861. }else{
  1862. $this->success('退还成功');
  1863. }
  1864. }
  1865. /**
  1866. * 当班产量明细修改
  1867. * @return void
  1868. * @throws \think\Exception
  1869. * @throws \think\db\exception\BindParamException
  1870. * @throws \think\exception\PDOException
  1871. */
  1872. public function chanliangEdit()
  1873. {
  1874. if (Request::instance()->isPost() === false){
  1875. $this->error('请求错误');
  1876. }
  1877. $param = Request::instance()->post();
  1878. if (empty($param['UniqId'])){
  1879. $this->error('参数错误');
  1880. }
  1881. $param['sczl_打样工时'] = $param['sczl_打样总工时'];
  1882. $param['sczl_装版工时'] = $param['sczl_装版总工时'];
  1883. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  1884. $data = $param;
  1885. unset($data['UniqId']);
  1886. unset($data['sczl_rq']);
  1887. $sql = \db('设备_产量计酬')
  1888. ->where('UniqId',$param['UniqId'])
  1889. ->fetchSql(true)
  1890. ->update($data);
  1891. $res = \db()->query($sql);
  1892. if ($res !== false){
  1893. $this->success('修改成功');
  1894. }else {
  1895. $this->error('修改失败');
  1896. }
  1897. }
  1898. /**
  1899. * 获取当日上报产量详细数据
  1900. * @return void
  1901. * @throws \think\db\exception\DataNotFoundException
  1902. * @throws \think\db\exception\ModelNotFoundException
  1903. * @throws \think\exception\DbException
  1904. */
  1905. public function MachineChanliangDetail()
  1906. {
  1907. if ($this->request->isGet() === false){
  1908. $this->error('请求错误');
  1909. }
  1910. $param = $this->request->param();
  1911. if (empty($param['UniqId'])){
  1912. $this->error('参数错误');
  1913. }
  1914. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_dedh) as dedh,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxh) as gxh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as num,rtrim(sczl_sj1) as sj1,rtrim(sczl_ls) as 联数,
  1915. rtrim(sczl_sj2) as sj2,rtrim(sczl_cl) as 产量,rtrim(sczl_bzdh) as bzdh,rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,
  1916. rtrim(sczl_装版工时) as 装版工时,rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常总工时,rtrim(sczl_设备运行工时) as 通电工时,
  1917. rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度数,
  1918. rtrim(sczl_异常工时1) as 异常补时,rtrim(sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,rtrim(sczl_装版工时) as 装版补产工时,rtrim(sczl_打样工时) as 打样补产工时,
  1919. sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
  1920. sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId';
  1921. $list = \db('设备_产量计酬')->where('UniqId',$param['UniqId'])->field($field)->find();
  1922. if (empty($list)){
  1923. $this->success('未找到产量详情信息');
  1924. }
  1925. $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$list['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
  1926. $list['印件名称'] = $productName['cpmc'];
  1927. if (!empty($productName['成品名称'])){
  1928. $list['cpmc'] = $productName['成品名称'];
  1929. }elseif (empty($productName['成品名称']) && !empty($productName['cpmc'])){
  1930. $list['cpmc'] = $productName['cpmc'];
  1931. }else{
  1932. $list['cpmc'] = '';
  1933. }
  1934. for ($i=1;$i<11;$i++){
  1935. if (isset($list['sczl_bh'.$i])){
  1936. $name = \db('人事_基本资料')->where('员工编号',$list['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
  1937. if (isset($name['name'])){
  1938. $list['组员'.$i] = [
  1939. '编号' => $list['sczl_bh'.$i],
  1940. '姓名' => $name['name'],
  1941. '比例' => (float)$list['sczl_rate'.$i]
  1942. ];
  1943. }
  1944. }
  1945. if (empty($list['sczl_bh'.$i])){
  1946. $list['组员'.$i] = [
  1947. '编号' => '',
  1948. '姓名' => '',
  1949. '比例' => ''
  1950. ];
  1951. }
  1952. unset($list['sczl_bh'.$i],$list['sczl_rate'.$i]);
  1953. }
  1954. $list['拉料'] = [
  1955. '编号' => $list['sczl_bh98'],
  1956. '姓名' => \db('人事_基本资料')->where('员工编号',$list['sczl_bh98'])->value('rtrim(员工姓名)')
  1957. ];
  1958. unset($list['sczl_bh98']);
  1959. $this->success('成功',$list);
  1960. }
  1961. /**
  1962. * 当日上报产量详细数据修改
  1963. * @return void
  1964. * @throws \think\Exception
  1965. * @throws \think\db\exception\BindParamException
  1966. * @throws \think\exception\PDOException
  1967. */
  1968. public function MachineChanliangDetailEdit()
  1969. {
  1970. if (Request::instance()->isPost() === false){
  1971. $this->error('请求错误');
  1972. }
  1973. $param = Request::instance()->post();
  1974. if (empty($param['UniqId'])){
  1975. $this->error('参数错误');
  1976. }
  1977. $param['sczl_type'] = $param['sczl_gxmc'];
  1978. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  1979. $UnidId = $param['UniqId'];
  1980. unset($param['UniqId']);
  1981. unset($param['sczl_rq']);
  1982. $sql = \db('设备_产量计酬')->where('UniqId',$UnidId)->fetchSql(true)->update($param);
  1983. $res = \db()->query($sql);
  1984. if ($res !== false){
  1985. $this->success('修改成功');
  1986. }else{
  1987. $this->error('修改失败');
  1988. }
  1989. }
  1990. /**
  1991. * 产量上报数据删除
  1992. * @return void
  1993. * @throws \think\Exception
  1994. * @throws \think\exception\PDOException
  1995. */
  1996. public function ChanliangDel()
  1997. {
  1998. if ($this->request->isGet() === false){
  1999. $this->error('请求错误');
  2000. }
  2001. $param = $this->request->param();
  2002. if (empty($param['UniqId'])){
  2003. $this->error('参数错误');
  2004. }
  2005. $idList = explode(',',$param['UniqId']);
  2006. foreach ($idList as $key=>$value){
  2007. $res = \db('设备_产量计酬')
  2008. ->where('UniqId',$value)
  2009. ->delete();
  2010. }
  2011. if ($res !== false){
  2012. $this->success('删除成功');
  2013. }else{
  2014. $this->error('删除失败');
  2015. }
  2016. }
  2017. /**
  2018. * 日产量上报添加
  2019. * @return void
  2020. * @throws \think\db\exception\BindParamException
  2021. * @throws \think\exception\PDOException
  2022. */
  2023. public function ChanliangAdd()
  2024. {
  2025. if (Request::instance()->isPost() === false){
  2026. $this->error('请求错误');
  2027. }
  2028. $params = Request::instance()->post();
  2029. if (empty($params['sczl_gdbh'])){
  2030. $this->error('参数错误');
  2031. }
  2032. $lastId = \db('设备_产量计酬')->order('UniqId desc')->value('rtrim(UniqId)');
  2033. $params['sczl_type'] = $params['sczl_gxmc'];
  2034. $params['sczl_wgsj'] = '1900-01-01 00:00:00';
  2035. $params['sczl_废品率系数'] = 0;
  2036. $params['sys_rq'] = date('Y-m-d H:i:s',time());
  2037. $params['mod_rq'] = date('Y-m-d H:i:s',time());
  2038. $params['UniqId'] = $lastId + 1;
  2039. $sql = \db('设备_产量计酬')->fetchSql(true)->insert($params);
  2040. $res = \db()->query($sql);
  2041. if ($res !== false){
  2042. $this->success('成功');
  2043. }else{
  2044. $this->error('失败');
  2045. }
  2046. }
  2047. /**
  2048. * 日产量上报添加获取工单信息
  2049. * @return void
  2050. * @throws \think\db\exception\DataNotFoundException
  2051. * @throws \think\db\exception\ModelNotFoundException
  2052. * @throws \think\exception\DbException
  2053. */
  2054. public function ChanliangWorkorder()
  2055. {
  2056. if ($this->request->isGet() === false)
  2057. {
  2058. $this->error('请求错误');
  2059. }
  2060. $param = $this->request->param();
  2061. if (empty($param)){
  2062. $this->error('参数错误');
  2063. }
  2064. // $where = [
  2065. // 'b.Gy0_sbbh' => ['like','%'.$param['machine'].'%'],
  2066. // ];
  2067. // if (!empty($param['machine'])){
  2068. // $where = [
  2069. // 'b.Gy0_sbbh' => ['like','%'.$param['machine'].'%'],
  2070. // ];
  2071. // }
  2072. if (!empty($param['search'])){
  2073. $where['b.Gy0_gdbh'] = ['like','%'.$param['search'].'%'];
  2074. }
  2075. $list = \db('工单_基本资料')
  2076. ->alias('a')
  2077. ->field('rtrim(Gd_gdbh) as gdbh,rtrim(成品名称) as cpmc')
  2078. ->join('工单_工艺资料 b','a.Gd_gdbh = b.Gy0_gdbh')
  2079. ->where($where)
  2080. ->select();
  2081. if (empty($list)){
  2082. $this->success('未找到相关工单');
  2083. }else{
  2084. $this->success('成功',$list);
  2085. }
  2086. }
  2087. /**
  2088. * 日产量上报工单印件资料
  2089. * @return void
  2090. * @throws \think\db\exception\DataNotFoundException
  2091. * @throws \think\db\exception\ModelNotFoundException
  2092. * @throws \think\exception\DbException
  2093. */
  2094. public function ChanliangPrintDetail()
  2095. {
  2096. if ($this->request->isGet() === false){
  2097. $this->error('请求错误');
  2098. }
  2099. $param = $this->request->param();
  2100. if (empty($param['gdbh'])){
  2101. $this->error('参数错误');
  2102. }
  2103. $where = [
  2104. 'Yj_Gdbh' => $param['gdbh']
  2105. ];
  2106. $list = \db('工单_印件资料')
  2107. ->where($where)
  2108. ->field('rtrim(yj_Yjno) as yjno,rtrim(yj_yjmc) as yjmc,rtrim(yj_ls) as ls')
  2109. ->select();
  2110. if (empty($list)){
  2111. $this->success('未找到印件资料');
  2112. }else{
  2113. $this->success('成功',$list);
  2114. }
  2115. }
  2116. /**
  2117. * 日产量上报工艺资料获取
  2118. * @return void
  2119. * @throws \think\db\exception\DataNotFoundException
  2120. * @throws \think\db\exception\ModelNotFoundException
  2121. * @throws \think\exception\DbException
  2122. */
  2123. public function ChanliangProcessDetail()
  2124. {
  2125. if ($this->request->isGet() === false){
  2126. $this->error('请求错误');
  2127. }
  2128. $param = $this->request->param();
  2129. if (empty($param['gdbh'])){
  2130. $this->error('参数错误');
  2131. }
  2132. // $sys_bh = \db('dic_lzde')->where('适用机型',$param['machine'])->value('sys_bh');
  2133. $list = \db('工单_工艺资料')
  2134. ->where('Gy0_gdbh',$param['gdbh'])
  2135. ->where('Gy0_yjno',$param['yjno'])
  2136. // ->where('Gy0_sbbh','like','%'.$param['machine'].'%')
  2137. ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
  2138. ->select();
  2139. if (empty($list)){
  2140. $this->success('未获取工序');
  2141. }
  2142. // $time = \db('设备_产量计酬')
  2143. // ->where('sczl_gdbh',$param['gdbh'])
  2144. // ->where('sczl_yjno',$param['yjno'])
  2145. // ->where('sczl_jtbh','like','%'.$param['machine'].'%')
  2146. // ->order('UniqId desc')
  2147. // ->value('sczl_sj2');
  2148. // $newTime = date('Y-m-d H:i:s');
  2149. // if ($newTime > date('Y-m-d 08:30:00') && $newTime < date('Y-m-d 20:30:00') && $time < date('Y-m-d 08:30:00')){
  2150. // $time = date('Y-m-d 08:30:00');
  2151. // }elseif ($newTime > date('Y-m-d 20:30:00') && $time < date('Y-m-d 20:30:00')){
  2152. // $time = date('Y-m-d 20:30:00');
  2153. // }
  2154. foreach ($list as $key=>$value){
  2155. if ((int)$value['gxh'] < 10){
  2156. $value['gxh'] = '0'.$value['gxh'];
  2157. }
  2158. if (empty($value['add_gxmc'])){
  2159. $list[$key]['name'] = $value['gxh'].'-'.$value['gxmc'];
  2160. }else{
  2161. $list[$key]['name'] = $value['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  2162. }
  2163. unset( $list[$key]['add_gxmc']);
  2164. // $list[$key]['time'] = $time;
  2165. }
  2166. // $list['sys_bh'] = $sys_bh;
  2167. $this->success('成功',$list);
  2168. }
  2169. /**
  2170. * 工价系数修改
  2171. * @return void
  2172. * @throws \think\Exception
  2173. * @throws \think\db\exception\BindParamException
  2174. * @throws \think\exception\PDOException
  2175. */
  2176. public function CoefficientEdit()
  2177. {
  2178. if (Request::instance()->isPost() === false){
  2179. $this->error('请求错误');
  2180. }
  2181. $params = Request::instance()->post();
  2182. if (empty($params['id'])){
  2183. $this->error('参数错误');
  2184. }
  2185. $idList = explode(',',$params['id']);
  2186. $i=0;
  2187. foreach ($idList as $key=>$value){
  2188. $sql = \db('设备_产量计酬')
  2189. ->where('UniqId',$value)
  2190. ->fetchSql(true)
  2191. ->update(['sczl_工价系数'=>$params['工价系数']]);
  2192. $res = \db()->query($sql);
  2193. if ($res === false){
  2194. $i++;
  2195. }
  2196. }
  2197. if ($i!==0){
  2198. $this->error('修改失败');
  2199. }else{
  2200. $this->success('修改成功');
  2201. }
  2202. }
  2203. /**
  2204. * 色度系数修改
  2205. * @return void
  2206. * @throws \think\Exception
  2207. * @throws \think\db\exception\BindParamException
  2208. * @throws \think\exception\PDOException
  2209. */
  2210. public function ChromaDataEdit()
  2211. {
  2212. if (Request::instance()->isPost() === false){
  2213. $this->error('请求错误');
  2214. }
  2215. $params = Request::instance()->post();
  2216. if (empty($params['id'])){
  2217. $this->error('参数错误');
  2218. }
  2219. $idList = explode(',',$params['id']);
  2220. $i=0;
  2221. foreach ($idList as $key=>$value){
  2222. $sql = \db('设备_产量计酬')
  2223. ->where('UniqId',$value)
  2224. ->fetchSql(true)
  2225. ->update(['sczl_ms'=>$params['ms']]);
  2226. $res = \db()->query($sql);
  2227. if ($res === false){
  2228. $i++;
  2229. }
  2230. }
  2231. if ($i!==0){
  2232. $this->error('修改失败');
  2233. }else{
  2234. $this->success('修改成功');
  2235. }
  2236. }
  2237. /**
  2238. * 凹印版距修改
  2239. * @return void
  2240. * @throws \think\Exception
  2241. * @throws \think\db\exception\BindParamException
  2242. * @throws \think\exception\PDOException
  2243. */
  2244. public function PrintingModeDataEdit()
  2245. {
  2246. if (Request::instance()->isPost() === false){
  2247. $this->error('请求错误');
  2248. }
  2249. $params = Request::instance()->post();
  2250. if (empty($params['id'])){
  2251. $this->error('参数错误');
  2252. }
  2253. $idList = explode(',',$params['id']);
  2254. //获取工单印件工序
  2255. $orderList = \db('设备_产量计酬')
  2256. ->where('UniqId',$idList[0])
  2257. ->field('rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as 印件号,rtrim(sczl_gxh) as 工序号')
  2258. ->find();
  2259. //修改工艺资料
  2260. $sql = \db('工单_工艺资料')
  2261. ->where([
  2262. 'Gy0_gdbh'=>$orderList['工单编号'],
  2263. 'Gy0_yjno'=>$orderList['印件号'],
  2264. 'Gy0_gxh'=>$orderList['工序号']
  2265. ])
  2266. ->fetchSql(true)
  2267. ->update(['版距'=>$params['plate'],'印刷方式'=>$params['mode']]);
  2268. $res = \db()->query($sql);
  2269. if ($res === false){
  2270. $this->error('修改失败');
  2271. }else{
  2272. $this->success('修改成功');
  2273. }
  2274. }
  2275. /**
  2276. * 废品率系数批量修改
  2277. * @return void
  2278. * @throws \think\Exception
  2279. * @throws \think\db\exception\BindParamException
  2280. * @throws \think\exception\PDOException
  2281. */
  2282. public function RejectionEdit()
  2283. {
  2284. if (Request::instance()->isPost() === false){
  2285. $this->error('请求错误');
  2286. }
  2287. $params = Request::instance()->post();
  2288. if (empty($params['id'])){
  2289. $this->error('参数错误');
  2290. }
  2291. $idList = explode(',',$params['id']);
  2292. $i=0;
  2293. foreach ($idList as $key=>$value){
  2294. $sql = \db('设备_产量计酬')
  2295. ->where('UniqId',$value)
  2296. ->fetchSql(true)
  2297. ->update(['sczl_废品率系数'=>$params['rejection']]);
  2298. $res = \db()->query($sql);
  2299. if ($res === false){
  2300. $i++;
  2301. }
  2302. }
  2303. if ($i!==0){
  2304. $this->error('修改失败');
  2305. }else{
  2306. $this->success('修改成功');
  2307. }
  2308. }
  2309. /**
  2310. * 日产量上报班组信息批量修改
  2311. * @return void
  2312. * @throws \think\Exception
  2313. * @throws \think\db\exception\BindParamException
  2314. * @throws \think\db\exception\DataNotFoundException
  2315. * @throws \think\db\exception\ModelNotFoundException
  2316. * @throws \think\exception\DbException
  2317. * @throws \think\exception\PDOException
  2318. */
  2319. public function YieldTeamEdit()
  2320. {
  2321. if ($this->request->isGet() === false){
  2322. $this->error('请求错误');
  2323. }
  2324. $param = $this->request->param();
  2325. if (empty($param['Uniqid']) || empty($param['teamID'])){
  2326. $this->error('参数错误');
  2327. }
  2328. $idList = explode(',',$param['Uniqid']);
  2329. $teamList = \db('设备_班组资料')->where('UniqId',$param['teamID'])->find();
  2330. $data = [];
  2331. for ($i=1;$i<11;$i++){
  2332. $data['sczl_bh'.$i] = $teamList['sczl_bh'.$i];
  2333. $data['sczl_rate'.$i] = $teamList['sczl_rate'.$i];
  2334. $data['sczl_bzdh'] = $teamList['sczl_bzdh'];
  2335. }
  2336. $j = 0;
  2337. foreach ($idList as $key => $value){
  2338. $sql = \db('设备_产量计酬')
  2339. ->where('UniqId',$value)
  2340. ->fetchSql(true)
  2341. ->update($data);
  2342. $res = \db()->query($sql);
  2343. if ($res === false){
  2344. $j++;
  2345. }
  2346. }
  2347. if ($j === 0){
  2348. $this->success('修改成功');
  2349. }else{
  2350. $this->error('修改失败');
  2351. }
  2352. }
  2353. /**
  2354. * 检品机日产量上报数据修改
  2355. * @return void
  2356. * @throws \think\Exception
  2357. * @throws \think\db\exception\BindParamException
  2358. * @throws \think\exception\PDOException
  2359. */
  2360. public function JpChanliangEdit()
  2361. {
  2362. if (Request::instance()->isPost() == false){
  2363. $this->error('非法请求');
  2364. }
  2365. $params = Request::instance()->post();
  2366. if (empty($params['UniqId'])){
  2367. $this->error('参数错误');
  2368. }
  2369. $params['mod_rq'] = date('Y-m-d H:i:s');
  2370. $data = $params;
  2371. $data['sczl_装版总工时'] = $params['sczl_装版工时'];
  2372. unset($data['UniqId']);
  2373. unset($data['sczl_rq']);
  2374. $sql = \db('设备_产量计酬')->where('UniqId',$params['UniqId'])->fetchSql(true)->update($data);
  2375. $res = \db()->query($sql);
  2376. if ($res === false){
  2377. $this->error('修改失败');
  2378. }else{
  2379. $this->success('成功');
  2380. }
  2381. }
  2382. /**
  2383. * 检品机日产量上报数据列表
  2384. * @return void
  2385. * @throws \think\db\exception\DataNotFoundException
  2386. * @throws \think\db\exception\ModelNotFoundException
  2387. * @throws \think\exception\DbException
  2388. */
  2389. public function JPmachineDetail()
  2390. {
  2391. if ($this->request->isGet() === false){
  2392. $this->error('请求错误');
  2393. }
  2394. $machine = input('machine');
  2395. $date = input('date');
  2396. $where = [
  2397. 'sczl_jtbh' => $machine,
  2398. 'sczl_rq' => date('Y-m-d H:i:s',strtotime($date.' 00:00:00')),
  2399. ];
  2400. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_dedh) as dedh,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxh) as gxh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_type) as 检验类型,rtrim(sczl_num) as num,rtrim(sczl_cl) as 计件箱数,
  2401. rtrim(sczl_Pgcl) as 每箱数量,rtrim(sczl_bzdh) as bzdh,IF(sczl_废品率系数 = 0, "",sczl_废品率系数) as 废品率系数,IF(sczl_装版工时 = 0, "",sczl_装版工时) as 换膜补时, IF(sczl_保养工时 = 0, "",sczl_保养工时) as 保养工时,IF(sczl_异常停机工时 = 0, "",sczl_异常停机工时) as 异常总工时,IF(sczl_设备运行工时 = 0, "",sczl_设备运行工时) as 通电工时,
  2402. rtrim(sys_id) as 用户,rtrim(mod_rq) as 更新时间,IF(sczl_异常工时1 = 0, "",sczl_异常工时1) as 异常补时,IF(sczl_异常类型1 = 0, "",sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
  2403. sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
  2404. sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId,rtrim(sczl_工价系数) as 难度系数,rtrim(sczl_dedh) as 定额代号,sczl_rq,sczl_装版总工时 as 换膜总工时';
  2405. //机台信息
  2406. $machineDetail = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
  2407. //组员信息
  2408. $list = \db('设备_产量计酬')->where($where)->field($field)->select();
  2409. $totalA = \db('设备_产量计酬')
  2410. ->where($where)
  2411. ->where('sczl_bzdh','like','A%')
  2412. ->field('sczl_type as 检验类型,SUM(sczl_cl) as 箱数')
  2413. ->group('检验类型')
  2414. ->select();
  2415. $totalB = \db('设备_产量计酬')
  2416. ->where($where)
  2417. ->where('sczl_bzdh','like','B%')
  2418. ->field('sczl_type as 检验类型,SUM(sczl_cl) as 箱数')
  2419. ->group('检验类型')
  2420. ->select();
  2421. if (empty($list)){
  2422. $this->success('',[]);
  2423. }
  2424. foreach ($list as $key=>$value){
  2425. //产品名称
  2426. $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$value['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
  2427. if (!empty($productName)){
  2428. if (!empty($productName['成品名称'])){
  2429. $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
  2430. $list[$key]['cpmc'] = $productName['成品名称'];
  2431. }else{
  2432. $list[$key]['产品名称'] = $value['工单编号'];
  2433. $list[$key]['cpmc'] = '';
  2434. }
  2435. }else{
  2436. $list[$key]['产品名称'] = $value['工单编号'];
  2437. $list[$key]['cpmc'] = '';
  2438. }
  2439. if (empty($value['定额代号'])){
  2440. $list[$key]['千件工价'] = '';
  2441. $list[$key]['日定额'] = '';
  2442. $list[$key]['补产标准'] = '';
  2443. }else{
  2444. $row = \db('dic_lzde')->where('sys_bh',$value['定额代号'])->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额,rtrim(补产标准) as 补产标准')->find();
  2445. $list[$key]['千件工价'] = $row['千件工价'];
  2446. $list[$key]['日定额'] = $row['日定额'];
  2447. $list[$key]['补产标准'] = $row['补产标准'];
  2448. }
  2449. $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxmc'];
  2450. for ($i=1;$i<11;$i++){
  2451. if (isset($value['sczl_bh'.$i])){
  2452. $name = \db('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('员工姓名 as name')->find();
  2453. if (isset($name['name'])){
  2454. $list[$key]['组员'.$i] = $value['sczl_bh'.$i].$name['name'].'('.((float)$value['sczl_rate'.$i]*100).'%'.')';
  2455. $list[$key]['sczl_name'.$i] = $name['name'];
  2456. }else{
  2457. $list[$key]['sczl_name'.$i] = '';
  2458. }
  2459. }
  2460. }
  2461. }
  2462. $list['totalA'] = $totalA;
  2463. $list['totalB'] = $totalB;
  2464. $this->success('成功',$list);
  2465. }
  2466. //设备运行跟踪月度数据导出
  2467. // public function MouthDataOutput()
  2468. // {
  2469. // if ($this->request->isGet() === false){
  2470. // $this->error('参数错误');
  2471. // }
  2472. // $param = $this->request->param();
  2473. // if (empty($param)){
  2474. // $this->error('参数错误');
  2475. // }
  2476. // $filed = "工单编号,产品名称,流程单号,印件号,工序号,机台编号,日期,工序产量,工序名称,机长工号,机长名称,组员工号1,组员姓名1,";
  2477. // }
  2478. }