20250528代码上传

main
李冬阳 3 weeks ago
parent b8ff8ccdff
commit 8e30a0480d

@ -1,58 +1,351 @@
2023-06-13 14:36:09,530 ERROR KExceptionHandler:26 - 异常请求URL:http://localhost:8082/plm/getDesign 2024-06-17 17:57:45,716 ERROR SpringApplication:823 - Application run failed
2023-06-13 14:36:09,537 ERROR KExceptionHandler:30 - BAD_REQUEST_BODY: java.lang.IllegalStateException: Failed to introspect Class [com.connor.web.controller.MyRestController] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993]
2023-06-13 14:36:09,538 ERROR KExceptionHandler:39 - 发生异常: at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:725)
at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:200) at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:710)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:419) at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:365) at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:137)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:65) at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:130)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:401) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1232) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1015) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at com.connor.web.util.RequestWrapperFilter.doFilterInternal(RequestWrapperFilter.java:17) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) Caused by: java.lang.NoClassDefFoundError: com/teamcenter/soa/client/model/strong/WorkspaceObject
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at java.lang.Class.getDeclaredFields0(Native Method)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ... 42 more
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) Caused by: java.lang.ClassNotFoundException: com.teamcenter.soa.client.model.strong.WorkspaceObject
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ... 46 more
at java.lang.Thread.run(Thread.java:748) 2024-06-17 17:57:45,736 ERROR TestContextManager:250 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@b30a50d] to prepare test instance [com.connor.web.controller.HelloControllerTest@764a3e5d]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.connor.web.controller.MyRestController] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:725)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:710)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:137)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:130)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 27 more
Caused by: java.lang.NoClassDefFoundError: com/teamcenter/soa/client/model/strong/WorkspaceObject
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
... 42 more
Caused by: java.lang.ClassNotFoundException: com.teamcenter.soa.client.model.strong.WorkspaceObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 more
2024-06-17 17:57:46,718 ERROR SpringApplication:823 - Application run failed
java.lang.IllegalStateException: Failed to introspect Class [com.connor.web.controller.MyRestController] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:725)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:710)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:137)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:130)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.NoClassDefFoundError: com/teamcenter/soa/client/model/strong/WorkspaceObject
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
... 42 more
Caused by: java.lang.ClassNotFoundException: com.teamcenter.soa.client.model.strong.WorkspaceObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 more
2024-06-17 17:57:46,719 ERROR TestContextManager:250 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@b30a50d] to prepare test instance [com.connor.web.controller.HelloControllerTest@2b82018]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.connor.web.controller.MyRestController] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:725)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:710)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:137)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:130)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 27 more
Caused by: java.lang.NoClassDefFoundError: com/teamcenter/soa/client/model/strong/WorkspaceObject
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
... 42 more
Caused by: java.lang.ClassNotFoundException: com.teamcenter.soa.client.model.strong.WorkspaceObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 more
2024-06-17 17:57:47,675 ERROR SpringApplication:823 - Application run failed
java.lang.IllegalStateException: Failed to introspect Class [com.connor.web.controller.MyRestController] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:725)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:710)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:137)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:130)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.NoClassDefFoundError: com/teamcenter/soa/client/model/strong/WorkspaceObject
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
... 42 more
Caused by: java.lang.ClassNotFoundException: com.teamcenter.soa.client.model.strong.WorkspaceObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 more
2024-06-17 17:57:47,676 ERROR TestContextManager:250 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@6527aa0] to prepare test instance [com.connor.web.DemoKApplicationTests@6153aca1]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.connor.web.controller.MyRestController] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:725)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:710)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:137)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:130)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 27 more
Caused by: java.lang.NoClassDefFoundError: com/teamcenter/soa/client/model/strong/WorkspaceObject
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
... 42 more
Caused by: java.lang.ClassNotFoundException: com.teamcenter.soa.client.model.strong.WorkspaceObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 more

@ -0,0 +1,58 @@
2023-06-13 14:36:09,530 ERROR KExceptionHandler:26 - 异常请求URL:http://localhost:8082/plm/getDesign
2023-06-13 14:36:09,537 ERROR KExceptionHandler:30 - BAD_REQUEST_BODY:
2023-06-13 14:36:09,538 ERROR KExceptionHandler:39 - 发生异常:
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:200)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:419)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:365)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:65)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:401)
at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1232)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1015)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:665)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.connor.web.util.RequestWrapperFilter.doFilterInternal(RequestWrapperFilter.java:17)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

@ -117,6 +117,8 @@
<version>1.6.3</version> <version>1.6.3</version>
</dependency>--> </dependency>-->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
@ -138,6 +140,11 @@
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>
<version>3.1</version> <version>3.1</version>
</dependency> </dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.10.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.jacorb</groupId> <groupId>org.jacorb</groupId>
<artifactId>jacorb</artifactId> <artifactId>jacorb</artifactId>
@ -159,6 +166,11 @@
<artifactId>commons-net</artifactId> <artifactId>commons-net</artifactId>
<version>1.4.1</version> <version>1.4.1</version>
</dependency> </dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
</dependencies> </dependencies>
@ -168,7 +180,27 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins> </plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build> </build>

@ -48,5 +48,5 @@ Class-Path: stax2-api-3.1.4.jar spring-jdbc-5.1.9.RELEASE.jar cxf-rt-bin
ore-2.9.9.jar cxf-rt-ws-policy-3.1.6.jar spring-boot-starter-web-2.1.8. ore-2.9.9.jar cxf-rt-ws-policy-3.1.6.jar spring-boot-starter-web-2.1.8.
RELEASE.jar TcSoaClassificationStrong_11000.2.0.jar TcSoaClassification RELEASE.jar TcSoaClassificationStrong_11000.2.0.jar TcSoaClassification
Types_11000.2.0.jar fastjson2-2.0.15.jar okhttp-2.7.4.jar okio-1.13.0.j Types_11000.2.0.jar fastjson2-2.0.15.jar okhttp-2.7.4.jar okio-1.13.0.j
ar TcSoaCadStrong_11000.2.0.jar TcSoaCadTypes_11000.2.0.jar ar TcSoaCadStrong_11000.2.0.jar TcSoaCadTypes_11000.2.0.jar commons-io-2.11.0.jar

