[MySQL] Mold data transfer processing

series of articles

C# underlying library-MySQLBuilder script construction class (select, insert, update, in, automatic generation of SQL with conditions)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/129179216

C# underlying library – MySQL database operation auxiliary class (recommended reading)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/126886379

C# underlying library – the use of SQLite (small, local database)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/123666958

[Improve programming efficiency] Import Excel data into the database in batches
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/126427323

[Oracle] The database server restricts ip access to
this article link: https://blog.csdn.net/youcheng_ge/article/details/122220930

[Oracle] Excel Import Data Tutorial
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/118722756

[Oracle] Database Restore Tutorial_Data Pump
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/118054855

[SQL] How to query table fields and identify primary keys
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/110820405

[SQL] Usage of outer apply
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/79903489

[SQL] Multi-table connection duplicate data processing
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/79903619

MySQL installation tutorial (detailed)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/126037520

MySQL uninstall tutorial (detailed)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/129279265

[MySQL] How to add the "total" field for group by classification and summary?
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/128217837

[MySQL] Usage of WITH CHECK OPTION
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/128147196

[MySQL] How to improve efficiency by using stored procedures to insert tens of millions of data?
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/77728189

[MySQL] Realization of row and column transposition of database table
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/77625052

[MySQL] In the query, the NULL value is converted to an empty string
This link: https://blog.csdn.net/youcheng_ge/article/details/130381878


foreword

This column is [Database], which mainly introduces the functions and characteristics of SQL, SQL data definition language (table, view, index, constraint), SQL data operation language (data retrieval, data insertion, data deletion, data update), creation and deletion Triggers, SQL Data Control Language (Security and Authorization, Transaction Processing), and Embedded SQL.
If you are interested in this album, keep paying attention. If you have any questions, you can also give feedback in the comment area and private message me.
insert image description here

1. Technical introduction

1. Import all the detection data in Excel into [Mold Process Table (Local)] to form a journal, about 70,000 pieces of data 2.
Export the data that has been printed on the label in [Mold Information Table (MES Server)]
3. Transfer Save to [Mold Information Table (Local)]
4. The data in step 3, according to the conditions (supplier number, factory number, specification), update the [Mold Process Table (Local)] information field 5,
[Mold Information Table (Local) ], formatted data

6. [Mold information table (local)], data initialization:
① New mold,
SELECT mold supplier number, mold factory number, COUNT( ) as count FROM mold flow table GROUP BY mold supplier number, mold factory number HAVING COUNT( ) = 1;
Get the data of the new mold, and insert the result into 【Mold Information Table (Local)】

②Rework mold
SELECT * FROM mold flow table where AutoID In
(
SELECT Max(AutoID) as AutoID FROM mold flow table GROUP BY mold supplier number, mold factory number HAVING COUNT(*) > 1
)
to get the latest record data of the reworked mold , insert the result into 【Mold Information Table (Local)】

2. Test cases


-- 1、导入【模具流程表(本地)】
SELECT COUNT(*) FROM 模具返修流程表
69841-- 2、导出【模具信息表(MES服务端)】已经打印标签的数据
17904-- 3、转储至 【模具信息表(本地)】
SELECT COUNT(*) FROM 模具信息表 WHERE 模具打标录入时间>'1000-01-01'
17904-- 4、更新【模具流程表(本地)】信息字段
UPDATE 模具返修流程表 a
SELECT a.公司编号,a.工厂名称,a.存货编码,a.采购订单编号,a.模具类型,a.模具材质,
a.模具编号,a.模链编号,a.模芯规格,a.粒度,a.状态描述,a.模具打标时间,a.模具打标录入时间,
a.模具打标操作人编号,a.模具打标备注
FROM 模具返修流程表 a
INNER JOIN 模具信息表 b ON a.模具供应商编号 = b.模具供应商编号 
			AND a.模具出厂编号 = b.模具出厂编号 
			AND a.平均直径 = b.平均直径
-- SET a.公司编号 = b.公司编号,a.工厂名称 = b.工厂名称,a.存货编码 = b.存货编码,
-- a.采购订单编号 = b.采购订单编号,a.模具类型 = b.模具类型,a.模具材质 = b.模具材质,
-- a.模具编号 = b.模具编号,a.模链编号 = b.模链编号,a.模芯规格 = b.模芯规格,
-- a.粒度 = b.粒度,a.状态描述 = b.状态描述,a.模具打标时间 = b.模具打标时间,
-- a.模具打标录入时间 = b.模具打标录入时间,a.模具打标操作人编号 = b.模具打标操作人编号,
-- a.模具打标备注 = b.模具打标备注,a.库存状态 = b.库存状态,a.仓库编号 = b.仓库编号,
-- a.货位编号 = b.货位编号,a.模具首次入库时间 = b.模具首次入库时间
WHERE a.模具编号='空' AND a.平均直径>0;

