| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 |
- <?php
- namespace app\service;
- use think\Db;
- use think\Exception;
- use think\Log;
- /**
- * 统一成本核算服务类
- * 五项计算完成后统一插入数据库
- */
- class UnifiedCostCalculationService
- {
- // 存储中间数据的数组
- protected $monthlyCostDetails = []; // 成本v23_月度成本明细
- protected $monthlyUtilities = []; // 成本_各月水电气
- protected $allocationFactors = []; // 成本_各月分摊系数
- // 配置常量
- const FLOOR_GROUP_MAP = [
- '1' => ['02、胶印机组', '03、卷凹机组', '06、单凹机组', '05、圆切机组', '04、圆烫机组', '10、模切机组', '09、烫金机组'],
- '2' => ['01、切纸机组', '11、检品机组', '07、丝印机组', '12、覆膜机组', '08、喷码机组'],
- ];
- /**
- * 主入口:执行所有成本计算并统一入库
- */
- public function calculateAndSaveAll(array $param): array
- {
- Db::startTrans();
- try {
- $month = $param['month'];
- $sysId = $param['sys_id'] ?? '';
- // 1. 清空旧数据
- $this->clearOldData($month);
- // 2. 执行五项计算
- $this->calculateDirectLabor($param); // 直接人工
- $this->calculateDirectUtilities($param); // 直接水电
- $this->calculateIndirectMaterials($month); // 间接材料分摊
- $this->calculateIndirectLabor($month); // 间接人工分摊
- $this->calculateApportionedUtilities($param); // 分摊水电
- // 3. 统一插入数据
- $this->saveAllData($month, $sysId);
- Db::commit();
- Log::info("成本核算完成", [
- 'month' => $month,
- '月度成本明细记录数' => count($this->monthlyCostDetails),
- '水电记录数' => count($this->monthlyUtilities),
- '分摊系数记录数' => count($this->allocationFactors)
- ]);
- return [
- 'success' => true,
- 'message' => '成本核算完成',
- 'stats' => [
- 'monthly_cost_details' => count($this->monthlyCostDetails),
- 'utilities' => count($this->monthlyUtilities),
- 'allocation_factors' => count($this->allocationFactors)
- ]
- ];
- } catch (Exception $e) {
- Db::rollback();
- Log::error("统一成本核算失败: " . $e->getMessage());
- return [
- 'success' => false,
- 'message' => '成本核算失败: ' . $e->getMessage()
- ];
- }
- }
- /**
- * 清空旧数据
- */
- protected function clearOldData(string $month): void
- {
- // 这里只记录要删除,实际删除操作在最后统一执行
- // 所有数据都缓存在内存中,最后统一插入
- $this->monthlyCostDetails = [];
- $this->monthlyUtilities = [];
- $this->allocationFactors = [];
- }
- /**
- * 1. 计算直接人工
- */
- protected function calculateDirectLabor(array $param): void
- {
- $month = $param['month'];
- $sysId = $param['sys_id'] ?? '';
- $list = Db::name('绩效工资汇总')
- ->alias('a')
- ->join('工单_工艺资料 b', 'a.sczl_gdbh = b.Gy0_gdbh and a.sczl_yjno = b.Gy0_yjno and a.sczl_gxh = b.Gy0_gxh')
- ->join('设备_基本资料 c', 'a.sczl_jtbh = c.设备编号', 'LEFT')
- ->join('工单_印件资料 d', 'a.sczl_gdbh = d.Yj_Gdbh and a.sczl_yjno = d.yj_Yjno')
- ->field('a.sczl_gdbh as 工单编号,a.sczl_yjno as 印件号,a.sczl_gxh as 工序号,sum(a.班组车头产量) as 班组车头产量,b.Gy0_gxmc as 工序名称,
- a.sczl_ms as 墨色数,c.使用部门,b.印刷方式,b.版距,b.工价系数,a.sczl_jtbh,d.yj_yjmc as 印件名称,sum(a.车头产量占用机时) as 占用机时,a.sys_rq as 年月,
- a.工序难度系数,sum(a.班组换算产量) as 班组换算产量,a.千件工价')
- ->where('a.sys_ny', $month)
- ->group('a.sczl_gdbh,a.sczl_yjno,a.sczl_gxh,a.sczl_jtbh')
- ->select();
- $now = date('Y-m-d H:i:s');
- foreach ($list as $k => $v) {
- // 处理特殊值
- $banju = $v['版距'] === '0.0' ? 1000 : $v['版距'];
- $moshushu = $v['墨色数'] === '0.00' ? 1 : $v['墨色数'];
- if (strpos($v['工序名称'], '切废')) {
- $moshushu = 0.2;
- }
- $chanliang = $v['班组车头产量'] * $v['工序难度系数'] + $v['班组换算产量'];
- $renGongFenTan = ($chanliang / 1000) * $v['千件工价'];
- $this->monthlyCostDetails[] = [
- '车间名称' => $v['使用部门'] ?? '',
- 'sys_ny' => $month,
- 'sczl_gdbh' => $v['工单编号'],
- '印件名称' => $v['印件名称'] ?? '',
- 'sczl_yjno' => $v['印件号'],
- 'sczl_gxh' => $v['工序号'],
- '工序名称' => $v['工序名称'] ?? '',
- 'sczl_jtbh' => $v['sczl_jtbh'] ?? '',
- '卷张换算系数' => floatval($banju) / 1000,
- '占用机时' => floatval($v['占用机时']) ?? 0,
- '班组车头产量' => floatval($v['班组车头产量']) ?? 0,
- 'sczl_ms' => floatval($moshushu),
- '工序难度系数' => floatval($v['工序难度系数']) ?? 1,
- '班组换算产量' => floatval($v['班组换算产量']) ?? 0,
- '千件工价' => floatval($v['千件工价']) ?? 0,
- '计件产量' => floatval($chanliang),
- '水电分摊因子' => floatval($v['占用机时']) ?? 0,
- '材料分摊因子' => floatval($chanliang),
- '人工分摊因子' => floatval($renGongFenTan),
- '直接水电' => 0, // 后续计算
- '分摊材料' => 0, // 后续计算
- '车间人工' => 0, // 后续计算
- '部门人工附加' => 0, // 后续计算
- '分摊水电' => 0, // 后续计算
- '废气处理(RTO)' => 0, // 后续计算
- '锅炉' => 0, // 后续计算
- '空压机' => 0, // 后续计算
- '热水锅炉' => 0, // 后续计算
- '真空鼓风机' => 0, // 后续计算
- '中央空调' => 0, // 后续计算
- 'Sys_id' => $sysId,
- 'Sys_rq' => $now
- ];
- }
- }
- /**
- * 2. 计算直接水电
- */
- protected function calculateDirectUtilities(array $param): void
- {
- $month = $param['month'];
- $sysId = $param['sys_id'] ?? '';
- $monthStr = substr($month, 0, 4) . '-' . substr($month, 4, 2);
- $sist = ['胶印车间', '凹丝印车间', '印后车间'];
- $list = Db::name('设备_产量计酬')
- ->alias('a')
- ->join('设备_基本资料 b', 'a.sczl_jtbh = b.设备编号')
- ->where('a.sczl_rq', 'like', $monthStr . '%')
- ->where('b.sys_sbID', '<>', '')
- ->where('b.使用部门', 'in', $sist)
- ->field('a.sczl_jtbh,sum(a.sczl_设备运行工时) as 通电工时,b.使用部门,rtrim(b.设备名称) as 设备名称')
- ->order('b.使用部门,a.sczl_jtbh')
- ->group('a.sczl_jtbh')
- ->select();
- $now = date('Y-m-d H:i:s');
- foreach ($list as $v) {
- $this->monthlyUtilities[] = [
- 'Sys_ny' => $month,
- '部门名称' => $v['使用部门'] ?? '',
- '费用类型' => '直接',
- '设备编号' => $v['sczl_jtbh'] ?? '',
- '科目名称' => $v['设备名称'] ?? '',
- '耗电量' => floatval($v['通电工时']) ?? 0,
- '单位电价' => 0.69,
- '耗气量' => 0,
- '单位气价' => 0,
- 'Sys_id' => $sysId,
- 'Sys_rq' => $now,
- ];
- }
- }
- /**
- * 3. 计算间接材料分摊
- */
- protected function calculateIndirectMaterials(string $month): void
- {
- if (empty($this->monthlyCostDetails)) {
- return;
- }
- $date = substr($month, 0, 4) . '-' . substr($month, 4, 2);
- // 获取分摊材料总金额
- $totalMoney = Db::name('材料出库单列表')
- ->where([
- '出库日期' => ['like', $date . '%'],
- '部门' => '印刷成本中心'
- ])
- ->whereNull('表体生产订单号')
- ->field('SUM(金额) as money')
- ->find();
- if (!$totalMoney || $totalMoney['money'] <= 0) {
- return;
- }
- // 计算总色度数
- $totalChroma = 0;
- foreach ($this->monthlyCostDetails as $detail) {
- $chroma = floatval($detail['班组车头产量']) * floatval($detail['sczl_ms']);
- $totalChroma += $chroma;
- }
- if ($totalChroma <= 0) {
- return;
- }
- // 分摊到每个记录
- foreach ($this->monthlyCostDetails as &$detail) {
- $chroma = floatval($detail['班组车头产量']) * floatval($detail['sczl_ms']);
- $money = round($totalMoney['money'] * ($chroma / $totalChroma), 2);
- $detail['分摊材料'] = $money;
- }
- }
- /**
- * 4. 计算间接人工分摊
- */
- protected function calculateIndirectLabor(string $month): void
- {
- // 获取工资比例
- $wageRatio = $this->getWageRatio($month);
- if (empty($wageRatio)) {
- return;
- }
- // 获取月度工资数据
- $monthWage = Db::name('成本_各月其他费用')
- ->where('sys_ny', $month)
- ->field('部门人员工资,管理人员工资')
- ->find();
- if (empty($monthWage)) {
- return;
- }
- // 计算每个车间的分配数据
- foreach ($wageRatio as $workshopName => $ratio) {
- $chromaData = $this->getChromaDataForWorkshop($workshopName);
- if (empty($chromaData['list']) || $chromaData['total'] == 0) {
- continue;
- }
- // 计算两种工资类型的分配
- $this->allocateWageToWorkshop($workshopName, $ratio, $monthWage, $chromaData);
- }
- }
- /**
- * 获取车间色度数数据
- */
- protected function getChromaDataForWorkshop(string $workshop): array
- {
- $data = [
- 'total' => 0,
- 'list' => []
- ];
- foreach ($this->monthlyCostDetails as $detail) {
- if ($detail['车间名称'] === $workshop) {
- $chroma = floatval($detail['班组车头产量']) * floatval($detail['sczl_ms']);
- $data['total'] += $chroma;
- $data['list'][] = [
- 'sczl_gdbh' => $detail['sczl_gdbh'],
- 'sczl_yjno' => $detail['sczl_yjno'],
- 'sczl_gxh' => $detail['sczl_gxh'],
- 'sczl_jtbh' => $detail['sczl_jtbh'],
- 'chroma' => $chroma
- ];
- }
- }
- return $data;
- }
- /**
- * 分配工资到车间
- */
- protected function allocateWageToWorkshop(string $workshop, float $ratio, array $monthWage, array $chromaData): void
- {
- $updateTypes = [
- '部门人员工资' => '车间人工',
- '管理人员工资' => '部门人工附加'
- ];
- foreach ($updateTypes as $wageType => $fieldName) {
- if (!isset($monthWage[$wageType]) || $monthWage[$wageType] <= 0) {
- continue;
- }
- $money = $ratio * $monthWage[$wageType];
- if ($chromaData['total'] <= 0) {
- continue;
- }
- // 找到对应记录并更新
- foreach ($this->monthlyCostDetails as &$detail) {
- if ($detail['车间名称'] === $workshop) {
- $chroma = floatval($detail['班组车头产量']) * floatval($detail['sczl_ms']);
- $perAmount = round($chroma / $chromaData['total'] * $money, 2);
- if ($fieldName === '车间人工') {
- $detail['车间人工'] += $perAmount;
- } else {
- $detail['部门人工附加'] += $perAmount;
- }
- }
- }
- }
- }
- /**
- * 获取工资比例
- */
- protected function getWageRatio(string $month): array
- {
- // 从缓存数据中计算
- $workshopTotals = [];
- foreach ($this->monthlyCostDetails as $detail) {
- $workshop = $detail['车间名称'];
- $amount = floatval($detail['人工分摊因子']);
- if (!isset($workshopTotals[$workshop])) {
- $workshopTotals[$workshop] = 0;
- }
- $workshopTotals[$workshop] += $amount;
- }
- $total = array_sum($workshopTotals);
- if ($total <= 0) {
- return [];
- }
- $ratios = [];
- foreach ($workshopTotals as $workshop => $workshopTotal) {
- $ratios[$workshop] = round($workshopTotal / $total, 4);
- }
- return $ratios;
- }
- /**
- * 5. 计算分摊水电
- */
- protected function calculateApportionedUtilities(array $param): void
- {
- $month = $param['month'];
- $sysId = $param['sys_id'] ?? '';
- // 获取分摊水电数据
- $utilityData = Db::name('成本_各月水电气')
- ->where('Sys_ny', $month)
- ->whereLike('费用类型', '%分摊%')
- ->select();
- if (empty($utilityData)) {
- return;
- }
- // 计算各机台的分摊金额
- $machineAllocations = $this->calculateMachineAllocations($utilityData, $month);
- // 生成分摊系数记录
- $this->generateAllocationFactors($machineAllocations, $month, $sysId);
- // 分配到工单
- $this->allocateUtilitiesToWorkOrders($machineAllocations, $month);
- }
- /**
- * 计算机台分摊金额
- */
- protected function calculateMachineAllocations(array $utilityData, string $month): array
- {
- $allocations = [];
- // 先按设备编号分组计算总机时
- $machineHours = $this->getMachineHours($month);
- // 按科目处理分摊
- foreach ($utilityData as $item) {
- $subject = $this->simplifySubjectName($item['科目名称']);
- $amount = $this->calculateUtilityAmount($item);
- if ($amount <= 0) {
- continue;
- }
- // 根据科目类型选择分摊方式
- if ($subject === '待分摊总额') {
- $this->allocateByFloor($allocations, $amount, $machineHours, $month);
- } elseif (in_array($subject, ['锅炉', '热水锅炉'])) {
- $this->allocateToRollCoater($allocations, $amount, $machineHours, $month);
- } else {
- $this->allocateGlobally($allocations, $amount, $machineHours);
- }
- }
- return $allocations;
- }
- /**
- * 获取机台运行时间
- */
- protected function getMachineHours(string $month): array
- {
- $hours = [];
- foreach ($this->monthlyCostDetails as $detail) {
- $machine = $detail['sczl_jtbh'];
- $hour = floatval($detail['占用机时']);
- if (!isset($hours[$machine])) {
- $hours[$machine] = 0;
- }
- $hours[$machine] += $hour;
- }
- return $hours;
- }
- /**
- * 按楼层分摊
- */
- protected function allocateByFloor(array &$allocations, float $amount, array $machineHours, string $month): void
- {
- // 按楼层分组
- $floorHours = ['1' => 0, '2' => 0];
- $floorMachines = ['1' => [], '2' => []];
- // 先计算每个楼层总机时
- foreach ($machineHours as $machine => $hours) {
- $floor = $this->getFloorByMachine($machine);
- if ($floor && isset($floorHours[$floor])) {
- $floorHours[$floor] += $hours;
- $floorMachines[$floor][] = $machine;
- }
- }
- // 按楼层比例分摊
- $totalFloorHours = array_sum($floorHours);
- if ($totalFloorHours <= 0) {
- return;
- }
- foreach ($floorHours as $floor => $hours) {
- if ($hours <= 0) continue;
- $floorAmount = $amount * ($hours / $totalFloorHours);
- // 在楼层内按机台分摊
- foreach ($floorMachines[$floor] as $machine) {
- if (!isset($allocations[$machine])) {
- $allocations[$machine] = [];
- }
- $machineAmount = round($floorAmount * ($machineHours[$machine] / $hours), 2);
- $allocations[$machine]['待分摊总额'] = ($allocations[$machine]['待分摊总额'] ?? 0) + $machineAmount;
- }
- }
- }
- /**
- * 只分摊到卷凹机组
- */
- protected function allocateToRollCoater(array &$allocations, float $amount, array $machineHours, string $month): void
- {
- // 筛选卷凹机组的机台
- $rollCoaterMachines = $this->filterRollCoaterMachines(array_keys($machineHours));
- $totalHours = 0;
- foreach ($rollCoaterMachines as $machine) {
- $totalHours += $machineHours[$machine];
- }
- if ($totalHours <= 0) {
- return;
- }
- foreach ($rollCoaterMachines as $machine) {
- if (!isset($allocations[$machine])) {
- $allocations[$machine] = [];
- }
- $machineAmount = round($amount * ($machineHours[$machine] / $totalHours), 2);
- $allocations[$machine]['锅炉'] = ($allocations[$machine]['锅炉'] ?? 0) + $machineAmount;
- }
- }
- /**
- * 全局分摊
- */
- protected function allocateGlobally(array &$allocations, float $amount, array $machineHours): void
- {
- $totalHours = array_sum($machineHours);
- if ($totalHours <= 0) {
- return;
- }
- foreach ($machineHours as $machine => $hours) {
- if ($hours <= 0) continue;
- if (!isset($allocations[$machine])) {
- $allocations[$machine] = [];
- }
- $machineAmount = round($amount * ($hours / $totalHours), 2);
- $allocations[$machine][$this->getSubjectKey($amount)] = ($allocations[$machine][$this->getSubjectKey($amount)] ?? 0) + $machineAmount;
- }
- }
- /**
- * 根据机台获取楼层
- */
- protected function getFloorByMachine(string $machine): ?string
- {
- // 简化实现,实际应从数据库查询
- $groups = Db::name('设备_基本资料')
- ->where('设备编号', $machine)
- ->value('设备编组');
- if (!$groups) {
- return null;
- }
- foreach (self::FLOOR_GROUP_MAP as $floor => $groupNames) {
- foreach ($groupNames as $groupName) {
- if (strpos($groups, $groupName) !== false) {
- return $floor;
- }
- }
- }
- return null;
- }
- /**
- * 筛选卷凹机组的机台
- */
- protected function filterRollCoaterMachines(array $machines): array
- {
- $rollCoater = [];
- foreach ($machines as $machine) {
- $group = Db::name('设备_基本资料')
- ->where('设备编号', $machine)
- ->value('设备编组');
- if ($group && strpos($group, '03、卷凹机组') !== false) {
- $rollCoater[] = $machine;
- }
- }
- return $rollCoater;
- }
- /**
- * 简化科目名称
- */
- protected function simplifySubjectName(string $subject): string
- {
- $map = [
- '废气处理(RTO)' => '废气处理(RTO)',
- '锅炉' => '锅炉',
- '空压机' => '空压机',
- '热水锅炉' => '热水锅炉',
- '真空鼓风机' => '真空鼓风机',
- '中央空调' => '中央空调',
- '待分摊总额' => '待分摊总额',
- ];
- foreach ($map as $keyword => $simple) {
- if (strpos($subject, $keyword) !== false) {
- return $simple;
- }
- }
- return $subject;
- }
- /**
- * 计算水电金额
- */
- protected function calculateUtilityAmount(array $item): float
- {
- $electricity = floatval($item['耗电量'] ?? 0) * floatval($item['单位电价'] ?? 0);
- $gas = floatval($item['耗气量'] ?? 0) * floatval($item['单位气价'] ?? 0);
- return round($electricity + $gas, 2);
- }
- /**
- * 获取科目键名
- */
- protected function getSubjectKey(float $amount): string
- {
- // 简化的实现
- return '其他分摊';
- }
- /**
- * 生成分摊系数记录
- */
- protected function generateAllocationFactors(array $allocations, string $month, string $sysId): void
- {
- $now = date('Y-m-d H:i:s');
- foreach ($allocations as $machine => $subjects) {
- foreach ($subjects as $subject => $amount) {
- $this->allocationFactors[] = [
- 'Sys_ny' => $month,
- '科目名称' => $subject,
- '设备编号' => $machine,
- '分摊系数' => 1,
- '分摊金额' => $amount,
- 'Sys_id' => $sysId,
- 'Sys_rq' => $now,
- ];
- }
- }
- }
- /**
- * 分配水电到工单
- */
- protected function allocateUtilitiesToWorkOrders(array $machineAllocations, string $month): void
- {
- // 计算机台每机时费用
- $machineRates = $this->calculateMachineRates($machineAllocations);
- // 更新月度成本明细
- foreach ($this->monthlyCostDetails as &$detail) {
- $machine = $detail['sczl_jtbh'];
- $hours = floatval($detail['占用机时']);
- if ($hours <= 0 || !isset($machineRates[$machine])) {
- continue;
- }
- // 直接水电费
- $detail['直接水电'] = round($hours * 0.69, 2);
- // 分摊水电费
- foreach ($machineRates[$machine] as $subject => $rate) {
- $field = $this->getUtilityFieldName($subject);
- $detail[$field] = round($hours * $rate, 2);
- }
- }
- }
- /**
- * 计算机台每机时费用
- */
- protected function calculateMachineRates(array $allocations): array
- {
- $rates = [];
- $machineHours = [];
- // 先计算机台总机时
- foreach ($this->monthlyCostDetails as $detail) {
- $machine = $detail['sczl_jtbh'];
- $hours = floatval($detail['占用机时']);
- if (!isset($machineHours[$machine])) {
- $machineHours[$machine] = 0;
- }
- $machineHours[$machine] += $hours;
- }
- // 计算每机时费用
- foreach ($allocations as $machine => $subjects) {
- $totalHours = $machineHours[$machine] ?? 0;
- if ($totalHours <= 0) {
- continue;
- }
- $rates[$machine] = [];
- foreach ($subjects as $subject => $amount) {
- $rates[$machine][$subject] = round($amount / $totalHours, 4);
- }
- }
- return $rates;
- }
- /**
- * 获取水电字段名
- */
- protected function getUtilityFieldName(string $subject): string
- {
- $map = [
- '待分摊总额' => '分摊水电',
- '废气处理(RTO)' => '废气处理(RTO)',
- '锅炉' => '锅炉',
- '空压机' => '空压机',
- '热水锅炉' => '热水锅炉',
- '真空鼓风机' => '真空鼓风机',
- '中央空调' => '中央空调',
- ];
- return $map[$subject] ?? $subject;
- }
- /**
- * 统一保存所有数据
- */
- protected function saveAllData(string $month, string $sysId): void
- {
- $now = date('Y-m-d H:i:s');
- // 1. 删除旧数据
- Db::name('成本v23_月度成本明细')->where('sys_ny', $month)->delete();
- Db::name('成本_各月水电气')->where('Sys_ny', $month)->delete();
- Db::name('成本_各月分摊系数')->where('Sys_ny', $month)->delete();
- // 2. 插入新数据
- if (!empty($this->monthlyCostDetails)) {
- $sql = Db::name('成本v23_月度成本明细')->fetchSql(true)->insertAll($this->monthlyCostDetails);
- Db::query($sql);
- }
- if (!empty($this->monthlyUtilities)) {
- $sql = Db::name('成本_各月水电气')->fetchSql(true)->insertAll($this->monthlyUtilities);
- Db::query($sql);
- }
- if (!empty($this->allocationFactors)) {
- $sql = Db::name('成本_各月分摊系数')->fetchSql(true)->insertAll($this->allocationFactors);
- Db::query($sql);
- }
- }
- }
|