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.

5964 lines
260 KiB

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