FId一览

This commit is contained in:
CRM8000 2023-08-24 15:14:16 +08:00
parent dd32e82f35
commit db996709dd
4 changed files with 1 additions and 323 deletions

View File

@ -1,76 +0,0 @@
<?php
namespace Home\Controller;
use Home\Common\FIdConst;
use Home\Service\FIdListService;
use Home\Service\UserService;
/**
* FId一览Controller
*
* @author PSI
* @copyright 2015 - present
* @license GPL v3
*/
class FIdListController extends PSIBaseController
{
/**
* FId一览 - 主页面
*
* web\Application\Home\View\FIdList\index.html
*/
public function index()
{
$us = new UserService();
if ($us->hasPermission(FIdConst::FID_LIST)) {
$this->initVar();
$this->assign("title", "FId一览");
$this->display();
} else {
$this->gotoLoginPage("/Home/FIdList");
}
}
/**
* 查询全部FId数据
*/
public function fidList()
{
if (IS_POST) {
$us = new UserService();
if (!$us->hasPermission(FIdConst::FID_LIST)) {
die("没有权限");
}
$service = new FIdListService();
$this->ajaxReturn($service->fidList());
}
}
/**
* 编辑fid
*/
public function editFId()
{
if (IS_POST) {
$us = new UserService();
if (!$us->hasPermission(FIdConst::FID_LIST)) {
die("没有权限");
}
$params = [
"fid" => I("post.fid"),
"code" => I("post.code"),
"py" => I("post.py"),
];
$service = new FIdListService();
$this->ajaxReturn($service->editFId($params));
}
}
}

View File

@ -1,180 +0,0 @@
<?php
namespace Home\DAO;
/**
* FId一览 DAO
*
* @author PSI
* @copyright 2015 - present
* @license GPL v3
*/
class FIdListDAO extends PSIBaseExDAO
{
private function getSlnInfo($slnCode)
{
$db = $this->db;
$sql = "select name from t_solution where code = '%s' ";
$data = $db->query($sql, $slnCode);
if ($data) {
$name = $data[0]["name"];
return "{$slnCode} - {$name}";
} else {
return "[SLN编码未定义]";
}
}
/**
* 查询全部FId数据
*/
public function fidList()
{
$db = $this->db;
$result = [];
// t_fid中的均为系统固有
$category = "系统固有";
$sql = "select fid, code, py, name, sln_code from t_fid order by fid";
$data = $db->query($sql);
foreach ($data as $v) {
$result[] = [
"fid" => $v["fid"],
"code" => $v["code"],
"name" => $v["name"],
"py" => $v["py"],
"category" => $category,
"sln" => $this->getSlnInfo($v["sln_code"]),
];
}
// t_fid_plus 由码表设置、自定义表单、视图开发助手等模块添加的Fid
$sql = "select fid, code, py, name, sln_code from t_fid_plus order by fid";
$data = $db->query($sql);
foreach ($data as $v) {
$fid = $v["fid"];
$item = [
"fid" => $fid,
"code" => $v["code"],
"name" => $v["name"],
"py" => $v["py"],
];
$category = "";
$sln = "";
if (substr($fid, 0, 2) == "ct") {
// 码表
$category = "码表";
$sql = "select s.name, m.sln_code
from t_code_table_md m, t_solution s
where m.sln_code = s.code and m.fid = '%s' ";
$d = $db->query($sql, $fid);
if ($d) {
$n = $d[0]["name"];
$c = $d[0]["sln_code"];
$sln = "{$c} - {$n}";
} else {
$sln = "未查询到解决方案";
}
} else {
// TODO 其他模块的查询逻辑
$category = "待处理";
}
$item["category"] = $category;
$item["sln"] = $sln;
$result[] = $item;
}
return $result;
}
/**
* 编辑fid
*/
public function editFId(&$params)
{
$db = $this->db;
$fid = $params["fid"];
$code = strtoupper(trim($params["code"]));
$py = strtoupper(trim($params["py"]));
if (!$fid) {
return $this->badParam("fid");
}
if (!$py) {
return $this->bad("拼音字头不能为空");
}
$sql = "select count(*) as cnt from t_fid where fid = '%s' ";
$data = $db->query($sql, $fid);
$cnt = $data[0]["cnt"];
if ($cnt == 1) {
$sql = "update t_fid
set code = '%s', py = '%s'
where fid = '%s' ";
$rc = $db->execute($sql, $code, $py, $fid);
if ($rc === false) {
return $this->sqlError(__METHOD__, __LINE__);
}
} else {
$sql = "select count(*) as cnt from t_fid_plus where fid = '%s' ";
$data = $db->query($sql, $fid);
$cnt = $data[0]["cnt"];
if ($cnt == 1) {
$sql = "update t_fid_plus
set code = '%s', py = '%s'
where fid = '%s' ";
$rc = $db->execute($sql, $code, $py, $fid);
if ($rc === false) {
return $this->sqlError(__METHOD__, __LINE__);
}
} else {
return $this->bad("fid:{$fid} 不存在");
}
}
// 同步主菜单中fid的code字段
$sql = "select count(*) as cnt from t_menu_item where fid = '%s' ";
$data = $db->query($sql, $fid);
$cnt = $data[0]["cnt"];
if ($cnt > 0) {
$sql = "update t_menu_item
set code = '%s'
where fid = '%s' ";
$rc = $db->query($sql, $code, $fid);
if ($rc === false) {
return $this->sqlError(__METHOD__, __LINE__);
}
} else {
// t_menu_item_plus
$sql = "select count(*) as cnt from t_menu_item_plus where fid = '%s' ";
$data = $db->query($sql, $fid);
$cnt = $data[0]["cnt"];
if ($cnt > 0) {
$sql = "update t_menu_item_plus
set code = '%s'
where fid = '%s' ";
$rc = $db->query($sql, $code, $fid);
if ($rc === false) {
return $this->sqlError(__METHOD__, __LINE__);
}
} else {
// 该fid没有挂接到主菜单中
}
}
// 操作成功
$params["log"] = "编辑fid{$fid} 的编码和拼音字头";
return null;
}
}

View File

@ -1,66 +0,0 @@
<?php
namespace Home\Service;
use Home\DAO\FIdListDAO;
use Home\DAO\SysDictDAO;
/**
* FId一览Service
*
* @author PSI
* @copyright 2015 - present
* @license GPL v3
*/
class FIdListService extends PSIBaseExService
{
private $LOG_CATEGORY = "FId一览";
/**
* 查询全部FId数据
*/
public function fidList()
{
if ($this->isNotOnline()) {
return $this->emptyResult();
}
$dao = new FIdListDAO($this->db());
return $dao->fidList();
}
/**
* 编辑fid
*/
public function editFId($params)
{
if ($this->isNotOnline()) {
return $this->notOnlineError();
}
if ($this->isDemo()) {
return $this->bad("演示环境下不能编辑fid");
}
$db = $this->db();
$db->startTrans();
$dao = new FIdListDAO($db);
$rc = $dao->editFId($params);
if ($rc) {
$db->rollback();
return $rc;
}
// 记录业务日志
$log = $params["log"];
$bs = new BizlogService($db);
$bs->insertBizlog($log, $this->LOG_CATEGORY);
$db->commit();
$fid = $params["fid"];
return $this->ok($fid);
}
}

View File

@ -4,8 +4,8 @@ namespace SLN0000\Controller;
use Home\Common\FIdConst;
use Home\Controller\PSIBaseController;
use Home\Service\FIdListService;
use Home\Service\UserService;
use SLN0000\Service\FIdListService;
/**
* FId一览Controller