平均直径 16581条
模具出厂直径 16810条
实际更新 16490


-- 6、【模具信息表(本地)】,数据初始化
-- ①新模具
SELECT * FROM 模具返修流程表 GROUP BY 模具供应商编号,模具出厂编号 HAVING COUNT(1) = 1;
65856

INSERT INTO `dl_mes`.`模具信息表`(`公司编号`, `工厂名称`, `存货编码`, `采购订单编号`, `领用申请单编号`, `销售订单编号`, `模具供应商编号`, `模具类别`, `模具类型`, `模具材质`, `模具出厂编号`, `模具出厂规格`, `模具出厂直径`, `返修次数`, `模具编号`, `模链编号`, `模具标准规格`, `模具规格`, `模具标准直径`, `模具直径`, `模芯规格`, `粒度`, `状态描述`, `库存状态`, `仓库编号`, `货位编号`, `设备编号`, `下盘编号`, `下盘规格`, `累计公里数`, `累计盘数`, `行动`, `模具打标时间`, `模具打标录入时间`, `模具打标操作人编号`, `模具打标备注`, `模具检验时间`, `模具检验录入时间`, `模具检验人编号`, `异常类型`, `特殊检验说明`, `模具检验备注`, `最小直径`, `最大直径`, `平均直径`, `椭圆度`, `椭圆率`, `左定径长度`, `右定径长度`, `定径长度`, `有效值`, `定径区AR`, `左压缩角`, `右压缩角`, `压缩角`, `压缩区AR1`, `压缩区AR2`, `孔偏角X`, `孔偏角Y`, `倍率`, `检验结果`, `模具首次入库时间`, `领用类型`, `模具领用时间`, `模具领用录入时间`, `模具领用人编号`, `模具领用备注`, `模具退库时间`, `模具退库录入时间`, `模具退库操作人编号`, `模具退库原因`, `模具退库备注`, `模具采购退货时间`, `模具采购退货录入时间`, `模具采购退货操作人编号`, `模具采购退货原因`, `模具采购退货备注`, `模具报废时间`, `模具报废录入时间`, `模具报废操作人编号`, `模具报废原因`, `模具报废备注`)

SELECT `公司编号`, `工厂名称`, `存货编码`, `采购订单编号`, `领用申请单编号`, `销售订单编号`, `模具供应商编号`, `模具类别`, `模具类型`, `模具材质`, `模具出厂编号`, `模具出厂规格`, `模具出厂直径`, `返修次数`, `模具编号`, `模链编号`, `模具标准规格`, `模具规格`, `模具标准直径`, `模具直径`, `模芯规格`, `粒度`, `状态描述`, `库存状态`, `仓库编号`, `货位编号`, `设备编号`, `下盘编号`, `下盘规格`, `累计公里数`, `累计盘数`, `行动`, `模具打标时间`, `模具打标录入时间`, `模具打标操作人编号`, `模具打标备注`, `模具检验时间`, `模具检验录入时间`, `模具检验人编号`, `异常类型`, `特殊检验说明`, `模具检验备注`, `最小直径`, `最大直径`, `平均直径`, `椭圆度`, `椭圆率`, `左定径长度`, `右定径长度`, `定径长度`, `有效值`, `定径区AR`, `左压缩角`, `右压缩角`, `压缩角`, `压缩区AR1`, `压缩区AR2`, `孔偏角X`, `孔偏角Y`, `倍率`, `检验结果`, `模具首次入库时间`, `领用类型`, `模具领用时间`, `模具领用录入时间`, `模具领用人编号`, `模具领用备注`, `模具退库时间`, `模具退库录入时间`, `模具退库操作人编号`, `模具退库原因`, `模具退库备注`, `模具采购退货时间`, `模具采购退货录入时间`, `模具采购退货操作人编号`, `模具采购退货原因`, `模具采购退货备注`, `模具报废时间`, `模具报废录入时间`, `模具报废操作人编号`, `模具报废原因`, `模具报废备注` FROM 模具返修流程表 GROUP BY 模具供应商编号,模具出厂编号 HAVING COUNT(1) = 1;



