|
@@ -49,16 +49,20 @@ class Supplierservicescore extends Backend
|
|
|
$list = $keyword !== ''
|
|
$list = $keyword !== ''
|
|
|
? $this->loadSupplierScoreSearchList($keyword)
|
|
? $this->loadSupplierScoreSearchList($keyword)
|
|
|
: $this->loadMonthlySupplierScoreList($ym, '', $forceSync);
|
|
: $this->loadMonthlySupplierScoreList($ym, '', $forceSync);
|
|
|
|
|
+ // 按列表行月份批量统计中标订单数(与「本月订单明细」口径一致)
|
|
|
|
|
+ $winCountByYmCompany = $this->loadMonthWinOrderCountMapForList($list);
|
|
|
$total = count($list);
|
|
$total = count($list);
|
|
|
$pageRows = array_slice($list, $offset, $limit);
|
|
$pageRows = array_slice($list, $offset, $limit);
|
|
|
$seqBase = $offset;
|
|
$seqBase = $offset;
|
|
|
$rows = [];
|
|
$rows = [];
|
|
|
foreach ($pageRows as $i => $item) {
|
|
foreach ($pageRows as $i => $item) {
|
|
|
$rowYm = (string)($item['ym'] ?? $ym);
|
|
$rowYm = (string)($item['ym'] ?? $ym);
|
|
|
|
|
+ $companyName = (string)($item['company_name'] ?? '');
|
|
|
|
|
+ $winKey = $rowYm . "\0" . $companyName;
|
|
|
$rows[] = [
|
|
$rows[] = [
|
|
|
'id' => $seqBase + $i + 1,
|
|
'id' => $seqBase + $i + 1,
|
|
|
'seq_no' => $seqBase + $i + 1,
|
|
'seq_no' => $seqBase + $i + 1,
|
|
|
- 'company_name' => (string)($item['company_name'] ?? ''),
|
|
|
|
|
|
|
+ 'company_name' => $companyName,
|
|
|
'quality_score' => $item['quality_score'] ?? null,
|
|
'quality_score' => $item['quality_score'] ?? null,
|
|
|
'quality_score_text' => (string)($item['quality_score_text'] ?? ''),
|
|
'quality_score_text' => (string)($item['quality_score_text'] ?? ''),
|
|
|
'price_score' => $item['price_score'] ?? null,
|
|
'price_score' => $item['price_score'] ?? null,
|
|
@@ -73,6 +77,7 @@ class Supplierservicescore extends Backend
|
|
|
'score_grade' => (string)($item['score_grade'] ?? ''),
|
|
'score_grade' => (string)($item['score_grade'] ?? ''),
|
|
|
'score_date' => (string)(($item['score_date'] ?? '') !== '' ? $item['score_date'] : $rowYm),
|
|
'score_date' => (string)(($item['score_date'] ?? '') !== '' ? $item['score_date'] : $rowYm),
|
|
|
'ym' => $rowYm,
|
|
'ym' => $rowYm,
|
|
|
|
|
+ 'win_order_count' => (int)($winCountByYmCompany[$winKey] ?? 0),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -491,14 +496,188 @@ class Supplierservicescore extends Backend
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 本月订单明细:已下发订单按「下发批次」(pick_time) 分行;
|
|
|
|
|
- * 同一批次内多工序顿号合并,不同下发时间不合并。
|
|
|
|
|
- * 仅返回已做质量评分且已完结的订单。
|
|
|
|
|
|
|
+ * 列表页批量统计:各供应商在对应月份的中标订单数(审核通过 + 中标)
|
|
|
|
|
+ * key = ym + "\0" + company_name
|
|
|
*
|
|
*
|
|
|
- * @return array<int, array<string, mixed>>
|
|
|
|
|
|
|
+ * @param array<int, array<string, mixed>> $list
|
|
|
|
|
+ * @return array<string, int>
|
|
|
*/
|
|
*/
|
|
|
|
|
+ protected function loadMonthWinOrderCountMapForList(array $list): array
|
|
|
|
|
+ {
|
|
|
|
|
+ /** @var array<string, array<string, true>> $need ym => company => true */
|
|
|
|
|
+ $need = [];
|
|
|
|
|
+ foreach ($list as $item) {
|
|
|
|
|
+ if (!is_array($item)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $rowYm = trim((string)($item['ym'] ?? ''));
|
|
|
|
|
+ $cn = trim((string)($item['company_name'] ?? ''));
|
|
|
|
|
+ if (!preg_match('/^\d{4}-\d{2}$/', $rowYm) || $cn === '') {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($need[$rowYm])) {
|
|
|
|
|
+ $need[$rowYm] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $need[$rowYm][$cn] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($need === []) {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $out = [];
|
|
|
|
|
+ foreach ($need as $ym => $companySet) {
|
|
|
|
|
+ $map = $this->loadMonthWinOrderCountMap($ym, array_keys($companySet));
|
|
|
|
|
+ foreach ($map as $cn => $cnt) {
|
|
|
|
|
+ $out[$ym . "\0" . $cn] = (int)$cnt;
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach (array_keys($companySet) as $cn) {
|
|
|
|
|
+ $k = $ym . "\0" . $cn;
|
|
|
|
|
+ if (!isset($out[$k])) {
|
|
|
|
|
+ $out[$k] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 本月订单明细:与质量得分同源 —— 该供应商「完结时间」落在本月且已质量评分的订单
|
|
|
|
|
|
|
+ * 某月各供应商中标订单数(按订单号去重)
|
|
|
|
|
+ * 口径与 loadMonthOrdersForSupplier 一致:审核通过 + pick 中标,且(下发月=本月 或 本月开标评分表有该单)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string[] $companyNames
|
|
|
|
|
+ * @return array<string, int>
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function loadMonthWinOrderCountMap(string $ym, array $companyNames): array
|
|
|
|
|
+ {
|
|
|
|
|
+ $ym = trim($ym);
|
|
|
|
|
+ $names = [];
|
|
|
|
|
+ foreach ($companyNames as $n) {
|
|
|
|
|
+ $n = trim((string)$n);
|
|
|
|
|
+ if ($n !== '') {
|
|
|
|
|
+ $names[$n] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $companyNames = array_keys($names);
|
|
|
|
|
+ if (!preg_match('/^\d{4}-\d{2}$/', $ym) || $companyNames === []) {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ ProcuremenSupplierScore::ensureSchema();
|
|
|
|
|
+ $approvedVals = \app\common\library\ProcuremenStatus::wflowApprovedValues();
|
|
|
|
|
+ $softDel = '(mod_rq IS NULL OR TRIM(CAST(mod_rq AS CHAR(32))) = \'\' OR TRIM(CAST(mod_rq AS CHAR(32))) LIKE \'0000-00-00%\')';
|
|
|
|
|
+
|
|
|
|
|
+ /** @var array<string, array<string, true>> $seen company => ccydh => true */
|
|
|
|
|
+ $seen = [];
|
|
|
|
|
+
|
|
|
|
|
+ // A) 下发时间落在本月的中标单
|
|
|
|
|
+ try {
|
|
|
|
|
+ $poRows = \think\Db::table('purchase_order')
|
|
|
|
|
+ ->where('pick_company_name', 'in', $companyNames)
|
|
|
|
|
+ ->where('wflow_status', 'in', $approvedVals)
|
|
|
|
|
+ ->whereRaw($softDel)
|
|
|
|
|
+ ->whereRaw('pick_time IS NOT NULL AND TRIM(CAST(pick_time AS CHAR(32))) <> \'\' AND TRIM(CAST(pick_time AS CHAR(32))) NOT LIKE \'0000-00-00%\'')
|
|
|
|
|
+ ->whereRaw('DATE_FORMAT(pick_time, \'%Y-%m\') = ?', [$ym])
|
|
|
|
|
+ ->field('CCYDH,pick_company_name')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ $poRows = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_array($poRows)) {
|
|
|
|
|
+ foreach ($poRows as $po) {
|
|
|
|
|
+ if (!is_array($po)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $cn = trim((string)($po['pick_company_name'] ?? ''));
|
|
|
|
|
+ $ccydh = trim((string)($po['CCYDH'] ?? ''));
|
|
|
|
|
+ if ($cn === '' || $ccydh === '' || !isset($names[$cn])) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($seen[$cn])) {
|
|
|
|
|
+ $seen[$cn] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $seen[$cn][$ccydh] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // B) 本月开标评分表有记录、且采购单仍为该供应商中标并已审核
|
|
|
|
|
+ try {
|
|
|
|
|
+ $bidRows = \think\Db::table(ProcuremenSupplierScore::TABLE_SCORE)
|
|
|
|
|
+ ->where('ym', $ym)
|
|
|
|
|
+ ->where('company_name', 'in', $companyNames)
|
|
|
|
|
+ ->field('ccydh,company_name')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ $bidRows = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $bidCcydhByCompany = [];
|
|
|
|
|
+ if (is_array($bidRows)) {
|
|
|
|
|
+ foreach ($bidRows as $br) {
|
|
|
|
|
+ if (!is_array($br)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $cn = trim((string)($br['company_name'] ?? ''));
|
|
|
|
|
+ $ccydh = trim((string)($br['ccydh'] ?? ''));
|
|
|
|
|
+ if ($cn === '' || $ccydh === '' || !isset($names[$cn])) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($bidCcydhByCompany[$cn])) {
|
|
|
|
|
+ $bidCcydhByCompany[$cn] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $bidCcydhByCompany[$cn][$ccydh] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $allBidCcydh = [];
|
|
|
|
|
+ foreach ($bidCcydhByCompany as $set) {
|
|
|
|
|
+ foreach (array_keys($set) as $c) {
|
|
|
|
|
+ $allBidCcydh[$c] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($allBidCcydh !== []) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $poBid = \think\Db::table('purchase_order')
|
|
|
|
|
+ ->where('CCYDH', 'in', array_keys($allBidCcydh))
|
|
|
|
|
+ ->where('pick_company_name', 'in', $companyNames)
|
|
|
|
|
+ ->where('wflow_status', 'in', $approvedVals)
|
|
|
|
|
+ ->whereRaw($softDel)
|
|
|
|
|
+ ->field('CCYDH,pick_company_name')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ $poBid = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_array($poBid)) {
|
|
|
|
|
+ foreach ($poBid as $po) {
|
|
|
|
|
+ if (!is_array($po)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $cn = trim((string)($po['pick_company_name'] ?? ''));
|
|
|
|
|
+ $ccydh = trim((string)($po['CCYDH'] ?? ''));
|
|
|
|
|
+ if ($cn === '' || $ccydh === '' || !isset($names[$cn])) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($bidCcydhByCompany[$cn][$ccydh])) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($seen[$cn])) {
|
|
|
|
|
+ $seen[$cn] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $seen[$cn][$ccydh] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $out = [];
|
|
|
|
|
+ foreach ($companyNames as $cn) {
|
|
|
|
|
+ $out[$cn] = isset($seen[$cn]) ? count($seen[$cn]) : 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 本月订单明细:
|
|
|
|
|
+ * 1)该供应商「审核通过」且中标的订单(按选定时间落在本月,或本月开标评分表有该单);
|
|
|
|
|
+ * 2)叠加「完结月=本月且已质量评分」的订单(有分可看合格/交货等)。
|
|
|
|
|
+ * 未到入库评分阶段的单:仍显示中标,分项/合格等为空,进度为待入库评分。
|
|
|
*
|
|
*
|
|
|
* @return array<int, array<string, mixed>>
|
|
* @return array<int, array<string, mixed>>
|
|
|
*/
|
|
*/
|
|
@@ -511,7 +690,141 @@ class Supplierservicescore extends Backend
|
|
|
}
|
|
}
|
|
|
ProcuremenSupplierScore::ensureSchema();
|
|
ProcuremenSupplierScore::ensureSchema();
|
|
|
|
|
|
|
|
- // 1) 入库/质量评分表(先取该供应商全部,再按完结月过滤,与月度计分一致)
|
|
|
|
|
|
|
+ /** @var array<string, array<string, mixed>> $byCcydh */
|
|
|
|
|
+ $byCcydh = [];
|
|
|
|
|
+
|
|
|
|
|
+ // ——— A) 审核通过 + 中标(本月)———
|
|
|
|
|
+ $approvedVals = \app\common\library\ProcuremenStatus::wflowApprovedValues();
|
|
|
|
|
+ $bidCcydhSet = [];
|
|
|
|
|
+ try {
|
|
|
|
|
+ $bidCcydhRows = \think\Db::table(ProcuremenSupplierScore::TABLE_SCORE)
|
|
|
|
|
+ ->where('ym', $ym)
|
|
|
|
|
+ ->where('company_name', $companyName)
|
|
|
|
|
+ ->field('ccydh')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (is_array($bidCcydhRows)) {
|
|
|
|
|
+ foreach ($bidCcydhRows as $br) {
|
|
|
|
|
+ if (!is_array($br)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $c = trim((string)($br['ccydh'] ?? ''));
|
|
|
|
|
+ if ($c !== '') {
|
|
|
|
|
+ $bidCcydhSet[$c] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ $poWinQuery = \think\Db::table('purchase_order')
|
|
|
|
|
+ ->where('pick_company_name', $companyName)
|
|
|
|
|
+ ->where('wflow_status', 'in', $approvedVals)
|
|
|
|
|
+ ->whereRaw('(mod_rq IS NULL OR TRIM(CAST(mod_rq AS CHAR(32))) = \'\' OR TRIM(CAST(mod_rq AS CHAR(32))) LIKE \'0000-00-00%\')')
|
|
|
|
|
+ ->field('CCYDH,CYJMC,CGYMC,CCLBMMC,CDW,pick_company_name,wflow_status,status,pick_time,scydgy_id,order_batch_no');
|
|
|
|
|
+ $poWinRows = $poWinQuery->order('id', 'asc')->select();
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $poWinRows = \think\Db::table('purchase_order')
|
|
|
|
|
+ ->where('pick_company_name', $companyName)
|
|
|
|
|
+ ->where('wflow_status', 'in', $approvedVals)
|
|
|
|
|
+ ->whereRaw('(mod_rq IS NULL OR TRIM(CAST(mod_rq AS CHAR(32))) = \'\' OR TRIM(CAST(mod_rq AS CHAR(32))) LIKE \'0000-00-00%\')')
|
|
|
|
|
+ ->field('CCYDH,CYJMC,CGYMC,CCLBMMC,CDW,pick_company_name,wflow_status,status,pick_time,scydgy_id')
|
|
|
|
|
+ ->order('id', 'asc')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e2) {
|
|
|
|
|
+ $poWinRows = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!is_array($poWinRows)) {
|
|
|
|
|
+ $poWinRows = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($poWinRows as $po) {
|
|
|
|
|
+ if (!is_array($po)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $ccydh = trim((string)($po['CCYDH'] ?? ''));
|
|
|
|
|
+ if ($ccydh === '') {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $pickTime = trim((string)($po['pick_time'] ?? ''));
|
|
|
|
|
+ $pickYm = '';
|
|
|
|
|
+ if ($pickTime !== '' && !preg_match('/^0000-00-00/', $pickTime)) {
|
|
|
|
|
+ $ts = strtotime($pickTime);
|
|
|
|
|
+ if ($ts !== false) {
|
|
|
|
|
+ $pickYm = date('Y-m', $ts);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $inMonth = ($pickYm === $ym) || isset($bidCcydhSet[$ccydh]);
|
|
|
|
|
+ if (!$inMonth) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($byCcydh[$ccydh])) {
|
|
|
|
|
+ $byCcydh[$ccydh] = [
|
|
|
|
|
+ 'CCYDH' => $ccydh,
|
|
|
|
|
+ 'order_batch_no' => trim((string)($po['order_batch_no'] ?? '')),
|
|
|
|
|
+ 'scydgy_id' => (int)($po['scydgy_id'] ?? 0),
|
|
|
|
|
+ 'scydgy_ids' => [],
|
|
|
|
|
+ 'CYJMC' => trim((string)($po['CYJMC'] ?? '')),
|
|
|
|
|
+ 'CCLBMMC' => trim((string)($po['CCLBMMC'] ?? '')),
|
|
|
|
|
+ 'CDW' => trim((string)($po['CDW'] ?? '')),
|
|
|
|
|
+ 'CGYMC_list' => [],
|
|
|
|
|
+ 'pick_company_name' => $companyName,
|
|
|
|
|
+ 'wflow_status' => \app\common\library\ProcuremenStatus::WFLOW_APPROVED,
|
|
|
|
|
+ 'status' => trim((string)($po['status'] ?? '')),
|
|
|
|
|
+ 'pick_time' => $pickTime,
|
|
|
|
|
+ 'completed' => \app\common\library\ProcuremenStatus::isPoCompleted($po['status'] ?? ''),
|
|
|
|
|
+ 'picked_match' => true,
|
|
|
|
|
+ 'has_inbound_score' => 0,
|
|
|
|
|
+ 'inbound_result' => '',
|
|
|
|
|
+ 'delivery_status' => '',
|
|
|
|
|
+ 'delivery_date' => '',
|
|
|
|
|
+ 'customer_complaint' => 0,
|
|
|
|
|
+ 'complaint_remark' => '',
|
|
|
|
|
+ 'order_interrupt' => 0,
|
|
|
|
|
+ 'inbound_remark' => '',
|
|
|
|
|
+ 'score_time' => '',
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ $g = &$byCcydh[$ccydh];
|
|
|
|
|
+ $sid = (int)($po['scydgy_id'] ?? 0);
|
|
|
|
|
+ if ($sid > 0) {
|
|
|
|
|
+ if ($g['scydgy_id'] <= 0) {
|
|
|
|
|
+ $g['scydgy_id'] = $sid;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!in_array($sid, $g['scydgy_ids'], true)) {
|
|
|
|
|
+ $g['scydgy_ids'][] = $sid;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $batchNo = trim((string)($po['order_batch_no'] ?? ''));
|
|
|
|
|
+ if ($batchNo !== '' && ($g['order_batch_no'] ?? '') === '') {
|
|
|
|
|
+ $g['order_batch_no'] = $batchNo;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($g['CYJMC'] === '') {
|
|
|
|
|
+ $g['CYJMC'] = trim((string)($po['CYJMC'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($g['CCLBMMC'] === '') {
|
|
|
|
|
+ $g['CCLBMMC'] = trim((string)($po['CCLBMMC'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($g['CDW'] === '') {
|
|
|
|
|
+ $g['CDW'] = trim((string)($po['CDW'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ $gymc = trim((string)($po['CGYMC'] ?? ''));
|
|
|
|
|
+ if ($gymc !== '' && !in_array($gymc, $g['CGYMC_list'], true)) {
|
|
|
|
|
+ $g['CGYMC_list'][] = $gymc;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($pickTime !== '' && !preg_match('/^0000-00-00/', $pickTime)) {
|
|
|
|
|
+ if ($g['pick_time'] === '' || strcmp($pickTime, $g['pick_time']) < 0) {
|
|
|
|
|
+ $g['pick_time'] = $pickTime;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (\app\common\library\ProcuremenStatus::isPoCompleted($po['status'] ?? '')) {
|
|
|
|
|
+ $g['completed'] = true;
|
|
|
|
|
+ $g['status'] = \app\common\library\ProcuremenStatus::PO_COMPLETED;
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($g);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ——— B) 入库质量评分(完结月=本月)叠加 ———
|
|
|
try {
|
|
try {
|
|
|
$scoreRowsRaw = \think\Db::table('purchase_order_inbound_score')
|
|
$scoreRowsRaw = \think\Db::table('purchase_order_inbound_score')
|
|
|
->where('company_name', $companyName)
|
|
->where('company_name', $companyName)
|
|
@@ -537,10 +850,10 @@ class Supplierservicescore extends Backend
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (!is_array($scoreRowsRaw) || $scoreRowsRaw === []) {
|
|
|
|
|
- return [];
|
|
|
|
|
|
|
+ if (!is_array($scoreRowsRaw)) {
|
|
|
|
|
+ $scoreRowsRaw = [];
|
|
|
}
|
|
}
|
|
|
- $sidSet = [];
|
|
|
|
|
|
|
+ $sidSetForYm = [];
|
|
|
$inboundTimeBySid = [];
|
|
$inboundTimeBySid = [];
|
|
|
foreach ($scoreRowsRaw as $r) {
|
|
foreach ($scoreRowsRaw as $r) {
|
|
|
if (!is_array($r)) {
|
|
if (!is_array($r)) {
|
|
@@ -550,18 +863,24 @@ class Supplierservicescore extends Backend
|
|
|
if ($sid <= 0) {
|
|
if ($sid <= 0) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- $sidSet[$sid] = true;
|
|
|
|
|
|
|
+ $sidSetForYm[$sid] = true;
|
|
|
$inboundTimeBySid[$sid] = [
|
|
$inboundTimeBySid[$sid] = [
|
|
|
'createtime' => $r['createtime'] ?? null,
|
|
'createtime' => $r['createtime'] ?? null,
|
|
|
'updatetime' => $r['updatetime'] ?? null,
|
|
'updatetime' => $r['updatetime'] ?? null,
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- $completedYmMap = ProcuremenSupplierScore::loadCompletedYmMapByScydgyIds(array_keys($sidSet), $inboundTimeBySid);
|
|
|
|
|
- $scoreRows = [];
|
|
|
|
|
|
|
+ $completedYmMap = $sidSetForYm !== []
|
|
|
|
|
+ ? ProcuremenSupplierScore::loadCompletedYmMapByScydgyIds(array_keys($sidSetForYm), $inboundTimeBySid)
|
|
|
|
|
+ : [];
|
|
|
foreach ($scoreRowsRaw as $r) {
|
|
foreach ($scoreRowsRaw as $r) {
|
|
|
if (!is_array($r)) {
|
|
if (!is_array($r)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ $ccydh = trim((string)($r['ccydh'] ?? ''));
|
|
|
|
|
+ $result = trim((string)($r['result'] ?? ''));
|
|
|
|
|
+ if ($ccydh === '' || ($result !== '合格' && $result !== '不合格')) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
$sid = (int)($r['scydgy_id'] ?? 0);
|
|
$sid = (int)($r['scydgy_id'] ?? 0);
|
|
|
$rowYm = $sid > 0 ? (string)($completedYmMap[$sid] ?? '') : '';
|
|
$rowYm = $sid > 0 ? (string)($completedYmMap[$sid] ?? '') : '';
|
|
|
if ($rowYm === '' && $sid <= 0) {
|
|
if ($rowYm === '' && $sid <= 0) {
|
|
@@ -573,28 +892,6 @@ class Supplierservicescore extends Backend
|
|
|
if ($rowYm !== $ym) {
|
|
if ($rowYm !== $ym) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- $scoreRows[] = $r;
|
|
|
|
|
- }
|
|
|
|
|
- if ($scoreRows === []) {
|
|
|
|
|
- return [];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /** @var array<string, array<string, mixed>> $byCcydh */
|
|
|
|
|
- $byCcydh = [];
|
|
|
|
|
- $sidSet = [];
|
|
|
|
|
- foreach ($scoreRows as $r) {
|
|
|
|
|
- if (!is_array($r)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- $ccydh = trim((string)($r['ccydh'] ?? ''));
|
|
|
|
|
- $result = trim((string)($r['result'] ?? ''));
|
|
|
|
|
- if ($ccydh === '' || ($result !== '合格' && $result !== '不合格')) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- $sid = (int)($r['scydgy_id'] ?? 0);
|
|
|
|
|
- if ($sid > 0) {
|
|
|
|
|
- $sidSet[$sid] = true;
|
|
|
|
|
- }
|
|
|
|
|
$scoreTime = trim((string)($r['updatetime'] ?? ''));
|
|
$scoreTime = trim((string)($r['updatetime'] ?? ''));
|
|
|
if ($scoreTime === '' || preg_match('/^0000-00-00/', $scoreTime)) {
|
|
if ($scoreTime === '' || preg_match('/^0000-00-00/', $scoreTime)) {
|
|
|
$scoreTime = trim((string)($r['createtime'] ?? ''));
|
|
$scoreTime = trim((string)($r['createtime'] ?? ''));
|
|
@@ -606,10 +903,20 @@ class Supplierservicescore extends Backend
|
|
|
}
|
|
}
|
|
|
$byCcydh[$ccydh] = [
|
|
$byCcydh[$ccydh] = [
|
|
|
'CCYDH' => $ccydh,
|
|
'CCYDH' => $ccydh,
|
|
|
|
|
+ 'order_batch_no' => '',
|
|
|
'scydgy_id' => $sid > 0 ? $sid : 0,
|
|
'scydgy_id' => $sid > 0 ? $sid : 0,
|
|
|
'scydgy_ids' => $sid > 0 ? [$sid] : [],
|
|
'scydgy_ids' => $sid > 0 ? [$sid] : [],
|
|
|
'CYJMC' => trim((string)($r['cyjmc'] ?? '')),
|
|
'CYJMC' => trim((string)($r['cyjmc'] ?? '')),
|
|
|
|
|
+ 'CCLBMMC' => '',
|
|
|
|
|
+ 'CDW' => '',
|
|
|
'CGYMC_list' => [],
|
|
'CGYMC_list' => [],
|
|
|
|
|
+ 'pick_company_name' => $companyName,
|
|
|
|
|
+ 'wflow_status' => \app\common\library\ProcuremenStatus::WFLOW_APPROVED,
|
|
|
|
|
+ 'status' => '',
|
|
|
|
|
+ 'pick_time' => '',
|
|
|
|
|
+ 'completed' => true,
|
|
|
|
|
+ 'picked_match' => true,
|
|
|
|
|
+ 'has_inbound_score' => 1,
|
|
|
'inbound_result' => $result,
|
|
'inbound_result' => $result,
|
|
|
'delivery_status' => $ds,
|
|
'delivery_status' => $ds,
|
|
|
'delivery_date' => '',
|
|
'delivery_date' => '',
|
|
@@ -621,9 +928,11 @@ class Supplierservicescore extends Backend
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
$g = &$byCcydh[$ccydh];
|
|
$g = &$byCcydh[$ccydh];
|
|
|
- // 任一工序不合格 → 整单不合格(与质量分统计一致)
|
|
|
|
|
|
|
+ $g['has_inbound_score'] = 1;
|
|
|
if ($result === '不合格') {
|
|
if ($result === '不合格') {
|
|
|
$g['inbound_result'] = '不合格';
|
|
$g['inbound_result'] = '不合格';
|
|
|
|
|
+ } elseif ($g['inbound_result'] === '') {
|
|
|
|
|
+ $g['inbound_result'] = $result;
|
|
|
}
|
|
}
|
|
|
if ($sid > 0) {
|
|
if ($sid > 0) {
|
|
|
if ($g['scydgy_id'] <= 0) {
|
|
if ($g['scydgy_id'] <= 0) {
|
|
@@ -668,106 +977,118 @@ class Supplierservicescore extends Backend
|
|
|
}
|
|
}
|
|
|
unset($g);
|
|
unset($g);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if ($byCcydh === []) {
|
|
if ($byCcydh === []) {
|
|
|
return [];
|
|
return [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 2) 补充采购单展示字段
|
|
|
|
|
- $poByCcydh = [];
|
|
|
|
|
- try {
|
|
|
|
|
- $poRows = \think\Db::table('purchase_order')
|
|
|
|
|
- ->where('CCYDH', 'in', array_keys($byCcydh))
|
|
|
|
|
- ->whereRaw('(mod_rq IS NULL OR TRIM(CAST(mod_rq AS CHAR(32))) = \'\' OR TRIM(CAST(mod_rq AS CHAR(32))) LIKE \'0000-00-00%\')')
|
|
|
|
|
- ->field('CCYDH,CYJMC,CGYMC,CCLBMMC,CDW,pick_company_name,wflow_status,status,pick_time,scydgy_id')
|
|
|
|
|
- ->order('id', 'asc')
|
|
|
|
|
- ->select();
|
|
|
|
|
- } catch (\Throwable $e) {
|
|
|
|
|
- $poRows = [];
|
|
|
|
|
|
|
+ // 补采购单展示字段(入库评分带来的单可能缺 PO 信息)
|
|
|
|
|
+ $needPo = [];
|
|
|
|
|
+ foreach ($byCcydh as $c => $g) {
|
|
|
|
|
+ if (($g['CCLBMMC'] ?? '') === ''
|
|
|
|
|
+ || ($g['pick_time'] ?? '') === ''
|
|
|
|
|
+ || empty($g['CGYMC_list'])
|
|
|
|
|
+ || ($g['order_batch_no'] ?? '') === ''
|
|
|
|
|
+ ) {
|
|
|
|
|
+ $needPo[$c] = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (is_array($poRows)) {
|
|
|
|
|
- foreach ($poRows as $po) {
|
|
|
|
|
- if (!is_array($po)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- $c = trim((string)($po['CCYDH'] ?? ''));
|
|
|
|
|
- if ($c === '' || !isset($byCcydh[$c])) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- if (!isset($poByCcydh[$c])) {
|
|
|
|
|
- $poByCcydh[$c] = [
|
|
|
|
|
- 'CYJMC' => '',
|
|
|
|
|
- 'CCLBMMC' => '',
|
|
|
|
|
- 'CGYMC_list' => [],
|
|
|
|
|
- 'CDW' => '',
|
|
|
|
|
- 'pick_company_name' => '',
|
|
|
|
|
- 'wflow_status' => '',
|
|
|
|
|
- 'status' => '',
|
|
|
|
|
- 'pick_time' => '',
|
|
|
|
|
- 'completed' => false,
|
|
|
|
|
- 'picked_match' => false,
|
|
|
|
|
- 'scydgy_id' => 0,
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
- $p = &$poByCcydh[$c];
|
|
|
|
|
- $sid = (int)($po['scydgy_id'] ?? 0);
|
|
|
|
|
- if ($p['scydgy_id'] <= 0 && $sid > 0) {
|
|
|
|
|
- $p['scydgy_id'] = $sid;
|
|
|
|
|
- }
|
|
|
|
|
- if ($p['CYJMC'] === '') {
|
|
|
|
|
- $p['CYJMC'] = trim((string)($po['CYJMC'] ?? ''));
|
|
|
|
|
- }
|
|
|
|
|
- if ($p['CCLBMMC'] === '') {
|
|
|
|
|
- $p['CCLBMMC'] = trim((string)($po['CCLBMMC'] ?? ''));
|
|
|
|
|
- }
|
|
|
|
|
- if ($p['CDW'] === '') {
|
|
|
|
|
- $p['CDW'] = trim((string)($po['CDW'] ?? ''));
|
|
|
|
|
- }
|
|
|
|
|
- $g = trim((string)($po['CGYMC'] ?? ''));
|
|
|
|
|
- if ($g !== '' && !in_array($g, $p['CGYMC_list'], true)) {
|
|
|
|
|
- $p['CGYMC_list'][] = $g;
|
|
|
|
|
|
|
+ if ($needPo !== []) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $poRows = \think\Db::table('purchase_order')
|
|
|
|
|
+ ->where('CCYDH', 'in', array_keys($needPo))
|
|
|
|
|
+ ->whereRaw('(mod_rq IS NULL OR TRIM(CAST(mod_rq AS CHAR(32))) = \'\' OR TRIM(CAST(mod_rq AS CHAR(32))) LIKE \'0000-00-00%\')')
|
|
|
|
|
+ ->field('CCYDH,CYJMC,CGYMC,CCLBMMC,CDW,pick_company_name,wflow_status,status,pick_time,scydgy_id,order_batch_no')
|
|
|
|
|
+ ->order('id', 'asc')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $poRows = \think\Db::table('purchase_order')
|
|
|
|
|
+ ->where('CCYDH', 'in', array_keys($needPo))
|
|
|
|
|
+ ->whereRaw('(mod_rq IS NULL OR TRIM(CAST(mod_rq AS CHAR(32))) = \'\' OR TRIM(CAST(mod_rq AS CHAR(32))) LIKE \'0000-00-00%\')')
|
|
|
|
|
+ ->field('CCYDH,CYJMC,CGYMC,CCLBMMC,CDW,pick_company_name,wflow_status,status,pick_time,scydgy_id')
|
|
|
|
|
+ ->order('id', 'asc')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e2) {
|
|
|
|
|
+ $poRows = [];
|
|
|
}
|
|
}
|
|
|
- $pn = trim((string)($po['pick_company_name'] ?? ''));
|
|
|
|
|
- if ($pn !== '') {
|
|
|
|
|
- if ($p['pick_company_name'] === '') {
|
|
|
|
|
- $p['pick_company_name'] = $pn;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_array($poRows)) {
|
|
|
|
|
+ foreach ($poRows as $po) {
|
|
|
|
|
+ if (!is_array($po)) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
- if ($pn === $companyName) {
|
|
|
|
|
- $p['picked_match'] = true;
|
|
|
|
|
|
|
+ $c = trim((string)($po['CCYDH'] ?? ''));
|
|
|
|
|
+ if ($c === '' || !isset($byCcydh[$c])) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- $pt = trim((string)($po['pick_time'] ?? ''));
|
|
|
|
|
- if ($pt !== '' && !preg_match('/^0000-00-00/', $pt)) {
|
|
|
|
|
- if ($p['pick_time'] === '' || strcmp($pt, $p['pick_time']) < 0) {
|
|
|
|
|
- $p['pick_time'] = $pt;
|
|
|
|
|
|
|
+ $g = &$byCcydh[$c];
|
|
|
|
|
+ $sid = (int)($po['scydgy_id'] ?? 0);
|
|
|
|
|
+ if ($g['scydgy_id'] <= 0 && $sid > 0) {
|
|
|
|
|
+ $g['scydgy_id'] = $sid;
|
|
|
}
|
|
}
|
|
|
|
|
+ if ($sid > 0 && !in_array($sid, $g['scydgy_ids'], true)) {
|
|
|
|
|
+ $g['scydgy_ids'][] = $sid;
|
|
|
|
|
+ }
|
|
|
|
|
+ $batchNo = trim((string)($po['order_batch_no'] ?? ''));
|
|
|
|
|
+ if ($batchNo !== '' && ($g['order_batch_no'] ?? '') === '') {
|
|
|
|
|
+ $g['order_batch_no'] = $batchNo;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($g['CYJMC'] === '') {
|
|
|
|
|
+ $g['CYJMC'] = trim((string)($po['CYJMC'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($g['CCLBMMC'] === '') {
|
|
|
|
|
+ $g['CCLBMMC'] = trim((string)($po['CCLBMMC'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($g['CDW'] === '') {
|
|
|
|
|
+ $g['CDW'] = trim((string)($po['CDW'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ $gymc = trim((string)($po['CGYMC'] ?? ''));
|
|
|
|
|
+ if ($gymc !== '' && !in_array($gymc, $g['CGYMC_list'], true)) {
|
|
|
|
|
+ $g['CGYMC_list'][] = $gymc;
|
|
|
|
|
+ }
|
|
|
|
|
+ $pt = trim((string)($po['pick_time'] ?? ''));
|
|
|
|
|
+ if ($pt !== '' && !preg_match('/^0000-00-00/', $pt)) {
|
|
|
|
|
+ if ($g['pick_time'] === '' || strcmp($pt, $g['pick_time']) < 0) {
|
|
|
|
|
+ $g['pick_time'] = $pt;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (\app\common\library\ProcuremenStatus::isPoCompleted($po['status'] ?? '')) {
|
|
|
|
|
+ $g['completed'] = true;
|
|
|
|
|
+ $g['status'] = \app\common\library\ProcuremenStatus::PO_COMPLETED;
|
|
|
|
|
+ } elseif ($g['status'] === '' && trim((string)($po['status'] ?? '')) !== '') {
|
|
|
|
|
+ $g['status'] = trim((string)$po['status']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (\app\common\library\ProcuremenStatus::isWflowApproved($po['wflow_status'] ?? '')) {
|
|
|
|
|
+ $g['wflow_status'] = \app\common\library\ProcuremenStatus::WFLOW_APPROVED;
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($g);
|
|
|
}
|
|
}
|
|
|
- if (\app\common\library\ProcuremenStatus::isPoCompleted($po['status'] ?? '')) {
|
|
|
|
|
- $p['completed'] = true;
|
|
|
|
|
- $p['status'] = \app\common\library\ProcuremenStatus::PO_COMPLETED;
|
|
|
|
|
- } elseif ($p['status'] === '' && trim((string)($po['status'] ?? '')) !== '') {
|
|
|
|
|
- $p['status'] = trim((string)$po['status']);
|
|
|
|
|
- }
|
|
|
|
|
- if (\app\common\library\ProcuremenStatus::isWflowApproved($po['wflow_status'] ?? '')) {
|
|
|
|
|
- $p['wflow_status'] = \app\common\library\ProcuremenStatus::WFLOW_APPROVED;
|
|
|
|
|
- } elseif ($p['wflow_status'] === '' && trim((string)($po['wflow_status'] ?? '')) !== '') {
|
|
|
|
|
- $p['wflow_status'] = trim((string)$po['wflow_status']);
|
|
|
|
|
- }
|
|
|
|
|
- unset($p);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 3) 可选:招标评分表补排名/分项(没有也不影响展示)
|
|
|
|
|
|
|
+ // 开标分项(可选)
|
|
|
$bidByCcydh = [];
|
|
$bidByCcydh = [];
|
|
|
try {
|
|
try {
|
|
|
$bidRows = \think\Db::table(ProcuremenSupplierScore::TABLE_SCORE)
|
|
$bidRows = \think\Db::table(ProcuremenSupplierScore::TABLE_SCORE)
|
|
|
->where('ym', $ym)
|
|
->where('ym', $ym)
|
|
|
->where('company_name', $companyName)
|
|
->where('company_name', $companyName)
|
|
|
->where('ccydh', 'in', array_keys($byCcydh))
|
|
->where('ccydh', 'in', array_keys($byCcydh))
|
|
|
- ->field('ccydh,score,rank_no,quality_score,price_score,price_sum,lead_score,lead_days_sum,createtime')
|
|
|
|
|
|
|
+ ->field('ccydh,order_batch_no,score,rank_no,quality_score,price_score,price_sum,lead_score,lead_days_sum,createtime')
|
|
|
->order('createtime', 'desc')
|
|
->order('createtime', 'desc')
|
|
|
->select();
|
|
->select();
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- $bidRows = [];
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ $bidRows = \think\Db::table(ProcuremenSupplierScore::TABLE_SCORE)
|
|
|
|
|
+ ->where('ym', $ym)
|
|
|
|
|
+ ->where('company_name', $companyName)
|
|
|
|
|
+ ->where('ccydh', 'in', array_keys($byCcydh))
|
|
|
|
|
+ ->field('ccydh,score,rank_no,quality_score,price_score,price_sum,lead_score,lead_days_sum,createtime')
|
|
|
|
|
+ ->order('createtime', 'desc')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ } catch (\Throwable $e2) {
|
|
|
|
|
+ $bidRows = [];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (is_array($bidRows)) {
|
|
if (is_array($bidRows)) {
|
|
|
foreach ($bidRows as $br) {
|
|
foreach ($bidRows as $br) {
|
|
@@ -779,49 +1100,45 @@ class Supplierservicescore extends Backend
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
$bidByCcydh[$c] = $br;
|
|
$bidByCcydh[$c] = $br;
|
|
|
|
|
+ $bn = trim((string)($br['order_batch_no'] ?? ''));
|
|
|
|
|
+ if ($bn !== '' && isset($byCcydh[$c]) && ($byCcydh[$c]['order_batch_no'] ?? '') === '') {
|
|
|
|
|
+ $byCcydh[$c]['order_batch_no'] = $bn;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$out = [];
|
|
$out = [];
|
|
|
foreach ($byCcydh as $ccydh => $g) {
|
|
foreach ($byCcydh as $ccydh => $g) {
|
|
|
- $po = $poByCcydh[$ccydh] ?? [];
|
|
|
|
|
$bid = $bidByCcydh[$ccydh] ?? [];
|
|
$bid = $bidByCcydh[$ccydh] ?? [];
|
|
|
$gymcList = is_array($g['CGYMC_list'] ?? null) ? $g['CGYMC_list'] : [];
|
|
$gymcList = is_array($g['CGYMC_list'] ?? null) ? $g['CGYMC_list'] : [];
|
|
|
- if ($gymcList === [] && is_array($po['CGYMC_list'] ?? null)) {
|
|
|
|
|
- $gymcList = $po['CGYMC_list'];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $hasInbound = !empty($g['has_inbound_score']);
|
|
|
$batch = [
|
|
$batch = [
|
|
|
- 'completed' => !empty($po['completed']),
|
|
|
|
|
- 'status' => (string)($po['status'] ?? ''),
|
|
|
|
|
- 'wflow_status' => (string)($po['wflow_status'] ?? ''),
|
|
|
|
|
|
|
+ 'completed' => !empty($g['completed']) || $hasInbound,
|
|
|
|
|
+ 'status' => (string)($g['status'] ?? ''),
|
|
|
|
|
+ 'wflow_status' => (string)($g['wflow_status'] ?? ''),
|
|
|
];
|
|
];
|
|
|
$progressText = $this->formatMonthOrderProgressText($batch);
|
|
$progressText = $this->formatMonthOrderProgressText($batch);
|
|
|
- // 已质量评分:进度优先显示已完结,否则显示实际流程
|
|
|
|
|
- if ($progressText === '待入库评分') {
|
|
|
|
|
|
|
+ // 已质量评分:进度优先显示已完结
|
|
|
|
|
+ if ($hasInbound && $progressText === '待入库评分') {
|
|
|
$progressText = \app\common\library\ProcuremenStatus::PO_COMPLETED;
|
|
$progressText = \app\common\library\ProcuremenStatus::PO_COMPLETED;
|
|
|
}
|
|
}
|
|
|
- $showBid = !empty($po['completed'])
|
|
|
|
|
- || \app\common\library\ProcuremenStatus::isPoCompleted($po['status'] ?? '')
|
|
|
|
|
- || \app\common\library\ProcuremenStatus::isWflowApproved($po['wflow_status'] ?? '');
|
|
|
|
|
- $pickTimeRaw = trim((string)($po['pick_time'] ?? ''));
|
|
|
|
|
|
|
+ $pickTimeRaw = trim((string)($g['pick_time'] ?? ''));
|
|
|
if ($pickTimeRaw === '') {
|
|
if ($pickTimeRaw === '') {
|
|
|
$pickTimeRaw = trim((string)($g['score_time'] ?? ''));
|
|
$pickTimeRaw = trim((string)($g['score_time'] ?? ''));
|
|
|
}
|
|
}
|
|
|
$sid = (int)($g['scydgy_id'] ?? 0);
|
|
$sid = (int)($g['scydgy_id'] ?? 0);
|
|
|
- if ($sid <= 0) {
|
|
|
|
|
- $sid = (int)($po['scydgy_id'] ?? 0);
|
|
|
|
|
- }
|
|
|
|
|
$out[] = [
|
|
$out[] = [
|
|
|
'seq_no' => 0,
|
|
'seq_no' => 0,
|
|
|
'scydgy_id' => $sid,
|
|
'scydgy_id' => $sid,
|
|
|
'CCYDH' => $ccydh,
|
|
'CCYDH' => $ccydh,
|
|
|
- 'CYJMC' => (string)(($g['CYJMC'] ?? '') !== '' ? $g['CYJMC'] : ($po['CYJMC'] ?? '')),
|
|
|
|
|
- 'CCLBMMC' => (string)($po['CCLBMMC'] ?? ''),
|
|
|
|
|
|
|
+ 'order_batch_no' => (string)($g['order_batch_no'] ?? ''),
|
|
|
|
|
+ 'CYJMC' => (string)($g['CYJMC'] ?? ''),
|
|
|
|
|
+ 'CCLBMMC' => (string)($g['CCLBMMC'] ?? ''),
|
|
|
'CGYMC' => $gymcList !== [] ? implode('、', $gymcList) : '',
|
|
'CGYMC' => $gymcList !== [] ? implode('、', $gymcList) : '',
|
|
|
- 'CDW' => (string)($po['CDW'] ?? ''),
|
|
|
|
|
- 'pick_company_name' => (string)(($po['pick_company_name'] ?? '') !== '' ? $po['pick_company_name'] : $companyName),
|
|
|
|
|
- 'wflow_status' => (string)($po['wflow_status'] ?? ''),
|
|
|
|
|
- 'status' => (string)($po['status'] ?? ''),
|
|
|
|
|
|
|
+ 'CDW' => (string)($g['CDW'] ?? ''),
|
|
|
|
|
+ 'pick_company_name' => (string)(($g['pick_company_name'] ?? '') !== '' ? $g['pick_company_name'] : $companyName),
|
|
|
|
|
+ 'wflow_status' => (string)($g['wflow_status'] ?? ''),
|
|
|
|
|
+ 'status' => (string)($g['status'] ?? ''),
|
|
|
'progress_text' => $progressText,
|
|
'progress_text' => $progressText,
|
|
|
'pick_time' => $pickTimeRaw,
|
|
'pick_time' => $pickTimeRaw,
|
|
|
'issue_time' => $pickTimeRaw !== ''
|
|
'issue_time' => $pickTimeRaw !== ''
|
|
@@ -834,15 +1151,16 @@ class Supplierservicescore extends Backend
|
|
|
'price_sum' => $bid['price_sum'] ?? null,
|
|
'price_sum' => $bid['price_sum'] ?? null,
|
|
|
'lead_score' => $bid['lead_score'] ?? null,
|
|
'lead_score' => $bid['lead_score'] ?? null,
|
|
|
'lead_days_sum' => $bid['lead_days_sum'] ?? null,
|
|
'lead_days_sum' => $bid['lead_days_sum'] ?? null,
|
|
|
- 'is_picked' => !empty($po['picked_match']) ? 1 : 1,
|
|
|
|
|
- 'show_bid_result' => $showBid ? 1 : 0,
|
|
|
|
|
- 'inbound_result' => (string)($g['inbound_result'] ?? ''),
|
|
|
|
|
- 'delivery_status' => (string)($g['delivery_status'] ?? ''),
|
|
|
|
|
- 'delivery_date' => (string)($g['delivery_date'] ?? ''),
|
|
|
|
|
- 'customer_complaint' => (int)($g['customer_complaint'] ?? 0),
|
|
|
|
|
- 'complaint_remark' => (string)($g['complaint_remark'] ?? ''),
|
|
|
|
|
- 'order_interrupt' => (int)($g['order_interrupt'] ?? 0),
|
|
|
|
|
- 'inbound_remark' => (string)($g['inbound_remark'] ?? ''),
|
|
|
|
|
|
|
+ 'is_picked' => 1,
|
|
|
|
|
+ 'show_bid_result' => 1,
|
|
|
|
|
+ 'has_inbound_score' => $hasInbound ? 1 : 0,
|
|
|
|
|
+ 'inbound_result' => $hasInbound ? (string)($g['inbound_result'] ?? '') : '',
|
|
|
|
|
+ 'delivery_status' => $hasInbound ? (string)($g['delivery_status'] ?? '') : '',
|
|
|
|
|
+ 'delivery_date' => $hasInbound ? (string)($g['delivery_date'] ?? '') : '',
|
|
|
|
|
+ 'customer_complaint' => $hasInbound ? (int)($g['customer_complaint'] ?? 0) : 0,
|
|
|
|
|
+ 'complaint_remark' => $hasInbound ? (string)($g['complaint_remark'] ?? '') : '',
|
|
|
|
|
+ 'order_interrupt' => $hasInbound ? (int)($g['order_interrupt'] ?? 0) : 0,
|
|
|
|
|
+ 'inbound_remark' => $hasInbound ? (string)($g['inbound_remark'] ?? '') : '',
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|