PDM更新数据结构后,基础数据查询和BOM初始查询等基本功能都已经OK,待完善和细化相关的上传和下载服务等。

This commit is contained in:
panx
2024-12-29 22:18:05 +08:00
parent d3d429e964
commit d70fcccc1d
99 changed files with 4877 additions and 948 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_footprint
* <!--partmanage-->
* 封装设计
* Class PdmFootprint
* @package app\admin\model
*/
class PdmFootprint extends Model
{
use SoftDelete;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind nickname,name
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['nickname','name']);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_mfg_name
* <!--partmanage-->
* 制造商名录
* Class PdmMfgName
* @package app\admin\model
*/
class PdmMfgName extends Model
{
use SoftDelete;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind nickname
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['nickname']);
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_partitem_index
* <!--partmanage-->
* Partnumber管理
* Class PdmPartitemIndex
* @package app\admin\model
*/
class PdmPartitemIndex extends Model
{
use SoftDelete;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind nickname,name
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['nickname','name']);
}
/**
* 定义 sa_admin 关联模型
* @localKey parttypeid
* @bind name
*/
public function parttype()
{
return $this->hasOne(\app\admin\model\PdmParttype::Class,'id','parttypeid')->bind(['name']);
}
/**
* 定义 sa_admin 关联模型
* @localKey parttypeid
* @bind name
*/
public function mfgname()
{
return $this->hasOne(\app\admin\model\PdmMfgName::Class,'id','mfg_id')->bind(['mfgname']);
}
public function setPartattributeAttr($value)
{
if (!empty($value) && is_array($value)) {
$arr = [];
foreach ($value['key'] as $key => $elem) {
$arr[$elem] = $value['value'][$key];
}
$value = json_encode($arr,JSON_UNESCAPED_UNICODE);
}
return $value ?: json_encode([]);
}
public function getPartattributeAttr($value)
{
if (!empty($value) && is_string($value)) {
$value = json_decode($value, true);
}
return $value;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_partitem_relation
* <!--partmanage-->
* PN关系维护
* Class PdmPartitemRelation
* @package app\admin\model
*/
class PdmPartitemRelation extends Model
{
use SoftDelete;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind name,nickname
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['name','nickname']);
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace app\admin\model;
use think\Model;
/**
* pdm_partitem_view
* <!--partview-->
* PN查询
* Class PdmPartitemView
* @package app\admin\model
*/
class PdmPartitemView extends Model
{
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,87 @@
<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_partlist
* <!--partlist-->
* BOM查询
* Class PdmPartlist
* @package app\admin\model
*/
class PdmPartlist extends Model
{
use SoftDelete;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind name,nickname
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['name','nickname']);
}
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind name,nickname
*/
public function partitemview()
{
return $this->hasOne(\app\admin\model\PdmPartitemView::Class,'partnumber','partnumber')->bind(['purchasecode','parttype','value','description','mpn','mfgname','footprint','manufacture']);
}
// 字段修改器
public function setSortAttr($value)
{
if (is_empty($value)) {
return self::max('id') + 1;
}
return $value;
}
/**
* 获取字典信息
* @param string $value
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function getValueList(string $value = ''): array
{
$list = [];
$data = self::where(['pid' => 0,'value' => $value])->find();
if (!empty($data)) {
$list = self::where('pid', $data['id'])->select()->toArray();
}
return $list;
}
/**
* 返回最小id
* @return int
*/
public static function minId(): int
{
return (int)self::where('pid', '0')->min('id');
}
}

View File

@@ -7,7 +7,7 @@ use think\model\concern\SoftDelete;
/**
* pdm_parttype
* <!---->
* <!--partmanage-->
* 分类目录
* Class PdmParttype
* @package app\admin\model
@@ -22,46 +22,38 @@ class PdmParttype extends Model
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_user 关联模型
* @localKey id
* @bind name,nickname
*/
public function user()
{
return $this->hasOne(\app\common\model\system\User::Class,'createrid','id')->bind(['nickname']);
}
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind nickname
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['nickname']);
}
public function usernames()
{
// return \app\common\model\system\User::select()->toArray();
return \app\common\model\system\Admin::select()->toArray();
}
public function setAttributeAttr($value)
{
if (!empty($value) && is_array($value)) {
$arr = [];
foreach ($value['key'] as $key => $elem) {
$arr[$elem] = $value['value'][$key];
}
public function setPartattributeAttr($value)
{
if (!empty($value) && is_array($value)) {
$arr = [];
foreach ($value['key'] as $key => $elem) {
$arr[$elem] = $value['value'][$key];
}
$value = json_encode($arr,JSON_UNESCAPED_UNICODE);
}
$value = json_encode($arr,JSON_UNESCAPED_UNICODE);
}
return $value ?: json_encode([]);
}
return $value ?: json_encode([]);
}
public function getAttributeAttr($value)
{
if (!empty($value) && is_string($value)) {
$value = json_decode($value, true);
}
public function getPartattributeAttr($value)
{
if (!empty($value) && is_string($value)) {
$value = json_decode($value, true);
}
return $value;
}
return $value;
}
}

View File

@@ -6,13 +6,13 @@ use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_partitem
* <!---->
* 部件
* Class PdmPartitem
* pdm_purchasecode
* <!--partmanage-->
* 采购编码
* Class PdmPurchasecode
* @package app\admin\model
*/
class PdmPartitem extends Model
class PdmPurchasecode extends Model
{
use SoftDelete;
@@ -22,18 +22,18 @@ class PdmPartitem extends Model
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_user 关联模型
* @localKey createrid
* @bind nickname,name
*/
public function user()
{
return $this->hasOne(\app\common\model\system\User::Class,'id','createrid')->bind(['nickname','name']);
}
/**
* 定义 sa_admin 关联模型
* @localKey creatorid
* @bind nickname
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['nickname']);
}
public function setPartattributeAttr($value)
public function setAttributeAttr($value)
{
if (!empty($value) && is_array($value)) {
$arr = [];
@@ -47,7 +47,7 @@ class PdmPartitem extends Model
return $value ?: json_encode([]);
}
public function getPartattributeAttr($value)
public function getAttributeAttr($value)
{
if (!empty($value) && is_string($value)) {
$value = json_decode($value, true);

View File

@@ -0,0 +1,38 @@
<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* pdm_symbol
* <!--partmanage-->
* 原理符号
* Class PdmSymbol
* @package app\admin\model
*/
class PdmSymbol extends Model
{
use SoftDelete;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
/**
* 定义 sa_admin 关联模型
* @localKey createrid
* @bind nickname
*/
public function admin()
{
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['nickname']);
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\partlist;
use think\Model;
/**
* BOM管理模型类
* <!--Partlist-->
* @mixin Model
*/
class Partlist extends Model
{
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updatetime = 'update_time';
/**
* 字段修改器
* @param $value
* @return int|mixed
*/
public function setSortAttr($value)
{
if (is_empty($value)) {
return self::max('id') + 1;
}
return $value;
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\partview;
use think\Model;
/**
* 部件查询模型类
* <!--Partview-->
* @mixin Model
*/
class Partview extends Model
{
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updatetime = 'update_time';
/**
* 字段修改器
* @param $value
* @return int|mixed
*/
public function setSortAttr($value)
{
if (is_empty($value)) {
return self::max('id') + 1;
}
return $value;
}
}