记下这些代码吧,成本太高昂,付出的不止是时间、精力……
人员登录帐号问题:
- 项目初始由其他手工录入
- 创建流程时并没核对帐号、没有整理流程人员对应关系表
- 流程测试时,发现缺少帐号
- 而后同步
- 填补自己挖的坑
哪个环节出问题了?
客户最终要的能使用的系统,而不是再配置的系统!
- 缺少把控人员
- 不能只管自己的一亩三分地
- 项目全局考虑
- 由一人负责某一模块完整功能
- 功能有边界时,我来做
- 沟通、沟通、还是沟通
- 不要模糊,要精准要求
- 代码上能得过且过吗?
- 这个世界是个草台班子,恰好我是其中一员
- 致良知
<?php namespace app\home\controller\Work; use app\common\controller\Again; use think\Db; class FixedSelf extends Again { private function clean() { $sql = "update zthc_user_list set user_name=trim(user_name),self_dept_name=trim(self_dept_name),master_dept_name=trim(master_dept_name),rule_name=trim(rule_name),yushu_name=trim(yushu_name);"; Db::table("zthc_user_list")->execute($sql); $list = Db::table("zthc_user_list")->select(); foreach ($list as $val) { $selfDeptArr = explode(',', $val['self_dept_name']); $selfDeptArr = array_unique($selfDeptArr); $selfDeptStr = implode(',', $selfDeptArr); $masterArr = isset($selfDeptArr[0]) ? explode(' ', $selfDeptArr[0]) : []; $masterStr = ""; if ($masterArr) { $masterStr = $masterArr[0] ?? $masterArr[1]; } $ruleArr = explode(',', $val['rule_name']); $ruleArr = array_unique($ruleArr); $ruleStr = implode(',', $ruleArr); $yushuArr = explode(',', $val['yushu_name']); $yushuArr = array_unique($yushuArr); $yushuStr = implode(',', $yushuArr); Db::table("zthc_user_list")->where("id", $val['id'])->update( [ 'self_dept_name' => $selfDeptStr, 'master_dept_name' => $masterStr, 'rule_name' => $ruleStr, 'yushu_name' => $yushuStr, ] ); } return count($list); } public function getName($name) { return Db::table("zthc_user_list")->where("user_name", $name)->find(); } public function insertName($dataArr, $rule, $yushu) { $rule = trim($rule); $yushu = trim($yushu); return Db::table("zthc_user_list")->insertGetId([ 'user_name' => trim($dataArr[0]), 'self_dept_name' => trim($dataArr[1]) . (isset($dataArr[2]) ? " " . trim($dataArr[2]) : ""), 'master_dept_name' => trim($dataArr[1]) . (isset($dataArr[2]) ? " " . trim($dataArr[2]) : ""), 'rule_name' => $rule, 'yushu_name' => $yushu, ]); } public function updateName($data, $dataArr, $rule, $yushu) { $rule = trim($rule); $yushu = trim($yushu); $dept = trim($dataArr[1]) . (isset($dataArr[2]) ? " " . trim($dataArr[2]) : ""); if (strstr($data['self_dept_name'], $dept) === false) { $dept = $data['self_dept_name'] . ',' . $dept; } if (strstr($data['rule_name'], $rule) === false) { $rule = $data['rule_name'] . ',' . $rule; } if (strstr($data['yushu_name'], $yushu) === false) { $yushu = $data['yushu_name'] . ',' . $yushu; } return Db::table("zthc_user_list")->where("id", $data['id'])->update([ 'user_name' => $dataArr[0], 'self_dept_name' => $dept, 'master_dept_name' => $dept, 'rule_name' => $rule, 'yushu_name' => $yushu, ]); } public function add() { $step = 3; switch ($step) { case 1: // 过滤 echo '<pre>', str_replace([",", "、", ";", "。", ";"], ' ', " "), '</pre>'; break; case 2: // 入库 $str = " "; $rule = "无"; $yushu = "无"; $arr = explode("\n", $str); $find = []; $new = []; foreach ($arr as $val) { $val = trim($val); if (!$val) { continue; } $dataArr = explode(' ', $val); $old = $this->getName($dataArr[0]); if ($old) { $id = $this->updateName($old, $dataArr, $rule, $yushu); $find[] = $val . "=>\t" . $id; } else { $id = $this->insertName($dataArr, $rule, $yushu); $new[] = $val . "=>\t" . $id; } } foreach ($find as $val) { echo $val, '<br />'; } echo '<hr>'; foreach ($new as $val) { echo $val, '<br />'; } break; case 3: // 清理 去重 echo 'clean ', $this->clean(); break; } return ''; } }