|
|
@@ -158,8 +158,15 @@ class WorkOrderVerification extends Api
|
|
|
if (!isset($params['UniqId']) || empty($params['UniqId'])){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $field = '';
|
|
|
- $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->find();
|
|
|
+ $field = 'qczl_gdbh,qczl_Pygd,qczl_yjno,qczl_gxh,qczl_gxmc,qczl_type,qczl_rq,qczl_num,qczl_fp,
|
|
|
+ qczl_NumDesc,qczl_NumDesc1,qczl_NumDesc2,qczl_NumDesc3,qczl_NumDesc4,qczl_NumDesc5,qczl_NumDesc6,qczl_NumDesc7,qczl_NumDesc8,
|
|
|
+ fp_lb1,fp_lb2,fp_lb3,fp_lb4,fp_lb5,fp_lb6,fp_lb7,fp_lb8,fp_lb9,fp_lb10,fp_lb11,fp_lb12,fp_lb13,trim(fp_lb14) as fp_lb14,trim(fp_lb15) as fp_lb15,trim(fp_lb16) as fp_lb16,trim(fp_lb17) as fp_lb17,
|
|
|
+ fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,fp_sl14,fp_sl15,fp_sl16,fp_sl17
|
|
|
+ fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
|
|
|
+ fp_bz1,fp_bz2,fp_bz3,fp_bz4,fp_bz5,fp_bz6,fp_bz7,fp_bz8,fp_bz9,fp_bz10,fp_bz11,fp_bz12,fp_bz13,
|
|
|
+ fp_gxmc1,fp_gxmc2,fp_gxmc3,fp_gxmc4,fp_gxmc5,fp_gxmc6,fp_gxmc7,fp_gxmc8,fp_gxmc9,fp_gxmc10,fp_gxmc11,fp_gxmc12,fp_gxmc13,
|
|
|
+ sys_id,rtrim(sys_rq) as sys_rq,UniqId';
|
|
|
+ $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->field($field)->find();
|
|
|
$list['fp_name1'] = '';
|
|
|
if (!empty($list['fp_bh1'])){
|
|
|
$list['fp_name1'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh1'])->value('rtrim(员工姓名)');
|
|
|
@@ -476,7 +483,7 @@ class WorkOrderVerification extends Api
|
|
|
$this->success('请求成功',$gdInfo);
|
|
|
}
|
|
|
/**
|
|
|
- * 工单工期异常调整
|
|
|
+ * 获取工单工序状态
|
|
|
* @ApiMethod GET
|
|
|
* @params string order
|
|
|
* 计划产量计算方式:上个工序计划产量-(基础损耗+损耗率*上个工序计划产量)*损耗系数*计损色数)
|
|
|
@@ -497,16 +504,17 @@ class WorkOrderVerification extends Api
|
|
|
->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh and a.Gy0_gxh = b.sczl_gxh','left')
|
|
|
->where($where)
|
|
|
->field('a.Gy0_yjno,a.Gy0_gxh,rtrim(a.Gy0_gxmc) as Gy0_gxmc,a.Gy0_sbbh,a.Gy0_Rate0,a.Gy0_Rate1,a.损耗系数 as Gy0_Rate3,a.Gy0_Ms,a.Gy0_SITE,a.Gy0_计划接货数,a.PD_WG,
|
|
|
- sum(b.sczl_cl) as cl')
|
|
|
+ a.UniqId,sum(b.sczl_cl) as cl')
|
|
|
->group('a.Gy0_gxh')
|
|
|
->select();
|
|
|
$lastNum = $productNum;
|
|
|
$res = [];
|
|
|
foreach ($gyData as $key=> $process) {
|
|
|
+ $res[$key]['UniqId'] = $process['UniqId'];
|
|
|
$res[$key]['Gy0_yjno'] = $process['Gy0_yjno'] > 10 ? $process['Gy0_yjno'] : '0'.$process['Gy0_yjno'];
|
|
|
$res[$key]['Gy0_gxh'] = $process['Gy0_gxh'] > 10 ? $process['Gy0_gxh'] : '0'.$process['Gy0_gxh'];
|
|
|
$res[$key]['Gy0_gxmc'] = $process['Gy0_gxmc'];
|
|
|
- $res[$key]['Gy0_sbbh'] = $process['Gy0_sbbh'];
|
|
|
+ $res[$key]['Gy0_sbbh'] = rtrim($process['Gy0_sbbh']);
|
|
|
$res[$key]['PD_WG'] = $process['PD_WG'];
|
|
|
$res[$key]['finish'] = empty($process['cl']) ? 0: (int)$process['cl'];
|
|
|
// 计算工序计划产量
|
|
|
@@ -542,4 +550,214 @@ class WorkOrderVerification extends Api
|
|
|
}
|
|
|
$this->success('请求成功',$res);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 工单工序状态更正
|
|
|
+ * @ApiMethod POST
|
|
|
+ * @params string UniqId
|
|
|
+ * @params string date
|
|
|
+ */
|
|
|
+ public function editOrderFinishDate(){
|
|
|
+ if (Request::instance()->isPost() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->post();
|
|
|
+ if (!isset($params['UniqId']) || !isset($params['date'])){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ if (empty($params['UniqId'])){
|
|
|
+ $this->error('参数不能为空');
|
|
|
+ }
|
|
|
+ if (empty($params['date'])){
|
|
|
+ $params['date'] = '1900-01-01 00:00:00';
|
|
|
+ }
|
|
|
+ $res = Db::name('工单_工艺资料')->where('UniqId',$params['UniqId'])->setField('PD_WG',$params['date']);
|
|
|
+ if ($res != false){
|
|
|
+ $this->success('更新成功');
|
|
|
+ }else{
|
|
|
+ $this->error('更新失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 工单工序生产进程菜单栏
|
|
|
+ * @ApiMethod GET
|
|
|
+ * @params string order
|
|
|
+ */
|
|
|
+ public function getOrderProcessLeft(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->param();
|
|
|
+ if (!isset($params['order']) || empty($params['order'])){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $where['Gd_gdbh'] = $params['order'];
|
|
|
+ $where['行号'] = 1;
|
|
|
+ //工单基本资料
|
|
|
+ $info = Db::name('工单_基本资料')->where($where)->field('rtrim(成品代号) as code,rtrim(成品名称) as name')->find();
|
|
|
+ //工艺资料
|
|
|
+ $option['Gy0_gdbh'] = $params['order'];
|
|
|
+ $gyInfo = Db::name('工单_工艺资料')
|
|
|
+ ->where($option)
|
|
|
+ ->where(function ($query) {
|
|
|
+ $query->where('Gy0_sbbh', '<>', '')
|
|
|
+ ->whereOr('Gy0_gxmc', '核检')
|
|
|
+ ->whereOr('Gy0_gxmc', '成品防护');
|
|
|
+ })
|
|
|
+ ->field('Gy0_yjno,Gy0_gxh')
|
|
|
+ ->select();
|
|
|
+ foreach ($gyInfo as $key=>$value){
|
|
|
+ $gyInfo[$key]['Gy0_yjno'] = $value['Gy0_yjno'] > 10 ? $value['Gy0_yjno'] : '0'.$value['Gy0_yjno'];
|
|
|
+ $gyInfo[$key]['Gy0_gxh'] = $value['Gy0_gxh'] > 10 ? $value['Gy0_gxh'] : '0'.$value['Gy0_gxh'];
|
|
|
+ }
|
|
|
+ $res['Gd_info'] = $info;
|
|
|
+ $res['Gy_info'] = $gyInfo;
|
|
|
+ $this->success('请求成功',$res);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 工单工序生产进程右侧
|
|
|
+ * @ApiMethod GET
|
|
|
+ * @params string order
|
|
|
+ * @params string gxNo
|
|
|
+ */
|
|
|
+ public function getOrderProcessRight(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->param();
|
|
|
+ if (!isset($params['order']) || empty($params['order'])){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ if (!isset($params['gxNo']) || empty($params['gxNo'])){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $total = Db::name('设备_产量计酬')->where('sczl_gdbh',$params['order'])->order('sczl_num')->column('distinct(sczl_num)');
|
|
|
+ $where['sczl_gxh'] = (int)$params['gxNo'];
|
|
|
+ $where['sczl_gdbh'] = $params['order'];
|
|
|
+ $process = Db::name('设备_产量计酬')->where($where)->order('sczl_num')->column('distinct(sczl_num)');
|
|
|
+ $res['total_process'] = $total;
|
|
|
+ $res['process'] = $process;
|
|
|
+ $this->success('请求成功',$res);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 核检废品日统计
|
|
|
+ * @ApiMethod GET
|
|
|
+ * @params date start_date
|
|
|
+ * @params date end_date
|
|
|
+ */
|
|
|
+ public function getDaysWast()
|
|
|
+ {
|
|
|
+ if (Request::instance()->isGet() == false) {
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->param();
|
|
|
+ if (!isset($params['start_date']) || empty($params['start_date'])) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ if (!isset($params['end_date']) || empty($params['end_date'])) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $where['qczl_rq'] = array('between time', [$params['start_date'], $params['start_date']]);
|
|
|
+ $field = '
|
|
|
+ rtrim(fp_lb1) as fp_lb1,rtrim(fp_lb2) as fp_lb2,rtrim(fp_lb3) as fp_lb3,rtrim(fp_lb4) as fp_lb4,rtrim(fp_lb5) as fp_lb5,rtrim(fp_lb6) as fp_lb6,rtrim(fp_lb7) as fp_lb7,
|
|
|
+ rtrim(fp_lb8) as fp_lb8,rtrim(fp_lb9) as fp_lb9,rtrim(fp_lb10) as fp_lb10,rtrim(fp_lb11) as fp_lb11,rtrim(fp_lb12) as fp_lb12,rtrim(fp_lb13) as fp_lb13,
|
|
|
+ fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
|
|
|
+ fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
|
|
|
+ rtrim(fp_bz1) as fp_bz1, rtrim(fp_bz2) as fp_bz2, rtrim(fp_bz3) as fp_bz3, rtrim(fp_bz4) as fp_bz4, rtrim(fp_bz5) as fp_bz5, rtrim(fp_bz6) as fp_bz6, rtrim(fp_bz7) as fp_bz7,
|
|
|
+ rtrim(fp_bz8) as fp_bz8, rtrim(fp_bz9) as fp_bz9, rtrim(fp_bz10) as fp_bz10, rtrim(fp_bz11) as fp_bz11, rtrim(fp_bz12) as fp_bz12, rtrim(fp_bz13) as fp_bz13,
|
|
|
+ qczl_rq
|
|
|
+ ';
|
|
|
+
|
|
|
+ $data = Db::name('db_qczl')
|
|
|
+ ->where($where)
|
|
|
+ ->where(function ($query) {
|
|
|
+ for ($i = 1; $i <= 13; $i++) {
|
|
|
+ $query->whereOr("fp_lb$i", 'like', '%K%','AND',"fp_sl$i",'>',0);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->field($field)->select();
|
|
|
+ $list = [];
|
|
|
+ $j = 0;
|
|
|
+ foreach ($data as $entry) {
|
|
|
+ for ($i = 1; $i <= 13; $i++) {
|
|
|
+ $labelKey = "fp_lb" . $i;
|
|
|
+ $slKey = "fp_sl" . $i;
|
|
|
+ $bhKey = "fp_bh" . $i;
|
|
|
+ $bzKey = "fp_bz" . $i;
|
|
|
+ if (!empty($entry[$labelKey])) {
|
|
|
+ if ((substr($entry[$labelKey],0,3) == 'K02' || substr($entry[$labelKey],0,3) == 'K01') && $entry[$slKey] != '0'){
|
|
|
+ $list[$j]['fp_lb'] = $entry[$labelKey];
|
|
|
+ $list[$j]['fp_sl'] = $entry[$slKey];
|
|
|
+ $list[$j]['fp_bh'] = $entry[$bhKey];
|
|
|
+ $name = Db::name('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
|
|
|
+ $list[$j]['fp_name'] = empty($name) ? '计时工' : $name;
|
|
|
+ $list[$j]['fp_bz'] = $entry[$bzKey];
|
|
|
+ $list[$j]['qczl_rq'] = $entry['qczl_rq'];
|
|
|
+ $j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $resultArray = array();
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $found = false;
|
|
|
+ foreach ($resultArray as &$resultItem) {
|
|
|
+ if ($item["fp_lb"] === $resultItem["fp_lb"] && $item["fp_bh"] === $resultItem["fp_bh"]) {
|
|
|
+ $resultItem["fp_sl"] += (int)$item["fp_sl"];
|
|
|
+ $found = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!$found) {
|
|
|
+ $resultArray[] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 使用usort进行排序
|
|
|
+ usort($resultArray, function($a, $b) {
|
|
|
+ // First, sort by fp_lb (K01/K02)
|
|
|
+ $compareLb = strcmp($a['fp_lb'], $b['fp_lb']);
|
|
|
+ if ($compareLb !== 0) {
|
|
|
+ return $compareLb;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If fp_lb is the same, prioritize B班 over A班
|
|
|
+ $compareBz = strcmp($a['fp_bz'], $b['fp_bz']);
|
|
|
+ if ($compareBz !== 0) {
|
|
|
+ return (trim($a['fp_bz']) === 'B班') ? -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If fp_bz is the same, sort by fp_bh
|
|
|
+ $compareBh = strcmp($a['fp_bh'], $b['fp_bh']);
|
|
|
+ return $compareBh;
|
|
|
+ });
|
|
|
+ $this->success('请求成功',$resultArray);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 月度核检废品责任人统计
|
|
|
+ * @ApiMethod GET
|
|
|
+ * @params string date
|
|
|
+ */
|
|
|
+ public function getMonthPeopleTotal(){
|
|
|
+ if (Request::instance()->isGet() == false) {
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->param();
|
|
|
+ if (!isset($params['date']) || empty($params['date'])) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|