阿基米德常用方法

一、未解决

1、多选框的使用

二、解决

一、后端

1、多条件查询

from Nkd.Foundation.Common.LogicaxOperator import LogicalOperator
from Nkd.Foundation.Common.FieldOperator import FieldOperator
from Nkd.Foundation.BusinessObjects.QueryObject.Filter import Filter, FilterCollection
 containerStorageBinCollection=ContainerStorageBinCollection()
                    fc = FilterCollection()
                    f = Filter()
                    f.Name = "SourceEntityId"
                    f.Value = i.SourceEntity  # type:ignore
                    f.Operator = FieldOperator.IsEqualTo
                    f.LogicalOperator = LogicalOperator.AND
                    f1 = Filter()
                    f1.Name = "UniversalState"
                    f1.Value = 2  # type:ignore
                    f1.Operator = FieldOperator.IsEqualTo
                    f1.LogicalOperator = LogicalOperator.AND
                    fc.append(f)
                    fc.append(f1)
                    containerStorageBinCollection.LoadByFilter(fc) // 
                    for i in containerStorageBinCollection:
                        containerStorageBin= ContainerStorageBin()
                        containerStorageBin.Id=i.Id
                        containerStorageBin.Load()
                        containerStorageBin.UniversalState = 4
                        containerStorageBin.Save()

2、sql 和Load() 查询

 from Nkd.Foundation.Common.CallContext import CallContextManager
    sql_execute = CallContextManager.GetCurrentCallContext().DbSession
    sql4='''SELECT * from  DataModel_T_ContainerStorageBin'''
    firstresult = sql_execute.execute(sql4)
    firstrows = firstresult.fetchall()
    print('ddd',firstrows)
#Load():                    
containerStorageBin= ContainerStorageBin()
                storageBin=StorageBin()
                storageBin.Name = i.Name.split('/')[1]
                storageBin.Load()                    
                            

sql时间模块

  SELECT DATE_SUB(now(),INTERVAL 1 HOUR) result;
  select  date1  from date where  date(date1)>=DATE_SUB(curdate(),INTERVAL 7 day) 
	                                  and date(date1)<=DATE_SUB(curdate(),INTERVAL 1 HOUR)

查询2021年8月的数据:

where
-- Year(date) ='2021' and month(date)= '8'
-- date_format(date,'%Y-%m')= '2021-08'
-- SUBSTRING_INDEX(date,'-',2)= '2021-08'
-- substring_index(“待截取有用部分的字符串”,“截取数据依据的字符”,截取字符的位置N)
SUBSTRING(date,1,7)= '2021-08'
substring():截取字符串中介于两个指定下标之间的字符
字符串.substring(参数1,参数2);参数1:字符串截取的起始下标,非负的整数,如果此参数是0,则是从字符串的第一个字符开始截取,参数2:截取结束位置的索引下标,注意:截取的结果,不包括结束位置的字符
-- LEFT(date,7) ='2021-08' 

3、name生成器

#1、不使用变量:
from Nkd.Foundation.BusinessObjects.NameGenerator import NameGenerator
 order_name_generator = NameGenerator()
                order_name_generator.Name = "ContainerStorageBinNameGenerator"
                containerStorageBin.Name = order_name_generator.GenerateName()
#2、使用变量?

4、query

