CCL_QMS检验
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6525 lines
286 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
3 months ago
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
6 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
3 months ago
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
6 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
5 months ago
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
5 months ago
​
​
5 months ago
​
​
​
5 months ago
​
​
​
​
​
5 months ago
5 months ago
​
​
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
1 month ago
6 months ago
​
​
1 month ago
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
6 months ago
5 months ago
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
11 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
11 hours ago
​
​
1 month ago
5 months ago
​
​
1 month ago
11 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
​
​
​
3 months ago
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
3 months ago
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
5 months ago
​
5 months ago
​
​
5 months ago
​
5 months ago
​
6 months ago
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
6 months ago
6 months ago
​
​
​
​
​
​
6 months ago
​
5 months ago
6 months ago
​
5 months ago
6 months ago
​
5 months ago
6 months ago
​
5 months ago
6 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
5 months ago
​
​
​
5 months ago
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
5 months ago
6 months ago
5 months ago
6 months ago
​
​
​
​
5 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
5 months ago
3 months ago
5 months ago
​
6 months ago
5 months ago
​
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
5 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
5 months ago
1 month ago
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
3 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
5 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gaotao.modules.pms.mapper.QcMapper">
  4. <!-- ================================================= FAI检验维护 ================================================= -->
  5. <!-- 查询FAI基础数据 -->
  6. <select id="selectFAIBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  7. SELECT
  8. top 1
  9. a.orderno as orderNo,
  10. j.partNo,
  11. j.PartDescription as part_desc,
  12. c.operationDesc,
  13. b.approve_qty as rollQty,
  14. a.s_resourceid as resourceId,
  15. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  16. a.itemno as itemNo,
  17. a.id as ssrId
  18. FROM soscheduledrouting as a
  19. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  20. LEFT JOIN sfdc as b
  21. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  22. select min(sfdc.id)
  23. from sfdc
  24. group by sfdc.assjob_seq_no, site
  25. )
  26. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  27. LEFT JOIN part j ON so.site = j.site and so.PartNo = j.partNo
  28. WHERE a.itemno = '10'
  29. AND a.id not in (select ssr_id from qc_fai_record)
  30. AND b.approve_qty is not null
  31. ORDER BY a.id desc
  32. </select>
  33. <!-- 获取该物料属性下维护的iqc -->
  34. <select id="selectPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  35. SELECT
  36. qat.site,
  37. qat.bu_no,
  38. qat.attribute_no,
  39. qat.template_id,
  40. qat.sampling_level_no,
  41. qsil.sampling_level_desc,
  42. qat.inspection_cycle,
  43. qat.sampling_programme_no,
  44. qsip.sampling_programme_desc,
  45. qat.AQL,
  46. qat.AC,
  47. qat.RE,
  48. qt.default_sampling_quantity,
  49. qt.default_sampling_proportion
  50. FROM qc_attribute_template as qat
  51. LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
  52. LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
  53. LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
  54. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  55. AND qat.attribute_no = #{partNo}
  56. AND qat.attribute_type = #{attributeType}
  57. AND qt.inspection_type_no = #{inspectionTypeNo}
  58. AND qat.manufacturer_id = #{supplierNo}
  59. </select>
  60. <!-- 获取该物料属性下维护的ipqc -->
  61. <select id="selectPartAttributeByOperationAndResource" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  62. SELECT
  63. qat.site,
  64. qat.bu_no,
  65. qat.attribute_no,
  66. qat.template_id,
  67. qat.sampling_level_no,
  68. qsil.sampling_level_desc,
  69. qat.inspection_cycle,
  70. qat.sampling_programme_no,
  71. qsip.sampling_programme_desc,
  72. qat.AQL,
  73. qat.AC,
  74. qat.RE,
  75. qt.default_sampling_quantity,
  76. qt.default_sampling_proportion
  77. FROM qc_attribute_template as qat
  78. LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
  79. LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
  80. LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
  81. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  82. AND qat.attribute_no = #{partNo}
  83. AND qat.attribute_type = #{attributeType1}
  84. AND qt.inspection_type_no = #{inspectionTypeNo}
  85. AND qat.operation = #{operationDesc}
  86. AND qat.resource_id = #{resourceId}
  87. </select>
  88. <!-- 获取模板详情 -->
  89. <select id="selectTemplate" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  90. SELECT
  91. qt.site,
  92. qt.bu_no,
  93. qt.template_id,
  94. qt.sampling_level_no,
  95. qsil.sampling_level_desc,
  96. qt.inspection_cycle,
  97. qt.sampling_programme_no,
  98. qsip.sampling_programme_desc,
  99. qt.AQL,
  100. qt.AC,
  101. qt.RE,
  102. qt.default_sampling_quantity,
  103. qt.default_sampling_proportion
  104. FROM qc_template as qt
  105. LEFT JOIN qc_sampling_inspection_level as qsil ON qt.sampling_level_no = qsil.sampling_level_no and qt.site = qsil.site and qt.bu_no = qsil.bu_no
  106. LEFT JOIN qc_sampling_inspection_programme as qsip ON qt.sampling_programme_no = qsip.sampling_programme_no and qt.site = qsip.site and qt.bu_no = qsip.bu_no
  107. WHERE qt.site = #{site} and qt.template_id = #{templateId} and qt.bu_no = #{buNo}
  108. </select>
  109. <!-- 新增FAI主记录信息 -->
  110. <insert id="saveFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  111. INSERT INTO qc_fai_record (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id, part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  112. VALUES(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId}, #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  113. </insert>
  114. <insert id="saveFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  115. INSERT INTO qc_fai_detailed_record
  116. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  117. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  118. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  119. VALUES
  120. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  121. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  122. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  123. </insert>
  124. <!-- 新增FAI明细记录信息 -->
  125. <insert id="saveFAIDetailedRecords">
  126. INSERT INTO qc_fai_detailed_record
  127. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  128. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  129. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  130. VALUES
  131. <foreach collection="list" item="item" separator=",">
  132. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  133. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  134. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  135. </foreach>
  136. </insert>
  137. <!-- 查询FAI主记录信息 -->
  138. <select id="qcFAIInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  139. SELECT
  140. a.inspection_no,
  141. a.site,
  142. a.bu_no,
  143. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  144. a.state,
  145. a.inspection_result,
  146. a.task_date,
  147. a.inspection_type_no,
  148. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  149. a.inspection_cycle,
  150. a.order_no,
  151. a.operation_desc,
  152. a.resource_id,
  153. r.resourceDesc,
  154. a.part_no,
  155. d.PartDescription as part_desc,
  156. d.cinv_source_code as cinvSourceCode,
  157. d.sku as sku,
  158. d.PartType as invdefinetype,
  159. a.inspection_remark,
  160. a.roll_qty,
  161. a.sampling_qty,
  162. a.disposal_measures,
  163. a.disposal_remark,
  164. a.inspector_date as inspectorDate,
  165. a.inspector_no,
  166. u.user_display as inspectorName,
  167. a.ssr_id,
  168. a.unqualified_qty,
  169. a.submit_flag,
  170. a.seq_no,
  171. a.batch_roll_no,
  172. a.special_requirements,
  173. a.work_center_no,
  174. a.roll_no,
  175. a.um_id,
  176. um.UMName as umName,
  177. a.action_date,
  178. a.action_by,
  179. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  180. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  181. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  182. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  183. a.pass_qty,
  184. a.not_pass_qty,
  185. a.batch_qualified_qty
  186. FROM qc_fai_record as a
  187. inner join part as d on a.site = d.site and a.part_no = d.partNo
  188. left join sys_user as u on a.inspector_no = u.username
  189. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  190. left join UM as um on a.site = um.site and a.um_id = um.UMID
  191. <where>
  192. a.site in (select site from AccessSite where userID = #{query.userName})
  193. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  194. <if test="query.buNo != null and query.buNo != ''">
  195. AND a.bu_no = #{query.buNo}
  196. </if>
  197. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  198. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  199. </if>
  200. <if test = "query.partNo != null and query.partNo != ''">
  201. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  202. </if>
  203. <if test = "query.partDesc != null and query.partDesc != ''">
  204. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  205. </if>
  206. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  207. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  208. </if>
  209. <if test = "query.sku != null and query.sku != ''">
  210. AND d.sku LIKE '%' + #{query.sku} + '%'
  211. </if>
  212. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  213. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  214. </if>
  215. <if test = "query.states != null and query.states.size > 0">
  216. AND a.state in
  217. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  218. #{item}
  219. </foreach>
  220. </if>
  221. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  222. AND a.inspection_result = #{query.inspectionResult}
  223. </if>
  224. <if test = "query.orderNo != null and query.orderNo != ''">
  225. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  226. </if>
  227. <if test = "query.seqNo != null and query.seqNo != ''">
  228. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  229. </if>
  230. <if test = "query.operationDesc != null and query.operationDesc != ''">
  231. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  232. </if>
  233. <if test="query.startDate != null">
  234. AND a.inspector_date >= #{query.startDate}
  235. </if>
  236. <if test="query.endDate != null">
  237. AND #{query.endDate} >= a.inspector_date
  238. </if>
  239. <if test="query.startDate2 != null">
  240. AND a.task_date >= #{query.startDate2}
  241. </if>
  242. <if test="query.endDate2 != null">
  243. AND #{query.endDate2} >= a.task_date
  244. </if>
  245. </where>
  246. ORDER BY
  247. CASE WHEN a.state = '待检验' THEN 1
  248. WHEN a.state = '待审核' THEN 2
  249. WHEN a.state = '已完成' THEN 3
  250. END, a.task_date desc
  251. </select>
  252. <!-- 获取物料的类别编码 -->
  253. <select id="selectFamilyIdByPartNo" parameterType="string" resultType="string">
  254. SELECT FamilyID
  255. FROM part
  256. WHERE partNo = #{partNo} AND site = #{site}
  257. </select>
  258. <!-- FAI明细记录查询 -->
  259. <select id="faiDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  260. SELECT
  261. a.site,
  262. a.bu_no,
  263. a.inspection_no,
  264. a.order_no,
  265. a.template_id,
  266. a.sampling_level_no,
  267. a.sampling_level_desc,
  268. a.sampling_programme_no,
  269. a.sampling_programme_desc,
  270. a.AQL,
  271. a.AC,
  272. a.RE,
  273. a.item_no,
  274. a.item_desc,
  275. a.object_id,
  276. a.object_desc,
  277. a.default_value,
  278. a.min_value,
  279. a.max_value,
  280. a.text_value,
  281. a.number_value,
  282. a.value_type_db,
  283. a.value_type,
  284. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  285. a.is_submit,
  286. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  287. a.sampling_qty,
  288. dbo.qc_get_fai_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  289. c.method_no,
  290. c.method_name,
  291. c.method_remark,
  292. sw.color_code as qcSpecWarningColorCode,
  293. sw.threshold_value as qcSpecWarningThresholdValue
  294. FROM qc_fai_detailed_record as a
  295. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  296. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  297. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  298. order by a.order_id
  299. </select>
  300. <!-- 修改FAI主记录信息 -->
  301. <update id="updateFAIMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  302. UPDATE qc_fai_record
  303. SET disposal_measures = #{disposalMeasures},
  304. disposal_remark = #{disposalRemark},
  305. inspection_result = #{inspectionResult},
  306. inspector_no = #{inspectorNo},
  307. state = #{state},
  308. inspection_remark = #{inspectionRemark},
  309. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  310. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  311. roll_qty = #{rollQty,jdbcType=DECIMAL},
  312. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  313. pass_qty = #{passQty,jdbcType=DECIMAL},
  314. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  315. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  316. WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
  317. </update>
  318. <!-- 修改FAI明细记录信息 -->
  319. <update id="updateFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  320. UPDATE qc_fai_detailed_record
  321. SET item_result = #{itemResult},
  322. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  323. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  324. text_value = #{textValue},
  325. number_value = #{numberValue,jdbcType=DECIMAL}
  326. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  327. </update>
  328. <!-- 修改子明细提交标识 -->
  329. <update id="updateSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  330. UPDATE qc_fai_sub_detail_record
  331. SET is_submit = 'Y'
  332. WHERE inspection_no = #{inspectionNo}
  333. </update>
  334. <!-- 删除FAI检验记录 -->
  335. <delete id="deleteFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  336. DELETE FROM qc_fai_record
  337. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  338. </delete>
  339. <!-- 删除FAI明细记录信息 -->
  340. <delete id="deleteFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  341. DELETE FROM qc_fai_detailed_record
  342. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  343. </delete>
  344. <!-- 删除FAI子明细记录信息 -->
  345. <delete id="deleteFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  346. DELETE FROM qc_fai_sub_detail_record
  347. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  348. </delete>
  349. <!-- 修改FAI主记录标识为已提交 -->
  350. <update id="updateFAIMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  351. UPDATE qc_fai_record
  352. SET submit_flag = 'Y',
  353. state = '已完成',
  354. submit_date = getDate()
  355. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  356. </update>
  357. <!-- 修改FAI明细记录标识为已提交 -->
  358. <update id="updateFAIDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  359. UPDATE qc_fai_detailed_record
  360. SET is_submit = 'Y'
  361. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  362. </update>
  363. <!-- 修改子明细记录标识为已提交 -->
  364. <update id="updateFAISubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  365. UPDATE qc_fai_sub_detail_record
  366. SET is_submit = 'Y'
  367. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  368. </update>
  369. <!-- 查询FAI检验记录是否已提交 -->
  370. <select id="checkFAIIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  371. SELECT submit_flag
  372. FROM qc_fai_record
  373. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  374. </select>
  375. <!-- 查询FAI检验记录状态(用于保存前校验) -->
  376. <select id="getFAIRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  377. SELECT submit_flag, state
  378. FROM qc_fai_record
  379. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  380. </select>
  381. <!-- 删除子明细的老数据 -->
  382. <delete id="delFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  383. DELETE FROM qc_fai_sub_detail_record
  384. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  385. </delete>
  386. <!-- 新增FAI子明细信息 -->
  387. <insert id="saveFAISubDetailed">
  388. INSERT INTO qc_fai_sub_detail_record
  389. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
  390. VALUES
  391. <foreach collection="list" item="item" separator=",">
  392. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  393. </foreach>
  394. </insert>
  395. <!-- 查询FAI的子明细 -->
  396. <select id="selectFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  397. SELECT
  398. site,
  399. bu_no,
  400. sub_detail_value,
  401. sampling_location,
  402. is_submit,
  403. sampling_location_b,
  404. num,
  405. sub_detail_value_b,
  406. sub_detail_value_c,
  407. sub_detail_value_d,
  408. sub_detail_value_e
  409. FROM qc_fai_sub_detail_record
  410. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  411. <if test = "collectionDataContent != null and collectionDataContent != ''">
  412. AND sub_detail_value ${collectionDataContent}
  413. </if>
  414. </select>
  415. <!-- 获取该项目的子明细值 -->
  416. <select id="selectFAISubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  417. SELECT sub_detail_value,
  418. sampling_location,
  419. is_submit
  420. FROM qc_fai_sub_detail_record
  421. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  422. </select>
  423. <!-- ================================================= IPQC检验维护 ================================================= -->
  424. <!-- 查询IPQC基础数据 -->
  425. <select id="selectIPQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  426. SELECT
  427. top 1
  428. a.orderno as orderNo,
  429. j.partNo,
  430. j.PartDescription as partDesc,
  431. c.operationDesc,
  432. b.approve_qty as rollQty,
  433. a.s_resourceid as resourceId,
  434. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  435. a.itemno as itemNo,
  436. a.id as ssrId
  437. FROM soscheduledrouting as a
  438. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  439. LEFT JOIN sfdc as b
  440. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  441. select max(sfdc.id)
  442. from sfdc
  443. group by sfdc.assjob_seq_no, site
  444. )
  445. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  446. LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
  447. LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
  448. ON a.id = temp.ssr_id
  449. WHERE b.approve_qty is not null and temp.ssr_id is null
  450. ORDER BY a.id desc
  451. </select>
  452. <select id="qcExec" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="string" statementType="CALLABLE">
  453. {CALL
  454. getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
  455. }
  456. </select>
  457. <insert id="saveIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  458. INSERT INTO qc_ipqc_detailed_record
  459. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  460. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  461. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
  462. VALUES
  463. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  464. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  465. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  466. </insert>
  467. <!-- 新增IPQC明细记录信息 -->
  468. <insert id="saveIPQCDetailedRecords">
  469. INSERT INTO qc_ipqc_detailed_record
  470. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  471. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  472. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  473. VALUES
  474. <foreach collection="list" item="item" separator=",">
  475. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  476. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  477. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId}, #{item.custom1}, #{item.custom2}, #{item.custom3})
  478. </foreach>
  479. </insert>
  480. <!-- 新增IPQC主记录信息 -->
  481. <insert id="saveIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  482. INSERT INTO qc_ipqc_record
  483. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  484. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, create_by, inspector_by)
  485. VALUES
  486. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  487. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
  488. #{createBy}, #{inspectorBy})
  489. </insert>
  490. <!-- 查询IPQC主记录信息 -->
  491. <select id="qcIPQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  492. SELECT
  493. a.inspection_no,
  494. a.site,
  495. a.bu_no,
  496. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  497. a.state,
  498. a.inspection_result,
  499. a.task_date,
  500. a.create_date,
  501. a.inspection_type_no,
  502. a.inspection_cycle,
  503. a.order_no,
  504. a.operation_desc,
  505. a.resource_id,
  506. r.resourceDesc,
  507. a.part_no,
  508. d.PartDescription as part_desc,
  509. d.cinv_source_code as cinvSourceCode,
  510. d.sku as sku,
  511. d.PartType as invdefinetype,
  512. d.spec,
  513. a.inspection_remark,
  514. a.roll_qty,
  515. a.sampling_qty,
  516. a.disposal_measures,
  517. a.disposal_remark,
  518. a.inspector_date as inspectorDate,
  519. a.submit_date,
  520. isnull(sub.user_display, a.submit_by) as submitBy,
  521. a.inspector_no,
  522. u.user_display as inspectorName,
  523. a.ssr_id,
  524. a.unqualified_qty,
  525. a.submit_flag,
  526. a.seq_no,
  527. a.batch_roll_no,
  528. a.special_requirements,
  529. a.work_center_no,
  530. a.roll_no,
  531. a.um_id,
  532. um.UMName as umName,
  533. a.action_date,
  534. isnull(ab.user_display, a.action_by) as actionBy,
  535. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  536. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  537. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  538. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  539. a.pass_qty,
  540. a.not_pass_qty,
  541. a.batch_qualified_qty,
  542. w.WorkCenterDesc,
  543. a.release_no as releaseNo,
  544. a.line_no,
  545. isnull(a.inspector_by, a.create_by) as inspectorBy,
  546. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName,
  547. a.upper_system_flag as upperSystemFlag
  548. FROM qc_ipqc_record as a
  549. inner join part as d on a.site = d.site and a.part_no = d.partNo
  550. left join sys_user as u on a.inspector_no = u.username
  551. left join sys_user as ab on a.action_by = ab.username
  552. left join sys_user as sub on a.submit_by = sub.username
  553. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  554. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  555. left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
  556. left join UM as um on a.um_id = um.UMID
  557. <where>
  558. a.site in (select site from AccessSite where userID = #{query.userName})
  559. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  560. <if test="query.site != null and query.site != ''">
  561. AND a.site = #{query.site}
  562. </if>
  563. <if test="query.buNo != null and query.buNo != ''">
  564. AND a.bu_no = #{query.buNo}
  565. </if>
  566. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  567. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  568. </if>
  569. <if test = "query.partNo != null and query.partNo != ''">
  570. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  571. </if>
  572. <if test = "query.partDesc != null and query.partDesc != ''">
  573. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  574. </if>
  575. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  576. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  577. </if>
  578. <if test = "query.sku != null and query.sku != ''">
  579. AND d.sku LIKE '%' + #{query.sku} + '%'
  580. </if>
  581. <if test = "query.states != null and query.states.size > 0">
  582. AND a.state in
  583. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  584. #{item}
  585. </foreach>
  586. </if>
  587. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  588. AND a.inspection_type_no = #{query.inspectionTypeNo}
  589. </if>
  590. <if test = "query.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
  591. AND a.inspection_type_no in
  592. <foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
  593. #{item}
  594. </foreach>
  595. </if>
  596. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  597. AND a.inspection_result = #{query.inspectionResult}
  598. </if>
  599. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  600. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  601. </if>
  602. <if test = "query.orderNo != null and query.orderNo != ''">
  603. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  604. </if>
  605. <if test = "query.seqNo != null and query.seqNo != ''">
  606. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  607. </if>
  608. <if test = "query.operationDesc != null and query.operationDesc != ''">
  609. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  610. </if>
  611. <if test = "query.resourceId != null and query.resourceId != ''">
  612. AND a.resource_id = #{query.resourceId}
  613. </if>
  614. <if test = "query.workCenterNo != null and query.workCenterNo != ''">
  615. AND a.work_center_no = #{query.workCenterNo}
  616. </if>
  617. <if test="query.startDate != null">
  618. AND a.inspector_date >= #{query.startDate}
  619. </if>
  620. <if test="query.endDate != null">
  621. AND #{query.endDate} >= a.inspector_date
  622. </if>
  623. <if test="query.startDate2 != null">
  624. AND a.task_date >= #{query.startDate2}
  625. </if>
  626. <if test="query.endDate2 != null">
  627. AND #{query.endDate2} >= a.task_date
  628. </if>
  629. <if test = "query.spec != null and query.spec != ''">
  630. AND d.spec LIKE '%' + #{query.spec} + '%'
  631. </if>
  632. </where>
  633. ORDER BY a.inspection_no desc,
  634. CASE WHEN a.state = '未开始' THEN 1
  635. WHEN a.state = '待检验' THEN 2
  636. END, a.action_date,a.task_date,a.inspector_date desc
  637. </select>
  638. <!-- IPQC明细记录查询 -->
  639. <select id="ipqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  640. SELECT
  641. a.site,
  642. a.bu_no,
  643. a.inspection_no,
  644. a.order_no,
  645. a.template_id,
  646. a.sampling_level_no,
  647. a.sampling_level_desc,
  648. a.sampling_programme_no,
  649. a.sampling_programme_desc,
  650. a.AQL,
  651. a.AC,
  652. a.RE,
  653. a.item_no,
  654. a.item_desc,
  655. a.object_id,
  656. a.object_desc,
  657. a.default_value,
  658. a.min_value,
  659. a.max_value,
  660. a.text_value,
  661. a.number_value,
  662. a.value_type_db,
  663. a.value_type,
  664. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  665. a.item_remark as itemRemark,
  666. a.custom1,
  667. a.custom2,
  668. a.custom3,
  669. a.is_submit,
  670. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  671. a.sampling_qty,
  672. dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  673. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  674. c.method_no,
  675. c.method_name,
  676. c.method_remark,
  677. sw.color_code as qcSpecWarningColorCode,
  678. sw.threshold_value as qcSpecWarningThresholdValue,
  679. (SELECT TOP 1 epi.collection_flag
  680. FROM eam_properties_item epi
  681. WHERE epi.site = a.site
  682. AND epi.bu_no = a.bu_no
  683. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  684. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  685. epi.inspection_type_no) AS collectionFlag,
  686. (SELECT TOP 1 epi.image_flag
  687. FROM eam_properties_item epi
  688. WHERE epi.site = a.site
  689. AND epi.bu_no = a.bu_no
  690. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  691. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  692. epi.inspection_type_no) AS imageFlag,
  693. (SELECT TOP 1 epi.data_flag
  694. FROM eam_properties_item epi
  695. WHERE epi.site = a.site
  696. AND epi.bu_no = a.bu_no
  697. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  698. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  699. epi.inspection_type_no) AS dataFlag
  700. FROM qc_ipqc_detailed_record as a
  701. LEFT JOIN qc_ipqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  702. OUTER APPLY (
  703. SELECT TOP 1
  704. w.color_code,
  705. w.threshold_value
  706. FROM qc_spec_warning w
  707. WHERE w.site = a.site
  708. AND w.bu_no = a.bu_no
  709. AND w.part_no = r.part_no
  710. AND w.item_no = a.item_no
  711. AND w.inspection_type_no = r.inspection_type_no
  712. ORDER BY w.threshold_value
  713. ) sw
  714. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  715. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  716. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  717. order by a.order_id
  718. </select>
  719. <!-- 删除IPQC检验记录 -->
  720. <delete id="deleteIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  721. DELETE FROM qc_ipqc_record
  722. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  723. </delete>
  724. <!-- 删除IPQC明细记录信息 -->
  725. <delete id="deleteIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  726. DELETE FROM qc_ipqc_detailed_record
  727. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  728. </delete>
  729. <!-- 删除IPQC子明细记录信息 -->
  730. <delete id="deleteIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  731. DELETE FROM qc_ipqc_sub_detail_record
  732. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  733. </delete>
  734. <!-- 任务重载:修改IPQC检验记录 -->
  735. <update id="updateIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  736. UPDATE qc_ipqc_record
  737. SET inspection_type_no = #{inspectionTypeNo},
  738. sampling_qty = #{samplingQty},
  739. inspection_cycle = #{inspectionCycle},
  740. state = '未开始',
  741. inspection_result = null,
  742. disposal_measures = null,
  743. disposal_remark = null,
  744. inspection_remark = null,
  745. inspector_no = null,
  746. inspector_date = null,
  747. submit_flag = 'N',
  748. action_date = null,
  749. action_by = null,
  750. pass_qty = null,
  751. not_pass_qty = null,
  752. unqualified_qty = null,
  753. batch_qualified_qty = null
  754. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  755. </update>
  756. <!-- 修改IPQC主记录信息 -->
  757. <update id="updateIPQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  758. UPDATE qc_ipqc_record
  759. SET disposal_measures = #{disposalMeasures},
  760. disposal_remark = #{disposalRemark},
  761. inspection_result = #{inspectionResult},
  762. inspector_no = #{inspectorNo},
  763. state = #{state},
  764. inspection_remark = #{inspectionRemark},
  765. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  766. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  767. roll_qty = #{rollQty,jdbcType=DECIMAL},
  768. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  769. pass_qty = #{passQty,jdbcType=DECIMAL},
  770. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  771. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  772. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  773. </update>
  774. <!-- 修改IPQC明细记录信息 -->
  775. <update id="updateIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  776. UPDATE qc_ipqc_detailed_record
  777. SET item_result = #{itemResult},
  778. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  779. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  780. text_value = #{textValue},
  781. number_value = #{numberValue,jdbcType=DECIMAL},
  782. default_value = #{defaultValue},
  783. min_value = #{minValue,jdbcType=DECIMAL},
  784. max_value = #{maxValue,jdbcType=DECIMAL},
  785. item_remark = #{itemRemark},
  786. custom1 = #{custom1},
  787. custom2 = #{custom2},
  788. custom3 = #{custom3}
  789. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  790. </update>
  791. <update id="patchIPQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  792. UPDATE qc_ipqc_detailed_record
  793. <set>
  794. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  795. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  796. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  797. <if test="textValue != null">text_value = #{textValue},</if>
  798. </set>
  799. WHERE inspection_no = #{inspectionNo}
  800. and RTRIM(item_no) = RTRIM(#{itemNo})
  801. and site = #{site}
  802. and bu_no = #{buNo}
  803. </update>
  804. <!-- 修改IPQC主记录标识为已提交 -->
  805. <update id="updateIPQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  806. UPDATE qc_ipqc_record
  807. SET submit_flag = 'Y',
  808. state = '已完成',
  809. submit_date = getDate(),
  810. submit_by = #{updateBy}
  811. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  812. </update>
  813. <!-- 修改IPQC明细记录标识为已提交 -->
  814. <update id="updateIPQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  815. UPDATE qc_ipqc_detailed_record
  816. SET is_submit = 'Y'
  817. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  818. </update>
  819. <!-- 修改IPQC子明细记录标识为已提交 -->
  820. <update id="updateIPQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  821. UPDATE qc_ipqc_sub_detail_record
  822. SET is_submit = 'Y'
  823. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  824. </update>
  825. <!-- 删除IPQC子明细的老数据 -->
  826. <delete id="delIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  827. DELETE FROM qc_ipqc_sub_detail_record
  828. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  829. </delete>
  830. <!-- 新增IPQC子明细信息 -->
  831. <insert id="saveIPQCSubDetailed">
  832. INSERT INTO qc_ipqc_sub_detail_record
  833. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, product_quantity, create_time)
  834. VALUES
  835. <foreach collection="list" item="item" separator=",">
  836. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, #{item.productQuantity,jdbcType=DECIMAL}, getDate())
  837. </foreach>
  838. </insert>
  839. <!-- 查询IPQC的子明细 -->
  840. <select id="selectIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  841. SELECT
  842. site,
  843. bu_no,
  844. sub_detail_value,
  845. sampling_location,
  846. is_submit,
  847. sampling_location_b,
  848. num,
  849. sub_detail_value_b,
  850. sub_detail_value_c,
  851. sub_detail_value_d,
  852. sub_detail_value_e,
  853. file_name,
  854. is_transfer,
  855. is_qualified,
  856. defect_qty,
  857. roll_no,
  858. product_quantity as productQuantity,
  859. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  860. FROM qc_ipqc_sub_detail_record
  861. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  862. <if test = "collectionDataContent != null and collectionDataContent != ''">
  863. AND sub_detail_value ${collectionDataContent}
  864. </if>
  865. </select>
  866. <!-- 查询IPQC检验记录是否已提交 -->
  867. <select id="checkIPQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  868. SELECT submit_flag
  869. FROM qc_ipqc_record
  870. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  871. </select>
  872. <!-- 查询IPQC检验记录状态(用于保存前校验) -->
  873. <select id="getIPQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  874. SELECT submit_flag, state
  875. FROM qc_ipqc_record
  876. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  877. </select>
  878. <!-- 获取该项目的子明细值 -->
  879. <select id="selectIPQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  880. SELECT sub_detail_value,
  881. sampling_location,
  882. is_submit
  883. FROM qc_ipqc_sub_detail_record
  884. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  885. </select>
  886. <!-- ================================================= SQC库存复检 ================================================= -->
  887. <select id="selectSQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  888. SELECT
  889. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  890. FROM qc_sqc_record
  891. WHERE site = #{site} and bu_no = #{buNo}
  892. </select>
  893. <insert id="saveSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  894. INSERT INTO qc_sqc_detailed_record
  895. (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  896. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  897. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  898. VALUES
  899. (#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  900. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  901. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo}, #{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  902. </insert>
  903. <insert id="saveSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  904. INSERT INTO qc_sqc_record
  905. (inspection_no, site, bu_no, state, create_date, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  906. part_no, part_desc, roll_qty, sampling_qty, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id,
  907. batch_no, receipt_no, receipt_item_no, [po_orderNo], po_itemNo, supplier_no, create_by, inspector_by)
  908. VALUES
  909. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  910. #{partNo}, #{partDesc}, #{rollQty,jdbcType=DECIMAL}, #{samplingQty,jdbcType=DECIMAL}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
  911. #{batchNo}, #{receiptNo}, #{receiptItemNo}, #{poOrderNo}, #{poItemNo}, #{supplierNo}, #{createBy}, #{inspectorBy})
  912. </insert>
  913. <sql id="qcSQCInspectionSearchWhere">
  914. <where>
  915. a.site in (select site from AccessSite where userID = #{query.userName})
  916. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  917. <if test="query.site != null and query.site != ''">
  918. AND a.site = #{query.site}
  919. </if>
  920. <if test="query.buNo != null and query.buNo != ''">
  921. AND a.bu_no = #{query.buNo}
  922. </if>
  923. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  924. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  925. </if>
  926. <if test = "query.partNo != null and query.partNo != ''">
  927. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  928. </if>
  929. <if test = "query.partDesc != null and query.partDesc != ''">
  930. AND (d.PartDescription LIKE '%' + #{query.partDesc} + '%' OR a.part_desc LIKE '%' + #{query.partDesc} + '%')
  931. </if>
  932. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  933. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  934. </if>
  935. <if test = "query.sku != null and query.sku != ''">
  936. AND d.sku LIKE '%' + #{query.sku} + '%'
  937. </if>
  938. <if test = "query.states != null and query.states.size > 0">
  939. AND a.state in
  940. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  941. #{item}
  942. </foreach>
  943. </if>
  944. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  945. AND a.inspection_type_no = #{query.inspectionTypeNo}
  946. </if>
  947. <if test = "query.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
  948. AND a.inspection_type_no in
  949. <foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
  950. #{item}
  951. </foreach>
  952. </if>
  953. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  954. AND a.inspection_result = #{query.inspectionResult}
  955. </if>
  956. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  957. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  958. </if>
  959. <if test = "query.orderNo != null and query.orderNo != ''">
  960. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  961. </if>
  962. <if test = "query.seqNo != null and query.seqNo != ''">
  963. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  964. </if>
  965. <if test = "query.batchNo != null and query.batchNo != ''">
  966. AND a.batch_no LIKE '%' + #{query.batchNo} + '%'
  967. </if>
  968. <if test = "query.receiptNo != null and query.receiptNo != ''">
  969. AND a.receipt_no LIKE '%' + #{query.receiptNo} + '%'
  970. </if>
  971. <if test = "query.operationDesc != null and query.operationDesc != ''">
  972. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  973. </if>
  974. <if test = "query.resourceId != null and query.resourceId != ''">
  975. AND a.resource_id = #{query.resourceId}
  976. </if>
  977. <if test = "query.workCenterNo != null and query.workCenterNo != ''">
  978. AND a.work_center_no = #{query.workCenterNo}
  979. </if>
  980. <if test="query.startDate != null">
  981. AND a.inspector_date >= #{query.startDate}
  982. </if>
  983. <if test="query.endDate != null">
  984. AND #{query.endDate} >= a.inspector_date
  985. </if>
  986. <if test="query.startDate2 != null">
  987. AND a.task_date >= #{query.startDate2}
  988. </if>
  989. <if test="query.endDate2 != null">
  990. AND #{query.endDate2} >= a.task_date
  991. </if>
  992. <if test = "query.spec != null and query.spec != ''">
  993. AND d.spec LIKE '%' + #{query.spec} + '%'
  994. </if>
  995. </where>
  996. </sql>
  997. <select id="qcSQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  998. SELECT
  999. a.inspection_no,
  1000. a.site,
  1001. a.bu_no,
  1002. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1003. a.state,
  1004. a.inspection_result,
  1005. a.task_date,
  1006. a.create_date,
  1007. a.inspection_type_no,
  1008. a.inspection_cycle,
  1009. a.order_no,
  1010. a.operation_desc,
  1011. a.resource_id,
  1012. r.resourceDesc,
  1013. a.part_no,
  1014. COALESCE(d.PartDescription, a.part_desc) as part_desc,
  1015. d.cinv_source_code as cinvSourceCode,
  1016. d.sku as sku,
  1017. d.PartType as invdefinetype,
  1018. d.spec,
  1019. a.inspection_remark,
  1020. a.roll_qty,
  1021. a.sampling_qty,
  1022. a.disposal_measures,
  1023. a.disposal_remark,
  1024. a.inspector_date as inspectorDate,
  1025. a.submit_date,
  1026. isnull(sub.user_display, a.submit_by) as submitBy,
  1027. a.inspector_no,
  1028. u.user_display as inspectorName,
  1029. a.unqualified_qty,
  1030. a.submit_flag,
  1031. a.seq_no,
  1032. a.batch_roll_no,
  1033. a.special_requirements,
  1034. a.work_center_no,
  1035. a.roll_no,
  1036. a.um_id,
  1037. um.UMName as umName,
  1038. a.action_date,
  1039. isnull(ab.user_display, a.action_by) as actionBy,
  1040. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1041. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1042. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1043. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1044. a.pass_qty,
  1045. a.not_pass_qty,
  1046. a.batch_qualified_qty,
  1047. w.WorkCenterDesc,
  1048. a.batch_no,
  1049. a.receipt_no,
  1050. a.receipt_item_no,
  1051. a.[po_orderNo] as poOrderNo,
  1052. a.po_itemNo as poItemNo,
  1053. a.release_no as releaseNo,
  1054. a.line_no,
  1055. isnull(a.inspector_by, a.create_by) as inspectorBy,
  1056. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName,
  1057. a.upper_system_flag as upperSystemFlag
  1058. FROM qc_sqc_record as a
  1059. inner join part as d on a.site = d.site and a.part_no = d.partNo
  1060. left join sys_user as u on a.inspector_no = u.username
  1061. left join sys_user as ab on a.action_by = ab.username
  1062. left join sys_user as sub on a.submit_by = sub.username
  1063. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  1064. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  1065. left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
  1066. left join UM as um on a.site = um.site and a.um_id = um.UMID
  1067. <include refid="qcSQCInspectionSearchWhere"/>
  1068. ORDER BY a.inspection_no desc,
  1069. CASE WHEN a.state = '未开始' THEN 1
  1070. WHEN a.state = '待检验' THEN 2
  1071. END, a.action_date,a.task_date,a.inspector_date desc
  1072. </select>
  1073. <select id="qcSQCInspectionSearchCount" resultType="java.lang.Long">
  1074. SELECT COUNT(1)
  1075. FROM qc_sqc_record as a
  1076. inner join part as d on a.site = d.site and a.part_no = d.partNo
  1077. <include refid="qcSQCInspectionSearchWhere"/>
  1078. </select>
  1079. <select id="sqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1080. SELECT
  1081. a.site,
  1082. a.bu_no,
  1083. a.inspection_no,
  1084. a.template_id,
  1085. a.sampling_level_no,
  1086. a.sampling_level_desc,
  1087. a.sampling_programme_no,
  1088. a.sampling_programme_desc,
  1089. a.AQL,
  1090. a.AC,
  1091. a.RE,
  1092. a.item_no,
  1093. a.item_desc,
  1094. a.object_id,
  1095. a.object_desc,
  1096. a.default_value,
  1097. a.min_value,
  1098. a.max_value,
  1099. a.text_value,
  1100. a.number_value,
  1101. a.value_type_db,
  1102. a.value_type,
  1103. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1104. a.item_remark as itemRemark,
  1105. a.custom1,
  1106. a.custom2,
  1107. a.custom3,
  1108. a.is_submit,
  1109. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1110. a.sampling_qty,
  1111. (SELECT COUNT(1) FROM qc_sqc_sub_detail_record s WHERE s.site = a.site AND s.bu_no = a.bu_no AND s.inspection_no = a.inspection_no AND s.item_no = a.item_no) as subDetailRecordNum,
  1112. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  1113. c.method_no,
  1114. c.method_name,
  1115. c.method_remark,
  1116. sw.color_code as qcSpecWarningColorCode,
  1117. sw.threshold_value as qcSpecWarningThresholdValue,
  1118. (SELECT TOP 1 epi.collection_flag
  1119. FROM eam_properties_item epi
  1120. WHERE epi.site = a.site
  1121. AND epi.bu_no = a.bu_no
  1122. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1123. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1124. epi.inspection_type_no) AS collectionFlag,
  1125. (SELECT TOP 1 epi.image_flag
  1126. FROM eam_properties_item epi
  1127. WHERE epi.site = a.site
  1128. AND epi.bu_no = a.bu_no
  1129. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1130. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1131. epi.inspection_type_no) AS imageFlag,
  1132. (SELECT TOP 1 epi.data_flag
  1133. FROM eam_properties_item epi
  1134. WHERE epi.site = a.site
  1135. AND epi.bu_no = a.bu_no
  1136. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1137. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1138. epi.inspection_type_no) AS dataFlag
  1139. FROM qc_sqc_detailed_record as a
  1140. LEFT JOIN qc_sqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  1141. OUTER APPLY (
  1142. SELECT TOP 1
  1143. w.color_code,
  1144. w.threshold_value
  1145. FROM qc_spec_warning w
  1146. WHERE w.site = a.site
  1147. AND w.bu_no = a.bu_no
  1148. AND w.part_no = r.part_no
  1149. AND w.item_no = a.item_no
  1150. AND w.inspection_type_no = r.inspection_type_no
  1151. ORDER BY w.threshold_value
  1152. ) sw
  1153. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  1154. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  1155. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1156. order by a.order_id
  1157. </select>
  1158. <delete id="deleteSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1159. DELETE FROM qc_sqc_record
  1160. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1161. </delete>
  1162. <delete id="deleteSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1163. DELETE FROM qc_sqc_detailed_record
  1164. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1165. </delete>
  1166. <delete id="deleteSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1167. DELETE FROM qc_sqc_sub_detail_record
  1168. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1169. </delete>
  1170. <!-- 任务重载:修改SQC检验记录 -->
  1171. <update id="updateSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1172. UPDATE qc_sqc_record
  1173. SET inspection_type_no = #{inspectionTypeNo},
  1174. sampling_qty = #{samplingQty},
  1175. inspection_cycle = #{inspectionCycle},
  1176. part_desc = #{partDesc},
  1177. state = '未开始',
  1178. inspection_result = null,
  1179. disposal_measures = null,
  1180. disposal_remark = null,
  1181. inspection_remark = null,
  1182. inspector_no = null,
  1183. inspector_date = null,
  1184. submit_flag = 'N',
  1185. action_date = null,
  1186. action_by = null,
  1187. pass_qty = null,
  1188. not_pass_qty = null,
  1189. unqualified_qty = null,
  1190. batch_qualified_qty = null
  1191. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1192. </update>
  1193. <update id="updateSQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1194. UPDATE qc_sqc_record
  1195. SET disposal_measures = #{disposalMeasures},
  1196. disposal_remark = #{disposalRemark},
  1197. inspection_result = #{inspectionResult},
  1198. inspector_no = #{inspectorNo},
  1199. state = #{state},
  1200. inspection_remark = #{inspectionRemark},
  1201. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  1202. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1203. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1204. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1205. pass_qty = #{passQty,jdbcType=DECIMAL},
  1206. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1207. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  1208. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1209. </update>
  1210. <update id="updateSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1211. UPDATE qc_sqc_detailed_record
  1212. SET item_result = #{itemResult},
  1213. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1214. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1215. text_value = #{textValue},
  1216. number_value = #{numberValue,jdbcType=DECIMAL},
  1217. default_value = #{defaultValue},
  1218. min_value = #{minValue,jdbcType=DECIMAL},
  1219. max_value = #{maxValue,jdbcType=DECIMAL},
  1220. item_remark = #{itemRemark},
  1221. custom1 = #{custom1},
  1222. custom2 = #{custom2},
  1223. custom3 = #{custom3}
  1224. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1225. </update>
  1226. <update id="patchSQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1227. UPDATE qc_sqc_detailed_record
  1228. <set>
  1229. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  1230. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  1231. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  1232. <if test="textValue != null">text_value = #{textValue},</if>
  1233. </set>
  1234. WHERE inspection_no = #{inspectionNo}
  1235. and RTRIM(item_no) = RTRIM(#{itemNo})
  1236. and site = #{site}
  1237. and bu_no = #{buNo}
  1238. </update>
  1239. <update id="updateSQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1240. UPDATE qc_sqc_record
  1241. SET submit_flag = 'Y',
  1242. state = '已完成',
  1243. submit_date = getDate(),
  1244. submit_by = #{updateBy}
  1245. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1246. </update>
  1247. <update id="updateSQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1248. UPDATE qc_sqc_detailed_record
  1249. SET is_submit = 'Y'
  1250. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1251. </update>
  1252. <update id="updateSQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1253. UPDATE qc_sqc_sub_detail_record
  1254. SET is_submit = 'Y'
  1255. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1256. </update>
  1257. <delete id="delSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  1258. DELETE FROM qc_sqc_sub_detail_record
  1259. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1260. </delete>
  1261. <insert id="saveSQCSubDetailed">
  1262. INSERT INTO qc_sqc_sub_detail_record
  1263. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, product_quantity, create_time)
  1264. VALUES
  1265. <foreach collection="list" item="item" separator=",">
  1266. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, #{item.productQuantity,jdbcType=DECIMAL}, getDate())
  1267. </foreach>
  1268. </insert>
  1269. <select id="selectSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1270. SELECT
  1271. site,
  1272. bu_no,
  1273. sub_detail_value,
  1274. sampling_location,
  1275. is_submit,
  1276. sampling_location_b,
  1277. num,
  1278. sub_detail_value_b,
  1279. sub_detail_value_c,
  1280. sub_detail_value_d,
  1281. sub_detail_value_e,
  1282. file_name,
  1283. is_transfer,
  1284. is_qualified,
  1285. defect_qty,
  1286. roll_no,
  1287. product_quantity as productQuantity,
  1288. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  1289. FROM qc_sqc_sub_detail_record
  1290. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1291. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1292. AND sub_detail_value ${collectionDataContent}
  1293. </if>
  1294. </select>
  1295. <select id="checkSQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1296. SELECT submit_flag
  1297. FROM qc_sqc_record
  1298. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1299. </select>
  1300. <select id="getSQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1301. SELECT submit_flag, state
  1302. FROM qc_sqc_record
  1303. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1304. </select>
  1305. <select id="selectSQCSubDetailValue" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1306. SELECT sub_detail_value,
  1307. sampling_location,
  1308. is_submit
  1309. FROM qc_sqc_sub_detail_record
  1310. WHERE inspection_no = #{param1} and item_no = #{param2} and site = #{param3}
  1311. </select>
  1312. <update id="actionSQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  1313. update qc_sqc_record
  1314. set action_date = getDate(),
  1315. action_by = #{actionBy},
  1316. state = #{state}
  1317. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1318. </update>
  1319. <select id="getSQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  1320. select
  1321. a.site,
  1322. a.bu_no,
  1323. a.inspection_no,
  1324. a.item_no,
  1325. a.item_desc,
  1326. b.collection_source,
  1327. b.collection_method,
  1328. b.equipment_classification
  1329. from qc_sqc_detailed_record as a
  1330. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  1331. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  1332. order by a.order_id
  1333. </select>
  1334. <select id="getSQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  1335. SELECT
  1336. ItemNo as itemNo,
  1337. ItemDesc as itemDesc,
  1338. DefaultValue as defaultValue,
  1339. MaxValue as maxValue,
  1340. MinValue as minValue,
  1341. ValueType as valueType,
  1342. ValueType_DB as valueTypeDb
  1343. FROM eam_properties_item
  1344. WHERE site = #{site}
  1345. AND bu_no = #{buNo}
  1346. AND inspection_type_no = #{inspectionTypeNo}
  1347. <if test="itemNo != null and itemNo != ''">
  1348. AND ItemNo LIKE '%' + #{itemNo} + '%'
  1349. </if>
  1350. <if test="itemDesc != null and itemDesc != ''">
  1351. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  1352. </if>
  1353. AND ItemNo NOT IN (
  1354. SELECT item_no
  1355. FROM qc_sqc_detailed_record
  1356. WHERE site = #{site}
  1357. AND bu_no = #{buNo}
  1358. AND inspection_no = #{inspectionNo}
  1359. )
  1360. ORDER BY ItemNo
  1361. </select>
  1362. <select id="getSQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  1363. SELECT
  1364. d.item_no as itemNo,
  1365. d.item_desc as itemDesc
  1366. FROM qc_sqc_detailed_record d
  1367. WHERE d.site = #{site}
  1368. AND d.bu_no = #{buNo}
  1369. AND d.inspection_no = #{inspectionNo}
  1370. ORDER BY d.item_no
  1371. </select>
  1372. <select id="getExistingSQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  1373. SELECT TOP 1
  1374. template_id as templateId,
  1375. item_no as itemNo,
  1376. item_desc as itemDesc
  1377. FROM qc_sqc_detailed_record
  1378. WHERE site = #{site}
  1379. AND bu_no = #{buNo}
  1380. AND inspection_no = #{inspectionNo}
  1381. ORDER BY item_no
  1382. </select>
  1383. <insert id="insertSQCItemDetail" parameterType="java.util.Map">
  1384. INSERT INTO qc_sqc_detailed_record (
  1385. inspection_no,
  1386. template_id,
  1387. item_no,
  1388. item_desc,
  1389. default_value,
  1390. min_value,
  1391. max_value,
  1392. value_type_db,
  1393. value_type,
  1394. site,
  1395. bu_no,
  1396. order_id
  1397. ) VALUES (
  1398. #{inspectionNo},
  1399. #{templateId},
  1400. #{itemNo},
  1401. #{itemDesc},
  1402. #{defaultValue},
  1403. #{minValue},
  1404. #{maxValue},
  1405. #{valueTypeDb},
  1406. #{valueType},
  1407. #{site},
  1408. #{buNo},
  1409. #{orderId}
  1410. )
  1411. </insert>
  1412. <select id="getMaxOrderIdForSQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  1413. SELECT ISNULL(MAX(order_id), 0)
  1414. FROM qc_sqc_detailed_record
  1415. WHERE site = #{site}
  1416. AND bu_no = #{buNo}
  1417. AND inspection_no = #{inspectionNo}
  1418. </select>
  1419. <delete id="deleteSQCItemDetail" parameterType="java.util.Map">
  1420. DELETE FROM qc_sqc_detailed_record
  1421. WHERE site = #{site}
  1422. AND bu_no = #{buNo}
  1423. AND inspection_no = #{inspectionNo}
  1424. AND item_no = #{itemNo}
  1425. </delete>
  1426. <delete id="deleteSQCSubDetailByItem" parameterType="java.util.Map">
  1427. DELETE FROM qc_sqc_sub_detail_record
  1428. WHERE site = #{site}
  1429. AND bu_no = #{buNo}
  1430. AND inspection_no = #{inspectionNo}
  1431. AND item_no = #{itemNo}
  1432. </delete>
  1433. <select id="getSQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  1434. SELECT
  1435. t.template_id as templateId,
  1436. t.template_name as templateName,
  1437. t.template_remark as remark,
  1438. (SELECT COUNT(*) FROM qc_template_detailed d
  1439. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  1440. FROM qc_template t
  1441. WHERE t.site = #{site}
  1442. AND t.bu_no = #{buNo}
  1443. AND t.inspection_type_no = #{inspectionTypeNo}
  1444. <if test="templateId != null and templateId != ''">
  1445. AND t.template_id LIKE '%' + #{templateId} + '%'
  1446. </if>
  1447. <if test="templateDesc != null and templateDesc != ''">
  1448. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  1449. </if>
  1450. ORDER BY t.template_id
  1451. </select>
  1452. <select id="getExistingSQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  1453. SELECT item_no
  1454. FROM qc_sqc_detailed_record
  1455. WHERE site = #{site}
  1456. AND bu_no = #{buNo}
  1457. AND inspection_no = #{inspectionNo}
  1458. </select>
  1459. <select id="getSQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  1460. select
  1461. a.site,
  1462. a.bu_no,
  1463. b.collection_condition as equipmentNo,
  1464. #{inspectionNo} as inspectionNo,
  1465. a.item_no,
  1466. b.collection_source,
  1467. #{actionBy} as actionBy,
  1468. b.collection_method
  1469. from qc_sqc_detailed_record as a
  1470. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  1471. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  1472. order by a.order_id
  1473. </select>
  1474. <!-- 查询工序列表 -->
  1475. <select id="getOperationList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1476. SELECT DISTINCT
  1477. operation_description as operationDesc
  1478. FROM View_IFS_Shop_Order_Operation
  1479. WHERE site = #{site}
  1480. AND order_no = #{orderNo}
  1481. AND release_no = #{releaseNo}
  1482. AND sequence_no = #{lineNo}
  1483. <!--<choose>
  1484. <when test="orderNo != null and orderNo != '' and releaseNo != null and releaseNo != '' and lineNo != null and lineNo != ''">
  1485. SELECT DISTINCT
  1486. operation_description as operationDesc
  1487. FROM View_IFS_Shop_Order_Operation
  1488. WHERE site = #{site}
  1489. AND order_no = #{orderNo}
  1490. AND release_no = #{releaseNo}
  1491. AND sequence_no = #{lineNo}
  1492. </when>
  1493. <otherwise>
  1494. SELECT
  1495. DISTINCT
  1496. a.seqno as seqNo,
  1497. a.orderno as orderNo,
  1498. j.partNo,
  1499. j.PartDescription as partDesc,
  1500. j.PartType as invdefinetype,
  1501. j.sku,
  1502. c.operationDesc as operationDesc,
  1503. a.itemno as operationNo,
  1504. a.s_resourceid as resourceId,
  1505. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1506. c.WorkCenterNo
  1507. FROM soscheduledrouting as a
  1508. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  1509. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  1510. LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
  1511. WHERE a.site = #{site} and a.seqno = #{seqNo}
  1512. </otherwise>
  1513. </choose>-->
  1514. </select>
  1515. <!-- 根据工单号和工序号查出所有数据 -->
  1516. <select id="getResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1517. SELECT
  1518. a.s_resourceid as resourceId,
  1519. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1520. c.workCenterNo
  1521. FROM soscheduledrouting as a
  1522. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  1523. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  1524. <!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
  1525. WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
  1526. ORDER BY a.id desc
  1527. </select>
  1528. <!-- 查询机台名称 -->
  1529. <select id="selectResourceDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1530. SELECT distinct
  1531. resourceDesc
  1532. FROM WorkCenterResource
  1533. WHERE site = #{site} and resourceId = #{resourceId}
  1534. </select>
  1535. <!-- 查询物料名称 -->
  1536. <select id="selectPartDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1537. SELECT distinct
  1538. PartDescription as part_desc
  1539. FROM part
  1540. WHERE site = #{site} and partNo = #{partNo}
  1541. </select>
  1542. <!-- ================================================= IQC检验维护 ================================================= -->
  1543. <!-- 查询IQC基础数据 -->
  1544. <select id="selectIQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1545. SELECT
  1546. qir.inspection_no,
  1547. qir.state,
  1548. qir.defect_tracking_flag as defectTrackingFlag,
  1549. qir.create_date as taskDate,
  1550. qir.roll_no,
  1551. qir.part_no,
  1552. p.PartDescription as part_desc,
  1553. p.cinv_source_code,
  1554. p.sku as sku,
  1555. qir.roll_qty,
  1556. qir.print_flag,
  1557. qir.inspector_by,
  1558. qir.supplier_no,
  1559. qir.site,
  1560. qir.bu_no,
  1561. qir.po_orderNo,
  1562. qir.po_itemNo,
  1563. qir.roll_count,
  1564. qir.document_no
  1565. FROM qc_iqc_record as qir
  1566. LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
  1567. WHERE qir.site in (select site from AccessSite where userID = #{userName})
  1568. and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
  1569. and qir.detail_flag = 'N'
  1570. </select>
  1571. <!-- 新增IQC明细记录信息 -->
  1572. <insert id="saveIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1573. INSERT INTO qc_iqc_detailed_record (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value, max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
  1574. VALUES(#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  1575. </insert>
  1576. <!-- 生成IQC检验单号:格式 IQC + YYYYMMDD + 3位流水(与 GetAutogenerateinspectiontasks 一致) -->
  1577. <select id="selectIQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1578. SELECT
  1579. CONVERT(VARCHAR(8), GETDATE(), 112)
  1580. + RIGHT('000' + CONVERT(VARCHAR(3), ISNULL(MAX(CONVERT(INT, RIGHT(inspection_no, 3))), 0) + 1), 3)
  1581. FROM qc_iqc_record
  1582. WHERE site = #{site}
  1583. AND bu_no = #{buNo}
  1584. AND inspection_no LIKE 'IQC' + CONVERT(VARCHAR(8), GETDATE(), 112) + '%'
  1585. AND LEN(inspection_no) >= 14
  1586. </select>
  1587. <!-- 新增IQC主记录信息(刀模新增等直接保存场景) -->
  1588. <insert id="saveIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1589. INSERT INTO qc_iqc_record
  1590. (inspection_no, site, bu_no, state, create_date, inspection_type_no, part_no, part_desc,
  1591. roll_qty, roll_count, roll_no, supplier_no, create_by, inspector_by, detail_flag, submission_type,
  1592. tool_instance_id, qualified_supplier_flag, supplier_avl_no, die_mold_type, special_requirements)
  1593. VALUES
  1594. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{partNo}, #{partDesc,jdbcType=VARCHAR},
  1595. #{rollQty,jdbcType=DECIMAL}, #{rollCount,jdbcType=DECIMAL}, #{rollNo,jdbcType=VARCHAR}, #{supplierNo,jdbcType=VARCHAR}, #{createBy}, #{inspectorBy},
  1596. 'N', #{taskSource,jdbcType=VARCHAR},
  1597. #{toolInstanceId,jdbcType=VARCHAR}, #{qualifiedSupplierFlag,jdbcType=CHAR}, #{supplierAvlNo,jdbcType=VARCHAR}, #{dieMoldType,jdbcType=NVARCHAR}, #{specialRequirements,jdbcType=VARCHAR})
  1598. </insert>
  1599. <!-- 修改IQC检验记录 -->
  1600. <update id="updateIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1601. UPDATE qc_iqc_record
  1602. SET inspection_type_no = #{inspectionTypeNo},
  1603. sampling_qty = #{samplingQty},
  1604. inspection_cycle = #{inspectionCycle},
  1605. part_desc = #{partDesc},
  1606. detail_flag = 'Y',
  1607. state = '未开始',
  1608. action_date = null,
  1609. action_by = null
  1610. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1611. </update>
  1612. <!-- 新增IQC记录后更新送检数量及送检单位 -->
  1613. <update id="updateIQCRecordRollCountOnAdd" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1614. UPDATE qc_iqc_record
  1615. SET roll_count = #{rollCount,jdbcType=DECIMAL}
  1616. <if test="inspectionUmId != null and inspectionUmId != ''">
  1617. , inspection_um_id = #{inspectionUmId,jdbcType=NVARCHAR}
  1618. </if>
  1619. WHERE site = #{site}
  1620. AND bu_no = #{buNo}
  1621. AND po_orderNo = #{poOrderNo}
  1622. AND po_itemNo = #{poItemNo}
  1623. AND part_no = #{partNo}
  1624. AND inspection_no = (
  1625. SELECT TOP 1 inspection_no
  1626. FROM qc_iqc_record
  1627. WHERE site = #{site}
  1628. AND bu_no = #{buNo}
  1629. AND po_orderNo = #{poOrderNo}
  1630. AND po_itemNo = #{poItemNo}
  1631. AND part_no = #{partNo}
  1632. ORDER BY create_date DESC
  1633. )
  1634. </update>
  1635. <!-- 刀模新增后更新扩展字段 -->
  1636. <update id="updateIQCRecordDieMoldOnAdd" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1637. UPDATE qc_iqc_record
  1638. SET roll_count = #{rollCount,jdbcType=DECIMAL},
  1639. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1640. supplier_no = #{supplierNo,jdbcType=VARCHAR},
  1641. tool_instance_id = #{toolInstanceId,jdbcType=VARCHAR},
  1642. qualified_supplier_flag = #{qualifiedSupplierFlag,jdbcType=CHAR},
  1643. supplier_avl_no = #{supplierAvlNo,jdbcType=VARCHAR},
  1644. die_mold_type = #{dieMoldType,jdbcType=NVARCHAR}
  1645. WHERE site = #{site}
  1646. AND bu_no = #{buNo}
  1647. AND part_no = #{partNo}
  1648. AND inspection_no = (
  1649. SELECT TOP 1 inspection_no
  1650. FROM qc_iqc_record
  1651. WHERE site = #{site}
  1652. AND bu_no = #{buNo}
  1653. AND part_no = #{partNo}
  1654. ORDER BY create_date DESC
  1655. )
  1656. </update>
  1657. <!-- 新增检验记录后更新下达号、行号 -->
  1658. <update id="updateRecordReleaseNoLineNoOnAdd">
  1659. UPDATE
  1660. <choose>
  1661. <when test="recordType == 'IQC'">qc_iqc_record</when>
  1662. <when test="recordType == 'IPQC'">qc_ipqc_record</when>
  1663. <when test="recordType == 'FQC'">qc_fqc_record</when>
  1664. <when test="recordType == 'OQC'">qc_oqc_record</when>
  1665. <when test="recordType == 'SQC'">qc_sqc_record</when>
  1666. </choose>
  1667. SET release_no = #{data.releaseNo,jdbcType=VARCHAR},
  1668. line_no = #{data.lineNo,jdbcType=VARCHAR}
  1669. WHERE site = #{data.site}
  1670. AND bu_no = #{data.buNo}
  1671. <choose>
  1672. <when test="data.inspectionNo != null and data.inspectionNo != ''">
  1673. AND inspection_no = #{data.inspectionNo}
  1674. </when>
  1675. <when test="recordType == 'IQC'">
  1676. AND po_orderNo = #{data.poOrderNo}
  1677. AND po_itemNo = #{data.poItemNo}
  1678. AND part_no = #{data.partNo}
  1679. AND inspection_no = (
  1680. SELECT TOP 1 inspection_no
  1681. FROM qc_iqc_record
  1682. WHERE site = #{data.site}
  1683. AND bu_no = #{data.buNo}
  1684. AND po_orderNo = #{data.poOrderNo}
  1685. AND po_itemNo = #{data.poItemNo}
  1686. AND part_no = #{data.partNo}
  1687. ORDER BY create_date DESC
  1688. )
  1689. </when>
  1690. <when test="recordType == 'OQC'">
  1691. AND part_no = #{data.partNo}
  1692. AND inspector_by = #{data.inspectorBy}
  1693. AND inspection_no = (
  1694. SELECT TOP 1 inspection_no
  1695. FROM qc_oqc_record
  1696. WHERE site = #{data.site}
  1697. AND bu_no = #{data.buNo}
  1698. AND part_no = #{data.partNo}
  1699. AND inspector_by = #{data.inspectorBy}
  1700. ORDER BY create_date DESC
  1701. )
  1702. </when>
  1703. <otherwise>
  1704. AND order_no = #{data.orderNo}
  1705. AND seq_no = #{data.seqNo}
  1706. AND part_no = #{data.partNo}
  1707. AND inspection_no = (
  1708. SELECT TOP 1 inspection_no
  1709. FROM
  1710. <choose>
  1711. <when test="recordType == 'IPQC'">qc_ipqc_record</when>
  1712. <when test="recordType == 'FQC'">qc_fqc_record</when>
  1713. <when test="recordType == 'SQC'">qc_sqc_record</when>
  1714. </choose>
  1715. WHERE site = #{data.site}
  1716. AND bu_no = #{data.buNo}
  1717. AND order_no = #{data.orderNo}
  1718. AND seq_no = #{data.seqNo}
  1719. AND part_no = #{data.partNo}
  1720. ORDER BY create_date DESC
  1721. )
  1722. </otherwise>
  1723. </choose>
  1724. </update>
  1725. <!-- 查询IQC主记录信息 -->
  1726. <select id="qcIQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1727. SELECT
  1728. a.inspection_no,
  1729. a.site,
  1730. a.bu_no,
  1731. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1732. a.state,
  1733. a.defect_tracking_flag as defectTrackingFlag,
  1734. a.inspection_result,
  1735. a.create_date as taskDate,
  1736. a.create_date,
  1737. a.inspection_type_no,
  1738. a.inspection_cycle,
  1739. a.part_no,
  1740. d.PartDescription as partDesc,
  1741. d.cinv_source_code as cinvSourceCode,
  1742. d.sku,
  1743. d.umid as umId,
  1744. um.UMName as umName,
  1745. d.PartType as invdefinetype,
  1746. d.spec,
  1747. a.inspection_remark,
  1748. a.roll_qty,
  1749. a.sampling_qty,
  1750. a.disposal_measures,
  1751. a.disposal_remark,
  1752. a.inspector_date as inspectorDate,
  1753. a.submit_date,
  1754. isnull(sub.user_display, a.submit_by) as submitBy,
  1755. a.inspector_no,
  1756. u.user_display as inspectorName,
  1757. a.unqualified_quantity,
  1758. a.submit_flag,
  1759. a.roll_no,
  1760. a.supplier_no,
  1761. s.SupplierName as supplierDesc,
  1762. a.po_orderNo,
  1763. a.po_itemNo,
  1764. a.roll_count,
  1765. a.inspection_um_id as inspectionUmId,
  1766. inspectionUm.UMName as inspectionUmName,
  1767. a.roll_count as dhjs,
  1768. dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) as orderType,
  1769. a.action_date,
  1770. isnull(ab.user_display, a.action_by) as actionBy,
  1771. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1772. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1773. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1774. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1775. a.submission_remark,
  1776. a.submission_type as submissionType,
  1777. a.tool_instance_id as toolInstanceId,
  1778. a.qualified_supplier_flag as qualifiedSupplierFlag,
  1779. a.supplier_avl_no as supplierAvlNo,
  1780. a.die_mold_type as dieMoldType,
  1781. a.batch_no,
  1782. a.production_date,
  1783. a.expiration_warning_date,
  1784. a.expiration_date,
  1785. a.pass_qty,
  1786. a.not_pass_qty,
  1787. a.batch_qualified_qty,
  1788. a.release_no as releaseNo,
  1789. a.line_no,
  1790. a.document_no,
  1791. isnull(a.inspector_by, a.create_by) as inspectorBy,
  1792. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName,
  1793. a.upper_system_flag as upperSystemFlag
  1794. FROM qc_iqc_record as a
  1795. <include refid="iqcInspectionPartJoins"/>
  1796. <include refid="iqcInspectionRecordJoins"/>
  1797. <include refid="iqcInspectionRecordWhere"/>
  1798. <include refid="iqcInspectionPartFilters"/>
  1799. ORDER BY a.inspection_no desc,
  1800. CASE WHEN a.state = '待检验' THEN 1
  1801. WHEN a.state = '待审核' THEN 2
  1802. WHEN a.state = '已完成' THEN 3
  1803. END, a.create_date desc
  1804. </select>
  1805. <sql id="iqcInspectionPartJoins">
  1806. <include refid="iqcInspectionPartJoin"/>
  1807. left join um as um on d.umid = um.UMID
  1808. </sql>
  1809. <sql id="iqcInspectionPartJoin">
  1810. inner join part as d on a.site = d.site and a.part_no = d.partNo
  1811. </sql>
  1812. <sql id="iqcInspectionRecordJoins">
  1813. left join view_Supplier as s on a.supplier_no = s.SupplierID
  1814. left join sys_user as u on a.inspector_no = u.username
  1815. left join sys_user as ab on a.action_by = ab.username
  1816. left join sys_user as sub on a.submit_by = sub.username
  1817. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  1818. left join um as inspectionUm on a.inspection_um_id = inspectionUm.UMID
  1819. </sql>
  1820. <sql id="iqcInspectionRecordWhere">
  1821. <where>
  1822. a.site in (select site from AccessSite where userID = #{query.userName})
  1823. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  1824. <if test="query.site != null and query.site != ''">
  1825. AND a.site = #{query.site}
  1826. </if>
  1827. <if test="query.buNo != null and query.buNo != ''">
  1828. AND a.bu_no = #{query.buNo}
  1829. </if>
  1830. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1831. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1832. </if>
  1833. <if test = "query.states != null and query.states.size > 0">
  1834. AND a.state in
  1835. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  1836. #{item}
  1837. </foreach>
  1838. </if>
  1839. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1840. AND a.inspection_result = #{query.inspectionResult}
  1841. </if>
  1842. <if test = "query.partNo != null and query.partNo != ''">
  1843. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  1844. </if>
  1845. <if test = "query.partDesc != null and query.partDesc != ''">
  1846. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  1847. </if>
  1848. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  1849. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  1850. </if>
  1851. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1852. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1853. </if>
  1854. <if test = "query.inspectorName != null and query.inspectorName != ''">
  1855. AND u.user_display LIKE '%' + #{query.inspectorName} + '%'
  1856. </if>
  1857. <if test="query.startDate != null">
  1858. AND a.inspector_date >= #{query.startDate}
  1859. </if>
  1860. <if test="query.endDate != null">
  1861. AND #{query.endDate} >= a.inspector_date
  1862. </if>
  1863. <if test="query.startDate2 != null">
  1864. AND a.create_date >= #{query.startDate2}
  1865. </if>
  1866. <if test="query.endDate2 != null">
  1867. AND #{query.endDate2} >= a.create_date
  1868. </if>
  1869. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  1870. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  1871. </if>
  1872. <if test = "query.poItemNo != null and query.poItemNo != ''">
  1873. AND a.po_itemNo LIKE '%' + #{query.poItemNo} + '%'
  1874. </if>
  1875. <if test = "query.orderType != null and query.orderType != ''">
  1876. AND dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) = #{query.orderType}
  1877. </if>
  1878. <if test = "query.submissionType != null and query.submissionType != ''">
  1879. AND a.submission_type = #{query.submissionType}
  1880. </if>
  1881. <if test = "query.documentNo != null and query.documentNo != ''">
  1882. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  1883. </if>
  1884. </where>
  1885. </sql>
  1886. <sql id="iqcInspectionPartFilters">
  1887. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1888. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1889. </if>
  1890. <if test = "query.sku != null and query.sku != ''">
  1891. AND d.sku LIKE '%' + #{query.sku} + '%'
  1892. </if>
  1893. <if test = "query.invdefinetype != null and query.invdefinetype != ''">
  1894. AND d.PartType LIKE '%' + #{query.invdefinetype} + '%'
  1895. </if>
  1896. <if test = "query.spec != null and query.spec != ''">
  1897. AND d.spec LIKE '%' + #{query.spec} + '%'
  1898. </if>
  1899. </sql>
  1900. <sql id="iqcInspectionCountWithLookups">
  1901. SELECT COALESCE(SUM(a.record_count), 0)
  1902. FROM (
  1903. SELECT a.site, a.part_no, COUNT_BIG(*) AS record_count
  1904. FROM qc_iqc_record as a
  1905. <include refid="iqcInspectionRecordJoins"/>
  1906. <include refid="iqcInspectionRecordWhere"/>
  1907. GROUP BY a.site, a.part_no
  1908. ) as a
  1909. <include refid="iqcInspectionPartJoins"/>
  1910. <where><include refid="iqcInspectionPartFilters"/></where>
  1911. </sql>
  1912. <select id="qcIQCInspectionSearchCount" resultType="java.lang.Long">
  1913. <choose>
  1914. <when test="(query.supplierDesc != null and query.supplierDesc != '') or (query.inspectorName != null and query.inspectorName != '')">
  1915. <include refid="iqcInspectionCountWithLookups"/>
  1916. </when>
  1917. <otherwise>
  1918. <!-- 展示表的关联键有重复时,列表的一条检验记录可能对应多行。 -->
  1919. SELECT CASE WHEN
  1920. EXISTS (SELECT 1 FROM view_Supplier WHERE SupplierID IS NOT NULL
  1921. GROUP BY SupplierID HAVING COUNT_BIG(*) > 1)
  1922. OR EXISTS (SELECT 1 FROM sys_user WHERE username IS NOT NULL
  1923. GROUP BY username HAVING COUNT_BIG(*) > 1)
  1924. OR EXISTS (SELECT 1 FROM um WHERE UMID IS NOT NULL
  1925. GROUP BY UMID HAVING COUNT_BIG(*) > 1)
  1926. THEN (
  1927. <include refid="iqcInspectionCountWithLookups"/>
  1928. ) ELSE (
  1929. SELECT COALESCE(SUM(a.record_count), 0)
  1930. FROM (
  1931. SELECT a.site, a.part_no, COUNT_BIG(*) AS record_count
  1932. FROM qc_iqc_record as a
  1933. <include refid="iqcInspectionRecordWhere"/>
  1934. GROUP BY a.site, a.part_no
  1935. ) as a
  1936. <include refid="iqcInspectionPartJoin"/>
  1937. <where><include refid="iqcInspectionPartFilters"/></where>
  1938. ) END
  1939. </otherwise>
  1940. </choose>
  1941. </select>
  1942. <!-- IQC明细记录查询 -->
  1943. <select id="iqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1944. SELECT
  1945. a.site,
  1946. a.bu_no,
  1947. a.inspection_no,
  1948. a.template_id,
  1949. a.sampling_level_no,
  1950. a.sampling_level_desc,
  1951. a.sampling_programme_no,
  1952. a.sampling_programme_desc,
  1953. a.AQL,
  1954. a.AC,
  1955. a.RE,
  1956. a.item_no,
  1957. a.item_desc,
  1958. a.object_id,
  1959. a.object_desc,
  1960. a.default_value,
  1961. a.min_value,
  1962. a.max_value,
  1963. a.text_value,
  1964. a.number_value,
  1965. a.value_type_db,
  1966. a.value_type,
  1967. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1968. a.item_remark as itemRemark,
  1969. a.custom1,
  1970. a.custom2,
  1971. a.custom3,
  1972. a.is_submit,
  1973. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1974. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1975. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  1976. c.method_no,
  1977. c.method_name,
  1978. c.method_remark,
  1979. sw.color_code as qcSpecWarningColorCode,
  1980. sw.threshold_value as qcSpecWarningThresholdValue,
  1981. a.sampling_qty,
  1982. (SELECT TOP 1 epi.collection_flag
  1983. FROM eam_properties_item epi
  1984. WHERE epi.site = a.site
  1985. AND epi.bu_no = a.bu_no
  1986. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1987. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1988. epi.inspection_type_no) AS collectionFlag,
  1989. (SELECT TOP 1 epi.image_flag
  1990. FROM eam_properties_item epi
  1991. WHERE epi.site = a.site
  1992. AND epi.bu_no = a.bu_no
  1993. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1994. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1995. epi.inspection_type_no) AS imageFlag,
  1996. (SELECT TOP 1 epi.data_flag
  1997. FROM eam_properties_item epi
  1998. WHERE epi.site = a.site
  1999. AND epi.bu_no = a.bu_no
  2000. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2001. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2002. epi.inspection_type_no) AS dataFlag
  2003. FROM qc_iqc_detailed_record as a
  2004. LEFT JOIN qc_iqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  2005. OUTER APPLY (
  2006. SELECT TOP 1
  2007. w.color_code,
  2008. w.threshold_value
  2009. FROM qc_spec_warning w
  2010. WHERE w.site = a.site
  2011. AND w.bu_no = a.bu_no
  2012. AND w.part_no = r.part_no
  2013. AND w.item_no = a.item_no
  2014. AND w.inspection_type_no = r.inspection_type_no
  2015. ORDER BY w.threshold_value
  2016. ) sw
  2017. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  2018. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  2019. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2020. order by a.order_id
  2021. </select>
  2022. <!-- 查询IQC的子明细 -->
  2023. <select id="selectIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2024. SELECT
  2025. site,
  2026. bu_no,
  2027. sub_detail_value,
  2028. sampling_location,
  2029. is_submit,
  2030. sampling_location_b,
  2031. num,
  2032. sub_detail_value_b,
  2033. sub_detail_value_c,
  2034. sub_detail_value_d,
  2035. sub_detail_value_e,
  2036. file_name,
  2037. is_transfer,
  2038. is_qualified,
  2039. defect_qty,
  2040. roll_no,
  2041. product_quantity as productQuantity,
  2042. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  2043. FROM qc_iqc_sub_detail_record
  2044. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2045. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2046. AND sub_detail_value ${collectionDataContent}
  2047. </if>
  2048. </select>
  2049. <!-- 获取该项目的子明细值 -->
  2050. <select id="selectIQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2051. SELECT sub_detail_value,
  2052. sampling_location,
  2053. is_submit
  2054. FROM qc_iqc_sub_detail_record
  2055. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2056. </select>
  2057. <!-- 修改IQC主记录信息 -->
  2058. <update id="updateIQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2059. UPDATE qc_iqc_record
  2060. SET disposal_measures = #{disposalMeasures},
  2061. disposal_remark = #{disposalRemark},
  2062. inspection_result = #{inspectionResult},
  2063. inspector_no = #{inspectorNo},
  2064. state = #{state},
  2065. inspection_remark = #{inspectionRemark},
  2066. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  2067. roll_count = #{rollCount,jdbcType=DECIMAL},
  2068. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2069. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2070. pass_qty = #{passQty,jdbcType=DECIMAL},
  2071. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2072. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  2073. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2074. </update>
  2075. <!-- 修改IQC明细记录信息 -->
  2076. <update id="updateIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2077. UPDATE qc_iqc_detailed_record
  2078. SET item_result = #{itemResult},
  2079. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2080. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2081. text_value = #{textValue},
  2082. number_value = #{numberValue,jdbcType=DECIMAL},
  2083. default_value = #{defaultValue},
  2084. min_value = #{minValue,jdbcType=DECIMAL},
  2085. max_value = #{maxValue,jdbcType=DECIMAL},
  2086. item_remark = #{itemRemark},
  2087. custom1 = #{custom1},
  2088. custom2 = #{custom2},
  2089. custom3 = #{custom3}
  2090. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2091. </update>
  2092. <!-- 部分更新IQC明细(实测值/结论即时落库,避免 null 覆盖其他字段) -->
  2093. <update id="patchIQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2094. UPDATE qc_iqc_detailed_record
  2095. <set>
  2096. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  2097. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  2098. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  2099. <if test="textValue != null">text_value = #{textValue},</if>
  2100. </set>
  2101. WHERE inspection_no = #{inspectionNo}
  2102. and RTRIM(item_no) = RTRIM(#{itemNo})
  2103. and site = #{site}
  2104. and bu_no = #{buNo}
  2105. </update>
  2106. <!-- 查询该记录明细是否已存在 -->
  2107. <select id="checkIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2108. SELECT inspection_no,
  2109. template_id
  2110. FROM qc_iqc_detailed_record
  2111. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2112. </select>
  2113. <!-- 查询IQC检验记录是否已提交 -->
  2114. <select id="checkIQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2115. SELECT submit_flag
  2116. FROM qc_iqc_record
  2117. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2118. </select>
  2119. <!-- 查询IQC检验记录状态(用于保存前校验) -->
  2120. <select id="getIQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2121. SELECT submit_flag, state
  2122. FROM qc_iqc_record
  2123. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2124. </select>
  2125. <!-- 删除IQC子明细的老数据 -->
  2126. <delete id="delIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  2127. DELETE FROM qc_iqc_sub_detail_record
  2128. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2129. </delete>
  2130. <!-- 新增IQC子明细信息 -->
  2131. <insert id="saveIQCSubDetailed">
  2132. INSERT INTO qc_iqc_sub_detail_record
  2133. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, product_quantity, create_time)
  2134. VALUES
  2135. <foreach collection="list" item="item" separator=",">
  2136. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, #{item.productQuantity,jdbcType=DECIMAL}, getDate())
  2137. </foreach>
  2138. </insert>
  2139. <!-- 修改IQC主记录标识为已提交 -->
  2140. <update id="updateIQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2141. UPDATE qc_iqc_record
  2142. SET submit_flag = 'Y',
  2143. state = '已完成',
  2144. submit_date = getDate(),
  2145. submit_by = #{updateBy}
  2146. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2147. </update>
  2148. <!-- 修改IQC明细记录标识为已提交 -->
  2149. <update id="updateIQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2150. UPDATE qc_iqc_detailed_record
  2151. SET is_submit = 'Y'
  2152. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2153. </update>
  2154. <!-- 修改IQC子明细记录标识为已提交 -->
  2155. <update id="updateIQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2156. UPDATE qc_iqc_sub_detail_record
  2157. SET is_submit = 'Y'
  2158. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2159. </update>
  2160. <!-- 删除IQC检验记录 -->
  2161. <delete id="deleteIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2162. DELETE FROM qc_iqc_record
  2163. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2164. </delete>
  2165. <!-- 删除IQC明细记录信息 -->
  2166. <delete id="deleteIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2167. DELETE FROM qc_iqc_detailed_record
  2168. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2169. </delete>
  2170. <!-- 删除IQC子明细记录信息 -->
  2171. <delete id="deleteIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2172. DELETE FROM qc_iqc_sub_detail_record
  2173. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2174. </delete>
  2175. <!-- 查询文件ID -->
  2176. <select id="queryFileId" parameterType="com.gaotao.modules.oss.entity.SysOssEntity" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  2177. SELECT id, file_name
  2178. FROM sys_oss
  2179. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  2180. </select>
  2181. <!-- 获取工序列表 -->
  2182. <select id="getOperationDescList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
  2183. SELECT distinct
  2184. operationDesc
  2185. FROM view_SO_Routing
  2186. <where>
  2187. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2188. AND operationDesc LIKE '%' + #{query.operationDesc} + '%'
  2189. </if>
  2190. <if test="query.site != null and query.site != ''">
  2191. AND site = #{query.site}
  2192. </if>
  2193. </where>
  2194. </select>
  2195. <!-- 获取供应商列表 -->
  2196. <select id="getManufacturerList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
  2197. SELECT
  2198. supplierID as manufacturerID,
  2199. supplierName as manufacturerName
  2200. FROM view_Supplier
  2201. <where>
  2202. <if test = "query.manufacturerID != null and query.manufacturerID != ''">
  2203. AND supplierID LIKE '%' + #{query.manufacturerID} + '%'
  2204. </if>
  2205. <if test = "query.manufacturerName != null and query.manufacturerName != ''">
  2206. AND supplierName LIKE '%' + #{query.manufacturerName} + '%'
  2207. </if>
  2208. </where>
  2209. </select>
  2210. <!-- 获取机台列表 -->
  2211. <select id="getAllResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2212. SELECT distinct
  2213. resourceId,
  2214. resourceDesc
  2215. FROM WorkCenterResource
  2216. <where>
  2217. site = #{site}
  2218. <if test = "resourceId != null and resourceId != ''">
  2219. AND resourceId LIKE '%' + #{resourceId} + '%'
  2220. </if>
  2221. <if test = "resourceDesc != null and resourceDesc != ''">
  2222. AND resourceDesc LIKE '%' + #{resourceDesc} + '%'
  2223. </if>
  2224. </where>
  2225. </select>
  2226. <!-- 获取工单列表 -->
  2227. <select id="getOrderNoList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2228. SELECT DISTINCT
  2229. a.orderno as orderNo
  2230. FROM soscheduledrouting as a
  2231. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2232. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  2233. <!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
  2234. <where>
  2235. a.site = #{site}
  2236. AND b.approve_qty is not null
  2237. <if test = "orderNo != null and orderNo != ''">
  2238. AND a.orderno LIKE '%' + #{orderNo} + '%'
  2239. </if>
  2240. </where>
  2241. order by a.orderno DESC
  2242. </select>
  2243. <!-- 查询FQC主记录信息 -->
  2244. <select id="qcFQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2245. SELECT
  2246. a.inspection_no,
  2247. a.site,
  2248. a.bu_no,
  2249. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2250. a.state,
  2251. a.inspection_result,
  2252. a.task_date,
  2253. a.create_date,
  2254. a.inspection_type_no,
  2255. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  2256. a.inspection_cycle,
  2257. a.order_no,
  2258. a.operation_desc,
  2259. a.resource_id,
  2260. r.resourceDesc,
  2261. a.part_no,
  2262. d.PartDescription as part_desc,
  2263. d.cinv_source_code as cinvSourceCode,
  2264. d.sku as sku,
  2265. d.PartType as invdefinetype,
  2266. d.spec,
  2267. a.inspection_remark,
  2268. a.roll_qty,
  2269. a.sampling_qty,
  2270. a.disposal_measures,
  2271. a.disposal_remark,
  2272. a.inspector_date as inspectorDate,
  2273. a.submit_date,
  2274. isnull(su.user_display, a.submit_by) as submitBy,
  2275. a.inspector_no,
  2276. u.user_display as inspectorName,
  2277. a.ssr_id,
  2278. a.unqualified_qty,
  2279. a.submit_flag,
  2280. a.seq_no,
  2281. a.batch_roll_no,
  2282. a.special_requirements,
  2283. a.work_center_no,
  2284. a.roll_no,
  2285. a.um_id,
  2286. um.UMName as umName,
  2287. a.action_date,
  2288. isnull(ab.user_display, a.action_by) as actionBy,
  2289. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2290. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2291. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2292. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2293. a.pass_qty,
  2294. a.not_pass_qty,
  2295. a.batch_qualified_qty,
  2296. a.document_no,
  2297. a.release_no as releaseNo,
  2298. a.line_no,
  2299. isnull(a.inspector_by, a.create_by) as inspectorBy,
  2300. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName,
  2301. a.upper_system_flag as upperSystemFlag
  2302. FROM qc_fqc_record as a
  2303. inner join part as d on a.site = d.site and a.part_no = d.partNo
  2304. left join sys_user as u on a.inspector_no = u.username
  2305. left join sys_user as ab on a.action_by = ab.username
  2306. left join sys_user as su on a.submit_by = su.username
  2307. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  2308. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  2309. left join UM as um on a.site = um.site and a.um_id = um.UMID
  2310. <where>
  2311. a.site in (select site from AccessSite where userID = #{query.userName})
  2312. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  2313. <if test="query.site != null and query.site != ''">
  2314. AND a.site = #{query.site}
  2315. </if>
  2316. <if test="query.buNo != null and query.buNo != ''">
  2317. AND a.bu_no = #{query.buNo}
  2318. </if>
  2319. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2320. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2321. </if>
  2322. <if test = "query.partNo != null and query.partNo != ''">
  2323. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2324. </if>
  2325. <if test = "query.partDesc != null and query.partDesc != ''">
  2326. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  2327. </if>
  2328. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2329. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2330. </if>
  2331. <if test = "query.sku != null and query.sku != ''">
  2332. AND d.sku LIKE '%' + #{query.sku} + '%'
  2333. </if>
  2334. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2335. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2336. </if>
  2337. <if test = "query.states != null and query.states.size > 0">
  2338. AND a.state in
  2339. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2340. #{item}
  2341. </foreach>
  2342. </if>
  2343. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2344. AND a.inspection_result = #{query.inspectionResult}
  2345. </if>
  2346. <if test = "query.orderNo != null and query.orderNo != ''">
  2347. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2348. </if>
  2349. <if test = "query.seqNo != null and query.seqNo != ''">
  2350. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  2351. </if>
  2352. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2353. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2354. </if>
  2355. <if test="query.startDate != null">
  2356. AND a.inspector_date >= #{query.startDate}
  2357. </if>
  2358. <if test="query.endDate != null">
  2359. AND #{query.endDate} >= a.inspector_date
  2360. </if>
  2361. <if test="query.startDate2 != null">
  2362. AND a.task_date >= #{query.startDate2}
  2363. </if>
  2364. <if test="query.endDate2 != null">
  2365. AND #{query.endDate2} >= a.task_date
  2366. </if>
  2367. <if test = "query.spec != null and query.spec != ''">
  2368. AND d.spec LIKE '%' + #{query.spec} + '%'
  2369. </if>
  2370. <if test = "query.documentNo != null and query.documentNo != ''">
  2371. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  2372. </if>
  2373. </where>
  2374. ORDER BY a.inspection_no desc,
  2375. CASE WHEN a.state = '待检验' THEN 1
  2376. WHEN a.state = '待审核' THEN 2
  2377. WHEN a.state = '已完成' THEN 3
  2378. END, a.task_date desc
  2379. </select>
  2380. <insert id="saveFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2381. INSERT INTO qc_fqc_detailed_record
  2382. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2383. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2384. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
  2385. VALUES
  2386. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  2387. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  2388. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  2389. </insert>
  2390. <!-- 新增FQC明细记录信息 -->
  2391. <insert id="saveFQCDetailedRecords">
  2392. INSERT INTO qc_fqc_detailed_record
  2393. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2394. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2395. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  2396. VALUES
  2397. <foreach collection="list" item="item" separator=",">
  2398. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  2399. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  2400. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId}, #{item.custom1}, #{item.custom2}, #{item.custom3})
  2401. </foreach>
  2402. </insert>
  2403. <!-- 新增FQC主记录信息 -->
  2404. <insert id="saveFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2405. INSERT INTO qc_fqc_record
  2406. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  2407. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, create_by, inspector_by)
  2408. VALUES
  2409. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  2410. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
  2411. #{createBy}, #{inspectorBy})
  2412. </insert>
  2413. <!-- FQC明细记录查询 -->
  2414. <select id="fqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2415. SELECT
  2416. a.site,
  2417. a.bu_no,
  2418. a.inspection_no,
  2419. a.order_no,
  2420. a.template_id,
  2421. a.sampling_level_no,
  2422. a.sampling_level_desc,
  2423. a.sampling_programme_no,
  2424. a.sampling_programme_desc,
  2425. a.AQL,
  2426. a.AC,
  2427. a.RE,
  2428. a.item_no,
  2429. a.item_desc,
  2430. a.object_id,
  2431. a.object_desc,
  2432. a.default_value,
  2433. a.min_value,
  2434. a.max_value,
  2435. a.text_value,
  2436. a.number_value,
  2437. a.value_type_db,
  2438. a.value_type,
  2439. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2440. a.item_remark as itemRemark,
  2441. a.custom1,
  2442. a.custom2,
  2443. a.custom3,
  2444. a.is_submit,
  2445. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2446. a.sampling_qty,
  2447. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2448. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  2449. c.method_no,
  2450. c.method_name,
  2451. c.method_remark,
  2452. sw.color_code as qcSpecWarningColorCode,
  2453. sw.threshold_value as qcSpecWarningThresholdValue,
  2454. (SELECT TOP 1 epi.collection_flag
  2455. FROM eam_properties_item epi
  2456. WHERE epi.site = a.site
  2457. AND epi.bu_no = a.bu_no
  2458. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2459. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2460. epi.inspection_type_no) AS collectionFlag,
  2461. (SELECT TOP 1 epi.image_flag
  2462. FROM eam_properties_item epi
  2463. WHERE epi.site = a.site
  2464. AND epi.bu_no = a.bu_no
  2465. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2466. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2467. epi.inspection_type_no) AS imageFlag,
  2468. (SELECT TOP 1 epi.data_flag
  2469. FROM eam_properties_item epi
  2470. WHERE epi.site = a.site
  2471. AND epi.bu_no = a.bu_no
  2472. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2473. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2474. epi.inspection_type_no) AS dataFlag
  2475. FROM qc_fqc_detailed_record as a
  2476. LEFT JOIN qc_fqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  2477. OUTER APPLY (
  2478. SELECT TOP 1
  2479. w.color_code,
  2480. w.threshold_value
  2481. FROM qc_spec_warning w
  2482. WHERE w.site = a.site
  2483. AND w.bu_no = a.bu_no
  2484. AND w.part_no = r.part_no
  2485. AND w.item_no = a.item_no
  2486. AND w.inspection_type_no = r.inspection_type_no
  2487. ORDER BY w.threshold_value
  2488. ) sw
  2489. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  2490. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  2491. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2492. order by a.order_id
  2493. </select>
  2494. <!-- 删除FQC检验记录 -->
  2495. <delete id="deleteFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2496. DELETE FROM qc_fqc_record
  2497. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2498. </delete>
  2499. <!-- 删除FQC明细记录信息 -->
  2500. <delete id="deleteFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2501. DELETE FROM qc_fqc_detailed_record
  2502. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2503. </delete>
  2504. <!-- 删除FQC子明细记录信息 -->
  2505. <delete id="deleteFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2506. DELETE FROM qc_fqc_sub_detail_record
  2507. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2508. </delete>
  2509. <!-- 任务重载:修改FQC检验记录 -->
  2510. <update id="updateFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2511. UPDATE qc_fqc_record
  2512. SET inspection_type_no = #{inspectionTypeNo},
  2513. sampling_qty = #{samplingQty},
  2514. inspection_cycle = #{inspectionCycle},
  2515. state = '未开始',
  2516. inspection_result = null,
  2517. disposal_measures = null,
  2518. disposal_remark = null,
  2519. inspection_remark = null,
  2520. inspector_no = null,
  2521. inspector_date = null,
  2522. submit_flag = 'N',
  2523. action_date = null,
  2524. action_by = null,
  2525. pass_qty = null,
  2526. not_pass_qty = null,
  2527. unqualified_qty = null,
  2528. batch_qualified_qty = null
  2529. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2530. </update>
  2531. <!-- 修改FQC主记录信息 -->
  2532. <update id="updateFQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2533. UPDATE qc_fqc_record
  2534. SET disposal_measures = #{disposalMeasures},
  2535. disposal_remark = #{disposalRemark},
  2536. inspection_result = #{inspectionResult},
  2537. inspector_no = #{inspectorNo},
  2538. state = #{state},
  2539. inspection_remark = #{inspectionRemark},
  2540. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  2541. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2542. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2543. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2544. pass_qty = #{passQty,jdbcType=DECIMAL},
  2545. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2546. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  2547. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2548. </update>
  2549. <!-- 修改FQC明细记录信息 -->
  2550. <update id="updateFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2551. UPDATE qc_fqc_detailed_record
  2552. SET item_result = #{itemResult},
  2553. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2554. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2555. text_value = #{textValue},
  2556. number_value = #{numberValue,jdbcType=DECIMAL},
  2557. default_value = #{defaultValue},
  2558. min_value = #{minValue,jdbcType=DECIMAL},
  2559. max_value = #{maxValue,jdbcType=DECIMAL},
  2560. item_remark = #{itemRemark},
  2561. custom1 = #{custom1},
  2562. custom2 = #{custom2},
  2563. custom3 = #{custom3}
  2564. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2565. </update>
  2566. <update id="patchFQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2567. UPDATE qc_fqc_detailed_record
  2568. <set>
  2569. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  2570. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  2571. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  2572. <if test="textValue != null">text_value = #{textValue},</if>
  2573. </set>
  2574. WHERE inspection_no = #{inspectionNo}
  2575. and RTRIM(item_no) = RTRIM(#{itemNo})
  2576. and site = #{site}
  2577. and bu_no = #{buNo}
  2578. </update>
  2579. <!-- 修改FQC主记录标识为已提交 -->
  2580. <update id="updateFQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2581. UPDATE qc_fqc_record
  2582. SET submit_flag = 'Y',
  2583. state = '已完成',
  2584. submit_date = getDate(),
  2585. submit_by = #{updateBy}
  2586. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2587. </update>
  2588. <!-- 修改FAI明细记录标识为已提交 -->
  2589. <update id="updateFQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2590. UPDATE qc_fqc_detailed_record
  2591. SET is_submit = 'Y'
  2592. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2593. </update>
  2594. <!-- 修改子明细记录标识为已提交 -->
  2595. <update id="updateFQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2596. UPDATE qc_fqc_sub_detail_record
  2597. SET is_submit = 'Y'
  2598. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2599. </update>
  2600. <!-- 删除子明细的老数据 -->
  2601. <delete id="delFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  2602. DELETE FROM qc_fqc_sub_detail_record
  2603. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2604. </delete>
  2605. <!-- 新增子明细信息 -->
  2606. <insert id="saveFQCSubDetailed">
  2607. INSERT INTO qc_fqc_sub_detail_record
  2608. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, product_quantity, create_time)
  2609. VALUES
  2610. <foreach collection="list" item="item" separator=",">
  2611. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, #{item.productQuantity,jdbcType=DECIMAL}, getDate())
  2612. </foreach>
  2613. </insert>
  2614. <!-- 查询FQC的子明细 -->
  2615. <select id="selectFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2616. SELECT
  2617. site,
  2618. bu_no,
  2619. sub_detail_value,
  2620. sampling_location,
  2621. is_submit,
  2622. sampling_location_b,
  2623. num,
  2624. sub_detail_value_b,
  2625. sub_detail_value_c,
  2626. sub_detail_value_d,
  2627. sub_detail_value_e,
  2628. file_name,
  2629. is_transfer,
  2630. is_qualified,
  2631. defect_qty,
  2632. roll_no,
  2633. product_quantity as productQuantity,
  2634. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  2635. FROM qc_fqc_sub_detail_record
  2636. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2637. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2638. AND sub_detail_value ${collectionDataContent}
  2639. </if>
  2640. </select>
  2641. <!-- 查询FQC检验记录是否已提交 -->
  2642. <select id="checkFQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2643. SELECT submit_flag
  2644. FROM qc_fqc_record
  2645. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2646. </select>
  2647. <!-- 查询FQC检验记录状态(用于保存前校验) -->
  2648. <select id="getFQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2649. SELECT submit_flag, state
  2650. FROM qc_fqc_record
  2651. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2652. </select>
  2653. <!-- 获取该项目的子明细值 -->
  2654. <select id="selectFQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2655. SELECT sub_detail_value,
  2656. sampling_location,
  2657. is_submit
  2658. FROM qc_fqc_sub_detail_record
  2659. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2660. </select>
  2661. <!-- 生成FQC检验单号 -->
  2662. <select id="selectFQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2663. SELECT
  2664. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2665. FROM qc_fqc_record
  2666. WHERE site = #{site} and bu_no = #{buNo}
  2667. </select>
  2668. <!-- 生成IPQC检验单号 -->
  2669. <select id="selectIPQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2670. SELECT
  2671. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  2672. FROM qc_ipqc_record
  2673. WHERE site = #{site} and bu_no = #{buNo}
  2674. </select>
  2675. <!-- 生成FAI检验单号 -->
  2676. <select id="selectFAIInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2677. SELECT
  2678. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2679. FROM qc_fai_record
  2680. WHERE site = #{site} and bu_no = #{buNo}
  2681. </select>
  2682. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  2683. <select id="queryDataFromViewPoOrder" resultType="com.gaotao.modules.pms.data.PoOrderData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2684. SELECT
  2685. site,
  2686. order_no,
  2687. item_no,
  2688. part_no,
  2689. part_desc,
  2690. spec,
  2691. supplier_id,
  2692. supplier_name,
  2693. order_qty,
  2694. created_date,
  2695. status,
  2696. citem_code,
  2697. citem_class,
  2698. sendto_address,
  2699. order_type
  2700. FROM view_po_order
  2701. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  2702. </select>
  2703. <!-- 向收货任务表里添加数据 -->
  2704. <insert id="saveReceivingTask" parameterType="com.gaotao.modules.pms.data.PoOrderData">
  2705. INSERT INTO receiving_task (site, order_no, item_no, part_no, part_desc, spec, supplier_id, supplier_name, order_qty, created_date, status, citem_code, citem_class, sendto_address, order_type, inspection_no, batch_no, production_date, expiration_warning_date, expiration_date)
  2706. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}, #{batchNo}, #{productionDate}, #{expirationWarningDate}, #{expirationDate})
  2707. </insert>
  2708. <!-- 检查动控是否开启 -->
  2709. <select id="queryController" parameterType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity" resultType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity">
  2710. SELECT
  2711. type,
  2712. base_data,
  2713. base_desc,
  2714. status,
  2715. remark,
  2716. third_type,
  2717. second_type,
  2718. page_control,
  2719. control_style
  2720. FROM sys_scene_dynamic_control_model
  2721. where site = #{site} and control_no = #{controlNo}
  2722. </select>
  2723. <!-- 查询检验模板列表 -->
  2724. <select id="queryTemplateList" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
  2725. SELECT
  2726. site,
  2727. bu_no,
  2728. template_id as templateId,
  2729. template_name as templateName,
  2730. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2731. FROM qc_template
  2732. <where>
  2733. site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  2734. <if test = "templateId != null and templateId != ''">
  2735. AND template_id LIKE '%' + #{templateId}+'%'
  2736. </if>
  2737. <if test = "templateName != null and templateName != ''">
  2738. AND template_name LIKE '%' + #{templateName}+'%'
  2739. </if>
  2740. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2741. AND inspection_type_no = #{inspectionTypeNo}
  2742. </if>
  2743. </where>
  2744. </select>
  2745. <!-- 查询检验模板列表 -->
  2746. <select id="getPartInformation" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2747. select
  2748. partNo,
  2749. PartDescription as partDesc,
  2750. spec,
  2751. sku,
  2752. DefaultWarehouseID as defaultWarehouseId
  2753. from part
  2754. where site = #{site} and partNo = #{partNo}
  2755. </select>
  2756. <!-- 获取特殊工序列表 -->
  2757. <select id="getSpecialOperationList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2758. select
  2759. site,
  2760. operation_no,
  2761. operation_desc
  2762. from qc_special_task_operation
  2763. where site = #{site}
  2764. </select>
  2765. <!-- 获取处置措施列表 -->
  2766. <select id="disposalMeasuresSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2767. SELECT
  2768. id,
  2769. disposal_measures
  2770. FROM qc_disposal_measures
  2771. <where>
  2772. <if test = "inspectionTypeNo != '101'">
  2773. inspection_type != 'IPQC'
  2774. </if>
  2775. </where>
  2776. </select>
  2777. <!-- 查询文件路径 -->
  2778. <select id="searchItemFileUrl" resultType="com.gaotao.modules.oss.entity.SysOssEntity" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2779. SELECT
  2780. id,
  2781. url,
  2782. file_name
  2783. FROM sys_oss
  2784. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2785. </select>
  2786. <!-- 删除图片-->
  2787. <delete id="imageDelete" parameterType="com.gaotao.modules.oss.entity.SysOssEntity">
  2788. DELETE FROM sys_oss
  2789. WHERE id = #{id}
  2790. </delete>
  2791. <!-- 模糊查询标签号 -->
  2792. <select id="getRollNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2793. SELECT DISTINCT top 3
  2794. a.seqno,
  2795. a.orderno,
  2796. b.RollNo
  2797. FROM soscheduledrouting AS a
  2798. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
  2799. WHERE a.site = #{site} and b.RollNo like '%' + #{rollNo} + '%'
  2800. </select>
  2801. <!-- 标签号回车事件 -->
  2802. <select id="rollNoEnter" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2803. SELECT
  2804. a.site,
  2805. a.seqno as seqNo,
  2806. a.orderno as orderNo,
  2807. b.RollNo,
  2808. #{inspectionTypeNo} as inspectionTypeNo
  2809. FROM soscheduledrouting AS a
  2810. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
  2811. WHERE a.site = #{site} and b.RollNo = #{rollNo}
  2812. </select>
  2813. <!-- 查询物料列表 -->
  2814. <select id="queryPartList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2815. SELECT
  2816. site,
  2817. partNo,
  2818. PartDescription as partDesc,
  2819. PartType as invdefinetype,
  2820. sku,
  2821. spec,
  2822. cinv_source_code as cinvSourceCode
  2823. FROM part
  2824. <where>
  2825. site = #{site}
  2826. <if test = "partNo != null and partNo != ''">
  2827. AND partNo LIKE '%' + #{partNo} + '%'
  2828. </if>
  2829. <if test = "partDesc != null and partDesc != ''">
  2830. AND PartDescription LIKE '%' + #{partDesc} + '%'
  2831. </if>
  2832. <if test = "sku != null and sku != ''">
  2833. AND sku LIKE '%' + #{sku} + '%'
  2834. </if>
  2835. <if test = "cinvSourceCode != null and cinvSourceCode != ''">
  2836. AND cinv_source_code LIKE '%' + #{cinvSourceCode} + '%'
  2837. </if>
  2838. </where>
  2839. order by partNo
  2840. </select>
  2841. <!-- 查询物料列表(分页) -->
  2842. <select id="queryPartListPage" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2843. SELECT
  2844. site,
  2845. partNo,
  2846. PartDescription as partDesc,
  2847. PartType as invdefinetype,
  2848. sku,
  2849. spec,
  2850. cinv_source_code as cinvSourceCode
  2851. FROM part
  2852. <where>
  2853. site = #{query.site}
  2854. <if test = "query.partNo != null and query.partNo != ''">
  2855. AND partNo LIKE '%' + #{query.partNo} + '%'
  2856. </if>
  2857. <if test = "query.partDesc != null and query.partDesc != ''">
  2858. AND PartDescription LIKE '%' + #{query.partDesc} + '%'
  2859. </if>
  2860. <if test = "query.sku != null and query.sku != ''">
  2861. AND sku LIKE '%' + #{query.sku} + '%'
  2862. </if>
  2863. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2864. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2865. </if>
  2866. </where>
  2867. order by partNo
  2868. </select>
  2869. <!-- 查询单位列表 -->
  2870. <select id="umSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2871. SELECT
  2872. site,
  2873. UMID as umId,
  2874. UMName as umName
  2875. FROM UM
  2876. WHERE active = #{active}
  2877. </select>
  2878. <!-- 查询单位列表 -->
  2879. <select id="checkItem" resultType="com.gaotao.modules.pms.data.SubDetailValues" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
  2880. SELECT
  2881. site,
  2882. bu_no,
  2883. inspection_no,
  2884. item_no,
  2885. value_type_db,
  2886. min_value,
  2887. max_value
  2888. FROM
  2889. <choose>
  2890. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  2891. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  2892. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  2893. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  2894. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  2895. <when test="flag == 'pqc'">qc_pqc_detailed_record</when>
  2896. <otherwise>qc_iqc_detailed_record</otherwise>
  2897. </choose>
  2898. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  2899. order by order_id
  2900. </select>
  2901. <!-- 修改detailFlag字段为N -->
  2902. <update id="updateIQCDetailFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2903. UPDATE qc_iqc_record
  2904. SET detail_flag = 'N'
  2905. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2906. </update>
  2907. <select id="searchSeqInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2908. SELECT
  2909. a.site,
  2910. a.order_no as orderNo,
  2911. a.release_no as releaseNo,
  2912. a.sequence_no as [lineNo],
  2913. a.part_no as partNo,
  2914. a.part_description as partDesc,
  2915. a.lot_size as lotsize,
  2916. a.planner,
  2917. a.status
  2918. FROM View_IFS_Shop_Order a
  2919. WHERE a.site = #{query.site}
  2920. <if test="query.userName != null and query.userName != ''">
  2921. AND a.site in (Select Site from AccessSite where upper(UserID) = #{query.userName})
  2922. </if>
  2923. <if test="query.status != null and query.status != ''">
  2924. AND a.status = #{query.status}
  2925. </if>
  2926. <if test="query.orderNo != null and query.orderNo != ''">
  2927. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2928. </if>
  2929. <if test="query.releaseNo != null and query.releaseNo != ''">
  2930. AND a.release_no LIKE '%' + #{query.releaseNo} + '%'
  2931. </if>
  2932. <if test="query.lineNo != null and query.lineNo != ''">
  2933. AND a.sequence_no LIKE '%' + #{query.lineNo} + '%'
  2934. </if>
  2935. <if test="query.partNo != null and query.partNo != ''">
  2936. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2937. </if>
  2938. <if test="query.partDesc != null and query.partDesc != ''">
  2939. AND a.part_description LIKE '%' + #{query.partDesc} + '%'
  2940. </if>
  2941. </select>
  2942. <!-- 查询采购订单信息(IQC新增) -->
  2943. <select id="searchPoOrderInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2944. SELECT
  2945. v.site,
  2946. v.poOrderNo,
  2947. v.poOrderItemNo as poItemNo,
  2948. CAST(v.poOrderLineNo AS VARCHAR(20)) as releaseNo,
  2949. CAST(v.receiptNo AS VARCHAR(20)) as receiptItemNo,
  2950. CAST(v.receiptNo AS VARCHAR(20)) as receiptNo,
  2951. v.partNo,
  2952. p.PartDescription as partDesc,
  2953. p.spec,
  2954. v.supplierNo,
  2955. s.SupplierName as supplierDesc,
  2956. v.orderQty as lotsize,
  2957. p.PartType as invdefinetype,
  2958. v.receivedQty as currentArrivalQty,
  2959. ISNULL(v.qtyInspected, 0) as allowInQty,
  2960. ISNULL(v.qtyToInspected, 0) as pendingInspectQty,
  2961. ISNULL(v.qtyInspected, 0) as inspectedQty,
  2962. v.umId,
  2963. um.UMName as umName
  2964. FROM View_Purchase_Order_List v
  2965. LEFT JOIN part p ON v.site = p.site AND v.partNo = p.PartNo
  2966. LEFT JOIN Supplier s ON v.supplierNo = s.SupplierID
  2967. LEFT JOIN UM um ON v.site = um.site AND v.umId = um.UMID
  2968. WHERE v.site = #{query.site}
  2969. AND CAST(v.poOrderNo AS VARCHAR(50)) LIKE '%' + #{query.poOrderNo} + '%'
  2970. <if test="query.poItemNo != null and query.poItemNo != ''">
  2971. AND CAST(v.poOrderItemNo AS VARCHAR(20)) LIKE '%' + #{query.poItemNo} + '%'
  2972. </if>
  2973. <if test="query.releaseNo != null and query.releaseNo != ''">
  2974. AND CAST(v.poOrderLineNo AS VARCHAR(20)) LIKE '%' + #{query.releaseNo} + '%'
  2975. </if>
  2976. <if test="query.receiptNo != null and query.receiptNo != ''">
  2977. AND CAST(v.receiptNo AS VARCHAR(20)) LIKE '%' + #{query.receiptNo} + '%'
  2978. </if>
  2979. <if test="query.partNo != null and query.partNo != ''">
  2980. AND v.partNo LIKE '%' + #{query.partNo} + '%'
  2981. </if>
  2982. <if test="query.partDesc != null and query.partDesc != ''">
  2983. AND p.PartDescription LIKE '%' + #{query.partDesc} + '%'
  2984. </if>
  2985. <if test="query.supplierNo != null and query.supplierNo != ''">
  2986. AND v.supplierNo LIKE '%' + #{query.supplierNo} + '%'
  2987. </if>
  2988. <if test="query.supplierDesc != null and query.supplierDesc != ''">
  2989. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  2990. </if>
  2991. </select>
  2992. <!--
  2993. IQC批量新增:采购接收单查询(可不填PO;支持供应商、接收日期)
  2994. 依赖 View_Purchase_Order_List 提供:receivedDate(接收日期)、batchNo(供应商批次)
  2995. 若视图暂无这两列,请先执行 db/view_purchase_order_list_batch_fields.sql 说明让 Mingo 补齐
  2996. -->
  2997. <select id="searchPoOrderInfoForBatch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2998. SELECT
  2999. v.site,
  3000. v.poOrderNo,
  3001. v.poOrderItemNo as poItemNo,
  3002. CAST(v.poOrderLineNo AS VARCHAR(20)) as releaseNo,
  3003. CAST(v.receiptNo AS VARCHAR(20)) as receiptItemNo,
  3004. CAST(v.receiptNo AS VARCHAR(20)) as receiptNo,
  3005. v.partNo,
  3006. p.PartDescription as partDesc,
  3007. p.spec,
  3008. v.supplierNo,
  3009. s.SupplierName as supplierDesc,
  3010. v.orderQty as lotsize,
  3011. p.PartType as invdefinetype,
  3012. v.receivedQty as currentArrivalQty,
  3013. ISNULL(v.qtyInspected, 0) as allowInQty,
  3014. ISNULL(v.qtyToInspected, 0) as pendingInspectQty,
  3015. ISNULL(v.qtyInspected, 0) as inspectedQty,
  3016. v.umId,
  3017. um.UMName as umName<!--,
  3018. v.batchNo as batchNo,
  3019. v.receivedDate as arrivalDate-->
  3020. FROM View_Purchase_Order_List v
  3021. LEFT JOIN part p ON v.site = p.site AND v.partNo = p.PartNo
  3022. LEFT JOIN Supplier s ON v.supplierNo = s.SupplierID
  3023. LEFT JOIN UM um ON v.site = um.site AND v.umId = um.UMID
  3024. WHERE v.site = #{query.site}
  3025. <if test="query.poOrderNo != null and query.poOrderNo != ''">
  3026. AND CAST(v.poOrderNo AS VARCHAR(50)) LIKE '%' + #{query.poOrderNo} + '%'
  3027. </if>
  3028. <if test="query.poItemNo != null and query.poItemNo != ''">
  3029. AND CAST(v.poOrderItemNo AS VARCHAR(20)) LIKE '%' + #{query.poItemNo} + '%'
  3030. </if>
  3031. <if test="query.releaseNo != null and query.releaseNo != ''">
  3032. AND CAST(v.poOrderLineNo AS VARCHAR(20)) LIKE '%' + #{query.releaseNo} + '%'
  3033. </if>
  3034. <if test="query.receiptNo != null and query.receiptNo != ''">
  3035. AND CAST(v.receiptNo AS VARCHAR(20)) LIKE '%' + #{query.receiptNo} + '%'
  3036. </if>
  3037. <if test="query.partNo != null and query.partNo != ''">
  3038. AND v.partNo LIKE '%' + #{query.partNo} + '%'
  3039. </if>
  3040. <if test="query.partDesc != null and query.partDesc != ''">
  3041. AND p.PartDescription LIKE '%' + #{query.partDesc} + '%'
  3042. </if>
  3043. <if test="query.supplierNo != null and query.supplierNo != ''">
  3044. AND v.supplierNo LIKE '%' + #{query.supplierNo} + '%'
  3045. </if>
  3046. <if test="query.supplierDesc != null and query.supplierDesc != ''">
  3047. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  3048. </if>
  3049. <if test="query.startDate != null">
  3050. AND v.receivedDate &gt;= #{query.startDate}
  3051. </if>
  3052. <if test="query.endDate != null">
  3053. AND v.receivedDate &lt;= #{query.endDate}
  3054. </if>
  3055. ORDER BY v.poOrderNo, v.poOrderItemNo
  3056. </select>
  3057. <select id="searchPartInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3058. select
  3059. partNo,
  3060. PartDescription as partDesc,
  3061. PartType as invdefinetype,
  3062. sku,
  3063. bu_no
  3064. from
  3065. part
  3066. where
  3067. bu_no = #{query.buNo}
  3068. <if test="query.site != null and query.site != ''">
  3069. AND site = #{query.site}
  3070. </if>
  3071. <if test="query.type != null and query.type != ''">
  3072. AND PartType = #{query.type}
  3073. </if>
  3074. <if test="query.handle != null and query.handle != ''">
  3075. AND handle = #{query.handle}
  3076. </if>
  3077. <if test="query.partNo != null and query.partNo != ''">
  3078. AND partNo LIKE '%' + #{query.partNo} + '%'
  3079. </if>
  3080. <if test="query.partDesc != null and query.partDesc != ''">
  3081. AND PartDescription LIKE '%' + #{query.partDesc} + '%'
  3082. </if>
  3083. <if test="query.sku != null and query.sku != ''">
  3084. AND sku LIKE '%' + #{query.sku} + '%'
  3085. </if>
  3086. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  3087. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  3088. </if>
  3089. order by partNo
  3090. </select>
  3091. <select id="getInterfaceTimeData" parameterType="String" resultType="com.gaotao.modules.pms.data.InterfaceTimeData">
  3092. SELECT
  3093. id,
  3094. start_time,
  3095. end_time,
  3096. del_flag
  3097. FROM interface_time
  3098. WHERE del_flag = 'N' and site = #{site}
  3099. </select>
  3100. <update id="updateInterfaceTimeData" parameterType="com.gaotao.modules.pms.data.InterfaceTimeData">
  3101. UPDATE interface_time
  3102. set
  3103. updated_by = #{updatedBy},
  3104. updated_date = #{updatedDate},
  3105. del_flag = #{delFlag}
  3106. </update>
  3107. <select id="getInterfaceRdStyleData" parameterType="String" resultType="com.gaotao.modules.pms.data.RdStyleData">
  3108. SELECT
  3109. crdcode,
  3110. crdname,
  3111. iRdGrade,
  3112. rdtype,
  3113. brdend
  3114. FROM view_custdev_mes_rdstyle
  3115. WHERE crdname = #{crdName}
  3116. </select>
  3117. <insert id="insertHardtagPurchaseInStorageData" parameterType="com.gaotao.modules.pms.data.HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
  3118. INSERT INTO purchase_in_storage_count
  3119. (site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
  3120. cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
  3121. values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
  3122. #{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
  3123. </insert>
  3124. <insert id="batchSaveHrdtagTransHeader" parameterType="com.gaotao.modules.pms.data.HardtagTransHeaderData">
  3125. insert into TransHeader
  3126. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
  3127. TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
  3128. department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
  3129. values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
  3130. #{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
  3131. #{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
  3132. </insert>
  3133. <insert id="batchSaveHardtagTransDetail" parameterType="com.gaotao.modules.pms.data.HardtagTransDetailData">
  3134. INSERT INTO TransDetail
  3135. (TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
  3136. values
  3137. (#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
  3138. </insert>
  3139. <select id="getSendMailAddress" parameterType="String" resultType="com.gaotao.modules.pms.data.MailAddressData">
  3140. SELECT
  3141. id,
  3142. site,
  3143. bu_no,
  3144. mail_address,
  3145. send_type,
  3146. del_flag,
  3147. created_by,
  3148. created_date,
  3149. orderref1
  3150. FROM mailAddress
  3151. WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
  3152. <if test="buNo != null and buNo != ''">
  3153. AND bu_no = #{buNo}
  3154. </if>
  3155. </select>
  3156. <select id="getSendMailFromAddress" resultType="com.gaotao.modules.pms.data.MailSendAddressData">
  3157. SELECT
  3158. port,
  3159. host,
  3160. username,
  3161. password,
  3162. emailForm,
  3163. timeout,
  3164. personal,
  3165. id
  3166. FROM mailSendAddress
  3167. where delFlag = 'N'
  3168. </select>
  3169. <!-- 新增发送邮件记录 -->
  3170. <insert id="saveSendMailRecord" parameterType="com.gaotao.modules.pms.data.SendMailRecord">
  3171. insert into send_mail_record
  3172. (site, bu_no, document_no, sender, recipient, send_date, type)
  3173. values
  3174. (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate(), #{type})
  3175. </insert>
  3176. <select id="orderTypeSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3177. SELECT distinct
  3178. order_type
  3179. FROM view_po_order
  3180. </select>
  3181. <update id="actionIQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3182. update qc_iqc_record
  3183. set action_date = getDate(),
  3184. action_by = #{actionBy},
  3185. state = #{state}
  3186. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3187. </update>
  3188. <update id="actionFAIInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3189. update qc_fai_record
  3190. set action_date = getDate(),
  3191. action_by = #{actionBy},
  3192. state = #{state}
  3193. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3194. </update>
  3195. <update id="actionIPQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3196. update qc_ipqc_record
  3197. set action_date = getDate(),
  3198. action_by = #{actionBy},
  3199. state = #{state}
  3200. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3201. </update>
  3202. <update id="actionFQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3203. update qc_fqc_record
  3204. set action_date = getDate(),
  3205. action_by = #{actionBy},
  3206. state = #{state}
  3207. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3208. </update>
  3209. <insert id="addEquipmentDataAcquisition">
  3210. insert into Equipment_data_acquisition
  3211. (site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
  3212. values
  3213. <foreach collection="list" item="item" separator=",">
  3214. (#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
  3215. </foreach>
  3216. </insert>
  3217. <update id="updateEquipmentDataAcquisitionItem">
  3218. UPDATE Equipment_data_acquisition WITH (UPDLOCK, HOLDLOCK)
  3219. SET batch_no = CASE WHEN equipment_no = #{equipmentNo} THEN batch_no ELSE NULL END,
  3220. equipment_no = #{equipmentNo},
  3221. collection_source = #{collectionSource},
  3222. collection_method = #{collectionMethod}
  3223. WHERE site = #{site}
  3224. AND bu_no = #{buNo}
  3225. AND inspection_no = #{inspectionNo}
  3226. AND item_no = #{itemNo}
  3227. </update>
  3228. <select id="listInspectionAcquisitionItems" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3229. SELECT a.site, a.bu_no, a.inspection_no, a.item_no, a.item_desc,
  3230. b.collection_source, b.collection_method, b.equipment_classification
  3231. FROM
  3232. <choose>
  3233. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  3234. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  3235. <when test="flag == 'oqc'">qc_oqc_detailed_record</when>
  3236. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  3237. <otherwise>qc_iqc_detailed_record</otherwise>
  3238. </choose>
  3239. a
  3240. INNER JOIN eam_properties_item b
  3241. ON a.site = b.site AND a.bu_no = b.bu_no AND a.item_no = b.ItemNo
  3242. WHERE a.site = #{site}
  3243. AND a.bu_no = #{buNo}
  3244. AND a.inspection_no = #{inspectionNo}
  3245. AND b.ItemType = 'D'
  3246. AND b.collection_flag = 'Y'
  3247. ORDER BY a.order_id, a.item_no
  3248. </select>
  3249. <!-- 新增人员信息 -->
  3250. <insert id="saveOperator" >
  3251. INSERT INTO eam_actual_operator
  3252. (site, order_no, function_type, operator, bu_no)
  3253. VALUES
  3254. <foreach collection="list" item="item" separator=",">
  3255. (#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
  3256. </foreach>
  3257. </insert>
  3258. <!-- 删除之前的人员-->
  3259. <delete id="delOperator" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3260. DELETE FROM eam_actual_operator
  3261. WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
  3262. </delete>
  3263. <select id="getInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3264. select distinct
  3265. site,
  3266. bu_no,
  3267. equipment_no,
  3268. inspection_no,
  3269. item_no,
  3270. collection_source,
  3271. collection_method,
  3272. batch_no,
  3273. accumulate_collect,
  3274. delete_after_collect
  3275. from Equipment_data_acquisition
  3276. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3277. </select>
  3278. <select id="getInspectionNoByItem" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3279. select distinct
  3280. site,
  3281. bu_no,
  3282. equipment_no,
  3283. inspection_no,
  3284. item_no,
  3285. collection_source,
  3286. collection_method,
  3287. batch_no,
  3288. accumulate_collect,
  3289. delete_after_collect
  3290. from Equipment_data_acquisition
  3291. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  3292. </select>
  3293. <select id="dataAcquisition" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  3294. select
  3295. id,
  3296. site,
  3297. bu_no,
  3298. #{inspectionNo} as inspectionNo,
  3299. #{itemNo} as itemNo,
  3300. <if test='subDetailValueType == 0'>
  3301. ${collectionSource} as subDetailValue,
  3302. </if>
  3303. <if test='subDetailValueType == 1'>
  3304. ${collectionSource} as subDetailValueB,
  3305. </if>
  3306. <if test='subDetailValueType == 2'>
  3307. ${collectionSource} as subDetailValueC,
  3308. </if>
  3309. <if test='subDetailValueType == 3'>
  3310. ${collectionSource} as subDetailValueD,
  3311. </if>
  3312. <if test='subDetailValueType == 4'>
  3313. ${collectionSource} as subDetailValueE,
  3314. </if>
  3315. num,
  3316. #{collectionSource} as collectionSource,
  3317. #{collectionMethod} as collectionMethod
  3318. from Equipment_data_detail
  3319. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  3320. <if test='collectionMethod == "plc"'>
  3321. AND inspection_no = #{inspectionNo}
  3322. </if>
  3323. <if test='collectionMethod == "RS232"'>
  3324. AND (inspection_no is null or inspection_no = '')
  3325. </if>
  3326. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3327. AND ${collectionSource} ${collectionDataContent}
  3328. </if>
  3329. <if test='standardMode != null and standardMode'>
  3330. AND source_column_no IS NULL
  3331. AND (serial_no IS NULL OR serial_no = '')
  3332. </if>
  3333. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3334. </select>
  3335. <select id="dataAcquisitionB" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  3336. select
  3337. id,
  3338. site,
  3339. bu_no,
  3340. #{inspectionNo} as inspectionNo,
  3341. #{itemNo} as itemNo,
  3342. ${collectionSource} as subDetailValueB,
  3343. num,
  3344. #{collectionSource} as collectionSource
  3345. from Equipment_data_detail
  3346. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  3347. <if test='collectionMethod == "plc"'>
  3348. AND inspection_no = #{inspectionNo}
  3349. </if>
  3350. <if test='collectionMethod == "RS232"'>
  3351. AND (inspection_no is null or inspection_no = '')
  3352. </if>
  3353. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3354. AND ${collectionSource} ${collectionDataContent}
  3355. </if>
  3356. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3357. </select>
  3358. <select id="dataAcquisition2" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  3359. select
  3360. site as orderRef1,
  3361. bu_no as orderRef4,
  3362. #{inspectionNo} as orderRef2,
  3363. #{itemNo} as orderRef3,
  3364. ${collectionSource} as url
  3365. from Equipment_data_detail
  3366. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  3367. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3368. AND ${collectionSource} ${collectionDataContent}
  3369. </if>
  3370. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3371. </select>
  3372. <select id="getIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3373. select
  3374. a.site,
  3375. a.bu_no,
  3376. b.collection_condition as equipmentNo,
  3377. #{inspectionNo} as inspectionNo,
  3378. a.item_no,
  3379. b.collection_source,
  3380. #{actionBy} as actionBy,
  3381. b.collection_method
  3382. from qc_iqc_detailed_record as a
  3383. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3384. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
  3385. order by a.order_id
  3386. </select>
  3387. <select id="getFAIDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3388. select
  3389. a.site,
  3390. a.bu_no,
  3391. b.collection_condition as equipmentNo,
  3392. #{inspectionNo} as inspectionNo,
  3393. a.item_no,
  3394. b.collection_source,
  3395. #{actionBy} as actionBy,
  3396. b.collection_method
  3397. from qc_fai_detailed_record as a
  3398. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3399. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
  3400. order by order_id
  3401. </select>
  3402. <select id="getIPQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3403. select
  3404. a.site,
  3405. a.bu_no,
  3406. b.collection_condition as equipmentNo,
  3407. #{inspectionNo} as inspectionNo,
  3408. a.item_no,
  3409. b.collection_source,
  3410. #{actionBy} as actionBy,
  3411. b.collection_method
  3412. from qc_ipqc_detailed_record as a
  3413. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3414. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  3415. order by a.order_id
  3416. </select>
  3417. <select id="getFQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3418. select
  3419. a.site,
  3420. a.bu_no,
  3421. b.collection_condition as equipmentNo,
  3422. #{inspectionNo} as inspectionNo,
  3423. a.item_no,
  3424. b.collection_source,
  3425. #{actionBy} as actionBy,
  3426. b.collection_method
  3427. from qc_fqc_detailed_record as a
  3428. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3429. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
  3430. order by a.order_id
  3431. </select>
  3432. <select id="querySubDetails" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  3433. select
  3434. b.site,
  3435. b.bu_no,
  3436. b.inspection_no,
  3437. b.item_no,
  3438. b.default_value,
  3439. b.min_value,
  3440. b.max_value,
  3441. b.value_type_db,
  3442. a.sub_detail_value
  3443. <if test="flag == 'iqc'">
  3444. from qc_iqc_sub_detail_record as a
  3445. left join qc_iqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3446. </if>
  3447. <if test="flag == 'ipqc'">
  3448. from qc_ipqc_sub_detail_record as a
  3449. left join qc_ipqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3450. </if>
  3451. <if test="flag == 'sqc'">
  3452. from qc_sqc_sub_detail_record as a
  3453. left join qc_sqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3454. </if>
  3455. <if test="flag == 'fqc'">
  3456. from qc_fqc_sub_detail_record as a
  3457. left join qc_fqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3458. </if>
  3459. <if test="flag == 'fai'">
  3460. from qc_fai_sub_detail_record as a
  3461. left join qc_fai_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3462. </if>
  3463. <if test="flag == 'fqas' or flag == 'oqc'">
  3464. from qc_oqc_sub_detail_record as a
  3465. left join qc_oqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3466. </if>
  3467. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
  3468. order by b.order_id
  3469. </select>
  3470. <insert id="saveFileList">
  3471. INSERT INTO sys_oss
  3472. (url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
  3473. VALUES
  3474. <foreach collection="list" item="item" separator=",">
  3475. (#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
  3476. </foreach>
  3477. </insert>
  3478. <select id="getEquipmentNoList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
  3479. select
  3480. equipment_no
  3481. from Equipment_folder_location
  3482. where site = #{site} and bu_no = #{buNo}
  3483. </select>
  3484. <select id="getEquipmentClassificationList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
  3485. select distinct
  3486. equipment_classification
  3487. from Equipment_folder_location
  3488. where site = #{site} and bu_no = #{buNo}
  3489. and equipment_classification is not null
  3490. and equipment_classification != ''
  3491. order by equipment_classification
  3492. </select>
  3493. <!-- 获取责任人员列表 -->
  3494. <select id="getResponsibleOperatorList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  3495. SELECT
  3496. DISTINCT
  3497. OperatorID as adminID,
  3498. OperatorName as adminName
  3499. FROM operator
  3500. <where>
  3501. site in (select site from AccessSite where userID = #{userName})
  3502. <if test = "adminID != null and adminID != ''">
  3503. AND OperatorID LIKE '%' + #{adminID} + '%'
  3504. </if>
  3505. <if test = "adminName != null and adminName != ''">
  3506. AND OperatorName LIKE '%' + #{adminName} + '%'
  3507. </if>
  3508. </where>
  3509. </select>
  3510. <select id="getDataContentList" parameterType="com.gaotao.modules.pms.data.QcCollectionDataContentData" resultType="com.gaotao.modules.pms.data.QcCollectionDataContentData">
  3511. select
  3512. content_desc
  3513. from qc_collection_data_content
  3514. where site = #{site} and bu_no = #{buNo} and active = 'Y'
  3515. </select>
  3516. <select id="getItemCollectionDataContent" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="string">
  3517. select
  3518. collection_data_content
  3519. from eam_properties_item
  3520. where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
  3521. </select>
  3522. <!-- 获取当前项目不包含的设备 -->
  3523. <select id="getObjectList1" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3524. SELECT
  3525. a.site,
  3526. a.bu_no,
  3527. a.equipment_no as ObjectID,
  3528. a.equipment_desc as ObjectDesc
  3529. FROM Equipment_folder_location as a
  3530. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.equipment_no = b.ObjectID and b.ItemNo = #{itemNo}
  3531. where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null
  3532. </select>
  3533. <!-- 获取当前项目所包含的设备 -->
  3534. <select id="getObjectList2" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3535. SELECT
  3536. a.site,
  3537. a.bu_no,
  3538. a.ObjectID,
  3539. b.equipment_desc as ObjectDesc,
  3540. a.default_flag
  3541. FROM qc_item_object a
  3542. LEFT JOIN Equipment_folder_location b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.equipment_no
  3543. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
  3544. </select>
  3545. <!-- 获取当前项目不包含的设备 -->
  3546. <select id="getObjectListBy" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3547. SELECT
  3548. a.site,
  3549. a.bu_no,
  3550. a.equipment_no as ObjectID,
  3551. a.equipment_desc as ObjectDesc
  3552. FROM Equipment_folder_location as a
  3553. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.equipment_no = b.ObjectID and b.ItemNo = #{itemNo}
  3554. <where>
  3555. a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null
  3556. <if test = "objectID != null and objectID != ''">
  3557. AND a.equipment_no LIKE '%' + #{objectID} + '%'
  3558. </if>
  3559. <if test = "objectDesc != null and objectDesc != ''">
  3560. AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
  3561. </if>
  3562. </where>
  3563. order by a.equipment_no
  3564. </select>
  3565. <!-- 新增项目设备 -->
  3566. <insert id="addItemObject">
  3567. INSERT INTO qc_item_object
  3568. (site, bu_no, ItemNo, ObjectID, default_flag)
  3569. VALUES
  3570. <foreach collection="list" item="item" separator=",">
  3571. (#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
  3572. </foreach>
  3573. </insert>
  3574. <delete id="deleteItemObject">
  3575. DELETE FROM qc_item_object
  3576. WHERE
  3577. <foreach collection="list" item="item" separator=" or " index="index">
  3578. (site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
  3579. </foreach>
  3580. </delete>
  3581. <update id="updateItemObject">
  3582. UPDATE qc_item_object
  3583. SET default_flag = #{defaultFlag}
  3584. WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
  3585. </update>
  3586. <select id="getIQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3587. select
  3588. a.site,
  3589. a.bu_no,
  3590. a.inspection_no,
  3591. a.item_no,
  3592. a.item_desc,
  3593. b.collection_source,
  3594. b.collection_method,
  3595. b.equipment_classification
  3596. from qc_iqc_detailed_record as a
  3597. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3598. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
  3599. order by a.order_id
  3600. </select>
  3601. <select id="getFAIInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3602. select
  3603. a.site,
  3604. a.bu_no,
  3605. a.inspection_no,
  3606. a.item_no,
  3607. a.item_desc,
  3608. b.collection_source,
  3609. b.collection_method,
  3610. b.equipment_classification
  3611. from qc_fai_detailed_record as a
  3612. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3613. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
  3614. order by a.order_id
  3615. </select>
  3616. <select id="getFQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3617. select
  3618. a.site,
  3619. a.bu_no,
  3620. a.inspection_no,
  3621. a.item_no,
  3622. a.item_desc,
  3623. b.collection_source,
  3624. b.collection_method,
  3625. b.equipment_classification
  3626. from qc_fqc_detailed_record as a
  3627. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3628. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
  3629. order by a.order_id
  3630. </select>
  3631. <select id="getIPQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3632. select
  3633. a.site,
  3634. a.bu_no,
  3635. a.inspection_no,
  3636. a.item_no,
  3637. a.item_desc,
  3638. b.collection_source,
  3639. b.collection_method,
  3640. b.equipment_classification
  3641. from qc_ipqc_detailed_record as a
  3642. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3643. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  3644. order by a.order_id
  3645. </select>
  3646. <delete id="deleteEquipmentDataAcquisition" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3647. delete from Equipment_data_acquisition
  3648. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3649. </delete>
  3650. <!-- IPQC检验项目操作相关SQL -->
  3651. <!-- 查询可选的IPQC检验项目(未添加到当前检验单的) -->
  3652. <select id="getIPQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3653. SELECT
  3654. ItemNo as itemNo,
  3655. ItemDesc as itemDesc,
  3656. DefaultValue as defaultValue,
  3657. MaxValue as maxValue,
  3658. MinValue as minValue,
  3659. ValueType as valueType,
  3660. ValueType_DB as valueTypeDb
  3661. FROM eam_properties_item
  3662. WHERE site = #{site}
  3663. AND bu_no = #{buNo}
  3664. AND inspection_type_no = '101'
  3665. <if test="itemNo != null and itemNo != ''">
  3666. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3667. </if>
  3668. <if test="itemDesc != null and itemDesc != ''">
  3669. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3670. </if>
  3671. AND ItemNo NOT IN (
  3672. SELECT item_no
  3673. FROM qc_ipqc_detailed_record
  3674. WHERE site = #{site}
  3675. AND bu_no = #{buNo}
  3676. AND inspection_no = #{inspectionNo}
  3677. )
  3678. ORDER BY ItemNo
  3679. </select>
  3680. <!-- 查询已有的IPQC检验项目(当前检验单已添加的) -->
  3681. <select id="getIPQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3682. SELECT
  3683. d.item_no as itemNo,
  3684. d.item_desc as itemDesc
  3685. FROM qc_ipqc_detailed_record d
  3686. WHERE d.site = #{site}
  3687. AND d.bu_no = #{buNo}
  3688. AND d.inspection_no = #{inspectionNo}
  3689. ORDER BY d.item_no
  3690. </select>
  3691. <!-- 查询当前检验单已有的项目(用于获取template_id) -->
  3692. <select id="getExistingIPQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3693. SELECT TOP 1
  3694. template_id as templateId,
  3695. item_no as itemNo,
  3696. item_desc as itemDesc
  3697. FROM qc_ipqc_detailed_record
  3698. WHERE site = #{site}
  3699. AND bu_no = #{buNo}
  3700. AND inspection_no = #{inspectionNo}
  3701. ORDER BY item_no
  3702. </select>
  3703. <!-- 插入IPQC检验项目明细 -->
  3704. <insert id="insertIPQCItemDetail" parameterType="java.util.Map">
  3705. INSERT INTO qc_ipqc_detailed_record (
  3706. inspection_no,
  3707. order_no,
  3708. template_id,
  3709. item_no,
  3710. item_desc,
  3711. default_value,
  3712. min_value,
  3713. max_value,
  3714. value_type_db,
  3715. value_type,
  3716. site,
  3717. bu_no,
  3718. foreign_flag,
  3719. order_id
  3720. ) VALUES (
  3721. #{inspectionNo},
  3722. #{orderNo},
  3723. #{templateId},
  3724. #{itemNo},
  3725. #{itemDesc},
  3726. #{defaultValue},
  3727. #{minValue},
  3728. #{maxValue},
  3729. #{valueTypeDb},
  3730. #{valueType},
  3731. #{site},
  3732. #{buNo},
  3733. #{foreignFlag},
  3734. #{orderId}
  3735. )
  3736. </insert>
  3737. <!-- 获取检验单中最大的order_id -->
  3738. <select id="getMaxOrderIdForIPQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  3739. SELECT ISNULL(MAX(order_id), 0)
  3740. FROM qc_ipqc_detailed_record
  3741. WHERE site = #{site}
  3742. AND bu_no = #{buNo}
  3743. AND inspection_no = #{inspectionNo}
  3744. </select>
  3745. <!-- 删除IPQC检验项目明细 -->
  3746. <delete id="deleteIPQCItemDetail" parameterType="java.util.Map">
  3747. DELETE FROM qc_ipqc_detailed_record
  3748. WHERE site = #{site}
  3749. AND bu_no = #{buNo}
  3750. AND inspection_no = #{inspectionNo}
  3751. AND item_no = #{itemNo}
  3752. </delete>
  3753. <!-- 删除IPQC检验项目的子明细 -->
  3754. <delete id="deleteIPQCSubDetailByItem" parameterType="java.util.Map">
  3755. DELETE FROM qc_ipqc_sub_detail_record
  3756. WHERE site = #{site}
  3757. AND bu_no = #{buNo}
  3758. AND inspection_no = #{inspectionNo}
  3759. AND item_no = #{itemNo}
  3760. </delete>
  3761. <!-- IPQC模板导入相关SQL -->
  3762. <!-- 查询IPQC模板列表 -->
  3763. <select id="getIPQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  3764. SELECT
  3765. t.template_id as templateId,
  3766. t.template_name as templateName,
  3767. t.template_remark as remark,
  3768. (SELECT COUNT(*) FROM qc_template_detailed d
  3769. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  3770. FROM qc_template t
  3771. WHERE t.site = #{site}
  3772. AND t.bu_no = #{buNo}
  3773. AND t.inspection_type_no = '101'
  3774. <if test="templateId != null and templateId != ''">
  3775. AND t.template_id LIKE '%' + #{templateId} + '%'
  3776. </if>
  3777. <if test="templateDesc != null and templateDesc != ''">
  3778. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  3779. </if>
  3780. ORDER BY t.template_id
  3781. </select>
  3782. <!-- 查询模板的所有检验项目(按order_id排序) -->
  3783. <select id="getTemplateItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3784. SELECT
  3785. d.ItemNo as itemNo,
  3786. p.ItemDesc as itemDesc,
  3787. d.default_value as defaultValue,
  3788. d.max_value as maxValue,
  3789. d.min_value as minValue,
  3790. p.ValueType as valueType,
  3791. p.ValueType_DB as valueTypeDb,
  3792. d.order_id as orderId
  3793. FROM qc_template_detailed d
  3794. LEFT JOIN eam_properties_item p
  3795. ON d.site = p.site
  3796. AND d.bu_no = p.bu_no
  3797. AND d.ItemNo = p.ItemNo
  3798. WHERE d.site = #{site}
  3799. AND d.bu_no = #{buNo}
  3800. AND d.template_id = #{templateId}
  3801. ORDER BY COALESCE(d.order_id, 99999) ASC, d.ItemNo ASC
  3802. </select>
  3803. <!-- 查询检验单已有的项目编码列表 -->
  3804. <select id="getExistingItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  3805. SELECT item_no
  3806. FROM qc_ipqc_detailed_record
  3807. WHERE site = #{site}
  3808. AND bu_no = #{buNo}
  3809. AND inspection_no = #{inspectionNo}
  3810. </select>
  3811. <!-- ======================== IQC检验项目操作和模板导入 ======================== -->
  3812. <!-- 查询IQC可选的检验项目 -->
  3813. <select id="getIQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3814. SELECT
  3815. ItemNo as itemNo,
  3816. ItemDesc as itemDesc,
  3817. DefaultValue as defaultValue,
  3818. MaxValue as maxValue,
  3819. MinValue as minValue,
  3820. ValueType as valueType,
  3821. ValueType_DB as valueTypeDb
  3822. FROM eam_properties_item
  3823. WHERE site = #{site}
  3824. AND bu_no = #{buNo}
  3825. AND inspection_type_no = '105'
  3826. <if test="itemNo != null and itemNo != ''">
  3827. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3828. </if>
  3829. <if test="itemDesc != null and itemDesc != ''">
  3830. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3831. </if>
  3832. AND ItemNo NOT IN (
  3833. SELECT item_no
  3834. FROM qc_iqc_detailed_record
  3835. WHERE site = #{site}
  3836. AND bu_no = #{buNo}
  3837. AND inspection_no = #{inspectionNo}
  3838. )
  3839. ORDER BY ItemNo
  3840. </select>
  3841. <!-- 查询IQC已选的检验项目 -->
  3842. <select id="getIQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3843. SELECT
  3844. d.item_no as itemNo,
  3845. d.item_desc as itemDesc
  3846. FROM qc_iqc_detailed_record d
  3847. WHERE d.site = #{site}
  3848. AND d.bu_no = #{buNo}
  3849. AND d.inspection_no = #{inspectionNo}
  3850. ORDER BY d.item_no
  3851. </select>
  3852. <!-- 查询当前IQC检验单已有的项目 -->
  3853. <select id="getExistingIQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3854. SELECT TOP 1
  3855. template_id as templateId,
  3856. item_no as itemNo,
  3857. foreign_flag as foreignFlag
  3858. FROM qc_iqc_detailed_record
  3859. WHERE site = #{site}
  3860. AND bu_no = #{buNo}
  3861. AND inspection_no = #{inspectionNo}
  3862. </select>
  3863. <!-- 插入IQC检验项目 -->
  3864. <insert id="insertIQCItemDetail" parameterType="java.util.Map">
  3865. INSERT INTO qc_iqc_detailed_record (
  3866. inspection_no,
  3867. template_id,
  3868. item_no,
  3869. item_desc,
  3870. default_value,
  3871. min_value,
  3872. max_value,
  3873. value_type_db,
  3874. value_type,
  3875. site,
  3876. bu_no,
  3877. foreign_flag,
  3878. order_id
  3879. ) VALUES (
  3880. #{inspectionNo},
  3881. #{templateId},
  3882. #{itemNo},
  3883. #{itemDesc},
  3884. #{defaultValue},
  3885. #{minValue},
  3886. #{maxValue},
  3887. #{valueTypeDb},
  3888. #{valueType},
  3889. #{site},
  3890. #{buNo},
  3891. #{foreignFlag},
  3892. #{orderId}
  3893. )
  3894. </insert>
  3895. <!-- 获取IQC检验单中最大的order_id -->
  3896. <select id="getMaxOrderIdForIQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  3897. SELECT ISNULL(MAX(order_id), 0)
  3898. FROM qc_iqc_detailed_record
  3899. WHERE site = #{site}
  3900. AND bu_no = #{buNo}
  3901. AND inspection_no = #{inspectionNo}
  3902. </select>
  3903. <!-- 删除IQC检验项目 -->
  3904. <delete id="deleteIQCItemDetail" parameterType="java.util.Map">
  3905. DELETE FROM qc_iqc_detailed_record
  3906. WHERE site = #{site}
  3907. AND bu_no = #{buNo}
  3908. AND inspection_no = #{inspectionNo}
  3909. AND item_no = #{itemNo}
  3910. </delete>
  3911. <!-- 删除IQC检验项目的子明细 -->
  3912. <delete id="deleteIQCSubDetailByItem" parameterType="java.util.Map">
  3913. DELETE FROM qc_iqc_sub_detail_record
  3914. WHERE site = #{site}
  3915. AND bu_no = #{buNo}
  3916. AND inspection_no = #{inspectionNo}
  3917. AND item_no = #{itemNo}
  3918. </delete>
  3919. <!-- 查询IQC模板列表 -->
  3920. <select id="getIQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  3921. SELECT
  3922. t.template_id as templateId,
  3923. t.template_name as templateName,
  3924. t.template_remark as remark,
  3925. (SELECT COUNT(*) FROM qc_template_detailed d
  3926. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  3927. FROM qc_template t
  3928. WHERE t.site = #{site}
  3929. AND t.bu_no = #{buNo}
  3930. AND t.inspection_type_no = '105'
  3931. <if test="templateId != null and templateId != ''">
  3932. AND t.template_id LIKE '%' + #{templateId} + '%'
  3933. </if>
  3934. <if test="templateDesc != null and templateDesc != ''">
  3935. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  3936. </if>
  3937. ORDER BY t.template_id
  3938. </select>
  3939. <!-- 查询IQC检验单已有的项目编码 -->
  3940. <select id="getExistingIQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  3941. SELECT item_no
  3942. FROM qc_iqc_detailed_record
  3943. WHERE site = #{site}
  3944. AND bu_no = #{buNo}
  3945. AND inspection_no = #{inspectionNo}
  3946. </select>
  3947. <!-- ======================== FQC检验项目操作和模板导入 ======================== -->
  3948. <!-- 查询FQC可选的检验项目 -->
  3949. <select id="getFQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3950. SELECT
  3951. ItemNo as itemNo,
  3952. ItemDesc as itemDesc,
  3953. DefaultValue as defaultValue,
  3954. MaxValue as maxValue,
  3955. MinValue as minValue,
  3956. ValueType as valueType,
  3957. ValueType_DB as valueTypeDb
  3958. FROM eam_properties_item
  3959. WHERE site = #{site}
  3960. AND bu_no = #{buNo}
  3961. AND inspection_type_no = '107'
  3962. <if test="itemNo != null and itemNo != ''">
  3963. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3964. </if>
  3965. <if test="itemDesc != null and itemDesc != ''">
  3966. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3967. </if>
  3968. AND ItemNo NOT IN (
  3969. SELECT item_no
  3970. FROM qc_fqc_detailed_record
  3971. WHERE site = #{site}
  3972. AND bu_no = #{buNo}
  3973. AND inspection_no = #{inspectionNo}
  3974. )
  3975. ORDER BY ItemNo
  3976. </select>
  3977. <!-- 查询FQC已选的检验项目 -->
  3978. <select id="getFQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3979. SELECT
  3980. d.item_no as itemNo,
  3981. d.item_desc as itemDesc
  3982. FROM qc_fqc_detailed_record d
  3983. WHERE d.site = #{site}
  3984. AND d.bu_no = #{buNo}
  3985. AND d.inspection_no = #{inspectionNo}
  3986. ORDER BY d.item_no
  3987. </select>
  3988. <!-- 查询当前FQC检验单已有的项目 -->
  3989. <select id="getExistingFQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3990. SELECT TOP 1
  3991. template_id as templateId,
  3992. item_no as itemNo,
  3993. foreign_flag as foreignFlag
  3994. FROM qc_fqc_detailed_record
  3995. WHERE site = #{site}
  3996. AND bu_no = #{buNo}
  3997. AND inspection_no = #{inspectionNo}
  3998. </select>
  3999. <!-- 插入FQC检验项目 -->
  4000. <insert id="insertFQCItemDetail" parameterType="java.util.Map">
  4001. INSERT INTO qc_fqc_detailed_record (
  4002. inspection_no,
  4003. template_id,
  4004. item_no,
  4005. item_desc,
  4006. default_value,
  4007. min_value,
  4008. max_value,
  4009. value_type_db,
  4010. value_type,
  4011. site,
  4012. bu_no,
  4013. foreign_flag,
  4014. order_id
  4015. ) VALUES (
  4016. #{inspectionNo},
  4017. #{templateId},
  4018. #{itemNo},
  4019. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4020. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4021. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4022. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4023. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4024. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4025. #{site},
  4026. #{buNo},
  4027. #{foreignFlag},
  4028. #{orderId}
  4029. )
  4030. </insert>
  4031. <!-- 获取FQC检验单中最大的order_id -->
  4032. <select id="getMaxOrderIdForFQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  4033. SELECT ISNULL(MAX(order_id), 0)
  4034. FROM qc_fqc_detailed_record
  4035. WHERE site = #{site}
  4036. AND bu_no = #{buNo}
  4037. AND inspection_no = #{inspectionNo}
  4038. </select>
  4039. <!-- 删除FQC检验项目 -->
  4040. <delete id="deleteFQCItemDetail" parameterType="java.util.Map">
  4041. DELETE FROM qc_fqc_detailed_record
  4042. WHERE site = #{site}
  4043. AND bu_no = #{buNo}
  4044. AND inspection_no = #{inspectionNo}
  4045. AND item_no = #{itemNo}
  4046. </delete>
  4047. <!-- 删除FQC检验项目的子明细 -->
  4048. <delete id="deleteFQCSubDetailByItem" parameterType="java.util.Map">
  4049. DELETE FROM qc_fqc_sub_detail_record
  4050. WHERE site = #{site}
  4051. AND bu_no = #{buNo}
  4052. AND inspection_no = #{inspectionNo}
  4053. AND item_no = #{itemNo}
  4054. </delete>
  4055. <!-- 查询FQC模板列表 -->
  4056. <select id="getFQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  4057. SELECT
  4058. t.template_id as templateId,
  4059. t.template_name as templateName,
  4060. t.template_remark as remark,
  4061. (SELECT COUNT(*) FROM qc_template_detailed d
  4062. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  4063. FROM qc_template t
  4064. WHERE t.site = #{site}
  4065. AND t.bu_no = #{buNo}
  4066. AND t.inspection_type_no = '107'
  4067. <if test="templateId != null and templateId != ''">
  4068. AND t.template_id LIKE '%' + #{templateId} + '%'
  4069. </if>
  4070. <if test="templateDesc != null and templateDesc != ''">
  4071. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  4072. </if>
  4073. ORDER BY t.template_id
  4074. </select>
  4075. <!-- 查询FQC检验单已有的项目编码 -->
  4076. <select id="getExistingFQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  4077. SELECT item_no
  4078. FROM qc_fqc_detailed_record
  4079. WHERE site = #{site}
  4080. AND bu_no = #{buNo}
  4081. AND inspection_no = #{inspectionNo}
  4082. </select>
  4083. <!-- ======================== OQC检验项目操作和模板导入 ======================== -->
  4084. <!-- 查询OQC可选的检验项目 -->
  4085. <select id="getOQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  4086. SELECT
  4087. ItemNo as itemNo,
  4088. ItemDesc as itemDesc,
  4089. DefaultValue as defaultValue,
  4090. MaxValue as maxValue,
  4091. MinValue as minValue,
  4092. ValueType as valueType,
  4093. ValueType_DB as valueTypeDb
  4094. FROM eam_properties_item
  4095. WHERE site = #{site}
  4096. AND bu_no = #{buNo}
  4097. AND inspection_type_no = '109'
  4098. <if test="itemNo != null and itemNo != ''">
  4099. AND ItemNo LIKE '%' + #{itemNo} + '%'
  4100. </if>
  4101. <if test="itemDesc != null and itemDesc != ''">
  4102. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  4103. </if>
  4104. AND ItemNo NOT IN (
  4105. SELECT item_no
  4106. FROM qc_oqc_detailed_record
  4107. WHERE site = #{site}
  4108. AND bu_no = #{buNo}
  4109. AND inspection_no = #{inspectionNo}
  4110. )
  4111. ORDER BY ItemNo
  4112. </select>
  4113. <!-- 查询OQC已选的检验项目 -->
  4114. <select id="getOQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  4115. SELECT
  4116. d.item_no as itemNo,
  4117. d.item_desc as itemDesc
  4118. FROM qc_oqc_detailed_record d
  4119. WHERE d.site = #{site}
  4120. AND d.bu_no = #{buNo}
  4121. AND d.inspection_no = #{inspectionNo}
  4122. ORDER BY d.item_no
  4123. </select>
  4124. <!-- 查询当前OQC检验单已有的项目 -->
  4125. <select id="getExistingOQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  4126. SELECT TOP 1
  4127. template_id as templateId,
  4128. item_no as itemNo,
  4129. foreign_flag as foreignFlag
  4130. FROM qc_oqc_detailed_record
  4131. WHERE site = #{site}
  4132. AND bu_no = #{buNo}
  4133. AND inspection_no = #{inspectionNo}
  4134. </select>
  4135. <!-- 插入OQC检验项目 -->
  4136. <insert id="insertOQCItemDetail" parameterType="java.util.Map">
  4137. INSERT INTO qc_oqc_detailed_record (
  4138. inspection_no,
  4139. template_id,
  4140. item_no,
  4141. item_desc,
  4142. default_value,
  4143. min_value,
  4144. max_value,
  4145. value_type_db,
  4146. value_type,
  4147. site,
  4148. bu_no,
  4149. foreign_flag,
  4150. order_id
  4151. ) VALUES (
  4152. #{inspectionNo},
  4153. #{templateId},
  4154. #{itemNo},
  4155. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4156. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4157. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4158. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4159. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4160. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4161. #{site},
  4162. #{buNo},
  4163. #{foreignFlag},
  4164. #{orderId}
  4165. )
  4166. </insert>
  4167. <!-- 获取OQC检验单中最大的order_id -->
  4168. <select id="getMaxOrderIdForOQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  4169. SELECT ISNULL(MAX(order_id), 0)
  4170. FROM qc_oqc_detailed_record
  4171. WHERE site = #{site}
  4172. AND bu_no = #{buNo}
  4173. AND inspection_no = #{inspectionNo}
  4174. </select>
  4175. <!-- 删除OQC检验项目 -->
  4176. <delete id="deleteOQCItemDetail" parameterType="java.util.Map">
  4177. DELETE FROM qc_oqc_detailed_record
  4178. WHERE site = #{site}
  4179. AND bu_no = #{buNo}
  4180. AND inspection_no = #{inspectionNo}
  4181. AND item_no = #{itemNo}
  4182. </delete>
  4183. <!-- 删除OQC检验项目的子明细 -->
  4184. <delete id="deleteOQCSubDetailByItem" parameterType="java.util.Map">
  4185. DELETE FROM qc_oqc_sub_detail_record
  4186. WHERE site = #{site}
  4187. AND bu_no = #{buNo}
  4188. AND inspection_no = #{inspectionNo}
  4189. AND item_no = #{itemNo}
  4190. </delete>
  4191. <!-- 查询OQC模板列表 -->
  4192. <select id="getOQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  4193. SELECT
  4194. t.template_id as templateId,
  4195. t.template_name as templateName,
  4196. t.template_remark as remark,
  4197. (SELECT COUNT(*) FROM qc_template_detailed d
  4198. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  4199. FROM qc_template t
  4200. WHERE t.site = #{site}
  4201. AND t.bu_no = #{buNo}
  4202. AND t.inspection_type_no = '109'
  4203. <if test="templateId != null and templateId != ''">
  4204. AND t.template_id LIKE '%' + #{templateId} + '%'
  4205. </if>
  4206. <if test="templateDesc != null and templateDesc != ''">
  4207. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  4208. </if>
  4209. ORDER BY t.template_id
  4210. </select>
  4211. <!-- 查询OQC检验单已有的项目编码 -->
  4212. <select id="getExistingOQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  4213. SELECT item_no
  4214. FROM qc_oqc_detailed_record
  4215. WHERE site = #{site}
  4216. AND bu_no = #{buNo}
  4217. AND inspection_no = #{inspectionNo}
  4218. </select>
  4219. <select id="getInspectionStandards" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  4220. select
  4221. site,
  4222. bu_no,
  4223. template_id,
  4224. item_no,
  4225. default_value,
  4226. min_value,
  4227. max_value,
  4228. condition,
  4229. collection_source,
  4230. seq_no
  4231. from qc_inspection_standards
  4232. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4233. </select>
  4234. <delete id="deleteInspectionStandard" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  4235. delete from qc_inspection_standards
  4236. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4237. </delete>
  4238. <insert id="saveInspectionStandard">
  4239. INSERT INTO qc_inspection_standards
  4240. (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
  4241. VALUES
  4242. <foreach collection="list" item="item" separator=",">
  4243. (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
  4244. </foreach>
  4245. </insert>
  4246. <select id="getInspectionTemplateDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  4247. select
  4248. site,
  4249. bu_no,
  4250. template_id,
  4251. item_no
  4252. <if test="flag == 'iqc'">
  4253. from qc_iqc_detailed_record
  4254. </if>
  4255. <if test="flag == 'ipqc'">
  4256. from qc_ipqc_detailed_record
  4257. </if>
  4258. <if test="flag == 'sqc'">
  4259. from qc_sqc_detailed_record
  4260. </if>
  4261. <if test="flag == 'fqc'">
  4262. from qc_fqc_detailed_record
  4263. </if>
  4264. <if test="flag == 'fai'">
  4265. from qc_fai_detailed_record
  4266. </if>
  4267. <if test="flag == 'fqas' or flag == 'oqc'">
  4268. from qc_oqc_detailed_record
  4269. </if>
  4270. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4271. order by order_id
  4272. </select>
  4273. <update id="updateEquipmentDataDetailInspectionNo" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
  4274. update Equipment_data_detail
  4275. set inspection_no = #{inspectionNo}
  4276. where id = #{id}
  4277. </update>
  4278. <delete id="deleteInspectionFiles" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4279. delete sys_oss
  4280. where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo}
  4281. </delete>
  4282. <select id="getUpItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
  4283. select
  4284. top 1
  4285. site,
  4286. bu_no,
  4287. template_id,
  4288. ItemNo,
  4289. order_id
  4290. from qc_template_detailed
  4291. where #{orderId} > order_id
  4292. and site = #{site}
  4293. and bu_no= #{buNo}
  4294. and template_id = #{templateId}
  4295. order by order_id desc
  4296. </select>
  4297. <select id="getDownItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
  4298. select
  4299. top 1
  4300. site,
  4301. bu_no,
  4302. template_id,
  4303. ItemNo,
  4304. order_id
  4305. from qc_template_detailed
  4306. where order_id > #{orderId}
  4307. and site = #{site}
  4308. and bu_no= #{buNo}
  4309. and template_id = #{templateId}
  4310. order by order_id
  4311. </select>
  4312. <update id="updateQcItemOrder">
  4313. update qc_template_detailed
  4314. set order_id=#{orderId}
  4315. where site = #{site}
  4316. and bu_no= #{buNo}
  4317. and template_id = #{templateId}
  4318. and ItemNo = #{itemNo}
  4319. </update>
  4320. <select id="selectInfoByInspectionNo" resultType="com.gaotao.modules.pms.data.PoOrderRollNoData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4321. select
  4322. site,
  4323. bu_no,
  4324. inspection_no
  4325. from po_order_roll_no
  4326. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4327. </select>
  4328. <update id="updateIQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4329. UPDATE qc_iqc_record
  4330. SET submit_flag = 'N',
  4331. state = '待检验',
  4332. cancel_check_by = #{updateBy},
  4333. cancel_check_date = getDate(),
  4334. submit_by = NULL
  4335. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4336. </update>
  4337. <update id="updateIQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4338. UPDATE qc_iqc_detailed_record
  4339. SET is_submit = 'N'
  4340. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4341. </update>
  4342. <update id="updateIQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4343. UPDATE qc_iqc_sub_detail_record
  4344. SET is_submit = 'N'
  4345. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4346. </update>
  4347. <update id="updatePartDefectTracking" statementType="CALLABLE">
  4348. {CALL UspUpdatePartDefectTracking(
  4349. #{site,mode=IN,jdbcType=VARCHAR},
  4350. #{buNo,mode=IN,jdbcType=VARCHAR},
  4351. #{partNo,mode=IN,jdbcType=VARCHAR},
  4352. #{supplierId,mode=IN,jdbcType=VARCHAR},
  4353. #{passFlag,mode=IN,jdbcType=BIT}
  4354. )}
  4355. </update>
  4356. <update id="updateFAIMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4357. UPDATE qc_fai_record
  4358. SET submit_flag = 'N',
  4359. state = '待检验',
  4360. cancel_check_by = #{updateBy},
  4361. cancel_check_date = getDate()
  4362. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4363. </update>
  4364. <update id="updateFAIDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4365. UPDATE qc_fai_detailed_record
  4366. SET is_submit = 'N'
  4367. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4368. </update>
  4369. <update id="updateFAISubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4370. UPDATE qc_fai_sub_detail_record
  4371. SET is_submit = 'N'
  4372. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4373. </update>
  4374. <update id="updateIPQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4375. UPDATE qc_ipqc_record
  4376. SET submit_flag = 'N',
  4377. state = '待检验',
  4378. cancel_check_by = #{updateBy},
  4379. cancel_check_date = getDate(),
  4380. submit_by = NULL
  4381. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4382. </update>
  4383. <update id="updateIPQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4384. UPDATE qc_ipqc_detailed_record
  4385. SET is_submit = 'N'
  4386. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4387. </update>
  4388. <update id="updateIPQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4389. UPDATE qc_ipqc_sub_detail_record
  4390. SET is_submit = 'N'
  4391. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4392. </update>
  4393. <update id="updateSQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4394. UPDATE qc_sqc_record
  4395. SET submit_flag = 'N',
  4396. state = '待检验',
  4397. cancel_check_by = #{updateBy},
  4398. cancel_check_date = getDate(),
  4399. submit_by = NULL
  4400. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4401. </update>
  4402. <update id="updateSQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4403. UPDATE qc_sqc_detailed_record
  4404. SET is_submit = 'N'
  4405. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4406. </update>
  4407. <update id="updateSQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4408. UPDATE qc_sqc_sub_detail_record
  4409. SET is_submit = 'N'
  4410. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4411. </update>
  4412. <update id="updateFQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4413. UPDATE qc_fqc_record
  4414. SET submit_flag = 'N',
  4415. state = '待检验',
  4416. cancel_check_by = #{updateBy},
  4417. cancel_check_date = getDate(),
  4418. submit_by = NULL
  4419. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4420. </update>
  4421. <update id="updateFQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4422. UPDATE qc_fqc_detailed_record
  4423. SET is_submit = 'N'
  4424. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4425. </update>
  4426. <update id="updateFQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4427. UPDATE qc_fqc_sub_detail_record
  4428. SET is_submit = 'N'
  4429. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4430. </update>
  4431. <update id="updateFQASMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4432. UPDATE qc_oqc_record
  4433. SET submit_flag = 'N',
  4434. state = '待检验',
  4435. cancel_check_by = #{updateBy},
  4436. cancel_check_date = getDate(),
  4437. submit_by = NULL
  4438. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4439. </update>
  4440. <update id="updateFQASDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4441. UPDATE qc_oqc_detailed_record
  4442. SET is_submit = 'N'
  4443. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4444. </update>
  4445. <update id="updateFQASSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4446. UPDATE qc_oqc_sub_detail_record
  4447. SET is_submit = 'N'
  4448. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4449. </update>
  4450. <delete id="deleteReceivingTaskByInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4451. delete receiving_task
  4452. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  4453. </delete>
  4454. <delete id="deleteObjectFile">
  4455. delete from sys_oss where id = #{id}
  4456. </delete>
  4457. <!-- 获取用户角色列表 -->
  4458. <select id="getUserRoleList" resultType="com.gaotao.modules.sys.entity.SysRoleEntity">
  4459. SELECT
  4460. role_id,
  4461. role_name
  4462. FROM sys_role
  4463. </select>
  4464. <select id="getOperatorListByOrder" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  4465. SELECT
  4466. a.user_id, a.username AS adminID, a.email, a.mobile AS phone, a.user_display AS adminName,
  4467. d.role_id, e.role_name, c.site, c.bu_no,
  4468. -- 获取计划工单数
  4469. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) AS planOrderCount,
  4470. -- 获取实际工单数
  4471. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) AS actualOrderCount,
  4472. -- 负荷率(%)
  4473. CASE
  4474. WHEN dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) = 0 THEN 0
  4475. ELSE
  4476. CAST(
  4477. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) * 100.0 /
  4478. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username)
  4479. AS DECIMAL(5,2))
  4480. END AS load_rate
  4481. FROM
  4482. sys_user AS a
  4483. LEFT JOIN AccessSite AS b ON a.username = b.userID
  4484. LEFT JOIN AccessBu AS c ON b.userID = c.username AND b.site = c.site
  4485. LEFT JOIN sys_user_role AS d ON a.user_id = d.user_id
  4486. LEFT JOIN sys_role AS e ON d.role_id = e.role_id
  4487. <where>
  4488. b.site = #{site} and c.bu_no = #{buNo}
  4489. <if test = "adminID != null and adminID != ''">
  4490. AND a.username LIKE '%' + #{adminID} + '%'
  4491. </if>
  4492. <if test = "adminName != null and adminName != ''">
  4493. AND a.user_display LIKE '%' + #{adminName} + '%'
  4494. </if>
  4495. <if test = "roleId != null and roleId != ''">
  4496. AND d.role_id = #{roleId}
  4497. </if>
  4498. <if test = "date != null and classesCode != null and classesCode != ''">
  4499. AND a.username IN (
  4500. SELECT tpm_scheduling_record.admin_id
  4501. FROM tpm_scheduling
  4502. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  4503. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  4504. )
  4505. </if>
  4506. <if test = "date != null and (classesCode == null or classesCode == '')">
  4507. AND a.username IN (
  4508. SELECT tpm_scheduling_record.admin_id
  4509. FROM tpm_scheduling
  4510. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  4511. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling_record.isHoliday = 'N'
  4512. )
  4513. </if>
  4514. <if test = "classesCode != null and classesCode != '' and date == null">
  4515. AND a.username IN (
  4516. SELECT tpm_scheduling_record.admin_id
  4517. FROM tpm_scheduling
  4518. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  4519. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  4520. )
  4521. </if>
  4522. </where>
  4523. order by load_rate desc
  4524. </select>
  4525. <!-- 查询OQC基础数据 -->
  4526. <select id="selectOQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4527. SELECT
  4528. qir.inspection_no,
  4529. qir.state,
  4530. qir.create_date as taskDate,
  4531. qir.roll_no,
  4532. qir.part_no,
  4533. dbo.Get_Part_DescSpec(qir.site, qir.part_no) as part_desc,
  4534. qir.roll_qty,
  4535. qir.print_flag,
  4536. qir.inspector_by,
  4537. qir.site,
  4538. qir.bu_no,
  4539. qir.roll_count
  4540. FROM qc_oqc_record as qir
  4541. LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
  4542. WHERE qir.site in (select site from AccessSite where userID = #{userName})
  4543. and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
  4544. and qir.detail_flag = 'N'
  4545. </select>
  4546. <select id="selectFQASPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4547. SELECT
  4548. qat.site,
  4549. qat.bu_no,
  4550. qat.attribute_no,
  4551. qat.template_id,
  4552. qat.sampling_level_no,
  4553. qsil.sampling_level_desc,
  4554. qat.inspection_cycle,
  4555. qat.sampling_programme_no,
  4556. qsip.sampling_programme_desc,
  4557. qat.AQL,
  4558. qat.AC,
  4559. qat.RE,
  4560. qt.default_sampling_quantity,
  4561. qt.default_sampling_proportion
  4562. FROM qc_attribute_template as qat
  4563. LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
  4564. LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
  4565. LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
  4566. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  4567. AND qat.attribute_no = #{partNo}
  4568. AND qat.attribute_type = #{attributeType}
  4569. AND qt.inspection_type_no = #{inspectionTypeNo}
  4570. </select>
  4571. <!-- 新增OQC明细记录信息 -->
  4572. <insert id="saveFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4573. INSERT INTO qc_oqc_detailed_record
  4574. (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE,
  4575. item_no, item_desc, object_id, object_desc, default_value, min_value, max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  4576. VALUES
  4577. (#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL},
  4578. #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo}, #{orderId}, #{custom1}, #{custom2}, #{custom3})
  4579. </insert>
  4580. <!-- 修改OQC检验记录 -->
  4581. <update id="updateFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4582. UPDATE qc_oqc_record
  4583. SET inspection_type_no = #{inspectionTypeNo},
  4584. sampling_qty = #{samplingQty},
  4585. inspection_cycle = #{inspectionCycle},
  4586. part_desc = #{partDesc},
  4587. detail_flag = 'Y',
  4588. pass_qty = #{samplingQty},
  4589. not_pass_qty = 0
  4590. <if test="inspectorBy != null and inspectorBy != ''">
  4591. , inspector_by = #{inspectorBy}
  4592. </if>
  4593. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4594. </update>
  4595. <!-- 查询OQC主记录信息 -->
  4596. <select id="qcOQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4597. SELECT
  4598. a.inspection_no,
  4599. a.site,
  4600. a.bu_no,
  4601. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  4602. a.state,
  4603. a.inspection_result,
  4604. a.create_date as taskDate,
  4605. a.create_date,
  4606. a.inspection_type_no,
  4607. a.inspection_cycle,
  4608. a.part_no,
  4609. d.PartDescription as partDesc,
  4610. d.umid as umId,
  4611. um.UMName as umName,
  4612. d.spec,
  4613. a.inspection_remark,
  4614. a.roll_qty,
  4615. a.sampling_qty,
  4616. a.disposal_measures,
  4617. a.disposal_remark,
  4618. a.inspector_date as inspectorDate,
  4619. a.submit_date,
  4620. isnull(sub.user_display, a.submit_by) as submitBy,
  4621. a.inspector_no,
  4622. u.user_display as inspectorName,
  4623. a.submit_flag,
  4624. a.roll_no,
  4625. a.roll_count,
  4626. a.action_date,
  4627. isnull(ab.user_display, a.action_by) as actionBy,
  4628. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  4629. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  4630. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  4631. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  4632. a.pass_qty,
  4633. a.not_pass_qty,
  4634. a.batch_qualified_qty,
  4635. a.create_by as createBy,
  4636. isnull(u2.user_display, a.create_by) as createByName,
  4637. a.customer_no,
  4638. dbo.Get_CustomerDesc(a.site, a.customer_no) as customerName,
  4639. a.po_orderNo,
  4640. a.po_itemNo,
  4641. a.document_no,
  4642. a.release_no as releaseNo,
  4643. a.line_no,
  4644. a.operation_desc,
  4645. isnull(a.inspector_by, a.create_by) as inspectorBy,
  4646. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName,
  4647. a.upper_system_flag as upperSystemFlag
  4648. FROM qc_oqc_record as a
  4649. left join sys_user as u on a.inspector_no = u.username
  4650. left join sys_user as ab on a.action_by = ab.username
  4651. left join sys_user as sub on a.submit_by = sub.username
  4652. inner join part as d on a.site = d.site and a.part_no = d.partNo
  4653. left join um as um on d.umid = um.UMID
  4654. left join sys_user as u2 on a.create_by = u2.username
  4655. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  4656. <where>
  4657. a.site in (select site from AccessSite where userID = #{query.userName})
  4658. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  4659. <if test="query.site != null and query.site != ''">
  4660. AND a.site = #{query.site}
  4661. </if>
  4662. <if test="query.buNo != null and query.buNo != ''">
  4663. AND a.bu_no = #{query.buNo}
  4664. </if>
  4665. <if test="query.buDesc != null and query.buDesc != ''">
  4666. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  4667. </if>
  4668. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  4669. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  4670. </if>
  4671. <if test = "query.states != null and query.states.size > 0">
  4672. AND a.state in
  4673. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  4674. #{item}
  4675. </foreach>
  4676. </if>
  4677. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  4678. AND a.inspection_result = #{query.inspectionResult}
  4679. </if>
  4680. <if test = "query.partNo != null and query.partNo != ''">
  4681. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  4682. </if>
  4683. <if test = "query.partDesc != null and query.partDesc != ''">
  4684. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  4685. </if>
  4686. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  4687. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  4688. </if>
  4689. <if test="query.startDate != null">
  4690. AND a.inspector_date >= #{query.startDate}
  4691. </if>
  4692. <if test="query.endDate != null">
  4693. AND #{query.endDate} >= a.inspector_date
  4694. </if>
  4695. <if test="query.startDate2 != null">
  4696. AND a.create_date >= #{query.startDate2}
  4697. </if>
  4698. <if test="query.endDate2 != null">
  4699. AND #{query.endDate2} >= a.create_date
  4700. </if>
  4701. <if test = "query.customerNo != null and query.customerNo != ''">
  4702. AND a.customer_no LIKE '%' + #{query.customerNo} + '%'
  4703. </if>
  4704. <if test = "query.customerName != null and query.customerName != ''">
  4705. AND dbo.Get_CustomerDesc(a.site, a.customer_no) LIKE '%' + #{query.customerName} + '%'
  4706. </if>
  4707. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  4708. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  4709. </if>
  4710. <if test = "query.spec != null and query.spec != ''">
  4711. AND d.spec LIKE '%' + #{query.spec} + '%'
  4712. </if>
  4713. <if test = "query.operationDesc != null and query.operationDesc != ''">
  4714. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  4715. </if>
  4716. </where>
  4717. ORDER BY a.inspection_no desc,
  4718. CASE WHEN a.state = '待检验' THEN 1
  4719. WHEN a.state = '待审核' THEN 2
  4720. WHEN a.state = '已完成' THEN 3
  4721. END, a.create_date desc
  4722. </select>
  4723. <!-- IQC明细记录查询 -->
  4724. <select id="fqasDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4725. SELECT
  4726. a.site,
  4727. a.bu_no,
  4728. a.inspection_no,
  4729. a.template_id,
  4730. a.sampling_level_no,
  4731. a.sampling_level_desc,
  4732. a.sampling_programme_no,
  4733. a.sampling_programme_desc,
  4734. a.AQL,
  4735. a.AC,
  4736. a.RE,
  4737. a.item_no,
  4738. a.item_desc,
  4739. a.object_id,
  4740. a.object_desc,
  4741. a.default_value,
  4742. a.min_value,
  4743. a.max_value,
  4744. a.text_value,
  4745. a.number_value,
  4746. a.value_type_db,
  4747. a.value_type,
  4748. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  4749. a.item_remark as itemRemark,
  4750. a.custom1,
  4751. a.custom2,
  4752. a.custom3,
  4753. a.is_submit,
  4754. a.unqualified_quantity,
  4755. dbo.qc_get_fqas_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  4756. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  4757. c.method_no,
  4758. c.method_name,
  4759. c.method_remark,
  4760. sw.color_code as qcSpecWarningColorCode,
  4761. sw.threshold_value as qcSpecWarningThresholdValue,
  4762. a.sampling_qty,
  4763. (SELECT TOP 1 epi.collection_flag
  4764. FROM eam_properties_item epi
  4765. WHERE epi.site = a.site
  4766. AND epi.bu_no = a.bu_no
  4767. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  4768. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  4769. epi.inspection_type_no) AS collectionFlag,
  4770. (SELECT TOP 1 epi.image_flag
  4771. FROM eam_properties_item epi
  4772. WHERE epi.site = a.site
  4773. AND epi.bu_no = a.bu_no
  4774. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  4775. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  4776. epi.inspection_type_no) AS imageFlag,
  4777. (SELECT TOP 1 epi.data_flag
  4778. FROM eam_properties_item epi
  4779. WHERE epi.site = a.site
  4780. AND epi.bu_no = a.bu_no
  4781. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  4782. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  4783. epi.inspection_type_no) AS dataFlag
  4784. FROM qc_oqc_detailed_record as a
  4785. LEFT JOIN qc_oqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  4786. OUTER APPLY (
  4787. SELECT TOP 1
  4788. w.color_code,
  4789. w.threshold_value
  4790. FROM qc_spec_warning w
  4791. WHERE w.site = a.site
  4792. AND w.bu_no = a.bu_no
  4793. AND w.part_no = r.part_no
  4794. AND w.item_no = a.item_no
  4795. AND w.inspection_type_no = r.inspection_type_no
  4796. ORDER BY w.threshold_value
  4797. ) sw
  4798. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  4799. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  4800. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  4801. ORDER BY COALESCE(a.order_id, 99999) ASC
  4802. </select>
  4803. <!-- 查询FQAS的子明细 -->
  4804. <select id="selectFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  4805. SELECT
  4806. site,
  4807. bu_no,
  4808. sub_detail_value,
  4809. sampling_location,
  4810. is_submit,
  4811. sampling_location_b,
  4812. num,
  4813. sub_detail_value_b,
  4814. sub_detail_value_c,
  4815. sub_detail_value_d,
  4816. sub_detail_value_e,
  4817. file_name,
  4818. is_transfer,
  4819. is_qualified,
  4820. defect_qty,
  4821. roll_no,
  4822. product_quantity as productQuantity,
  4823. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  4824. FROM qc_oqc_sub_detail_record
  4825. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  4826. </select>
  4827. <select id="getSupplier" parameterType="java.lang.String" resultType="com.gaotao.modules.base.entity.SupplierData">
  4828. SELECT
  4829. site,
  4830. SupplierID,
  4831. SupplierName
  4832. FROM Supplier
  4833. WHERE site = #{site} and SupplierID = #{supplierID} and Active = #{active}
  4834. </select>
  4835. <!-- 修改FQAS主记录信息 -->
  4836. <update id="updateFQASMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4837. UPDATE qc_oqc_record
  4838. SET disposal_measures = #{disposalMeasures},
  4839. disposal_remark = #{disposalRemark},
  4840. inspection_result = #{inspectionResult},
  4841. inspector_no = #{inspectorNo},
  4842. state = #{state},
  4843. inspection_remark = #{inspectionRemark},
  4844. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  4845. roll_count = #{rollCount,jdbcType=DECIMAL},
  4846. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  4847. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  4848. pass_qty = #{passQty,jdbcType=DECIMAL},
  4849. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  4850. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  4851. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  4852. </update>
  4853. <!-- 修改FQAS明细记录信息 -->
  4854. <update id="updateFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4855. UPDATE qc_oqc_detailed_record
  4856. SET item_result = #{itemResult},
  4857. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  4858. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  4859. text_value = #{textValue},
  4860. number_value = #{numberValue,jdbcType=DECIMAL},
  4861. default_value = #{defaultValue},
  4862. min_value = #{minValue,jdbcType=DECIMAL},
  4863. max_value = #{maxValue,jdbcType=DECIMAL},
  4864. item_remark = #{itemRemark},
  4865. custom1 = #{custom1},
  4866. custom2 = #{custom2},
  4867. custom3 = #{custom3}
  4868. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  4869. </update>
  4870. <update id="patchFQASDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4871. UPDATE qc_oqc_detailed_record
  4872. <set>
  4873. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  4874. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  4875. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  4876. <if test="textValue != null">text_value = #{textValue},</if>
  4877. </set>
  4878. WHERE inspection_no = #{inspectionNo}
  4879. and RTRIM(item_no) = RTRIM(#{itemNo})
  4880. and site = #{site}
  4881. and bu_no = #{buNo}
  4882. </update>
  4883. <!-- 查询FQAS主记录信息 -->
  4884. <select id="getFQASInspectionRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4885. SELECT
  4886. site,
  4887. bu_no,
  4888. inspection_no,
  4889. not_pass_qty,
  4890. roll_count,
  4891. inspection_result,
  4892. disposal_measures,
  4893. part_no
  4894. FROM qc_oqc_record
  4895. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4896. </select>
  4897. <!-- 修改FQAS主记录标识为已提交 -->
  4898. <update id="updateFQASMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4899. UPDATE qc_oqc_record
  4900. SET submit_flag = 'Y',
  4901. state = '已完成',
  4902. submit_date = getDate(),
  4903. submit_by = #{updateBy}
  4904. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4905. </update>
  4906. <!-- 修改FQAS明细记录标识为已提交 -->
  4907. <update id="updateFQASDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4908. UPDATE qc_oqc_detailed_record
  4909. SET is_submit = 'Y'
  4910. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4911. </update>
  4912. <!-- 修改FQAS子明细记录标识为已提交 -->
  4913. <update id="updateFQASSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4914. UPDATE qc_oqc_sub_detail_record
  4915. SET is_submit = 'Y'
  4916. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4917. </update>
  4918. <!-- 查询FQAS检验记录是否已提交 -->
  4919. <select id="checkFQASIsSubmit" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4920. SELECT submit_flag
  4921. FROM qc_oqc_record
  4922. WHERE inspection_no = #{inspectionNo} and site = #{site}
  4923. </select>
  4924. <!-- 删除FQAS子明细的老数据 -->
  4925. <delete id="delFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  4926. DELETE FROM qc_oqc_sub_detail_record
  4927. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  4928. </delete>
  4929. <!-- 新增FQAS子明细信息 -->
  4930. <insert id="saveFQASSubDetailed">
  4931. INSERT INTO qc_oqc_sub_detail_record
  4932. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, product_quantity, create_time)
  4933. VALUES
  4934. <foreach collection="list" item="item" separator=",">
  4935. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, #{item.productQuantity,jdbcType=DECIMAL}, getDate())
  4936. </foreach>
  4937. </insert>
  4938. <!-- 删除FQAS检验记录 -->
  4939. <delete id="deleteFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4940. DELETE FROM qc_oqc_record
  4941. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4942. </delete>
  4943. <!-- 删除FQAS明细记录信息 -->
  4944. <delete id="deleteFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4945. DELETE FROM qc_oqc_detailed_record
  4946. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4947. </delete>
  4948. <!-- 删除FQAS子明细记录信息 -->
  4949. <delete id="deleteFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4950. DELETE FROM qc_oqc_sub_detail_record
  4951. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4952. </delete>
  4953. <!-- 查询FQAS(OQC)检验单当前状态 -->
  4954. <select id="getFQASRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4955. SELECT submit_flag, state
  4956. FROM qc_oqc_record
  4957. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4958. </select>
  4959. <update id="actionFQASInspection" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4960. update qc_oqc_record
  4961. set action_date = getDate(),
  4962. action_by = #{actionBy},
  4963. state = #{state}
  4964. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4965. </update>
  4966. <update id="updateSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4967. update
  4968. <if test = "inspectionTypeNo == '105'">
  4969. qc_iqc_record
  4970. </if>
  4971. <if test = "inspectionTypeNo == '108'">
  4972. qc_oqc_record
  4973. </if>
  4974. set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
  4975. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4976. </update>
  4977. <update id="updateDetailSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4978. update
  4979. <if test = "inspectionTypeNo == '105'">
  4980. qc_iqc_detailed_record
  4981. </if>
  4982. <if test = "inspectionTypeNo == '108'">
  4983. qc_oqc_detailed_record
  4984. </if>
  4985. set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
  4986. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4987. </update>
  4988. <!-- 获取审核人员列表 -->
  4989. <select id="getCheckerList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  4990. SELECT
  4991. a.user_id,
  4992. a.username as adminID,
  4993. a.email,
  4994. a.mobile as phone,
  4995. a.user_display as adminName,
  4996. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  4997. d.role_id,
  4998. e.role_name
  4999. FROM sys_user as a
  5000. LEFT JOIN AccessSite as b on a.username = b.userID
  5001. LEFT JOIN AccessBu as c on b.userID = c.username and b.site = c.site
  5002. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  5003. LEFT JOIN sys_role as e on d.role_id = e.role_id
  5004. <where>
  5005. b.site = #{site} and c.bu_no = #{buNo}
  5006. <if test = "adminID != null and adminID != ''">
  5007. AND a.username LIKE '%' + #{adminID}+'%'
  5008. </if>
  5009. <if test = "adminName != null and adminName != ''">
  5010. AND a.user_display LIKE '%' + #{adminName}+'%'
  5011. </if>
  5012. <if test = "buDesc != null and buDesc != ''">
  5013. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  5014. </if>
  5015. <if test = "roleId != null and roleId != ''">
  5016. AND d.role_id = #{roleId}
  5017. </if>
  5018. </where>
  5019. </select>
  5020. <!-- 获取送检员列表:由 getCheckerList 复制,改为按所选 site 的 access_role.role_no = R007 授权用户 -->
  5021. <select id="getSenderList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  5022. SELECT
  5023. a.user_id,
  5024. a.username as adminID,
  5025. a.email,
  5026. a.mobile as phone,
  5027. a.user_display as adminName,
  5028. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  5029. d.role_id,
  5030. e.role_name
  5031. FROM sys_user as a
  5032. INNER JOIN access_role ar on a.username = ar.username and ar.site = #{site} and ar.role_no = 'R007'
  5033. LEFT JOIN AccessSite as b on a.username = b.userID and b.site = ar.site
  5034. LEFT JOIN AccessBu as c on b.userID = c.username and b.site = c.site
  5035. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  5036. LEFT JOIN sys_role as e on d.role_id = e.role_id
  5037. <where>
  5038. <if test = "adminID != null and adminID != ''">
  5039. AND a.username LIKE '%' + #{adminID}+'%'
  5040. </if>
  5041. <if test = "adminName != null and adminName != ''">
  5042. AND a.user_display LIKE '%' + #{adminName}+'%'
  5043. </if>
  5044. <if test = "buDesc != null and buDesc != ''">
  5045. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  5046. </if>
  5047. <if test = "roleId != null and roleId != ''">
  5048. AND d.role_id = #{roleId}
  5049. </if>
  5050. </where>
  5051. </select>
  5052. <!-- ================================================= SOP清单相关SQL ================================================= -->
  5053. <!-- SOP清单查询 -->
  5054. <select id="sopListSearch" resultType="map">
  5055. <!-- SELECT-->
  5056. <!-- ps.site,-->
  5057. <!-- ps.bu_no as buNo,-->
  5058. <!-- ps.part_no as partNo,-->
  5059. <!-- ps.sop_no as sopNo,-->
  5060. <!-- ps.sop_name as sopName,-->
  5061. <!-- ps.sop_url as sopUrl,-->
  5062. <!-- ps.version,-->
  5063. <!-- ps.sop_status as sopStatus,-->
  5064. <!-- ps.phase_in_date as phaseInDate,-->
  5065. <!-- ps.phase_out_date as phaseOutDate,-->
  5066. <!-- ps.created_by as createdBy,-->
  5067. <!-- ps.creation_date as creationDate,-->
  5068. <!-- ps.sop_type as sopType,-->
  5069. <!-- ps.operation_desc as operationDesc-->
  5070. <!-- FROM part_sop ps-->
  5071. <!-- <where>-->
  5072. <!-- <if test="params.site != null and params.site != ''">-->
  5073. <!-- AND ps.site = #{params.site}-->
  5074. <!-- </if>-->
  5075. <!-- <if test="params.partNo != null and params.partNo != ''">-->
  5076. <!-- AND ps.part_no = #{params.partNo}-->
  5077. <!-- </if>-->
  5078. <!-- </where>-->
  5079. <!-- ORDER BY ps.creation_date DESC-->
  5080. SELECT DISTINCT
  5081. site,
  5082. buNo,
  5083. partNo,
  5084. sopNo,
  5085. sopName,
  5086. sopUrl,
  5087. [version],
  5088. sopStatus,
  5089. phaseInDate,
  5090. phaseOutDate,
  5091. createdBy,
  5092. creationDate,
  5093. sopType,
  5094. operationDesc
  5095. FROM (
  5096. -- 来源1: part_sop(零件SOP)
  5097. SELECT
  5098. ps.site,
  5099. ps.bu_no AS buNo,
  5100. ps.part_no AS partNo,
  5101. ps.sop_no AS sopNo,
  5102. ps.sop_name AS sopName,
  5103. ps.sop_url AS sopUrl,
  5104. ps.[version ] AS [version],
  5105. ps.sop_status AS sopStatus,
  5106. ps.phase_in_date AS phaseInDate,
  5107. ps.phase_out_date AS phaseOutDate,
  5108. ps.created_by AS createdBy,
  5109. ps.creation_date AS creationDate,
  5110. ps.sop_type AS sopType,
  5111. ps.operation_desc AS operationDesc
  5112. FROM part_sop ps
  5113. WHERE ps.site = #{params.site}
  5114. AND ps.part_no = #{params.partNo}
  5115. UNION ALL
  5116. -- 来源2: file_management(公共生产文件 或 订单关联文件)
  5117. SELECT
  5118. fm.site,
  5119. fm.bu_no AS buNo,
  5120. '' AS partNo,
  5121. fm.file_no AS sopNo,
  5122. fm.file_name AS sopName,
  5123. fm.url_add_ress AS sopUrl,
  5124. fm.sop_rev_no AS [version],
  5125. fm.status AS sopStatus,
  5126. fm.phase_in_date AS phaseInDate,
  5127. fm.phase_out_date AS phaseOutDate,
  5128. fm.created_by AS createdBy,
  5129. fm.create_date AS creationDate,
  5130. fm.file_type AS sopType,
  5131. fm.item_no AS operationDesc
  5132. FROM file_management fm
  5133. WHERE fm.site = #{params.site}
  5134. AND fm.file_type = '生产'
  5135. AND (
  5136. ISNULL(fm.public_flag, 'N') = 'Y'
  5137. OR fm.order_no = #{params.orderNo}
  5138. )
  5139. ) AS CombinedResults
  5140. </select>
  5141. <!-- 查询检验页面的SOP文件列表(从file_management表) -->
  5142. <select id="searchQcSopFileList" resultType="map">
  5143. <!-- SELECT DISTINCT-->
  5144. <!-- fm.ID AS id,-->
  5145. <!-- fm.url_add_ress AS sopUrl,-->
  5146. <!-- fm.create_date AS creationDate,-->
  5147. <!-- fm.file_name AS sopName,-->
  5148. <!-- fm.new_file_name AS newFileName,-->
  5149. <!-- fm.created_by AS createdBy,-->
  5150. <!-- fm.file_type AS fileType,&#45;&#45;-->
  5151. <!-- fm.file_suffix AS fileSuffix,-->
  5152. <!-- fm.sop_rev_no AS version,-->
  5153. <!-- fm.phase_in_date AS phaseInDate,-->
  5154. <!-- fm.phase_out_date AS phaseOutDate-->
  5155. <!-- FROM file_management fm-->
  5156. SELECT DISTINCT
  5157. site,
  5158. buNo,
  5159. partNo,
  5160. sopNo,
  5161. sopName,
  5162. sopUrl,
  5163. [version],
  5164. sopStatus,
  5165. phaseInDate,
  5166. phaseOutDate,
  5167. createdBy,
  5168. creationDate,
  5169. sopType as fileType,
  5170. operationDesc
  5171. FROM (
  5172. -- 来源1: part_sop(零件SOP)
  5173. SELECT
  5174. ps.site,
  5175. ps.bu_no AS buNo,
  5176. ps.part_no AS partNo,
  5177. ps.sop_no AS sopNo,
  5178. ps.sop_name AS sopName,
  5179. ps.sop_url AS sopUrl,
  5180. ps.[version ] AS [version],
  5181. ps.sop_status AS sopStatus,
  5182. ps.phase_in_date AS phaseInDate,
  5183. ps.phase_out_date AS phaseOutDate,
  5184. ps.created_by AS createdBy,
  5185. ps.creation_date AS creationDate,
  5186. ps.sop_type AS sopType,
  5187. ps.operation_desc AS operationDesc
  5188. FROM part_sop ps
  5189. WHERE ps.site = #{params.site}
  5190. AND ps.part_no = #{params.partNo}
  5191. UNION ALL
  5192. -- 来源2: file_management(公共生产文件 或 订单关联文件)
  5193. SELECT
  5194. fm.site,
  5195. fm.bu_no AS buNo,
  5196. '' AS partNo,
  5197. fm.file_no AS sopNo,
  5198. fm.file_name AS sopName,
  5199. fm.url_add_ress AS sopUrl,
  5200. fm.sop_rev_no AS [version],
  5201. fm.status AS sopStatus,
  5202. fm.phase_in_date AS phaseInDate,
  5203. fm.phase_out_date AS phaseOutDate,
  5204. fm.created_by AS createdBy,
  5205. fm.create_date AS creationDate,
  5206. fm.file_type AS sopType,
  5207. fm.item_no AS operationDesc
  5208. FROM file_management fm
  5209. WHERE fm.site = #{params.site}
  5210. AND fm.file_type = '质量'
  5211. AND (
  5212. ISNULL(fm.public_flag, 'N') = 'Y'
  5213. OR fm.order_no = #{params.orderNo}
  5214. )
  5215. ) AS CombinedResults
  5216. </select>
  5217. <!-- 查询可用的SOP文件 -->
  5218. <select id="sopAvailableFiles" resultType="map">
  5219. SELECT
  5220. A.site,
  5221. A.bu_no as buNo,
  5222. A.file_no as fileNo,
  5223. A.file_name as fileName,
  5224. A.file_type as fileType,
  5225. A.file_suffix as fileSuffix,
  5226. A.sop_rev_no as sopRevNo,
  5227. A.url_add_ress as sopUrl,
  5228. A.sop_type as sopType,
  5229. A.source_system as sourceSystem
  5230. FROM file_management A
  5231. LEFT JOIN part_sop B ON A.SITE = B.SITE AND A.BU_NO = B.BU_NO AND A.FILE_NO = B.sop_no and b.part_no = #{params.partNo}
  5232. <where>
  5233. B.SITE IS NULL
  5234. AND A.status_tb = 0
  5235. and ISNULL(public_flag,'N') = 'N'
  5236. <if test="params.site != null and params.site != ''">
  5237. AND A.site = #{params.site}
  5238. </if>
  5239. <if test="params.fileNo != null and params.fileNo != ''">
  5240. AND A.file_no LIKE '%' + #{params.fileNo} + '%'
  5241. </if>
  5242. <if test="params.fileName != null and params.fileName != ''">
  5243. AND A.file_name LIKE '%' + #{params.fileName} + '%'
  5244. </if>
  5245. <if test="params.fileType != null and params.fileType != ''">
  5246. AND A.file_type LIKE '%' + #{params.fileType} + '%'
  5247. </if>
  5248. <if test="params.sopRevNo != null and params.sopRevNo != ''">
  5249. AND A.sop_rev_no LIKE '%' + #{params.sopRevNo} + '%'
  5250. </if>
  5251. </where>
  5252. ORDER BY A.file_no
  5253. </select>
  5254. <!-- 插入SOP记录 -->
  5255. <insert id="insertSopRecord">
  5256. INSERT INTO part_sop (
  5257. site,
  5258. bu_no,
  5259. part_no,
  5260. sop_no,
  5261. sop_name,
  5262. sop_url,
  5263. sop_type,
  5264. version,
  5265. sop_status,
  5266. phase_in_date,
  5267. phase_out_date,
  5268. created_by,
  5269. creation_date,
  5270. operation_desc
  5271. ) VALUES (
  5272. #{data.site},
  5273. #{data.buNo},
  5274. #{data.partNo},
  5275. #{data.sopNo},
  5276. #{data.sopName},
  5277. #{data.sopUrl},
  5278. #{data.sopType},
  5279. #{data.version},
  5280. #{data.sopStatus},
  5281. <choose>
  5282. <when test="data.phaseInDate != null and data.phaseInDate != ''">
  5283. CONVERT(DATE, #{data.phaseInDate})
  5284. </when>
  5285. <otherwise>
  5286. NULL
  5287. </otherwise>
  5288. </choose>,
  5289. <choose>
  5290. <when test="data.phaseOutDate != null and data.phaseOutDate != ''">
  5291. CONVERT(DATE, #{data.phaseOutDate})
  5292. </when>
  5293. <otherwise>
  5294. NULL
  5295. </otherwise>
  5296. </choose>,
  5297. #{data.createdBy},
  5298. <choose>
  5299. <when test="data.creationDate != null and data.creationDate != ''">
  5300. CONVERT(DATE, #{data.creationDate})
  5301. </when>
  5302. <otherwise>
  5303. GETDATE()
  5304. </otherwise>
  5305. </choose>,
  5306. #{data.operationDesc}
  5307. )
  5308. </insert>
  5309. <!-- 删除SOP记录 -->
  5310. <delete id="deleteSopRecord">
  5311. DELETE FROM part_sop
  5312. <where>
  5313. <if test="params.site != null and params.site != ''">
  5314. AND site = #{params.site}
  5315. </if>
  5316. <if test="params.buNo != null and params.buNo != ''">
  5317. AND bu_no = #{params.buNo}
  5318. </if>
  5319. <if test="params.partNo != null and params.partNo != ''">
  5320. AND part_no = #{params.partNo}
  5321. </if>
  5322. <if test="params.sopNo != null and params.sopNo != ''">
  5323. AND sop_no = #{params.sopNo}
  5324. </if>
  5325. </where>
  5326. </delete>
  5327. <!-- ================================================= BOM清单相关SQL ================================================= -->
  5328. <!-- BOM清单查询 -->
  5329. <select id="bomListSearch" resultType="com.gaotao.modules.pms.data.BomListData">
  5330. SELECT
  5331. bh.site,
  5332. bh.bu_no as buNo,
  5333. bh.revno,
  5334. bh.bomtype,
  5335. bh.status,
  5336. bh.phaseindate,
  5337. bh.phaseoutdate
  5338. FROM BOMHeader bh
  5339. <where>
  5340. <if test="query.site != null and query.site != ''">
  5341. AND bh.site = #{query.site}
  5342. </if>
  5343. <if test="query.buNo != null and query.buNo != ''">
  5344. AND bh.bu_no = #{query.buNo}
  5345. </if>
  5346. <if test="query.partNo != null and query.partNo != ''">
  5347. AND bh.bu_no = #{query.partNo}
  5348. </if>
  5349. </where>
  5350. ORDER BY bh.phaseindate DESC
  5351. </select>
  5352. <!-- ================================================= Routing清单相关SQL ================================================= -->
  5353. <!-- Routing清单查询 -->
  5354. <select id="routingListSearch" resultType="com.gaotao.modules.pms.data.RoutingListData">
  5355. SELECT
  5356. rh.site,
  5357. rh.bu_no as buNo,
  5358. rh.revno,
  5359. rh.routingtype,
  5360. rh.status,
  5361. rh.phaseindate,
  5362. rh.phaseoutdate
  5363. FROM RoutingHeader rh
  5364. <where>
  5365. <if test="query.site != null and query.site != ''">
  5366. AND rh.site = #{query.site}
  5367. </if>
  5368. <if test="query.buNo != null and query.buNo != ''">
  5369. AND rh.bu_no = #{query.buNo}
  5370. </if>
  5371. <if test="query.partNo != null and query.partNo != ''">
  5372. AND rh.bu_no = #{query.partNo}
  5373. </if>
  5374. </where>
  5375. ORDER BY rh.phaseindate DESC
  5376. </select>
  5377. <update id="updateInboundNotificationStatus">
  5378. update inbound_notification_head
  5379. set order_status = #{status}
  5380. <if test="inspectionFlag != null and inspectionFlag != ''">
  5381. , inspection_flag = #{inspectionFlag}
  5382. </if>
  5383. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  5384. </update>
  5385. <!-- 查询过程检验待检验记录数量(只统计首件检和自检类型) -->
  5386. <select id="checkProcessInspectionPendingCount" resultType="int">
  5387. SELECT COUNT(1)
  5388. FROM qc_ipqc_record
  5389. WHERE site = #{site}
  5390. AND order_no = #{orderNo}
  5391. AND state IN ('未开始', '待检验')
  5392. AND seq_no = #{seqNo}
  5393. AND inspection_type_no IN ('首件检', '自检', '末件检')
  5394. </select>
  5395. <select id="queryResourceList3" resultType="com.gaotao.modules.pms.data.ResourceData">
  5396. select DISTINCT ResourceId,ResourceDesc from WorkCenterResource
  5397. </select>
  5398. <update id="updateSaleBoxManageStatus">
  5399. update outbound_notification_head
  5400. set order_status = #{status}
  5401. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  5402. </update>
  5403. <update id="updateSaleBoxManageInspectionFlag">
  5404. update outbound_notification_detail
  5405. set inspection_flag = #{inspectionFlag}
  5406. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  5407. </update>
  5408. <select id="queryEquipmentFolderLocationList"
  5409. resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
  5410. select efl.*,
  5411. dbo.get_bu_desc(efl.site, efl.bu_no) as buDesc
  5412. from Equipment_folder_location efl
  5413. <where>
  5414. <if test="params.site != null and params.site != ''">
  5415. and efl.site = #{params.site}
  5416. </if>
  5417. <if test="params.buNo != null and params.buNo != ''">
  5418. and efl.bu_no = #{params.buNo}
  5419. </if>
  5420. <if test="params.equipmentNo != null and params.equipmentNo != ''">
  5421. and efl.equipment_no like '%'+ #{params.equipmentNo} +'%'
  5422. </if>
  5423. <if test="params.equipmentDesc != null and params.equipmentDesc != ''">
  5424. and efl.equipment_desc like '%'+ #{params.equipmentDesc} +'%'
  5425. </if>
  5426. <if test="params.IP != null and params.IP != ''">
  5427. and efl.IP like '%'+ #{params.IP} +'%'
  5428. </if>
  5429. <if test="params.suffix != null and params.suffix != ''">
  5430. and efl.suffix like '%'+ #{params.suffix} +'%'
  5431. </if>
  5432. </where>
  5433. order by equipment_no
  5434. </select>
  5435. <select id="getEquipmentDatabaseConfigForUser" resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
  5436. SELECT efl.*
  5437. FROM Equipment_folder_location efl WITH (UPDLOCK, HOLDLOCK)
  5438. WHERE efl.id = #{id}
  5439. AND EXISTS (SELECT 1 FROM AccessSite a
  5440. WHERE a.Site = efl.site AND UPPER(a.UserID) = UPPER(#{username}))
  5441. </select>
  5442. <insert id="saveEquipmentFolderLocationList">
  5443. insert into Equipment_folder_location
  5444. (folder_path,equipment_no,site,bu_no,file_no,backup_folder_path,IP,suffix,equipment_desc,backup_photo_path,batch_date,port,register_address,
  5445. register_num,register_num_columntype,register_address_inspection,register_num_inspection,register_num_inspection_columntype,unit_id,
  5446. excel_compare_fields_x,excel_compare_fields_y,initial_line,data_row,data_column,skip_line,cutting_symbol,transparent_flag,Formula_calculation,
  5447. Formula,Group_calculation,regexp,data_storage_mode,serial_no,repair_type,buzzer,equipment_classification,
  5448. db_name,table_name,db_account,db_password,collect_sql)
  5449. values (#{folderPath}, #{equipmentNo}, #{site}, #{buNo}, #{fileNo}, #{backupFolderPath}, #{IP}, #{suffix}, #{equipmentDesc}, #{backupPhotoPath}, #{batchDate}, #{port}, #{registerAddress},
  5450. #{registerNum}, #{registerNumColumntype}, #{registerAddressInspection}, #{registerNumInspection}, #{registerNumInspectionColumntype}, #{unitId},
  5451. #{excelCompareFieldsX}, #{excelCompareFieldsY}, #{initialLine}, #{dataRow}, #{dataColumn}, #{skipLine}, #{cuttingSymbol}, #{transparentFlag}, #{formulaCalculation},
  5452. #{formula}, #{groupCalculation}, #{regexp}, #{dataStorageMode}, #{serialNo}, #{repairType}, #{buzzer}, #{equipmentClassification},
  5453. #{dbName}, #{tableName}, #{dbAccount}, #{dbPassword}, #{collectSql})
  5454. </insert>
  5455. <update id="updateEquipmentFolderLocation">
  5456. UPDATE Equipment_folder_location
  5457. SET
  5458. folder_path = #{folderPath},
  5459. equipment_no = #{equipmentNo},
  5460. bu_no = #{buNo},
  5461. file_no = #{fileNo},
  5462. backup_folder_path = #{backupFolderPath},
  5463. IP = #{IP},
  5464. suffix = #{suffix},
  5465. equipment_desc = #{equipmentDesc},
  5466. backup_photo_path = #{backupPhotoPath},
  5467. batch_date = #{batchDate},
  5468. port = #{port},
  5469. register_address = #{registerAddress},
  5470. register_num = #{registerNum},
  5471. register_num_columntype = #{registerNumColumntype},
  5472. register_address_inspection = #{registerAddressInspection},
  5473. register_num_inspection = #{registerNumInspection},
  5474. register_num_inspection_columntype = #{registerNumInspectionColumntype},
  5475. unit_id = #{unitId},
  5476. excel_compare_fields_x = #{excelCompareFieldsX},
  5477. excel_compare_fields_y = #{excelCompareFieldsY},
  5478. initial_line = #{initialLine},
  5479. data_row = #{dataRow},
  5480. data_column = #{dataColumn},
  5481. skip_line = #{skipLine},
  5482. cutting_symbol = #{cuttingSymbol},
  5483. transparent_flag = #{transparentFlag},
  5484. Formula_calculation = #{formulaCalculation},
  5485. Formula = #{formula},
  5486. Group_calculation = #{groupCalculation},
  5487. regexp = #{regexp},
  5488. data_storage_mode = #{dataStorageMode},
  5489. serial_no = #{serialNo},
  5490. repair_type = #{repairType},
  5491. buzzer = #{buzzer},
  5492. equipment_classification = #{equipmentClassification},
  5493. db_name = #{dbName},
  5494. table_name = #{tableName},
  5495. db_account = #{dbAccount},
  5496. <if test="dbPassword != null">
  5497. db_password = #{dbPassword},
  5498. </if>
  5499. collect_sql = #{collectSql},
  5500. update_by = #{updateBy},
  5501. update_time = getDate()
  5502. WHERE id = #{id}
  5503. </update>
  5504. <delete id="deleteEquipmentFolderLocationList">
  5505. delete from Equipment_folder_location
  5506. where id = #{id}
  5507. </delete>
  5508. <select id="checkEquipmentFolderLocation" resultType="java.lang.Integer">
  5509. select count(1)
  5510. from Equipment_folder_location
  5511. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  5512. </select>
  5513. <select id="getSuffixList" resultType="java.lang.String">
  5514. select distinct suffix from Equipment_folder_location
  5515. </select>
  5516. <!-- 获取检验单物料编码 -->
  5517. <select id="getInspectionCollectContext" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData"
  5518. resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5519. SELECT part_no AS partNo, inspection_no AS inspectionNo
  5520. <choose>
  5521. <when test="flag == 'ipqc'">
  5522. , order_no AS orderNo, roll_no AS rollNo
  5523. FROM qc_ipqc_record
  5524. </when>
  5525. <when test="flag == 'sqc'">
  5526. , order_no AS orderNo, roll_no AS rollNo
  5527. FROM qc_sqc_record
  5528. </when>
  5529. <when test="flag == 'fqc'">
  5530. , order_no AS orderNo, roll_no AS rollNo
  5531. FROM qc_fqc_record
  5532. </when>
  5533. <when test="flag == 'fai'">
  5534. , order_no AS orderNo, roll_no AS rollNo
  5535. FROM qc_fai_record
  5536. </when>
  5537. <when test="flag == 'fqas' or flag == 'oqc'">
  5538. , po_orderNo AS orderNo, roll_no AS rollNo
  5539. FROM qc_oqc_record
  5540. </when>
  5541. <otherwise>
  5542. , po_orderNo AS poOrderNo, roll_no AS rollNo
  5543. FROM qc_iqc_record
  5544. </otherwise>
  5545. </choose>
  5546. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5547. </select>
  5548. <select id="getInspectionPartNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5549. select part_no from
  5550. <choose>
  5551. <when test="flag == 'ipqc'">qc_ipqc_record</when>
  5552. <when test="flag == 'sqc'">qc_sqc_record</when>
  5553. <when test="flag == 'fqc'">qc_fqc_record</when>
  5554. <when test="flag == 'fai'">qc_fai_record</when>
  5555. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
  5556. <otherwise>qc_iqc_record</otherwise>
  5557. </choose>
  5558. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5559. </select>
  5560. <!-- 获取检验单工序(仅 IPQC/FQC/OQC 主表维护 operation_desc) -->
  5561. <select id="getInspectionOperationDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5562. <choose>
  5563. <when test="flag == 'ipqc'">
  5564. select operation_desc from qc_ipqc_record
  5565. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5566. </when>
  5567. <when test="flag == 'fqc'">
  5568. select operation_desc from qc_fqc_record
  5569. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5570. </when>
  5571. <when test="flag == 'fqas' or flag == 'oqc'">
  5572. select operation_desc from qc_oqc_record
  5573. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5574. </when>
  5575. <otherwise>
  5576. select null
  5577. </otherwise>
  5578. </choose>
  5579. </select>
  5580. <!-- 获取检验单检验类型 -->
  5581. <select id="getInspectionTypeNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5582. select inspection_type_no from
  5583. <choose>
  5584. <when test="flag == 'ipqc'">qc_ipqc_record</when>
  5585. <when test="flag == 'sqc'">qc_sqc_record</when>
  5586. <when test="flag == 'fqc'">qc_fqc_record</when>
  5587. <when test="flag == 'fai'">qc_fai_record</when>
  5588. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
  5589. <otherwise>qc_iqc_record</otherwise>
  5590. </choose>
  5591. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5592. </select>
  5593. <!-- 获取检验单全部子明细实测值 -->
  5594. <select id="listInspectionSubDetailValues" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  5595. select
  5596. item_no as itemNo,
  5597. sub_detail_value as subDetailValue,
  5598. sub_detail_value_b as subDetailValueB,
  5599. sub_detail_value_c as subDetailValueC,
  5600. sub_detail_value_d as subDetailValueD,
  5601. sub_detail_value_e as subDetailValueE,
  5602. sampling_location as samplingLocation,
  5603. sampling_location_b as samplingLocationB,
  5604. num,
  5605. file_name as fileName,
  5606. is_transfer as isTransfer,
  5607. is_qualified as isQualified,
  5608. defect_qty as defectQty,
  5609. roll_no as rollNo
  5610. from
  5611. <choose>
  5612. <when test="flag == 'ipqc'">qc_ipqc_sub_detail_record</when>
  5613. <when test="flag == 'sqc'">qc_sqc_sub_detail_record</when>
  5614. <when test="flag == 'fqc'">qc_fqc_sub_detail_record</when>
  5615. <when test="flag == 'fai'">qc_fai_sub_detail_record</when>
  5616. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_sub_detail_record</when>
  5617. <otherwise>qc_iqc_sub_detail_record</otherwise>
  5618. </choose>
  5619. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5620. order by item_no, num
  5621. </select>
  5622. <!-- 获取检验单明细项目编码 -->
  5623. <select id="listInspectionItemNos" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5624. select item_no from
  5625. <choose>
  5626. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  5627. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  5628. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  5629. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  5630. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  5631. <otherwise>qc_iqc_detailed_record</otherwise>
  5632. </choose>
  5633. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5634. </select>
  5635. <!-- 获取检验单明细行实测值(含规格,用于复制与合格判定) -->
  5636. <select id="listInspectionDetailMeasuredValues" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5637. select
  5638. item_no as itemNo,
  5639. number_value as numberValue,
  5640. text_value as textValue,
  5641. value_type_db as valueTypeDb,
  5642. min_value as minValue,
  5643. max_value as maxValue,
  5644. item_result as itemResult,
  5645. unqualified_quantity as unqualifiedQuantity
  5646. from
  5647. <choose>
  5648. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  5649. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  5650. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  5651. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  5652. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  5653. <otherwise>qc_iqc_detailed_record</otherwise>
  5654. </choose>
  5655. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5656. </select>
  5657. <!-- 更新明细行实测值(数值/文本) -->
  5658. <update id="updateInspectionDetailMeasuredValue" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5659. update
  5660. <choose>
  5661. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  5662. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  5663. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  5664. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  5665. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  5666. <otherwise>qc_iqc_detailed_record</otherwise>
  5667. </choose>
  5668. set
  5669. number_value = #{numberValue,jdbcType=DECIMAL},
  5670. text_value = #{textValue}
  5671. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  5672. </update>
  5673. <!-- 查询检验单提交标识 -->
  5674. <select id="getInspectionSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5675. select submit_flag from
  5676. <choose>
  5677. <when test="flag == 'ipqc'">qc_ipqc_record</when>
  5678. <when test="flag == 'sqc'">qc_sqc_record</when>
  5679. <when test="flag == 'fqc'">qc_fqc_record</when>
  5680. <when test="flag == 'fai'">qc_fai_record</when>
  5681. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
  5682. <otherwise>qc_iqc_record</otherwise>
  5683. </choose>
  5684. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5685. </select>
  5686. <!-- 按物料+设备查询文件列映射 -->
  5687. <select id="listPartFileCollectByPartAndEquipment" resultType="com.gaotao.modules.pms.data.QcPartFileCollectData">
  5688. SELECT
  5689. file_column_no AS fileColumnNo,
  5690. item_no AS itemNo,
  5691. item_desc AS itemDesc,
  5692. operation
  5693. FROM qc_part_file_collect
  5694. WHERE site = #{site}
  5695. AND bu_no = #{buNo}
  5696. AND part_no = #{partNo}
  5697. AND equipment_no = #{equipmentNo}
  5698. ORDER BY file_column_no, id
  5699. </select>
  5700. <!-- 按物料查询已配置的设备编码 -->
  5701. <select id="listEquipmentNoByPartFileCollect" resultType="java.lang.String">
  5702. SELECT DISTINCT equipment_no
  5703. FROM qc_part_file_collect
  5704. WHERE site = #{site}
  5705. AND bu_no = #{buNo}
  5706. AND part_no = #{partNo}
  5707. AND equipment_no IS NOT NULL
  5708. AND equipment_no <![CDATA[<>]]> ''
  5709. ORDER BY equipment_no
  5710. </select>
  5711. <!-- 获取项目默认关联设备(优先 default_flag=Y) -->
  5712. <select id="getDefaultItemObjectId" resultType="java.lang.String">
  5713. SELECT TOP 1 ObjectID
  5714. FROM qc_item_object
  5715. WHERE site = #{site}
  5716. AND bu_no = #{buNo}
  5717. AND ItemNo = #{itemNo}
  5718. ORDER BY CASE WHEN default_flag = 'Y' THEN 0 ELSE 1 END, ObjectID
  5719. </select>
  5720. <!-- 校验项目是否关联指定设备 -->
  5721. <select id="countItemObject" resultType="int">
  5722. SELECT COUNT(1)
  5723. FROM qc_item_object
  5724. WHERE site = #{site}
  5725. AND bu_no = #{buNo}
  5726. AND ItemNo = #{itemNo}
  5727. AND ObjectID = #{objectId}
  5728. </select>
  5729. <!-- 按设备编码查询文件夹配置 -->
  5730. <select id="getEquipmentFolderLocationByEquipmentNo"
  5731. resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
  5732. SELECT TOP 1
  5733. equipment_no AS equipmentNo,
  5734. equipment_desc AS equipmentDesc,
  5735. data_storage_mode AS dataStorageMode,
  5736. suffix, IP, port,
  5737. db_name AS dbName,
  5738. table_name AS tableName,
  5739. db_account AS dbAccount,
  5740. db_password AS dbPassword,
  5741. collect_sql AS collectSql
  5742. FROM Equipment_folder_location
  5743. WHERE site = #{site}
  5744. AND bu_no = #{buNo}
  5745. AND equipment_no = #{equipmentNo}
  5746. </select>
  5747. <!-- 查询项目采集配置 -->
  5748. <select id="getItemCollectionConfig" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  5749. SELECT
  5750. ItemNo AS itemNo,
  5751. ItemDesc AS itemDesc,
  5752. collection_source AS collectionSource,
  5753. collection_method AS collectionMethod,
  5754. collection_data_content AS collectionDataContent
  5755. FROM eam_properties_item
  5756. WHERE site = #{site}
  5757. AND bu_no = #{buNo}
  5758. AND ItemNo = #{itemNo}
  5759. </select>
  5760. <!-- 查询设备最新批次解析数据(含列号元数据) -->
  5761. <select id="listLatestEquipmentDataDetail" resultType="com.gaotao.modules.reader.entity.EquipmentDataDetail">
  5762. SELECT
  5763. id,
  5764. site,
  5765. bu_no AS buNo,
  5766. equipment_no AS equipmentNo,
  5767. value0,
  5768. source_column_no AS sourceColumnNo,
  5769. num,
  5770. serial_no AS serialNo,
  5771. batch_no AS batchNo,
  5772. file_name AS fileName
  5773. FROM Equipment_data_detail
  5774. WHERE site = #{site}
  5775. AND bu_no = #{buNo}
  5776. AND equipment_no = #{equipmentNo}
  5777. AND batch_no = (
  5778. SELECT MAX(batch_no)
  5779. FROM Equipment_data_detail
  5780. WHERE site = #{site} AND bu_no = #{buNo} AND equipment_no = #{equipmentNo}
  5781. )
  5782. AND source_column_no IS NOT NULL
  5783. AND source_column_no != -1
  5784. ORDER BY source_column_no, num
  5785. </select>
  5786. <!-- 按列号查询设备最新批次解析数据;collectionDataContent 非空时作为 value0 的 SQL 过滤条件 -->
  5787. <select id="listLatestEquipmentDataDetailByColumn" resultType="com.gaotao.modules.reader.entity.EquipmentDataDetail">
  5788. SELECT
  5789. id,
  5790. site,
  5791. bu_no AS buNo,
  5792. equipment_no AS equipmentNo,
  5793. value0,
  5794. source_column_no AS sourceColumnNo,
  5795. num,
  5796. serial_no AS serialNo,
  5797. batch_no AS batchNo,
  5798. file_name AS fileName
  5799. FROM Equipment_data_detail
  5800. WHERE site = #{site}
  5801. AND bu_no = #{buNo}
  5802. AND equipment_no = #{equipmentNo}
  5803. <choose>
  5804. <when test="matchBySerialNo == true">
  5805. AND LTRIM(RTRIM(CONVERT(VARCHAR(50), serial_no))) = CONVERT(VARCHAR(50), #{fileColumnNo})
  5806. </when>
  5807. <otherwise>
  5808. AND source_column_no = #{fileColumnNo}
  5809. </otherwise>
  5810. </choose>
  5811. AND batch_no = (
  5812. SELECT MAX(batch_no)
  5813. FROM Equipment_data_detail
  5814. WHERE site = #{site} AND bu_no = #{buNo} AND equipment_no = #{equipmentNo}
  5815. )
  5816. <if test="collectionDataContent != null and collectionDataContent != ''">
  5817. AND value0 ${collectionDataContent}
  5818. </if>
  5819. ORDER BY num
  5820. </select>
  5821. <!-- 数据采集后更新明细不合格数量与项目检验结果 -->
  5822. <update id="updateIQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5823. UPDATE qc_iqc_detailed_record
  5824. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5825. item_result = #{itemResult}
  5826. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5827. </update>
  5828. <update id="refreshIQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5829. UPDATE qc_iqc_record
  5830. SET unqualified_qty = (
  5831. SELECT COUNT(*) FROM qc_iqc_detailed_record
  5832. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5833. )
  5834. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5835. </update>
  5836. <update id="updateIPQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5837. UPDATE qc_ipqc_detailed_record
  5838. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5839. item_result = #{itemResult}
  5840. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5841. </update>
  5842. <update id="refreshIPQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5843. UPDATE qc_ipqc_record
  5844. SET unqualified_qty = (
  5845. SELECT COUNT(*) FROM qc_ipqc_detailed_record
  5846. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5847. )
  5848. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5849. </update>
  5850. <update id="updateSQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5851. UPDATE qc_sqc_detailed_record
  5852. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5853. item_result = #{itemResult}
  5854. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5855. </update>
  5856. <update id="refreshSQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5857. UPDATE qc_sqc_record
  5858. SET unqualified_qty = (
  5859. SELECT COUNT(*) FROM qc_sqc_detailed_record
  5860. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5861. )
  5862. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5863. </update>
  5864. <update id="updateFQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5865. UPDATE qc_fqc_detailed_record
  5866. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5867. item_result = #{itemResult}
  5868. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5869. </update>
  5870. <update id="refreshFQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5871. UPDATE qc_fqc_record
  5872. SET unqualified_qty = (
  5873. SELECT COUNT(*) FROM qc_fqc_detailed_record
  5874. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5875. )
  5876. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5877. </update>
  5878. <update id="updateFQASDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5879. UPDATE qc_oqc_detailed_record
  5880. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5881. item_result = #{itemResult}
  5882. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5883. </update>
  5884. <update id="refreshFQASMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5885. UPDATE qc_oqc_record
  5886. SET unqualified_qty = (
  5887. SELECT COUNT(*) FROM qc_oqc_detailed_record
  5888. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5889. )
  5890. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5891. </update>
  5892. <select id="getLatestEquipmentDetailBatchNo" resultType="java.lang.Integer">
  5893. SELECT MAX(batch_no)
  5894. FROM Equipment_data_detail
  5895. WHERE site = #{site}
  5896. AND bu_no = #{buNo}
  5897. AND equipment_no = #{equipmentNo}
  5898. </select>
  5899. <update id="updateEquipmentDataAcquisitionBatchNo">
  5900. UPDATE Equipment_data_acquisition
  5901. SET batch_no = #{batchNo}
  5902. WHERE site = #{site}
  5903. AND bu_no = #{buNo}
  5904. AND inspection_no = #{inspectionNo}
  5905. AND equipment_no = #{equipmentNo}
  5906. </update>
  5907. <update id="updateEquipmentDataAcquisitionCollectMode">
  5908. UPDATE Equipment_data_acquisition
  5909. SET accumulate_collect = #{accumulateCollect},
  5910. delete_after_collect = #{deleteAfterCollect}
  5911. WHERE site = #{site}
  5912. AND bu_no = #{buNo}
  5913. AND inspection_no = #{inspectionNo}
  5914. AND equipment_no = #{equipmentNo}
  5915. </update>
  5916. <!-- 累计采集时用于续号 -->
  5917. <select id="getSubDetailMaxNum" resultType="java.lang.Integer">
  5918. SELECT ISNULL(MAX(num), 0)
  5919. FROM
  5920. <choose>
  5921. <when test="flag == 'ipqc'">qc_ipqc_sub_detail_record</when>
  5922. <when test="flag == 'sqc'">qc_sqc_sub_detail_record</when>
  5923. <when test="flag == 'fqc'">qc_fqc_sub_detail_record</when>
  5924. <when test="flag == 'fai'">qc_fai_sub_detail_record</when>
  5925. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_sub_detail_record</when>
  5926. <otherwise>qc_iqc_sub_detail_record</otherwise>
  5927. </choose>
  5928. WHERE site = #{site}
  5929. AND bu_no = #{buNo}
  5930. AND inspection_no = #{inspectionNo}
  5931. AND item_no = #{itemNo}
  5932. </select>
  5933. <!-- 检验单弹框:最近设备解析时间 -->
  5934. <select id="getLatestEquipmentParseTime" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5935. SELECT TOP 1
  5936. N'最近解析时间:' + a.equipment_no + N' - ' + ISNULL(b.equipment_desc, N'') + N' - '
  5937. + CONVERT(varchar(19), c.create_date, 120)
  5938. FROM Equipment_data_acquisition A
  5939. INNER JOIN Equipment_folder_location B
  5940. ON A.site = B.site AND A.bu_no = B.bu_no AND A.equipment_no = B.equipment_no
  5941. INNER JOIN Equipment_folder_sort C
  5942. ON B.site = C.site AND B.bu_no = C.bu_no AND B.file_no = C.file_no
  5943. WHERE A.site = #{site}
  5944. AND A.bu_no = #{buNo}
  5945. AND A.inspection_no = #{inspectionNo}
  5946. ORDER BY C.create_date DESC
  5947. </select>
  5948. <!-- 同步 EDS 成功后,将子明细是否传输更新为 Y -->
  5949. <update id="updateSubDetailTransferToY">
  5950. UPDATE
  5951. <choose>
  5952. <when test="inspectionType == 'IQC'">qc_iqc_sub_detail_record</when>
  5953. <when test="inspectionType == 'IPQC'">qc_ipqc_sub_detail_record</when>
  5954. <when test="inspectionType == 'FQC'">qc_fqc_sub_detail_record</when>
  5955. <when test="inspectionType == 'OQC'">qc_oqc_sub_detail_record</when>
  5956. <when test="inspectionType == 'SQC'">qc_sqc_sub_detail_record</when>
  5957. <otherwise>qc_iqc_sub_detail_record</otherwise>
  5958. </choose>
  5959. SET is_transfer = 'Y'
  5960. WHERE inspection_no = #{inspectionNo}
  5961. AND item_no = #{itemNo}
  5962. AND site = #{site}
  5963. AND bu_no = #{buNo}
  5964. AND (is_transfer IS NULL OR is_transfer &lt;&gt; 'Y')
  5965. AND num IN
  5966. <foreach collection="numList" item="num" open="(" separator="," close=")">
  5967. #{num}
  5968. </foreach>
  5969. </update>
  5970. <!-- 同步 EDS:按检验单查询全部子明细(跨检验项目),用于按标签号汇总 -->
  5971. <select id="selectSubDetailedRecordForEds" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  5972. SELECT
  5973. item_no,
  5974. site,
  5975. bu_no,
  5976. sub_detail_value,
  5977. sampling_location,
  5978. is_submit,
  5979. sampling_location_b,
  5980. num,
  5981. sub_detail_value_b,
  5982. sub_detail_value_c,
  5983. sub_detail_value_d,
  5984. sub_detail_value_e,
  5985. file_name,
  5986. is_transfer,
  5987. is_qualified,
  5988. defect_qty,
  5989. roll_no,
  5990. product_quantity as productQuantity,
  5991. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  5992. FROM
  5993. <choose>
  5994. <when test="inspectionType == 'IQC'">qc_iqc_sub_detail_record</when>
  5995. <when test="inspectionType == 'IPQC'">qc_ipqc_sub_detail_record</when>
  5996. <when test="inspectionType == 'FQC'">qc_fqc_sub_detail_record</when>
  5997. <when test="inspectionType == 'OQC'">qc_oqc_sub_detail_record</when>
  5998. <when test="inspectionType == 'SQC'">qc_sqc_sub_detail_record</when>
  5999. <otherwise>qc_iqc_sub_detail_record</otherwise>
  6000. </choose>
  6001. WHERE inspection_no = #{inspectionNo}
  6002. AND site = #{site}
  6003. AND bu_no = #{buNo}
  6004. ORDER BY item_no, num
  6005. </select>
  6006. <!-- 同步 EDS 成功后按标签号批量更新是否传输为 Y(整单跨项目) -->
  6007. <update id="updateSubDetailTransferToYByRollNos">
  6008. UPDATE
  6009. <choose>
  6010. <when test="inspectionType == 'IQC'">qc_iqc_sub_detail_record</when>
  6011. <when test="inspectionType == 'IPQC'">qc_ipqc_sub_detail_record</when>
  6012. <when test="inspectionType == 'FQC'">qc_fqc_sub_detail_record</when>
  6013. <when test="inspectionType == 'OQC'">qc_oqc_sub_detail_record</when>
  6014. <when test="inspectionType == 'SQC'">qc_sqc_sub_detail_record</when>
  6015. <otherwise>qc_iqc_sub_detail_record</otherwise>
  6016. </choose>
  6017. SET is_transfer = 'Y'
  6018. WHERE inspection_no = #{inspectionNo}
  6019. AND site = #{site}
  6020. AND bu_no = #{buNo}
  6021. AND (is_transfer IS NULL OR is_transfer &lt;&gt; 'Y')
  6022. AND roll_no IN
  6023. <foreach collection="rollNoList" item="rollNo" open="(" separator="," close=")">
  6024. #{rollNo}
  6025. </foreach>
  6026. </update>
  6027. <!-- EDS 批量录入:按行更新,IPQC/FQC/OQC 变更行重置传输标记 -->
  6028. <update id="updateSubDetailRowForEds">
  6029. UPDATE
  6030. <choose>
  6031. <when test="inspectionType == 'IQC'">qc_iqc_sub_detail_record</when>
  6032. <when test="inspectionType == 'IPQC'">qc_ipqc_sub_detail_record</when>
  6033. <when test="inspectionType == 'FQC'">qc_fqc_sub_detail_record</when>
  6034. <when test="inspectionType == 'OQC'">qc_oqc_sub_detail_record</when>
  6035. <when test="inspectionType == 'SQC'">qc_sqc_sub_detail_record</when>
  6036. <otherwise>qc_iqc_sub_detail_record</otherwise>
  6037. </choose>
  6038. SET
  6039. sub_detail_value = #{row.subDetailValue},
  6040. sub_detail_value_b = #{row.subDetailValueB},
  6041. sub_detail_value_c = #{row.subDetailValueC},
  6042. sub_detail_value_d = #{row.subDetailValueD},
  6043. sub_detail_value_e = #{row.subDetailValueE},
  6044. sampling_location = #{row.samplingLocation},
  6045. sampling_location_b = #{row.samplingLocationB},
  6046. roll_no = #{row.rollNo},
  6047. product_quantity = #{row.productQuantity,jdbcType=DECIMAL},
  6048. is_qualified = #{row.isQualified},
  6049. <if test="inspectionType == 'IPQC' or inspectionType == 'FQC' or inspectionType == 'OQC'">
  6050. is_transfer = 'N',
  6051. </if>
  6052. defect_qty = #{row.defectQty}
  6053. WHERE inspection_no = #{row.inspectionNo}
  6054. AND site = #{row.site}
  6055. AND bu_no = #{row.buNo}
  6056. AND item_no = #{row.itemNo}
  6057. AND num = #{row.num}
  6058. </update>
  6059. <!-- EDS 批量录入:按 itemNo+num 批量删除(已传输行不允许删) -->
  6060. <delete id="deleteSubDetailRowsForEds">
  6061. DELETE FROM
  6062. <choose>
  6063. <when test="inspectionType == 'IQC'">qc_iqc_sub_detail_record</when>
  6064. <when test="inspectionType == 'IPQC'">qc_ipqc_sub_detail_record</when>
  6065. <when test="inspectionType == 'FQC'">qc_fqc_sub_detail_record</when>
  6066. <when test="inspectionType == 'OQC'">qc_oqc_sub_detail_record</when>
  6067. <when test="inspectionType == 'SQC'">qc_sqc_sub_detail_record</when>
  6068. <otherwise>qc_iqc_sub_detail_record</otherwise>
  6069. </choose>
  6070. WHERE inspection_no = #{inspectionNo}
  6071. AND site = #{site}
  6072. AND bu_no = #{buNo}
  6073. AND (is_transfer IS NULL OR is_transfer &lt;&gt; 'Y')
  6074. AND
  6075. <foreach collection="rows" item="row" open="(" separator=" OR " close=")">
  6076. (item_no = #{row.itemNo} AND num = #{row.num})
  6077. </foreach>
  6078. </delete>
  6079. <!-- 各标签号最新一次 EDS 传输结论 -->
  6080. <select id="selectLatestEdsTransferHistory"
  6081. resultType="com.gaotao.modules.pms.entity.QcEdsTransferHistoryEntity">
  6082. SELECT h.site,
  6083. h.bu_no AS buNo,
  6084. h.inspection_no AS inspectionNo,
  6085. h.inspection_type AS inspectionType,
  6086. h.roll_no AS rollNo,
  6087. h.result,
  6088. h.create_by AS createBy,
  6089. h.create_date AS createDate
  6090. FROM qc_eds_transfer_history h
  6091. INNER JOIN (
  6092. SELECT site, bu_no, inspection_no, inspection_type, roll_no, MAX(id) AS max_id
  6093. FROM qc_eds_transfer_history
  6094. WHERE site = #{site}
  6095. AND bu_no = #{buNo}
  6096. AND inspection_no = #{inspectionNo}
  6097. AND inspection_type = #{inspectionType}
  6098. GROUP BY site, bu_no, inspection_no, inspection_type, roll_no
  6099. ) t ON h.id = t.max_id
  6100. </select>
  6101. <insert id="insertEdsTransferHistoryBatch">
  6102. INSERT INTO qc_eds_transfer_history
  6103. (site, bu_no, inspection_no, inspection_type, roll_no, result, create_by, create_date)
  6104. VALUES
  6105. <foreach collection="list" item="item" separator=",">
  6106. (#{item.site}, #{item.buNo}, #{item.inspectionNo}, #{item.inspectionType},
  6107. #{item.rollNo}, #{item.result}, #{item.createBy}, #{item.createDate})
  6108. </foreach>
  6109. </insert>
  6110. <!-- EDS 批量保存仅更新三类检验主表的数量,不改结论和状态 -->
  6111. <update id="updateEdsMasterQuantities">
  6112. UPDATE
  6113. <choose>
  6114. <when test="inspectionType == 'IPQC'">qc_ipqc_record</when>
  6115. <when test="inspectionType == 'FQC'">qc_fqc_record</when>
  6116. <otherwise>qc_oqc_record</otherwise>
  6117. </choose>
  6118. SET
  6119. <choose>
  6120. <when test="inspectionType == 'OQC'">roll_count = #{row.rollCount,jdbcType=DECIMAL},</when>
  6121. <otherwise>roll_qty = #{row.rollQty,jdbcType=DECIMAL},</otherwise>
  6122. </choose>
  6123. sampling_qty = #{row.samplingQty,jdbcType=DECIMAL},
  6124. pass_qty = #{row.passQty,jdbcType=DECIMAL},
  6125. not_pass_qty = #{row.notPassQty,jdbcType=DECIMAL}
  6126. WHERE site = #{row.site} AND bu_no = #{row.buNo} AND inspection_no = #{row.inspectionNo}
  6127. AND UPPER(LTRIM(RTRIM(upper_system_flag))) = 'EDS'
  6128. </update>
  6129. </mapper>