@ -1,5 +1,6 @@
package com; package com;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
@ -11,6 +12,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement @EnableTransactionManagement
@ServletComponentScan @ServletComponentScan
@SpringBootApplication @SpringBootApplication
@MapperScan("com.connor.web.mapper")
public class DemoKApplication extends SpringBootServletInitializer { public class DemoKApplication extends SpringBootServletInitializer {
// public static String Group_FolderName; // public static String Group_FolderName;

@ -0,0 +1,20 @@
package com.connor.web.bean;
import java.util.List;
public class CoreBatchBean {
private List<CoreBean> requests;
public List<CoreBean> getRequests() {
return requests;
}
public void setRequests(List<CoreBean> requests) {
this.requests = requests;
}
public String toString(){
return "{\"requests\":" + requests + "}";
}
}

@ -20,4 +20,8 @@ public class CoreBean {
public void setWbsno(String wbsno) { public void setWbsno(String wbsno) {
this.wbsno = wbsno; this.wbsno = wbsno;
} }
public String toString(){
return "{\"wbsno\":\"" + wbsno + "\",\"productno\":\"" + productno + "\"}";
}
} }

@ -5,13 +5,15 @@ public class CoreBeanReturn {
private String productno; private String productno;
private String wbsno; private String wbsno;
private String weight; private String weight;
private String code; //private String code;
private String length;
public CoreBeanReturn(String productno, String wbsno, String weight, String code) { public CoreBeanReturn(String productno, String wbsno, String weight, String code, String length) {
this.productno = productno; this.productno = productno;
this.wbsno = wbsno; this.wbsno = wbsno;
this.weight = weight; this.weight = weight;
this.code = code; //this.code = code;
this.length = length;
} }
public String getProductno() { public String getProductno() {
@ -26,13 +28,13 @@ public class CoreBeanReturn {
this.weight = weight; this.weight = weight;
} }
public String getCode() { /*public String getCode() {
return code; return code;
} }
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }*/
public void setProductno(String productno) { public void setProductno(String productno) {
this.productno = productno; this.productno = productno;
@ -45,4 +47,12 @@ public class CoreBeanReturn {
public void setWbsno(String wbsno) { public void setWbsno(String wbsno) {
this.wbsno = wbsno; this.wbsno = wbsno;
} }
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
} }

@ -0,0 +1,36 @@
package com.connor.web.bean;
public class ECNBean {
private String creationdatebefore;//创建时间早于
private String factory;//所属组织
private String creationdateafter;//创建时间晚于
public String getCreationdatebefore() {
return creationdatebefore;
}
public void setCreationdatebefore(String creationdatebefore) {
this.creationdatebefore = creationdatebefore;
}
public String getFactory() {
return factory;
}
public void setFactory(String factory) {
this.factory = factory;
}
public String getCreationdateafter() {
return creationdateafter;
}
public void setCreationdateafter(String creationdateafter) {
this.creationdateafter = creationdateafter;
}
public String toString(){
return "{\"factory\":\"" + factory + "\",\"creationdatebefore\":\"" + creationdatebefore + "\",\"creationdateafter\":\"" + creationdateafter + "\"}";
}
}

@ -0,0 +1,33 @@
package com.connor.web.bean;
public class ECNBeanReturn {
private String owninguser;
private int counts;
public ECNBeanReturn(String owninguser, int counts) {
this.owninguser = owninguser;
this.counts = counts;
}
public String getOwninguser() {
return owninguser;
}
public void setOwninguser(String owninguser) {
this.owninguser = owninguser;
}
public int getCounts() {
return counts;
}
public void setCounts(int counts) {
this.counts = counts;
}
public void add(){
counts ++;
}
public String toString(){
return "{\"owninguser\":\"" + owninguser + "\",\"counts\":\"" + counts + "\"}";
}
}

@ -32,6 +32,8 @@ public class MaterialBean {
@JsonProperty("PUID") @JsonProperty("PUID")
private String puid; private String puid;
@JsonProperty("Specification")
private String Specification;
private String time; private String time;
@ -49,7 +51,8 @@ public class MaterialBean {
} }
public MaterialBean(String pmpcCode, String goodsCode, String goodsName, String unitCode, String companyCode, String bpNo, String spec, String teRe, String state, int code, String puid) { public MaterialBean(String pmpcCode, String goodsCode, String goodsName, String unitCode, String companyCode,
String bpNo, String spec, String teRe, String state, int code, String puid, String specification) {
PmpcCode = pmpcCode==null?"":pmpcCode; PmpcCode = pmpcCode==null?"":pmpcCode;
GoodsCode = goodsCode==null?"":goodsCode; GoodsCode = goodsCode==null?"":goodsCode;
GoodsName = goodsName==null?"":goodsName; GoodsName = goodsName==null?"":goodsName;
@ -61,6 +64,7 @@ public class MaterialBean {
State = state==null?"":state; State = state==null?"":state;
Code = code; Code = code;
this.puid = puid==null?"":puid; this.puid = puid==null?"":puid;
Specification = specification==null?"":specification;
} }
public String getPuid() { public String getPuid() {
@ -167,6 +171,14 @@ public class MaterialBean {
this.time = time; this.time = time;
} }
public String getSpecification() {
return Specification;
}
public void setSpecification(String Specification) {
this.Specification = Specification;
}
@Override @Override
public String toString() { public String toString() {
return "MaterialBean{" + return "MaterialBean{" +
@ -181,6 +193,7 @@ public class MaterialBean {
", TeRe='" + TeRe + '\'' + ", TeRe='" + TeRe + '\'' +
", State='" + State + '\'' + ", State='" + State + '\'' +
", puid='" + puid + '\''+ ", puid='" + puid + '\''+
", Specification='" + Specification + '\''+
'}'; '}';
} }

@ -0,0 +1,242 @@
package com.connor.web.bean;
import java.math.BigDecimal;
public class SRMResultBean {
private BigDecimal code;
private String materialno;
private String factory;
private String username;
private String userid;
private String wbs;
private String objectname;
private String datesetname;
private String drawingno;
private String revision;
private String fileurl;
private String released;
private String createtime;
private String updatetime;
private String urlcreatetime;
private String urlstatus;
private String procuretype;
private String factoryno;
private String ecncode;
//private boolean isNotRealease;
//
// public boolean isNotRealease() {
// return isNotRealease;
// }
//
// public void setNotRealease(boolean notRealease) {
// isNotRealease = notRealease;
// }
public String getEcncode() {
return ecncode;
}
public void setEcncode(String ecncode) {
this.ecncode = ecncode;
}
public SRMResultBean(BigDecimal code, String materialno, String factory, String username, String userid, String wbs, String objectname, String datesetname, String drawingno, String revision, String fileurl, String released, String createtime, String updatetime, String urlcreatetime, String urlstatus, String procuretype, String factoryno, String ecncode) {
this.code = code;
this.materialno = materialno;
this.factory = factory;
this.username = username;
this.userid = userid;
this.wbs = wbs;
this.objectname = objectname;
this.datesetname = datesetname;
this.drawingno = drawingno;
this.revision = revision;
this.fileurl = fileurl;
this.released = released;
this.createtime = createtime;
this.updatetime = updatetime;
this.urlcreatetime = urlcreatetime;
this.urlstatus = urlstatus;
this.procuretype = procuretype;
this.factoryno = factoryno;
this.ecncode = ecncode;
}
public SRMResultBean(BigDecimal code, String materialno, String factory, String username, String userid, String wbs, String objectname, String datesetname, String drawingno, String revision, String fileurl, String released, String createtime, String updatetime, String urlcreatetime, String urlstatus, String procuretype, String factoryno) {
this.code = code;
this.materialno = materialno;
this.factory = factory;
this.username = username;
this.userid = userid;
this.wbs = wbs;
this.objectname = objectname;
this.datesetname = datesetname;
this.drawingno = drawingno;
this.revision = revision;
this.fileurl = fileurl;
this.released = released;
this.createtime = createtime;
this.updatetime = updatetime;
this.urlcreatetime = urlcreatetime;
this.urlstatus = urlstatus;
this.procuretype = procuretype;
this.factoryno = factoryno;
}
public String getProcuretype() {
return procuretype;
}
public void setProcuretype(String procuretype) {
this.procuretype = procuretype;
}
public String getFactoryno() {
return factoryno;
}
public void setFactoryno(String factoryno) {
this.factoryno = factoryno;
}
// Getter and Setter methods for all fields
public BigDecimal getCode() {
return code;
}
public void setCode(BigDecimal code) {
this.code = code;
}
public String getMaterialno() {
return materialno;
}
public void setMaterialno(String materialno) {
this.materialno = materialno;
}
public String getFactory() {
return factory;
}
public void setFactory(String factory) {
this.factory = factory;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getWbs() {
return wbs;
}
public void setWbs(String wbs) {
this.wbs = wbs;
}
public String getObjectname() {
return objectname;
}
public void setObjectname(String objectname) {
this.objectname = objectname;
}
public String getDatesetname() {
return datesetname;
}
public void setDatesetname(String datesetname) {
this.datesetname = datesetname;
}
public String getDrawingno() {
return drawingno;
}
public void setDrawingno(String drawingno) {
this.drawingno = drawingno;
}
public String getRevision() {
return revision;
}
public void setRevision(String revision) {
this.revision = revision;
}
public String getFileurl() {
return fileurl;
}
public void setFileurl(String fileurl) {
this.fileurl = fileurl;
}
public String getReleased() {
return released;
}
public void setReleased(String released) {
this.released = released;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getUpdatetime() {
return updatetime;
}
public void setUpdatetime(String updatetime) {
this.updatetime = updatetime;
}
public String getUrlcreatetime() {
return urlcreatetime;
}
public void setUrlcreatetime(String urlcreatetime) {
this.urlcreatetime = urlcreatetime;
}
public String getUrlstatus() {
return urlstatus;
}
public void setUrlstatus(String urlstatus) {
this.urlstatus = urlstatus;
}
public SRMResultBean(String materialno, String wbs, String revision, String fileurl, String factory) {
this.materialno = materialno;
this.wbs = wbs;
this.revision = revision;
this.fileurl = fileurl;
this.factory = factory;
}
}

@ -9,9 +9,10 @@ public class DB_PRODUCT extends PrintBean{
private String tankNo; private String tankNo;
private String unit; private String unit;
private String quantity; private String quantity;
private String factoryNo;
public DB_PRODUCT(String netWorkNo, String materialNo, String materialName, public DB_PRODUCT(String netWorkNo, String materialNo, String materialName,
String site, String tankNo,String unit,String quantity) { String site, String tankNo, String unit, String quantity, String factoryNo) {
this.netWorkNo = netWorkNo; this.netWorkNo = netWorkNo;
this.materialNo = materialNo; this.materialNo = materialNo;
this.materialName = materialName; this.materialName = materialName;
@ -19,6 +20,7 @@ public class DB_PRODUCT extends PrintBean{
this.tankNo = tankNo; this.tankNo = tankNo;
this.unit = unit==null?"台":unit; this.unit = unit==null?"台":unit;
this.quantity = quantity; this.quantity = quantity;
this.factoryNo = factoryNo;
} }
/* /*
@ -29,6 +31,14 @@ public class DB_PRODUCT extends PrintBean{
} }
*/ */
public String getFactoryNo() {
return factoryNo;
}
public void setFactoryNo(String factoryNo) {
this.factoryNo = factoryNo;
}
public String getQuantity() { public String getQuantity() {
return quantity; return quantity;
} }

@ -10,6 +10,15 @@ public class Product extends PrintBean {
private String tankNo; private String tankNo;
private String unit; private String unit;
private String quantity; private String quantity;
private String factoryNo;
public String getFactoryNo() {
return factoryNo;
}
public void setFactoryNo(String factoryNo) {
this.factoryNo = factoryNo;
}
public String getQuantity() { public String getQuantity() {
return quantity; return quantity;
@ -67,7 +76,8 @@ public class Product extends PrintBean {
site, site,
tankNo, tankNo,
unit, unit,
quantity quantity,
factoryNo
)); ));
} }

@ -1,7 +1,5 @@
package com.connor.web.controller; package com.connor.web.controller;
import com.DemoKApplication;
import com.alibaba.fastjson2.JSON;
import com.connor.web.bean.*; import com.connor.web.bean.*;
import com.connor.web.bean.getproject.*; import com.connor.web.bean.getproject.*;
import com.connor.web.config.Config; import com.connor.web.config.Config;
@ -12,30 +10,21 @@ import com.connor.web.mapper.pojo.UNV8_category_set;
import com.connor.web.util.FtpUtil; import com.connor.web.util.FtpUtil;
import com.connor.web.util.RelationUtils; import com.connor.web.util.RelationUtils;
import com.connor.web.util.TCUtil; import com.connor.web.util.TCUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.squareup.okhttp.OkHttpClient;
import com.teamcenter.clientx.Session; import com.teamcenter.clientx.Session;
import com.teamcenter.services.internal.loose.core.StructureManagementRestBindingStub;
//import com.teamcenter.services.strong.cad._2007_01.StructureManagement;
import com.teamcenter.services.strong.classification.ClassificationService; import com.teamcenter.services.strong.classification.ClassificationService;
import com.teamcenter.services.strong.classification._2007_01.Classification; import com.teamcenter.services.strong.classification._2007_01.Classification;
import com.teamcenter.services.strong.core.DataManagementService; import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core.StructureManagementService;
import com.teamcenter.services.strong.core._2008_06.DataManagement; import com.teamcenter.services.strong.core._2008_06.DataManagement;
import com.teamcenter.services.strong.query.SavedQueryService; import com.teamcenter.services.strong.query.SavedQueryService;
import com.teamcenter.services.strong.query._2006_03.SavedQuery; import com.teamcenter.services.strong.query._2006_03.SavedQuery;
import com.teamcenter.soa.client.model.ModelObject; import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData; import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.*; import com.teamcenter.soa.client.model.strong.*;
import com.teamcenter.services.strong.workflow.WorkflowService;
import com.teamcenter.services.strong.workflow._2014_06.Workflow;
import com.teamcenter.soa.exceptions.NotLoadedException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONArray; import org.springframework.boot.configurationprocessor.json.JSONArray;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject; import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -46,16 +35,13 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.BufferedReader;
import java.math.BigDecimal; import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/** /**
* Created by K on 2018/8/10. * Created by K on 2018/8/10.
@ -111,16 +97,16 @@ public class MyRestController {
groups.add("M005"); groups.add("M005");
groups.add("M008"); groups.add("M008");
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); final DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Folder homeFolder = user.get_home_folder(); Folder homeFolder = user.get_home_folder();
dataManagementService.getProperties(new ModelObject[]{user}, new String[]{"newstuff_folder"}); dataManagementService.getProperties(new ModelObject[]{user}, new String[]{"newstuff_folder"});
Folder newStuffFolder = user.get_newstuff_folder(); final Folder newStuffFolder = user.get_newstuff_folder();
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
Result rs = null; Result rs = null;
TCUtil.byPass(true); TCUtil.byPass(true);
for (int i = 0; i < materials.size(); i++) { for (int i = 0; i < materials.size(); i++) {
MaterialBean material = materials.get(i); final MaterialBean material = materials.get(i);
log("第" + i + "个:" + material); log("第" + i + "个:" + material);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
@ -136,7 +122,7 @@ public class MyRestController {
String now = format.format(new Date()); String now = format.format(new Date());
String item_id = material.getGoodsCode(); String item_id = material.getGoodsCode();
ModelObject items[] = TCUtil.queryItemByID(item_id); ModelObject[] items = TCUtil.queryItemByID(item_id);
ModelObject itemObj = null; ModelObject itemObj = null;
ModelObject revObj = null; ModelObject revObj = null;
String uid = ""; String uid = "";
@ -164,8 +150,7 @@ public class MyRestController {
int n = serverData.sizeOfPlainObjects(); int n = serverData.sizeOfPlainObjects();
log("查询个数:" + n); log("查询个数:" + n);
if (n == 1) { if (n == 1) {
ModelObject obj = serverData.getPlainObject(0); revObj = serverData.getPlainObject(0);
revObj = obj;
dataManagementService.refreshObjects(new ModelObject[]{revObj}); dataManagementService.refreshObjects(new ModelObject[]{revObj});
} }
} }
@ -212,7 +197,6 @@ public class MyRestController {
//code = materialLists.get(0).getCode(); //code = materialLists.get(0).getCode();
log("查询结果:" + code); log("查询结果:" + code);
hasCode = true;
if (flag) { if (flag) {
// log("items2_uid:"+items[0].getUid()); // log("items2_uid:"+items[0].getUid());
//dataManagementService.refreshObjects(new ModelObject[]{items[0]}); //dataManagementService.refreshObjects(new ModelObject[]{items[0]});
@ -228,8 +212,7 @@ public class MyRestController {
int n = serverData.sizeOfPlainObjects(); int n = serverData.sizeOfPlainObjects();
log("查询个数:" + n); log("查询个数:" + n);
if (n == 1) { if (n == 1) {
ModelObject obj = serverData.getPlainObject(0); revObj = serverData.getPlainObject(0);
revObj = obj;
dataManagementService.refreshObjects(new ModelObject[]{revObj}); dataManagementService.refreshObjects(new ModelObject[]{revObj});
} }
} }
@ -275,11 +258,7 @@ public class MyRestController {
String old_id = revObj.getPropertyDisplayableValue("item_id"); String old_id = revObj.getPropertyDisplayableValue("item_id");
log("原ID:[" + old_id + "]新ID:[" + item_id + "]"); log("原ID:[" + old_id + "]新ID:[" + item_id + "]");
if (item_id.equals(old_id)) { TCUtil.updatePart(revObj, dataManagementService, material, !item_id.equals(old_id), errMess);
TCUtil.updatePart(revObj, dataManagementService, material, false, errMess);
} else {
TCUtil.updatePart(revObj, dataManagementService, material, true, errMess);
}
log("更新"); log("更新");
log("开始更新数据库Code:" + code); log("开始更新数据库Code:" + code);
material.set_PUID(uid); material.set_PUID(uid);
@ -422,7 +401,6 @@ public class MyRestController {
for (int i = 0; i < objs.length; i++) { for (int i = 0; i < objs.length; i++) {
System.out.println(i + "-->[" + objs[i].getUid() + "]Type=[" + objs[i].getTypeObject().getName() + "]"); System.out.println(i + "-->[" + objs[i].getUid() + "]Type=[" + objs[i].getTypeObject().getName() + "]");
} }
ModelObject[] itemObjs = {objs[0]};
ModelObject[] revObjs = {objs[2]}; ModelObject[] revObjs = {objs[2]};
Map<String, com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct> revMaps = new HashMap<>(); Map<String, com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct> revMaps = new HashMap<>();
@ -471,16 +449,19 @@ public class MyRestController {
@Transactional @Transactional
@RequestMapping(value = "/getCoreweight", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getCoreweight", method = {RequestMethod.GET, RequestMethod.POST})
public String getCoreweight(@RequestBody CoreBean coreBean) throws Exception { public String getCoreweight(@RequestBody CoreBatchBean coreBeans) throws Exception {//TODO getCoreweight
log(">> 开始执行getCoreweight"); log(">> 开始执行getCoreweight");
log("jSONObject = " + coreBean); log("jSONObject = " + coreBeans);
Session session = new Session(config.getTc_url()); Session session = new Session(config.getTc_url());
User user = session.login2(config.getTc_user(), config.getTc_pwd()); User user = session.login2(config.getTc_user(), config.getTc_pwd());
if (user == null) { if (user == null) {
throw new Exception("Teamcenter SOA登录失败"); throw new Exception("Teamcenter SOA登录失败");
} }
ArrayList<CoreBeanReturn> returns = new ArrayList<>();
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
for(CoreBean coreBean : coreBeans.getRequests()){
log("coreBean = " + coreBean);
String productno = coreBean.getProductno(); String productno = coreBean.getProductno();
String wbsno = coreBean.getWbsno(); String wbsno = coreBean.getWbsno();
//根据查询搜索到线圈物料 //根据查询搜索到线圈物料
@ -489,6 +470,7 @@ public class MyRestController {
fields.put("materialno", productno); fields.put("materialno", productno);
fields.put("WBS No", wbsno); fields.put("WBS No", wbsno);
String weight = "";//0.0; String weight = "";//0.0;
String length = "";//lidy20240507增加器身长度获取逻辑
ModelObject[] chint_query_material_updates = TCUtil.query("chint_query_material_test", fields); ModelObject[] chint_query_material_updates = TCUtil.query("chint_query_material_test", fields);
if (chint_query_material_updates.length > 0) { if (chint_query_material_updates.length > 0) {
ModelObject item = chint_query_material_updates[0]; ModelObject item = chint_query_material_updates[0];
@ -513,13 +495,49 @@ public class MyRestController {
System.out.println(String.valueOf(zt2_designWeight)); System.out.println(String.valueOf(zt2_designWeight));
weight = format.toString(); weight = format.toString();
} }
//器身长度(公式=2*MO+QSDMAX
//CodeSource codeSource = MyRestController.class.getProtectionDomain().getCodeSource();
//URL location = codeSource.getLocation();
//String path = location.getPath();//System.getenv("TC_ROOT")
String[] cmd = new String[] { "java", "-jar", System.getenv("TC_ROOT") + "\\bin\\findCshSql.jar", split[1], "2*%MO#+%QSDMAX#" };
log(Arrays.toString(cmd));
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
processBuilder.redirectErrorStream(true);
BufferedReader reader = null;
try {
Process process = processBuilder.start();
// 读取jar包的输出
reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
String line;
while ((line = reader.readLine()) != null) {
log(line);
if(line.contains("Exception"))
length = "Exception";
if(!length.equals("Exception"))
length = line;
}
// 等待jar执行完成
int exitCode = process.waitFor();
if (exitCode != 0 || length.equals("Exception")) {
log("findCshSql.jar execution failed with exit code: " + exitCode);
length = "";
}
} catch (Exception e) {
e.printStackTrace();
log(TCUtil.getStackTrace(e));
}finally {
if(reader != null)
reader.close();
}
}
} }
CoreBeanReturn rs = new CoreBeanReturn(productno, wbsno, weight, code, length);
returns.add(rs);
} }
CoreBeanReturn rs = new CoreBeanReturn(productno, wbsno, weight, code);
// Result rs = new Result("",1); // Result rs = new Result("",1);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String data = objectMapper.writeValueAsString(rs); String data = "{\"code\": \"200\",\"results\":" + objectMapper.writeValueAsString(returns) + "}";
log("返回数据:" + data + "\n"); log("返回数据:" + data + "\n");
session.logout(); session.logout();
return data; return data;
@ -545,7 +563,6 @@ public class MyRestController {
String code = "500"; String code = "500";
String weight = ""; String weight = "";
String drawingno = ""; String drawingno = "";
String materialno = materialno2;
String name = ""; String name = "";
for (ModelObject chint_query_material_update : chint_query_material_updates) { for (ModelObject chint_query_material_update : chint_query_material_updates) {
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
@ -639,7 +656,7 @@ public class MyRestController {
break; break;
} }
} }
ReturnBean1 rs = new ReturnBean1(code, weight, drawingno, materialno, name); ReturnBean1 rs = new ReturnBean1(code, weight, drawingno, materialno2, name);
// Result rs = new Result("",1); // Result rs = new Result("",1);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String data = objectMapper.writeValueAsString(rs); String data = objectMapper.writeValueAsString(rs);
@ -648,6 +665,125 @@ public class MyRestController {
return data; return data;
} }
// @Transactional
// @RequestMapping(value = "/getProject", method = {RequestMethod.GET, RequestMethod.POST})
// public String getProject(@RequestBody ProjectInfoBean projInfo) throws Exception {
// //project = "{\"project\":[{\"projectName\":\"100001\",\"projectNo\":\"10KV\",\"projectState\":\"正常\",\"state\":\"已创建\",\"WBS\":[{\"WBSName\":\"变压器\",\"WBSNo\":\"100001002\",\"netWork\":[{\"netWorkNo\":\"1111112\",\"netWorkname\":\"123123\",\"deliveryDate\":\"20190909\",\"task\":[{\"activeName\":\"100001001001\",\"activeNo\":\"变压器设计\",\"plansStart\":\"20190815\",\"plansEnd\":\"20190830\"}],\"product\":[{\"materialNo\":\"20000000\",\"materialName\":\"变压器\"}]}]}]}]}";
// log(">> 开始执行getProject");
// log("project: " + projInfo);
// /*ObjectMapper om = new ObjectMapper();
// om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// ProjectInfoBean projInfo = om.readValue(project,new TypeReference<ProjectInfoBean>(){});
// log("解析结果:"+projInfo);*/
// projInfo.initDBData();
// log("项目数据:\n" + projInfo.getDb_projects());
// log("任务数据:\n" + projInfo.getDb_tasks());
// log("产品数据:\n" + projInfo.getDb_products());
// log("factory:" + projInfo.getDb_projects().get(0).getFactory());
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String now = format.format(new Date());
// System.out.println("now:" + now);
// List<String> resetNetworkNos = new ArrayList<>();
//
//
// //写入数据库
// for (int i = 0; i < projInfo.getDb_projects().size(); i++) {
// DB_PROJECT data = projInfo.getDb_projects().get(i);
// String factory = projInfo.getDb_projects().get(0).getFactory();
// String netNo = data.getNetWorkNo();
// log("准备添加项目数据:" + data);
// List<DB_PROJECT> existedProjs = dataMapper.queryProject(netNo);
// if (existedProjs.size() > 0) {
// String state = existedProjs.get(0).getState();// data.getState();
// log("项目已存在state = " + state);
// if ("已创建".equals(state)) {
// state = "已变更";
// }
// if ("未创建".equals(state) || "已变更".equals(state)) {
// log("更新项目状态state = " + state);
// int row = dataMapper.updateProjectState(netNo, state, now, factory);
// if (row != 1) {
// throw new Exception("更新项目状态失败:" + data);
// }
// log("更新完成");
// } else {
// throw new Exception("未知状态 state = " + state);
// }
// resetNetworkNos.add(netNo);
// } else {
// log("首次添加项目 state = 未创建");
// data.setState("未创建");
// data.setTime(now);
// int row = dataMapper.addProjectData(data);
// if (row != 1) {
// throw new Exception("插入数据失败:" + data);
// }
// log("添加成功");
// }
// }
//
// for (int i = 0; i < resetNetworkNos.size(); i++) {
// String netNo = resetNetworkNos.get(i);
// log("删除旧PRODUCT数据...netWorkNo = " + netNo);
// int row = dataMapper.removeProductData(netNo);
// log("删除了" + row + "行数据");
// log("删除旧TASK数据...netWorkNo = " + netNo);
// row = dataMapper.removeTaskData(netNo);
// log("删除了" + row + "行数据");
// }
//
// for (int i = 0; i < projInfo.getDb_tasks().size(); i++) {
// DB_TASK data = projInfo.getDb_tasks().get(i);
// log("插入TASK数据 >> " + data);
// int row = dataMapper.addTaskData(data);
// if (row != 1) {
// throw new Exception("插入数据失败:" + data);
// }
// }
//
// for (int i = 0; i < projInfo.getDb_products().size(); i++) {
// DB_PRODUCT data = projInfo.getDb_products().get(i);
// System.out.println("单位:" + data.getUnit());
// if (data.getUnit() == null || data.getUnit().equals("")) {
// data.setUnit("台");
// System.out.println("设置单位:" + data.getUnit());
// }
// log("插入PRODUCT数据 >> " + data);
// int row = dataMapper.addProductData(data);
// if (row != 1) {
// throw new Exception("插入数据失败:" + data);
// }
// }
//
//// OkHttpClient client = new OkHttpClient();
//// com.squareup.okhttp.MediaType mediaType = com.squareup.okhttp.MediaType.parse("application/json;charset=UTF-8");
//// com.squareup.okhttp.RequestBody body = com.squareup.okhttp.RequestBody.create(mediaType,str);
//// com.squareup.okhttp.Request request = new com.squareup.okhttp.Request.Builder().url("http://10.0.14.5:31465/api/change")
//// .method("POST", body)
//// // .addHeader("Cookie", "")
////// .addHeader("Authorization", "Bearer "+token)
//// // .addHeader("Connection", "keep-alive")
//// .addHeader("Content-Type", "application/json")
//// .build();
//// com.squareup.okhttp.Response response = client.newCall(request).execute();
//// // response.body().byteStream()
//// // System.out.println(response.body().string());
//// JSONObject parseObject = JSON.parseObject(response.body().string());
//// Boolean bool = parseObject.getBoolean("success");
//// if(!bool) {
//// String msg = parseObject.getString("msg");
//// System.out.println(msg);
//// }else {
//// System.out.println("success");
//// }
//
// Result rs = new Result("", 1);
// ObjectMapper objectMapper = new ObjectMapper();
// String data = objectMapper.writeValueAsString(rs);
// log("返回数据:" + data + "\n");
// return data;
// }
@Transactional @Transactional
@RequestMapping(value = "/getProject", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getProject", method = {RequestMethod.GET, RequestMethod.POST})
public String getProject(@RequestBody ProjectInfoBean projInfo) throws Exception { public String getProject(@RequestBody ProjectInfoBean projInfo) throws Exception {
@ -705,8 +841,7 @@ public class MyRestController {
} }
} }
for (int i = 0; i < resetNetworkNos.size(); i++) { for (String netNo : resetNetworkNos) {
String netNo = resetNetworkNos.get(i);
log("删除旧PRODUCT数据...netWorkNo = " + netNo); log("删除旧PRODUCT数据...netWorkNo = " + netNo);
int row = dataMapper.removeProductData(netNo); int row = dataMapper.removeProductData(netNo);
log("删除了" + row + "行数据"); log("删除了" + row + "行数据");
@ -767,6 +902,9 @@ public class MyRestController {
return data; return data;
} }
@RequestMapping(value = "/getSchedule", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getSchedule", method = {RequestMethod.GET, RequestMethod.POST})
public String getSchedule(@RequestParam String item, @RequestParam String product) throws Exception { public String getSchedule(@RequestParam String item, @RequestParam String product) throws Exception {
log(">> 开始执行获取TC中时间表信息"); log(">> 开始执行获取TC中时间表信息");
@ -1213,7 +1351,7 @@ public class MyRestController {
try { try {
User user = session.login2(config.getTc_user(), config.getTc_pwd()); User user = session.login2(config.getTc_user(), config.getTc_pwd());
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
ModelObject object = queryItems("chint_query_material", new String[]{"materialno"}, new String[]{item}); ModelObject object = queryItem("chint_query_material", new String[]{"materialno"}, new String[]{item});
if (object == null) if (object == null)
throw new Exception(); throw new Exception();
@ -1648,7 +1786,7 @@ public class MyRestController {
try { try {
User user = session.login2(config.getTc_user(), config.getTc_pwd()); User user = session.login2(config.getTc_user(), config.getTc_pwd());
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
ModelObject object = queryItems("chint_query_FactoryNo", new String[]{"fid"}, new String[]{factoryNo}); ModelObject object = queryItem("chint_query_FactoryNo", new String[]{"fid"}, new String[]{factoryNo});
if (object == null) if (object == null)
throw new Exception(); throw new Exception();
Item part_revision = (Item) object; Item part_revision = (Item) object;
@ -1700,7 +1838,7 @@ public class MyRestController {
User user = session.login2(config.getTc_user(), config.getTc_pwd()); User user = session.login2(config.getTc_user(), config.getTc_pwd());
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
ModelObject object = queryItems("chint_query_FactoryNo", new String[]{"fid"}, new String[]{factoryNo}); ModelObject object = queryItem("chint_query_FactoryNo", new String[]{"fid"}, new String[]{factoryNo});
log("开始查找对象"); log("开始查找对象");
if (object == null) if (object == null)
throw new Exception(); throw new Exception();
@ -1840,8 +1978,7 @@ public class MyRestController {
return data.toString(); return data.toString();
} }
public static ModelObject[] queryItems(String queryName, String[] entries, String[] values) {
public static ModelObject queryItems(String queryName, String[] entries, String[] values) {
ImanQuery query = null; ImanQuery query = null;
@ -1857,7 +1994,7 @@ public class MyRestController {
if (savedQueries.queries.length == 0) { if (savedQueries.queries.length == 0) {
System.out.println("There are no saved queries in the system."); log("There are no saved queries in the system.");
return null; return null;
} }
@ -1870,16 +2007,18 @@ public class MyRestController {
} }
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("GetSavedQueries service request failed."); log("GetSavedQueries service request failed.");
System.out.println(e.getMessage()); log(TCUtil.getStackTrace(e));
return null; return null;
} }
if (query == null) { if (query == null) {
System.out.println("There is not an 'Item Name' query."); log("There is not an query:" + queryName);
return null; return null;
} }
try { try {
DataManagementService.getService(Session.getConnection()).getProperties(new ModelObject[] { query }, new String[]{ "query_clauses" });
log("query:" + Arrays.toString(query.get_query_clauses()));
// Search for all Items, returning a maximum of 25 objects // Search for all Items, returning a maximum of 25 objects
com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[] savedQueryInput = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[1]; com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[] savedQueryInput = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[1];
savedQueryInput[0] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput(); savedQueryInput[0] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput();
@ -1893,16 +2032,25 @@ public class MyRestController {
com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput); com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = savedQueryResult.arrayOfResults[0]; com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = savedQueryResult.arrayOfResults[0];
TCUtil.throwServiceDataError(savedQueryResult.serviceData);
// Page through the results 10 at a time // Page through the results 10 at a time
if (found != null && found.numOfObjects > 0) { if (found != null && found.numOfObjects > 0) {
return found.objects[0]; return found.objects;
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("ExecuteSavedQuery service request failed."); log("ExecuteSavedQuery service request failed.");
System.out.println(e.getMessage()); log(TCUtil.getStackTrace(e));
return null;
}
return null; return null;
} }
public static ModelObject queryItem(String queryName, String[] entries, String[] values) {
ModelObject[] results = queryItems(queryName, entries, values);
if(results != null && results.length > 0){
return results[0];
}
return null; return null;
} }
@ -1953,12 +2101,12 @@ public class MyRestController {
@Transactional @Transactional
@RequestMapping(value = "/getPart3", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getPart3", method = {RequestMethod.GET, RequestMethod.POST})
public String getMaterial_Part3(@RequestBody List<MaterialBean> materials) throws Exception { public String getMaterial_Part3(@RequestBody final List<MaterialBean> materials) throws Exception {
long time = new Date().getTime(); long time = new Date().getTime();
String data = ""; String data = "";
log("maaterials:" + materials); log("maaterials:" + materials);
StringBuilder errMess = new StringBuilder(); final StringBuilder errMess = new StringBuilder();
Session session = new Session(config.getTc_url()); final Session session = new Session(config.getTc_url());
User user = session.login2(config.getTc_user(), config.getTc_pwd()); User user = session.login2(config.getTc_user(), config.getTc_pwd());
if (user == null) { if (user == null) {
throw new Exception("Teamcenter SOA登录失败"); throw new Exception("Teamcenter SOA登录失败");
@ -1973,11 +2121,11 @@ public class MyRestController {
groups.add("M041"); groups.add("M041");
groups.add("M042"); groups.add("M042");
groups.add("M043"); groups.add("M043");
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); final DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Folder homeFolder = user.get_home_folder(); Folder homeFolder = user.get_home_folder();
dataManagementService.getProperties(new ModelObject[]{user}, new String[]{"newstuff_folder"}); dataManagementService.getProperties(new ModelObject[]{user}, new String[]{"newstuff_folder"});
Folder newStuffFolder = user.get_newstuff_folder(); final Folder newStuffFolder = user.get_newstuff_folder();
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
Result rs = null; Result rs = null;
ServiceData serverData = null; ServiceData serverData = null;
@ -2251,6 +2399,59 @@ public class MyRestController {
// return bomWindowandParentLine; // return bomWindowandParentLine;
// } // }
//TODO 云派调用TC接口查询更改通知单对象
@RequestMapping(value = "/getECN", method = {RequestMethod.GET, RequestMethod.POST})
public String getECN(@RequestBody ECNBean ecnBean) throws Exception {
log(">> 开始执行getECN");
log("jSONObject = " + ecnBean);
Session session = new Session(config.getTc_url());
User user = session.login2(config.getTc_user(), config.getTc_pwd());
if (user == null) {
throw new Exception("Teamcenter SOA登录失败");
}
HashMap<String, ECNBeanReturn> counts = new HashMap<>();
try{
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
// sdf2.applyLocalizedPattern();
String[] vals = new String[]{ sdf2.format(sdf1.parse(ecnBean.getCreationdatebefore())) + " 23:59", "*" + ecnBean.getFactory() + "*",
sdf2.format(sdf1.parse(ecnBean.getCreationdateafter())) + " 00:00" };
log("query = " + Arrays.toString(vals));
// ModelObject[] results = queryItems("chint_query_change", new String[]{ "创建时间早于", "所有权组", "创建时间晚于" }, vals);
// ModelObject[] results = queryItems("chint_query_change", new String[]{ "CreatedBefore", "OwningGroup", "CreatedAfter" }, vals);
ModelObject[] results = queryItems("chint_query_change", new String[]{ "before", "groupname", "after" }, vals);
if (results != null) {
for(ModelObject result : results){
dataManagementService.getProperties(new ModelObject[] { result }, new String[]{ "owning_user" });
com.teamcenter.soa.client.model.Property prop = result.getPropertyObject("owning_user");
ModelObject owning_user = prop.getModelObjectValue();
dataManagementService.getProperties(new ModelObject[] { owning_user }, new String[]{ "user_name" });
String user_name = owning_user.getPropertyDisplayableValue("user_name");
if(counts.containsKey(user_name)){
counts.get(user_name).add();
}else {
counts.put(user_name, new ECNBeanReturn(user_name, 1));
}
}
}else{
log("chint_query_change查询未返回有效结果");
}
}catch(Exception e){
e.printStackTrace();
log("getECN 异常===>" + TCUtil.getStackTrace(e));
throw e;
}
ArrayList<ECNBeanReturn> returns = new ArrayList<>(counts.values());
ObjectMapper objectMapper = new ObjectMapper();
String data = "{\"code\": \"200\",\"msg\": \"\",\"results\":" + objectMapper.writeValueAsString(returns) + "}";
log("返回数据:" + data + "\n");
session.logout();
return data;
}
public static void log(String msg) { public static void log(String msg) {
TCUtil.log(logger, msg); TCUtil.log(logger, msg);
} }

@ -6,34 +6,36 @@ package com.connor.web.controller;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.connor.web.bean.GZXQBean; import com.connor.web.bean.GZXQBean;
import com.connor.web.bean.QuotationDTO; import com.connor.web.bean.QuotationDTO;
import com.connor.web.bean.SapResult; import com.connor.web.bean.SRMResultBean;
import com.connor.web.bean.SapReturn;
import com.connor.web.bean.SendSapBom; import com.connor.web.bean.SendSapBom;
import com.connor.web.service.QuotationService; import com.connor.web.service.QuotationService;
import com.connor.web.service.TCSoaUserService;
import com.connor.web.util.DefineUtil; import com.connor.web.util.DefineUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.squareup.okhttp.MediaType; import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request; import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response; import com.squareup.okhttp.Response;
import com.teamcenter.clientx.Session; import com.teamcenter.clientx.Session;
import com.teamcenter.services.strong.cad._2007_01.StructureManagement; //import com.teamcenter.services.strong.cad._2007_01.StructureManagement;
import com.teamcenter.soa.client.model.ModelObject; //import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.*; //import com.teamcenter.soa.client.model.strong.*;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.soa.client.model.strong.User;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.configurationprocessor.json.JSONObject; //import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.boot.configurationprocessor.json.JSONException; //import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject; //import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.*; import java.io.*;
//import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -45,7 +47,7 @@ import com.connor.web.util.TCUtil;
@RestController @RestController
//@RequestMapping("/plm") //@RequestMapping("/plm")
public class QuotationController { public class QuotationController {
private Session session;
@Autowired @Autowired
private QuotationService quotationService; private QuotationService quotationService;
private static final Logger logger = LoggerFactory.getLogger(QuotationController.class); private static final Logger logger = LoggerFactory.getLogger(QuotationController.class);
@ -93,7 +95,7 @@ public class QuotationController {
try { try {
result.put("code", "500"); result.put("code", "500");
result.put("msc", "接收失败" + e.getMessage()); result.put("msc", "接收失败" + e.getMessage());
} catch (JSONException jsonException) { } catch (Exception jsonException) {
jsonException.printStackTrace(); jsonException.printStackTrace();
} }
e.printStackTrace(); e.printStackTrace();
@ -102,7 +104,8 @@ public class QuotationController {
} }
public static void logMsg(String msg) { public static void logMsg(String msg) {
TCUtil.log(logger, msg); //TCUtil.log(logger, msg);
MyRestController.log(msg);
} }
@PostMapping("/sendBomXB") @PostMapping("/sendBomXB")
@ -116,8 +119,7 @@ public class QuotationController {
StringBuilder builder = new StringBuilder(""); StringBuilder builder = new StringBuilder("");
List<String> uidList = sendSapBom.getUid(); List<String> uidList = sendSapBom.getUid();
System.out.println(uidList.size()); System.out.println(uidList.size());
for (int i = 0; i < uidList.size(); i++) { for (String s : uidList) {
String s = uidList.get(i);
builder.append(s).append(":"); builder.append(s).append(":");
} }
// System.out.println(builder.toString()); // System.out.println(builder.toString());
@ -137,7 +139,7 @@ public class QuotationController {
System.out.println("num" + num); System.out.println("num" + num);
result.put("code", "S"); result.put("code", "S");
result.put("msg", "成功接收"); result.put("msg", "成功接收");
} catch (JSONException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return result.toString(); return result.toString();
@ -197,7 +199,7 @@ public class QuotationController {
try { try {
result.put("code", "500"); result.put("code", "500");
result.put("msc", "接收失败" + e.getMessage()); result.put("msc", "接收失败" + e.getMessage());
} catch (JSONException jsonException) { } catch (Exception jsonException) {
jsonException.printStackTrace(); jsonException.printStackTrace();
} }
e.printStackTrace(); e.printStackTrace();
@ -219,7 +221,7 @@ public class QuotationController {
try { try {
result.put("code", "500"); result.put("code", "500");
result.put("msc", "接收失败" + e.getMessage()); result.put("msc", "接收失败" + e.getMessage());
} catch (JSONException jsonException) { } catch (Exception jsonException) {
jsonException.printStackTrace(); jsonException.printStackTrace();
} }
e.printStackTrace(); e.printStackTrace();
@ -238,89 +240,30 @@ public class QuotationController {
@PostMapping("/GetBomDetails") @PostMapping("/GetBomDetails")
public String getBomDetails(@RequestBody String jsonObject) { public String getBomDetails(@RequestBody String jsonObject) {
new Thread(new Runnable() { new Thread(() -> {
@Override logMsg("GetBomDetails 入参1===>" + jsonObject);
public void run() { JSONObject result = new JSONObject();
logMsg("GetBomDetails 入参===>"+jsonObject);
com.alibaba.fastjson2.JSONObject result = new com.alibaba.fastjson2.JSONObject();
Session session = new Session(config.getTc_url()); Session session = new Session(config.getTc_url());
String re = "";
try { try {
//登录 //登录
User user = session.login2(config.getTc_user(), config.getTc_pwd()); User user = session.login2(config.getTc_user(), config.getTc_pwd());
com.alibaba.fastjson2.JSONObject jsonObject1 = JSON.parseObject(jsonObject); DefineUtil.refreshAndGetProperties(user, "user_name");
//产成品物料编码 WBS号 logMsg("GetBomDetails1 User===>" + user.get_user_name());
String wbsNo = jsonObject1.getString(DefineUtil.JSON_WBSNO); re = TCSoaUserService.callUserSerivce(Session.getConnection(), "getBomDetails", new Object[]{ jsonObject });
String materialNo = jsonObject1.getString(DefineUtil.JSON_CCP_MATERIALNO); result = JSON.parseObject(re);
//查询物料
Map<String, String> fields = new HashMap<>();
fields.put(DefineUtil.COND_MATERIAL, materialNo);
fields.put(DefineUtil.COND_WBSNO, wbsNo);
ModelObject[] modelObjects = TCUtil.query(DefineUtil.SEARCH_MATERIAL, fields);
//返回信息
result.put(DefineUtil.JSON_WBSNO, wbsNo);
result.put(DefineUtil.JSON_CCP_MATERIALNO, materialNo);
if (modelObjects.length == 0) {
//没有查询到产成品 返回500
result.put(DefineUtil.JSON_CODE, DefineUtil.ERROR_CODE);
result.put(DefineUtil.JSON_MSG, DefineUtil.ERROR_MSG_NOCCP);
} else {
//查询到产成品 返回200 如果有P物料获取P物料
result.put(DefineUtil.JSON_CODE, DefineUtil.SUCCESS_CODE);
result.put(DefineUtil.JSON_MSG, DefineUtil.ERROR_MSG_CCP);
//BOM全展开 获取到底层物料 数量累乘 相同物料合并数量 物料查询查的版本
ItemRevision ccpRevision = (ItemRevision) modelObjects[0];
//如果有P物料遍历P物料的BOM
for (int i = 0; i < modelObjects.length; i++) {
DefineUtil.refreshAndGetProperties(modelObjects[i], DefineUtil.PROP_IFPBOM);
String ifPbom = modelObjects[i].getPropertyDisplayableValue(DefineUtil.PROP_IFPBOM);
if (ifPbom.equals(DefineUtil.VAL_ISPBOM)) {
ccpRevision = (ItemRevision) modelObjects[i];
}
}
//遍历
DefineUtil.refreshAndGetProperties(ccpRevision, DefineUtil.PROP_REV_QUANTITY);
String ztQuantity = ccpRevision.getPropertyDisplayableValue(DefineUtil.PROP_REV_QUANTITY);
if (ztQuantity == null || ztQuantity.isEmpty()) {
ztQuantity = DefineUtil.VAL_DEFAULT_QUANTITY;
}
ArrayList arrayList = DefineUtil.openBOMWindow(ccpRevision);
BOMLine topLine = (BOMLine) arrayList.get(1);
Map<String, Double> materialMap = new HashMap<>();
Map<String, StructureManagement.ExpandPSData[]> bomMap =
DefineUtil.getBomLineTreeNodeSOA(topLine);
System.out.println(" end ExpandBOM ");
DefineUtil.getChildBomMsg(topLine, ccpRevision, bomMap, materialMap, 1.0);
DefineUtil.closeBOMWindow((BOMWindow) arrayList.get(0));
//信息搭建JSON
JSONArray array = new JSONArray();
int no = 1;
result.fluentPut(DefineUtil.JSON_CCP_QUANTITY, ztQuantity);
result.fluentPut(
DefineUtil.JSON_FACTORY,
jsonObject1.getString(DefineUtil.JSON_FACTORY) == null
? DefineUtil.VAL_EMPTY_STRING
: jsonObject1.getString(DefineUtil.JSON_FACTORY));
for (String key : materialMap.keySet()) {
com.alibaba.fastjson2.JSONObject object = new com.alibaba.fastjson2.JSONObject();
Double aDouble = materialMap.get(key);
String num = String.format("%03d", no);
object.fluentPut(DefineUtil.JSON_CONTENTS_NO, num);
object.fluentPut(DefineUtil.JSON_CONTENTS_MATERIAL, key);
object.fluentPut(DefineUtil.JSON_CONTENTS_QTY, aDouble + "");
no++;
array.add(object);
}
result.fluentPut(DefineUtil.JSON_CONTENTS, array);
}
} catch (Exception e) { } catch (Exception e) {
result.put(DefineUtil.JSON_CODE, DefineUtil.ERROR_CODE); result.put(DefineUtil.JSON_CODE, DefineUtil.ERROR_CODE);
result.put(DefineUtil.JSON_MSG, e.getMessage()); result.put(DefineUtil.JSON_MSG, e.getMessage());
e.printStackTrace(); e.printStackTrace();
logMsg("GetBomDetails1 异常===>" + TCUtil.getStackTrace(e));
} finally { } finally {
session.logout(); session.logout();
} }
com.alibaba.fastjson2.JSONObject jsonInfo = new com.alibaba.fastjson2.JSONObject(); // logMsg("re===>" + re);
com.alibaba.fastjson2.JSONObject jsonData = new com.alibaba.fastjson2.JSONObject(); logMsg("GetBomDetails1 result===>" + result.toJSONString());
JSONObject jsonInfo = new JSONObject();
JSONObject jsonData = new JSONObject();
jsonData.fluentPut(DefineUtil.JSON_DATA, result.toJSONString()); jsonData.fluentPut(DefineUtil.JSON_DATA, result.toJSONString());
jsonInfo.fluentPut(DefineUtil.JSON_INFO, jsonData); jsonInfo.fluentPut(DefineUtil.JSON_INFO, jsonData);
@ -333,27 +276,294 @@ public class QuotationController {
.addHeader(DefineUtil.CONTENT_TYPE, DefineUtil.JSON_APP) .addHeader(DefineUtil.CONTENT_TYPE, DefineUtil.JSON_APP)
.addHeader(DefineUtil.AUTH, DefineUtil.BASIC) .addHeader(DefineUtil.AUTH, DefineUtil.BASIC)
.build(); .build();
//logMsg("GetBomDetails 推送===>" + jsonInfo.toJSONString());
try { try {
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
int code = response.code(); int code = response.code();
logMsg("GetBomDetails 入参===>"+jsonObject); //String msg = response.message();//.body().string();
boolean success = response.isSuccessful();
// logMsg("GetBomDetails 入参===>"+jsonObject);
logMsg("GetBomDetails 组织结果===>" + jsonInfo.toJSONString()); logMsg("GetBomDetails 组织结果===>" + jsonInfo.toJSONString());
logMsg("GetBomDetails 返回结果===>"+code); logMsg("GetBomDetails 是否成功===>" + success);
} catch (IOException e) { logMsg("GetBomDetails 返回结果===>" + code+"" + response.message() + "" + response.body().string());
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logMsg("GetBomDetails 推送异常===>"+e.getMessage()); logMsg("GetBomDetails 推送异常===>"+TCUtil.getStackTrace(e));
} }
}
}).start(); }).start();
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
try { try {
result.put("code", "200"); result.put("code", "200");
result.put("msg", "成功接收"); result.put("msg", "成功接收");
} catch (JSONException e) { } catch (Exception e) {
e.printStackTrace(); logMsg("GetBomDetails 异常===>"+TCUtil.getStackTrace(e));
} }
return result.toString(); return result.toString();
} }
//SRM接口
@PostMapping("/getsrm")
public String querySRM(@RequestBody String jsonstr) throws Exception {
//org.json.JSONObject json = new com.alibaba.fastjson2.JSONObject(jsonstr);
com.alibaba.fastjson2.JSONObject json = com.alibaba.fastjson2.JSONObject.parseObject(jsonstr);
System.out.println(jsonstr);
String wbsno = "";
String materialno = "";
String version = "";
try {
// 获取 "lists" 数组
JSONArray listsArray = json.getJSONArray("lists");
// 获取数组的第一个元素(假设我们知道至少有一个元素)
com.alibaba.fastjson2.JSONObject firstListObject = listsArray.getJSONObject(0);
// 从第一个元素中获取 "wbsno" 的值
wbsno = firstListObject.getString("wbsno");
materialno = firstListObject.getString("materialno");
version = firstListObject.getString("version");
}catch (Exception e){
e.printStackTrace();
JSONObject result = new JSONObject();
//参数非空判断
result.put("code",-1);
result.put("msg","请输入正确的参数!");
return result.toString();
}
return quotationService.querySRM(wbsno,materialno,version);
}
@PostMapping("/GetDrawingUrl")
public String GetDrawingUrl(@RequestBody String jsonstr) throws Exception {
JSONObject parse = (JSONObject) JSON.parse(jsonstr);
JSONObject errorResult = new JSONObject();
JSONObject result = new JSONObject();
List<SRMResultBean> lastBeans = new ArrayList<>();
List<JSONObject> emptyJson = new ArrayList<>();
// 遍历lists数组
JSONArray lists = parse.getJSONArray("lists");
for (int i = 0; i < lists.size(); i++) {
JSONObject listObject = lists.getJSONObject(i);
// 获取listObject中的属性
String factory = listObject.getString("factory");
String wbsno = listObject.getString("wbsno");
String materialno = listObject.getString("materialno");
String versionall = listObject.getString("versionall");
String version = listObject.getString("version");
//参数非空判断
if(factory == null || factory.isEmpty()){
errorResult.put("code",-1);
errorResult.put("msg","factory不能为空");
return errorResult.toString();
}
//参数非空判断
// if(wbsno == null || wbsno.isEmpty()){
// errorResult.put("code",-1);
// errorResult.put("msg","wbsno不能为空");
// return errorResult.toString();
// }
if(materialno == null || materialno.isEmpty()){
errorResult.put("code",-1);
errorResult.put("msg","materialno不能为空");
return errorResult.toString();
}
List<SRMResultBean> srmResultBeans = quotationService.GetDrawingUrl(factory, wbsno, materialno, versionall, version);
if(srmResultBeans != null && srmResultBeans.size() > 0){
for (SRMResultBean srmResultBean : srmResultBeans) {
lastBeans.add(srmResultBean);
}
}else{
JSONObject tempJsonObject = new JSONObject();
tempJsonObject.put("url","");
tempJsonObject.put("version",version==null?"":version);
tempJsonObject.put("factory",factory==null?"":factory);
tempJsonObject.put("materialno",materialno==null?"":materialno);
tempJsonObject.put("wbsno",wbsno==null?"":wbsno);
emptyJson.add(tempJsonObject);
}
}
result.put("code",200);
result.put("msg","success");
JSONArray jsonArray = new JSONArray();
System.out.println("lastBean============"+ lastBeans.size());
for (SRMResultBean lastBean : lastBeans) {
JSONObject tempJsonObject = new JSONObject();
tempJsonObject.put("url",lastBean.getFileurl());
tempJsonObject.put("version",lastBean.getRevision());
tempJsonObject.put("factory",lastBean.getFactory());
tempJsonObject.put("materialno",lastBean.getMaterialno());
tempJsonObject.put("wbsno",lastBean.getWbs()==null?"":lastBean.getWbs());
jsonArray.add(tempJsonObject);
}
for (int i = 0; i < emptyJson.size(); i++) {
jsonArray.add(emptyJson.get(i));
}
result.put("lists",jsonArray);
return result.toJSONString();
}
@PostMapping("/GetProcureUrl")
public String GetProcure(@RequestBody String jsonstr) throws Exception {
JSONObject errorResult = new JSONObject();
JSONObject result = new JSONObject();
HashMap<String, JSONObject> enptyMap = new HashMap<>();
int count = 0;
List<SRMResultBean> lastBeans = new ArrayList<SRMResultBean>();
// 解析JSON字符串
JSONObject jsonObject = JSON.parseObject(jsonstr);
// 获取lists对象
JSONObject lists = jsonObject.getJSONObject("lists");
// 获取wbsno
String wbsno = lists.getString("wbsno");
// 获取procurelists数组
String procuretype = "";
String version = "";
JSONArray procurelistsArray = lists.getJSONArray("procurelists");
for (int i = 0; i < procurelistsArray.size(); i++) {
JSONObject procurelist = procurelistsArray.getJSONObject(i);
procuretype = procurelist.getString("procuretype");
version = procurelist.getString("version");
System.out.println("procuretype: " + procuretype + ", version: " + version);
break;
}
// 获取factory
String factory = lists.getString("factory");
// 获取factoryno
String factoryno = lists.getString("factoryno");
// 获取productno
String productno = lists.getString("productno");
//参数非空判断
//参数非空判断
if(wbsno == null || wbsno.isEmpty()){
errorResult.put("code",-1);
errorResult.put("msg","wbsno不能为空");
return errorResult.toString();
}
if(procuretype == null || procuretype.isEmpty()){
errorResult.put("code",-1);
errorResult.put("msg","procuretype不能为空");
return errorResult.toString();
}
// if(version == null || version.isEmpty()){
// errorResult.put("code",-1);
// errorResult.put("msg","version不能为空");
// return errorResult.toString();
// }
if(factory == null || factory.isEmpty()){
errorResult.put("code",-1);
errorResult.put("msg","factory不能为空");
return errorResult.toString();
}
// if(factoryno == null || factoryno.isEmpty()){
// errorResult.put("code",-1);
// errorResult.put("msg","factoryno不能为空");
// return errorResult.toString();
// }
if(productno == null || productno.isEmpty()){
errorResult.put("code",-1);
errorResult.put("msg","productno不能为空");
return errorResult.toString();
}
List<SRMResultBean> srmResultBeans = quotationService.GetProcure(wbsno, productno, version, factory, factoryno, procuretype);
if(srmResultBeans != null && srmResultBeans.size() > 0){
for (SRMResultBean srmResultBean : srmResultBeans) {
lastBeans.add(srmResultBean);
}
}else{
JSONObject tempJsonObject = new JSONObject();
tempJsonObject.put("wbsno",wbsno == null?"":wbsno);
tempJsonObject.put("productno","");
tempJsonObject.put("factoryno",factoryno == null?"":factoryno);
tempJsonObject.put("factory",factory == null?"":factory);
JSONArray tempJsonArray = new JSONArray();
JSONObject tempJsonObject2 = new JSONObject();
tempJsonObject2.put("type",procuretype == null?"":procuretype);
tempJsonObject2.put("version",version == null?"":version);
tempJsonObject2.put("url","");
tempJsonArray.add(tempJsonObject2);
tempJsonObject.put("filelists",tempJsonArray);
enptyMap.put(count+"",tempJsonObject);
count++;
}
result.put("code",200);
result.put("msg","返回信息:成功");
JSONArray jsonArray = new JSONArray();
System.out.println("lastBean============"+ lastBeans.size());
for (SRMResultBean lastBean : lastBeans) {
JSONObject tempJsonObject = new JSONObject();
tempJsonObject.put("wbsno",lastBean.getWbs()==null?"":lastBean.getWbs());
tempJsonObject.put("productno",lastBean.getMaterialno());
tempJsonObject.put("factoryno",lastBean.getFactoryno()==null?"":lastBean.getFactoryno());
tempJsonObject.put("factory",lastBean.getFactory());
JSONArray tempJsonArray = new JSONArray();
JSONObject tempJsonObject2 = new JSONObject();
tempJsonObject2.put("type",lastBean.getProcuretype());
tempJsonObject2.put("version",lastBean.getRevision());
tempJsonObject2.put("url",lastBean.getFileurl());
tempJsonArray.add(tempJsonObject2);
tempJsonObject.put("filelists",tempJsonArray);
jsonArray.add(tempJsonObject);
}
for (Map.Entry<String, JSONObject> map :enptyMap.entrySet()
) {
JSONObject value = map.getValue();
jsonArray.add(value);
}
result.put("lists",jsonArray);
return result.toJSONString();
}
// @PostMapping("/GetDrawingUrlAA")
// public String GetA() throws Exception {
//
// JSONObject errorResult = new JSONObject();
// JSONObject result = new JSONObject();
//
// quotationService.getA();
//
// return result.toJSONString();
// }
} }

@ -47,6 +47,10 @@ public interface IDataMapper {
@Select({"SELECT \"Code\" FROM PITEMREVISION where RITEMS_TAGU=#{0,jdbcType=VARCHAR}"}) @Select({"SELECT \"Code\" FROM PITEMREVISION where RITEMS_TAGU=#{0,jdbcType=VARCHAR}"})
int getCode(String goodsCode); int getCode(String goodsCode);
@Update({"update CHINT_MATERIAL "+ @Update({"update CHINT_MATERIAL "+
"set \"PmpcCode\"=#{PmpcCode,jdbcType=VARCHAR}, "+ "set \"PmpcCode\"=#{PmpcCode,jdbcType=VARCHAR}, "+
"\"GoodsCode\"=#{GoodsCode,jdbcType=VARCHAR}, "+ "\"GoodsCode\"=#{GoodsCode,jdbcType=VARCHAR}, "+
@ -59,7 +63,8 @@ public interface IDataMapper {
"\"State\"=#{State,jdbcType=VARCHAR}, "+ "\"State\"=#{State,jdbcType=VARCHAR}, "+
"\"Time\"=to_date(#{time,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss') ,"+ "\"Time\"=to_date(#{time,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss') ,"+
"\"Condition\"='已通过', "+ "\"Condition\"='已通过', "+
"P_STATUS= '0' "+ "P_STATUS= '0', "+
"\"Specification\"=#{Specification,jdbcType=VARCHAR} "+
"WHERE \"Code\"=#{Code,jdbcType=VARCHAR}"}) "WHERE \"Code\"=#{Code,jdbcType=VARCHAR}"})
int updateMaterial2(MaterialBean material); int updateMaterial2(MaterialBean material);
@ -77,7 +82,8 @@ public interface IDataMapper {
"\"PUID\", " + "\"PUID\", " +
"\"Condition\", "+ "\"Condition\", "+
"P_STATUS, " + "P_STATUS, " +
"\"Time\""+ "\"Time\", " +
"\"Specification\""+
""+ ""+
"VALUES("+ "VALUES("+
"#{PmpcCode,jdbcType=VARCHAR}, "+ "#{PmpcCode,jdbcType=VARCHAR}, "+
@ -93,14 +99,13 @@ public interface IDataMapper {
"#{puid,jdbcType=VARCHAR}, "+ "#{puid,jdbcType=VARCHAR}, "+
"'已通过',"+ "'已通过',"+
"0,"+ "0,"+
"to_date(#{time,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss')"+ "to_date(#{time,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss'), "+
"#{Specification,jdbcType=VARCHAR}"+
")" ")"
) )
int insertMaterial(MaterialBean bean); int insertMaterial(MaterialBean bean);
@Update({"update CHINT_MATERIAL set \"Info\"=#{0,jdbcType=VARCHAR} where \"Code\" = #{1,jdbcType=INTEGER} "}) @Update({"update CHINT_MATERIAL set \"Info\"=#{0,jdbcType=VARCHAR} where \"Code\" = #{1,jdbcType=INTEGER} "})
int updateMaterialInfo(String info,int code); int updateMaterialInfo(String info,int code);
@ -149,6 +154,46 @@ public interface IDataMapper {
")"}) ")"})
int addMaterialNoCode(int code,String time); int addMaterialNoCode(int code,String time);
// @Select({"select " +
// "projectName, " +
// "projectNo, " +
// "projectState, " +
// "WBSName, " +
// "WBSNo, " +
// "netWorkNo, " +
// "netWorkName, " +
// "deliveryDate, " +
// "\"NUMBER\", "+
// "factory, "+
// "state, " +
// "projectManager, "+
// "projectSource, "+
// "userIndustry, "+
// "\"projectYN\", "+
// "\"planYN\", "+
// "isImportant "+
// "from chint_pm_project " +
// "where netWorkNo = #{0,jdbcType=VARCHAR} "})
// List<DB_PROJECT> queryProject(String netWorkNo);
//
// @Update({"update chint_pm_project " +
// "set state = #{1,jdbcType=VARCHAR}, " +
// "\"DATE\"=to_date(#{2,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss'), "+
// "factory= #{3,jdbcType=VARCHAR} " +
// "where netWorkNo = #{0,jdbcType=VARCHAR}"
// })
// int updateProjectState(String netWorkNo,String state,String time,String factory);
@Update({"update chint_pm_project " +
"set state = #{1,jdbcType=VARCHAR}, " +
"\"DATE\"=to_date(#{2,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss'), "+
"factory= #{3,jdbcType=VARCHAR} " +
"where netWorkNo = #{0,jdbcType=VARCHAR}"
})
int updateProjectState(String netWorkNo,String state,String time,String factory);
@Select({"select " + @Select({"select " +
"projectName, " + "projectName, " +
"projectNo, " + "projectNo, " +
@ -171,13 +216,8 @@ public interface IDataMapper {
"where netWorkNo = #{0,jdbcType=VARCHAR} "}) "where netWorkNo = #{0,jdbcType=VARCHAR} "})
List<DB_PROJECT> queryProject(String netWorkNo); List<DB_PROJECT> queryProject(String netWorkNo);
@Update({"update chint_pm_project " +
"set state = #{1,jdbcType=VARCHAR}, " +
"\"DATE\"=to_date(#{2,jdbcType=VARCHAR},'yyyy-mm-dd HH24:mi:ss'), "+
"factory= #{3,jdbcType=VARCHAR} " +
"where netWorkNo = #{0,jdbcType=VARCHAR}"
})
int updateProjectState(String netWorkNo,String state,String time,String factory);
@Insert({ "insert into chint_pm_project(" + @Insert({ "insert into chint_pm_project(" +
"projectName, " + "projectName, " +
@ -250,7 +290,7 @@ public interface IDataMapper {
"site, "+ "site, "+
"tankNo, "+ "tankNo, "+
"unit, "+ "unit, "+
"quantity "+ "quantity,factoryno "+
") values(" + ") values(" +
"#{netWorkNo,jdbcType=VARCHAR}, " + "#{netWorkNo,jdbcType=VARCHAR}, " +
"#{materialNo,jdbcType=VARCHAR}, " + "#{materialNo,jdbcType=VARCHAR}, " +
@ -258,12 +298,12 @@ public interface IDataMapper {
"#{site,jdbcType=VARCHAR}, "+ "#{site,jdbcType=VARCHAR}, "+
"#{tankNo,jdbcType=VARCHAR}, "+ "#{tankNo,jdbcType=VARCHAR}, "+
"#{unit,jdbcType=VARCHAR},"+ "#{unit,jdbcType=VARCHAR},"+
"#{quantity,jdbcType=VARCHAR}"+ "#{quantity,jdbcType=VARCHAR},"+
"#{factoryNo,jdbcType=VARCHAR}"+
")" }) ")" })
int addProductData(DB_PRODUCT product); int addProductData(DB_PRODUCT product);
@Select({"select " + @Select({"select " +
"t.UNV8_PROJECT_ID item," + "t.UNV8_PROJECT_ID item," +
"t.UNV8_EFFECTIVE_PROCESS formId," + "t.UNV8_EFFECTIVE_PROCESS formId," +
@ -531,4 +571,63 @@ public interface IDataMapper {
) )
int insertECR(ECRBean ecrBean); int insertECR(ECRBean ecrBean);
@Select(value = {"select * "+
"from CHINT_DRAWING_TO_SRM_DETIALS "+
"where wbs=#{0,jdbcType=VARCHAR} and materialno=#{1,jdbcType=VARCHAR} order by code desc FETCH FIRST 1 ROW ONLY"})
List<SRMResultBean> querySRM_A(String wbs, String materialno);
@Select(value = {"select * " +
"from CHINT_DRAWING_TO_SRM_DETIALS "+
"where wbs=#{0,jdbcType=VARCHAR} and materialno=#{1,jdbcType=VARCHAR} and revision=#{2,jdbcType=VARCHAR} order by code desc FETCH FIRST 1 ROW ONLY"})
List<SRMResultBean> querySRM_B(String wbs, String materialno, String revision);
// @Select(value = {"select * " +
// "from CHINT_DRAWING_TO_SRM_DETIALS "+
// "where wbs=#{wbs} and materialno=#{materialno} and factory=#{factory} order by code desc"})
// List<SRMResultBean> GetDrawingUrlAllVersion(@Param("wbs")String wbs, @Param("materialno")String materialno,@Param("factory")String factory);
List<SRMResultBean> GetDrawingUrlAllVersion(@Param("wbs")String wbs, @Param("materialno")String materialno,@Param("factory")String factory);
// @Select(value = {"select * " +
// "from CHINT_DRAWING_TO_SRM_DETIALS "+
// "where wbs=#{wbs} and materialno=#{materialno} and revision=#{revision} and factory=#{factory} order by code desc FETCH FIRST 1 ROW ONLY"})
// List<SRMResultBean> GetDrawingUrlVersion(@Param("wbs")String wbs, @Param("materialno")String materialno, @Param("revision")String revision,@Param("factory")String factory);
List<SRMResultBean> GetDrawingUrlVersion(@Param("wbs")String wbs, @Param("materialno")String materialno, @Param("revision")String revision,@Param("factory")String factory);
// @Select(value = {"select * " +
// "from CHINT_DRAWING_TO_SRM_DETIALS "+
// "where wbs=#{wbs} and materialno=#{materialno} and factory=#{factory} order by code desc FETCH FIRST 1 ROW ONLY"})
// List<SRMResultBean> GetDrawingUrlLatestVersion(@Param("wbs")String wbs, @Param("materialno")String materialno,@Param("factory")String factory);
//
List<SRMResultBean> GetDrawingUrlLatestVersion(@Param("wbs")String wbs, @Param("materialno")String materialno,@Param("factory")String factory);
@Insert("insert into CHINT_DRAWING_TO_SRM_DETIALS(fileurl,materialno,wbs,revision,factory,objectname,drawingno,urlstatus,released,datesetname,createtime,updatetime,urlcreatetime)" +
"values(#{fileurl},#{materialno},#{wbs},#{revision},#{factory},#{objectname},#{drawingno},#{urlstatus},#{released},#{datesetname},#{createtime},#{updatetime},#{urlcreatetime})")
int insertSRM_DETIALS(@Param("fileurl")String fileurl,@Param("wbs")String wbs, @Param("materialno")String materialno, @Param("revision")String revision,@Param("factory")String factory,@Param("objectname")String objectname,@Param("drawingno")String drawingno,@Param("urlstatus")String urlstatus,@Param("released")String released,@Param("datesetname")String datesetname,@Param("createtime")String createtime,@Param("updatetime")String updatetime,@Param("urlcreatetime")String urlcreatetime);
// @Select(value = {"select * " +
// "from CHINT_DRAWING_TO_SRM_DETIALS "+
// "where wbs=#{wbs} and materialno=#{materialno} and revision=#{version} and factory=#{factory} and factoryno=#{factoryno} and procuretype=#{procuretype} order by code desc FETCH FIRST 1 ROW ONLY"})
// List<SRMResultBean> GetProcure(@Param("wbs")String wbs, @Param("materialno")String materialno, @Param("version")String version,@Param("factory")String factory,@Param("factoryno")String factoryno,@Param("procuretype")String procuretype);
List<SRMResultBean> GetProcure(@Param("wbs")String wbs, @Param("materialno")String materialno, @Param("version")String version,@Param("factory")String factory,@Param("factoryno")String factoryno,@Param("procuretype")String procuretype);
@Select("select code from CHINT_DRAWING_TO_SRM_DETIALS where materialno=#{materialno} and revision=#{revision} and factory=#{factory} order by code desc FETCH FIRST 1 ROW ONLY")
String querySRMCode(@Param("materialno")String materialno, @Param("revision")String revision,@Param("factory")String factory);
@Delete("delete from CHINT_DRAWING_TO_SRM_DETIALS where code=#{code}")
int deleteSRM(@Param("code")String code);
@Insert("insert into CHINT_DRAWING_TO_SRM_DETIALS(code,fileurl,materialno,wbs,revision,factory,objectname,drawingno,urlstatus,released,datesetname,createtime,updatetime,urlcreatetime)" +
"values(#{code},#{fileurl},#{materialno},#{wbs},#{revision},#{factory},#{objectname},#{drawingno},#{urlstatus},#{released},#{datesetname},#{createtime},#{updatetime},#{urlcreatetime})")
int insertSRM_code_DETIALS(@Param("code")String code,@Param("fileurl")String fileurl,@Param("wbs")String wbs, @Param("materialno")String materialno, @Param("revision")String revision,@Param("factory")String factory,@Param("objectname")String objectname,@Param("drawingno")String drawingno,@Param("urlstatus")String urlstatus,@Param("released")String released,@Param("datesetname")String datesetname,@Param("createtime")String createtime,@Param("updatetime")String updatetime,@Param("urlcreatetime")String urlcreatetime);
} }

@ -0,0 +1,60 @@
package com.connor.web.service;
//import com.teamcenter.clientx.AppXSession;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.internal.loose.core.ICTService;
import com.teamcenter.services.internal.loose.core._2011_06.ICT.Arg;
import com.teamcenter.services.internal.loose.core._2011_06.ICT.InvokeICTMethodResponse;
import com.teamcenter.soa.client.Connection;
public class ICCTUserService {
private ICTService m_service;
// public ICCTUserService() {
// m_service = ICTService.getService( AppXSession.getConnection() );
// }
public ICCTUserService(Connection connection) {
m_service = ICTService.getService( connection );
}
public void getMethodParameters(String methodName, longSeqValue_uHolder argumentTypeList, IntHolder returnParameterType){
Arg[] args_ = new Arg[1];
args_[0] = TcUtility.createArg(methodName);
InvokeICTMethodResponse response = null;
try {
response = m_service.invokeICTMethod("ICCTUserService", "getMethodParameters", args_);
} catch (ServiceException e) {
e.printStackTrace();
//LogHelper.Error(ICCTUserService.class, "调用 ICCTUserService,getMethodParameters错误",e);
return;
}
// if( TCSoaUtil.checkServicedataHaveError(response.serviceData))
// {
// return;
// }
argumentTypeList.value = TcUtility.queryArg(response.output[0], argumentTypeList.value);
returnParameterType.value = TcUtility.queryArg(response.output[1], returnParameterType.value);
}
public void callMethod(String methodName, stringSeqValue_u marshalledArguments, StringHolder returnValue) {
Arg[] args_ = new Arg[2];
args_[0] = TcUtility.createArg(methodName);
args_[1] = TcUtility.createArg(marshalledArguments);
InvokeICTMethodResponse response = null;
try {
response = m_service.invokeICTMethod("ICCTUserService", "callMethod", args_);
} catch (ServiceException e) {
//LogHelper.Error(ICCTUserService.class, "调用 ICCTUserService,callMethod错误",e);
e.printStackTrace();
}
if( response.serviceData.sizeOfPartialErrors() > 0)
{
return;
}
returnValue.value = TcUtility.queryArgStringUnion(response.output[0], returnValue.value);
}
}

@ -0,0 +1,14 @@
package com.connor.web.service;
public class IntHolder {
public int value = 0;
public IntHolder() {
}
public IntHolder(int value) {
this.value = value;
}
}

@ -1,20 +1,28 @@
package com.connor.web.service; package com.connor.web.service;
//import com.connor.rb.savadata.pojo.*; //import com.connor.rb.savadata.pojo.*;
import com.alibaba.fastjson2.JSON;
import com.connor.web.bean.*; import com.connor.web.bean.*;
import org.apache.commons.io.FileUtils;
import com.connor.web.controller.QuotationController; import com.connor.web.controller.QuotationController;
import com.connor.web.mapper.IDataMapper; import com.connor.web.mapper.IDataMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
//import com.teamcenter.soa.client.model.strong.Session; //import com.teamcenter.soa.client.model.strong.Session;
import com.squareup.okhttp.*; import com.squareup.okhttp.*;
import com.teamcenter.clientx.Session; import com.teamcenter.clientx.Session;
import com.teamcenter.services.strong.core.DataManagementService; import com.teamcenter.services.strong.core.DataManagementService;
//import com.teamcenter.services.strong.workflow.WorkflowService; //import com.teamcenter.services.strong.workflow.WorkflowService;
//import com.teamcenter.services.strong.workflow._2014_06.Workflow; //import com.teamcenter.services.strong.workflow._2014_06.Workflow;
import com.teamcenter.services.strong.query.SavedQueryService;
import com.teamcenter.services.strong.query._2007_09.SavedQuery;
import com.teamcenter.soa.client.FileManagementUtility;
import com.teamcenter.soa.client.GetFileResponse;
import com.teamcenter.soa.client.model.ModelObject; import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.Property;
import com.teamcenter.soa.client.model.ServiceData; import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.EPMTask; import com.teamcenter.soa.client.model.strong.*;
import com.teamcenter.soa.client.model.strong.User; import com.teamcenter.soa.exceptions.NotLoadedException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -22,19 +30,34 @@ import org.springframework.boot.configurationprocessor.json.JSONArray;
import org.springframework.boot.configurationprocessor.json.JSONObject; import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date; import java.util.*;
import java.util.HashMap; import java.util.regex.Matcher;
import java.util.List; import java.util.regex.Pattern;
import java.util.Map; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.connor.web.config.Config; import com.connor.web.config.Config;
import com.connor.web.util.TCUtil; import com.connor.web.util.TCUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@Service @Service
public class QuotationService { public class QuotationService {
@Autowired @Autowired
private IDataMapper dataMapper; private IDataMapper dataMapper;
private static final Logger logger = LoggerFactory.getLogger(QuotationController.class); private static final Logger logger = LoggerFactory.getLogger(QuotationController.class);
public void saveQuotation(QuotationDTO quotationDTO) throws Exception { public void saveQuotation(QuotationDTO quotationDTO) throws Exception {
// 解析并保存CHINT_QUOTATION_TITLE_TEMPLATE数据 // 解析并保存CHINT_QUOTATION_TITLE_TEMPLATE数据
Quotation quotation = new Quotation(); Quotation quotation = new Quotation();
@ -91,16 +114,20 @@ public class QuotationService {
} }
} }
} }
public static void logMsg(String msg) { public static void logMsg(String msg) {
TCUtil.log(logger, msg); TCUtil.log(logger, msg);
} }
//工装需求 //工装需求
public void saveGzxq(GZXQBean gzxqBean) throws Exception { public void saveGzxq(GZXQBean gzxqBean) throws Exception {
dataMapper.insertGzxq(gzxqBean); dataMapper.insertGzxq(gzxqBean);
} }
@Autowired @Autowired
private Config config; private Config config;
//工装需求 //工装需求
public void saveSapResult(List<SapResult> results) { public void saveSapResult(List<SapResult> results) {
// Session session = new Session(config.getTc_url()); // Session session = new Session(config.getTc_url());
@ -246,4 +273,907 @@ public class QuotationService {
// } // }
// } // }
public String querySRM(String wbsno, String materialno, String version) throws Exception {
JSONObject result = new JSONObject();
//参数非空判断
if (wbsno == null || wbsno.isEmpty()) {
result.put("code", -1);
result.put("msg", "wbsno不能为空");
return result.toString();
}
if (materialno == null || materialno.isEmpty()) {
result.put("code", -1);
result.put("msg", "materialno不能为空");
return result.toString();
}
if (version == null || version.isEmpty()) {
List<SRMResultBean> srmResultBeans_A = dataMapper.querySRM_A(wbsno, materialno);
if (srmResultBeans_A.size() > 0) {
SRMResultBean srmResultBean = srmResultBeans_A.get(0);
result.put("code", "1");
result.put("msg", "成功");
result.put("factory", srmResultBean.getFactory());
JSONArray jsonArray = new JSONArray();
//数组里的json 11
JSONObject innerJson = new JSONObject();
innerJson.put("materialno", srmResultBean.getMaterialno());
innerJson.put("wbsno", srmResultBean.getWbs());
innerJson.put("version", srmResultBean.getRevision());
innerJson.put("fileurl", srmResultBean.getFileurl());
jsonArray.put(innerJson);
result.put("lists", jsonArray);
}
} else {
List<SRMResultBean> srmResultBeans_B = dataMapper.querySRM_B(wbsno, materialno, version);
if (srmResultBeans_B.size() > 0) {
SRMResultBean srmResultBean = srmResultBeans_B.get(0);
result.put("code", "1");
result.put("msg", "成功");
result.put("factory", srmResultBean.getFactory());
JSONArray jsonArray = new JSONArray();
//数组里的json
JSONObject innerJson = new JSONObject();
innerJson.put("materialno", srmResultBean.getMaterialno());
innerJson.put("wbsno", srmResultBean.getWbs());
innerJson.put("version", srmResultBean.getRevision());
innerJson.put("fileurl", srmResultBean.getFileurl());
jsonArray.put(innerJson);
result.put("lists", jsonArray);
}
}
return result.toString();
}
public List<SRMResultBean> GetDrawingUrl(String factory, String wbs, String materialno, String versionall, String revision) throws Exception {
List<SRMResultBean> srmResultBeans = null;
if (versionall != null && versionall.equals("Y")) {
//所有版本
// List<SRMResultBean> srmResultBeans1 = new ArrayList<>();
// srmResultBeans1.add(new SRMResultBean("1111111"));
// srmResultBeans = srmResultBeans1;
srmResultBeans = dataMapper.GetDrawingUrlAllVersion(wbs, materialno, factory);
if (srmResultBeans == null || srmResultBeans.size() == 0) {
srmResultBeans = dataMapper.GetDrawingUrlAllVersion("", materialno, factory);
}
} else {
if (revision != null && !revision.isEmpty()) {
// List<SRMResultBean> srmResultBeans1 = new ArrayList<>();
// srmResultBeans1.add(new SRMResultBean("33333333"));
// srmResultBeans1.add(new SRMResultBean("2222222"));
// srmResultBeans = srmResultBeans1;
//匹配版本
srmResultBeans = dataMapper.GetDrawingUrlVersion(wbs, materialno, revision, factory);
if (srmResultBeans == null || srmResultBeans.size() == 0) {
srmResultBeans = dataMapper.GetDrawingUrlVersion("", materialno, revision, factory);
}
} else {
//最新版本
srmResultBeans = dataMapper.GetDrawingUrlLatestVersion(wbs, materialno, factory);
if (srmResultBeans == null || srmResultBeans.size() == 0) {
srmResultBeans = dataMapper.GetDrawingUrlLatestVersion("", materialno, factory);
}
if (srmResultBeans.size() > 1) {//查出多条取最新版本
//最新版本
SRMResultBean newRevSrmResultBean = null;
newRevSrmResultBean = srmResultBeans.get(0);
for (int i = 1; i < srmResultBeans.size(); i++) {
SRMResultBean tempSrmResultBean = srmResultBeans.get(i);
if (compareVersions(tempSrmResultBean.getRevision(), newRevSrmResultBean.getRevision()) >= 1) {
newRevSrmResultBean = tempSrmResultBean;
}
}
srmResultBeans = new ArrayList<>();
srmResultBeans.add(newRevSrmResultBean);
}
}
}
//用物料号调用tc查询 下发图纸
if (srmResultBeans == null || srmResultBeans.size() <= 0) {
//调用查询
System.out.println("判断进来了");
Session session = new Session(config.getTc_url());
User user = session.login2(config.getTc_user(), config.getTc_pwd());
if (user == null) {
throw new Exception("Teamcenter SOA登录失败");
}
System.out.println("登入成功");
//获取首选项 CHINT_SRM_URL
String[] pref = TCUtil.getPrefVals("CHINT_SRM_URL");
String url;
String path;
if (pref.length == 2) {
url = pref[0];
path = pref[1];
} else {
throw new Exception("CHINT_SRM_URL首选项配置不正确");
}
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
//SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//查询
SavedQueryService queryService = SavedQueryService.getService(session.getConnection());
com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse savedQueries1 = queryService.getSavedQueries();
if (savedQueries1.queries.length == 0) {
throw new Exception("系统中没有保存的查询");
}
ImanQuery query = null;
for (com.teamcenter.services.strong.query._2006_03.SavedQuery.SavedQueryObject queryObj : savedQueries1.queries) {
if (queryObj.name.equals("chint_query_material_srm")) {
query = queryObj.query;
}
}
if (query == null) {
throw new Exception("没有找到查询chint_query_material_srm");
}
SavedQuery.QueryInput queryInput =
new com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryInput();
queryInput.query = query;
queryInput.entries = new String[]{"materialno"};
queryInput.values = new String[]{materialno};
queryInput.maxNumToReturn = 2;
com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse queryResp =
queryService.executeSavedQueries(
new com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryInput[]{queryInput});
com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults queryResults =
queryResp.arrayOfResults[0];
int cnt = queryResults.objectUIDS.length;
System.out.println("cnt============" + cnt);
System.out.println("参数的查询个数============" + cnt);
if (cnt > 0) {
//iterator.remove();
String userUid = queryResults.objectUIDS[0];
ServiceData serviceData = dataManagementService.loadObjects(new String[]{userUid});
//物料对象
ItemRevision wlRev = (ItemRevision) serviceData.getPlainObject(0);
//物料对象获取所有发布图纸对象
dataManagementService.getProperties(new ModelObject[]{wlRev}, new String[]{"TC_Is_Represented_By"});
Property wlProp = wlRev.getPropertyObject("TC_Is_Represented_By");
ModelObject[] wlObjs = wlProp.getModelObjectArrayValue();
HashMap<String, ItemRevision> tzMap = new HashMap<String, ItemRevision>();
dataManagementService.getProperties(wlObjs, new String[]{"item_revision_id", "release_status_list"});
System.out.println("--------------------图纸个数============" + wlObjs.length);
for (ModelObject wlObj : wlObjs) {
//所有版本
ItemRevision tzRev = (ItemRevision) wlObj;
//判断版本是否发布
ReleaseStatus[] rs = tzRev.get_release_status_list();
if (rs != null && rs.length > 0) {
if (versionall != null && versionall.equals("Y")) {
String item_revision_id = tzRev.get_item_revision_id();
System.out.println("mappppppppppppppppp================" + item_revision_id);
System.out.println(" tzRev.getUid()======" + tzRev.getUid());
tzMap.put(item_revision_id, tzRev);
} else if (revision != null && !revision.isEmpty()) {//匹配版本
String item_revision_id = tzRev.get_item_revision_id();
if (revision.equals(item_revision_id)) {
tzMap.put(item_revision_id, tzRev);
}
} else {
ItemRevision latestReleasedRev = TCUtil.getLatestReleasedRev(dataManagementService, tzRev.get_items_tag());
dataManagementService.getProperties(new ModelObject[]{latestReleasedRev}, new String[]{"item_revision_id"});
String item_revision_id = latestReleasedRev.get_item_revision_id();
tzMap.put(item_revision_id, latestReleasedRev);
}
}
}
System.out.println("--------------------发布图纸个数============" + tzMap.size());
for (Map.Entry<String, ItemRevision> map : tzMap.entrySet()
) {
ItemRevision designRev = map.getValue();
//获取图纸下的PDF对象
dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"IMAN_specification", "item_revision_id", "object_name", "item_id", "zt2_WBSNo"});
Property dsProp = designRev.getPropertyObject("IMAN_specification");
String tzRevision = designRev.get_item_revision_id();
ModelObject[] dsObjs = dsProp.getModelObjectArrayValue();
if (dsObjs == null || dsObjs.length == 0) {
System.out.println("通过" + "IMAN_specification" + "关系未找到对象");
return srmResultBeans;
}
dataManagementService.refreshObjects(dsObjs);
dataManagementService.getProperties(dsObjs, new String[]{"object_type", "object_name", "object_string", "object_desc", "ref_list", "creation_date", "last_mod_date"});
//循环一遍查看pdf个数
int count = 0;
for (int d = 0; d < dsObjs.length; d++) {
if (dsObjs[d] instanceof Dataset) {
Dataset ds = (Dataset) dsObjs[d];
String object_type = ds.get_object_type();
if (object_type.equals("PDF")) {
count++;
}
}
}
if (count <= 1) {
for (int d = 0; d < dsObjs.length; d++) {
if (dsObjs[d] instanceof Dataset) {
Dataset ds = (Dataset) dsObjs[d];
String object_type = ds.get_object_type();
if (object_type.equals("PDF")) {
ModelObject[] ref_list = ds.get_ref_list();
ModelObject object = ref_list[0];
dataManagementService.getProperties(ref_list, new String[]{"original_file_name"});
String datasetName = object.getPropertyDisplayableValue("original_file_name");
//创建文件夹
String finalPath = createDirectoryByDate(path);
//文件下载到指定路径
File outFile = downloadFileFromDataset(ds, dataManagementService, finalPath);
if (outFile == null || !outFile.exists()) {
System.out.println("没找到PDF");
return srmResultBeans;
}
//获取srm后面的信息
System.out.println("outFile.getAbsolutePath()================" + outFile.getAbsolutePath());
int startIndex = outFile.getAbsolutePath().indexOf("SRM") + 4; // 找到 "SRM" 后面的位置
System.out.println("startIndex================" + startIndex);
String subPath = outFile.getAbsolutePath().substring(startIndex);
//在数据库中插入一条srm数据
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//String creation_date = sdf.format(ds.get_creation_date());
//String last_mod_date = sdf.format(ds.get_last_mod_date());
String newDare = sdf.format(new Date());
//插入之前判断 工厂+物料号+版本 有没有对应数据
String code = dataMapper.querySRMCode(materialno, revision, factory);
System.out.println("code================================" + code);
//把\改成/
String urlPath = url + subPath;
urlPath = urlPath.replace("\\\\", "/");
urlPath = urlPath.replace("\\", "/");
if (code != null && !code.isEmpty()) {
dataMapper.deleteSRM(code);
dataMapper.insertSRM_code_DETIALS(code, urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
} else {
dataMapper.insertSRM_DETIALS(urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
}
//发送接口
//拼接json
// // 创建OkHttpClient
// OkHttpClient client = new OkHttpClient();
//
// // 创建MediaType对象
// MediaType mediaType = MediaType.parse("text/xml");
// RequestBody body = RequestBody.create(mediaType, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n\t<SOAP-ENV:Body>\r\n\t\t<m:PurchasingAttachmentInfoSync xmlns:m=\"http://tempuri.org/\">\r\n\t\t\t<m:data>\r\n{\r\n \"ecncode\": \"\",\r\n \"factory\": \"M060\",\r\n \"procurelists\": [{\r\n \"factoryno\": \"出厂编号\",\r\n \"procuretypes\": [{\r\n \"owninguser\": \"所有者\",\r\n \"procuretype\": \"采购附件类型\",\r\n \"url\": \"采购附件链接\",\r\n \"version\": \"采购附件版本信息\"\r\n },{\r\n \"owninguser\": \"所有者\",\r\n \"procuretype\": \"采购附件类型\",\r\n \"url\": \"采购附件链接\",\r\n \"version\": \"采购附件版本信息\"\r\n }] ,\r\n\"productno\": \"产成品物料编码清单\",\r\n \"wbsno\": \"wbs\"\r\n }\r\n ]\r\n}\r\n\t\t\t</m:data>\r\n\t\t</m:PurchasingAttachmentInfoSync>\r\n\t</SOAP-ENV:Body>\r\n</SOAP-ENV:Envelope>");
// Request request = new Request.Builder()
// .url("http://10.128.10.163:8082/IS/PLMWebService.asmx?wsdl")
// .method("POST", body)
// .addHeader("Content-Type", "text/xml")
// .addHeader("Cookie", "ASP.NET_SessionId=xoofq3wijpcs1rdcakq4lcl1")
// .build();
// Response response = client.newCall(request).execute();
// String responseBody = response.body().string();
// System.out.println(responseBody);
//
// //解析返回值
// try {
// DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder builder = docFactory.newDocumentBuilder();
// Document doc = builder.parse(new InputSource(new StringReader(responseBody)));
//
// NodeList resultNodes = doc.getElementsByTagName("PurchasingAttachmentInfoSyncResult");
// Node resultNode = resultNodes.item(0);
//
// String resultText = resultNode.getTextContent();
// System.out.println("resultText==="+resultText);
//
// com.alibaba.fastjson2.JSONObject jsonObject = JSON.parseObject(resultText);
// String resultCode = jsonObject.getString("code");
// String msg = jsonObject.getString("msg");
// System.out.println("code: " + resultCode+"---------------msg: " + msg);
// } catch (Exception e) {
// e.printStackTrace();
// }
//
srmResultBeans.add(new SRMResultBean(materialno, designRev.getPropertyDisplayableValue("zt2_WBSNo"), tzRevision, urlPath, factory));
}
}
}
} else {
String datasetName = "";
ArrayList<String> list = new ArrayList<String>();
//创建文件夹
String finalPath = createDirectoryByDate(path);
for (int d = 0; d < dsObjs.length; d++) {
if (dsObjs[d] instanceof Dataset) {
Dataset ds = (Dataset) dsObjs[d];
String object_type = ds.get_object_type();
if (object_type.equals("PDF")) {
ModelObject[] ref_list = ds.get_ref_list();
ModelObject object = ref_list[0];
dataManagementService.getProperties(ref_list, new String[]{"original_file_name"});
datasetName = object.getPropertyDisplayableValue("original_file_name");
//文件下载到指定路径
File outFile = downloadFileFromDataset(ds, dataManagementService, finalPath);
System.out.println("outFile.getAbsolutePath()================" + outFile.getAbsolutePath());
list.add(outFile.getAbsolutePath());
if (outFile == null || !outFile.exists()) {
System.out.println("没找到PDF");
return srmResultBeans;
}
}
}
}
//获取srm后面的信息
String zipPath = finalPath + "/" + designRev.get_item_id() + "-" + designRev.get_object_name() + ".zip";
System.out.println("zipPath===============================" + zipPath);
compressMultipleFilesToZip(list.toArray(new String[0]), zipPath);
int startIndex = zipPath.indexOf("SRM") + 4; // 找到 "SRM" 后面的位置
String subPath = zipPath.substring(startIndex);
//在数据库中插入一条srm数据
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//String creation_date = sdf.format(ds.get_creation_date());
//String last_mod_date = sdf.format(ds.get_last_mod_date());
String newDare = sdf.format(new Date());
//插入之前判断 工厂+物料号+版本 有没有对应数据
String code = dataMapper.querySRMCode(materialno, revision, factory);
System.out.println("code================================" + code);
//把\改成/
String urlPath = url + subPath;
urlPath = urlPath.replace("\\\\", "/");
urlPath = urlPath.replace("\\", "/");
if (code != null && !code.isEmpty()) {
dataMapper.deleteSRM(code);
dataMapper.insertSRM_code_DETIALS(code, urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
} else {
dataMapper.insertSRM_DETIALS(urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
}
srmResultBeans.add(new SRMResultBean(materialno, designRev.getPropertyDisplayableValue("zt2_WBSNo"), tzRevision, urlPath, factory));
}
}
}
}
//20240819加逻辑
if (srmResultBeans != null && srmResultBeans.size() > 0 && versionall != null && versionall.equalsIgnoreCase("Y")) {
//调用查询
System.out.println("判断进来了");
Session session = new Session(config.getTc_url());
User user = session.login2(config.getTc_user(), config.getTc_pwd());
if (user == null) {
throw new Exception("Teamcenter SOA登录失败");
}
System.out.println("登入成功");
//获取首选项 CHINT_SRM_URL
String[] pref = TCUtil.getPrefVals("CHINT_SRM_URL");
String url;
String path;
if (pref.length == 2) {
url = pref[0];
path = pref[1];
} else {
throw new Exception("CHINT_SRM_URL首选项配置不正确");
}
DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection());
//SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//查询
SavedQueryService queryService = SavedQueryService.getService(session.getConnection());
com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse savedQueries1 = queryService.getSavedQueries();
if (savedQueries1.queries.length == 0) {
throw new Exception("系统中没有保存的查询");
}
ImanQuery query = null;
for (com.teamcenter.services.strong.query._2006_03.SavedQuery.SavedQueryObject queryObj : savedQueries1.queries) {
if (queryObj.name.equals("chint_query_material_srm")) {
query = queryObj.query;
}
}
if (query == null) {
throw new Exception("没有找到查询chint_query_material_srm");
}
SavedQuery.QueryInput queryInput =
new com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryInput();
queryInput.query = query;
queryInput.entries = new String[]{"materialno"};
queryInput.values = new String[]{materialno};
queryInput.maxNumToReturn = 2;
com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse queryResp =
queryService.executeSavedQueries(
new com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryInput[]{queryInput});
com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults queryResults =
queryResp.arrayOfResults[0];
int cnt = queryResults.objectUIDS.length;
System.out.println("cnt============" + cnt);
System.out.println("参数的查询个数============" + cnt);
if (cnt > 0) {
//iterator.remove();
String userUid = queryResults.objectUIDS[0];
ServiceData serviceData = dataManagementService.loadObjects(new String[]{userUid});
//物料对象
ItemRevision wlRev = (ItemRevision) serviceData.getPlainObject(0);
//物料对象获取所有发布图纸对象
dataManagementService.getProperties(new ModelObject[]{wlRev}, new String[]{"TC_Is_Represented_By"});
Property wlProp = wlRev.getPropertyObject("TC_Is_Represented_By");
ModelObject[] wlObjs = wlProp.getModelObjectArrayValue();
HashMap<String, ItemRevision> tzMap = new HashMap<String, ItemRevision>();
dataManagementService.getProperties(wlObjs, new String[]{"item_revision_id", "release_status_list"});
System.out.println("--------------------图纸个数============" + wlObjs.length);
ArrayList<String> versions = new ArrayList<>();
for (int i = 0; i < srmResultBeans.size(); i++) {
String tempRevision = srmResultBeans.get(i).getRevision();
versions.add(tempRevision);
}
System.out.println("versions===================" + versions);
for (ModelObject wlObj : wlObjs) {
//所有版本
ItemRevision tzRev = (ItemRevision) wlObj;
//判断版本是否发布
ReleaseStatus[] rs = tzRev.get_release_status_list();
if (rs != null && rs.length > 0) {
String item_revision_id = tzRev.get_item_revision_id();
if (!versions.contains(item_revision_id)) {
System.out.println("mappppppppppppppppp================" + item_revision_id);
System.out.println(" tzRev.getUid()======" + tzRev.getUid());
tzMap.put(item_revision_id, tzRev);
}
}
}
System.out.println("--------------------发布图纸个数============" + tzMap.size());
for (Map.Entry<String, ItemRevision> map : tzMap.entrySet()
) {
ItemRevision designRev = map.getValue();
//获取图纸下的PDF对象
dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"IMAN_specification", "item_revision_id", "object_name", "item_id", "zt2_WBSNo"});
Property dsProp = designRev.getPropertyObject("IMAN_specification");
String tzRevision = designRev.get_item_revision_id();
ModelObject[] dsObjs = dsProp.getModelObjectArrayValue();
if (dsObjs == null || dsObjs.length == 0) {
System.out.println("通过" + "IMAN_specification" + "关系未找到对象");
return srmResultBeans;
}
dataManagementService.refreshObjects(dsObjs);
dataManagementService.getProperties(dsObjs, new String[]{"object_type", "object_name", "object_string", "object_desc", "ref_list", "creation_date", "last_mod_date"});
//循环一遍查看pdf个数
int count = 0;
for (int d = 0; d < dsObjs.length; d++) {
if (dsObjs[d] instanceof Dataset) {
Dataset ds = (Dataset) dsObjs[d];
String object_type = ds.get_object_type();
if (object_type.equals("PDF")) {
count++;
}
}
}
if (count <= 1) {
for (int d = 0; d < dsObjs.length; d++) {
if (dsObjs[d] instanceof Dataset) {
Dataset ds = (Dataset) dsObjs[d];
String object_type = ds.get_object_type();
if (object_type.equals("PDF")) {
ModelObject[] ref_list = ds.get_ref_list();
ModelObject object = ref_list[0];
dataManagementService.getProperties(ref_list, new String[]{"original_file_name"});
String datasetName = object.getPropertyDisplayableValue("original_file_name");
//创建文件夹
String finalPath = createDirectoryByDate(path);
//文件下载到指定路径
File outFile = downloadFileFromDataset(ds, dataManagementService, finalPath);
if (outFile == null || !outFile.exists()) {
System.out.println("没找到PDF");
return srmResultBeans;
}
//获取srm后面的信息
System.out.println("outFile.getAbsolutePath()================" + outFile.getAbsolutePath());
int startIndex = outFile.getAbsolutePath().indexOf("SRM") + 4; // 找到 "SRM" 后面的位置
System.out.println("startIndex================" + startIndex);
String subPath = outFile.getAbsolutePath().substring(startIndex);
//在数据库中插入一条srm数据
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//String creation_date = sdf.format(ds.get_creation_date());
//String last_mod_date = sdf.format(ds.get_last_mod_date());
String newDare = sdf.format(new Date());
//插入之前判断 工厂+物料号+版本 有没有对应数据
String code = dataMapper.querySRMCode(materialno, revision, factory);
System.out.println("code================================" + code);
//把\改成/
String urlPath = url + subPath;
urlPath = urlPath.replace("\\\\", "/");
urlPath = urlPath.replace("\\", "/");
if (code != null && !code.isEmpty()) {
dataMapper.deleteSRM(code);
dataMapper.insertSRM_code_DETIALS(code, urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
} else {
dataMapper.insertSRM_DETIALS(urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
}
srmResultBeans.add(new SRMResultBean(materialno, designRev.getPropertyDisplayableValue("zt2_WBSNo"), tzRevision, urlPath, factory));
}
}
}
} else {
String datasetName = "";
ArrayList<String> list = new ArrayList<String>();
//创建文件夹
String finalPath = createDirectoryByDate(path);
for (int d = 0; d < dsObjs.length; d++) {
if (dsObjs[d] instanceof Dataset) {
Dataset ds = (Dataset) dsObjs[d];
String object_type = ds.get_object_type();
if (object_type.equals("PDF")) {
ModelObject[] ref_list = ds.get_ref_list();
ModelObject object = ref_list[0];
dataManagementService.getProperties(ref_list, new String[]{"original_file_name"});
datasetName = object.getPropertyDisplayableValue("original_file_name");
//文件下载到指定路径
File outFile = downloadFileFromDataset(ds, dataManagementService, finalPath);
System.out.println("outFile.getAbsolutePath()================" + outFile.getAbsolutePath());
list.add(outFile.getAbsolutePath());
if (outFile == null || !outFile.exists()) {
System.out.println("没找到PDF");
return srmResultBeans;
}
}
}
}
//获取srm后面的信息
String zipPath = finalPath + "/" + designRev.get_item_id() + "-" + designRev.get_object_name() + ".zip";
System.out.println("zipPath===============================" + zipPath);
compressMultipleFilesToZip(list.toArray(new String[0]), zipPath);
int startIndex = zipPath.indexOf("SRM") + 4; // 找到 "SRM" 后面的位置
String subPath = zipPath.substring(startIndex);
//在数据库中插入一条srm数据
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//String creation_date = sdf.format(ds.get_creation_date());
//String last_mod_date = sdf.format(ds.get_last_mod_date());
String newDare = sdf.format(new Date());
//插入之前判断 工厂+物料号+版本 有没有对应数据
String code = dataMapper.querySRMCode(materialno, revision, factory);
System.out.println("code================================" + code);
//把\改成/
String urlPath = url + subPath;
urlPath = urlPath.replace("\\\\", "/");
urlPath = urlPath.replace("\\", "/");
if (code != null && !code.isEmpty()) {
dataMapper.deleteSRM(code);
dataMapper.insertSRM_code_DETIALS(code, urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
} else {
dataMapper.insertSRM_DETIALS(urlPath, designRev.getPropertyDisplayableValue("zt2_WBSNo"), materialno, tzRevision, factory, designRev.get_object_name(), designRev.get_item_id(), "未同步", "0", datasetName, "", "", newDare);
}
srmResultBeans.add(new SRMResultBean(materialno, designRev.getPropertyDisplayableValue("zt2_WBSNo"), tzRevision, urlPath, factory));
}
}
}
}
return srmResultBeans;
}
public List<SRMResultBean> GetProcure(String wbs, String materialno, String version, String factory, String factoryno, String procuretype) throws Exception {
System.out.println(wbs + "=" + materialno + "=" + version + "=" + factory + "=" + factoryno + "=" + procuretype);
List<SRMResultBean> srmResultBeans = null;
srmResultBeans = dataMapper.GetProcure(wbs, materialno, version, factory, factoryno, procuretype);
if (srmResultBeans == null || srmResultBeans.size() == 0) {
srmResultBeans = dataMapper.GetProcure(wbs, materialno, version, factory, "", procuretype);
}
if (srmResultBeans == null || srmResultBeans.size() == 0) {
srmResultBeans = dataMapper.GetProcure(wbs, materialno, "", factory, "", procuretype);
}
if (version == null || version.isEmpty()) {
if (srmResultBeans.size() > 1) {//查出多条取最新版本
//最新版本
SRMResultBean newRevSrmResultBean = null;
newRevSrmResultBean = srmResultBeans.get(0);
for (int i = 1; i < srmResultBeans.size(); i++) {
SRMResultBean tempSrmResultBean = srmResultBeans.get(i);
if (compareVersions(tempSrmResultBean.getRevision(), newRevSrmResultBean.getRevision()) >= 1) {
newRevSrmResultBean = tempSrmResultBean;
}
}
srmResultBeans = new ArrayList<>();
srmResultBeans.add(newRevSrmResultBean);
}
}
// SqlSession sqlSession = MybatisUtils.getSqlSession();
//
// IDataMapper mapper = sqlSession.getMapper(IDataMapper.class);
// srmResultBeans = mapper.GetProcure();
return srmResultBeans;
}
//最新版本 版本判断逻辑问题需要用REVISION进行判断 V01-V02 , V01.001-V01.004-V02.001-V02.003 ,A-Z 如果都是字母直接比较如果带V+数字则去掉V进行比较如果带V+整数+点+整数,先判断第一个整数的大小,再判断第二个整数的大小,取到最新的版本)
private final Pattern VERSION_PATTERN = Pattern.compile("^(V)?(\\d+)(?:\\.(\\d+))?$");
public int compareVersions(String version1, String version2) {
Matcher matcher1 = VERSION_PATTERN.matcher(version1);
Matcher matcher2 = VERSION_PATTERN.matcher(version2);
if (!matcher1.matches() || !matcher2.matches()) {
return version1.compareTo(version2); // 直接比较非标准格式的版本
}
int major1 = Integer.parseInt(matcher1.group(2));
int major2 = Integer.parseInt(matcher2.group(2));
int result = Integer.compare(major1, major2);
if (result != 0) {
return result;
}
String minor1 = matcher1.group(3);
String minor2 = matcher2.group(3);
if (minor1 == null && minor2 == null) {
return 0;
} else if (minor1 == null) {
return -1;
} else if (minor2 == null) {
return 1;
} else {
int minor1Int = Integer.parseInt(minor1);
int minor2Int = Integer.parseInt(minor2);
return Integer.compare(minor1Int, minor2Int);
}
}
private File downloadFileFromDataset(Dataset pdf_dataset, DataManagementService dmService, String fileFullPath) throws NotLoadedException, IOException {
File outfile = null;
ModelObject[] refs = pdf_dataset.get_ref_list();
if (refs == null || refs.length == 0) {
System.out.println("没有引用数量,跳过");
return null;
}
System.out.println("下载数据集引用数量:" + refs.length);
dmService.refreshObjects(refs);
for (int r = 0; r < refs.length; r++) {
if (refs[r] instanceof ImanFile) {
ImanFile imanFile = (ImanFile) refs[r];
dmService.getProperties(new ModelObject[]{imanFile}, new String[]{"original_file_name"});
System.out.println("物理文件名:" + imanFile.get_original_file_name());
String[] fmsUrls = new String[]{config.getFms_url()};
FileManagementUtility fileManagementUtility = new FileManagementUtility(Session.getConnection(), null, null, fmsUrls, fileFullPath);
GetFileResponse getFileResponse = fileManagementUtility.getFiles(new ModelObject[]{imanFile});
File[] fileinfovec = getFileResponse.getFiles();
if (fileinfovec != null && fileinfovec.length > 0) {
System.out.println("文件数量:" + fileinfovec.length);
for (int j = 0; j < fileinfovec.length; j++) {
if (fileinfovec[j] != null) {
//文件下载路径
String filePath = String.format("%s/%s", fileFullPath, imanFile.get_original_file_name());
File newFile = new File(filePath);
FileUtils.copyFile(fileinfovec[j], newFile);
return newFile;
}
}
} else {
System.out.println("未获取到文件");
}
}
}
return outfile;
}
// public void getA() throws Exception {
//
// //调用查询
// System.out.println("判断进来了");
// Session session = new Session(config.getTc_url());
// User user = session.login2(config.getTc_user(), config.getTc_pwd());
// if (user == null) {
// throw new Exception("Teamcenter SOA登录失败");
// }
// System.out.println("登入成功");
//
//
//
//
// DataManagementService datamanagementservice = DataManagementService.getService(Session.getConnection());
//
// ServiceData serviceData = datamanagementservice.loadObjects(new String[]{"AThZHBiabJ7sDB"});
// //物料对象
// ItemRevision revision = (ItemRevision) serviceData.getPlainObject(0);
// datamanagementservice.refreshObjects2(new ModelObject[]{revision}, false);
// datamanagementservice.getProperties(new ModelObject[]{revision}, new String[]{"release_status_list"});
// //修改状态
// System.out.println("开始添加状态");
// WorkflowService workflowService = WorkflowService.getService(Session.getConnection());
// Workflow.ReleaseStatusInput[] releaseStatusInputs = new Workflow.ReleaseStatusInput[1];
// releaseStatusInputs[0] = new Workflow.ReleaseStatusInput();
// releaseStatusInputs[0].objects = new WorkspaceObject[]{revision};
// releaseStatusInputs[0].operations = new Workflow.ReleaseStatusOption[1];
// releaseStatusInputs[0].operations[0] = new Workflow.ReleaseStatusOption();
//
//
//
//
// ModelObject[] status_list = revision.get_release_status_list();
// int status_length = status_list==null?0:status_list.length;
// logger.info("发布状态数量:"+status_length);
// if(status_length>0){
// releaseStatusInputs[0].operations[0].operation = "Delete";
// workflowService.setReleaseStatus(releaseStatusInputs);
// logger.info("移除多余状态完成");
// }
//
//
//
// releaseStatusInputs[0].operations[0].newReleaseStatusTypeName = "Obsolete";
// releaseStatusInputs[0].operations[0].operation = "Append";
// Workflow.SetReleaseStatusResponse releaseResponse = workflowService.setReleaseStatus(releaseStatusInputs);
// System.out.println("结束添加状态");
// }
public static String createDirectoryByDate(String prePath) {
// 获取当前日期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/M/d");
String formattedDate = simpleDateFormat.format(new Date());
UUID uid = UUID.randomUUID();
formattedDate = formattedDate + "//" + uid.toString();
// 构建文件夹路径
Path path = Paths.get(prePath, formattedDate);
// 判断文件夹是否存在,如果不存在则创建
try {
if (!Files.exists(path)) {
Files.createDirectories(path);
System.out.println("目录 " + path + " 已创建。");
} else {
System.out.println("目录 " + path + " 已存在,无需创建。");
}
} catch (IOException e) {
e.printStackTrace();
}
return path.toString();
}
public static void compressMultipleFilesToZip(String[] fileNames, String zipFileName) throws IOException {
try (FileOutputStream fos = new FileOutputStream(zipFileName);
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos))) {
// 设置压缩流的编码避免非ASCII字符乱码问题如果文件名包含非ASCII字符
// zos.setEncoding("UTF-8");
for (String fileName : fileNames) {
File inputFile = new File(fileName);
if (inputFile.exists()) {
addToZipFile(inputFile, zos, inputFile.getName());
} else {
System.out.println("File " + fileName + " does not exist.");
}
}
// 完成压缩过程必要时写入ZIP文件的结尾部分
zos.finish();
}
}
private static void addToZipFile(File fileToZip, ZipOutputStream zos, String entryNameInZipFile) throws IOException {
FileInputStream fis = new FileInputStream(fileToZip);
ZipEntry zipEntry = new ZipEntry(entryNameInZipFile);
zos.putNextEntry(zipEntry);
byte[] bytes = new byte[1024];
int length;
while ((length = fis.read(bytes)) >= 0) {
zos.write(bytes, 0, length);
}
// 关闭当前条目
zos.closeEntry();
fis.close();
}
} }

@ -0,0 +1,16 @@
package com.connor.web.service;
public class StringHolder {
public String value = null;
public StringHolder() {
}
public StringHolder(String value) {
this.value = value;
}
}

@ -0,0 +1,104 @@
package com.connor.web.service;
import com.teamcenter.soa.client.Connection;
public class TCSoaUserService
{
private static final String BYPASS_METHOD = "ITK_server_bypass";
/**
*
* @return
*/
public static String openByPass(Connection connection){
return callUserSerivce(connection,BYPASS_METHOD,new Object[]{"true"});
}
/**
*
* @return
*/
public static String closeByPass(Connection connection){
return callUserSerivce(connection,BYPASS_METHOD,new Object[]{"false"});
}
/**
* UserService
* @param methodName
* @param marshalledArguments
* @return
*/
public static String callUserSerivce(Connection connection,String methodName, Object[] marshalledArguments)
{
ICCTUserService userService = new ICCTUserService(connection);
longSeqValue_uHolder holder1 = new longSeqValue_uHolder();
IntHolder localIntHolder = new IntHolder();
userService.getMethodParameters(methodName, holder1, localIntHolder);
int[] localObject1 = new int[0];
if (holder1.value.is_seqValue())
{
localObject1 = holder1.value.seqValue();
}
String[] values = new String[marshalledArguments.length];
values = marshallArguments(localObject1, marshalledArguments);
stringSeqValue_u localObject2 = new stringSeqValue_u();
localObject2.seqValue(values);
StringHolder localObject3 = new StringHolder();
userService.callMethod(methodName,localObject2,localObject3);
return localObject3.value;
}
private static String[] marshallArguments(int[] paramArrayOfInt, Object[] paramArrayOfObject)
{
int i = paramArrayOfObject.length;
String[] arrayOfString = new String[i];
for (int j = 0; j < i; j++) {
if (isArrayType(paramArrayOfInt[j])) {
//arrayOfString[j] = marshallArrayValue(paramArrayOfInt[j], paramArrayOfObject[j]);
} else {
arrayOfString[j] = marshallValue(paramArrayOfInt[j], paramArrayOfObject[j]);
}
}
return arrayOfString;
}
private static String marshallValue(int paramInt, Object paramObject)
{
String localObject1 = "";
switch (paramInt)
{
case 5:
int localInteger = (int)paramObject;
localObject1 = localInteger +"";
break;
case 8:
String str1 = (String)paramObject;
localObject1 = str1;
break;
default:
break;
}
return localObject1;
}
private static boolean isArrayType(int paramInt)
{
boolean isok = false;
if (paramInt > 100) {
isok = true;
}
return isok;
}
}

@ -0,0 +1,191 @@
package com.connor.web.service;
import com.teamcenter.services.internal.loose.core._2011_06.ICT.Arg;
import com.teamcenter.services.internal.loose.core._2011_06.ICT.Array;
import com.teamcenter.services.internal.loose.core._2011_06.ICT.Entry;
import com.teamcenter.services.internal.loose.core._2011_06.ICT.Structure;
public class TcUtility
{
public static Arg createArg(String argValue)
{
Arg arg = new Arg();
arg.val = argValue;
return arg;
}
public Entry createEntry()
{
Entry arg = new Entry();
arg.structure = new Structure[1];
arg.structure[0] = new Structure();
return arg;
}
public static longSeqValue_u queryArg(Arg arg, longSeqValue_u argValue)
{
if (argValue == null) {
argValue = new longSeqValue_u();
}
argValue.__default();
if (arg.structure == null || arg.structure[0] == null) {
return null;
}
if (arg.structure[0].args == null) {
return argValue;
}
String dicVal = "0";
if (argValue.discriminator()) {
dicVal = "1";
}
if (arg.structure[0].args[0].val.equals(dicVal))
{
return argValue;
}
if (arg.structure[0].args[0].val.equalsIgnoreCase("TRUE"))
{
argValue.seqValue(TcUtility.queryArg(arg.structure[0].args[1], argValue.seqValue()));
}
else
{
argValue.seqValue(new int[0]);
}
return argValue;
}
public static int[] queryArg(Arg arg, int[] argValue)
{
if (arg.array == null || arg.array.length == 0 || arg.array[0] == null) {
return null;
}
if (arg.array[0].entries == null) {
return null;
}
argValue = new int[arg.array[0].entries.length];
for (int ii = 0; ii < arg.array[0].entries.length; ii++)
{
argValue[ii] = (int)TcUtility.queryEntry(arg.array[0].entries[ii], argValue[ii]);
}
return argValue;
}
public static int[] queryEntry(Entry arg, int[] argValue)
{
if (arg.array == null || arg.array.length == 0 || arg.array[0] == null) {
return null;
}
if (arg.array[0].entries == null) {
return null;
}
argValue = new int[arg.array[0].entries.length];
for (int ii = 0; ii < arg.array[0].entries.length; ii++)
{
argValue[ii] = (int)TcUtility.queryEntry(arg.array[0].entries[ii], argValue[ii]);
}
return argValue;
}
public static int queryEntry(Entry arg, int argValue)
{
return Integer.parseInt(arg.val);
}
public static int queryArg(Arg arg, int argValue)
{
return Integer.parseInt(arg.val);
}
public static Arg createArg(stringSeqValue_u[] argValue)
{
Arg arg = new Arg();
arg.array = new Array[1];
arg.array[0] = new Array();
arg.array[0].entries = new Entry[argValue.length];
for (int ii = 0; ii < argValue.length; ii++)
{
arg.array[0].entries[ii] = TcUtility.createEntry(argValue[ii]);
}
return arg;
}
public static Entry createEntry(stringSeqValue_u argValue)
{
Entry arg = new Entry();
String discValue = Boolean.toString(argValue.discriminator());
arg.structure = new Structure[1];
arg.structure[0] = new Structure();
if (discValue.equalsIgnoreCase("TRUE"))
{
arg.structure[0].args = new Arg[2];
}
else
{
arg.structure[0].args = new Arg[1];
}
arg.structure[0].args[0] = new Arg();
arg.structure[0].args[0].val = discValue;
//process union members
if (discValue.equalsIgnoreCase("TRUE"))
{
arg.structure[0].args[1] = TcUtility.createArg(argValue.seqValue());
}
return arg;
}
public static Arg createArg(String[] argValue)
{
Arg arg = new Arg();
arg.array = new Array[1];
arg.array[0] = new Array();
arg.array[0].entries = new Entry[argValue.length];
for (int ii = 0; ii < argValue.length; ii++)
{
arg.array[0].entries[ii] = TcUtility.createEntry(argValue[ii]);
}
return arg;
}
public static Entry createEntry(String argValue)
{
Entry arg = new Entry();
arg.val = argValue;
return arg;
}
public static Arg createArg(stringSeqValue_u argValue)
{
Arg arg = new Arg();
String discValue =Boolean.toString( argValue.discriminator());
arg.structure = new Structure[1];
arg.structure[0] = new Structure();
if (discValue.equalsIgnoreCase("TRUE"))
{
arg.structure[0].args = new Arg[2];
}
else
{
arg.structure[0].args = new Arg[1];
}
arg.structure[0].args[0] = new Arg();
arg.structure[0].args[0].val = discValue;
//process union members
if (discValue.equalsIgnoreCase("TRUE"))
{
arg.structure[0].args[1] = TcUtility.createArg(argValue.seqValue());
}
return arg;
}
public static String queryArgStringUnion(Arg arg, String argValue)
{
argValue = null;
if (arg.structure != null && arg.structure[0] != null && arg.structure[0].args != null && arg.structure[0].args[0].val.equalsIgnoreCase("TRUE"))
{
argValue = arg.structure[0].args[1].val;
}
return argValue;
}
}

@ -0,0 +1,35 @@
package com.connor.web.service;
public class longSeqValue_u {
private boolean __discriminator;
private Object __value;
public longSeqValue_u() {
__default();
}
public boolean discriminator() {
return __discriminator;
}
public void __default() {
this.__discriminator = false;
this.__value = null;
}
public int[] seqValue() {
return (int[])__value;
}
public void seqValue(int[] value) {
this.__discriminator = true;
this.__value = value;
}
public boolean is_seqValue() {
return __discriminator;
}
}

@ -0,0 +1,14 @@
package com.connor.web.service;
public class longSeqValue_uHolder {
public longSeqValue_u value;
public longSeqValue_uHolder() {
}
public longSeqValue_uHolder(longSeqValue_u value) {
this.value = value;
}
}

@ -0,0 +1,35 @@
package com.connor.web.service;
public class stringSeqValue_u {
private boolean __discriminator;
private Object __value;
public stringSeqValue_u() {
__default();
}
public boolean discriminator() {
return __discriminator;
}
public void __default() {
this.__discriminator = false;
this.__value = null;
}
public String[] seqValue() {
return (String[])__value;
}
public void seqValue(String[] value) {
this.__discriminator = true;
this.__value = value;
}
public boolean is_seqValue() {
return __discriminator;
}
}

@ -1,12 +1,12 @@
package com.connor.web.util; package com.connor.web.util;
import com.alibaba.fastjson2.JSONObject; import com.connor.web.controller.MyRestController;
import com.teamcenter.services.strong.cad._2007_01.StructureManagement; import com.teamcenter.services.strong.cad._2007_01.StructureManagement;
import com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput; import com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput;
import com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSData; import com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.strong.core.DataManagementService; import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core._2007_06.DataManagement;
import com.teamcenter.soa.client.model.ModelObject; import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.*; import com.teamcenter.soa.client.model.strong.*;
import com.teamcenter.clientx.Session; import com.teamcenter.clientx.Session;
@ -54,12 +54,14 @@ public class DefineUtil {
public static final String VAL_EMPTY_STRING = ""; public static final String VAL_EMPTY_STRING = "";
public static final String VAL_OUTBUY = "外购"; public static final String VAL_OUTBUY = "外购";
public static final String VAL_ISPBOM = "P"; public static final String VAL_ISPBOM = "P";
public static final String URL_BOM_DETAILS = "https://gfpoapp.chint.com:2443/RESTAdapter/PLM2S4/GET_BOMDETAILS";//测试地址"https://gfpot01.chint.com:4443/RESTAdapter/PLM2S4/GET_BOMDETAILS"; // public static final String URL_BOM_DETAILS = "https://gfpot01.chint.com:4443/RESTAdapter/PLM2S4/GET_BOMDETAILS";//测试地址
public static final String URL_BOM_DETAILS = "https://gfpoapp.chint.com:2443/RESTAdapter/PLM2S4/GET_BOMDETAILS";//正式地址
public static final String POST_METHOD = "POST"; public static final String POST_METHOD = "POST";
public static final String CONTENT_TYPE = "Content-Type"; public static final String CONTENT_TYPE = "Content-Type";
public static final String JSON_APP = "application/json"; public static final String JSON_APP = "application/json";
public static final String AUTH = "Authorization"; public static final String AUTH = "Authorization";
public static final String BASIC = "Basic cG9fcmZjOjFxYXohUUFa"; // public static final String BASIC = "Basic cG9fcmZjOjFxYXohUUFa";
public static final String BASIC = "Basic c2hwbG06c2FwQDIwMTk=";
/** /**
* BOM * BOM
* *
@ -70,7 +72,7 @@ public class DefineUtil {
// List<String> bomLineNodes = list; // List<String> bomLineNodes = list;
// 预定义BOM父子对map及ItemRev map // 预定义BOM父子对map及ItemRev map
Map<String, ExpandPSData[]> bomLineMap = new HashMap(); Map<String, ExpandPSData[]> bomLineMap = new HashMap<>();
try { try {
// 调用SOA方法批量展开BOM // 调用SOA方法批量展开BOM
com.teamcenter.services.strong.cad._2007_01.StructureManagement structureService = com.teamcenter.services.strong.cad.StructureManagementService com.teamcenter.services.strong.cad._2007_01.StructureManagement structureService = com.teamcenter.services.strong.cad.StructureManagementService
@ -90,7 +92,7 @@ public class DefineUtil {
// 将BOM构建成uid父子对关系 // 将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) { for (ExpandPSAllLevelsOutput data : levelResp.output) {
ExpandPSData[] children = data.children; ExpandPSData[] children = data.children;
BOMLine parentBomLine = (BOMLine) data.parent.bomLine; BOMLine parentBomLine = data.parent.bomLine;
bomLineMap.put(parentBomLine.getUid(), children); bomLineMap.put(parentBomLine.getUid(), children);
} }
} }
@ -111,22 +113,18 @@ public class DefineUtil {
.getService(Session.getConnection()); .getService(Session.getConnection());
StructureManagement.CloseBOMWindowsResponse response = null; StructureManagement.CloseBOMWindowsResponse response = null;
com.teamcenter.services.strong.cad._2008_06.StructureManagement.SaveBOMWindowsResponse res = null; com.teamcenter.services.strong.cad._2008_06.StructureManagement.SaveBOMWindowsResponse res = null;
if (cadSMService != null if (bomWindow != null) {//cadSMService != null &&
&& bomWindow != null) {
res = cadSMService.saveBOMWindows(new BOMWindow[]{bomWindow}); res = cadSMService.saveBOMWindows(new BOMWindow[]{bomWindow});
response = response = cadSMService.closeBOMWindows(new BOMWindow[]{bomWindow});
cadSMService.closeBOMWindows(new BOMWindow[]{bomWindow});
} }
if (response.serviceData.sizeOfPartialErrors() > 0) { if (response != null && response.serviceData.sizeOfPartialErrors() > 0) {
for (int i = 0; i < response.serviceData for (int i = 0; i < response.serviceData.sizeOfPartialErrors(); i++) {
.sizeOfPartialErrors(); i++) {
System.out.println("Close BOMWindow Partial Error -- " + response.serviceData System.out.println("Close BOMWindow Partial Error -- " + response.serviceData
.getPartialError(i).getMessages()[0]); .getPartialError(i).getMessages()[0]);
} }
} }
if (res.serviceData.sizeOfPartialErrors() > 0) { if (res != null && res.serviceData.sizeOfPartialErrors() > 0) {
for (int i = 0; i < res.serviceData for (int i = 0; i < res.serviceData.sizeOfPartialErrors(); i++) {
.sizeOfPartialErrors(); i++) {
System.out.println("save BOMWindow Partial Error -- " + res.serviceData System.out.println("save BOMWindow Partial Error -- " + res.serviceData
.getPartialError(i).getMessages()[0]); .getPartialError(i).getMessages()[0]);
} }
@ -137,6 +135,7 @@ public class DefineUtil {
} }
/** /**
* BOM * BOM
* *
@ -149,6 +148,21 @@ public class DefineUtil {
public static void getChildBomMsg(BOMLine parentLine, ItemRevision itemRevOfBOMLine public static void getChildBomMsg(BOMLine parentLine, ItemRevision itemRevOfBOMLine
, Map<String, ExpandPSData[]> expandMap, Map<String, Double> materialMap, Double qty) throws Exception { , Map<String, ExpandPSData[]> expandMap, Map<String, Double> materialMap, Double qty) throws Exception {
String parentUid = parentLine.getUid(); String parentUid = parentLine.getUid();
//TODO 查找关联的工艺BOM获取辅料
refreshAndGetProperties(itemRevOfBOMLine, PROP_MATERIAL_NO);
String material = itemRevOfBOMLine.getPropertyDisplayableValue(PROP_MATERIAL_NO);
MyRestController.log("GetBomDetails getChildBomMsg = " + material + " = " + parentUid);
ModelObject procModel = whereReferencedByTypeRelation(itemRevOfBOMLine, "IMAN_METarget");
if(procModel != null){
ItemRevision processRev = (ItemRevision) procModel;
refreshAndGetProperties(processRev, "item_id");
String id = processRev.getPropertyDisplayableValue("item_id");
MyRestController.log("GetBomDetails processRev = " + id);
ArrayList<Object> arrayList = DefineUtil.openBOMWindow(processRev);
BOMLine procTopLine = (BOMLine) arrayList.get(1);
Map<String, ExpandPSData[]> procBomMap = DefineUtil.getBomLineTreeNodeSOA(procTopLine);
getProcessBomMsg(procTopLine, processRev, procBomMap, materialMap, 1.0, 0);
}
ExpandPSData[] expandPSData = expandMap.get(parentUid); ExpandPSData[] expandPSData = expandMap.get(parentUid);
refreshAndGetProperties(parentLine, PROP_QUANTITY); refreshAndGetProperties(parentLine, PROP_QUANTITY);
String blQty = parentLine.getPropertyDisplayableValue(PROP_QUANTITY); String blQty = parentLine.getPropertyDisplayableValue(PROP_QUANTITY);
@ -159,20 +173,73 @@ public class DefineUtil {
// 数量为0为底层数据 // 数量为0为底层数据
if (expandPSData == null || expandPSData.length == 0) { if (expandPSData == null || expandPSData.length == 0) {
//自制不需要 //自制不需要
if (!isOutBuy(itemRevOfBOMLine)) {
return;
}
refreshAndGetProperties(itemRevOfBOMLine, PROP_MATERIAL_NO, PROP_SZFACTORY, PROP_SZPROCURE_TYPE); refreshAndGetProperties(itemRevOfBOMLine, PROP_MATERIAL_NO, PROP_SZFACTORY, PROP_SZPROCURE_TYPE);
String materialNo = itemRevOfBOMLine.getPropertyDisplayableValue(PROP_MATERIAL_NO); String materialNo = itemRevOfBOMLine.getPropertyDisplayableValue(PROP_MATERIAL_NO);
if (materialMap.containsKey(materialNo)) { if (materialMap.containsKey(materialNo)) {
materialMap.put(materialNo, materialMap.get(materialNo) + qty * qtyDouble); materialMap.put(materialNo, materialMap.get(materialNo) + qty * qtyDouble);
}else{
materialMap.put(materialNo, qty * qtyDouble);
} }
if (!isOutBuy(itemRevOfBOMLine)) { if(materialNo.equals("2100285335"))
return; MyRestController.log("GetBomDetails count = " + qty * qtyDouble + " >> " + materialMap.get(materialNo));
} else {
MyRestController.log("GetBomDetails 开始遍历");
//获取当前层级数量,然后累乘
for (ExpandPSData expandPSDatum : expandPSData) {
getChildBomMsg(expandPSDatum.bomLine, expandPSDatum.itemRevOfBOMLine
, expandMap, materialMap, qty * qtyDouble);
}
MyRestController.log("GetBomDetails 结束遍历");
}
}
/**
* BOM
*
* @param parentLine BOM
* @param itemRevOfBOMLine BOM
* @param expandMap BOM
* @param materialMap Map -
* @param qty
* @param level BOM
*/
public static void getProcessBomMsg(BOMLine parentLine, ItemRevision itemRevOfBOMLine
, Map<String, ExpandPSData[]> expandMap, Map<String, Double> materialMap, Double qty, int level) throws Exception {
String parentUid = parentLine.getUid();
ExpandPSData[] expandPSData = expandMap.get(parentUid);
refreshAndGetProperties(parentLine, PROP_QUANTITY);
String blQty = parentLine.getPropertyDisplayableValue(PROP_QUANTITY);
Double qtyDouble = 1.0;
if (!blQty.isEmpty()) {
qtyDouble = Double.parseDouble(blQty);
} }
// 0为工艺层1、2为工序层3为辅料层
if (level == 3) {
// refreshAndGetProperties(itemRevOfBOMLine, PROP_MATERIAL_NO);
// String materialNo = itemRevOfBOMLine.getPropertyDisplayableValue(PROP_MATERIAL_NO);
refreshAndGetProperties(parentLine, "bl_occ_type");
String bl_occ_type = parentLine.getPropertyDisplayableValue("bl_occ_type");
// if(materialNo.equals("1000025108")){
// MyRestController.log("GetBomDetails getProcessBomMsg = " + materialNo);
// MyRestController.log("GetBomDetails bl_occ_type = " + bl_occ_type);
// }
if(!bl_occ_type.equals("Fu Liao"))//辅料
return;
refreshAndGetProperties(itemRevOfBOMLine, PROP_MATERIAL_NO);
String materialNo = itemRevOfBOMLine.getPropertyDisplayableValue(PROP_MATERIAL_NO);
if (materialMap.containsKey(materialNo)) {
materialMap.put(materialNo, materialMap.get(materialNo) + qty * qtyDouble);
}else{
materialMap.put(materialNo, qty * qtyDouble); materialMap.put(materialNo, qty * qtyDouble);
}
} else { } else {
//获取当前层级数量,然后累乘 //获取当前层级数量,然后累乘
for (int i = 0; i < expandPSData.length; i++) { for (ExpandPSData expandPSDatum : expandPSData) {
getChildBomMsg(expandPSData[i].bomLine, expandPSData[i].itemRevOfBOMLine getProcessBomMsg(expandPSDatum.bomLine, expandPSDatum.itemRevOfBOMLine
, expandMap, materialMap, qty * qtyDouble); , expandMap, materialMap, qty * qtyDouble, level + 1);
} }
} }
} }
@ -181,7 +248,7 @@ public class DefineUtil {
* *
* *
* @param material * @param material
* @return * @return
*/ */
public static boolean isOutBuy(ItemRevision material) throws Exception { public static boolean isOutBuy(ItemRevision material) throws Exception {
boolean flag = false; boolean flag = false;
@ -192,6 +259,7 @@ public class DefineUtil {
&& procureTypes.size() > i && procureTypes.size() > i
&& procureTypes.get(i).contains(VAL_OUTBUY)) { && procureTypes.get(i).contains(VAL_OUTBUY)) {
flag = true; flag = true;
break;
} }
} }
return flag; return flag;
@ -200,17 +268,17 @@ public class DefineUtil {
/** /**
* BOM * BOM
* *
* @param parentItemRev * @param parentItemRev BOM
* @return 0 BOMWindow 1 BOMLine * @return 0 BOMWindow 1 BOMLine
*/ */
public static ArrayList openBOMWindow(ItemRevision parentItemRev) { public static ArrayList<Object> openBOMWindow(ItemRevision parentItemRev) {
ArrayList bomWindowandParentLine = new ArrayList(3); ArrayList<Object> bomWindowandParentLine = new ArrayList<>();
StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo = new StructureManagement.CreateBOMWindowsInfo[1]; StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo = new StructureManagement.CreateBOMWindowsInfo[1];
createBOMWindowsInfo[0] = new StructureManagement.CreateBOMWindowsInfo(); createBOMWindowsInfo[0] = new StructureManagement.CreateBOMWindowsInfo();
createBOMWindowsInfo[0].itemRev = (ItemRevision) parentItemRev; createBOMWindowsInfo[0].itemRev = parentItemRev;
com.teamcenter.services.strong.cad.StructureManagementService cadSMService = com.teamcenter.services.strong.cad.StructureManagementService cadSMService =
com.teamcenter.services.strong.cad.StructureManagementService com.teamcenter.services.strong.cad.StructureManagementService
.getService(Session.getConnection()); .getService(Session.getConnection());
@ -239,11 +307,49 @@ public class DefineUtil {
* *
* @param modelObject TC * @param modelObject TC
* @param properties * @param properties
* @throws Exception * @throws Exception
*/ */
public static void refreshAndGetProperties(ModelObject modelObject, String... properties) throws Exception { public static void refreshAndGetProperties(ModelObject modelObject, String... properties) throws Exception {
DataManagementService dmService = DataManagementService.getService(Session.getConnection()); DataManagementService dmService = DataManagementService.getService(Session.getConnection());
dmService.refreshObjects(new ModelObject[]{modelObject}); dmService.refreshObjects(new ModelObject[]{modelObject});
dmService.getProperties(new ModelObject[]{modelObject}, properties); dmService.getProperties(new ModelObject[]{modelObject}, properties);
} }
/**
*
*
* @param modelObject TC
* @param relation
* @return
* @throws Exception
*/
public static ModelObject whereReferencedByTypeRelation(ModelObject modelObject, String relation) throws Exception {
DataManagementService dmService = DataManagementService.getService(Session.getConnection());
DataManagement.WhereReferencedByRelationNameInfo relInfo = new DataManagement.WhereReferencedByRelationNameInfo();
relInfo.object = modelObject;
DataManagement.RelationAndTypesFilter filter = new DataManagement.RelationAndTypesFilter();
filter.relationTypeName = relation;//"IMAN_METarget";
relInfo.filter = new DataManagement.RelationAndTypesFilter[]{ filter };
DataManagement.WhereReferencedByRelationNameInfo[] relInfos = new DataManagement.WhereReferencedByRelationNameInfo[]{ relInfo };
DataManagement.WhereReferencedByRelationNameResponse response = dmService.whereReferencedByRelationName(relInfos, 1);
// MyRestController.log("GetBomDetails response.output.length = " + response.output.length);
// MyRestController.log("GetBomDetails response.serviceData.sizeOfPartialErrors = " + response.serviceData.sizeOfPartialErrors());
try {
TCUtil.throwServiceDataError(response.serviceData);
} catch(Exception e) {
String msg = TCUtil.getStackTrace(e);
if(!msg.contains("No referencer matches the input relation type name")){
MyRestController.log(msg);
}
}
if(response.output.length > 0){
MyRestController.log("GetBomDetails response.output[0].info.length = " + response.output[0].info.length);
}
if(response.output.length > 0 && response.output[0].info.length > 0)
return response.output[0].info[0].referencer;
else
return null;
}
} }

@ -0,0 +1,29 @@
package com.connor.web.util;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;
import java.io.InputStream;
public class MybatisUtils {
private static SqlSessionFactory sqlSessionFactory;
static {
try {
// 获取SqlSessionFactory对象
String resource = "MybatisConfig.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
// 通过SqlSessionFactory 获取 SqlSession,SqlSession包含了控制数据库的SQL的方法
public static SqlSession getSqlSession() {
return sqlSessionFactory.openSession();
}
}

@ -5,6 +5,7 @@ import com.connor.web.bean.MaterialBean;
import com.connor.web.config.Config; import com.connor.web.config.Config;
import com.connor.web.controller.MyRestController; import com.connor.web.controller.MyRestController;
//import com.connor.web.mapper.IDataMapper; //import com.connor.web.mapper.IDataMapper;
import com.connor.web.service.*;
import com.s8.services.strong.bypass.S8SoaBypassServiceService; import com.s8.services.strong.bypass.S8SoaBypassServiceService;
import com.s8.services.strong.bypass._2016_05.S8SoaBypassService; import com.s8.services.strong.bypass._2016_05.S8SoaBypassService;
import com.s8.services.strong.custserver.S8CustServerService; import com.s8.services.strong.custserver.S8CustServerService;
@ -1401,6 +1402,20 @@ public class TCUtil {
} }
} }
/**
*
*
* @param e
* @return
*/
public static String getStackTrace(Exception e) {
StringBuilder rError = new StringBuilder("" + e.getMessage());
for(StackTraceElement ste : e.getStackTrace()) {
rError.append("\n\t"+ste.toString());
}
return rError.toString();
}
/** /**
* *
* *
@ -1833,18 +1848,9 @@ public class TCUtil {
return null; return null;
} }
} }
return null; return null;
} }
} }

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST = 10.128.10.207)(PORT = 1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME=tcprod)))"/>
<property name="username" value="infodba"/>
<property name="password" value="infodba"/>
</dataSource>
</environment>
</environments>
<!-- 每一个mapper都需要注册 -->
<mappers>
<mapper resource="mapper/SRM.xml"/>
</mappers>
</configuration>

@ -65,7 +65,9 @@ spring:
minimum-idle: 1 minimum-idle: 1
maximum-pool-size: 5 maximum-pool-size: 5
auto-commit: true auto-commit: true
mybatis:
type-aliases-package: com.connor.web.bean.SRMResultBean
mapper-locations: classpath:mapper/*.xml
#jpa: #jpa:
# hibernate: # hibernate:
# ddl-auto: update # ddl-auto: update

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.connor.web.mapper.IDataMapper">
<select id="GetDrawingUrlAllVersion" resultType="com.connor.web.bean.SRMResultBean">
SELECT *
FROM CHINT_DRAWING_TO_SRM_DETIALS
WHERE 1=1
<if test="wbs != null and wbs != ''">
AND wbs = #{wbs}
</if>
<if test="materialno != null">
AND materialno = #{materialno}
</if>
<if test="factory != null">
AND factory = #{factory}
</if>
AND procuretype IS NULL
ORDER BY code DESC
</select>
<select id="GetDrawingUrlVersion" resultType="com.connor.web.bean.SRMResultBean">
SELECT *
FROM CHINT_DRAWING_TO_SRM_DETIALS
WHERE 1=1
<if test="wbs != null and wbs != ''">
AND wbs = #{wbs}
</if>
<if test="materialno != null">
AND materialno = #{materialno}
</if>
<if test="revision != null">
AND revision = #{revision}
</if>
<if test="factory != null">
AND factory = #{factory}
</if>
AND procuretype IS NULL
ORDER BY code DESC
FETCH FIRST 1 ROW ONLY
</select>
<select id="GetDrawingUrlLatestVersion" resultType="com.connor.web.bean.SRMResultBean">
SELECT *
FROM CHINT_DRAWING_TO_SRM_DETIALS
WHERE 1=1
<if test="wbs != null and wbs != ''">
AND wbs = #{wbs}
</if>
<if test="materialno != null">
AND materialno = #{materialno}
</if>
<if test="factory != null">
AND factory = #{factory}
</if>
AND procuretype IS NULL
ORDER BY code DESC
-- FETCH FIRST 1 ROW ONLY
</select>
<select id="GetProcure" resultType="com.connor.web.bean.SRMResultBean">
SELECT *
FROM CHINT_DRAWING_TO_SRM_DETIALS
WHERE 1=1
<if test="wbs != null and wbs != ''">
AND wbs = #{wbs}
</if>
<if test="materialno != null">
AND materialno = #{materialno}
</if>
<if test="version != null and version != ''">
AND revision = #{version}
</if>
<if test="factory != null">
AND factory = #{factory}
</if>
<if test="factoryno != null and factoryno != ''">
AND factoryno = #{factoryno}
</if>
<if test="procuretype != null">
AND procuretype = #{procuretype}
</if>
ORDER BY code DESC
-- FETCH FIRST 1 ROW ONLY
</select>
</mapper>
Loading…
Cancel
Save