getObjectByNamePort(name):Observable { const executeQueryInput = new newlbo.Nkd.Foundation.BusinessOrchestration.QueryManagement.InputObjects.ExecuteQueryInput; const filterCollection: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.FilterCollection = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.FilterCollection(); // Filter filter_0 const filter_0: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Filter = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Filter(); filter_0.Name = "Name"; filter_0.ObjectName = "Container"; filter_0.ObjectAlias = "Container"; filter_0.Operator = newlbo.Nkd.Foundation.Common.FieldOperator.IsEqualTo; filter_0.Value = name; filter_0.LogicalOperator = newlbo.Nkd.Foundation.Common.LogicalOperator.Nothing; filter_0.FilterType = newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Enums.FilterType.Normal; filterCollection.push(filter_0) const fieldCollection: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.FieldCollection = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.FieldCollection(); // Field field_0 const field_0: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Field = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Field(); field_0.Alias = 'ContainerName'; field_0.ObjectName = 'Container'; field_0.ObjectAlias = 'Container'; field_0.IsUserAttribute = false; field_0.Name = 'Name'; field_0.Position = 0; field_0.Sort = newlbo.Nkd.Foundation.Common.FieldSort.NoSort; fieldCollection.push(field_0) const relationCollection: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.RelationCollection = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.RelationCollection(); const relation_1: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Relation = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Relation(); relation_1.Alias = ""; relation_1.IsRelation = false; relation_1.Name = ""; relation_1.SourceEntity = "Container"; relation_1.SourceEntityAlias = "Container"; relation_1.SourceJoinType = newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Enums.JoinType.LeftJoin; relation_1.SourceProperty = "ContainerId"; relation_1.TargetEntity = "ContainerStorageBin"; relation_1.TargetEntityAlias = "ContainerStorageBin"; relation_1.TargetJoinType = newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Enums.JoinType. LeftJoin; relation_1.TargetProperty = "SourceEntityId"; relationCollection.push(relation_1) const query: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.QueryObject = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.QueryObject(); query.Description = ""; query.EntityTypeName = "Container"; query.Name = "Container"; query.Query = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Query(); query.Query.Distinct = false; query.Query.Filters = filterCollection; query.Query.Fields = fieldCollection; query.Query.Relations = relationCollection; query.Query.Top = 0; executeQueryInput.QueryObject = query; return this.http .post(commonApi.getQueryListApi, executeQueryInput, {}, { headers: new HttpHeaders({}) })
### 5、端口占用
一、问题:OSError: [Errno 98] Address already in use
解决:sudo lsof -i:(port) 
 	 sudo kill (PID)

6、git步骤:

git init 
git status
git pull
git add Nkd/Custom
git add Tools/MasterDataBuilder/MasterData/CustomData
后段上传这两个文件夹:
Nkd/Custom
Tools/MasterDataBuilder/MasterData/CustomData
Feeder优化

![img](file:///D:/培训文件/WXWork/1688856445354591/Cache/Image/2022-10/企业微信截图_1665540565632.png)


git restore

7、后端2.5导入数据后报错:Error 111 connecting to localhost:6379. Connection refused

运行:sudo apt-get install redis

8、后端客制化命令

生成models.ts:
python3 Tools/ClientCodeGenerator/ClientCodeGenerator.pyc

9、解决前端过站报错:(本质:数据库的信息覆盖了修改的文件)

git restore 

10、VPN

账号:nokida 
密码:IGBT@yt2020

二、前端

1、接口传值

 updateWarehouseLocation(date,i): Observable<any> {
        const ContainerStorageBinDateInput = new newlbo.Nkd.Custom.BusinessOrchestration.ScaleboardQueryManagement.InputObjects.UpdateWarehouseLocationInput
        const ContainerStorageBinCollection =new newlbo. Nkd.Venus.BusinessObjects.ContainerStorageBinCollection()
        date.forEach(item=>{
            const ContainerStorageBin = new newlbo.Nkd.Venus.BusinessObjects.ContainerStorageBin()
            ContainerStorageBin.Name = item.ContainerName+'/'+item.newWarehouseLocation
            ContainerStorageBin.SourceEntity= item.ContainerId
            ContainerStorageBin.TargetEntity = item.StorageBinId
            // ContainerName: 'M1E1H22XX001', StorageBinName: 'N201-1-01', ContainerId: '1555024017411411968', StorageBinId: '1554280608778293248'
            ContainerStorageBinCollection.push(ContainerStorageBin)
        })
        ContainerStorageBinDateInput.ContainerStorageBin=ContainerStorageBinCollection
        ContainerStorageBinDateInput.flag = i;
        const ContainerStorageBinDateInputStr = newlbo.LboJson.stringify(ContainerStorageBinDateInput);
        return this.http
            .post(containerApi.UpdateWarehouseLocationApi,JSON.parse(ContainerStorageBinDateInputStr), {}, {});
    }

2、对话框

 this.modal.confirm({
                            nzTitle: '<i>您确定执行绑定操作吗?</i>',
                            // nzContent: '<b>Some descriptions</b>',
                            nzOnOk: () => {
                                console.log(this.ContainerList);
                                this.updatedata(e);
                            }
                        });
                        
刷新表单:
import { Component, OnInit, ViewChild } from '@angular/core';
import { STColumn, STChange, ReuseTabService, STComponent, STColumnBadge } from '@delon/abc';
export class ScaleboardQueryComponent implements OnInit {
    @ViewChild('st', { static: false }) private st: STComponent;
 this.st.reload();  
 
  columns: STColumn[] = [
        { title: '序号', index: '', width: '1%' },
        { title: '托盘号', index: 'name', width: '5%' },
        { title: '现有库位号', index: 'oldFacilityId', width: '8%' },
        { title: '新绑定库位号', index: 'newFacilityId', width: '5%' },]

html:
st标签:
  <st #st [data]="" [columns]="columns_Container" [ps]="5" [scroll]="{x:'100%'}"
                [widthMode]="{type:'strict',strictBehavior:'warp'}" size="small" bordered="true"
                [page]="{ front: true, show: true, showSize: true, pageSizes: [5,10,20,50,100] }">
 </st>

3、帆软-打印

const url = FineReportApi.FineReportIp;  // 帆软IP
                console.log('打印批次号:',materialNameList);
                window.open(url + '/webroot/decision/view/report?viewlet=archimedes%252Fprint-晶圆绷膜标签.cpt' + '&批次号=' + materialNameList)
                this.message.success(res.MESSAGE)

4、导出

1.ng-alain:Excel 操作

2.阿基米徳:query-management->product-defect-query
 // 导出
  <st #st1 [data]="ContainerStorageBinList" [columns]="columns_Container" [ps]="5" [scroll]="{x:'100%'}"
                [widthMode]="{type:'strict',strictBehavior:'warp'}" size="small" bordered="true"
                [page]="{ front: true, show: true, showSize: true, pageSizes: [5,10,20,50,100] }">
 </st>
            
@ViewChild('st1', { static: false }) private st1: STComponent; 
 
if(this.ContainerStorageBinList.length!==0){
            console.log('ContainerStorageBinList',this.ContainerStorageBinList);
            this.st1.export(this.ContainerStorageBinList, {filename: '托盘绑定信息.xlsx', sheetname: '托盘绑定信息'});
            
        }

5、表格下方添加一行总计

image-20221214113327511

  <st #st [data]="data" [columns]="columns" [body]="bodyTpl">
      <ng-template #bodyTpl let-s>
        <ng-container *ngIf="st.count > 0">
          <tr>
            <td>合计</td>
            <td>{{ s.len.text }} 个</td>
            <td>{{ s.dc.text }}</td>
            <td class="text-right">{{ s.sum.text }}</td>
            <td class="text-right">{{ s.avg.text }}</td>
            <td class="text-right">{{ s.min.text }}</td>
            <td class="text-right">{{ s.max.text }}</td>
            <td class="text-right">{{ s.custom.text }}</td>
          </tr>
          <tr class="bg-grey-lighter">
            <td colspan="3">性别平均值</td>
            <td class="text-right">{{ s.sum.value / s.len.value | price }}</td>
            <td colspan="4"></td>
          </tr>
        </ng-container>
      </ng-template>
    </st>
 [columns]="columns":
    { title: 'Min', index: 'price', type: 'currency', statistical: 'min', key: 'min' },
    { title: 'Max', index: 'price', type: 'currency', statistical: 'max', key: 'max' },
    {
      title: 'Custom',
      index: 'price',
      type: 'currency',
      statistical: { type: values => ({ value: values[0], text: `**${values[0]}` }), currency: false },
      key: 'custom',
    }

6、前端初始加载配置文件

  1. 前端导入依赖库的时候出现以下错误使用npm install --legacy-peer-deps或者npm install -force

7、导出添加导出本页和导出全部

<!-- 导出开始 -->
                    <button style="width: 70px; margin-left: 10px" nz-button nz-dropdown [nzDropdownMenu]="menu">导出<i nz-icon nzType="down"></i></button>
                    <nz-dropdown-menu #menu="nzDropdownMenu">
                        <ul nz-menu>
                            <li nz-menu-item (click)="export(st,0)">
                                导出本页
                            </li>
                            <li nz-menu-item (click)="export(st,1)">
                                导出全部
                            </li>
                        </ul>
                    </nz-dropdown-menu>
  <!-- 导出结束 -->
  
  this.st.export(this.checkedArr, { filename: '领料审批数据.xlsx', sheetname: '领料审批数据' }); 

8、去重:思想,把需要的Name放进集合,后用filter筛当前选索引和数据第一次出现的索引是否一致

 // 获取物料编码
    GetProducts() {
        this.recoilapi.GetSimplifyEntity('Product').subscribe((res) => {
            const data=res.NgpDataSet.T_Result;
            let NameDatas=[]  
         	data.forEach(v=>{NameDatas.push(v.Name)}) // 把name放进集合
            NameDatas=NameDatas.filter((x,index,self)=>self.indexOf(x)===index) // 去重
            console.log(NameDatas);
            this.Products = res.NgpDataSet.T_Result;
            // console.log(this.Products);
        }, (err) => {
        });
    }

引申:怎末给[{id:“123”,Name:“张山”},{id:“123”,Name:“张山”},{id:“124”,Name:“李四”}] 去重

9、解决后端传值为null时,len()方法报错:设置属性为空时aa='',不设置为aa=null

10、st表格:

10.1 :columns: STColumn[] = []

1.1日期格式化:
 {
            title: 'Loss时间', index: 'TimeName', width: '10%', className: 'text-center',
            format: item => !item.TimeName ? '' :
                moment(item.TimeName).utcOffset(0).format('YYYY-MM-DD HH:mm')
        },
1.2 :数据格式化
  format: item => `${Number(item.InProgressQuantity).toFixed(1)}`,
    {
            title: this.TableBaseInfoModel.InProgressQuantity,
            width:'6%',
            index: 'InProgressQuantity',
            format: item => `${Number(item.InProgressQuantity).toFixed(1)}`,
            type: 'currency',statistical:{ type: 'sum',digits:3,currency: false }, key: 'sum1'  #合计属性
        },

11、Query查询

11.1 模糊筛选

  const filter_1: newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Filter = new newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Filter();
        filter_1.Name = "Name";
        filter_1.ObjectName = "Flow";
        filter_1.ObjectAlias = "Flow";
        filter_1.Operator = newlbo.Nkd.Foundation.Common.FieldOperator.NotLike;
        filter_1.Value = "not like '%发料流程'";
        filter_1.LogicalOperator = newlbo.Nkd.Foundation.Common.LogicalOperator.AND;
        filter_1.FilterType = newlbo.Nkd.Foundation.BusinessObjects.QueryObject.Enums.FilterType.Normal;

12、过站报错:list index out of range

消耗设备

13、虚拟滑动: virtualScroll [scroll]="{ x: '10px', y: '400px' }"

<st #st [data]="data" [columns]="columns" [widthMode]="{type:'strict',strictBehavior:'warp'}" bordered="true"
 ps="10" [page]="{ front: true, show: true, showSize: true, pageSizes: [10, 20, 30, 40, 50,100] }"
 virtualScroll [scroll]="{ x: '10px', y: '400px' }"
[loading]= "loading" size="small"></st>

出现问题:后端几条数据无法显示

image-20230202090858374

解决:

最终方案:当设置的页面高度超过设定的高度,就会出现滑动拦

overflow 属性规定当内容溢出元素框时发生的事情。auto:如果内容被修剪,则浏览器会显示滚动条以便查看其余的内容。

<div class="top-wafer" style = 'overflow:auto;height:410px' >
   <st #st [data]="OrderData" 
   [columns]="columns" 
   [widthMode]="{type:'strict'}" 
   bordered="true"
   ps="20" 
   [page]="{ front: true, show: true, showSize: true, pageSizes: [10, 20, 30, 40, 50] }"
   [scroll]="{x:'100%'}" 
   [loading]="loading" 
   size="small" 
   (change)="_click($event)">
   </st>

14、取消输入框的只读设置,但是ngModel拿不到数据

解决:添加一个ngModelChange,为后端重新复制。(ngModelChange)='ProductNamechange($event)',

posted @   苍白之躯  阅读(88)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示