-- ②返修模具
SELECT * FROM 模具返修流程表 where AutoID In
(
	SELECT Max(AutoID) as AutoID FROM 模具返修流程表 GROUP BY 模具供应商编号,模具出厂编号 HAVING COUNT(1) > 1
)
1941

INSERT INTO `dl_mes`.`模具信息表`(`公司编号`, `工厂名称`, `存货编码`, `采购订单编号`, `领用申请单编号`, `销售订单编号`, `模具供应商编号`, `模具类别`, `模具类型`, `模具材质`, `模具出厂编号`, `模具出厂规格`, `模具出厂直径`, `返修次数`, `模具编号`, `模链编号`, `模具标准规格`, `模具规格`, `模具标准直径`, `模具直径`, `模芯规格`, `粒度`, `状态描述`, `库存状态`, `仓库编号`, `货位编号`, `设备编号`, `下盘编号`, `下盘规格`, `累计公里数`, `累计盘数`, `行动`, `模具打标时间`, `模具打标录入时间`, `模具打标操作人编号`, `模具打标备注`, `模具检验时间`, `模具检验录入时间`, `模具检验人编号`, `异常类型`, `特殊检验说明`, `模具检验备注`, `最小直径`, `最大直径`, `平均直径`, `椭圆度`, `椭圆率`, `左定径长度`, `右定径长度`, `定径长度`, `有效值`, `定径区AR`, `左压缩角`, `右压缩角`, `压缩角`, `压缩区AR1`, `压缩区AR2`, `孔偏角X`, `孔偏角Y`, `倍率`, `检验结果`, `模具首次入库时间`, `领用类型`, `模具领用时间`, `模具领用录入时间`, `模具领用人编号`, `模具领用备注`, `模具退库时间`, `模具退库录入时间`, `模具退库操作人编号`, `模具退库原因`, `模具退库备注`, `模具采购退货时间`, `模具采购退货录入时间`, `模具采购退货操作人编号`, `模具采购退货原因`, `模具采购退货备注`, `模具报废时间`, `模具报废录入时间`, `模具报废操作人编号`, `模具报废原因`, `模具报废备注`)

SELECT `公司编号`, `工厂名称`, `存货编码`, `采购订单编号`, `领用申请单编号`, `销售订单编号`, `模具供应商编号`, `模具类别`, `模具类型`, `模具材质`, `模具出厂编号`, `模具出厂规格`, `模具出厂直径`, `返修次数`, `模具编号`, `模链编号`, `模具标准规格`, `模具规格`, `模具标准直径`, `模具直径`, `模芯规格`, `粒度`, `状态描述`, `库存状态`, `仓库编号`, `货位编号`, `设备编号`, `下盘编号`, `下盘规格`, `累计公里数`, `累计盘数`, `行动`, `模具打标时间`, `模具打标录入时间`, `模具打标操作人编号`, `模具打标备注`, `模具检验时间`, `模具检验录入时间`, `模具检验人编号`, `异常类型`, `特殊检验说明`, `模具检验备注`, `最小直径`, `最大直径`, `平均直径`, `椭圆度`, `椭圆率`, `左定径长度`, `右定径长度`, `定径长度`, `有效值`, `定径区AR`, `左压缩角`, `右压缩角`, `压缩角`, `压缩区AR1`, `压缩区AR2`, `孔偏角X`, `孔偏角Y`, `倍率`, `检验结果`, `模具首次入库时间`, `领用类型`, `模具领用时间`, `模具领用录入时间`, `模具领用人编号`, `模具领用备注`, `模具退库时间`, `模具退库录入时间`, `模具退库操作人编号`, `模具退库原因`, `模具退库备注`, `模具采购退货时间`, `模具采购退货录入时间`, `模具采购退货操作人编号`, `模具采购退货原因`, `模具采购退货备注`, `模具报废时间`, `模具报废录入时间`, `模具报废操作人编号`, `模具报废原因`, `模具报废备注`
FROM 模具返修流程表 where AutoID In
(
	SELECT Max(AutoID) as AutoID FROM 模具返修流程表 GROUP BY 模具供应商编号,模具出厂编号 HAVING COUNT(1) > 1
)

3. Usage summary

select * FROM Mold Rework Flow Chart

select * FROM mold inspection data table

select * FROM Mold information table

Guess you like

Origin blog.csdn.net/youcheng_ge/article/details/132020410