Compare commits
191 Commits
20240218_0
...
feature/SD
| Author | SHA1 | Date | |
|---|---|---|---|
| 21347036cc | |||
| 67170a87ca | |||
| cd042fc248 | |||
| 31f2195acb | |||
| 1b8b6f6304 | |||
| 7ab4f8a55f | |||
| 879fcb9d56 | |||
| ab761d0ac9 | |||
| b35d51f0ad | |||
| eb0b047994 | |||
| ac71a4a92a | |||
| 29677501e8 | |||
| 3821c88000 | |||
| fc52433878 | |||
| efdd30a8dd | |||
| a5ef9aebee | |||
| 900c00e6c2 | |||
| 0f3261185a | |||
| ed5817d6e2 | |||
| 2578efc638 | |||
| 0428bb9680 | |||
| 3aeb112f10 | |||
| 1f3caadc14 | |||
| 388ff5c36e | |||
| 7d7d0b508a | |||
| b0b4cc6298 | |||
| 30ddd694d1 | |||
| 7eecf7591f | |||
| ad035e63ad | |||
| 9e1e670faf | |||
| 5a0a5491cf | |||
| f85fce7127 | |||
| ec1f3939d6 | |||
| d086a88214 | |||
| 50ba382f6d | |||
| 36074a3765 | |||
| 4c490e21af | |||
| 2963c7b592 | |||
| e320f90a1a | |||
| f61df8763c | |||
| a275167a4b | |||
| 09cd7ba414 | |||
| 3ffa635387 | |||
| db8395fdd5 | |||
| 15041e3b44 | |||
| 5104bdb53f | |||
| 42858e0c30 | |||
| 10f6702573 | |||
| 3243008219 | |||
| 6b7d2057d7 | |||
| 60e43da598 | |||
| dae5d4cf21 | |||
| b7083541e8 | |||
| a26a2ee44f | |||
| a4b297dc9d | |||
| a2f169101b | |||
| eb1043eb3b | |||
| a62f804c25 | |||
| 60f9578a14 | |||
| 11bc54df6e | |||
| 831434267d | |||
| a554141182 | |||
| d5a9070a7f | |||
| 90e5874ba4 | |||
| 9e47404c91 | |||
| d4a1c85390 | |||
| 696d4a2f4b | |||
| cf3235b176 | |||
| ba198c9d2f | |||
| 574f747618 | |||
| 09ffd4090f | |||
| 50b1f43818 | |||
| aab7560ecb | |||
| 29c28367d1 | |||
| 8035b2c5c1 | |||
| bfbc459393 | |||
| a2d536d6d5 | |||
| 507aa7cd0d | |||
| 4af91e8c8d | |||
| 8f7215a57c | |||
| a71cf5517b | |||
| 5292edfd78 | |||
| f3e0ad8f60 | |||
| 26b17202df | |||
| 17b975a4fe | |||
| a94bb34c54 | |||
| 66dd299d09 | |||
| 8d2dfbf178 | |||
| bc6cd67e81 | |||
| 7ba6771112 | |||
| 4cac7be4cc | |||
| 14ce9cefc8 | |||
| 6fab1e8db5 | |||
| 7e2c4256f2 | |||
| 8c33b02dae | |||
| bc2f063ed8 | |||
| 1dc94e60a2 | |||
| f4eb510770 | |||
| c34b15aeae | |||
| 19ac975f14 | |||
| 074f939559 | |||
| d702d208ab | |||
| bbf199f6c7 | |||
| 4182ef790e | |||
| f01887dd50 | |||
| 0ca1bb46d3 | |||
| d2cfd915a4 | |||
| 64bfafbcf1 | |||
| 8e615a3ee9 | |||
| de6d9a82b7 | |||
| 9b5abfcdd4 | |||
| 857b6a150a | |||
| ffa4ded1fe | |||
| 7709c11636 | |||
| 06f8d99688 | |||
| 863d808914 | |||
| 11307be692 | |||
| 0ad90cf961 | |||
| d5c285fa45 | |||
| 8c5eba3031 | |||
| 0efbc8ba16 | |||
| 063ab02a28 | |||
| 80a65dbcb3 | |||
| cdaa89749b | |||
| edda17080d | |||
| 0871c50ceb | |||
| 3771891886 | |||
| 3aae8b5d24 | |||
| 4b17566d15 | |||
| 6128d3756c | |||
| 91bb735fb1 | |||
| 9f1489a9c8 | |||
| 02ac9d1559 | |||
| 2d6f27d8a6 | |||
| 8d143fa2ab | |||
| cc6f8dfa52 | |||
| 80333cc27e | |||
| d4883a25e7 | |||
| 504d5c8171 | |||
| ac3c048e7a | |||
| 8c2e407c10 | |||
| bb159584f0 | |||
| 3b269da398 | |||
| 94b44a723e | |||
| 7acd898115 | |||
| c751d70663 | |||
| 167feef6be | |||
| 7c7be3a89c | |||
| 1bf6f776e9 | |||
| 83acc13fe9 | |||
| 7b727538e7 | |||
| 5252a0d522 | |||
| 27cdb94dff | |||
| bd64c14e7c | |||
| d095e2c1b1 | |||
| 330a977e77 | |||
| e8df520abd | |||
| cdc9b35ccd | |||
| 0cb3aee12e | |||
| 75446207a5 | |||
| 75d1671e7b | |||
| 9a390dd6f1 | |||
| f225211ffd | |||
| d07f6ceeb2 | |||
| 65d1221fb6 | |||
| 56721f4730 | |||
| 42f5b96acb | |||
| 30374c6e98 | |||
| 0a13ab43d0 | |||
| 8b8486b3f2 | |||
| 9062f0b4f6 | |||
| a7c87523c9 | |||
| c609fd74eb | |||
| 8cfe60ae30 | |||
| 6a225715cb | |||
| f136e6b6bd | |||
| 0910a8ab50 | |||
| 407d9231e3 | |||
| 6e55d3f4af | |||
| dbb0f7c4a8 | |||
| be8dc47a94 | |||
| 71d4011d09 | |||
| 56e880e3c6 | |||
| c09af099da | |||
| 49ad5aed67 | |||
| 31d5b67ddf | |||
| baa0ddffd0 | |||
| 5d23629723 | |||
| f1da0aeccd | |||
| 9dbfc8579b | |||
| d6aca23687 |
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -135,10 +135,13 @@ ems-contabil/src/main/java/it/integry/ems/contabil/service/ContabilService.java
|
|||||||
ems-contabil/src/main/java/it/integry/ems/contabil/service/DistinteIncassiDTO.java -text
|
ems-contabil/src/main/java/it/integry/ems/contabil/service/DistinteIncassiDTO.java -text
|
||||||
ems-contabil/src/main/java/it/integry/ems/contabil/type/ContabilImportFormat.java -text
|
ems-contabil/src/main/java/it/integry/ems/contabil/type/ContabilImportFormat.java -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIBdyPaymentRequest.00.04.00.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIBdyPaymentRequest.00.04.00.xsd -text
|
||||||
|
ems-contabil/src/main/resources/sepa/xsd/CBIBdyPaymentRequest.00.04.01.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIHdrSrv.001.07.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIHdrSrv.001.07.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIHdrTrt.001.07.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIHdrTrt.001.07.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequest.00.04.00.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequest.00.04.00.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequestMsg.00.04.00.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequestMsg.00.04.00.xsd -text
|
||||||
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequest.00.04.01.xsd -text
|
||||||
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequestMsg.00.04.01.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBISgnInf.001.04.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBISgnInf.001.04.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/binding.jxb -text
|
ems-contabil/src/main/resources/sepa/xsd/binding.jxb -text
|
||||||
ems-contabil/target/classes/it/integry/ems/contabil/it.integry.core.controller/ContabilController.class -text
|
ems-contabil/target/classes/it/integry/ems/contabil/it.integry.core.controller/ContabilController.class -text
|
||||||
|
|||||||
@@ -108,6 +108,9 @@
|
|||||||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.4" />
|
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.4" />
|
||||||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.4" />
|
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.4" />
|
||||||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.9.4" />
|
<element id="library" level="project" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.9.4" />
|
||||||
|
<element id="library" level="project" name="Maven: com.alibaba:fastjson:2.0.47" />
|
||||||
|
<element id="library" level="project" name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.47" />
|
||||||
|
<element id="library" level="project" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.47" />
|
||||||
<element id="library" level="project" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" />
|
<element id="library" level="project" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" />
|
||||||
<element id="library" level="project" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" />
|
<element id="library" level="project" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" />
|
||||||
<element id="library" level="project" name="Maven: org.springframework:spring-instrument-tomcat:4.2.5.RELEASE" />
|
<element id="library" level="project" name="Maven: org.springframework:spring-instrument-tomcat:4.2.5.RELEASE" />
|
||||||
@@ -254,7 +257,7 @@
|
|||||||
<element id="library" level="project" name="Maven: org.reflections:reflections:0.9.10" />
|
<element id="library" level="project" name="Maven: org.reflections:reflections:0.9.10" />
|
||||||
<element id="library" level="project" name="Maven: org.javassist:javassist:3.19.0-GA" />
|
<element id="library" level="project" name="Maven: org.javassist:javassist:3.19.0-GA" />
|
||||||
<element id="library" level="project" name="Maven: com.google.code.findbugs:annotations:2.0.1" />
|
<element id="library" level="project" name="Maven: com.google.code.findbugs:annotations:2.0.1" />
|
||||||
<element id="library" level="project" name="Maven: com.google.code.gson:gson:2.5" />
|
<element id="library" level="project" name="Maven: com.google.code.gson:gson:2.9.1" />
|
||||||
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" />
|
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" />
|
||||||
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" />
|
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" />
|
||||||
<element id="library" level="project" name="Maven: commons-logging:commons-logging:1.1.3" />
|
<element id="library" level="project" name="Maven: commons-logging:commons-logging:1.1.3" />
|
||||||
@@ -549,7 +552,6 @@
|
|||||||
<option value="$PROJECT_DIR$/ems-retail/pom.xml" />
|
<option value="$PROJECT_DIR$/ems-retail/pom.xml" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="PWA">
|
<component name="PWA">
|
||||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||||
@@ -829,6 +831,44 @@
|
|||||||
</option>
|
</option>
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration default="false" name="Tomcat 7 #1 (ServerDev)" type="Remote">
|
||||||
|
<module name="ems-engine" />
|
||||||
|
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||||
|
<option name="SERVER_MODE" value="false" />
|
||||||
|
<option name="SHMEM_ADDRESS" />
|
||||||
|
<option name="HOST" value="serverdev" />
|
||||||
|
<option name="PORT" value="8001" />
|
||||||
|
<option name="AUTO_RESTART" value="false" />
|
||||||
|
<RunnerSettings RunnerId="Debug">
|
||||||
|
<option name="DEBUG_PORT" value="8001" />
|
||||||
|
<option name="LOCAL" value="false" />
|
||||||
|
</RunnerSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="false" name="Tomcat 9 #2 (ServerDev)" type="Remote">
|
||||||
|
<module name="ems-engine" />
|
||||||
|
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||||
|
<option name="SERVER_MODE" value="false" />
|
||||||
|
<option name="SHMEM_ADDRESS" />
|
||||||
|
<option name="HOST" value="serverdev" />
|
||||||
|
<option name="PORT" value="8002" />
|
||||||
|
<option name="AUTO_RESTART" value="false" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="false" name="Tomcat #1 (ServerTomcat)" type="Remote">
|
||||||
|
<module name="ems-engine" />
|
||||||
|
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||||
|
<option name="SERVER_MODE" value="false" />
|
||||||
|
<option name="SHMEM_ADDRESS" />
|
||||||
|
<option name="HOST" value="servertomcat" />
|
||||||
|
<option name="PORT" value="8000" />
|
||||||
|
<option name="AUTO_RESTART" value="false" />
|
||||||
|
<RunnerSettings RunnerId="Debug">
|
||||||
|
<option name="DEBUG_PORT" value="8000" />
|
||||||
|
<option name="LOCAL" value="false" />
|
||||||
|
</RunnerSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
<configuration default="false" name="Tomcat (FAST)" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat" ALTERNATIVE_JRE_ENABLED="false" ALTERNATIVE_JRE_PATH="1.8" show_console_on_std_err="true" show_console_on_std_out="true">
|
<configuration default="false" name="Tomcat (FAST)" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat" ALTERNATIVE_JRE_ENABLED="false" ALTERNATIVE_JRE_PATH="1.8" show_console_on_std_err="true" show_console_on_std_out="true">
|
||||||
<option name="COMMON_VM_ARGUMENTS" value="-DDISABLE_DROOLS_COMPILE=TRUE -Xms256m -Xmx1024m -XX:PermSize=1024m" />
|
<option name="COMMON_VM_ARGUMENTS" value="-DDISABLE_DROOLS_COMPILE=TRUE -Xms256m -Xmx1024m -XX:PermSize=1024m" />
|
||||||
<deployment>
|
<deployment>
|
||||||
@@ -900,6 +940,21 @@
|
|||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
</SHUTDOWN>
|
</SHUTDOWN>
|
||||||
</ConfigurationWrapper>
|
</ConfigurationWrapper>
|
||||||
|
<ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="JProfiler">
|
||||||
|
<option name="USE_ENV_VARIABLES" value="true" />
|
||||||
|
<STARTUP>
|
||||||
|
<option name="USE_DEFAULT" value="true" />
|
||||||
|
<option name="SCRIPT" value="" />
|
||||||
|
<option name="VM_PARAMETERS" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
</STARTUP>
|
||||||
|
<SHUTDOWN>
|
||||||
|
<option name="USE_DEFAULT" value="true" />
|
||||||
|
<option name="SCRIPT" value="" />
|
||||||
|
<option name="VM_PARAMETERS" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
</SHUTDOWN>
|
||||||
|
</ConfigurationWrapper>
|
||||||
<ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Profile">
|
<ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Profile">
|
||||||
<option name="USE_ENV_VARIABLES" value="true" />
|
<option name="USE_ENV_VARIABLES" value="true" />
|
||||||
<STARTUP>
|
<STARTUP>
|
||||||
@@ -1065,6 +1120,42 @@
|
|||||||
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
|
<library name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.47" type="java-imported" external-system-id="Maven">
|
||||||
|
<properties groupId="com.alibaba.fastjson2" artifactId="fastjson2-extension" version="2.0.47" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2-extension/2.0.47/fastjson2-extension-2.0.47.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2-extension/2.0.47/fastjson2-extension-2.0.47-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2-extension/2.0.47/fastjson2-extension-2.0.47-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
<library name="Maven: com.alibaba.fastjson2:fastjson2:2.0.47" type="java-imported" external-system-id="Maven">
|
||||||
|
<properties groupId="com.alibaba.fastjson2" artifactId="fastjson2" version="2.0.47" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.47/fastjson2-2.0.47.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.47/fastjson2-2.0.47-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.47/fastjson2-2.0.47-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
<library name="Maven: com.alibaba:fastjson:2.0.47" type="java-imported" external-system-id="Maven">
|
||||||
|
<properties groupId="com.alibaba" artifactId="fastjson" version="2.0.47" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/2.0.47/fastjson-2.0.47.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/2.0.47/fastjson-2.0.47-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/2.0.47/fastjson-2.0.47-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
<library name="Maven: com.amazonservices.mws:MWSClientJavaRuntime:1.1" type="java-imported" external-system-id="Maven">
|
<library name="Maven: com.amazonservices.mws:MWSClientJavaRuntime:1.1" type="java-imported" external-system-id="Maven">
|
||||||
<properties groupId="com.amazonservices.mws" artifactId="MWSClientJavaRuntime" version="1.1" />
|
<properties groupId="com.amazonservices.mws" artifactId="MWSClientJavaRuntime" version="1.1" />
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
@@ -1449,16 +1540,16 @@
|
|||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
<library name="Maven: com.google.code.gson:gson:2.5" type="java-imported" external-system-id="Maven">
|
<library name="Maven: com.google.code.gson:gson:2.9.1" type="java-imported" external-system-id="Maven">
|
||||||
<properties groupId="com.google.code.gson" artifactId="gson" version="2.5" />
|
<properties groupId="com.google.code.gson" artifactId="gson" version="2.9.1" />
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.5/gson-2.5.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC>
|
<JAVADOC>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.5/gson-2.5-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.9.1/gson-2.9.1-javadoc.jar!/" />
|
||||||
</JAVADOC>
|
</JAVADOC>
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.5/gson-2.5-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.9.1/gson-2.9.1-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
<library name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" type="java-imported" external-system-id="Maven">
|
<library name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" type="java-imported" external-system-id="Maven">
|
||||||
|
|||||||
@@ -437,6 +437,12 @@
|
|||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>2.0.47</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public class WooCommerceArticoliDataManager {
|
|||||||
" where cod_mdep = dbo.getGestSetup('WOOCOMMERCE','SETUP','COD_MDEP')";
|
" where cod_mdep = dbo.getGestSetup('WOOCOMMERCE','SETUP','COD_MDEP')";
|
||||||
|
|
||||||
if (codMarts != null && codMarts.size() > 0) {
|
if (codMarts != null && codMarts.size() > 0) {
|
||||||
sql += " AND lisv.cod_mart IN (" + UtilityQuery.concatFieldsWithSeparator(codMarts, ",") + ")";
|
sql += " AND lisv.cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement info = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
PreparedStatement info = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public class CommonConstants {
|
|||||||
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.TIME_FORMAT)
|
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.TIME_FORMAT)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
public static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
public static final DateTimeFormatter DATESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyMMdd")
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
|
||||||
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|||||||
@@ -37,17 +37,10 @@ public class BooleanDeserializer extends JsonDeserializer<Boolean> {
|
|||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ("N".equalsIgnoreCase(text) || text.length() == 0) {
|
|
||||||
// return Boolean.FALSE;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if ("Y".equalsIgnoreCase(text)) {
|
|
||||||
// return Boolean.TRUE;
|
|
||||||
// }
|
|
||||||
throw ctxt.weirdStringException("", _valueClass, "only \"true\" or \"false\" recognized");
|
throw ctxt.weirdStringException("", _valueClass, "only \"true\" or \"false\" recognized");
|
||||||
}
|
}
|
||||||
// Otherwise, no can do:
|
// Otherwise, no can do:
|
||||||
throw ctxt.mappingException(_valueClass);
|
throw ctxt.instantiationException(_valueClass, "error");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
package it.integry.ems.async.controller;
|
|
||||||
|
|
||||||
import it.integry.common.var.CommonConstants;
|
|
||||||
import it.integry.ems.async.service.AsyncServiceNew;
|
|
||||||
import it.integry.ems.controller.EmsController;
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
|
||||||
import it.integry.ems.response.StatusResponse;
|
|
||||||
import it.integry.ems.status.ServiceChecker;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Scope("request")
|
|
||||||
@RequestMapping(EmsRestConstants.PATH_ASYNC_BASE_ROUTE)
|
|
||||||
public class AsyncControllerNew {
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ServiceChecker serviceChecker;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AsyncServiceNew asyncServiceNew;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/status", method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
List<StatusResponse> status(HttpServletRequest request) {
|
|
||||||
Method[] methods = EmsController.class.getDeclaredMethods();
|
|
||||||
return serviceChecker.getServiceStatus(methods, EmsController.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_ASYNC_START, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse start(
|
|
||||||
HttpServletRequest request,
|
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
|
||||||
@RequestParam String subscriptionName
|
|
||||||
) throws Exception {
|
|
||||||
asyncServiceNew.startSync(subscriptionName);
|
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_ASYNC_RETRIEVE_TRANSACTIONS, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse retrieveTransactions(
|
|
||||||
HttpServletRequest request,
|
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
|
||||||
@RequestParam(value = "limit", required = false, defaultValue = "1") Integer limit
|
|
||||||
) throws Exception {
|
|
||||||
return ServiceRestResponse.createPositiveResponse(asyncServiceNew.retrieveTransactions(limit));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_ASYNC_UPDATE_TRANSACTION_IMPORT_ID, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse updateTransactionImportID(HttpServletRequest request,
|
|
||||||
@RequestParam Integer transactionImportID,
|
|
||||||
@RequestParam String sender,
|
|
||||||
@RequestParam String publicationID) throws Exception {
|
|
||||||
|
|
||||||
asyncServiceNew.updateTransactionImportCounterInDB(transactionImportID, publicationID, sender);
|
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package it.integry.ems.async.dto;
|
|
||||||
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
|
|
||||||
public class SubscriptionDTO {
|
|
||||||
|
|
||||||
private String publicationId;
|
|
||||||
private int lastTransactionIDImport = 0;
|
|
||||||
private String entityName = null;
|
|
||||||
private String whereCond = null;
|
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
|
||||||
|
|
||||||
|
|
||||||
public String getPublicationId() {
|
|
||||||
return publicationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setPublicationId(String publicationId) {
|
|
||||||
this.publicationId = publicationId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastTransactionIDImport() {
|
|
||||||
return lastTransactionIDImport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setLastTransactionIDImport(int lastTransactionIDImport) {
|
|
||||||
this.lastTransactionIDImport = lastTransactionIDImport;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEntityName() {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setEntityName(String entityName) {
|
|
||||||
this.entityName = entityName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWhereCond() {
|
|
||||||
return whereCond;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setWhereCond(String whereCond) {
|
|
||||||
this.whereCond = whereCond;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MultiDBTransactionManager getMultiDBTransactionManager() {
|
|
||||||
return multiDBTransactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setMultiDBTransactionManager(MultiDBTransactionManager multiDBTransactionManager) {
|
|
||||||
this.multiDBTransactionManager = multiDBTransactionManager;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package it.integry.ems.async.dto;
|
|
||||||
|
|
||||||
public class SyncConfigDTO
|
|
||||||
{
|
|
||||||
private String endpoint;
|
|
||||||
private String profileDb;
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
public String getEndpoint() {
|
|
||||||
return endpoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncConfigDTO setEndpoint(String endpoint) {
|
|
||||||
this.endpoint = endpoint;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfileDb() {
|
|
||||||
return profileDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncConfigDTO setProfileDb(String profileDb) {
|
|
||||||
this.profileDb = profileDb;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncConfigDTO setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,340 +0,0 @@
|
|||||||
package it.integry.ems.async.service;
|
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import it.integry.common.var.CommonConstants;
|
|
||||||
import it.integry.ems.async.dto.SubscriptionDTO;
|
|
||||||
import it.integry.ems.async.dto.SyncConfigDTO;
|
|
||||||
import it.integry.ems.async.dto.TransactionDTO;
|
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
|
||||||
import it.integry.ems.json.JSONObjectMapper;
|
|
||||||
import it.integry.ems.response.EsitoType;
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
|
||||||
import it.integry.ems.service.EntityProcessor;
|
|
||||||
import it.integry.ems.service.HttpRestWrapper;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
import it.integry.ems_model.base.EntityBase;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
|
||||||
import it.integry.ems_model.resolver.EntitySubTypeHolder;
|
|
||||||
import it.integry.ems_model.service.SetupGest;
|
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
|
||||||
import it.integry.ems_model.utility.UtilityHashMap;
|
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.josql.Query;
|
|
||||||
import org.josql.QueryResults;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Scope("request")
|
|
||||||
public class AsyncServiceNew {
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JSONObjectMapper jsonObjectMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityProcessor entityProcessor;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RequestDataDTO requestData;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SetupGest setupGest;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void startSync(String subscriptionName) throws Exception {
|
|
||||||
|
|
||||||
String jsonConfigurationString = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "SINCRONIZZAZIONI_OFFLINE", "SETUP", subscriptionName);
|
|
||||||
|
|
||||||
if(UtilityString.isNullOrEmpty(jsonConfigurationString))
|
|
||||||
throw new Exception("Nessuna configurazione trovata per la sincronizzazione: " + subscriptionName);
|
|
||||||
|
|
||||||
final List<SyncConfigDTO> syncConfigs = jsonObjectMapper.readValue(jsonConfigurationString, new TypeReference<List<SyncConfigDTO>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
for (SyncConfigDTO syncConfig : syncConfigs) {
|
|
||||||
String wsUrlEndpoint = syncConfig.getEndpoint() + EmsRestConstants.PATH_ASYNC_BASE_ROUTE + EmsRestConstants.PATH_ASYNC_RETRIEVE_TRANSACTIONS;
|
|
||||||
|
|
||||||
HashMap<String, String> queryParams = new HashMap<>();
|
|
||||||
queryParams.put("profileDb", syncConfig.getProfileDb());
|
|
||||||
|
|
||||||
boolean shouldStop = false;
|
|
||||||
|
|
||||||
int importedTransactionsCounter = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
|
|
||||||
StringBuilder responseBody = new StringBuilder();
|
|
||||||
int status = HttpRestWrapper.callGenericGet(wsUrlEndpoint, syncConfig.getUsername(), syncConfig.getUsername(), responseBody, queryParams);
|
|
||||||
|
|
||||||
if (status != 200)
|
|
||||||
throw new Exception("La richiesta \"" + wsUrlEndpoint + "\" ha generato status code: " + status + "<br />Body: " + responseBody);
|
|
||||||
|
|
||||||
ServiceRestResponse response = jsonObjectMapper.readValue(responseBody.toString(), ServiceRestResponse.class);
|
|
||||||
|
|
||||||
if (response.getEsito() == EsitoType.OK) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
jsonObjectMapper.writeValue(writer, response.getJsonObject());
|
|
||||||
String dtoJson = writer.toString();
|
|
||||||
|
|
||||||
List<List<TransactionDTO>> transactions = jsonObjectMapper.readValue(dtoJson, new TypeReference<List<List<TransactionDTO>>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
if (transactions.isEmpty() || transactions.get(0).isEmpty()) {
|
|
||||||
if (importedTransactionsCounter == 0) logger.debug("Nessuna entity da sincronizzare");
|
|
||||||
else logger.debug("Sincronizzazione OFFLINE terminata");
|
|
||||||
shouldStop = true;
|
|
||||||
} else {
|
|
||||||
importedTransactionsCounter +=
|
|
||||||
importTransactions(syncConfig.getEndpoint(), syncConfig.getProfileDb(), syncConfig.getUsername(), transactions);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new Exception("La richiesta \"" + wsUrlEndpoint + "\" ha generato un ESITO KO<br />Body: " + responseBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (!shouldStop);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private int importTransactions(@NotNull String hostEndpoint, @NotNull String profileDb, @NotNull String username, @NotNull List<List<TransactionDTO>> transactionList) throws Exception {
|
|
||||||
|
|
||||||
int importedEntityCounter = 0;
|
|
||||||
|
|
||||||
|
|
||||||
for (List<TransactionDTO> transactionDTOS : transactionList) {
|
|
||||||
final List<Integer> transactionsIDGroups = new ArrayList<>();
|
|
||||||
|
|
||||||
for (TransactionDTO dto : transactionDTOS) {
|
|
||||||
if (!transactionsIDGroups.contains(dto.getTransactionGroupId()))
|
|
||||||
transactionsIDGroups.add(dto.getTransactionGroupId());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Per ogni transaction group trovato mi prendo tutte le transactions
|
|
||||||
for (int j = 0; j < transactionsIDGroups.size(); j++) {
|
|
||||||
final int finalJ = j;
|
|
||||||
List<TransactionDTO> transactionsToImport = Stream.of(transactionDTOS)
|
|
||||||
.filter(transactionDTO -> transactionDTO.getTransactionGroupId() == transactionsIDGroups.get(finalJ))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
List<EntityBase> entitiesToImport = new ArrayList<EntityBase>();
|
|
||||||
|
|
||||||
for (TransactionDTO transaction : transactionsToImport) {
|
|
||||||
EntityBase entity = jsonObjectMapper.readValue(transaction.getTransactionJson(), EntityBase.class);
|
|
||||||
entitiesToImport.add(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
entityProcessor.processEntityList(null, false, true, false, entitiesToImport);
|
|
||||||
|
|
||||||
for (EntityBase importedEntity : entitiesToImport) {
|
|
||||||
if (importedEntity.getException() != null) {
|
|
||||||
throw importedEntity.getException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
importedEntityCounter += entitiesToImport.size();
|
|
||||||
|
|
||||||
updateTransactionImportCounterInRemote(hostEndpoint, profileDb, username, transactionsToImport);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return importedEntityCounter;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<List<TransactionDTO>> retrieveTransactions(int limit) throws Exception {
|
|
||||||
String username = requestData.getUsername();
|
|
||||||
|
|
||||||
String sqlCheckActiveSubscriptions = "SELECT * " +
|
|
||||||
" FROM stb_subscriptions_user " +
|
|
||||||
" LEFT OUTER JOIN stb_subscriptions_user_detail ssud" +
|
|
||||||
" on stb_subscriptions_user.publication_id = ssud.publication_id and" +
|
|
||||||
" stb_subscriptions_user.user_name = ssud.user_name" +
|
|
||||||
" WHERE stb_subscriptions_user.user_name = " + UtilityDB.valueToString(username) +
|
|
||||||
" AND flag_attivo = 'S'";
|
|
||||||
|
|
||||||
|
|
||||||
List<SubscriptionDTO> activeSubscriptions = new ArrayList<>();
|
|
||||||
|
|
||||||
//Lettura di tutte le sottoscrizioni attive (di tutte le entity)
|
|
||||||
List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sqlCheckActiveSubscriptions);
|
|
||||||
|
|
||||||
if (!result.isEmpty()) {
|
|
||||||
for (HashMap<String, Object> stringObjectHashMap : result) {
|
|
||||||
activeSubscriptions.add(new SubscriptionDTO()
|
|
||||||
.setPublicationId(UtilityHashMap.<String>getValueIfExists(stringObjectHashMap, "publication_id"))
|
|
||||||
.setLastTransactionIDImport(UtilityHashMap.<Integer>getValueIfExists(stringObjectHashMap, "last_transaction_id_import"))
|
|
||||||
.setEntityName(UtilityHashMap.<String>getValueIfExists(stringObjectHashMap, "entity_name"))
|
|
||||||
.setWhereCond(UtilityHashMap.<String>getValueIfExists(stringObjectHashMap, "where_cond_sql")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Estraggo le transazione in base alle sottoscrizioni attive
|
|
||||||
return getTransactionsFromSubscriptions(activeSubscriptions, limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<List<TransactionDTO>> getTransactionsFromSubscriptions(List<SubscriptionDTO> subscriptionList, int limit) throws Exception {
|
|
||||||
List<List<TransactionDTO>> groupOfTransactionsToBeExecuted = new ArrayList<>();
|
|
||||||
|
|
||||||
int totalTransactionsCounter = 0;
|
|
||||||
|
|
||||||
for (SubscriptionDTO subscriptionDTO : subscriptionList) {
|
|
||||||
if (totalTransactionsCounter >= limit) break;
|
|
||||||
|
|
||||||
String sqlToRetrieveMaxGroupTransactionId = "SELECT min(transaction_group_id) as min_group, max(transaction_group_id) as max_group " +
|
|
||||||
"FROM stb_transaction_log_db " +
|
|
||||||
"WHERE transaction_id > " + UtilityDB.valueToString(subscriptionDTO.getLastTransactionIDImport()) + " AND " +
|
|
||||||
"entity_name_list = " + UtilityDB.valueToString(subscriptionDTO.getEntityName());
|
|
||||||
|
|
||||||
HashMap<String, Object> transactionGroupsResult = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sqlToRetrieveMaxGroupTransactionId);
|
|
||||||
|
|
||||||
if (transactionGroupsResult == null) continue;
|
|
||||||
|
|
||||||
Integer minTransactionGroupId = UtilityHashMap.getValueIfExists(transactionGroupsResult, "min_group");
|
|
||||||
Integer maxTransactionGroupId = UtilityHashMap.getValueIfExists(transactionGroupsResult, "max_group");
|
|
||||||
|
|
||||||
if (minTransactionGroupId == null || maxTransactionGroupId == null) continue;
|
|
||||||
|
|
||||||
List<TransactionDTO> transactionsToBeProcessed = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = minTransactionGroupId; i <= maxTransactionGroupId; i++) {
|
|
||||||
if (totalTransactionsCounter >= limit) break;
|
|
||||||
|
|
||||||
String sqlToRetrieveTransactions = "SELECT * " +
|
|
||||||
"FROM stb_transaction_log_db " +
|
|
||||||
"WHERE transaction_group_id = " + UtilityDB.valueToString(i) + " AND " +
|
|
||||||
"entity_name_list = " + UtilityDB.valueToString(subscriptionDTO.getEntityName()) + " " +
|
|
||||||
"ORDER BY transaction_id";
|
|
||||||
|
|
||||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sqlToRetrieveTransactions);
|
|
||||||
|
|
||||||
boolean shouldAdd = true;
|
|
||||||
|
|
||||||
for (HashMap<String, Object> result : results) {
|
|
||||||
TransactionDTO transaction = new TransactionDTO()
|
|
||||||
.setPublicationId(subscriptionDTO.getPublicationId())
|
|
||||||
.setEntityName(UtilityHashMap.<String>getValueIfExists(result, "entity_name_list"))
|
|
||||||
//.setErrorMsg(UtilityHashMap.<String>getValueIfExists(result, "error_msg"))
|
|
||||||
//.setEsito(UtilityHashMap.<String>getValueIfExists(result, "esito"))
|
|
||||||
//.setExecDate(UtilityHashMap.<Date>getValueIfExists(result, "exec_date"))
|
|
||||||
.setTransactionDate(UtilityHashMap.<Date>getValueIfExists(result, "transaction_date"))
|
|
||||||
.setTransactionGroupId(UtilityHashMap.<Integer>getValueIfExists(result, "transaction_group_id"))
|
|
||||||
.setTransactionId(UtilityHashMap.<Integer>getValueIfExists(result, "transaction_id"))
|
|
||||||
.setTransactionJson(UtilityHashMap.<String>getValueIfExists(result, "transaction_json"))
|
|
||||||
.setUsername(UtilityHashMap.<String>getValueIfExists(result, "user_name"));
|
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(subscriptionDTO.getWhereCond())) {
|
|
||||||
Class<? extends EntityBase> entityClass = UtilityHashMap.getValueIfExists(EntitySubTypeHolder.getMapType(), subscriptionDTO.getEntityName().toLowerCase());
|
|
||||||
|
|
||||||
EntityBase entity = jsonObjectMapper.readValue(transaction.getTransactionJson(), EntityBase.class);
|
|
||||||
|
|
||||||
List<EntityBase> tmpList = new ArrayList<>();
|
|
||||||
tmpList.add(entity);
|
|
||||||
|
|
||||||
String selectSql = "SELECT * FROM " + entityClass.getCanonicalName() + " WHERE " + subscriptionDTO.getWhereCond();
|
|
||||||
|
|
||||||
// Create a new Query.
|
|
||||||
Query q = new Query();
|
|
||||||
q.parse(selectSql);
|
|
||||||
|
|
||||||
QueryResults qr = q.execute(tmpList);
|
|
||||||
tmpList = qr.getResults();
|
|
||||||
|
|
||||||
if (tmpList.size() == 0) {
|
|
||||||
shouldAdd = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldAdd) {
|
|
||||||
transactionsToBeProcessed.add(transaction);
|
|
||||||
totalTransactionsCounter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transactionsToBeProcessed.size() > 0) groupOfTransactionsToBeExecuted.add(transactionsToBeProcessed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return groupOfTransactionsToBeExecuted;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void updateTransactionImportCounterInDB(int lastTransactionId, String publicationID, String username) throws Exception {
|
|
||||||
String sql = "UPDATE stb_subscriptions_user " +
|
|
||||||
"SET last_transaction_id_import = " + lastTransactionId + " " +
|
|
||||||
"WHERE publication_id = " + UtilityDB.valueToString(publicationID) + " " +
|
|
||||||
"AND user_name = " + UtilityDB.valueToString(username);
|
|
||||||
|
|
||||||
PreparedStatement psUpdate = multiDBTransactionManager.prepareStatement(sql);
|
|
||||||
psUpdate.executeUpdate();
|
|
||||||
multiDBTransactionManager.commitAll();
|
|
||||||
psUpdate.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTransactionImportCounterInRemote(String hostEndpoint, String profileDb, String username, List<TransactionDTO> importedTransactions) throws Exception {
|
|
||||||
StringBuilder responseBody;
|
|
||||||
String wsUrlEndpoint = hostEndpoint + EmsRestConstants.PATH_ASYNC_BASE_ROUTE + EmsRestConstants.PATH_ASYNC_UPDATE_TRANSACTION_IMPORT_ID;
|
|
||||||
|
|
||||||
List<String> publicationIDs = Stream.of(importedTransactions)
|
|
||||||
.map(transactionDTO -> transactionDTO.getPublicationId())
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
|
|
||||||
List<TransactionDTO> maxOfTransactionsIDList = new ArrayList<>();
|
|
||||||
for (final String publicationId : publicationIDs) {
|
|
||||||
maxOfTransactionsIDList.add(Stream.of(importedTransactions)
|
|
||||||
.filter(transactionDTO -> transactionDTO.getPublicationId().equalsIgnoreCase(publicationId))
|
|
||||||
.max((o1, o2) -> o1.getTransactionId() - o2.getTransactionId()).get());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TransactionDTO transactionDTO : maxOfTransactionsIDList) {
|
|
||||||
int status;
|
|
||||||
int retryCounter = 0;
|
|
||||||
do {
|
|
||||||
HashMap<String, String> queryParams = new HashMap<>();
|
|
||||||
queryParams.put(CommonConstants.PROFILE_DB, profileDb);
|
|
||||||
queryParams.put("publicationID", transactionDTO.getPublicationId());
|
|
||||||
queryParams.put("sender", username);
|
|
||||||
queryParams.put("transactionImportID", "" + transactionDTO.getTransactionId());
|
|
||||||
|
|
||||||
responseBody = new StringBuilder();
|
|
||||||
status = HttpRestWrapper.callGenericGet(wsUrlEndpoint, username, username, responseBody, queryParams);
|
|
||||||
|
|
||||||
retryCounter++;
|
|
||||||
} while (status != 200 && retryCounter < 4);
|
|
||||||
|
|
||||||
if (retryCounter == 4) {
|
|
||||||
throw new Exception("La richiesta \"" + wsUrlEndpoint + "\" ha generato un ESITO KO<br />Body: " + responseBody);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -334,8 +334,8 @@ public class EmsController {
|
|||||||
List<EntityBase> entityList = new ArrayList<>();
|
List<EntityBase> entityList = new ArrayList<>();
|
||||||
|
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
if (obj instanceof EntityBase[]) {
|
if (obj instanceof List) {
|
||||||
entityList = Arrays.asList((EntityBase[]) obj);
|
entityList = (List<EntityBase>) obj;
|
||||||
} else {
|
} else {
|
||||||
entityList.add((EntityBase) obj);
|
entityList.add((EntityBase) obj);
|
||||||
}
|
}
|
||||||
@@ -705,7 +705,7 @@ public class EmsController {
|
|||||||
if (ordinaSuPriorita)
|
if (ordinaSuPriorita)
|
||||||
entityList = entityPropertyHolder.getEntityChain(entityList, multiDBTransactionManager.getPrimaryConnection());
|
entityList = entityPropertyHolder.getEntityChain(entityList, multiDBTransactionManager.getPrimaryConnection());
|
||||||
|
|
||||||
Integer prevTransactionGroupId = null;
|
Long prevTransactionGroupId = null;
|
||||||
|
|
||||||
for (EntityBase entity : entityList) {
|
for (EntityBase entity : entityList) {
|
||||||
entity.setTransactionGroupId(prevTransactionGroupId);
|
entity.setTransactionGroupId(prevTransactionGroupId);
|
||||||
@@ -726,6 +726,7 @@ public class EmsController {
|
|||||||
|
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
|
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import javax.annotation.PreDestroy;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -61,6 +62,10 @@ public class DataSource {
|
|||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
||||||
|
try (final PreparedStatement setNocountOn = connection.prepareStatement("SET NOCOUNT ON")) {
|
||||||
|
boolean resultNoCount = setNocountOn.execute();
|
||||||
|
}
|
||||||
|
|
||||||
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select @@spid AS session_id," +
|
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select @@spid AS session_id," +
|
||||||
" user_name() AS [user_name]," +
|
" user_name() AS [user_name]," +
|
||||||
" suser_name() AS [suser_name]," +
|
" suser_name() AS [suser_name]," +
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.integry.ems.dto;
|
|||||||
|
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EntityHierarchyDTO {
|
public class EntityHierarchyDTO {
|
||||||
@@ -9,6 +10,8 @@ public class EntityHierarchyDTO {
|
|||||||
private Class<? extends EntityBase> clazz;
|
private Class<? extends EntityBase> clazz;
|
||||||
private String entityName;
|
private String entityName;
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
private Field field;
|
||||||
|
private boolean master;
|
||||||
private List<EntityHierarchyDTO> children;
|
private List<EntityHierarchyDTO> children;
|
||||||
|
|
||||||
public Class<? extends EntityBase> getClazz() {
|
public Class<? extends EntityBase> getClazz() {
|
||||||
@@ -36,6 +39,24 @@ public class EntityHierarchyDTO {
|
|||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Field getField() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityHierarchyDTO setField(Field field) {
|
||||||
|
this.field = field;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMaster() {
|
||||||
|
return master;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityHierarchyDTO setMaster(boolean master) {
|
||||||
|
this.master = master;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<EntityHierarchyDTO> getChildren() {
|
public List<EntityHierarchyDTO> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package it.integry.ems.menu;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.menu.dto.MenuConfigDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class MenuStaticCreator {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
System.out.println("Running the Menu UPDATE");
|
||||||
|
|
||||||
|
String connectionString = String.format("jdbc:sqlserver://%s;databaseName=%s;applicationName=%s", "SERVERDB2019", "studioml", "IntelliJ Connection");
|
||||||
|
String username = "sa";
|
||||||
|
String password = "sa";
|
||||||
|
|
||||||
|
Connection connection = DriverManager.getConnection(connectionString, username, password);
|
||||||
|
connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
|
final String baseProjectPath = new File("").getAbsolutePath() + "\\ems-core\\src\\main\\";
|
||||||
|
final String menuJsonResourceFolder = baseProjectPath + "resources\\menus\\";
|
||||||
|
|
||||||
|
ObjectMapper jsonObjectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
final List<StbMenuOpzDTO> stbMenuOpzs = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_menu_opz", StbMenuOpzDTO.class);
|
||||||
|
|
||||||
|
final List<StbTipoAziendaDTO> stbTipoAziendas = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_tipo_azienda", StbTipoAziendaDTO.class);
|
||||||
|
|
||||||
|
final List<StbMenuDTO> stbMenus = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_menu", StbMenuDTO.class);
|
||||||
|
final Map<String, List<StbMenuDTO>> menusByAzienda = stbMenus.stream().collect(Collectors.groupingBy(StbMenuDTO::getTipoAzienda));
|
||||||
|
|
||||||
|
|
||||||
|
MenuConfigDTO menuConfigDTO = new MenuConfigDTO(Integer.parseInt(CommonConstants.DATESTAMP_FORMATTER.format(UtilityLocalDate.getNow())))
|
||||||
|
.setStbMenuOpz(stbMenuOpzs)
|
||||||
|
.setStbTipoAzienda(stbTipoAziendas)
|
||||||
|
.setMenusByAzienda(menusByAzienda);
|
||||||
|
|
||||||
|
writeContentToFile(menuJsonResourceFolder + "menu_config.json", jsonObjectMapper.writeValueAsString(menuConfigDTO), true);
|
||||||
|
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void writeContentToFile(String filePath, String content, boolean overwrite) throws IOException {
|
||||||
|
File f = new File(filePath);
|
||||||
|
if (overwrite && f.exists()) f.delete();
|
||||||
|
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(filePath);
|
||||||
|
byte[] strToBytes = content.getBytes();
|
||||||
|
outputStream.write(strToBytes);
|
||||||
|
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package it.integry.ems.menu.controller;
|
||||||
|
|
||||||
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.menu.service.MenuConfigurationService;
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope("request")
|
||||||
|
@RequestMapping("system/menu")
|
||||||
|
public class MenuConfigurationController {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MenuConfigurationService menuConfigurationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@RequestMapping(value = "refresh", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody
|
||||||
|
ServiceRestResponse refresh(@RequestParam(CommonConstants.PROFILE_DB) String profileDB) throws Exception {
|
||||||
|
menuConfigurationService.refresh(multiDBTransactionManager.getPrimaryConnection());
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MenuConfigDTO {
|
||||||
|
|
||||||
|
private int version;
|
||||||
|
private List<StbMenuOpzDTO> stbMenuOpz;
|
||||||
|
private List<StbTipoAziendaDTO> stbTipoAzienda;
|
||||||
|
private Map<String, List<StbMenuDTO>> menusByAzienda;
|
||||||
|
|
||||||
|
public MenuConfigDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO(int version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setVersion(int version) {
|
||||||
|
this.version = version;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StbMenuOpzDTO> getStbMenuOpz() {
|
||||||
|
return stbMenuOpz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setStbMenuOpz(List<StbMenuOpzDTO> stbMenuOpz) {
|
||||||
|
this.stbMenuOpz = stbMenuOpz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StbTipoAziendaDTO> getStbTipoAzienda() {
|
||||||
|
return stbTipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setStbTipoAzienda(List<StbTipoAziendaDTO> stbTipoAzienda) {
|
||||||
|
this.stbTipoAzienda = stbTipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<StbMenuDTO>> getMenusByAzienda() {
|
||||||
|
return menusByAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setMenusByAzienda(Map<String, List<StbMenuDTO>> menusByAzienda) {
|
||||||
|
this.menusByAzienda = menusByAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
283
ems-core/src/main/java/it/integry/ems/menu/dto/StbMenuDTO.java
Normal file
283
ems-core/src/main/java/it/integry/ems/menu/dto/StbMenuDTO.java
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.entity.StbMenu;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
public class StbMenuDTO {
|
||||||
|
|
||||||
|
private String type = "stb_menu";
|
||||||
|
|
||||||
|
@SqlField(value = "cod_opz", maxLength = 5, nullable = false)
|
||||||
|
private String codOpz;
|
||||||
|
|
||||||
|
@SqlField(value = "cod_parent", maxLength = 5, nullable = false)
|
||||||
|
private String codParent;
|
||||||
|
|
||||||
|
@SqlField(value = "tipo_azienda", maxLength = 40, nullable = false)
|
||||||
|
private String tipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 255, nullable = true)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione_estesa", maxLength = 8000, nullable = true)
|
||||||
|
private String descrizioneEstesa;
|
||||||
|
|
||||||
|
@SqlField(value = "entity_name", maxLength = 40, nullable = true)
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
|
@SqlField(value = "flag_attivo", maxLength = 1, nullable = true, defaultObjectValue = "S")
|
||||||
|
private String flagAttivo;
|
||||||
|
|
||||||
|
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||||
|
private String flagPrinterSetup;
|
||||||
|
|
||||||
|
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
||||||
|
private String gestName;
|
||||||
|
|
||||||
|
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@SqlField(value = "object_type", maxLength = 5, nullable = true)
|
||||||
|
private String objectType;
|
||||||
|
|
||||||
|
@SqlField(value = "open_type", maxLength = 1, nullable = true)
|
||||||
|
private String openType;
|
||||||
|
|
||||||
|
@SqlField(value = "parameter", maxLength = 255, nullable = true)
|
||||||
|
private String parameter;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_menu", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureMenu;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_select", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureSelect;
|
||||||
|
|
||||||
|
@SqlField(value = "pos", nullable = true)
|
||||||
|
private Integer pos;
|
||||||
|
|
||||||
|
@SqlField(value = "pos_cliente", nullable = true)
|
||||||
|
private Integer posCliente;
|
||||||
|
|
||||||
|
@SqlField(value = "pos_tipo_azienda", nullable = true)
|
||||||
|
private Integer posTipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "type", maxLength = -1, nullable = true, defaultObjectValue = "F")
|
||||||
|
private String menuType;
|
||||||
|
|
||||||
|
@SqlField(value = "url_descrizione", maxLength = 1024, nullable = true)
|
||||||
|
private String urlDescrizione;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodOpz() {
|
||||||
|
return codOpz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setCodOpz(String codOpz) {
|
||||||
|
this.codOpz = codOpz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodParent() {
|
||||||
|
return codParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setCodParent(String codParent) {
|
||||||
|
this.codParent = codParent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTipoAzienda() {
|
||||||
|
return tipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setTipoAzienda(String tipoAzienda) {
|
||||||
|
this.tipoAzienda = tipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizioneEstesa() {
|
||||||
|
return descrizioneEstesa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setDescrizioneEstesa(String descrizioneEstesa) {
|
||||||
|
this.descrizioneEstesa = descrizioneEstesa;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntityName() {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setEntityName(String entityName) {
|
||||||
|
this.entityName = entityName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlagAttivo() {
|
||||||
|
return flagAttivo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setFlagAttivo(String flagAttivo) {
|
||||||
|
this.flagAttivo = flagAttivo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlagPrinterSetup() {
|
||||||
|
return flagPrinterSetup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setFlagPrinterSetup(String flagPrinterSetup) {
|
||||||
|
this.flagPrinterSetup = flagPrinterSetup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGestName() {
|
||||||
|
return gestName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setGestName(String gestName) {
|
||||||
|
this.gestName = gestName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setNote(String note) {
|
||||||
|
this.note = note;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getObjectType() {
|
||||||
|
return objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setObjectType(String objectType) {
|
||||||
|
this.objectType = objectType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenType() {
|
||||||
|
return openType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setOpenType(String openType) {
|
||||||
|
this.openType = openType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setParameter(String parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureMenu() {
|
||||||
|
return pictureMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPictureMenu(String pictureMenu) {
|
||||||
|
this.pictureMenu = pictureMenu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureSelect() {
|
||||||
|
return pictureSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPictureSelect(String pictureSelect) {
|
||||||
|
this.pictureSelect = pictureSelect;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPos() {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPos(Integer pos) {
|
||||||
|
this.pos = pos;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPosCliente() {
|
||||||
|
return posCliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPosCliente(Integer posCliente) {
|
||||||
|
this.posCliente = posCliente;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPosTipoAzienda() {
|
||||||
|
return posTipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPosTipoAzienda(Integer posTipoAzienda) {
|
||||||
|
this.posTipoAzienda = posTipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMenuType() {
|
||||||
|
return menuType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setMenuType(String menuType) {
|
||||||
|
this.menuType = menuType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrlDescrizione() {
|
||||||
|
return urlDescrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setUrlDescrizione(String urlDescrizione) {
|
||||||
|
this.urlDescrizione = urlDescrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenu toEntity() {
|
||||||
|
return new StbMenu()
|
||||||
|
.setCodOpz(getCodOpz())
|
||||||
|
.setCodParent(UtilityString.isNullOrEmpty(getCodParent()) ? "ROOT" : getCodParent())
|
||||||
|
.setTipoAzienda(getTipoAzienda())
|
||||||
|
.setDescrizione(getDescrizione())
|
||||||
|
.setDescrizioneEstesa(getDescrizioneEstesa())
|
||||||
|
.setEntityName(getEntityName())
|
||||||
|
.setFlagAttivo(getFlagAttivo())
|
||||||
|
.setFlagPrinterSetup(getFlagPrinterSetup())
|
||||||
|
.setGestName(getGestName())
|
||||||
|
.setNote(getNote())
|
||||||
|
.setObjectType(getObjectType())
|
||||||
|
.setOpenType(getOpenType())
|
||||||
|
.setParameter(getParameter())
|
||||||
|
.setPictureMenu(getPictureMenu())
|
||||||
|
.setPictureSelect(getPictureSelect())
|
||||||
|
.setPos(getPos())
|
||||||
|
.setPosCliente(getPosCliente())
|
||||||
|
.setPosTipoAzienda(getPosTipoAzienda())
|
||||||
|
.setMenuType(getMenuType())
|
||||||
|
.setUrlDescrizione(getUrlDescrizione());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.entity.StbMenuOpz;
|
||||||
|
|
||||||
|
public class StbMenuOpzDTO {
|
||||||
|
|
||||||
|
private String type = "stb_menu_opz";
|
||||||
|
|
||||||
|
@SqlField(value = "cod_opz", maxLength = 5, nullable = false)
|
||||||
|
private String codOpz;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 255, nullable = false)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
@SqlField(value = "entity_name", maxLength = 40, nullable = true)
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
|
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||||
|
private String flagPrinterSetup;
|
||||||
|
|
||||||
|
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
||||||
|
private String gestName;
|
||||||
|
|
||||||
|
@SqlField(value = "is_deprecated", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||||
|
private String isDeprecated;
|
||||||
|
|
||||||
|
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@SqlField(value = "object_type", maxLength = 5, nullable = true)
|
||||||
|
private String objectType;
|
||||||
|
|
||||||
|
@SqlField(value = "open_type", maxLength = 1, nullable = true)
|
||||||
|
private String openType;
|
||||||
|
|
||||||
|
@SqlField(value = "parameter", maxLength = 255, nullable = true)
|
||||||
|
private String parameter;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_menu", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureMenu;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_select", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureSelect;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodOpz() {
|
||||||
|
return codOpz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setCodOpz(String codOpz) {
|
||||||
|
this.codOpz = codOpz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntityName() {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setEntityName(String entityName) {
|
||||||
|
this.entityName = entityName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlagPrinterSetup() {
|
||||||
|
return flagPrinterSetup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setFlagPrinterSetup(String flagPrinterSetup) {
|
||||||
|
this.flagPrinterSetup = flagPrinterSetup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGestName() {
|
||||||
|
return gestName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setGestName(String gestName) {
|
||||||
|
this.gestName = gestName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsDeprecated() {
|
||||||
|
return isDeprecated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setIsDeprecated(String isDeprecated) {
|
||||||
|
this.isDeprecated = isDeprecated;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setNote(String note) {
|
||||||
|
this.note = note;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getObjectType() {
|
||||||
|
return objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setObjectType(String objectType) {
|
||||||
|
this.objectType = objectType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenType() {
|
||||||
|
return openType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setOpenType(String openType) {
|
||||||
|
this.openType = openType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setParameter(String parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureMenu() {
|
||||||
|
return pictureMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setPictureMenu(String pictureMenu) {
|
||||||
|
this.pictureMenu = pictureMenu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureSelect() {
|
||||||
|
return pictureSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setPictureSelect(String pictureSelect) {
|
||||||
|
this.pictureSelect = pictureSelect;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StbMenuOpz toEntity() {
|
||||||
|
return new StbMenuOpz()
|
||||||
|
.setCodOpz(getCodOpz())
|
||||||
|
.setDescrizione(getDescrizione())
|
||||||
|
.setEntityName(getEntityName())
|
||||||
|
.setFlagPrinterSetup(getFlagPrinterSetup())
|
||||||
|
.setGestName(getGestName())
|
||||||
|
.setIsDeprecated(getIsDeprecated())
|
||||||
|
.setNote(getNote())
|
||||||
|
.setObjectType(getObjectType())
|
||||||
|
.setOpenType(getOpenType())
|
||||||
|
.setParameter(getParameter())
|
||||||
|
.setPictureMenu(getPictureMenu())
|
||||||
|
.setPictureSelect(getPictureSelect());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.entity.StbTipoAzienda;
|
||||||
|
|
||||||
|
public class StbTipoAziendaDTO {
|
||||||
|
|
||||||
|
private String type = "stb_tipo_azienda";
|
||||||
|
|
||||||
|
@SqlField(value = "tipo_azienda", maxLength = 40, nullable = false)
|
||||||
|
private String tipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 1024)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAziendaDTO setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTipoAzienda() {
|
||||||
|
return tipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAziendaDTO setTipoAzienda(String tipoAzienda) {
|
||||||
|
this.tipoAzienda = tipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAziendaDTO setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StbTipoAzienda toEntity() {
|
||||||
|
return new StbTipoAzienda()
|
||||||
|
.setTipoAzienda(getTipoAzienda())
|
||||||
|
.setDescrizione(getDescrizione());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
package it.integry.ems.menu.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import it.integry.annotations.PostContextAutowired;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.menu.dto.MenuConfigDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
||||||
|
import it.integry.ems.settings.SettingsController;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.entity.Azienda;
|
||||||
|
import it.integry.ems_model.entity.StbMenu;
|
||||||
|
import it.integry.ems_model.entity.StbMenuOpz;
|
||||||
|
import it.integry.ems_model.entity.StbTipoAzienda;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static it.integry.ems_model.utility.UtilityDB.executeStatement;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MenuConfigurationService {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingsController settingsController;
|
||||||
|
|
||||||
|
@PostContextAutowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@PostContextConstruct(priority = 5)
|
||||||
|
public void init() throws Exception {
|
||||||
|
if(UtilityDebug.isDebugExecution()) return;
|
||||||
|
|
||||||
|
logger.debug(MenuConfigurationService.class.getSimpleName() + ": Refresh menu");
|
||||||
|
|
||||||
|
final MenuConfigDTO menuConfig = loadMenuData();
|
||||||
|
|
||||||
|
for (AdvancedDataSource advancedDataSource : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
|
||||||
|
if (advancedDataSource.getDataSource().getDbName().equalsIgnoreCase("studioml") || isHistoryDB(advancedDataSource))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
||||||
|
internalRefresh(advancedDataSource.getConnection(), menuConfig);
|
||||||
|
//logger.debug("Menu refresh time: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Errore durante l'aggiornamento del menu di " + advancedDataSource.getProfileName(), ex);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHistoryDB(AdvancedDataSource advancedDataSource) throws Exception {
|
||||||
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
|
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(Connection connection) throws Exception {
|
||||||
|
final MenuConfigDTO menuConfig = loadMenuData();
|
||||||
|
internalRefresh(connection, menuConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MenuConfigDTO loadMenuData() throws IOException {
|
||||||
|
|
||||||
|
ObjectMapper jsonObjectMapper = new ObjectMapper();
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
|
||||||
|
final URL resourceMenuConfigURL = classLoader.getResource("menus/menu_config.json");
|
||||||
|
final MenuConfigDTO menuConfig = jsonObjectMapper.readValue(resourceMenuConfigURL, MenuConfigDTO.class);
|
||||||
|
|
||||||
|
return menuConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalRefresh(Connection connection, MenuConfigDTO menuConfig) throws Exception {
|
||||||
|
final Azienda azienda = Azienda.getDefaultAzienda(connection);
|
||||||
|
int lastMenuUpd = Integer.parseInt(azienda.getLastUpgDbMenu().replace("QM", ""));
|
||||||
|
|
||||||
|
if (menuConfig.getVersion() <= lastMenuUpd)
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(connection, "DELETE FROM stb_menu",
|
||||||
|
"EXECUTE dbo.DropForeignKey 'azienda', 'stb_tipo_azienda'",
|
||||||
|
"DELETE FROM stb_tipo_azienda",
|
||||||
|
"DELETE FROM stb_menu_opz");
|
||||||
|
|
||||||
|
for (StbMenuOpzDTO stbMenuOpzDto : menuConfig.getStbMenuOpz()) {
|
||||||
|
StbMenuOpz stbMenuOpz = stbMenuOpzDto.toEntity();
|
||||||
|
stbMenuOpz.setOperation(OperationType.INSERT);
|
||||||
|
stbMenuOpz.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (StbTipoAziendaDTO stbTipoAziendaDto : menuConfig.getStbTipoAzienda()) {
|
||||||
|
StbTipoAzienda stbTipoAzienda = stbTipoAziendaDto.toEntity();
|
||||||
|
stbTipoAzienda.setOperation(OperationType.INSERT);
|
||||||
|
stbTipoAzienda.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<StbMenuDTO> stbMenus = menuConfig.getMenusByAzienda().get(azienda.getTipoAzienda().toUpperCase());
|
||||||
|
|
||||||
|
if (stbMenus == null)
|
||||||
|
logger.error("Nessuna configurazione trovata per il menu " + azienda.getTipoAzienda() + " di " + azienda.getNomeDitta());
|
||||||
|
else
|
||||||
|
for (StbMenuDTO stbMenuDto : stbMenus) {
|
||||||
|
StbMenu stbMenu = stbMenuDto.toEntity();
|
||||||
|
stbMenu.setOperation(OperationType.INSERT);
|
||||||
|
stbMenu.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
executeStatement(connection, "ALTER TABLE azienda ADD CONSTRAINT FK_azienda_stb_tipo_azienda FOREIGN KEY (tipo_azienda) REFERENCES stb_tipo_azienda ( tipo_azienda )",
|
||||||
|
"DELETE FROM stb_abil WHERE cod_opz not in (select cod_opz from stb_menu_opz )",
|
||||||
|
"INSERT INTO stb_Abil SELECT opz2Abil.cod_parent AS cod_opz, opz2Abil.user_name, 'S' flag_Abil, NULL gest_name\n" +
|
||||||
|
"FROM (SELECT DISTINCT opz.cod_parent, abil.user_name\n" +
|
||||||
|
" FROM stb_menu opz\n" +
|
||||||
|
" LEFT OUTER JOIN stb_menu root ON opz.cod_parent = root.cod_opz,\n" +
|
||||||
|
" stb_abil Abil,\n" +
|
||||||
|
" azienda\n" +
|
||||||
|
" WHERE opz.cod_parent <> 'ROOT'\n" +
|
||||||
|
" AND ISNULL(root.cod_parent, '') <> 'WM002'\n" +
|
||||||
|
" AND opz.cod_opz = abil.cod_opz\n" +
|
||||||
|
" AND opz.tipo_azienda = azienda.tipo_azienda\n" +
|
||||||
|
" AND abil.flag_Abil <> 'N') Opz2Abil\n" +
|
||||||
|
" LEFT OUTER JOIN stb_Abil ON stb_Abil.cod_opz = Opz2Abil.cod_parent AND stb_abil.user_name = Opz2Abil.user_name\n" +
|
||||||
|
"WHERE stb_abil.cod_opz IS NULL",
|
||||||
|
"UPDATE azienda SET last_upg_db_menu = " + UtilityDB.valueToString("QM" + menuConfig.getVersion()));
|
||||||
|
|
||||||
|
|
||||||
|
connection.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,7 +66,13 @@ public class MigrationService {
|
|||||||
.sortBy(Class::getSimpleName)
|
.sortBy(Class::getSimpleName)
|
||||||
.toList());
|
.toList());
|
||||||
|
|
||||||
|
if (UtilityDebug.isDebugExecution())
|
||||||
|
return;
|
||||||
|
|
||||||
|
startMigrationsGlobally(multiDBTransactionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startMigrationsGlobally(MultiDBTransactionManager multiDBTransactionManager) {
|
||||||
List<AdvancedDataSource> advancedDataSources;
|
List<AdvancedDataSource> advancedDataSources;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -98,7 +104,10 @@ public class MigrationService {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
||||||
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
||||||
|
//logger.debug("MIGRATION TIME: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
||||||
|
|
||||||
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
advancedDataSource.getConnection().commit();
|
||||||
@@ -125,6 +134,7 @@ public class MigrationService {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
|
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
|
||||||
AdvancedDataSource advancedDataSource,
|
AdvancedDataSource advancedDataSource,
|
||||||
SettingsController settingsController,
|
SettingsController settingsController,
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package it.integry.ems.migration._base;
|
package it.integry.ems.migration._base;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseScheduledOperationDTO;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.entity.StbGestSetup;
|
||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.Query;
|
import it.integry.ems_model.utility.Query;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -13,6 +17,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.springframework.web.context.ContextLoader;
|
import org.springframework.web.context.ContextLoader;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class BaseMigration implements MigrationModelInterface {
|
public abstract class BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
@@ -67,6 +72,11 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
return val != null && val == 1;
|
return val != null && val == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void renameColumn(Connection connection, String tableName, String oldColumnname, String newColumnName) throws SQLException {
|
||||||
|
String sql = "exec sp_rename 'dbo." + tableName + "." + oldColumnname + "', " + newColumnName + ", 'COLUMN'";
|
||||||
|
executeStatement(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean existsTable(Connection connection, String tableName) throws SQLException {
|
protected boolean existsTable(Connection connection, String tableName) throws SQLException {
|
||||||
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N%s", tableName);
|
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N%s", tableName);
|
||||||
|
|
||||||
@@ -102,4 +112,74 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
String dropSql = "DROP TABLE " + tableName;
|
String dropSql = "DROP TABLE " + tableName;
|
||||||
executeStatement(connection, dropSql);
|
executeStatement(connection, dropSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void createSetup(Connection connection, String gestName, String section, String keySection, String value, String description, String codQuery) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection)
|
||||||
|
.setValue(value)
|
||||||
|
.setDescription(description)
|
||||||
|
.setQueryDefault(codQuery);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void deleteSetup(Connection connection, String gestName, String section, String keySection) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.DELETE);
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateSetupValue(Connection connection, String gestName, String section, String keySection, String newValue) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection)
|
||||||
|
.setValue(newValue);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.UPDATE);
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(120 * 1000);
|
||||||
|
|
||||||
|
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
|
||||||
|
automatedOperationHandlerComponent.add(operation);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAutomatedOperations(List<? extends BaseScheduledOperationDTO> operations) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(120 * 1000);
|
||||||
|
|
||||||
|
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
|
||||||
|
for (BaseScheduledOperationDTO operation : operations)
|
||||||
|
automatedOperationHandlerComponent.add(operation);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ public class MigrationSetupController {
|
|||||||
return ServiceRestResponse.createPositiveResponse(migrationSetupService.retrieveAll());
|
return ServiceRestResponse.createPositiveResponse(migrationSetupService.retrieveAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "executeAll", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody ServiceRestResponse executeAll() throws Exception {
|
||||||
|
migrationSetupService.executeAll();
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "{migrationCode}/retry", method = RequestMethod.POST)
|
@RequestMapping(value = "{migrationCode}/retry", method = RequestMethod.POST)
|
||||||
public @ResponseBody ServiceRestResponse retryMigration(@PathVariable long migrationCode) throws Exception {
|
public @ResponseBody ServiceRestResponse retryMigration(@PathVariable long migrationCode) throws Exception {
|
||||||
migrationSetupService.retry(migrationCode);
|
migrationSetupService.retry(migrationCode);
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240219094933 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "ALTER TABLE mtb_colt\n" +
|
||||||
|
" ADD barcode_ul VARCHAR(20)";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240219103840 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup(advancedDataSource.getConnection(),
|
||||||
|
"PICKING", "ACCETTAZIONE", "FLAG_ALLOW_BARCODE_FORNITORE", "N",
|
||||||
|
"Abilita la possibilità di effettuare l'accettazione merci utilizzando direttamente l'SSCC del fornitore (salvato poi nella colonna barcode_pedana)",
|
||||||
|
"SI_NO");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240220114903 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "EXEC DropDefault 'mtb_colr', 'causale';\n" +
|
||||||
|
"ALTER TABLE mtb_colr\n" +
|
||||||
|
" ALTER COLUMN causale TINYINT NOT NULL;\n" +
|
||||||
|
"ALTER TABLE mtb_colr\n" +
|
||||||
|
" ADD DEFAULT 0 FOR causale;";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240221190821 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup(advancedDataSource.getConnection(),
|
||||||
|
"DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "N",
|
||||||
|
"Abilita l'ansi padding nella connessione del gestionale. Il valore suggerito è ON (prima era OFF).",
|
||||||
|
"SI_NO");
|
||||||
|
|
||||||
|
createSetup(advancedDataSource.getConnection(),
|
||||||
|
"DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "N",
|
||||||
|
"Abilita il concat null yields null nella connessione del gestionale. Il valore suggerito è ON (prima era OFF).",
|
||||||
|
"SI_NO");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240228160024 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dropTable(advancedDataSource.getConnection(), "stb_subscriptions_user_detail");
|
||||||
|
dropTable(advancedDataSource.getConnection(), "stb_subscriptions_user");
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(),
|
||||||
|
|
||||||
|
"CREATE TABLE dbo.stb_remote_subscription\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY\n" +
|
||||||
|
" CONSTRAINT stb_remote_subscription_pk\n" +
|
||||||
|
" PRIMARY KEY,\n" +
|
||||||
|
" publication_id BIGINT NOT NULL,\n" +
|
||||||
|
" publication_description VARCHAR(MAX),\n" +
|
||||||
|
" endpoint_protocol VARCHAR(5) DEFAULT 'HTTP' NOT NULL,\n" +
|
||||||
|
" endpoint_host VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" endpoint_port INT DEFAULT 80 NOT NULL,\n" +
|
||||||
|
" username VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" password VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" profile_db VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" last_transaction_id BIGINT,\n" +
|
||||||
|
" last_transaction_id_imported BIGINT,\n" +
|
||||||
|
" active BIT DEFAULT 0 NOT NULL\n" +
|
||||||
|
")",
|
||||||
|
|
||||||
|
"EXEC sp_addextendedproperty 'MS_Description', 'HTTP or HTTPS', 'SCHEMA', 'dbo', 'TABLE', 'stb_remote_subscription',\n" +
|
||||||
|
" 'COLUMN', 'endpoint_protocol'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
|
public class Migration_20240304165725 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (advancedDataSource.getProfileName().equalsIgnoreCase("carelli") ||
|
||||||
|
advancedDataSource.getProfileName().equalsIgnoreCase("gestfood") ||
|
||||||
|
advancedDataSource.getProfileName().equalsIgnoreCase("panimal")) {
|
||||||
|
|
||||||
|
String sql = "UPDATE carelli_giacenza_prog\n" +
|
||||||
|
"SET tipo_car = 'R'\n" +
|
||||||
|
"WHERE tipo_car = 'C'";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import com.annimon.stream.Stream;
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ExportAutomatedOperationDTO;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20240307103608 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<String> elencoDb = new ArrayList<String>() {{
|
||||||
|
add("CARELLI");
|
||||||
|
add("GESTFOOD");
|
||||||
|
add("PANIMAL");
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (elencoDb.stream().noneMatch(x -> x.equalsIgnoreCase(advancedDataSource.getDataSource().getDbName())))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql =
|
||||||
|
"SELECT UPPER(stb_user.user_name) AS user_name,\n" +
|
||||||
|
" dbo.sys_dcd_pss(stb_user.password) AS password,\n" +
|
||||||
|
" mtb_depo.cod_mdep\n" +
|
||||||
|
"FROM stb_user\n" +
|
||||||
|
" INNER JOIN wtb_depo ON stb_user.user_name = wtb_depo.user_name\n" +
|
||||||
|
" INNER JOIN mtb_depo ON wtb_depo.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||||
|
" INNER JOIN wtb_users_info\n" +
|
||||||
|
" ON stb_user.user_name = wtb_users_info.user_name AND wtb_users_info.export_type = 'VARIAZIONE PV'\n" +
|
||||||
|
"WHERE stb_user.flag_attivo = 'S'\n" +
|
||||||
|
" AND mtb_depo.flag_movimentabile = 'S'\n" +
|
||||||
|
" AND wtb_users_info.flag_state = 'S'\n" +
|
||||||
|
" AND stb_user.key_group = '10'";
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> elencoUtenti = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
|
||||||
|
|
||||||
|
List<ExportAutomatedOperationDTO> operations = new ArrayList<>();
|
||||||
|
for (HashMap<String, Object> user : elencoUtenti) {
|
||||||
|
final String operationName = "Invio Variazioni Griglia - " + user.get("cod_mdep");
|
||||||
|
|
||||||
|
|
||||||
|
ExportAutomatedOperationDTO exportAutomatedOperationDTO =
|
||||||
|
new ExportAutomatedOperationDTO()
|
||||||
|
.setFormat("XML_DIALOGO")
|
||||||
|
.setType("VARIAZIONE PV")
|
||||||
|
.setUsername((String) user.get("user_name"))
|
||||||
|
.setPassword((String) user.get("password"))
|
||||||
|
.setJsonRequest("{ \t\"tipoReport\": \"G\" }")
|
||||||
|
.setProfileDb(advancedDataSource.getProfileName());
|
||||||
|
exportAutomatedOperationDTO
|
||||||
|
.setCronTrigger("0 0 22 1/1 * *")
|
||||||
|
.setName(operationName);
|
||||||
|
|
||||||
|
operations.add(exportAutomatedOperationDTO);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
addAutomatedOperations(operations);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20240307123633 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<String> elencoDb = new ArrayList<String>() {{
|
||||||
|
add("CARELLI");
|
||||||
|
add("GESTFOOD");
|
||||||
|
add("PANIMAL");
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (elencoDb.stream().noneMatch(x -> x.equalsIgnoreCase(advancedDataSource.getDataSource().getDbName())))
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), "UPDATE vtb_promo SET flag_tipo_promo = 'T' WHERE cod_promo like '%TAGLIO%'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.migration.service;
|
package it.integry.ems.migration.service;
|
||||||
|
|
||||||
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
import it.integry.ems.migration.MigrationService;
|
import it.integry.ems.migration.MigrationService;
|
||||||
import it.integry.ems.migration.dto.MigrationStatusDTO;
|
import it.integry.ems.migration.dto.MigrationStatusDTO;
|
||||||
@@ -124,4 +125,16 @@ public class MigrationSetupService {
|
|||||||
migrationService.updateLastMigrationIntoDB(advancedDataSource, migrationCode);
|
migrationService.updateLastMigrationIntoDB(advancedDataSource, migrationCode);
|
||||||
migrationService.executeMigrationGroup(advancedDataSource);
|
migrationService.executeMigrationGroup(advancedDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void executeAll() throws Exception {
|
||||||
|
for (AvailableConnectionsModel availableConnectionsModel : settingsModel.getAvailableConnections()) {
|
||||||
|
if (!Stream.of(multiDBTransactionManager.getActiveConnections())
|
||||||
|
.anyMatch(advancedDataSource -> advancedDataSource.getDataSource().getDbName().equalsIgnoreCase(availableConnectionsModel.getDbName()))) {
|
||||||
|
multiDBTransactionManager.addConnection(availableConnectionsModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
migrationService.startMigrationsGlobally(multiDBTransactionManager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import it.integry.ems_model.types.OperationType;
|
|||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.kie.api.runtime.rule.ConsequenceException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
@@ -80,9 +79,6 @@ public class ServiceRestResponse {
|
|||||||
public ServiceRestResponse(EsitoType esito, String profileDb, Exception e) {
|
public ServiceRestResponse(EsitoType esito, String profileDb, Exception e) {
|
||||||
this(esito);
|
this(esito);
|
||||||
|
|
||||||
if (esito == EsitoType.KO)
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
this.profileDB = profileDb;
|
this.profileDB = profileDb;
|
||||||
this.errorType = e.getClass().getCanonicalName();
|
this.errorType = e.getClass().getCanonicalName();
|
||||||
this.errorMessage = e.getMessage();
|
this.errorMessage = e.getMessage();
|
||||||
|
|||||||
@@ -447,31 +447,31 @@ public class AccountingBusinessLogic {
|
|||||||
if (UtilityString.isNullOrEmpty(tipoPartita)) tipoPartita = 1;
|
if (UtilityString.isNullOrEmpty(tipoPartita)) tipoPartita = 1;
|
||||||
|
|
||||||
BigDecimal impScad = ctbScadOrig.getImpDare().subtract(ctbScadOrig.getImpAvere());
|
BigDecimal impScad = ctbScadOrig.getImpDare().subtract(ctbScadOrig.getImpAvere());
|
||||||
Date dataPag = ctbScadOrig.getDataPag();
|
|
||||||
impScad = impScad.abs();
|
impScad = impScad.abs();
|
||||||
|
|
||||||
if (residuo.compareTo(BigDecimal.ZERO) > 0 && dataPag == null) {
|
if (!UtilityBigDecimal.isNullOrZero(residuo) && ctbScadOrig.getDataPag() == null ) {
|
||||||
residuo = residuo.abs();
|
residuo = residuo.abs();
|
||||||
if (residuo.compareTo(impScad) >= 0) {
|
if (UtilityBigDecimal.equalsOrGreaterThan(residuo, impScad)) {
|
||||||
if (residuo.equals(impScad)) {
|
if (UtilityBigDecimal.equalsTo(residuo, impScad)) {
|
||||||
residuo = BigDecimal.ZERO;
|
residuo = BigDecimal.ZERO;
|
||||||
} else {
|
} else {
|
||||||
// il controllo del segno della partita è necessario solo nel caso in cui si passa un importo a copertuta di più scadenze che si possono compensare
|
// il controllo del segno della partita è necessario solo nel caso in cui si passa un importo a copertuta di più scadenze che si possono compensare
|
||||||
// registrazione dei titoli
|
// registrazione dei titoli
|
||||||
if (tipoPartita == 1 || countScad == 1) {
|
if (tipoPartita == TipoPartita.ATTIVA.getValue() || countScad == 1) {
|
||||||
residuo = residuo.subtract(impScad);
|
residuo = residuo.subtract(impScad);
|
||||||
} else if (tipoPartita == 0) {
|
} else if (tipoPartita == 0) {
|
||||||
residuo = residuo.add(impScad);
|
residuo = residuo.add(impScad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctbScadOrig.getImpDare().compareTo(BigDecimal.ZERO) > 0) {
|
if (!UtilityBigDecimal.isNullOrZero(ctbScadOrig.getImpDare())) {
|
||||||
ctbScadOrig.setImpAvere(impScad);
|
ctbScadOrig.setImpAvere(impScad);
|
||||||
} else {
|
} else {
|
||||||
ctbScadOrig.setImpDare(impScad);
|
ctbScadOrig.setImpDare(impScad);
|
||||||
}
|
}
|
||||||
ctbScadOrig.setDataPag(dataCmov);
|
ctbScadOrig.setDataPag(dataCmov);
|
||||||
ctbScadOrig.setIdRigaMov(idRigaMov);
|
ctbScadOrig.setIdRigaMov(idRigaMov);
|
||||||
|
ctbScadOrig.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
} else {
|
} else {
|
||||||
//Clona scadenza
|
//Clona scadenza
|
||||||
CtbScad ctbScadNew = (CtbScad) ctbScadOrig.clone();
|
CtbScad ctbScadNew = (CtbScad) ctbScadOrig.clone();
|
||||||
@@ -481,6 +481,7 @@ public class AccountingBusinessLogic {
|
|||||||
ctbScadOrig.setImpAvere(residuo);
|
ctbScadOrig.setImpAvere(residuo);
|
||||||
ctbScadOrig.setDataPag(dataCmov);
|
ctbScadOrig.setDataPag(dataCmov);
|
||||||
ctbScadOrig.setIdRigaMov(idRigaMov);
|
ctbScadOrig.setIdRigaMov(idRigaMov);
|
||||||
|
ctbScadOrig.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
|
|
||||||
// calcola importo residuo della nuova scadenza
|
// calcola importo residuo della nuova scadenza
|
||||||
residuo = residuo.subtract(impScad);
|
residuo = residuo.subtract(impScad);
|
||||||
@@ -494,6 +495,7 @@ public class AccountingBusinessLogic {
|
|||||||
} else {
|
} else {
|
||||||
ctbScadNew.setImpAvere(residuo.abs());
|
ctbScadNew.setImpAvere(residuo.abs());
|
||||||
}
|
}
|
||||||
|
residuo = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elencoScadenzeNew.add(ctbScadOrig);
|
elencoScadenzeNew.add(ctbScadOrig);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.sql.ResultSet;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
public class LoadColliService {
|
public class LoadColliService {
|
||||||
@@ -262,6 +264,16 @@ public class LoadColliService {
|
|||||||
dtbDoct.setMtbColt(mtbColt);
|
dtbDoct.setMtbColt(mtbColt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Acquisizione ID_LOTTO del primo collo da agganciare
|
||||||
|
if (loadDatiFromDB) {
|
||||||
|
query = "SELECT TOP 1 id_lotto FROM mtb_colt ";
|
||||||
|
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||||
|
Integer idLotto = (Integer) getSingleValue(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||||
|
if (idLotto != null){
|
||||||
|
dtbDoct.setIdLotto(idLotto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Stream.of(loadColli.getColli()).forEach(x -> x.setUpdateColliFromDoc(true));
|
Stream.of(loadColli.getColli()).forEach(x -> x.setUpdateColliFromDoc(true));
|
||||||
|
|
||||||
//AGGIUNGERE CAMPI CHE PASSIAMO DA FUORI
|
//AGGIUNGERE CAMPI CHE PASSIAMO DA FUORI
|
||||||
@@ -585,7 +597,8 @@ public class LoadColliService {
|
|||||||
" dtb_ordr.cod_promo as 'cod_promo', " +
|
" dtb_ordr.cod_promo as 'cod_promo', " +
|
||||||
" dtb_ordr.cod_art_for as 'cod_art_for', " +
|
" dtb_ordr.cod_art_for as 'cod_art_for', " +
|
||||||
" mvw_kit.flag_kit as 'articolo_composto', " +
|
" mvw_kit.flag_kit as 'articolo_composto', " +
|
||||||
" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom) as 'cod_jcom', " +
|
/*" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom) as 'cod_jcom', " +*/
|
||||||
|
" dtb_ordr.cod_jcom as 'cod_jcom', " +
|
||||||
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2) as 'unt_doc2', " +
|
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2) as 'unt_doc2', " +
|
||||||
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3) as 'unt_doc3', " +
|
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3) as 'unt_doc3', " +
|
||||||
" mtb_aart.tara_kg as 'tara_kg', " +
|
" mtb_aart.tara_kg as 'tara_kg', " +
|
||||||
@@ -652,7 +665,8 @@ public class LoadColliService {
|
|||||||
" mtb_aart.flag_stato, " +
|
" mtb_aart.flag_stato, " +
|
||||||
" dtb_ordr.cod_art_for, " +
|
" dtb_ordr.cod_art_for, " +
|
||||||
" mvw_kit.flag_kit, " +
|
" mvw_kit.flag_kit, " +
|
||||||
" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom), " +
|
/*" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom), " +*/
|
||||||
|
" dtb_ordr.cod_jcom, " +
|
||||||
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2), " +
|
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2), " +
|
||||||
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3), " +
|
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3), " +
|
||||||
" mtb_aart.tara_kg, " +
|
" mtb_aart.tara_kg, " +
|
||||||
|
|||||||
@@ -18,4 +18,8 @@ public enum TipoPartita {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import it.integry.ems_model.types.OperationType;
|
|||||||
import it.integry.ems_model.utility.*;
|
import it.integry.ems_model.utility.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -451,6 +452,7 @@ public class AccountingRules extends QueryRules {
|
|||||||
List<CtbScad> elencoScadenzeNew = new ArrayList<>();
|
List<CtbScad> elencoScadenzeNew = new ArrayList<>();
|
||||||
String finalDesAgg = desAgg;
|
String finalDesAgg = desAgg;
|
||||||
for (CtbScad scad : ctbMovr.getCtbScad()) {
|
for (CtbScad scad : ctbMovr.getCtbScad()) {
|
||||||
|
|
||||||
CtbScad ctbScad = (CtbScad) scad.clone();
|
CtbScad ctbScad = (CtbScad) scad.clone();
|
||||||
|
|
||||||
com.annimon.stream.Optional<CtbParr> ctbParrFirst = Stream.of(elencoPartite)
|
com.annimon.stream.Optional<CtbParr> ctbParrFirst = Stream.of(elencoPartite)
|
||||||
@@ -466,24 +468,29 @@ public class AccountingRules extends QueryRules {
|
|||||||
if (ctbParrFirst.isPresent()) {
|
if (ctbParrFirst.isPresent()) {
|
||||||
elencoPartite.remove(ctbParrFirst.get());
|
elencoPartite.remove(ctbParrFirst.get());
|
||||||
ctbParr = ctbParrFirst.get();
|
ctbParr = ctbParrFirst.get();
|
||||||
if (ctbParr.getTipoPartitaEnum() == TipoPartita.PASSIVA) {
|
if (UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO)) {
|
||||||
ctbParr.setImpDare(ctbParr.getImpDare().add(ctbScad.getImpDare()));
|
ctbParr.setImpDare(ctbParr.getImpDare().add(ctbScad.getImpDare().divide(ctbParr.getCambioDiviScad()).setScale(5, RoundingMode.HALF_UP)));
|
||||||
} else {
|
} else {
|
||||||
ctbParr.setImpAvere(ctbParr.getImpAvere().add(ctbScad.getImpAvere()));
|
ctbParr.setImpAvere(ctbParr.getImpAvere().add(ctbScad.getImpAvere().divide(ctbParr.getCambioDiviScad()).setScale(5, RoundingMode.HALF_UP)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Integer tipoPartita = ctbMovr.getTipoPartita();
|
|
||||||
if (tipoPartita == null) {
|
|
||||||
String sql =
|
|
||||||
"SELECT Cast(tipo_partita as integer) as tipo_partita " +
|
|
||||||
" FROM ctb_part " +
|
|
||||||
" WHERE cod_anag = " + UtilityDB.valueToString(ctbScad.getCodAnag()) + " AND " +
|
|
||||||
"tipo_anag = " + UtilityDB.valueToString(ctbScad.getTipoAnag()) + " AND " +
|
|
||||||
"anno_part = " + UtilityDB.valueToString(ctbScad.getAnnoPart()) + " AND " +
|
|
||||||
"ser_doc = " + UtilityDB.valueToString(ctbScad.getSerDoc()) + " AND " +
|
|
||||||
"num_doc = " + UtilityDB.valueToString(ctbScad.getNumDoc());
|
|
||||||
|
|
||||||
tipoPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
BigDecimal cambioScad = BigDecimal.ONE;
|
||||||
|
Integer tipoPartita = ctbMovr.getTipoPartita();
|
||||||
|
|
||||||
|
String sql =
|
||||||
|
"SELECT Cast(tipo_partita as integer) as tipo_partita, cambio " +
|
||||||
|
" FROM ctb_part " +
|
||||||
|
" WHERE cod_anag = " + UtilityDB.valueToString(ctbScad.getCodAnag()) + " AND " +
|
||||||
|
"tipo_anag = " + UtilityDB.valueToString(ctbScad.getTipoAnag()) + " AND " +
|
||||||
|
"anno_part = " + UtilityDB.valueToString(ctbScad.getAnnoPart()) + " AND " +
|
||||||
|
"ser_doc = " + UtilityDB.valueToString(ctbScad.getSerDoc()) + " AND " +
|
||||||
|
"num_doc = " + UtilityDB.valueToString(ctbScad.getNumDoc());
|
||||||
|
|
||||||
|
HashMap<String, Object> datiCtbPart = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||||
|
if ( UtilityHashMap.isPresent(datiCtbPart)) {
|
||||||
|
if ( tipoPartita == null ) tipoPartita = UtilityHashMap.getValueIfExists(datiCtbPart, "tipo_partita");
|
||||||
|
cambioScad = UtilityHashMap.getValueIfExists(datiCtbPart, "cambio", BigDecimal.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctbScad.setTipoAnag(UtilityString.isNullOrEmpty(ctbScad.getTipoAnag()) ? ctbMovr.getTipoAnag() : ctbScad.getTipoAnag())
|
ctbScad.setTipoAnag(UtilityString.isNullOrEmpty(ctbScad.getTipoAnag()) ? ctbMovr.getTipoAnag() : ctbScad.getTipoAnag())
|
||||||
@@ -492,7 +499,6 @@ public class AccountingRules extends QueryRules {
|
|||||||
.setSerDoc(UtilityString.isNullOrEmpty(ctbScad.getSerDoc()) ? ctbMovr.getSerDoc() : ctbScad.getSerDoc())
|
.setSerDoc(UtilityString.isNullOrEmpty(ctbScad.getSerDoc()) ? ctbMovr.getSerDoc() : ctbScad.getSerDoc())
|
||||||
.setNumDoc(UtilityString.isNullOrEmpty(ctbScad.getNumDoc()) ? ctbMovr.getNumDoc() : ctbScad.getNumDoc());
|
.setNumDoc(UtilityString.isNullOrEmpty(ctbScad.getNumDoc()) ? ctbMovr.getNumDoc() : ctbScad.getNumDoc());
|
||||||
|
|
||||||
|
|
||||||
ctbParr =
|
ctbParr =
|
||||||
new CtbParr()
|
new CtbParr()
|
||||||
.setCodCcon(ctbMovr.getCodCcon())
|
.setCodCcon(ctbMovr.getCodCcon())
|
||||||
@@ -503,12 +509,13 @@ public class AccountingRules extends QueryRules {
|
|||||||
.setNumDoc(ctbScad.getNumDoc())
|
.setNumDoc(ctbScad.getNumDoc())
|
||||||
.setDataCmov(ctbMovr.getDataCmov())
|
.setDataCmov(ctbMovr.getDataCmov())
|
||||||
.setIdRiga(ctbMovr.getIdRiga())
|
.setIdRiga(ctbMovr.getIdRiga())
|
||||||
.setImpDare(TipoPartita.fromValue(tipoPartita) == TipoPartita.PASSIVA ? ctbScad.getImpDare() : BigDecimal.ZERO)
|
.setImpDare(UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO) ? ctbScad.getImpDare().divide(cambioScad).setScale(5, RoundingMode.HALF_UP) : BigDecimal.ZERO)
|
||||||
.setImpAvere(TipoPartita.fromValue(tipoPartita) == TipoPartita.ATTIVA ? ctbScad.getImpAvere() : BigDecimal.ZERO)
|
.setImpAvere(UtilityBigDecimal.greaterThan(ctbMovr.getImpAvere(), BigDecimal.ZERO) ? ctbScad.getImpAvere().divide(cambioScad).setScale(5, RoundingMode.HALF_UP) : BigDecimal.ZERO)
|
||||||
.setCodCcau(ctbMovr.getCodCcau())
|
.setCodCcau(ctbMovr.getCodCcau())
|
||||||
.setDesAgg(finalDesAgg)
|
.setDesAgg(finalDesAgg)
|
||||||
.setTipoPartita(tipoPartita)
|
.setTipoPartita(tipoPartita)
|
||||||
.setChiudiScad(ctbMovr.getChiudiScad());
|
.setChiudiScad(ctbMovr.getChiudiScad())
|
||||||
|
.setCambioDiviScad(cambioScad);
|
||||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,23 +540,39 @@ public class AccountingRules extends QueryRules {
|
|||||||
}
|
}
|
||||||
ctbMovr.setCtbScad(elencoScadenzeNew);
|
ctbMovr.setCtbScad(elencoScadenzeNew);
|
||||||
} else {
|
} else {
|
||||||
CtbParr ctbParr =
|
String sql =
|
||||||
new CtbParr()
|
Query.format(
|
||||||
.setCodCcon(ctbMovr.getCodCcon())
|
"SELECT cast(case when count(*) > 1 THEN 1 ELSE 0 eND as bit)" +
|
||||||
.setTipoAnag(ctbMovr.getTipoAnag())
|
" FROM ctb_parr " +
|
||||||
.setCodAnag(ctbMovr.getCodAnag())
|
" WHERE cod_anag = %s AND " +
|
||||||
.setAnnoPart(ctbMovr.getAnnoPart())
|
"tipo_anag = %s AND " +
|
||||||
.setSerDoc(ctbMovr.getSerDoc())
|
"anno_part = %s AND " +
|
||||||
.setNumDoc(ctbMovr.getNumDoc())
|
"ser_doc = %s AND " +
|
||||||
.setDataCmov(ctbMovr.getDataCmov())
|
"num_doc = %s AND " +
|
||||||
.setIdRiga(ctbMovr.getIdRiga())
|
"id_riga = %s ",
|
||||||
.setImpDare(ctbMovr.getImpDare())
|
ctbMovr.getCodAnag(), ctbMovr.getTipoAnag(), ctbMovr.getAnnoPart(), ctbMovr.getSerDoc(), ctbMovr.getNumDoc(), ctbMovr.getIdRiga());
|
||||||
.setImpAvere(ctbMovr.getImpAvere())
|
|
||||||
.setCodCcau(ctbMovr.getCodCcau())
|
boolean existRow = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
.setDesAgg(desAgg)
|
|
||||||
.setChiudiScad(ctbMovr.getChiudiScad());
|
if (!existRow) {
|
||||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
CtbParr ctbParr =
|
||||||
elencoPartite.add(ctbParr);
|
new CtbParr()
|
||||||
|
.setCodCcon(ctbMovr.getCodCcon())
|
||||||
|
.setTipoAnag(ctbMovr.getTipoAnag())
|
||||||
|
.setCodAnag(ctbMovr.getCodAnag())
|
||||||
|
.setAnnoPart(ctbMovr.getAnnoPart())
|
||||||
|
.setSerDoc(ctbMovr.getSerDoc())
|
||||||
|
.setNumDoc(ctbMovr.getNumDoc())
|
||||||
|
.setDataCmov(ctbMovr.getDataCmov())
|
||||||
|
.setIdRiga(ctbMovr.getIdRiga())
|
||||||
|
.setImpDare(ctbMovr.getImpDare())
|
||||||
|
.setImpAvere(ctbMovr.getImpAvere())
|
||||||
|
.setCodCcau(ctbMovr.getCodCcau())
|
||||||
|
.setDesAgg(desAgg)
|
||||||
|
.setChiudiScad(ctbMovr.getChiudiScad());
|
||||||
|
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
|
elencoPartite.add(ctbParr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return elencoPartite;
|
return elencoPartite;
|
||||||
}
|
}
|
||||||
@@ -891,7 +914,7 @@ public class AccountingRules extends QueryRules {
|
|||||||
ResultSetMapper resultSetMapper = new ResultSetMapper();
|
ResultSetMapper resultSetMapper = new ResultSetMapper();
|
||||||
List<CtbScad> ctbScad = resultSetMapper.mapQuerySetToList(conn, sql, CtbScad.class);
|
List<CtbScad> ctbScad = resultSetMapper.mapQuerySetToList(conn, sql, CtbScad.class);
|
||||||
if (ctbMovr.getOperation() == OperationType.DELETE && ctbScad.size() > 0) {
|
if (ctbMovr.getOperation() == OperationType.DELETE && ctbScad.size() > 0) {
|
||||||
Stream.of(ctbScad).forEach(x -> {
|
for ( CtbScad x: ctbScad) {
|
||||||
x.setOperation(x.getIsInsoluto() ? OperationType.DELETE : OperationType.UPDATE);
|
x.setOperation(x.getIsInsoluto() ? OperationType.DELETE : OperationType.UPDATE);
|
||||||
CrlScadParr crlScadParr =
|
CrlScadParr crlScadParr =
|
||||||
new CrlScadParr()
|
new CrlScadParr()
|
||||||
@@ -905,8 +928,9 @@ public class AccountingRules extends QueryRules {
|
|||||||
.setNumCmov(ctbMovr.getNumCmov())
|
.setNumCmov(ctbMovr.getNumCmov())
|
||||||
.setId(x.getPkRelazione());
|
.setId(x.getPkRelazione());
|
||||||
crlScadParr.setOperation(OperationType.DELETE);
|
crlScadParr.setOperation(OperationType.DELETE);
|
||||||
|
if (x.getCrlScadParr() == null ) x.setCrlScadParr(new ArrayList<>());
|
||||||
x.getCrlScadParr().add(crlScadParr);
|
x.getCrlScadParr().add(crlScadParr);
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctbScad;
|
return ctbScad;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ConfigActivityRules extends QueryRules {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Date> dataDaControllare = new ArrayList<>();
|
List<Date> dataDaControllare = new ArrayList<>();
|
||||||
if (stbActivity.getEstimatedDate() != null) dataDaControllare.add(stbActivity.getEstimatedDate());
|
//if (stbActivity.getEstimatedDate() != null) dataDaControllare.add(stbActivity.getEstimatedDate());
|
||||||
if (stbActivity.getEffectiveDate() != null) dataDaControllare.add(stbActivity.getEffectiveDate());
|
if (stbActivity.getEffectiveDate() != null) dataDaControllare.add(stbActivity.getEffectiveDate());
|
||||||
|
|
||||||
for (Date data : dataDaControllare) {
|
for (Date data : dataDaControllare) {
|
||||||
|
|||||||
@@ -824,7 +824,7 @@ public class DocOrdRules extends QueryRules {
|
|||||||
.setGestione(ordine.getGestione())
|
.setGestione(ordine.getGestione())
|
||||||
.setDataOrd(ordine.getDataOrd())
|
.setDataOrd(ordine.getDataOrd())
|
||||||
.setNumOrd(ordine.getNumOrd())
|
.setNumOrd(ordine.getNumOrd())
|
||||||
.setPartitaMag(dtbOrdt.getOperation() == OperationType.DELETE ? EmsRestConstants.NULL : dtbOrdt.getPartitaMag())
|
.setPartitaMag(dtbOrdt.getOperation() == OperationType.DELETE || ordine.getFlagScollegaPartitaMag() ? EmsRestConstants.NULL : dtbOrdt.getPartitaMag())
|
||||||
);
|
);
|
||||||
|
|
||||||
righeOrdine.forEach(rigaOrdine -> rigaOrdine.setOperation(OperationType.UPDATE));
|
righeOrdine.forEach(rigaOrdine -> rigaOrdine.setOperation(OperationType.UPDATE));
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package it.integry.ems.rules.completing;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
||||||
import it.integry.ems_model.annotation.SqlField;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.entity.MtbColr;
|
import it.integry.ems_model.entity.MtbColr;
|
||||||
import it.integry.ems_model.entity.MtbCols;
|
import it.integry.ems_model.entity.MtbCols;
|
||||||
@@ -11,12 +10,13 @@ import it.integry.ems_model.entity.MtbColt;
|
|||||||
import it.integry.ems_model.entity.MtbPartitaMag;
|
import it.integry.ems_model.entity.MtbPartitaMag;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.*;
|
import it.integry.ems_model.utility.*;
|
||||||
import org.springframework.util.ReflectionUtils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.sql.*;
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -77,9 +77,9 @@ public class PackagesRules extends QueryRules {
|
|||||||
|
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT Cast(count(*) as bit) " +
|
"SELECT Cast(count(*) as bit) " +
|
||||||
" FROM mtb_partita_mag " +
|
" FROM mtb_partita_mag " +
|
||||||
" WHERE mtb_partita_mag.cod_mart = " + UtilityDB.valueToString(mtbColr.getCodMart()) + " AND " +
|
" WHERE mtb_partita_mag.cod_mart = " + UtilityDB.valueToString(mtbColr.getCodMart()) + " AND " +
|
||||||
"mtb_partita_mag.partita_mag = "+ UtilityDB.valueToString(mtbColr.getPartitaMag());
|
"mtb_partita_mag.partita_mag = " + UtilityDB.valueToString(mtbColr.getPartitaMag());
|
||||||
|
|
||||||
boolean existPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
boolean existPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
@@ -88,14 +88,14 @@ public class PackagesRules extends QueryRules {
|
|||||||
operation = OperationType.INSERT;
|
operation = OperationType.INSERT;
|
||||||
sql =
|
sql =
|
||||||
"SELECT CASE\n" +
|
"SELECT CASE\n" +
|
||||||
" WHEN dbo.getgestsetup('MTB_PARTITA_MAG', 'SETUP', 'DESCRIZIONE_PARTITA_FORNITORE') = 'S' THEN\n" +
|
" WHEN dbo.getgestsetup('MTB_PARTITA_MAG', 'SETUP', 'DESCRIZIONE_PARTITA_FORNITORE') = 'S' THEN\n" +
|
||||||
" gtb_anag.rag_soc\n" +
|
" gtb_anag.rag_soc\n" +
|
||||||
" ELSE NULL END\n" +
|
" ELSE NULL END\n" +
|
||||||
"FROM dtb_ordt \n" +
|
"FROM dtb_ordt \n" +
|
||||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||||
"WHERE dtb_ordt.gestione = " + UtilityDB.valueToString(mtbColr.getGestione()) + "\n" +
|
"WHERE dtb_ordt.gestione = " + UtilityDB.valueToString(mtbColr.getGestione()) + "\n" +
|
||||||
" AND dtb_ordt.data_ord = " + UtilityDB.valueDateToString(mtbColr.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + "\n" +
|
" AND dtb_ordt.data_ord = " + UtilityDB.valueDateToString(mtbColr.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + "\n" +
|
||||||
" AND dtb_ordt.num_ord = " + UtilityDB.valueToString(mtbColr.getNumOrd());
|
" AND dtb_ordt.num_ord = " + UtilityDB.valueToString(mtbColr.getNumOrd());
|
||||||
|
|
||||||
String descrPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
String descrPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
partita.setDescrizione(descrPartita);
|
partita.setDescrizione(descrPartita);
|
||||||
@@ -142,7 +142,7 @@ public class PackagesRules extends QueryRules {
|
|||||||
return codVlis;
|
return codVlis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Object> completeDimensioniCollo(Connection connection, String codTcol) throws Exception{
|
public static HashMap<String, Object> completeDimensioniCollo(Connection connection, String codTcol) throws Exception {
|
||||||
String sql =
|
String sql =
|
||||||
Query.format("select lunghezza_cm, larghezza_cm, altezza_cm from mtb_tcol where cod_tcol = %s ", codTcol);
|
Query.format("select lunghezza_cm, larghezza_cm, altezza_cm from mtb_tcol where cod_tcol = %s ", codTcol);
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ public class PackagesRules extends QueryRules {
|
|||||||
"GROUP BY posizione, cod_mdep";
|
"GROUP BY posizione, cod_mdep";
|
||||||
|
|
||||||
final HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
final HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||||
if(result == null) return false;
|
if (result == null) return false;
|
||||||
|
|
||||||
boolean colloExists = UtilityHashMap.getValueIfExists(result, "exist");
|
boolean colloExists = UtilityHashMap.getValueIfExists(result, "exist");
|
||||||
String prevPosizione = UtilityHashMap.getValueIfExists(result, "posizione");
|
String prevPosizione = UtilityHashMap.getValueIfExists(result, "posizione");
|
||||||
@@ -188,14 +188,14 @@ public class PackagesRules extends QueryRules {
|
|||||||
public static void insertMtbCols(MtbColt mtbColt, MtbCols.Causale causale) {
|
public static void insertMtbCols(MtbColt mtbColt, MtbCols.Causale causale) {
|
||||||
//if(mtbColt.getMtbCols().isEmpty()) {
|
//if(mtbColt.getMtbCols().isEmpty()) {
|
||||||
|
|
||||||
MtbCols mtbCols = new MtbCols()
|
MtbCols mtbCols = new MtbCols()
|
||||||
.setCausale(causale)
|
.setCausale(causale)
|
||||||
.setCodMdep(mtbColt.getCodMdep())
|
.setCodMdep(mtbColt.getCodMdep())
|
||||||
.setDataMove(new Date())
|
.setDataMove(new Date())
|
||||||
.setPosizione(mtbColt.getPosizione())
|
.setPosizione(mtbColt.getPosizione())
|
||||||
.setModificatoDa(mtbColt.getPreparatoDa());
|
.setModificatoDa(mtbColt.getPreparatoDa());
|
||||||
mtbCols.setOperation(OperationType.INSERT);
|
mtbCols.setOperation(OperationType.INSERT);
|
||||||
mtbColt.getMtbCols().add(mtbCols);
|
mtbColt.getMtbCols().add(mtbCols);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,8 +295,8 @@ public class PackagesRules extends QueryRules {
|
|||||||
"SELECT dtb_ordt.cod_anag, " +
|
"SELECT dtb_ordt.cod_anag, " +
|
||||||
" dtb_ordt.cod_vdes, " +
|
" dtb_ordt.cod_vdes, " +
|
||||||
" dtb_ordt.rif_ord " +
|
" dtb_ordt.rif_ord " +
|
||||||
" FROM dtb_ordt " +
|
" FROM dtb_ordt " +
|
||||||
" WHERE gestione = " + UtilityDB.valueToString(mtbColt.getGestione()) + " AND " +
|
" WHERE gestione = " + UtilityDB.valueToString(mtbColt.getGestione()) + " AND " +
|
||||||
" data_ord = " + UtilityDB.valueDateToString(mtbColt.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
" data_ord = " + UtilityDB.valueDateToString(mtbColt.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||||
" num_ord = " + UtilityDB.valueToString(mtbColt.getNumOrd());
|
" num_ord = " + UtilityDB.valueToString(mtbColt.getNumOrd());
|
||||||
|
|
||||||
@@ -355,10 +355,10 @@ public class PackagesRules extends QueryRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void completeFlagColloAnonimo(MtbColt mtbColt) {
|
public static void completeFlagColloAnonimo(MtbColt mtbColt) {
|
||||||
if (mtbColt.getDataDoc() == null || mtbColt.getOperation() == OperationType.DELETE){
|
if (mtbColt.getDataDoc() == null || mtbColt.getOperation() == OperationType.DELETE) {
|
||||||
if ( UtilityString.isNullOrEmpty(mtbColt.getCodAnag()) &&
|
if (UtilityString.isNullOrEmpty(mtbColt.getCodAnag()) &&
|
||||||
UtilityString.isNullOrEmpty(mtbColt.getCodVdes()) &&
|
UtilityString.isNullOrEmpty(mtbColt.getCodVdes()) &&
|
||||||
mtbColt.getDataOrd() == null && mtbColt.getNumOrd() == null){
|
mtbColt.getDataOrd() == null && mtbColt.getNumOrd() == null) {
|
||||||
mtbColt.setFlagColloAnonimo("S");
|
mtbColt.setFlagColloAnonimo("S");
|
||||||
} else {
|
} else {
|
||||||
mtbColt.setFlagColloAnonimo("N");
|
mtbColt.setFlagColloAnonimo("N");
|
||||||
@@ -381,8 +381,8 @@ public class PackagesRules extends QueryRules {
|
|||||||
if (mtbColt.getCalcPeso()) {
|
if (mtbColt.getCalcPeso()) {
|
||||||
mtbColt.setPesoKg(pesoLordo);
|
mtbColt.setPesoKg(pesoLordo);
|
||||||
mtbColt.setPesoNettoKg(pesoNetto);
|
mtbColt.setPesoNettoKg(pesoNetto);
|
||||||
|
if (mtbColt.getOperation() != OperationType.SUBSTITUTE)
|
||||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
} else if (!mtbColt.getCalcPeso() && righe.size() > 0 && UtilityBigDecimal.greaterThan(pesoLordo, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(pesoNetto, BigDecimal.ZERO)) {
|
} else if (!mtbColt.getCalcPeso() && righe.size() > 0 && UtilityBigDecimal.greaterThan(pesoLordo, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(pesoNetto, BigDecimal.ZERO)) {
|
||||||
long countRowKG = Stream.of(righe).filter(x -> x.getOperation() != OperationType.DELETE && "S".equalsIgnoreCase(x.getArtAPeso())).count();
|
long countRowKG = Stream.of(righe).filter(x -> x.getOperation() != OperationType.DELETE && "S".equalsIgnoreCase(x.getArtAPeso())).count();
|
||||||
long countNewRows = Stream.of(righe)
|
long countNewRows = Stream.of(righe)
|
||||||
@@ -440,26 +440,27 @@ public class PackagesRules extends QueryRules {
|
|||||||
|
|
||||||
if (UtilityHashMap.isPresent(datiOrdine))
|
if (UtilityHashMap.isPresent(datiOrdine))
|
||||||
mtbcolt
|
mtbcolt
|
||||||
.setCodAnag(mtbcolt.getCodAnag()==null?UtilityHashMap.getValueIfExists(datiOrdine, "cod_anag"):mtbcolt.getCodAnag())
|
.setCodAnag(mtbcolt.getCodAnag() == null ? UtilityHashMap.getValueIfExists(datiOrdine, "cod_anag") : mtbcolt.getCodAnag())
|
||||||
.setCodVdes(mtbcolt.getCodVdes()== null?UtilityHashMap.getValueIfExists(datiOrdine, "cod_vdes"):mtbcolt.getCodVdes())
|
.setCodVdes(mtbcolt.getCodVdes() == null ? UtilityHashMap.getValueIfExists(datiOrdine, "cod_vdes") : mtbcolt.getCodVdes())
|
||||||
.setRifOrd(UtilityHashMap.getValueIfExists(datiOrdine, "rif_ord"));
|
.setRifOrd(UtilityHashMap.getValueIfExists(datiOrdine, "rif_ord"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSerCollo(Connection conn, String codMdep) throws Exception {
|
public static String getSerCollo(Connection conn, String codMdep) throws Exception {
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT dbo.f_getSerCollo(" + UtilityDB.valueToString(codMdep) + ")";
|
"SELECT dbo.f_getSerCollo(" + UtilityDB.valueToString(codMdep) + ")";
|
||||||
|
|
||||||
String serDoc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
String serDoc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
if (serDoc == null){
|
if (serDoc == null) {
|
||||||
serDoc = (String) CommonRules.completeWithDefault(MtbColt.class, "serCollo");
|
serDoc = (String) CommonRules.completeWithDefault(MtbColt.class, "serCollo");
|
||||||
}
|
}
|
||||||
return serDoc;
|
return serDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkForAnyColloRif(Connection conn, String gestione, String serCollo, int numCollo, Date dataCollo) throws Exception{
|
public static boolean checkForAnyColloRif(Connection conn, String gestione, String serCollo, int numCollo, Date dataCollo) throws Exception {
|
||||||
String sql = "SELECT count(*) " +
|
String sql = "SELECT count(*) " +
|
||||||
"FROM mtb_colr " +
|
"FROM mtb_colr " +
|
||||||
"WHERE gestione_rif = " + UtilityDB.valueToString(gestione) +
|
"WHERE gestione_rif = " + UtilityDB.valueToString(gestione) +
|
||||||
@@ -469,7 +470,7 @@ public class PackagesRules extends QueryRules {
|
|||||||
|
|
||||||
int countColliRif = (int) getSingleValue(conn, sql);
|
int countColliRif = (int) getSingleValue(conn, sql);
|
||||||
|
|
||||||
if ( countColliRif > 0){
|
if (countColliRif > 0) {
|
||||||
throw new Exception("Impossibile cancellare il collo, ci sono altri colli che hanno un riferimento a questo.");
|
throw new Exception("Impossibile cancellare il collo, ci sono altri colli che hanno un riferimento a questo.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -159,6 +159,31 @@ public class SalesRules extends QueryRules {
|
|||||||
return untMisVend;
|
return untMisVend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VtbList insertVtbList(Connection connection, VtbListData vtbListData) throws SQLException {
|
||||||
|
String sql = Query.format(
|
||||||
|
"SELECT CAST(COUNT(*) AS BIT) FROM vtb_list WHERE cod_vlis = %s",
|
||||||
|
vtbListData.getCodVlis()
|
||||||
|
);
|
||||||
|
|
||||||
|
Boolean countVtbList = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
|
if (!countVtbList) {
|
||||||
|
VtbList vtbList = new VtbList();
|
||||||
|
|
||||||
|
vtbList
|
||||||
|
.setCodVlis(vtbListData.getCodVlis())
|
||||||
|
.setDescrizione(vtbListData.getDescrizione())
|
||||||
|
.setCodDivi(vtbListData.getCodDivi());
|
||||||
|
|
||||||
|
vtbList.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
return vtbList;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static VtbPromo completePromoVend(VtbListData vtbListData) {
|
public static VtbPromo completePromoVend(VtbListData vtbListData) {
|
||||||
if (vtbListData.getVtbPromo() != null) {
|
if (vtbListData.getVtbPromo() != null) {
|
||||||
VtbPromo vtbPromo = vtbListData.getVtbPromo().setCodPromo(vtbListData.getCodPromo());
|
VtbPromo vtbPromo = vtbListData.getVtbPromo().setCodPromo(vtbListData.getCodPromo());
|
||||||
@@ -486,6 +511,8 @@ public class SalesRules extends QueryRules {
|
|||||||
valUntIva != null) {
|
valUntIva != null) {
|
||||||
|
|
||||||
BigDecimal percAliq = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "perc_aliq");
|
BigDecimal percAliq = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "perc_aliq");
|
||||||
|
if ( percAliq == null )
|
||||||
|
throw new Exception ( String.format("Aliquota iva mancante sull'articolo ", entity.getCodMart()));
|
||||||
BigDecimal valUnt = CommonRules.scorporoIva(valUntIva, percAliq);
|
BigDecimal valUnt = CommonRules.scorporoIva(valUntIva, percAliq);
|
||||||
entity.setValUnt(valUnt);
|
entity.setValUnt(valUnt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.annimon.stream.Stream;
|
|||||||
import it.integry.annotations.PostContextAutowired;
|
import it.integry.annotations.PostContextAutowired;
|
||||||
import it.integry.annotations.PostWebServerConstruct;
|
import it.integry.annotations.PostWebServerConstruct;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ExportAutomatedOperationDTO;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
@@ -11,6 +12,7 @@ import it.integry.ems.settings.Model.SettingsModel;
|
|||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -43,7 +45,6 @@ public class DefaultAutomatedOperationHandlerComponent {
|
|||||||
|
|
||||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||||
deleteJobFileDeleter(multiDBTransactionManager);
|
deleteJobFileDeleter(multiDBTransactionManager);
|
||||||
//initFileDeleterJob(multiDBTransactionManager);
|
|
||||||
initServerInfoCheckJob();
|
initServerInfoCheckJob();
|
||||||
initRemoveFpxInvioFilesJob();
|
initRemoveFpxInvioFilesJob();
|
||||||
initChkAutofatture();
|
initChkAutofatture();
|
||||||
@@ -51,6 +52,7 @@ public class DefaultAutomatedOperationHandlerComponent {
|
|||||||
initMinioOrphanFileCleaner(multiDBTransactionManager);
|
initMinioOrphanFileCleaner(multiDBTransactionManager);
|
||||||
initPassaggioAnno(multiDBTransactionManager);
|
initPassaggioAnno(multiDBTransactionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -161,43 +163,6 @@ public class DefaultAutomatedOperationHandlerComponent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFileDeleterJob(MultiDBTransactionManager data) {
|
|
||||||
try {
|
|
||||||
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
|
||||||
|
|
||||||
HashMap<AutomatedOperationTypeEnum, List<BaseAutomatedOperationDTO>> activeOperations = automatedOperationHandlerComponent.get(AutomatedOperationTypeEnum.METHOD_CALLS, null);
|
|
||||||
if (!activeOperations.containsKey(AutomatedOperationTypeEnum.METHOD_CALLS))
|
|
||||||
activeOperations.put(AutomatedOperationTypeEnum.METHOD_CALLS, new ArrayList<>());
|
|
||||||
|
|
||||||
activeConnections = Stream.of(activeConnections)
|
|
||||||
.filter(x -> x.isInternalDb() && x.getDataSource().getProfile().equalsIgnoreCase(x.getDataSource().getDbName()))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
for (AdvancedDataSource activeConnection : activeConnections) {
|
|
||||||
final String filesDeleterOperationName = "File deleter " + activeConnection.getProfileName().toUpperCase();
|
|
||||||
|
|
||||||
boolean jobExists = Stream.of(activeOperations.get(AutomatedOperationTypeEnum.METHOD_CALLS))
|
|
||||||
.anyMatch(iScheduledOperation -> iScheduledOperation.getName().equals(filesDeleterOperationName));
|
|
||||||
|
|
||||||
if (!jobExists) {
|
|
||||||
ServiceCallAutomatedOperationDTO serviceCallAutomatedOperationDTO = new ServiceCallAutomatedOperationDTO()
|
|
||||||
.setMethodName("cleanDirectories")
|
|
||||||
.setProfileDb(activeConnection.getProfileName());
|
|
||||||
serviceCallAutomatedOperationDTO
|
|
||||||
.setCronTrigger("0 0 0 1/1 * ?")
|
|
||||||
.setName(filesDeleterOperationName);
|
|
||||||
|
|
||||||
automatedOperationHandlerComponent.add(serviceCallAutomatedOperationDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteJobFileDeleter(MultiDBTransactionManager data) {
|
private void deleteJobFileDeleter(MultiDBTransactionManager data) {
|
||||||
try {
|
try {
|
||||||
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
import it.integry.ems_model.annotation.EntityChild;
|
import it.integry.ems_model.annotation.EntityChild;
|
||||||
import it.integry.ems_model.annotation.SqlField;
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
|
||||||
import it.integry.ems_model.base.EntityInterface;
|
import it.integry.ems_model.base.EntityInterface;
|
||||||
import it.integry.ems_model.entity.StbLogEntitySetup;
|
import it.integry.ems_model.entity.StbLogEntitySetup;
|
||||||
import it.integry.ems_model.resolver.SqlFieldHolder;
|
import it.integry.ems_model.resolver.SqlFieldHolder;
|
||||||
@@ -154,7 +153,7 @@ public class EntityLoggerNewService {
|
|||||||
|
|
||||||
String columns = StringUtils.join(entityMap.keySet(), ", ");
|
String columns = StringUtils.join(entityMap.keySet(), ", ");
|
||||||
String values = StringUtils.join(Stream.of(entityMap.values())
|
String values = StringUtils.join(Stream.of(entityMap.values())
|
||||||
.map(SqlFieldHolder::getSqlValueField).toList(), ", ");
|
.map(SqlFieldHolder::getSqlValueFieldAsString).toList(), ", ");
|
||||||
|
|
||||||
String sql = "INSERT INTO " + entityToLog.getEntity().getTableName() +
|
String sql = "INSERT INTO " + entityToLog.getEntity().getTableName() +
|
||||||
"(" + columns + ") VALUES (" + values + ")";
|
"(" + columns + ") VALUES (" + values + ")";
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class EntityProcessor {
|
|||||||
username = requestDataDTO.getUsername();
|
username = requestDataDTO.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (T) processEntity(entity, true, false, username, multiDBTransactionManager, true);
|
return (T) processEntity(entity, true, false, username, multiDBTransactionManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBase processEntity(EntityInterface entity, boolean skipCommit, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
public EntityBase processEntity(EntityInterface entity, boolean skipCommit, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
@@ -101,13 +101,20 @@ public class EntityProcessor {
|
|||||||
username = requestDataDTO.getUsername();
|
username = requestDataDTO.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (EntityBase) processEntity(entity, true, skipCommit, username, multiDBTransactionManager, true);
|
return (EntityBase) processEntity(entity, true, skipCommit, username, multiDBTransactionManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBase processEntity(EntityInterface entity, Boolean isSync,
|
public EntityBase processEntity(EntityInterface entity, Boolean isSync,
|
||||||
boolean skipCommit, String username,
|
boolean skipCommit, String username,
|
||||||
MultiDBTransactionManager mdb) throws Exception {
|
MultiDBTransactionManager mdb) throws Exception {
|
||||||
return (EntityBase) processEntity(entity, true, skipCommit, username, mdb, true);
|
return (EntityBase) processEntity(entity, isSync, skipCommit, username, mdb, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object processEntity(EntityInterface entity, Boolean isSync,
|
||||||
|
boolean skipCommit, String username,
|
||||||
|
MultiDBTransactionManager mdb,
|
||||||
|
boolean completeEntity) throws Exception {
|
||||||
|
return processEntity(entity, isSync, skipCommit, username, mdb, completeEntity, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,7 +132,7 @@ public class EntityProcessor {
|
|||||||
public Object processEntity(EntityInterface entity, Boolean isSync,
|
public Object processEntity(EntityInterface entity, Boolean isSync,
|
||||||
boolean skipCommit, String username,
|
boolean skipCommit, String username,
|
||||||
MultiDBTransactionManager mdb,
|
MultiDBTransactionManager mdb,
|
||||||
boolean completeEntity) throws Exception {
|
boolean completeEntity, boolean overrideEntityChildCheck) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
entity.setEntityHolder(entityPropertyHolder);
|
entity.setEntityHolder(entityPropertyHolder);
|
||||||
@@ -137,7 +144,7 @@ public class EntityProcessor {
|
|||||||
entity.setOperation(OperationType.NO_OP);
|
entity.setOperation(OperationType.NO_OP);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.checkEntityChildsUsage(entity, mdb);
|
if (!overrideEntityChildCheck) this.checkEntityChildsUsage(entity, mdb);
|
||||||
|
|
||||||
if (settingsModel.isEnablePermissionCheck() && !checkUserPermissions(entity))
|
if (settingsModel.isEnablePermissionCheck() && !checkUserPermissions(entity))
|
||||||
throw new InvalidPermissionsException();
|
throw new InvalidPermissionsException();
|
||||||
@@ -453,26 +460,21 @@ public class EntityProcessor {
|
|||||||
|
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean singleTransaction) throws Exception {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean singleTransaction) throws Exception {
|
||||||
return processEntityList(null, true, singleTransaction, false, entities);
|
return processEntityList(entities, null, true, singleTransaction, false, mDbTransactManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager, boolean singleTransaction) throws Exception {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager, boolean singleTransaction) throws Exception {
|
||||||
return processEntityList(null, true, singleTransaction, false, entities, multiDBTransactionManager);
|
return processEntityList(entities, null, true, singleTransaction, false, multiDBTransactionManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
||||||
return processEntityList(null, isSync, singleTransaction, ordinaSuPriorita, entities);
|
return processEntityList(entities, null, isSync, singleTransaction, ordinaSuPriorita, mDbTransactManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
||||||
return processEntityList(username, isSync, singleTransaction, ordinaSuPriorita, entities);
|
return processEntityList(entities, username, isSync, singleTransaction, ordinaSuPriorita, mDbTransactManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita, List<? extends EntityBase> entities) throws Exception {
|
|
||||||
return processEntityList(username, isSync, singleTransaction, ordinaSuPriorita, entities, mDbTransactManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity List Processor
|
* Entity List Processor
|
||||||
*
|
*
|
||||||
@@ -485,7 +487,12 @@ public class EntityProcessor {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public List<EntityBase> processEntityList(String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita, List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username,
|
||||||
|
boolean isSync,
|
||||||
|
boolean singleTransaction,
|
||||||
|
boolean ordinaSuPriorita,
|
||||||
|
MultiDBTransactionManager multiDBTransactionManager,
|
||||||
|
boolean completeEntity, boolean overrideEntityChildCheck) throws Exception {
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(username) && requestDataDTO != null && requestDataDTO.isValidUsername()) {
|
if (UtilityString.isNullOrEmpty(username) && requestDataDTO != null && requestDataDTO.isValidUsername()) {
|
||||||
username = requestDataDTO.getUsername();
|
username = requestDataDTO.getUsername();
|
||||||
@@ -498,13 +505,13 @@ public class EntityProcessor {
|
|||||||
entities = entityPropertyHolder.getEntityChain(entities, multiDBTransactionManager.getPrimaryDatasource().getConnection());
|
entities = entityPropertyHolder.getEntityChain(entities, multiDBTransactionManager.getPrimaryDatasource().getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer prevTransactionGroupId = null;
|
Long prevTransactionGroupId = null;
|
||||||
|
|
||||||
for (int i = 0; i < entities.size(); i++) {
|
for (int i = 0; i < entities.size(); i++) {
|
||||||
EntityBase entity = entities.get(i);
|
EntityBase entity = entities.get(i);
|
||||||
entity.setTransactionGroupId(prevTransactionGroupId);
|
entity.setTransactionGroupId(prevTransactionGroupId);
|
||||||
try {
|
try {
|
||||||
EntityBase entityResult = (EntityBase) this.processEntity(entity, isSync, singleTransaction, username, multiDBTransactionManager, true);
|
EntityBase entityResult = (EntityBase) this.processEntity(entity, isSync, singleTransaction, username, multiDBTransactionManager, completeEntity, overrideEntityChildCheck);
|
||||||
prevTransactionGroupId = entity.getTransactionGroupId();
|
prevTransactionGroupId = entity.getTransactionGroupId();
|
||||||
if (entityResult != null) {
|
if (entityResult != null) {
|
||||||
entityList.add(entityResult);
|
entityList.add(entityResult);
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
package it.integry.ems.sync;
|
package it.integry.ems.sync;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
import it.integry.ems.datasource.DataSource;
|
import it.integry.ems.datasource.DataSource;
|
||||||
import it.integry.ems.json.JSONObjectMapper;
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.sync.dto.ExportHistoryGroupDTO;
|
||||||
import it.integry.ems.sync.dto.ExportHistoryItemDTO;
|
import it.integry.ems.sync.dto.ExportHistoryItemDTO;
|
||||||
import it.integry.ems.sync.dto.ExportHistoryStatusDTO;
|
import it.integry.ems.sync.dto.ExportHistoryStatusDTO;
|
||||||
import it.integry.ems.sync.dto.PublicationDTO;
|
import it.integry.ems.sync.dto.PublicationDTO;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
|
import it.integry.ems_model.entity.StbPublications;
|
||||||
|
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||||
import it.integry.ems_model.entity.StbTransactionLog;
|
import it.integry.ems_model.entity.StbTransactionLog;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
@@ -22,7 +27,12 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AsyncHistoryManager {
|
public class AsyncHistoryManager {
|
||||||
@@ -39,27 +49,36 @@ public class AsyncHistoryManager {
|
|||||||
private JSONObjectMapper jsonObjectMapper;
|
private JSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
//Implement check list like distribuzione
|
//Implement check list like distribuzione
|
||||||
private final HashMap<Long, List<ExportHistoryItemDTO>> currentlyInExecution = new HashMap<>();
|
private final AtomicReference<List<ExportHistoryGroupDTO>> currentlyInExecutionG = new AtomicReference<>(new ArrayList<>());
|
||||||
|
|
||||||
|
|
||||||
@PostContextConstruct
|
@PostContextConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
this.looperService.add(this::consumeRetrieveQueue, 10 * 1000, "async-history-read");
|
this.looperService.add(this::consumeRetrieveQueue, 10 * 1000, "async-history-read");
|
||||||
this.looperService.add(this::consumeProcessedQueue, 10 * 1000, "async-history-save");
|
this.looperService.add(this::consumeProcessedQueue, 2 * 1000, "async-history-save");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToExportQueue(DataSource dataSource, long groupId, PublicationDTO publication) throws Exception {
|
public void addToExportQueue(DataSource dataSource, long groupId, PublicationDTO publication) throws Exception {
|
||||||
|
|
||||||
tryAddInExecutionList(groupId, new ExportHistoryItemDTO()
|
tryAddInExecutionList(groupId, dataSource, new ExportHistoryItemDTO()
|
||||||
.setPublicationGroupId(groupId)
|
.setPublication(publication));
|
||||||
.setPublication(publication)
|
|
||||||
.setDataSource(dataSource));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryAddInExecutionList(long groupId, ExportHistoryItemDTO exportHistoryItemDTO) throws Exception {
|
private void tryAddInExecutionList(long groupId, DataSource dataSource, ExportHistoryItemDTO exportHistoryItemDTO) throws Exception {
|
||||||
currentlyInExecution.putIfAbsent(groupId, new ArrayList<>());
|
|
||||||
|
|
||||||
List<ExportHistoryItemDTO> list = currentlyInExecution.get(groupId);
|
ExportHistoryGroupDTO currentlyInExec = currentlyInExecutionG.get().stream()
|
||||||
|
.filter(x -> x.getGroupId() == groupId)
|
||||||
|
.findFirst().orElseGet(() ->
|
||||||
|
{
|
||||||
|
final ExportHistoryGroupDTO exportHistoryGroupDTO = new ExportHistoryGroupDTO()
|
||||||
|
.setDataSource(dataSource)
|
||||||
|
.setGroupId(groupId);
|
||||||
|
|
||||||
|
currentlyInExecutionG.get().add(exportHistoryGroupDTO);
|
||||||
|
return exportHistoryGroupDTO;
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ExportHistoryItemDTO> list = currentlyInExec.getItems();
|
||||||
final boolean alreadyRegistered = list.stream()
|
final boolean alreadyRegistered = list.stream()
|
||||||
.anyMatch(x -> x.getPublication().getId() == exportHistoryItemDTO.getPublication().getId());
|
.anyMatch(x -> x.getPublication().getId() == exportHistoryItemDTO.getPublication().getId());
|
||||||
|
|
||||||
@@ -67,164 +86,183 @@ public class AsyncHistoryManager {
|
|||||||
throw new Exception("Il sistema sta già elaborando questa publication");
|
throw new Exception("Il sistema sta già elaborando questa publication");
|
||||||
}
|
}
|
||||||
|
|
||||||
exportHistoryItemDTO.setTotalItemCount(countExistingItems(exportHistoryItemDTO));
|
currentlyInExec.setTotalItemCount(currentlyInExec.getTotalItemCount() + countExistingItems(dataSource, exportHistoryItemDTO));
|
||||||
|
|
||||||
list.add(exportHistoryItemDTO);
|
list.add(exportHistoryItemDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void consumeRetrieveQueue() {
|
private void consumeRetrieveQueue() {
|
||||||
final List<Long> currentlyInExecutionKeys = new ArrayList<>(currentlyInExecution.keySet());
|
|
||||||
|
|
||||||
for (long currentGroupId : currentlyInExecutionKeys) {
|
for (ExportHistoryGroupDTO currentGroup : currentlyInExecutionG.get()) {
|
||||||
List<ExportHistoryItemDTO> entitiesToExport = currentlyInExecution.get(currentGroupId);
|
List<ExportHistoryItemDTO> entitiesToExport = currentGroup.getItems();
|
||||||
|
|
||||||
|
if (currentGroup.getStartTime() != null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
currentGroup.setStartTime(UtilityLocalDate.getNowTime());
|
||||||
|
|
||||||
for (ExportHistoryItemDTO entityToExport : entitiesToExport) {
|
for (ExportHistoryItemDTO entityToExport : entitiesToExport) {
|
||||||
try {
|
try {
|
||||||
internalExportEntity(entityToExport);
|
internalExportEntity(currentGroup, entityToExport);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
logger.error(ex.getMessage(), ex);
|
logger.error(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentGroup.setCompletedRead(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void internalExportEntity(ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
private void internalExportEntity(ExportHistoryGroupDTO exportHistoryGroup, ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
||||||
|
if (entityHistoryToExport.getStartDate() == null)
|
||||||
|
entityHistoryToExport.setStartDate(UtilityLocalDate.getNowTime());
|
||||||
|
|
||||||
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
||||||
|
|
||||||
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(entityHistoryToExport.getDataSource().getProfile())) {
|
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(exportHistoryGroup.getDataSource().getProfile())) {
|
||||||
retrieveEntitiesByChunk(newConnection.getPrimaryConnection(), entityHistoryToExport, entityClass);
|
retrieveEntitiesByChunk(newConnection.getPrimaryConnection(), exportHistoryGroup, entityHistoryToExport, entityClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countExistingItems(ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
private long countExistingItems(DataSource dataSource, ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
||||||
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
||||||
|
|
||||||
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(entityHistoryToExport.getDataSource().getProfile())) {
|
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(dataSource.getProfile())) {
|
||||||
String sql = "SELECT CONVERT(BIGINT, COUNT(*)) FROM " + entityClass.newInstance().getTableName();
|
String sql = "SELECT CONVERT(BIGINT, COUNT(*)) FROM " + entityClass.newInstance().getTableName();
|
||||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(newConnection.getPrimaryConnection(), sql);
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(newConnection.getPrimaryConnection(), sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveEntitiesByChunk(Connection connection, ExportHistoryItemDTO exportHistoryItem, Class<? extends EntityBase> entityClass) throws Exception {
|
private void retrieveEntitiesByChunk(Connection connection, ExportHistoryGroupDTO exportHistoryGroup, ExportHistoryItemDTO exportHistoryItem, Class<? extends EntityBase> entityClass) throws Exception {
|
||||||
|
|
||||||
long totalItemCount = exportHistoryItem.getTotalItemCount();
|
String innerSql = "SELECT * " +
|
||||||
int chunkSize = 10000;
|
"FROM " + exportHistoryItem.getPublication().getEntityName();
|
||||||
|
innerSql = UtilityDB.addwhereCond(innerSql, exportHistoryItem.getPublication().getWhereCondSql(), true);
|
||||||
|
|
||||||
for (int chunkIndex = 0; chunkIndex < (totalItemCount / chunkSize) + 1; chunkIndex++) {
|
UtilityDB.executeSimpleQueryDTOAsync(connection, innerSql, entityClass, data -> {
|
||||||
|
|
||||||
while (exportHistoryItem.getToProcessQueue().size() > 30000) {
|
exportHistoryGroup.setProcessedItemCount(exportHistoryGroup.getProcessedItemCount() + 1);
|
||||||
Thread.sleep(10 * 1000);
|
// exportHistoryItem.getToProcessQueue().add(JSON.toJSONString(data));
|
||||||
|
|
||||||
|
data.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
exportHistoryGroup.getToProcessQueue().add(new AbstractMap.SimpleEntry<>(exportHistoryItem.getPublication().getEntityName(), jsonObjectMapper.writeValueAsString(data)));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
String innerSql = "SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS row_number " +
|
|
||||||
"FROM " + exportHistoryItem.getPublication().getEntityName();
|
|
||||||
|
|
||||||
innerSql = UtilityDB.addwhereCond(innerSql, exportHistoryItem.getPublication().getWhereCond(), true);
|
while ((float) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().totalMemory() > 0.9f) {
|
||||||
|
logger.debug("Memory limit reached: " + (((float) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().totalMemory()) * 100) + "%");
|
||||||
String sql = "WITH TempResult AS (\n" +
|
try {
|
||||||
innerSql + ")\n" +
|
Thread.sleep(1 * 1000);
|
||||||
"SELECT TempResult.*\n" +
|
} catch (InterruptedException e) {
|
||||||
"FROM TempResult\n" +
|
throw new RuntimeException(e);
|
||||||
"ORDER BY row_number\n" +
|
}
|
||||||
"OFFSET (" + chunkIndex + ") * " + chunkSize + " ROWS FETCH NEXT " + chunkSize + " ROWS ONLY";
|
}
|
||||||
|
});
|
||||||
final List<? extends EntityBase> selectedChunk = UtilityDB.executeSimpleQueryDTO(connection, sql, entityClass);
|
|
||||||
|
|
||||||
if (selectedChunk == null || selectedChunk.isEmpty()) continue;
|
|
||||||
|
|
||||||
exportHistoryItem.setProcessedItemCount(exportHistoryItem.getProcessedItemCount() + selectedChunk.size());
|
|
||||||
//logger.debug("COUNT: " + exportHistoryItem.getProcessedItemCount());
|
|
||||||
|
|
||||||
selectedChunk.forEach(x -> exportHistoryItem.getToProcessQueue().add(x));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void consumeProcessedQueue() {
|
private void consumeProcessedQueue() {
|
||||||
final List<Long> currentlyInExecutionKeys = new ArrayList<>(currentlyInExecution.keySet());
|
List<ExportHistoryGroupDTO> list = currentlyInExecutionG.get();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
ExportHistoryGroupDTO currentGroup = list.get(i);
|
||||||
|
try {
|
||||||
|
internalProcessQueue(currentGroup);
|
||||||
|
|
||||||
for (long currentGroupId : currentlyInExecutionKeys) {
|
if (currentGroup.isCompletedRead() && currentGroup.getEndTime() == null) {
|
||||||
List<ExportHistoryItemDTO> entitiesToExport = currentlyInExecution.get(currentGroupId);
|
currentGroup.setEndTime(UtilityLocalDate.getNowTime());
|
||||||
|
updateReadyToTransmit(currentGroup);
|
||||||
|
list.remove(i--);
|
||||||
|
}
|
||||||
|
|
||||||
for (ExportHistoryItemDTO entityToExport : entitiesToExport) {
|
currentGroup.getDataSource().getConnection().commit();
|
||||||
try {
|
} catch (Exception ex) {
|
||||||
internalProcessQueue(entityToExport);
|
ex.printStackTrace();
|
||||||
} catch (Exception ex) {
|
logger.error(ex.getMessage(), ex);
|
||||||
logger.error(ex.getMessage(), ex);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalProcessQueue(ExportHistoryGroupDTO currentGroup) throws Exception {
|
||||||
|
String insertSQL = "INSERT INTO " + StbTransactionLog.ENTITY + " (publication_group_id, created_at, user_name, entities, entities_json, group_id)" +
|
||||||
|
" VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(currentGroup.getDataSource().getProfile())) {
|
||||||
|
|
||||||
|
while (!currentGroup.getToProcessQueue().isEmpty()) {
|
||||||
|
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) multiDBTransactionManager.prepareStatement(insertSQL)) {
|
||||||
|
Map.Entry<String, String> entityJson;
|
||||||
|
while ((entityJson = currentGroup.getToProcessQueue().poll()) != null) {
|
||||||
|
insertBulkPs.setLong(1, currentGroup.getGroupId());
|
||||||
|
insertBulkPs.setObject(2, UtilityLocalDate.getNowTime());
|
||||||
|
insertBulkPs.setString(3, null);
|
||||||
|
insertBulkPs.setString(4, entityJson.getKey());
|
||||||
|
insertBulkPs.setString(5, entityJson.getValue());
|
||||||
|
insertBulkPs.setLong(6, Long.MIN_VALUE + currentGroup.getSyncronizedItemCount());
|
||||||
|
|
||||||
|
insertBulkPs.addBatch();
|
||||||
|
currentGroup.setSyncronizedItemCount(currentGroup.getSyncronizedItemCount() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
insertBulkPs.executeLargeBatch();
|
||||||
|
|
||||||
|
System.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void internalProcessQueue(ExportHistoryItemDTO entityToExport) throws Exception {
|
|
||||||
//logger.debug("TBS COUNT: " + entityToExport.getToProcessQueue().size());
|
|
||||||
|
|
||||||
if (entityToExport.getStartDate() == null) entityToExport.setStartDate(UtilityLocalDate.getNowTime());
|
private void updateReadyToTransmit(ExportHistoryGroupDTO exportHistoryGroup) throws Exception {
|
||||||
|
StbPublications stbPublications = new StbPublications()
|
||||||
|
.setId(exportHistoryGroup.getGroupId());
|
||||||
|
stbPublications.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(entityToExport.getDataSource().getProfile())) {
|
stbPublications.setStbPublicationsDetails(exportHistoryGroup.getItems().stream()
|
||||||
|
.map(x -> {
|
||||||
|
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||||
|
.setId(x.getPublication().getId())
|
||||||
|
.setReadyToTransmit(true);
|
||||||
|
|
||||||
EntityBase entity;
|
stbPublicationsDetail.setOperation(OperationType.UPDATE);
|
||||||
while ((entity = entityToExport.getToProcessQueue().poll()) != null) {
|
return stbPublicationsDetail;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
StbTransactionLog stbTransactionLog = new StbTransactionLog()
|
stbPublications.manageWithParentConnection(exportHistoryGroup.getDataSource().getConnection());
|
||||||
.setPublicationGroupId(entityToExport.getPublicationGroupId())
|
|
||||||
.setCreatedAt(UtilityLocalDate.getNowTime())
|
|
||||||
.setEntitiesJson(jsonObjectMapper.writeValueAsString(entity))
|
|
||||||
.setGroupId(-1)
|
|
||||||
.setEntities(entityToExport.getPublication().getEntityName());
|
|
||||||
|
|
||||||
stbTransactionLog
|
|
||||||
.setOperation(OperationType.INSERT);
|
|
||||||
|
|
||||||
stbTransactionLog.manageWithParentConnection(multiDBTransactionManager.getPrimaryConnection());
|
|
||||||
entityToExport.setSyncronizedItemCount(entityToExport.getSyncronizedItemCount() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<ExportHistoryStatusDTO> getStatus() {
|
public List<ExportHistoryStatusDTO> getStatus() {
|
||||||
|
|
||||||
List<ExportHistoryStatusDTO> statusList = new ArrayList<>();
|
List<ExportHistoryStatusDTO> statusList = new ArrayList<>();
|
||||||
|
|
||||||
HashMap<Long, HashMap<String, Object>> total = new HashMap<>();
|
for (ExportHistoryGroupDTO currentGroup : currentlyInExecutionG.get()) {
|
||||||
|
|
||||||
for (Long key : currentlyInExecution.keySet()) {
|
final LocalDateTime startDate = currentGroup.getStartTime();
|
||||||
|
|
||||||
final LocalDateTime startDate = currentlyInExecution.get(key).stream()
|
|
||||||
.map(ExportHistoryItemDTO::getStartDate)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.min(Comparator.naturalOrder())
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
long totalCount = 0;
|
long totalCount = 0;
|
||||||
long processedCount = 0;
|
long processedCount = 0;
|
||||||
long itemsPerSec = 1;
|
long itemsPerSec = 1;
|
||||||
LocalDateTime estimatedEnd = null;
|
LocalDateTime estimatedEnd = currentGroup.getEndTime();
|
||||||
|
|
||||||
if (startDate != null) {
|
if (startDate != null) {
|
||||||
totalCount = currentlyInExecution.get(key).stream()
|
totalCount = currentGroup.getTotalItemCount();
|
||||||
.map(ExportHistoryItemDTO::getTotalItemCount)
|
processedCount = currentGroup.getSyncronizedItemCount();
|
||||||
.reduce(0L, Long::sum);
|
|
||||||
|
|
||||||
processedCount = currentlyInExecution.get(key).stream()
|
final long secondsBetween = ChronoUnit.SECONDS.between(startDate, estimatedEnd != null ? estimatedEnd : UtilityLocalDate.getNowTime());
|
||||||
.map(ExportHistoryItemDTO::getSyncronizedItemCount)
|
|
||||||
.reduce(0L, Long::sum);
|
|
||||||
|
|
||||||
final long secondsBetween = ChronoUnit.SECONDS.between(startDate, UtilityLocalDate.getNowTime());
|
|
||||||
itemsPerSec = processedCount / (secondsBetween == 0 ? 1 : secondsBetween);
|
itemsPerSec = processedCount / (secondsBetween == 0 ? 1 : secondsBetween);
|
||||||
|
|
||||||
//if(itemsPerSec == 0) itemsPerSec = 1 / 60;
|
|
||||||
double secsToEnd = (double) totalCount / (itemsPerSec == 0 ? 1 : itemsPerSec);
|
double secsToEnd = (double) totalCount / (itemsPerSec == 0 ? 1 : itemsPerSec);
|
||||||
|
|
||||||
estimatedEnd = startDate.plusSeconds((long) secsToEnd);
|
estimatedEnd = startDate.plusSeconds((long) secsToEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
statusList.add(new ExportHistoryStatusDTO()
|
statusList.add(new ExportHistoryStatusDTO()
|
||||||
.setPublicationGroupId(key)
|
.setPublicationGroupId(currentGroup.getGroupId())
|
||||||
.setStartedAt(startDate)
|
.setStartedAt(startDate)
|
||||||
.setTotalCount(totalCount)
|
.setTotalCount(totalCount)
|
||||||
.setProcessedCount(processedCount)
|
.setProcessedCount(processedCount)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.sync;
|
package it.integry.ems.sync;
|
||||||
|
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
import it.integry.common.var.CommonConstants;
|
|
||||||
import it.integry.ems.json.JSONObjectMapper;
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
@@ -11,7 +11,10 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||||
|
import it.integry.ems_model.entity.StbTransactionLog;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -21,11 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.context.ContextLoader;
|
import org.springframework.web.context.ContextLoader;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -45,11 +46,13 @@ public class AsyncManager {
|
|||||||
|
|
||||||
private final static HashMap<String, List<StbPublicationsDetail>> cachedSetup = new HashMap<>();
|
private final static HashMap<String, List<StbPublicationsDetail>> cachedSetup = new HashMap<>();
|
||||||
|
|
||||||
|
private final static ConcurrentLinkedQueue<Map.Entry<String, StbTransactionLog>> toBeSavedQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
@PostContextConstruct
|
@PostContextConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||||
looperService.add(this::internalCachePublicationsSetup, 5 * 60 * 1000, AsyncManager.class.getName());
|
looperService.add(this::internalCachePublicationsSetup, 5 * 60 * 1000, "sync-setup-cache");
|
||||||
|
looperService.add(this::consumeToBeSavedQueue, 20 * 1000, "sync-flush-data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +87,7 @@ public class AsyncManager {
|
|||||||
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileName, false);
|
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileName, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String sql = "SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE syncronize = 'R'";
|
String sql = "SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE active = 1";
|
||||||
List<StbPublicationsDetail> publications = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbPublicationsDetail.class);
|
List<StbPublicationsDetail> publications = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbPublicationsDetail.class);
|
||||||
|
|
||||||
cachedSetup.putIfAbsent(dbName, publications);
|
cachedSetup.putIfAbsent(dbName, publications);
|
||||||
@@ -106,14 +109,14 @@ public class AsyncManager {
|
|||||||
if (activePublication == null)
|
if (activePublication == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
logger.debug("SYNC OFFLINE ABILITATA SU " + tableName);
|
//logger.debug("SYNC OFFLINE ABILITATA SU " + tableName);
|
||||||
|
|
||||||
List<EntityBase> myObjs = new ArrayList<>();
|
List<EntityBase> myObjs = new ArrayList<>();
|
||||||
myObjs.add(entityBase);
|
myObjs.add(entityBase);
|
||||||
|
|
||||||
String selectSql = "SELECT * FROM " + entityBase.getClass().getCanonicalName();
|
String selectSql = "SELECT * FROM " + entityBase.getClass().getCanonicalName();
|
||||||
if (!UtilityString.isNullOrEmpty(activePublication.getWhereCondSql())) {
|
if (!UtilityString.isNullOrEmpty(activePublication.getWhereCondField())) {
|
||||||
selectSql = selectSql + " WHERE " + activePublication.getWhereCondSql();
|
selectSql = selectSql + " WHERE " + activePublication.getWhereCondField();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new Query.
|
// Create a new Query.
|
||||||
@@ -130,49 +133,91 @@ public class AsyncManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void saveNewTransaction(Connection connection, EntityBase entityBase, int transactionGroupId) throws Exception {
|
public static Long saveNewTransaction(Connection connection, String dbName, EntityBase entityBase, long publicationId, Long transactionGroupId) throws Exception {
|
||||||
|
//TODO: Calc transaction group ID here
|
||||||
String transactionDate = new SimpleDateFormat(CommonConstants.DATETIME_FORMAT_YMD).format(new Date());
|
if (transactionGroupId == null) transactionGroupId = getNextTransactionGroupId(connection, dbName);
|
||||||
int transactionId = 0;
|
|
||||||
|
|
||||||
Integer tmpTransactionId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
|
|
||||||
connection, "SELECT max(transaction_id) as max_id from stb_transaction_log_db");
|
|
||||||
|
|
||||||
if (tmpTransactionId != null) transactionId = tmpTransactionId;
|
|
||||||
transactionId++; //Incremento l'ID
|
|
||||||
|
|
||||||
JSONObjectMapper jsonObjectMapper = ContextLoader.getCurrentWebApplicationContext().getBean(JSONObjectMapper.class);
|
JSONObjectMapper jsonObjectMapper = ContextLoader.getCurrentWebApplicationContext().getBean(JSONObjectMapper.class);
|
||||||
|
|
||||||
StringWriter writer = new StringWriter();
|
StbTransactionLog stbTransactionLog = new StbTransactionLog()
|
||||||
jsonObjectMapper.writeValue(writer, entityBase);
|
.setCreatedAt(UtilityLocalDate.getNowTime())
|
||||||
|
.setEntities(entityBase.getTableName().toUpperCase())
|
||||||
String entityName = entityBase.getTableName().toUpperCase();
|
.setEntitiesJson(jsonObjectMapper.writeValueAsString(entityBase))
|
||||||
|
.setPublicationGroupId(publicationId)
|
||||||
String sql =
|
.setUserName(entityBase.getUsername())
|
||||||
"INSERT INTO stb_transaction_log_db(transaction_id, transaction_group_id, transaction_date, user_name, transaction_json, entity_name_list) " +
|
.setGroupId(transactionGroupId);
|
||||||
"VALUES (" + transactionId + "," + transactionGroupId + ",'" + transactionDate + "', null, '%s', " + UtilityDB.valueToString(entityName) + ")";
|
stbTransactionLog.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
String jsonString = writer.toString().replace("'", "''");
|
|
||||||
|
|
||||||
sql = String.format(sql, jsonString);
|
|
||||||
|
|
||||||
PreparedStatement psExec = connection.prepareStatement(sql);
|
|
||||||
psExec.executeUpdate();
|
|
||||||
psExec.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int getNextTransactionGroupId(Connection connection) throws Exception {
|
|
||||||
int transactionGroupId = 0;
|
|
||||||
|
|
||||||
Integer tmpTransactionGroupId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
|
|
||||||
connection, "SELECT MAX(transaction_group_id) AS max_id from stb_transaction_log_db");
|
|
||||||
|
|
||||||
if (tmpTransactionGroupId != null) transactionGroupId = tmpTransactionGroupId;
|
|
||||||
transactionGroupId++; //Incremento l'ID
|
|
||||||
|
|
||||||
|
toBeSavedQueue.add(new AbstractMap.SimpleEntry<>(dbName, stbTransactionLog));
|
||||||
return transactionGroupId;
|
return transactionGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static long getNextTransactionGroupId(Connection connection, String dbName) throws Exception {
|
||||||
|
|
||||||
|
final long maxToBeProcessed = toBeSavedQueue.stream().filter(x -> x.getKey().equalsIgnoreCase(dbName))
|
||||||
|
.map(x -> x.getValue().getGroupId())
|
||||||
|
.max(Long::compare)
|
||||||
|
.orElse(0L);
|
||||||
|
|
||||||
|
long transactionGroupId = 0;
|
||||||
|
|
||||||
|
if (maxToBeProcessed <= 0) {
|
||||||
|
Long tmpTransactionGroupId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
|
||||||
|
connection, "SELECT MAX(group_id) AS max_id FROM " + StbTransactionLog.ENTITY);
|
||||||
|
|
||||||
|
tmpTransactionGroupId = tmpTransactionGroupId != 0 ? tmpTransactionGroupId : 0L;
|
||||||
|
|
||||||
|
transactionGroupId = Math.max(maxToBeProcessed, tmpTransactionGroupId);
|
||||||
|
} else {
|
||||||
|
transactionGroupId = maxToBeProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionGroupId++; //Incremento l'ID
|
||||||
|
return transactionGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void consumeToBeSavedQueue() {
|
||||||
|
if (cachedSetup.entrySet().stream().anyMatch(x -> x.getValue() != null && x.getValue().stream().anyMatch(y -> !y.isReadyToTransmit())))
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<String> dbNamesToConnect = toBeSavedQueue.stream().map(Map.Entry::getKey).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
final List<AvailableConnectionsModel> databaseConnections = settingsModel.getAvailableConnections().stream()
|
||||||
|
.filter(x -> dbNamesToConnect.stream().anyMatch(y -> x.getDbName().equalsIgnoreCase(y)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
String insertSQL = "INSERT INTO " + StbTransactionLog.ENTITY + " (publication_group_id, created_at, user_name, entities, entities_json, group_id)" +
|
||||||
|
" VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
Map.Entry<String, StbTransactionLog> itemToSave = null;
|
||||||
|
while ((itemToSave = toBeSavedQueue.poll()) != null) {
|
||||||
|
final Map.Entry<String, StbTransactionLog> finalItemToSave = itemToSave;
|
||||||
|
final StbTransactionLog stbTransactionLog = finalItemToSave.getValue();
|
||||||
|
|
||||||
|
AvailableConnectionsModel connectionModel = databaseConnections.stream()
|
||||||
|
.filter(x -> x.getDbName().equalsIgnoreCase(finalItemToSave.getKey()))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionModel);
|
||||||
|
SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) multiDBTransactionManager.prepareStatement(insertSQL)) {
|
||||||
|
|
||||||
|
insertBulkPs.setLong(1, stbTransactionLog.getPublicationGroupId());
|
||||||
|
insertBulkPs.setObject(2, stbTransactionLog.getCreatedAt());
|
||||||
|
insertBulkPs.setString(3, stbTransactionLog.getUserName());
|
||||||
|
insertBulkPs.setString(4, stbTransactionLog.getEntities());
|
||||||
|
insertBulkPs.setString(5, stbTransactionLog.getEntitiesJson());
|
||||||
|
insertBulkPs.setLong(6, stbTransactionLog.getGroupId());
|
||||||
|
|
||||||
|
|
||||||
|
insertBulkPs.executeLargeUpdate();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class MultiDBTransactionManager implements AutoCloseable{
|
|||||||
public MultiDBTransactionManager() {
|
public MultiDBTransactionManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultiDBTransactionManager(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||||
|
this(connectionsModel.getProfileName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
public MultiDBTransactionManager(String profileDb) throws Exception {
|
public MultiDBTransactionManager(String profileDb) throws Exception {
|
||||||
this(profileDb, true);
|
this(profileDb, true);
|
||||||
}
|
}
|
||||||
@@ -79,6 +83,10 @@ public class MultiDBTransactionManager implements AutoCloseable{
|
|||||||
this.dbPrimary = null;
|
this.dbPrimary = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addConnection(AvailableConnectionsModel availableConnectionsModel) throws Exception {
|
||||||
|
this.addConnection(availableConnectionsModel.getProfileName());
|
||||||
|
}
|
||||||
|
|
||||||
public void addConnection(String profileName) throws Exception {
|
public void addConnection(String profileName) throws Exception {
|
||||||
DataSource ds = new DataSource();
|
DataSource ds = new DataSource();
|
||||||
ds.initialize(profileName);
|
ds.initialize(profileName);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.sync.controller;
|
package it.integry.ems.sync.controller;
|
||||||
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
import it.integry.ems.sync.service.RemoteSyncronizationService;
|
import it.integry.ems.sync.service.RemoteSynchronizationService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -12,20 +12,28 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
@RequestMapping("system/remote-sync")
|
@RequestMapping("system/remote-sync")
|
||||||
public class RemoteSyncronizationController {
|
public class RemoteSynchronizationController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteSyncronizationService remoteSyncronizationService;
|
private RemoteSynchronizationService remoteSynchronizationService;
|
||||||
|
|
||||||
@RequestMapping(value = "publications/{groupId}/start", method = RequestMethod.GET)
|
@RequestMapping(value = "publications/{groupId}/start", method = RequestMethod.GET)
|
||||||
public ServiceRestResponse startPublication(@PathVariable long groupId) throws Exception {
|
public ServiceRestResponse startPublication(@PathVariable long groupId) throws Exception {
|
||||||
remoteSyncronizationService.startPublication(groupId);
|
remoteSynchronizationService.startPublication(groupId);
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "publications/status", method = RequestMethod.GET)
|
@RequestMapping(value = "publications/status", method = RequestMethod.GET)
|
||||||
public ServiceRestResponse statusPublication() {
|
public ServiceRestResponse statusPublication() {
|
||||||
return ServiceRestResponse.createPositiveResponse(remoteSyncronizationService.getPublicationStatus());
|
return ServiceRestResponse.createPositiveResponse(remoteSynchronizationService.getPublicationStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "subscription/{subscriptionId}/run", method = RequestMethod.GET)
|
||||||
|
public ServiceRestResponse runSubscription(@PathVariable long subscriptionId) throws Exception {
|
||||||
|
remoteSynchronizationService.runSubscription(subscriptionId);
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package it.integry.ems.sync.controller;
|
||||||
|
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.sync.dto.*;
|
||||||
|
import it.integry.ems.sync.service.RemoteSynchronizationSetupService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope("request")
|
||||||
|
@RequestMapping("system/remote-sync/setup")
|
||||||
|
public class RemoteSynchronizationSetupController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteSynchronizationSetupService remoteSynchronizationSetupService;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "publications/retrieve", method = RequestMethod.GET)
|
||||||
|
public ServiceRestResponse retrievePublications() throws Exception {
|
||||||
|
return ServiceRestResponse.createPositiveResponse(remoteSynchronizationSetupService.retrievePublications());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "publications/insert-group", method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse insertPublicationGroup(@RequestBody InsertPublicationGroupRequestDTO request) throws Exception {
|
||||||
|
return ServiceRestResponse.createPositiveResponse(remoteSynchronizationSetupService.addPublicationGroup(request.getDescription()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "publications/{groupId}/insert", method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse insertPublications(@PathVariable long groupId, @RequestBody PublicationDTO publicationToInsert) throws Exception {
|
||||||
|
InsertPublicationItemResponseDTO response = new InsertPublicationItemResponseDTO()
|
||||||
|
.setId(remoteSynchronizationSetupService.addPublicationItem(groupId, publicationToInsert));
|
||||||
|
|
||||||
|
return ServiceRestResponse.createPositiveResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "publications/{groupId}/delete-group", method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse deletePublicationGroup(@PathVariable long groupId) throws Exception {
|
||||||
|
remoteSynchronizationSetupService.deletePublicationsGroup(groupId);
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "publications/{publicationId}/delete", method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse deletePublication(@PathVariable long publicationId) throws Exception {
|
||||||
|
remoteSynchronizationSetupService.deletePublications(Collections.singletonList(publicationId));
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "publications/{publicationId}/edit", method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse editPublication(@PathVariable long publicationId, @RequestBody PublicationDTO publicationToEdit) throws Exception {
|
||||||
|
remoteSynchronizationSetupService.editPublication(publicationId, publicationToEdit);
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "subscriptions/insert", method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse insertSubscription(@RequestBody SubscriptionDTO subscriptionToInsert) throws Exception {
|
||||||
|
InsertSubscriptionResponseDTO response = new InsertSubscriptionResponseDTO()
|
||||||
|
.setId(remoteSynchronizationSetupService.addSubscription(subscriptionToInsert));
|
||||||
|
|
||||||
|
return ServiceRestResponse.createPositiveResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package it.integry.ems.sync.controller;
|
||||||
|
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.sync.service.RemoteSynchronizationTransactionsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope("request")
|
||||||
|
@RequestMapping("system/remote-transaction")
|
||||||
|
public class RemoteSynchronizationTransactionsController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteSynchronizationTransactionsService remoteSynchronizationTransactionsService;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "{publicationId}/retrieve", method = RequestMethod.GET)
|
||||||
|
public ServiceRestResponse retrieve(@PathVariable long publicationId,
|
||||||
|
@RequestParam(required = false) Long lastRetrievedTransactionId,
|
||||||
|
@RequestParam(required = false, defaultValue = "-1") int limit) throws Exception {
|
||||||
|
return ServiceRestResponse.createPositiveResponse(
|
||||||
|
remoteSynchronizationTransactionsService.retrieveTransactions(publicationId, lastRetrievedTransactionId, limit));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package it.integry.ems.sync.controller;
|
|
||||||
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
|
||||||
import it.integry.ems.sync.dto.InsertPublicationGroupRequestDTO;
|
|
||||||
import it.integry.ems.sync.dto.InsertPublicationItemResponseDTO;
|
|
||||||
import it.integry.ems.sync.dto.PublicationDTO;
|
|
||||||
import it.integry.ems.sync.service.RemoteSyncronizationSetupService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Scope("request")
|
|
||||||
@RequestMapping("system/remote-sync/setup")
|
|
||||||
public class RemoteSyncronizationSetupController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RemoteSyncronizationSetupService remoteSyncronizationSetupService;
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "publications/retrieve", method = RequestMethod.GET)
|
|
||||||
public ServiceRestResponse retrievePublications() throws Exception {
|
|
||||||
return ServiceRestResponse.createPositiveResponse(remoteSyncronizationSetupService.retrievePublications());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "publications/insert-group", method = RequestMethod.POST)
|
|
||||||
public ServiceRestResponse insertPublicationGroup(@RequestBody InsertPublicationGroupRequestDTO request) throws Exception {
|
|
||||||
return ServiceRestResponse.createPositiveResponse(remoteSyncronizationSetupService.addPublicationGroup(request.getDescription()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "publications/{groupId}/insert", method = RequestMethod.POST)
|
|
||||||
public ServiceRestResponse insertPublications(@PathVariable long groupId, @RequestBody PublicationDTO publicationToInsert) throws Exception {
|
|
||||||
InsertPublicationItemResponseDTO response = new InsertPublicationItemResponseDTO()
|
|
||||||
.setId(remoteSyncronizationSetupService.addPublicationItem(groupId, publicationToInsert));
|
|
||||||
|
|
||||||
|
|
||||||
return ServiceRestResponse.createPositiveResponse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,27 @@
|
|||||||
package it.integry.ems.sync.dto;
|
package it.integry.ems.sync.dto;
|
||||||
|
|
||||||
|
import it.integry.ems.datasource.DataSource;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
public class ExportHistoryGroupDTO {
|
public class ExportHistoryGroupDTO {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
private long groupId;
|
private long groupId;
|
||||||
private List<ExportHistoryItemDTO> items;
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private boolean completedRead;
|
||||||
|
private long totalItemCount;
|
||||||
|
private long processedItemCount;
|
||||||
|
private long syncronizedItemCount;
|
||||||
|
private List<ExportHistoryItemDTO> items = new ArrayList<>();
|
||||||
|
|
||||||
|
private final Queue<Map.Entry<String, String>> toProcessQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
|
|
||||||
public long getGroupId() {
|
public long getGroupId() {
|
||||||
@@ -25,4 +41,72 @@ public class ExportHistoryGroupDTO {
|
|||||||
this.items = items;
|
this.items = items;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Queue<Map.Entry<String, String>> getToProcessQueue() {
|
||||||
|
return toProcessQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataSource getDataSource() {
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setDataSource(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalItemCount() {
|
||||||
|
return totalItemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setTotalItemCount(long totalItemCount) {
|
||||||
|
this.totalItemCount = totalItemCount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getProcessedItemCount() {
|
||||||
|
return processedItemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setProcessedItemCount(long processedItemCount) {
|
||||||
|
this.processedItemCount = processedItemCount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSyncronizedItemCount() {
|
||||||
|
return syncronizedItemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setSyncronizedItemCount(long syncronizedItemCount) {
|
||||||
|
this.syncronizedItemCount = syncronizedItemCount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompletedRead() {
|
||||||
|
return completedRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setCompletedRead(boolean completedRead) {
|
||||||
|
this.completedRead = completedRead;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportHistoryGroupDTO setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,12 @@
|
|||||||
package it.integry.ems.sync.dto;
|
package it.integry.ems.sync.dto;
|
||||||
|
|
||||||
import it.integry.ems.datasource.DataSource;
|
|
||||||
import it.integry.ems_model.base.EntityBase;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
|
|
||||||
public class ExportHistoryItemDTO {
|
public class ExportHistoryItemDTO {
|
||||||
|
|
||||||
private long publicationGroupId;
|
|
||||||
private DataSource dataSource;
|
|
||||||
private PublicationDTO publication;
|
private PublicationDTO publication;
|
||||||
private LocalDateTime startDate;
|
private LocalDateTime startDate;
|
||||||
private long totalItemCount;
|
|
||||||
private long processedItemCount;
|
|
||||||
private long syncronizedItemCount;
|
|
||||||
|
|
||||||
private Queue<EntityBase> toProcessQueue = new ConcurrentLinkedQueue<EntityBase>();
|
|
||||||
|
|
||||||
public long getPublicationGroupId() {
|
|
||||||
return publicationGroupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportHistoryItemDTO setPublicationGroupId(long publicationGroupId) {
|
|
||||||
this.publicationGroupId = publicationGroupId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataSource getDataSource() {
|
|
||||||
return dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportHistoryItemDTO setDataSource(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationDTO getPublication() {
|
public PublicationDTO getPublication() {
|
||||||
return publication;
|
return publication;
|
||||||
@@ -54,40 +25,4 @@ public class ExportHistoryItemDTO {
|
|||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTotalItemCount() {
|
|
||||||
return totalItemCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportHistoryItemDTO setTotalItemCount(long totalItemCount) {
|
|
||||||
this.totalItemCount = totalItemCount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getProcessedItemCount() {
|
|
||||||
return processedItemCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportHistoryItemDTO setProcessedItemCount(long processedItemCount) {
|
|
||||||
this.processedItemCount = processedItemCount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Queue<EntityBase> getToProcessQueue() {
|
|
||||||
return toProcessQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportHistoryItemDTO setToProcessQueue(Queue<EntityBase> toProcessQueue) {
|
|
||||||
this.toProcessQueue = toProcessQueue;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSyncronizedItemCount() {
|
|
||||||
return syncronizedItemCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportHistoryItemDTO setSyncronizedItemCount(long syncronizedItemCount) {
|
|
||||||
this.syncronizedItemCount = syncronizedItemCount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package it.integry.ems.sync.dto;
|
||||||
|
|
||||||
|
public class InsertSubscriptionResponseDTO {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InsertSubscriptionResponseDTO setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,14 +8,17 @@ public class PublicationDTO {
|
|||||||
private String entityName;
|
private String entityName;
|
||||||
private String whereCondSql;
|
private String whereCondSql;
|
||||||
private String recalcColumns;
|
private String recalcColumns;
|
||||||
private boolean active;
|
private Boolean active;
|
||||||
private boolean exportHistory;
|
private Boolean exportHistory;
|
||||||
|
private Boolean readyToTransmit;
|
||||||
private String whereCond;
|
private String whereCond;
|
||||||
|
|
||||||
|
|
||||||
public static PublicationDTO fromStbPublicationDetail(StbPublicationsDetail stbPublicationsDetail) {
|
public static PublicationDTO fromStbPublicationDetail(StbPublicationsDetail stbPublicationsDetail) {
|
||||||
return new PublicationDTO()
|
return new PublicationDTO()
|
||||||
.setActive(stbPublicationsDetail.isActive())
|
.setActive(stbPublicationsDetail.isActive())
|
||||||
|
.setExportHistory(stbPublicationsDetail.isExportHistory())
|
||||||
|
.setReadyToTransmit(stbPublicationsDetail.isReadyToTransmit())
|
||||||
.setId(stbPublicationsDetail.getId())
|
.setId(stbPublicationsDetail.getId())
|
||||||
.setRecalcColumns(stbPublicationsDetail.getRecalcColumnsField())
|
.setRecalcColumns(stbPublicationsDetail.getRecalcColumnsField())
|
||||||
.setEntityName(stbPublicationsDetail.getEntityName())
|
.setEntityName(stbPublicationsDetail.getEntityName())
|
||||||
@@ -59,24 +62,33 @@ public class PublicationDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public Boolean getActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicationDTO setActive(boolean active) {
|
public PublicationDTO setActive(Boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExportHistory() {
|
public Boolean getExportHistory() {
|
||||||
return exportHistory;
|
return exportHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicationDTO setExportHistory(boolean exportHistory) {
|
public PublicationDTO setExportHistory(Boolean exportHistory) {
|
||||||
this.exportHistory = exportHistory;
|
this.exportHistory = exportHistory;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getReadyToTransmit() {
|
||||||
|
return readyToTransmit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationDTO setReadyToTransmit(Boolean readyToTransmit) {
|
||||||
|
this.readyToTransmit = readyToTransmit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getWhereCond() {
|
public String getWhereCond() {
|
||||||
return whereCond;
|
return whereCond;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ public class PublicationGroupDTO {
|
|||||||
private long id;
|
private long id;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
private boolean canStartExport;
|
||||||
|
private boolean canBeDeleted;
|
||||||
|
|
||||||
private List<PublicationDTO> publications = new ArrayList<>();
|
private List<PublicationDTO> publications = new ArrayList<>();
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
@@ -28,6 +31,24 @@ public class PublicationGroupDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCanStartExport() {
|
||||||
|
return canStartExport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationGroupDTO setCanStartExport(boolean canStartExport) {
|
||||||
|
this.canStartExport = canStartExport;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCanBeDeleted() {
|
||||||
|
return canBeDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationGroupDTO setCanBeDeleted(boolean canBeDeleted) {
|
||||||
|
this.canBeDeleted = canBeDeleted;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<PublicationDTO> getPublications() {
|
public List<PublicationDTO> getPublications() {
|
||||||
return publications;
|
return publications;
|
||||||
}
|
}
|
||||||
@@ -36,4 +57,5 @@ public class PublicationGroupDTO {
|
|||||||
this.publications = publications;
|
this.publications = publications;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package it.integry.ems.sync.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.entity.StbRemoteSubscription;
|
||||||
|
|
||||||
|
public class SubscriptionDTO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private long publicationId;
|
||||||
|
private String publicationDescription;
|
||||||
|
private String endpointProtocol;
|
||||||
|
private String endpointHost;
|
||||||
|
private int endpointPort;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String profileDb;
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPublicationId() {
|
||||||
|
return publicationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setPublicationId(long publicationId) {
|
||||||
|
this.publicationId = publicationId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicationDescription() {
|
||||||
|
return publicationDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setPublicationDescription(String publicationDescription) {
|
||||||
|
this.publicationDescription = publicationDescription;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndpointProtocol() {
|
||||||
|
return endpointProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setEndpointProtocol(String endpointProtocol) {
|
||||||
|
this.endpointProtocol = endpointProtocol;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndpointHost() {
|
||||||
|
return endpointHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setEndpointHost(String endpointHost) {
|
||||||
|
this.endpointHost = endpointHost;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEndpointPort() {
|
||||||
|
return endpointPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setEndpointPort(int endpointPort) {
|
||||||
|
this.endpointPort = endpointPort;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileDb() {
|
||||||
|
return profileDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setProfileDb(String profileDb) {
|
||||||
|
this.profileDb = profileDb;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionDTO setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getEndpointUrl() {
|
||||||
|
return endpointProtocol.toLowerCase() + "://" + endpointHost + ":" + endpointPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static SubscriptionDTO fromEntity(StbRemoteSubscription stbRemoteSubscription) {
|
||||||
|
return new SubscriptionDTO()
|
||||||
|
.setId(stbRemoteSubscription.getId())
|
||||||
|
.setPublicationId(stbRemoteSubscription.getPublicationId())
|
||||||
|
.setPublicationDescription(stbRemoteSubscription.getPublicationDescription())
|
||||||
|
.setEndpointProtocol(stbRemoteSubscription.getEndpointProtocol())
|
||||||
|
.setEndpointHost(stbRemoteSubscription.getEndpointHost())
|
||||||
|
.setEndpointPort(stbRemoteSubscription.getEndpointPort())
|
||||||
|
.setUsername(stbRemoteSubscription.getUsername())
|
||||||
|
.setPassword(stbRemoteSubscription.getPassword())
|
||||||
|
.setProfileDb(stbRemoteSubscription.getProfileDb())
|
||||||
|
.setActive(stbRemoteSubscription.isActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription toEntity() {
|
||||||
|
return new StbRemoteSubscription()
|
||||||
|
.setPublicationId(getPublicationId())
|
||||||
|
.setPublicationDescription(getPublicationDescription())
|
||||||
|
.setEndpointProtocol(getEndpointProtocol())
|
||||||
|
.setEndpointHost(getEndpointHost())
|
||||||
|
.setEndpointPort(getEndpointPort())
|
||||||
|
.setProfileDb(getProfileDb())
|
||||||
|
.setUsernameField(getUsername())
|
||||||
|
.setPassword(getPassword())
|
||||||
|
.setActive(isActive());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +1,39 @@
|
|||||||
package it.integry.ems.async.dto;
|
package it.integry.ems.sync.dto;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public class TransactionDTO {
|
public class TransactionDTO {
|
||||||
|
|
||||||
private String publicationId;
|
private long publicationId;
|
||||||
private int transactionId;
|
private long transactionId;
|
||||||
private Date transactionDate;
|
private LocalDateTime transactionDate;
|
||||||
private String username;
|
private String username;
|
||||||
private String entityName;
|
private String entityName;
|
||||||
private String transactionJson;
|
private String transactionJson;
|
||||||
private int transactionGroupId;
|
|
||||||
|
|
||||||
public String getPublicationId() {
|
public long getPublicationId() {
|
||||||
return publicationId;
|
return publicationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransactionDTO setPublicationId(String publicationId) {
|
public TransactionDTO setPublicationId(long publicationId) {
|
||||||
this.publicationId = publicationId;
|
this.publicationId = publicationId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTransactionId() {
|
public long getTransactionId() {
|
||||||
return transactionId;
|
return transactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransactionDTO setTransactionId(int transactionId) {
|
public TransactionDTO setTransactionId(long transactionId) {
|
||||||
this.transactionId = transactionId;
|
this.transactionId = transactionId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getTransactionDate() {
|
public LocalDateTime getTransactionDate() {
|
||||||
return transactionDate;
|
return transactionDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransactionDTO setTransactionDate(Date transactionDate) {
|
public TransactionDTO setTransactionDate(LocalDateTime transactionDate) {
|
||||||
this.transactionDate = transactionDate;
|
this.transactionDate = transactionDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -65,13 +64,4 @@ public class TransactionDTO {
|
|||||||
this.transactionJson = transactionJson;
|
this.transactionJson = transactionJson;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTransactionGroupId() {
|
|
||||||
return transactionGroupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setTransactionGroupId(int transactionGroupId) {
|
|
||||||
this.transactionGroupId = transactionGroupId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package it.integry.ems.sync.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TransactionGroupDTO {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
private List<TransactionDTO> items;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransactionGroupDTO setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TransactionDTO> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransactionGroupDTO setItems(List<TransactionDTO> items) {
|
||||||
|
this.items = items;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package it.integry.ems.sync.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
|
import it.integry.ems.response.EsitoType;
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.service.EntityProcessor;
|
||||||
|
import it.integry.ems.service.HttpRestWrapper;
|
||||||
|
import it.integry.ems.sync.AsyncHistoryManager;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.sync.dto.ExportHistoryStatusDTO;
|
||||||
|
import it.integry.ems.sync.dto.PublicationDTO;
|
||||||
|
import it.integry.ems.sync.dto.TransactionDTO;
|
||||||
|
import it.integry.ems.sync.dto.TransactionGroupDTO;
|
||||||
|
import it.integry.ems.utility.UtilityEntity;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
|
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||||
|
import it.integry.ems_model.entity.StbRemoteSubscription;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Scope(value = "request")
|
||||||
|
public class RemoteSynchronizationService {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsyncHistoryManager asyncHistoryManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityPropertyHolder entityPropertyHolder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityProcessor entityProcessor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
|
public void startPublication(long groupId) throws Exception {
|
||||||
|
String sql = Query.format("SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE stb_publication_id = %s AND export_history = %s AND ready_to_transmit = 0", groupId, 1);
|
||||||
|
|
||||||
|
final List<StbPublicationsDetail> stbPublicationsDetails = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbPublicationsDetail.class);
|
||||||
|
|
||||||
|
if (stbPublicationsDetails == null)
|
||||||
|
throw new Exception("Non è stata trovata alcuna pubblicazione da poter avviare (ID: " + groupId + ")");
|
||||||
|
|
||||||
|
for (StbPublicationsDetail stbPublicationsDetail : stbPublicationsDetails) {
|
||||||
|
asyncHistoryManager.addToExportQueue(multiDBTransactionManager.getPrimaryDatasource(),
|
||||||
|
groupId,
|
||||||
|
PublicationDTO.fromStbPublicationDetail(stbPublicationsDetail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExportHistoryStatusDTO> getPublicationStatus() {
|
||||||
|
return asyncHistoryManager.getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runSubscription(long subscriptionId) throws Exception {
|
||||||
|
String sql = Query.format("SELECT * FROM " + StbRemoteSubscription.ENTITY +
|
||||||
|
" WHERE id = %s AND active = 1", subscriptionId);
|
||||||
|
|
||||||
|
final StbRemoteSubscription stbRemoteSubscription =
|
||||||
|
UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbRemoteSubscription.class);
|
||||||
|
|
||||||
|
if (stbRemoteSubscription == null)
|
||||||
|
throw new Exception("Non è stata trovata alcuna sottoscrizione da poter avviare con l'ID " + subscriptionId);
|
||||||
|
|
||||||
|
internalSubscriptionRun(stbRemoteSubscription);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void internalSubscriptionRun(StbRemoteSubscription subscription) throws Exception {
|
||||||
|
boolean shouldStop = false;
|
||||||
|
|
||||||
|
while (!shouldStop) {
|
||||||
|
List<TransactionGroupDTO> downloadedTransactions = downloadTransactions(subscription);
|
||||||
|
|
||||||
|
if (downloadedTransactions == null || downloadedTransactions.isEmpty()) {
|
||||||
|
shouldStop = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
long lastImportedId = importTransactions(subscription, downloadedTransactions);
|
||||||
|
subscription.setLastTransactionIdImported(lastImportedId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalSubscriptionRunParallel(StbRemoteSubscription subscription) throws Exception {
|
||||||
|
AtomicBoolean shouldStop = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
ConcurrentLinkedQueue<TransactionGroupDTO> queue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
|
||||||
|
while (!shouldStop.get()) {
|
||||||
|
try {
|
||||||
|
if (queue.size() > 1000) {
|
||||||
|
Thread.sleep(3 * 1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TransactionGroupDTO> downloadedTransactions = downloadTransactions(subscription);
|
||||||
|
|
||||||
|
|
||||||
|
if (downloadedTransactions == null || downloadedTransactions.isEmpty()) {
|
||||||
|
shouldStop.set(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.addAll(downloadedTransactions);
|
||||||
|
|
||||||
|
final Long maxId = downloadedTransactions.stream()
|
||||||
|
.flatMap(x -> x.getItems().stream())
|
||||||
|
.map(TransactionDTO::getTransactionId)
|
||||||
|
.max(Long::compare)
|
||||||
|
.get();
|
||||||
|
subscription.setLastTransactionIdImported(maxId);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
shouldStop.set(true);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
while (!shouldStop.get()) {
|
||||||
|
|
||||||
|
if (queue.isEmpty()) {
|
||||||
|
Thread.sleep(2 * 1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!queue.isEmpty()) {
|
||||||
|
try {
|
||||||
|
importTransactionGroup(subscription, queue.poll());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
shouldStop.set(true);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while (!shouldStop.get()) {
|
||||||
|
Thread.sleep(5 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<TransactionGroupDTO> downloadTransactions(StbRemoteSubscription subscription) throws Exception {
|
||||||
|
String endpoint = subscription.getEndpointUrl();
|
||||||
|
HashMap<String, String> queryParams = new HashMap<String, String>() {{
|
||||||
|
put("profileDb", subscription.getProfileDb());
|
||||||
|
put("lastRetrievedTransactionId", subscription.getLastTransactionIdImported() == null ? null : String.valueOf(subscription.getLastTransactionIdImported()));
|
||||||
|
put("limit", String.valueOf(500));
|
||||||
|
}};
|
||||||
|
|
||||||
|
String retrieveTransactionsUrl = endpoint + "/ems-api/system/remote-transaction/" + subscription.getPublicationId() + "/retrieve";
|
||||||
|
|
||||||
|
StringBuilder responseBody = new StringBuilder();
|
||||||
|
int status = HttpRestWrapper.callGenericGet(retrieveTransactionsUrl, subscription.getUsername(), subscription.getPassword(), responseBody, queryParams);
|
||||||
|
|
||||||
|
if (status != 200)
|
||||||
|
throw new Exception("Errore durante l'aggiornamento della subscription \"" + subscription.getPublicationDescription() + "\"," +
|
||||||
|
" l'endpoint " + endpoint + " ha generato lo status code " + status);
|
||||||
|
|
||||||
|
ServiceRestResponse response = jsonObjectMapper.readValue(responseBody.toString(), ServiceRestResponse.class);
|
||||||
|
|
||||||
|
if (response.getEsito() != EsitoType.OK)
|
||||||
|
throw new Exception("Errore durante l'aggiornamento della subscription \"" + subscription.getPublicationDescription() + "\"." +
|
||||||
|
" L'endpoint " + endpoint + " ha generato esito KO con il seguente messaggio: " + response.getErrorMessage());
|
||||||
|
|
||||||
|
|
||||||
|
return response.getDTO(new TypeReference<List<TransactionGroupDTO>>() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private long importTransactions(StbRemoteSubscription subscription, List<TransactionGroupDTO> transactions) throws Exception {
|
||||||
|
long idToReturn = -1;
|
||||||
|
|
||||||
|
for (TransactionGroupDTO transactionGroup : transactions) {
|
||||||
|
idToReturn = importTransactionGroup(subscription, transactionGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
return idToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long importTransactionGroup(StbRemoteSubscription subscription, TransactionGroupDTO transactionGroup) throws Exception {
|
||||||
|
StbRemoteSubscription cloneSubscriptionItem = (StbRemoteSubscription) subscription.deepClone();
|
||||||
|
List<EntityBase> entities = new ArrayList<>();
|
||||||
|
|
||||||
|
for (TransactionDTO transaction : transactionGroup.getItems()) {
|
||||||
|
final String entityJson = new String(Base64.getDecoder().decode(transaction.getTransactionJson()));
|
||||||
|
final EntityBase entityBase = jsonObjectMapper.readValue(entityJson, EntityBase.class);
|
||||||
|
entities.add(entityBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
cloneSubscriptionItem.setLastTransactionIdImported(
|
||||||
|
transactionGroup.getItems().stream()
|
||||||
|
.map(TransactionDTO::getTransactionId)
|
||||||
|
.max(Long::compare).get());
|
||||||
|
|
||||||
|
cloneSubscriptionItem.setOperation(OperationType.UPDATE);
|
||||||
|
entities.add(cloneSubscriptionItem);
|
||||||
|
|
||||||
|
entities = entityProcessor.processEntityList(entities,
|
||||||
|
null, false, true,
|
||||||
|
false, multiDBTransactionManager,
|
||||||
|
false, true);
|
||||||
|
|
||||||
|
UtilityEntity.throwEntitiesException(entities);
|
||||||
|
|
||||||
|
return cloneSubscriptionItem.getLastTransactionIdImported();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
package it.integry.ems.sync.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||||
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.service.EntityProcessor;
|
||||||
|
import it.integry.ems.service.HttpRestWrapper;
|
||||||
|
import it.integry.ems.sync.AsyncHistoryManager;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.sync.dto.ExportHistoryStatusDTO;
|
||||||
|
import it.integry.ems.sync.dto.PublicationDTO;
|
||||||
|
import it.integry.ems.sync.dto.PublicationGroupDTO;
|
||||||
|
import it.integry.ems.sync.dto.SubscriptionDTO;
|
||||||
|
import it.integry.ems.utility.UtilityEntity;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.entity.StbPublications;
|
||||||
|
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||||
|
import it.integry.ems_model.entity.StbRemoteSubscription;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Scope(value = "request")
|
||||||
|
public class RemoteSynchronizationSetupService {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityProcessor entityProcessor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsyncHistoryManager asyncHistoryManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
|
public List<PublicationGroupDTO> retrievePublications() throws Exception {
|
||||||
|
|
||||||
|
List<StbPublications> stbPublicationsToRetrieve = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
|
"SELECT * FROM " + StbPublications.ENTITY, StbPublications.class);
|
||||||
|
if (stbPublicationsToRetrieve == null) return null;
|
||||||
|
|
||||||
|
List<StbPublicationsDetail> stbPublicationsDetails =
|
||||||
|
UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
|
"SELECT * FROM " + StbPublicationsDetail.ENTITY, StbPublicationsDetail.class);
|
||||||
|
if (stbPublicationsDetails == null) stbPublicationsDetails = new ArrayList<>();
|
||||||
|
|
||||||
|
List<PublicationGroupDTO> publicationGroups = new ArrayList<>();
|
||||||
|
|
||||||
|
final List<ExportHistoryStatusDTO> currentExportStatus = asyncHistoryManager.getStatus();
|
||||||
|
|
||||||
|
for (StbPublications stbPublication : stbPublicationsToRetrieve) {
|
||||||
|
|
||||||
|
final PublicationGroupDTO publicationGroupDTO = new PublicationGroupDTO()
|
||||||
|
.setId(stbPublication.getId())
|
||||||
|
.setDescription(stbPublication.getPublicationDescription());
|
||||||
|
publicationGroups.add(publicationGroupDTO);
|
||||||
|
|
||||||
|
final List<PublicationDTO> publications = stbPublicationsDetails.stream()
|
||||||
|
.filter(x -> x.getStbPublicationId() == stbPublication.getId())
|
||||||
|
.map(PublicationDTO::fromStbPublicationDetail)
|
||||||
|
.collect(toList());
|
||||||
|
publicationGroupDTO.setPublications(publications);
|
||||||
|
|
||||||
|
boolean atLeastOneActiveToExport = publications.stream().anyMatch(publicationDTO -> publicationDTO.getExportHistory() && publicationDTO.getActive() && !publicationDTO.getReadyToTransmit());
|
||||||
|
boolean alreadyExporting = currentExportStatus.stream().anyMatch(x -> x.getPublicationGroupId() == publicationGroupDTO.getId());
|
||||||
|
|
||||||
|
publicationGroupDTO.setCanStartExport(atLeastOneActiveToExport && !alreadyExporting);
|
||||||
|
publicationGroupDTO.setCanBeDeleted(!alreadyExporting);
|
||||||
|
}
|
||||||
|
|
||||||
|
return publicationGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long addPublicationGroup(String description) throws Exception {
|
||||||
|
StbPublications stbPublications = new StbPublications()
|
||||||
|
.setPublicationDescription(description);
|
||||||
|
stbPublications.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
||||||
|
|
||||||
|
return stbPublications.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long addPublicationItem(long groupId, @NotNull PublicationDTO publicationToInsert) throws Exception {
|
||||||
|
if (checkIfPublicationExists(groupId, publicationToInsert))
|
||||||
|
throw new Exception("Esiste già una pubblicazione per " + publicationToInsert.getEntityName() + " con gli stessi parametri");
|
||||||
|
|
||||||
|
final StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||||
|
.setStbPublicationId(groupId)
|
||||||
|
.setEntityName(publicationToInsert.getEntityName().toUpperCase())
|
||||||
|
.setWhereCondSql(publicationToInsert.getWhereCondSql())
|
||||||
|
.setRecalcColumns(publicationToInsert.getRecalcColumns())
|
||||||
|
.setActive(publicationToInsert.getActive())
|
||||||
|
.setWhereCondField(publicationToInsert.getWhereCond())
|
||||||
|
.setExportHistory(publicationToInsert.getExportHistory())
|
||||||
|
.setReadyToTransmit(!(publicationToInsert.getExportHistory() != null && publicationToInsert.getExportHistory()));
|
||||||
|
stbPublicationsDetail.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
StbPublications stbPublications = new StbPublications()
|
||||||
|
.setId(groupId);
|
||||||
|
stbPublications.setOperation(OperationType.NO_OP);
|
||||||
|
stbPublications.getStbPublicationsDetails().add(stbPublicationsDetail);
|
||||||
|
|
||||||
|
entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
||||||
|
|
||||||
|
return stbPublications.getStbPublicationsDetails().get(0).getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPublications(long groupId, @NotNull List<PublicationDTO> publications) throws Exception {
|
||||||
|
final List<StbPublicationsDetail> stbPublicationsToInsert = publications.stream()
|
||||||
|
.map(x -> {
|
||||||
|
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||||
|
.setStbPublicationId(groupId)
|
||||||
|
.setEntityName(x.getEntityName())
|
||||||
|
.setWhereCondSql(x.getWhereCondSql())
|
||||||
|
.setRecalcColumns(x.getRecalcColumns())
|
||||||
|
.setActive(x.getActive())
|
||||||
|
.setWhereCondField(x.getWhereCond());
|
||||||
|
stbPublicationsDetail.setOperation(OperationType.INSERT);
|
||||||
|
return stbPublicationsDetail;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
StbPublications stbPublications = new StbPublications()
|
||||||
|
.setId(groupId)
|
||||||
|
.setStbPublicationsDetails(stbPublicationsToInsert);
|
||||||
|
stbPublications.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
|
final List<EntityBase> savedEntities = entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
||||||
|
|
||||||
|
UtilityEntity.throwEntitiesException(savedEntities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePublications(@NotNull List<Long> publicationsId) throws Exception {
|
||||||
|
List<StbPublicationsDetail> stbPubblicationsDetail = publicationsId.stream()
|
||||||
|
.map(x -> {
|
||||||
|
final StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||||
|
.setId(x);
|
||||||
|
stbPublicationsDetail.setOperation(OperationType.SELECT_OBJECT);
|
||||||
|
return stbPublicationsDetail;
|
||||||
|
})
|
||||||
|
.collect(toList());
|
||||||
|
final List<EntityBase> entityBases = entityProcessor.processEntityList(stbPubblicationsDetail, true);
|
||||||
|
|
||||||
|
stbPubblicationsDetail = UtilityEntity.toCustomEntity(entityBases);
|
||||||
|
|
||||||
|
final Map<Long, List<StbPublicationsDetail>> collect = stbPubblicationsDetail.stream()
|
||||||
|
.collect(groupingBy(StbPublicationsDetail::getStbPublicationId));
|
||||||
|
|
||||||
|
final List<StbPublications> stbPublications = new ArrayList<>();
|
||||||
|
collect.keySet().forEach(x -> {
|
||||||
|
List<StbPublicationsDetail> details = collect.get(x);
|
||||||
|
details.forEach(y -> y.setOperation(OperationType.DELETE));
|
||||||
|
|
||||||
|
StbPublications stbPublication = new StbPublications()
|
||||||
|
.setId(x)
|
||||||
|
.setStbPublicationsDetails(details);
|
||||||
|
stbPublication.setOperation(OperationType.NO_OP);
|
||||||
|
stbPublications.add(stbPublication);
|
||||||
|
});
|
||||||
|
|
||||||
|
final List<EntityBase> savedEntities = entityProcessor.processEntityList(stbPublications, multiDBTransactionManager, true);
|
||||||
|
UtilityEntity.throwEntitiesException(savedEntities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editPublication(long publicationId, PublicationDTO publicationDTO) throws Exception {
|
||||||
|
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||||
|
.setId(publicationId);
|
||||||
|
stbPublicationsDetail.setOperation(OperationType.SELECT_OBJECT);
|
||||||
|
|
||||||
|
stbPublicationsDetail = entityProcessor.processEntity(stbPublicationsDetail, multiDBTransactionManager);
|
||||||
|
|
||||||
|
if (publicationDTO.getExportHistory() != null && !stbPublicationsDetail.isReadyToTransmit())
|
||||||
|
stbPublicationsDetail.setExportHistory(publicationDTO.getExportHistory());
|
||||||
|
|
||||||
|
if (publicationDTO.getActive() != null)
|
||||||
|
stbPublicationsDetail.setActive(publicationDTO.getActive());
|
||||||
|
|
||||||
|
if (publicationDTO.getEntityName() != null)
|
||||||
|
stbPublicationsDetail.setEntityName(publicationDTO.getEntityName());
|
||||||
|
|
||||||
|
if (publicationDTO.getRecalcColumns() != null)
|
||||||
|
stbPublicationsDetail.setRecalcColumns(publicationDTO.getRecalcColumns());
|
||||||
|
|
||||||
|
if (publicationDTO.getWhereCond() != null)
|
||||||
|
stbPublicationsDetail.setWhereCondField(publicationDTO.getWhereCond());
|
||||||
|
|
||||||
|
if (publicationDTO.getWhereCondSql() != null)
|
||||||
|
stbPublicationsDetail.setWhereCondSql(publicationDTO.getWhereCondSql());
|
||||||
|
|
||||||
|
stbPublicationsDetail.setOperation(OperationType.UPDATE);
|
||||||
|
|
||||||
|
StbPublications stbPublication = new StbPublications()
|
||||||
|
.setId(stbPublicationsDetail.getStbPublicationId());
|
||||||
|
stbPublication.getStbPublicationsDetails().add(stbPublicationsDetail);
|
||||||
|
stbPublication.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
|
entityProcessor.processEntity(stbPublication, multiDBTransactionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePublicationsGroup(long publicationGroup) throws Exception {
|
||||||
|
StbPublications tmpStbPublications = new StbPublications()
|
||||||
|
.setId(publicationGroup);
|
||||||
|
tmpStbPublications.setOperation(OperationType.DELETE);
|
||||||
|
|
||||||
|
entityProcessor.processEntity(tmpStbPublications, multiDBTransactionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean checkIfPublicationExists(long groupId, PublicationDTO publication) throws SQLException, IOException, PrimaryDatabaseNotPresentException {
|
||||||
|
HashMap<String, Object> searchParams = new HashMap<>();
|
||||||
|
searchParams.put("entity_name", publication.getEntityName());
|
||||||
|
searchParams.put("where_cond_sql", publication.getWhereCondSql());
|
||||||
|
searchParams.put("recalc_columns", publication.getRecalcColumns());
|
||||||
|
searchParams.put("where_cond", publication.getWhereCond());
|
||||||
|
searchParams.put("stb_publication_id", groupId);
|
||||||
|
|
||||||
|
String sql = "SELECT CAST(COUNT(*) AS BIT) AS exist " +
|
||||||
|
"FROM " + StbPublicationsDetail.ENTITY + " " +
|
||||||
|
"WHERE " + UtilityQuery.concatFieldsInWhereCond(searchParams);
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long addSubscription(SubscriptionDTO subscriptionToInsert) throws Exception {
|
||||||
|
|
||||||
|
String endpointRetrieve = subscriptionToInsert.getEndpointUrl() + "/ems-api/system/remote-sync/setup/publications/retrieve";
|
||||||
|
HashMap<String, String> queryParams = new HashMap<String, String>() {{
|
||||||
|
put("profileDb", subscriptionToInsert.getProfileDb());
|
||||||
|
}};
|
||||||
|
|
||||||
|
StringBuilder responseString = new StringBuilder();
|
||||||
|
int retrieveStatus = HttpRestWrapper.callGenericGet(endpointRetrieve,
|
||||||
|
subscriptionToInsert.getUsername(), subscriptionToInsert.getPassword(), responseString, queryParams);
|
||||||
|
|
||||||
|
if (retrieveStatus != 200)
|
||||||
|
throw new Exception("Impossibile stabilire una connessione con l'endpoint " + subscriptionToInsert.getEndpointUrl() + ". [STATUS CODE: " + retrieveStatus + "]");
|
||||||
|
|
||||||
|
final ServiceRestResponse publicationResponse = jsonObjectMapper.readValue(responseString.toString(), ServiceRestResponse.class);
|
||||||
|
final List<PublicationGroupDTO> availablePublications = publicationResponse.getDTO(new TypeReference<List<PublicationGroupDTO>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
final PublicationGroupDTO publicationGroupDTO = availablePublications.stream().filter(x -> x.getId() == subscriptionToInsert.getPublicationId())
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (publicationGroupDTO == null)
|
||||||
|
throw new Exception("Non è stata trovata alcuna pubblicazione con ID " + subscriptionToInsert.getPublicationId() + " sull'endpoint " + subscriptionToInsert.getEndpointUrl());
|
||||||
|
|
||||||
|
subscriptionToInsert.setPublicationDescription(publicationGroupDTO.getDescription());
|
||||||
|
|
||||||
|
final StbRemoteSubscription stbRemoteSubscription = subscriptionToInsert.toEntity();
|
||||||
|
stbRemoteSubscription.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
entityProcessor.processEntity(stbRemoteSubscription, multiDBTransactionManager);
|
||||||
|
|
||||||
|
return stbRemoteSubscription.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package it.integry.ems.sync.service;
|
||||||
|
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.sync.dto.TransactionDTO;
|
||||||
|
import it.integry.ems.sync.dto.TransactionGroupDTO;
|
||||||
|
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||||
|
import it.integry.ems_model.entity.StbTransactionLog;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Scope("request")
|
||||||
|
public class RemoteSynchronizationTransactionsService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
|
||||||
|
public List<TransactionGroupDTO> retrieveTransactions(long publicationId, Long lastRetrievedTransactionId, int limit) throws Exception {
|
||||||
|
|
||||||
|
String sql = Query.format("SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE stb_publication_id = %s AND ready_to_transmit = 1", publicationId);
|
||||||
|
final StbPublicationsDetail stbPublicationsDetails = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbPublicationsDetail.class);
|
||||||
|
|
||||||
|
if (stbPublicationsDetails == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List<Long> availableGroupIds = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
|
"SELECT DISTINCT group_id\n" +
|
||||||
|
"FROM " + StbTransactionLog.ENTITY + "\n" +
|
||||||
|
"WHERE publication_group_id = " + UtilityDB.valueToString(publicationId) + "\n" +
|
||||||
|
(lastRetrievedTransactionId != null ? "AND id > " + UtilityDB.valueToString(lastRetrievedTransactionId) + "\n" : "") +
|
||||||
|
"ORDER BY group_id");
|
||||||
|
|
||||||
|
if (availableGroupIds == null || availableGroupIds.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
availableGroupIds = availableGroupIds.subList(0, Math.min(limit > 0 ? limit : 100, availableGroupIds.size()));
|
||||||
|
|
||||||
|
List<StbTransactionLog> transactions = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
|
"SELECT * FROM " + StbTransactionLog.ENTITY + "\n" +
|
||||||
|
"WHERE group_id IN (" + UtilityQuery.concatLongFieldsWithSeparator(availableGroupIds, ",") + ")\n" +
|
||||||
|
"AND publication_group_id = " + UtilityDB.valueToString(publicationId) + "\n" +
|
||||||
|
"ORDER BY id",
|
||||||
|
StbTransactionLog.class);
|
||||||
|
|
||||||
|
|
||||||
|
if (transactions == null || transactions.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
final Map<Long, List<StbTransactionLog>> collect = transactions.stream().collect(groupingBy(StbTransactionLog::getGroupId));
|
||||||
|
final List<TransactionGroupDTO> transactionGroups = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Long groupId : collect.keySet().stream().sorted().collect(Collectors.toList())) {
|
||||||
|
transactionGroups.add(new TransactionGroupDTO()
|
||||||
|
.setId(groupId)
|
||||||
|
.setItems(collect.get(groupId).stream()
|
||||||
|
.sorted(Comparator.comparingLong(StbTransactionLog::getId))
|
||||||
|
.map(x -> new TransactionDTO()
|
||||||
|
.setTransactionId(x.getId())
|
||||||
|
.setPublicationId(x.getPublicationGroupId())
|
||||||
|
.setTransactionDate(x.getCreatedAt())
|
||||||
|
.setEntityName(x.getEntities())
|
||||||
|
.setTransactionJson(Base64.getEncoder().encodeToString(x.getEntitiesJson().getBytes()))
|
||||||
|
.setUsername(x.getUserName()))
|
||||||
|
.collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return transactionGroups;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package it.integry.ems.sync.service;
|
|
||||||
|
|
||||||
import it.integry.ems.service.EntityProcessor;
|
|
||||||
import it.integry.ems.sync.AsyncHistoryManager;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
import it.integry.ems.sync.dto.ExportHistoryStatusDTO;
|
|
||||||
import it.integry.ems.sync.dto.PublicationDTO;
|
|
||||||
import it.integry.ems.utility.UtilityEntity;
|
|
||||||
import it.integry.ems_model.base.EntityBase;
|
|
||||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
|
||||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
|
||||||
import it.integry.ems_model.utility.Query;
|
|
||||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Scope(value = "request")
|
|
||||||
public class RemoteSyncronizationService {
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AsyncHistoryManager asyncHistoryManager;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityPropertyHolder entityPropertyHolder;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityProcessor entityProcessor;
|
|
||||||
|
|
||||||
public void startPublication(long groupId) throws Exception {
|
|
||||||
StbPublicationsDetail tmpStbPublicationsDetail = new StbPublicationsDetail();
|
|
||||||
String whereCond = Query.format("stb_publication_id = %s AND export_history = %s", groupId, 1);
|
|
||||||
|
|
||||||
final List<? extends EntityBase> select = tmpStbPublicationsDetail.select(multiDBTransactionManager.getPrimaryConnection(), whereCond);
|
|
||||||
final List<StbPublicationsDetail> stbPublicationsDetails = UtilityEntity.toCustomEntity(select);
|
|
||||||
|
|
||||||
for (StbPublicationsDetail stbPublicationsDetail : stbPublicationsDetails) {
|
|
||||||
asyncHistoryManager.addToExportQueue(multiDBTransactionManager.getPrimaryDatasource(),
|
|
||||||
groupId,
|
|
||||||
PublicationDTO.fromStbPublicationDetail(stbPublicationsDetail));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ExportHistoryStatusDTO> getPublicationStatus() {
|
|
||||||
int totalCount = new Random().nextInt(1000000);
|
|
||||||
int currentCount = new Random().nextInt(totalCount);
|
|
||||||
|
|
||||||
return Collections.singletonList(new ExportHistoryStatusDTO()
|
|
||||||
.setPublicationGroupId(1)
|
|
||||||
.setProcessedCount(currentCount)
|
|
||||||
.setTotalCount(totalCount)
|
|
||||||
.setStartedAt(UtilityLocalDate.getNowTime().minusMinutes(10))
|
|
||||||
.setEstimatedEnd(UtilityLocalDate.getNowTime().plusMinutes(15))
|
|
||||||
.setSpeedPerMinute(500));
|
|
||||||
|
|
||||||
// return asyncHistoryManager.getStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
package it.integry.ems.sync.service;
|
|
||||||
|
|
||||||
import it.integry.ems.service.EntityProcessor;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
import it.integry.ems.sync.dto.PublicationDTO;
|
|
||||||
import it.integry.ems.sync.dto.PublicationGroupDTO;
|
|
||||||
import it.integry.ems.utility.UtilityEntity;
|
|
||||||
import it.integry.ems_model.base.EntityBase;
|
|
||||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
|
||||||
import it.integry.ems_model.entity.StbPublications;
|
|
||||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
|
||||||
import it.integry.ems_model.types.OperationType;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.groupingBy;
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Scope(value = "request")
|
|
||||||
public class RemoteSyncronizationSetupService {
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityProcessor entityProcessor;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityPropertyHolder entityPropertyHolder;
|
|
||||||
|
|
||||||
public List<PublicationGroupDTO> retrievePublications() throws Exception {
|
|
||||||
|
|
||||||
StbPublications tmpStbPublications = new StbPublications();
|
|
||||||
tmpStbPublications.setOperation(OperationType.SELECT);
|
|
||||||
tmpStbPublications.setOnlyPkMaster(false);
|
|
||||||
|
|
||||||
List<EntityBase> selectedEntities = entityProcessor.processEntity(tmpStbPublications, multiDBTransactionManager);
|
|
||||||
if (selectedEntities == null) return null;
|
|
||||||
List<StbPublications> stbPublicationsToRetrieve = UtilityEntity.toCustomEntity(selectedEntities);
|
|
||||||
|
|
||||||
StbPublicationsDetail tmpStbPublicationsDetail = new StbPublicationsDetail();
|
|
||||||
tmpStbPublicationsDetail.setOperation(OperationType.SELECT);
|
|
||||||
tmpStbPublicationsDetail.setOnlyPkMaster(false);
|
|
||||||
List<EntityBase> selectedStbPublicationsDetail = entityProcessor.processEntity(tmpStbPublicationsDetail, multiDBTransactionManager);
|
|
||||||
if (selectedStbPublicationsDetail == null) selectedStbPublicationsDetail = new ArrayList<>();
|
|
||||||
|
|
||||||
List<StbPublicationsDetail> stbPublicationsDetails = UtilityEntity.toCustomEntity(selectedStbPublicationsDetail);
|
|
||||||
|
|
||||||
|
|
||||||
List<PublicationGroupDTO> publicationGroups = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
for (StbPublications stbPublication : stbPublicationsToRetrieve) {
|
|
||||||
|
|
||||||
final PublicationGroupDTO publicationGroupDTO = new PublicationGroupDTO()
|
|
||||||
.setId(stbPublication.getId())
|
|
||||||
.setDescription(stbPublication.getPublicationDescription());
|
|
||||||
publicationGroups.add(publicationGroupDTO);
|
|
||||||
|
|
||||||
final List<PublicationDTO> publications = stbPublicationsDetails.stream()
|
|
||||||
.filter(x -> x.getStbPublicationId() == stbPublication.getId())
|
|
||||||
.map(PublicationDTO::fromStbPublicationDetail)
|
|
||||||
.collect(toList());
|
|
||||||
publicationGroupDTO.setPublications(publications);
|
|
||||||
}
|
|
||||||
|
|
||||||
return publicationGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public long addPublicationGroup(String description) throws Exception {
|
|
||||||
StbPublications stbPublications = new StbPublications()
|
|
||||||
.setPublicationDescription(description);
|
|
||||||
stbPublications.setOperation(OperationType.INSERT);
|
|
||||||
|
|
||||||
entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
|
||||||
|
|
||||||
return stbPublications.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public long addPublicationItem(long groupId, @NotNull PublicationDTO publicationToInsert) throws Exception {
|
|
||||||
final StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
|
||||||
.setStbPublicationId(groupId)
|
|
||||||
.setEntityName(publicationToInsert.getEntityName())
|
|
||||||
.setWhereCondSql(publicationToInsert.getWhereCondSql())
|
|
||||||
.setRecalcColumns(publicationToInsert.getRecalcColumns())
|
|
||||||
.setActive(publicationToInsert.isActive())
|
|
||||||
.setWhereCondField(publicationToInsert.getWhereCond())
|
|
||||||
.setExportHistory(publicationToInsert.isExportHistory())
|
|
||||||
.setReadyToTransmit(!publicationToInsert.isExportHistory());
|
|
||||||
stbPublicationsDetail.setOperation(OperationType.INSERT);
|
|
||||||
|
|
||||||
StbPublications stbPublications = new StbPublications()
|
|
||||||
.setId(groupId);
|
|
||||||
stbPublications.setOperation(OperationType.NO_OP);
|
|
||||||
stbPublications.getStbPublicationsDetails().add(stbPublicationsDetail);
|
|
||||||
|
|
||||||
entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
|
||||||
|
|
||||||
return stbPublications.getStbPublicationsDetails().get(0).getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPublications(long groupId, @NotNull List<PublicationDTO> publications) throws Exception {
|
|
||||||
final List<StbPublicationsDetail> stbPublicationsToInsert = publications.stream()
|
|
||||||
.map(x -> {
|
|
||||||
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
|
||||||
.setStbPublicationId(groupId)
|
|
||||||
.setEntityName(x.getEntityName())
|
|
||||||
.setWhereCondSql(x.getWhereCondSql())
|
|
||||||
.setRecalcColumns(x.getRecalcColumns())
|
|
||||||
.setActive(x.isActive())
|
|
||||||
.setWhereCondField(x.getWhereCond());
|
|
||||||
stbPublicationsDetail.setOperation(OperationType.INSERT);
|
|
||||||
return stbPublicationsDetail;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
StbPublications stbPublications = new StbPublications()
|
|
||||||
.setId(groupId)
|
|
||||||
.setStbPublicationsDetails(stbPublicationsToInsert);
|
|
||||||
stbPublications.setOperation(OperationType.NO_OP);
|
|
||||||
|
|
||||||
final List<EntityBase> savedEntities = entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
|
||||||
|
|
||||||
UtilityEntity.throwEntitiesException(savedEntities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deletePublications(@NotNull List<Long> publicationsId) throws Exception {
|
|
||||||
final Map<Long, List<StbPublicationsDetail>> stbPubblicationsDetail = publicationsId.stream()
|
|
||||||
.map(x -> {
|
|
||||||
final StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
|
||||||
.setId(x);
|
|
||||||
stbPublicationsDetail.setOperation(OperationType.DELETE);
|
|
||||||
return stbPublicationsDetail;
|
|
||||||
})
|
|
||||||
.collect(groupingBy(StbPublicationsDetail::getStbPublicationId));
|
|
||||||
|
|
||||||
final AtomicReference<List<StbPublications>> stbPublications = new AtomicReference<>(new ArrayList<>());
|
|
||||||
|
|
||||||
stbPubblicationsDetail.forEach((k, v) -> {
|
|
||||||
StbPublications stbPublication = new StbPublications()
|
|
||||||
.setId(k)
|
|
||||||
.setStbPublicationsDetails(v);
|
|
||||||
stbPublication.setOperation(OperationType.NO_OP);
|
|
||||||
stbPublications.get().add(stbPublication);
|
|
||||||
});
|
|
||||||
|
|
||||||
final List<EntityBase> savedEntities = entityProcessor.processEntityList(stbPublications.get(), multiDBTransactionManager, true);
|
|
||||||
UtilityEntity.throwEntitiesException(savedEntities);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,6 +36,7 @@ public class GlobalExceptionHandler {
|
|||||||
@ExceptionHandler({Exception.class})
|
@ExceptionHandler({Exception.class})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ServiceRestResponse handleException(HttpServletRequest request, HttpServletResponse response, Exception ex) {
|
ServiceRestResponse handleException(HttpServletRequest request, HttpServletResponse response, Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
logger.error(request.getRequestURI(), ex);
|
logger.error(request.getRequestURI(), ex);
|
||||||
return ServiceRestResponse.createNegativeResponse(ex);
|
return ServiceRestResponse.createNegativeResponse(ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
@@ -77,19 +76,14 @@ public class SystemRequisiteCheckInterceptor extends HandlerInterceptorAdapter {
|
|||||||
if (foundName != null) {
|
if (foundName != null) {
|
||||||
|
|
||||||
if (emsDBConst.getConsts(foundName).getApplicationDbName() == null) {
|
if (emsDBConst.getConsts(foundName).getApplicationDbName() == null) {
|
||||||
response.sendError(551, "Application Name not initialized");
|
throw new SystemNotInitializedException(553, "Application Name not initialized");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (emsDBConst.getConsts(foundName).getNomeAzienda() == null) {
|
if (emsDBConst.getConsts(foundName).getNomeAzienda() == null) {
|
||||||
response.sendError(551, "Nome azienda not initialized");
|
throw new SystemNotInitializedException(554, "Nome azienda not initialized");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} catch (SystemNotInitializedException snie) {
|
} catch (SystemNotInitializedException snie) {
|
||||||
throw snie;
|
throw snie;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
|
|||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonTypeResolver;
|
import com.fasterxml.jackson.databind.annotation.JsonTypeResolver;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.common.var.EmsDBConst;
|
import it.integry.common.var.EmsDBConst;
|
||||||
import it.integry.ems.object_storage.minio.MinIOService;
|
import it.integry.ems.object_storage.minio.MinIOService;
|
||||||
@@ -58,6 +60,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@JsonFilter("jsonEntityFilter")
|
@JsonFilter("jsonEntityFilter")
|
||||||
//@JsonDeserialize(using = CustomPropertyTypeDeserializerNew.class)
|
//@JsonDeserialize(using = CustomPropertyTypeDeserializerNew.class)
|
||||||
@@ -112,7 +115,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
|
|
||||||
//ID del gruppo di transazioni per le Sync OFFLINE
|
//ID del gruppo di transazioni per le Sync OFFLINE
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Integer transactionGroupId = null;
|
private Long transactionGroupId = null;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private int queryTimeoutSeconds = 60 * 30;
|
private int queryTimeoutSeconds = 60 * 30;
|
||||||
@@ -130,19 +133,20 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
this.type = null;
|
this.type = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Field> fields = getEntityHolder().getFields(this.getClass());
|
List<Field> entityChildFields = getEntityHolder().getEntityChildFields(this.getClass());
|
||||||
for (Field field : fields) {
|
|
||||||
if (field.getAnnotation(EntityChild.class) != null) {
|
if (entityChildFields == null) return;
|
||||||
field.setAccessible(true);
|
|
||||||
try {
|
for (Field field : entityChildFields) {
|
||||||
Object object = field.get(this);
|
field.setAccessible(true);
|
||||||
if (object == null && field.getType().isAssignableFrom(List.class)) {
|
try {
|
||||||
object = new ArrayList();
|
Object object = field.get(this);
|
||||||
field.set(this, object);
|
if (object == null && field.getType().isAssignableFrom(List.class)) {
|
||||||
}
|
object = new ArrayList();
|
||||||
} catch (IllegalAccessException ex) {
|
field.set(this, object);
|
||||||
logger.error(ex);
|
|
||||||
}
|
}
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
logger.error(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -925,8 +929,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
long publicationId = AsyncManager.getPublicationIdIfExists(dbName, this);
|
long publicationId = AsyncManager.getPublicationIdIfExists(dbName, this);
|
||||||
|
|
||||||
if (publicationId > 0) {
|
if (publicationId > 0) {
|
||||||
if (transactionGroupId == null) transactionGroupId = AsyncManager.getNextTransactionGroupId(connection);
|
transactionGroupId = AsyncManager.saveNewTransaction(connection, dbName, this, publicationId, transactionGroupId);
|
||||||
AsyncManager.saveNewTransaction(connection, this, transactionGroupId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1340,47 +1343,100 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
|
|
||||||
List<Field> fields = getEntityHolder().getFields(this.getClass());
|
List<Field> fields = getEntityHolder().getFields(this.getClass());
|
||||||
|
|
||||||
|
|
||||||
List<String> campi = new ArrayList<>();
|
List<String> campi = new ArrayList<>();
|
||||||
List<String> valori = new ArrayList<>();
|
List<String> valori = new ArrayList<>();
|
||||||
|
List<Object> originalValues = new ArrayList<>();
|
||||||
|
|
||||||
Map<Integer, Object> mapLob = getFieldToQuery(fields, campi, valori);
|
Map<Integer, Object> mapLob = getFieldToQuery(fields, campi, valori, originalValues);
|
||||||
|
|
||||||
if (!campi.isEmpty()) {
|
if (!campi.isEmpty()) {
|
||||||
String sql = "INSERT INTO " + getTableName() + "(" + StringUtils.join(campi, ",") + ") " + "VALUES (" + StringUtils.join(valori, ",") + ")";
|
|
||||||
|
|
||||||
boolean containsIdentity;
|
|
||||||
|
boolean containsIdentity = mapLob.containsKey(-1);
|
||||||
String identityFieldName = null;
|
String identityFieldName = null;
|
||||||
if (containsIdentity = mapLob.containsKey(-1)) {
|
|
||||||
|
if (containsIdentity) {
|
||||||
identityFieldName = (String) mapLob.get(-1);
|
identityFieldName = (String) mapLob.get(-1);
|
||||||
mapLob.remove(-1);
|
mapLob.remove(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isTraceEnabled()) {
|
long insertedIdentity = -1;
|
||||||
logger.trace("QUERY: " + sql);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
PreparedStatement pstm = connection.prepareStatement(sql, containsIdentity ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS);
|
|
||||||
setupBinaryParams(mapLob, pstm);
|
|
||||||
|
|
||||||
int insertedRowCount = pstm.executeUpdate();
|
if (connection instanceof SQLServerConnection) {
|
||||||
pstm.setQueryTimeout(queryTimeoutSeconds);
|
SQLServerConnection sqlServerConnection = (SQLServerConnection) connection;
|
||||||
|
|
||||||
if (insertedRowCount > 0 && containsIdentity) {
|
StringBuilder insertSQL = new StringBuilder("INSERT INTO ")
|
||||||
ResultSet rs = pstm.getGeneratedKeys();
|
.append(getTableName())
|
||||||
if (rs.next()) {
|
.append(" (")
|
||||||
Long identity = rs.getLong(1);
|
.append(StringUtils.join(campi, ","))
|
||||||
|
.append(") VALUES (");
|
||||||
|
|
||||||
// Field identityField = getClass().getDeclaredField(SqlFieldHolder.getSqlValue(identityFieldName,));
|
for (int i = 0; i < campi.size(); i++) {
|
||||||
Field identityField = getEntityHolder().getFieldBySql(getClass().getSimpleName(), identityFieldName);
|
insertSQL.append(" ?");
|
||||||
identityField.setAccessible(true);
|
|
||||||
identityField.set(this, identity);
|
if (i < campi.size() - 1)
|
||||||
}
|
insertSQL.append(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
pstm.close();
|
insertSQL.append(")");
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new EntityException(e, this, sql);
|
try (SQLServerPreparedStatement insertBulkPs =
|
||||||
|
(SQLServerPreparedStatement) sqlServerConnection.prepareStatement(
|
||||||
|
insertSQL.toString(),
|
||||||
|
containsIdentity ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS)) {
|
||||||
|
|
||||||
|
for (int i = 1; i <= originalValues.size(); i++) {
|
||||||
|
insertBulkPs.setObject(i, SqlFieldHolder.getSqlValueFieldAsObject(originalValues.get(i - 1), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
long insertedRowCount = insertBulkPs.executeLargeUpdate();
|
||||||
|
if (insertedRowCount > 0 && containsIdentity) {
|
||||||
|
ResultSet rs = insertBulkPs.getGeneratedKeys();
|
||||||
|
if (rs.next()) {
|
||||||
|
insertedIdentity = rs.getLong(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String sql = "INSERT INTO " + getTableName() + "(" + StringUtils.join(campi, ",") + ") " + "VALUES (" + StringUtils.join(valori, ",") + ")";
|
||||||
|
|
||||||
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("QUERY: " + sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement pstm = connection.prepareStatement(sql, containsIdentity ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS);
|
||||||
|
setupBinaryParams(mapLob, pstm);
|
||||||
|
|
||||||
|
int insertedRowCount = pstm.executeUpdate();
|
||||||
|
pstm.setQueryTimeout(queryTimeoutSeconds);
|
||||||
|
|
||||||
|
if (insertedRowCount > 0 && containsIdentity) {
|
||||||
|
try (ResultSet rs = pstm.getGeneratedKeys()) {
|
||||||
|
if (rs.next())
|
||||||
|
insertedIdentity = rs.getLong(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pstm.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new EntityException(e, this, sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (containsIdentity) {
|
||||||
|
if(insertedIdentity < 0)
|
||||||
|
throw new Exception("Impossibile leggere il campo identity anche se è richiesto");
|
||||||
|
|
||||||
|
Field identityField = getEntityHolder().getFieldBySql(getClass().getSimpleName(), identityFieldName);
|
||||||
|
identityField.setAccessible(true);
|
||||||
|
identityField.set(this, insertedIdentity);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Nessun campo valorizzato per la entity " + getTableName() + " (Controllare metodi get/set della entity)");
|
throw new Exception("Nessun campo valorizzato per la entity " + getTableName() + " (Controllare metodi get/set della entity)");
|
||||||
}
|
}
|
||||||
@@ -1451,7 +1507,9 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setParentPKAndImportFromParent(EntityBase parent, Boolean isChild) throws InvocationTargetException, IllegalAccessException {
|
public void setParentPKAndImportFromParent(EntityBase parent, Boolean isChild) throws InvocationTargetException, IllegalAccessException {
|
||||||
List<Field> pkField = Stream.of(parent.getClass().getDeclaredFields()).filter(x -> x.isAnnotationPresent(PK.class) && x.isAnnotationPresent(SqlField.class)).toList();
|
List<Field> pkField = Arrays.stream(parent.getClass().getDeclaredFields())
|
||||||
|
.filter(x -> x.isAnnotationPresent(PK.class) && x.isAnnotationPresent(SqlField.class) && !x.isAnnotationPresent(Identity.class))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
for (Field field : pkField) {
|
for (Field field : pkField) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
@@ -1517,9 +1575,9 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
HashMap<String, Object> j = (HashMap<String, Object>) parent.getOldPk().clone();
|
HashMap<String, Object> j = (HashMap<String, Object>) parent.getOldPk().clone();
|
||||||
if (this.getOldPk() != null) {
|
if (this.getOldPk() != null) {
|
||||||
Set<Entry<String, Object>> map = this.getOldPk().entrySet();
|
Set<Entry<String, Object>> map = this.getOldPk().entrySet();
|
||||||
Iterator<Entry<String, Object>> iterator = map.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
for (Entry<String, Object> stringObjectEntry : map) {
|
||||||
String propName = iterator.next().getKey();
|
String propName = stringObjectEntry.getKey();
|
||||||
Object element = this.getOldPk().get(propName);
|
Object element = this.getOldPk().get(propName);
|
||||||
j.put(propName, element);
|
j.put(propName, element);
|
||||||
}
|
}
|
||||||
@@ -1641,7 +1699,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
|
|
||||||
Object obj = field.get(parent);
|
Object obj = field.get(parent);
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
Object dato = SqlFieldHolder.getSqlValueField(obj);
|
Object dato = SqlFieldHolder.getSqlValueFieldAsString(obj);
|
||||||
where.add(sqlColumn + " = " + dato);
|
where.add(sqlColumn + " = " + dato);
|
||||||
} else if (this.getOperation() != OperationType.DELETE) {
|
} else if (this.getOperation() != OperationType.DELETE) {
|
||||||
where.add(sqlColumn + " IS null ");
|
where.add(sqlColumn + " IS null ");
|
||||||
@@ -1730,9 +1788,9 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
String whereCondOldPk = null;
|
String whereCondOldPk = null;
|
||||||
if (this.getOldPk() != null) {
|
if (this.getOldPk() != null) {
|
||||||
Set<Entry<String, Object>> map = this.getOldPk().entrySet();
|
Set<Entry<String, Object>> map = this.getOldPk().entrySet();
|
||||||
Iterator<Entry<String, Object>> iterator = map.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
for (Entry<String, Object> stringObjectEntry : map) {
|
||||||
final String campo = iterator.next().getKey();
|
final String campo = stringObjectEntry.getKey();
|
||||||
Optional<Field> fieldOptional = Stream.of(fields).filter(field -> field.getName().equalsIgnoreCase(campo) && field.getAnnotation(SqlField.class) != null).findFirst();
|
Optional<Field> fieldOptional = Stream.of(fields).filter(field -> field.getName().equalsIgnoreCase(campo) && field.getAnnotation(SqlField.class) != null).findFirst();
|
||||||
|
|
||||||
if (fieldOptional.isEmpty()) {
|
if (fieldOptional.isEmpty()) {
|
||||||
@@ -1752,7 +1810,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
if ((fieldOptional.get().getType() == Date.class || fieldOptional.get().getType() == Timestamp.class) && valore instanceof String) {
|
if ((fieldOptional.get().getType() == Date.class || fieldOptional.get().getType() == Timestamp.class) && valore instanceof String) {
|
||||||
valore = UtilityString.parseDate(valore.toString());
|
valore = UtilityString.parseDate(valore.toString());
|
||||||
}
|
}
|
||||||
Object valueSql = SqlFieldHolder.getSqlValueField(valore);
|
Object valueSql = SqlFieldHolder.getSqlValueFieldAsString(valore);
|
||||||
where.add(sqlField + " = " + valueSql);
|
where.add(sqlField + " = " + valueSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1762,7 +1820,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
return whereCondOldPk;
|
return whereCondOldPk;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Integer, Object> getFieldToQuery(List<Field> fields, List<String> campi, List<String> valori) throws Exception {
|
private Map<Integer, Object> getFieldToQuery(List<Field> fields, List<String> campi, List<String> valori, List<Object> originalValues) throws Exception {
|
||||||
|
|
||||||
Map<Integer, Object> map = new HashMap<Integer, Object>();
|
Map<Integer, Object> map = new HashMap<Integer, Object>();
|
||||||
Integer counter = 1;
|
Integer counter = 1;
|
||||||
@@ -1789,7 +1847,8 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(refUuid)) {
|
if (!UtilityString.isNullOrEmpty(refUuid)) {
|
||||||
campi.add("ref_uuid" + (objectStorage.suffix() > 0 ? objectStorage.suffix() : ""));
|
campi.add("ref_uuid" + (objectStorage.suffix() > 0 ? objectStorage.suffix() : ""));
|
||||||
valori.add(SqlFieldHolder.getSqlValueField(refUuid).toString());
|
valori.add(SqlFieldHolder.getSqlValueFieldAsString(refUuid).toString());
|
||||||
|
originalValues.add(refUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SettingsModel.getInstance().getMinioConfiguration().isEnableOldSave()) continue;
|
if (!SettingsModel.getInstance().getMinioConfiguration().isEnableOldSave()) continue;
|
||||||
@@ -1831,17 +1890,20 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
if (field.getAnnotation(it.integry.ems_model.annotation.Clob.class) != null) {
|
if (field.getAnnotation(it.integry.ems_model.annotation.Clob.class) != null) {
|
||||||
setupClobData(counter, map, obj);
|
setupClobData(counter, map, obj);
|
||||||
valori.add("?");
|
valori.add("?");
|
||||||
|
originalValues.add(obj);
|
||||||
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
} else if (field.getAnnotation(it.integry.ems_model.annotation.Blob.class) != null) {
|
} else if (field.getAnnotation(it.integry.ems_model.annotation.Blob.class) != null) {
|
||||||
setupBlobData(counter, map, obj);
|
setupBlobData(counter, map, obj);
|
||||||
valori.add("?");
|
valori.add("?");
|
||||||
|
originalValues.add(obj);
|
||||||
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
} else {
|
} else {
|
||||||
String value = SqlFieldHolder.getSqlValueField(obj == null ? defaultVal : obj, sqlField.trimSpaces()).toString();
|
Object originalValue = obj == null ? defaultVal : obj;
|
||||||
|
String value = SqlFieldHolder.getSqlValueFieldAsString(originalValue, sqlField.trimSpaces());
|
||||||
|
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
value = value.replaceAll("\r", "' + CHAR(13) + '").replaceAll("\n", "' + CHAR(10) + '");
|
value = value.replaceAll("\r", "' + CHAR(13) + '").replaceAll("\n", "' + CHAR(10) + '");
|
||||||
@@ -1850,6 +1912,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
valori.add(value);
|
valori.add(value);
|
||||||
|
originalValues.add(originalValue);
|
||||||
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1881,7 +1944,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
else if (obj instanceof byte[]) refUuid = minIOService.uploadObject((byte[]) obj, connection);
|
else if (obj instanceof byte[]) refUuid = minIOService.uploadObject((byte[]) obj, connection);
|
||||||
|
|
||||||
|
|
||||||
campi.add("ref_uuid" + (objectStorage.suffix() > 0 ? objectStorage.suffix() : "") + " = " + SqlFieldHolder.getSqlValueField(refUuid));
|
campi.add("ref_uuid" + (objectStorage.suffix() > 0 ? objectStorage.suffix() : "") + " = " + SqlFieldHolder.getSqlValueFieldAsString(refUuid));
|
||||||
|
|
||||||
|
|
||||||
if (!SettingsModel.getInstance().getMinioConfiguration().isEnableOldSave()) continue;
|
if (!SettingsModel.getInstance().getMinioConfiguration().isEnableOldSave()) continue;
|
||||||
@@ -1892,7 +1955,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
if ((sqlField = field.getAnnotation(SqlField.class)) != null && !field.getName().startsWith("refUuid")) {
|
if ((sqlField = field.getAnnotation(SqlField.class)) != null && !field.getName().startsWith("refUuid")) {
|
||||||
PK pk = field.getAnnotation(PK.class);
|
PK pk = field.getAnnotation(PK.class);
|
||||||
SqlField sqlProp = field.getAnnotation(SqlField.class);
|
SqlField sqlProp = field.getAnnotation(SqlField.class);
|
||||||
Object dato = SqlFieldHolder.getSqlValueField(obj, sqlProp.trimSpaces());
|
Object dato = SqlFieldHolder.getSqlValueFieldAsString(obj, sqlProp.trimSpaces());
|
||||||
String sqlVal = SqlFieldHolder.getSqlValue(sqlField.value(), field);
|
String sqlVal = SqlFieldHolder.getSqlValue(sqlField.value(), field);
|
||||||
|
|
||||||
if (pk != null) {
|
if (pk != null) {
|
||||||
@@ -1984,11 +2047,11 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getTransactionGroupId() {
|
public Long getTransactionGroupId() {
|
||||||
return transactionGroupId;
|
return transactionGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransactionGroupId(Integer transactionGroupId) {
|
public void setTransactionGroupId(Long transactionGroupId) {
|
||||||
this.transactionGroupId = transactionGroupId;
|
this.transactionGroupId = transactionGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2001,8 +2064,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
|||||||
try {
|
try {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
idRiga = (Integer) field.get(entityBase);
|
idRiga = (Integer) field.get(entityBase);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return idRiga;
|
return idRiga;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ public interface EntityInterface {
|
|||||||
|
|
||||||
EntityException getException();
|
EntityException getException();
|
||||||
|
|
||||||
Integer getTransactionGroupId();
|
Long getTransactionGroupId();
|
||||||
|
|
||||||
void setTransactionGroupId(Integer transactionGroupId);
|
void setTransactionGroupId(Long transactionGroupId);
|
||||||
|
|
||||||
void resetTransactionGroupId();
|
void resetTransactionGroupId();
|
||||||
|
|
||||||
|
|||||||
@@ -80,15 +80,18 @@ public class EntityPropertyHolder {
|
|||||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||||
List<EntityHierarchyDTO> mapping = new ArrayList<>();
|
List<EntityHierarchyDTO> mapping = new ArrayList<>();
|
||||||
Set<Class<? extends EntityBase>> classes = reflections.getSubTypesOf(EntityBase.class);
|
Set<Class<? extends EntityBase>> classes = reflections.getSubTypesOf(EntityBase.class);
|
||||||
|
|
||||||
for (Class<? extends EntityBase> entity : classes) {
|
for (Class<? extends EntityBase> entity : classes) {
|
||||||
if (entity.isAnnotationPresent(Master.class)) {
|
if(!entity.isAnnotationPresent(Table.class)) continue;
|
||||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
|
||||||
dto.setClazz(entity);
|
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||||
dto.setEntityName(entity.getSimpleName());
|
dto.setClazz(entity);
|
||||||
dto.setTableName(entity.getAnnotation(Table.class).value());
|
dto.setEntityName(entity.getSimpleName());
|
||||||
dto.setChildren(getEntityChildren(entity));
|
dto.setTableName(entity.getAnnotation(Table.class).value());
|
||||||
mapping.add(dto);
|
dto.setChildren(getEntityChildren(entity));
|
||||||
}
|
dto.setMaster(entity.isAnnotationPresent(Master.class));
|
||||||
|
|
||||||
|
mapping.add(dto);
|
||||||
}
|
}
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
@@ -206,42 +209,16 @@ public class EntityPropertyHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Field getEntityChildField(Class<? extends EntityBase> parentClazz, Class<? extends EntityBase> childClass) {
|
|
||||||
final List<Field> entityChildField = getEntityChildField(parentClazz);
|
|
||||||
|
|
||||||
final Field foundField = entityChildField.stream()
|
public List<Field> getEntityChildFields(Class<? extends EntityBase> clazz) {
|
||||||
.filter(x -> {
|
return this.entityHierarchyMap.stream()
|
||||||
|
.filter(x -> x.getClazz().equals(clazz))
|
||||||
if(x.getType().isAssignableFrom(childClass)) return true;
|
.map(EntityHierarchyDTO::getChildren)
|
||||||
|
.flatMap(Collection::stream)
|
||||||
if(x.getType().isAssignableFrom(List.class)) {
|
.map(EntityHierarchyDTO::getField)
|
||||||
ParameterizedType type = (ParameterizedType)x.getGenericType();
|
.collect(Collectors.toList());
|
||||||
Class listItemType = type.getActualTypeArguments().length > 0 ? (Class<?>) type.getActualTypeArguments()[0] : null;
|
|
||||||
|
|
||||||
if(listItemType == null) return false;
|
|
||||||
return listItemType.isAssignableFrom(childClass);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
return foundField;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isEntityChild(Class<? extends EntityBase> clazz, String childName) {
|
|
||||||
Boolean isChild = false;
|
|
||||||
List<Field> children = getEntityChildField(clazz);
|
|
||||||
|
|
||||||
for (Field child : children) {
|
|
||||||
if (child.getName().equals(childName)) {
|
|
||||||
isChild = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<EntityBase> getEntityChain(List<? extends EntityBase> entityList, Connection conn, EntityBase testata) throws Exception {
|
public List<EntityBase> getEntityChain(List<? extends EntityBase> entityList, Connection conn, EntityBase testata) throws Exception {
|
||||||
List<EntityBase> chain = new ArrayList<EntityBase>();
|
List<EntityBase> chain = new ArrayList<EntityBase>();
|
||||||
@@ -375,7 +352,7 @@ public class EntityPropertyHolder {
|
|||||||
if (identity != null && (field.getType().isPrimitive() && ((long) obj) == 0)) {
|
if (identity != null && (field.getType().isPrimitive() && ((long) obj) == 0)) {
|
||||||
pkIdentityNull = true;
|
pkIdentityNull = true;
|
||||||
} else {
|
} else {
|
||||||
Object dato = SqlFieldHolder.getSqlValueField(obj);
|
Object dato = SqlFieldHolder.getSqlValueFieldAsString(obj);
|
||||||
where.add(SqlFieldHolder.getSqlValue(colName, field) + " = " + dato);
|
where.add(SqlFieldHolder.getSqlValue(colName, field) + " = " + dato);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,7 +373,7 @@ public class EntityPropertyHolder {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
whereUnique.add(SqlFieldHolder.getSqlValue(colName, field) + " IS NULL");
|
whereUnique.add(SqlFieldHolder.getSqlValue(colName, field) + " IS NULL");
|
||||||
} else {
|
} else {
|
||||||
Object dato = SqlFieldHolder.getSqlValueField(obj);
|
Object dato = SqlFieldHolder.getSqlValueFieldAsString(obj);
|
||||||
whereUnique.add(SqlFieldHolder.getSqlValue(colName, field) + " = " + dato);
|
whereUnique.add(SqlFieldHolder.getSqlValue(colName, field) + " = " + dato);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,7 +384,7 @@ public class EntityPropertyHolder {
|
|||||||
if (!UtilityString.isNullOrEmpty(whereUniqueStr))
|
if (!UtilityString.isNullOrEmpty(whereUniqueStr))
|
||||||
whereStr += "OR (" + whereUniqueStr + ")";
|
whereStr += "OR (" + whereUniqueStr + ")";
|
||||||
|
|
||||||
if(whereStr.equalsIgnoreCase("()"))
|
if (whereStr.equalsIgnoreCase("()"))
|
||||||
whereStr = "(1 = 1)";
|
whereStr = "(1 = 1)";
|
||||||
|
|
||||||
return whereStr;
|
return whereStr;
|
||||||
@@ -424,7 +401,7 @@ public class EntityPropertyHolder {
|
|||||||
SqlField sqlField;
|
SqlField sqlField;
|
||||||
if ((sqlField = field.getAnnotation(SqlField.class)) != null) {
|
if ((sqlField = field.getAnnotation(SqlField.class)) != null) {
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
Object dato = SqlFieldHolder.getSqlValueField(obj);
|
Object dato = SqlFieldHolder.getSqlValueFieldAsString(obj);
|
||||||
where.add(SqlFieldHolder.getSqlValue(sqlField.value(), field) + " = " + dato);
|
where.add(SqlFieldHolder.getSqlValue(sqlField.value(), field) + " = " + dato);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -527,15 +504,16 @@ public class EntityPropertyHolder {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (childEntity.equals(entity)) {
|
|
||||||
//ignoro le entity autoreferenziate
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||||
dto.setClazz(childEntity);
|
dto.setClazz(childEntity);
|
||||||
dto.setEntityName(childEntity.getSimpleName());
|
dto.setEntityName(childEntity.getSimpleName());
|
||||||
dto.setTableName(childEntity.getAnnotation(Table.class).value());
|
dto.setTableName(childEntity.getAnnotation(Table.class).value());
|
||||||
dto.setChildren(getEntityChildren(childEntity));
|
|
||||||
|
if (!childEntity.equals(entity))
|
||||||
|
//Prendo i fields solo delle entity non autoreferenziate
|
||||||
|
dto.setChildren(getEntityChildren(childEntity));
|
||||||
|
|
||||||
|
dto.setField(field);
|
||||||
children.add(dto);
|
children.add(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -789,7 +789,7 @@ public class ProductionBusinessLogic {
|
|||||||
for (int a = 0; a < elencoFasiAss.length; a++) {
|
for (int a = 0; a < elencoFasiAss.length; a++) {
|
||||||
datiDist.setIdRigaStep(datiDist.getIdRigaStep() + 1);
|
datiDist.setIdRigaStep(datiDist.getIdRigaStep() + 1);
|
||||||
|
|
||||||
if (pesoInQtaLav){
|
if (pesoInQtaLav) {
|
||||||
qtaLav = qtaProd.divide(rapConv, EmsRestConstants.cifreDecMax, RoundingMode.HALF_UP);
|
qtaLav = qtaProd.divide(rapConv, EmsRestConstants.cifreDecMax, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1198,8 +1198,8 @@ public class ProductionBusinessLogic {
|
|||||||
userName = userNameLav;
|
userName = userNameLav;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifica se l'articolo prevede l'obbligo del codice di commessa, in tal caso si blocca la procedura
|
// Verifica se l'articolo prevede l'obbligo del codice di commessa, in tal caso si blocca la procedura.
|
||||||
// il campo COD_JCOM_REQUIRED può contenere o S/N se qualciasi produzione deve avere la specifica della commessa,
|
// Il campo COD_JCOM_REQUIRED può contenere o S/N se qualsiasi produzione deve avere la specifica della commessa,
|
||||||
// oppure la specifica di una etichetta (Disegni) sui quali prodotti è necessario specificare la commessa
|
// oppure la specifica di una etichetta (Disegni) sui quali prodotti è necessario specificare la commessa
|
||||||
String codJcomRequired = UtilityString.isNull(setupOrdProdGest.get("COD_JCOM_REQUIRED"), "");
|
String codJcomRequired = UtilityString.isNull(setupOrdProdGest.get("COD_JCOM_REQUIRED"), "");
|
||||||
|
|
||||||
@@ -1223,6 +1223,7 @@ public class ProductionBusinessLogic {
|
|||||||
|
|
||||||
count = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
count = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != 0 && (codJcom == null || codJcom.equals(EmsRestConstants.NULL))) {
|
if (count != 0 && (codJcom == null || codJcom.equals(EmsRestConstants.NULL))) {
|
||||||
throw new Exception("Il prodotto " + codProd + " prevede il codice commessa obbligatoriamente, impossibile procedere alla generazione dell'ordine di produzione");
|
throw new Exception("Il prodotto " + codProd + " prevede il codice commessa obbligatoriamente, impossibile procedere alla generazione dell'ordine di produzione");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,10 +150,6 @@ public class EmsRestConstants {
|
|||||||
public static final String PATH_EXPORT_PRODOTTI_CQ = PATH + "exportProdottiCQ";
|
public static final String PATH_EXPORT_PRODOTTI_CQ = PATH + "exportProdottiCQ";
|
||||||
public static final String PATH_IMPORT_ORDINI_CQ = PATH + "importOrdiniCQ";
|
public static final String PATH_IMPORT_ORDINI_CQ = PATH + "importOrdiniCQ";
|
||||||
public static final String PATH_SELECT_RAW_DATA = PATH + "selectRawData";
|
public static final String PATH_SELECT_RAW_DATA = PATH + "selectRawData";
|
||||||
public static final String PATH_ASYNC_BASE_ROUTE = PATH + "async_v2";
|
|
||||||
public static final String PATH_ASYNC_START = PATH + "start";
|
|
||||||
public static final String PATH_ASYNC_RETRIEVE_TRANSACTIONS = PATH + "retrieveTransactions";
|
|
||||||
public static final String PATH_ASYNC_UPDATE_TRANSACTION_IMPORT_ID = PATH + "updateTransactionImportID";
|
|
||||||
public static final String PATH_ACCETTAZIONE = PATH + "accettazione";
|
public static final String PATH_ACCETTAZIONE = PATH + "accettazione";
|
||||||
public static final String PATH_PICKING = PATH + "picking";
|
public static final String PATH_PICKING = PATH + "picking";
|
||||||
public static final String PATH_PICKING_ORDINE = PATH + "pickingOrdine";
|
public static final String PATH_PICKING_ORDINE = PATH + "pickingOrdine";
|
||||||
@@ -295,6 +291,7 @@ public class EmsRestConstants {
|
|||||||
public static final String PATH_DELETE_ACTIVITY = PATH + "activity/delete";
|
public static final String PATH_DELETE_ACTIVITY = PATH + "activity/delete";
|
||||||
public static final String PATH_GET_COMMESSA_FROM_USERNAME = PATH + "activity/getCommessaFromUsername";
|
public static final String PATH_GET_COMMESSA_FROM_USERNAME = PATH + "activity/getCommessaFromUsername";
|
||||||
public static final String PATH_GET_ACTIVITY_HISTORY = PATH + "activity/getActivityHistory";
|
public static final String PATH_GET_ACTIVITY_HISTORY = PATH + "activity/getActivityHistory";
|
||||||
|
public static final String PATH_SET_ACTIVITY_SOLVED = PATH + "activity/activitySolved";
|
||||||
//SteUP
|
//SteUP
|
||||||
public static final String PATH_LOGIN_STEUP = PATH + "login";
|
public static final String PATH_LOGIN_STEUP = PATH + "login";
|
||||||
public static final String PATH_LOGINAZIENDA_STEUP = PATH + "loginAzienda";
|
public static final String PATH_LOGINAZIENDA_STEUP = PATH + "loginAzienda";
|
||||||
|
|||||||
@@ -0,0 +1,282 @@
|
|||||||
|
package it.integry.ems_model.db;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerResultSet;
|
||||||
|
import it.integry.ems.expansion.RunnableArgs;
|
||||||
|
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.ImportExport.Interfaces.IExportFormat;
|
||||||
|
import it.integry.ems_model.ImportExport.Interfaces.IImportFormat;
|
||||||
|
import it.integry.ems_model.annotation.Clob;
|
||||||
|
import it.integry.ems_model.annotation.MapToTable;
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
|
import it.integry.ems_model.resolver.SqlFieldHolder;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.ResultSetMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class AsyncResultSetMapper {
|
||||||
|
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static List<HashMap<String, Object>> mapResultSetToHashMap(ResultSet rs) throws SQLException {
|
||||||
|
ResultSetMetaData md = rs.getMetaData();
|
||||||
|
int columns = md.getColumnCount();
|
||||||
|
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
|
||||||
|
while (rs.next()) {
|
||||||
|
HashMap<String, Object> row = new HashMap<String, Object>(columns);
|
||||||
|
for (int i = 1; i <= columns; ++i) {
|
||||||
|
row.put(md.getColumnName(i), rs.getObject(i));
|
||||||
|
}
|
||||||
|
list.add(row);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map.Entry<String[], List<Object[]>> mapResultSetToArray(ResultSet rs) throws SQLException {
|
||||||
|
ResultSetMetaData md = rs.getMetaData();
|
||||||
|
int columns = md.getColumnCount();
|
||||||
|
|
||||||
|
String[] columnNames = new String[columns];
|
||||||
|
for (int i = 1; i <= columns; ++i) {
|
||||||
|
columnNames[i - 1] = md.getColumnName(i).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Object[]> rowsValues = new ArrayList<>();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
Object[] singleRowValues = new Object[columns];
|
||||||
|
|
||||||
|
for (int i = 1; i <= columns; ++i) {
|
||||||
|
singleRowValues[i - 1] = rs.getObject(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
rowsValues.add(singleRowValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
return new AbstractMap.SimpleEntry<>(columnNames, rowsValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void mapResultSetToList(SQLServerResultSet rs, Class<T> outputClass, RunnableArgs<T> onElementRetrieved) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
mapResultSetToList(rs, outputClass, null, true, onElementRetrieved);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void mapResultSetToList(SQLServerResultSet rs, Class<T> outputClass, OperationType operation, RunnableArgs<T> onElementRetrieved)
|
||||||
|
throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
mapResultSetToList(rs, outputClass, operation, true, onElementRetrieved);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void mapResultSetToList(SQLServerResultSet rs, Class<T> outputClass, OperationType operation, Boolean onlyPKMaster, RunnableArgs<T> onElementRetrieved) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
if (rs != null) {
|
||||||
|
|
||||||
|
Field[] fields;
|
||||||
|
if (IExportFormat.class.isAssignableFrom(outputClass) || IImportFormat.class.isAssignableFrom(outputClass)) {
|
||||||
|
fields = outputClass.getSuperclass().getDeclaredFields();
|
||||||
|
} else {
|
||||||
|
fields = outputClass.getDeclaredFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
internalMappingList(rs, outputClass, fields, onElementRetrieved);
|
||||||
|
|
||||||
|
// if (outputList != null && !outputList.isEmpty() && EntityBase.class.isAssignableFrom(outputClass)) {
|
||||||
|
// for (T bean : outputList) {
|
||||||
|
// if (operation != null) {
|
||||||
|
// ((EntityBase) bean).setOperation(operation);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (onlyPKMaster != null) {
|
||||||
|
// ((EntityBase) bean).setOnlyPkMaster(onlyPKMaster);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// return outputList != null && !outputList.isEmpty() ? outputList : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> void internalMappingList(SQLServerResultSet resultSet, Class<T> outputClass, Field[] fields, RunnableArgs<T> onElementRetrieved) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
final HashMap<Integer, RunnableArgsWithReturn<Object, Object>> columnToConverterMap = new HashMap<>();
|
||||||
|
final HashMap<Integer, Field> columnToFieldMap = new HashMap<>();
|
||||||
|
|
||||||
|
final ResultSetMetaData metaData = resultSet.getMetaData();
|
||||||
|
|
||||||
|
for (int i = 0; i < metaData.getColumnCount(); i++) {
|
||||||
|
String columnName = metaData.getColumnName(i + 1).toLowerCase();
|
||||||
|
|
||||||
|
final Field field = Arrays.stream(fields)
|
||||||
|
.filter(x -> x.isAnnotationPresent(SqlField.class) && x.getAnnotation(SqlField.class).value().equalsIgnoreCase(columnName))
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
|
||||||
|
if (field == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
final int columnType = metaData.getColumnType(i + 1);
|
||||||
|
final RunnableArgsWithReturn<Object, Object> converter = SqlFieldHolder.getConverter(UtilityDB.sqlTypeToJavaClass(columnType), field.getType());
|
||||||
|
|
||||||
|
columnToConverterMap.put(i + 1, converter);
|
||||||
|
columnToFieldMap.put(i + 1, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
final T outputObject = outputClass.newInstance();
|
||||||
|
|
||||||
|
for (Integer columnIndex : columnToConverterMap.keySet()) {
|
||||||
|
Object obj = resultSet.getObject(columnIndex);
|
||||||
|
Object convertedObject = columnToConverterMap.get(columnIndex).run(obj);
|
||||||
|
columnToFieldMap.get(columnIndex).set(outputObject, convertedObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
onElementRetrieved.run(outputObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// final Map.Entry<String[], List<Object[]>> listPair = mapResultSetToArray(resultSet);
|
||||||
|
//
|
||||||
|
// List<String> columnNames = Arrays.asList(listPair.getKey());
|
||||||
|
// List<Object[]> columnValuesList = listPair.getValue();
|
||||||
|
//
|
||||||
|
// if (columnValuesList == null || columnValuesList.isEmpty())
|
||||||
|
// return null;
|
||||||
|
//
|
||||||
|
// List<Field> fieldsWithAnnotations = Stream.of(fields)
|
||||||
|
// .filter(x -> x.isAnnotationPresent(SqlField.class) || x.isAnnotationPresent(JsonProperty.class) || x.isAnnotationPresent(MapToTable.class))
|
||||||
|
// .toList();
|
||||||
|
//
|
||||||
|
// if (fieldsWithAnnotations.isEmpty()) {
|
||||||
|
// System.out.println("Attenzione nella classe non sono presenti elementi con le seguenti annotazioni @SqlField, @JsonProperty, @MapToTable. Nessun campo sarà mappato nella classe");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// final List<ResultSetMappingField> resultSetMappingFields = scanResultSetFields(fields, columnNames, columnTypesFromResultSet);
|
||||||
|
// final HashMap<Field, List<ResultSetMappingField>> entityChildsResultSetMappingField = new HashMap<>();
|
||||||
|
//
|
||||||
|
// //Searching entities
|
||||||
|
// List<Field> entityFields = fieldsWithAnnotations.stream()
|
||||||
|
// .filter(x -> EntityBase.class.isAssignableFrom(x.getType()))
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
//
|
||||||
|
// for (Field entityField : entityFields) {
|
||||||
|
// Field[] entityChildFields = entityField.getType().getDeclaredFields();
|
||||||
|
// entityChildsResultSetMappingField.put(entityField, scanResultSetFields(entityChildFields, columnNames, columnTypesFromResultSet));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < listPair.getValue().size(); i++) {
|
||||||
|
// T bean = outputClass.newInstance();
|
||||||
|
// Object[] columnValues = columnValuesList.get(i);
|
||||||
|
//
|
||||||
|
// for (ResultSetMappingField resultSetMappingField : resultSetMappingFields) {
|
||||||
|
// Object columnValue = columnValues[resultSetMappingField.getColumnIndex()];
|
||||||
|
//
|
||||||
|
// if (resultSetMappingField.getConverter() != null && columnValue != null) {
|
||||||
|
// columnValue = resultSetMappingField.getConverter().run(columnValue);
|
||||||
|
// resultSetMappingField.getField().set(bean, columnValue);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (Field entityChildResultSetMappingField : entityChildsResultSetMappingField.keySet()) {
|
||||||
|
// EntityBase entityChildBean = (EntityBase) entityChildResultSetMappingField.getType().newInstance();
|
||||||
|
// entityChildBean.setOperation(OperationType.SELECT_OBJECT);
|
||||||
|
// entityChildResultSetMappingField.set(bean, entityChildBean);
|
||||||
|
//
|
||||||
|
// List<ResultSetMappingField> entityChildResultSetMappingFieldList = entityChildsResultSetMappingField.get(entityChildResultSetMappingField);
|
||||||
|
//
|
||||||
|
// for (ResultSetMappingField entityChildResultSetMapping : entityChildResultSetMappingFieldList) {
|
||||||
|
// Object columnValue = columnValues[entityChildResultSetMapping.getColumnIndex()];
|
||||||
|
//
|
||||||
|
// if (entityChildResultSetMapping.getConverter() != null && columnValue != null) {
|
||||||
|
// columnValue = entityChildResultSetMapping.getConverter().run(columnValue);
|
||||||
|
// entityChildResultSetMapping.getField().set(entityChildBean, columnValue);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// values.add(bean);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<ResultSetMappingField> scanResultSetFields(Field[] fields, List<String> columnNames, HashMap<String, Type> sqlTypes) throws DataConverterNotFoundException {
|
||||||
|
final List<ResultSetMappingField> resultSetMappingFields = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Field field : fields) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
if (!field.isAnnotationPresent(SqlField.class) && !field.isAnnotationPresent(JsonProperty.class) && !field.isAnnotationPresent(MapToTable.class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String columnName;
|
||||||
|
if (field.isAnnotationPresent(SqlField.class)) {
|
||||||
|
SqlField column = field.getAnnotation(SqlField.class);
|
||||||
|
columnName = !UtilityString.isNullOrEmpty(column.value()) ? column.value() : field.getName();
|
||||||
|
|
||||||
|
} else if (field.isAnnotationPresent(MapToTable.class)) {
|
||||||
|
columnName = field.getAnnotation(MapToTable.class).value();
|
||||||
|
|
||||||
|
} else if (field.isAnnotationPresent(JsonProperty.class)) {
|
||||||
|
columnName = field.getAnnotation(JsonProperty.class).value();
|
||||||
|
} else continue;
|
||||||
|
|
||||||
|
if (EntityBase.class.isAssignableFrom(field.getType()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
columnName = columnName.toLowerCase();
|
||||||
|
|
||||||
|
Type sqlType = sqlTypes.get(columnName);
|
||||||
|
Type entityType = field.getGenericType();
|
||||||
|
|
||||||
|
if (sqlType == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
RunnableArgsWithReturn<Object, Object> converter;
|
||||||
|
if (field.isAnnotationPresent(Clob.class)) {
|
||||||
|
converter = data -> Base64.encodeBase64String(data.toString().getBytes());
|
||||||
|
} else
|
||||||
|
converter = SqlFieldHolder.getConverter(sqlType, entityType);
|
||||||
|
|
||||||
|
if (converter == null) {
|
||||||
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||||
|
throw new DataConverterNotFoundException(columnName, sqlType.getTypeName(), entityType.getTypeName());
|
||||||
|
|
||||||
|
logger.warn(String.format("Converter non trovato per colonna %s, sqlType %s -> dtoType %s", columnName, sqlType.getTypeName(), entityType.getTypeName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
resultSetMappingFields.add(new ResultSetMappingField()
|
||||||
|
.setField(field)
|
||||||
|
.setColumnName(columnName)
|
||||||
|
.setFieldName(field.getName())
|
||||||
|
.setConverter(converter)
|
||||||
|
.setColumnIndex(columnNames.indexOf(columnName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultSetMappingFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,14 +7,16 @@ import it.integry.ems_model.annotation.PK;
|
|||||||
import it.integry.ems_model.annotation.SqlField;
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
import it.integry.ems_model.annotation.Table;
|
import it.integry.ems_model.annotation.Table;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.db.ResultSetMapper;
|
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import org.kie.api.definition.type.PropertyReactive;
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import it.integry.ems_model.annotation.FK;
|
|
||||||
|
|
||||||
@Master
|
@Master
|
||||||
@PropertyReactive
|
@PropertyReactive
|
||||||
@@ -123,6 +125,9 @@ public class Azienda extends EntityBase {
|
|||||||
@SqlField(value = "last_upg_sp", maxLength = 40, nullable = true)
|
@SqlField(value = "last_upg_sp", maxLength = 40, nullable = true)
|
||||||
private String lastUpgSp;
|
private String lastUpgSp;
|
||||||
|
|
||||||
|
@SqlField(value = "last_upg_db_menu", maxLength = 10, nullable = false)
|
||||||
|
private String lastUpgDbMenu;
|
||||||
|
|
||||||
@SqlField(value = "sito_web", maxLength = 255, nullable = true)
|
@SqlField(value = "sito_web", maxLength = 255, nullable = true)
|
||||||
private String sitoWeb;
|
private String sitoWeb;
|
||||||
|
|
||||||
@@ -559,6 +564,15 @@ public class Azienda extends EntityBase {
|
|||||||
this.lastUpgSp = lastUpgSp;
|
this.lastUpgSp = lastUpgSp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLastUpgDbMenu() {
|
||||||
|
return lastUpgDbMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Azienda setLastUpgDbMenu(String lastUpgDbMenu) {
|
||||||
|
this.lastUpgDbMenu = lastUpgDbMenu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSitoWeb() {
|
public String getSitoWeb() {
|
||||||
return sitoWeb;
|
return sitoWeb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -504,13 +504,17 @@ public class CtbMovr extends EntityBase {
|
|||||||
@Override
|
@Override
|
||||||
public void checkPreSave() throws Exception {
|
public void checkPreSave() throws Exception {
|
||||||
// TODO -MINA Valutare completamento ctb_movr_coan
|
// TODO -MINA Valutare completamento ctb_movr_coan
|
||||||
for (CtbMovrCoan ctbMovrCoan : getCtbMovrCoan()) {
|
if (getCtbMovrCoan() != null ) {
|
||||||
ctbMovrCoan.setIdRiga(getIdRiga());
|
for (CtbMovrCoan ctbMovrCoan : getCtbMovrCoan()) {
|
||||||
|
ctbMovrCoan.setIdRiga(getIdRiga());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (CtbParr ctbParr : getCtbParr()) {
|
if (getCtbParr() != null ) {
|
||||||
ctbParr.setIdRiga(getIdRiga());
|
for (CtbParr ctbParr : getCtbParr()) {
|
||||||
|
ctbParr.setIdRiga(getIdRiga());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (getCtbScad() != null ){
|
if (getCtbScad() != null ) {
|
||||||
for (CtbScad ctbScad : getCtbScad()) {
|
for (CtbScad ctbScad : getCtbScad()) {
|
||||||
ctbScad.setIdRigaMov(getIdRiga());
|
ctbScad.setIdRigaMov(getIdRiga());
|
||||||
}
|
}
|
||||||
@@ -519,14 +523,18 @@ public class CtbMovr extends EntityBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void insertChilds() throws Exception {
|
protected void insertChilds() throws Exception {
|
||||||
for (CtbMovrCoan ctbMovrCoan : getCtbMovrCoan()) {
|
if ( getCtbMovrCoan() != null ) {
|
||||||
ctbMovrCoan.manageWithParentConnection(connection, ctbMovrCoan.getOperation(), dataCompleting, entityHolder);
|
for (CtbMovrCoan ctbMovrCoan : getCtbMovrCoan()) {
|
||||||
}
|
ctbMovrCoan.manageWithParentConnection(connection, ctbMovrCoan.getOperation(), dataCompleting, entityHolder);
|
||||||
for (CtbParr ctbParr : getCtbParr()) {
|
}
|
||||||
if (!UtilityString.isNullOrEmpty(ctbParr.getDesAgg()) && ctbParr.getDesAgg().length() > 40) {
|
}
|
||||||
ctbParr.setDesAgg(ctbParr.getDesAgg().substring(0, 39));
|
if ( getCtbParr() != null ) {
|
||||||
|
for (CtbParr ctbParr : getCtbParr()) {
|
||||||
|
if (!UtilityString.isNullOrEmpty(ctbParr.getDesAgg()) && ctbParr.getDesAgg().length() > 40) {
|
||||||
|
ctbParr.setDesAgg(ctbParr.getDesAgg().substring(0, 39));
|
||||||
|
}
|
||||||
|
ctbParr.manageWithParentConnection(connection, ctbParr.getOperation(), dataCompleting, entityHolder);
|
||||||
}
|
}
|
||||||
ctbParr.manageWithParentConnection(connection, ctbParr.getOperation(), dataCompleting, entityHolder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ public class CtbParr extends EntityBase {
|
|||||||
|
|
||||||
private Integer tipoPartita;
|
private Integer tipoPartita;
|
||||||
|
|
||||||
|
private BigDecimal cambioDiviScad;
|
||||||
|
|
||||||
@Priority(value = 101, copyPk = false)
|
@Priority(value = 101, copyPk = false)
|
||||||
private List<CtbScad> ctbScad;
|
private List<CtbScad> ctbScad;
|
||||||
|
|
||||||
@@ -258,6 +260,16 @@ public class CtbParr extends EntityBase {
|
|||||||
this.tipoPartita = tipoPartita;
|
this.tipoPartita = tipoPartita;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCambioDiviScad() {
|
||||||
|
return cambioDiviScad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CtbParr setCambioDiviScad(BigDecimal cambioDiviScad) {
|
||||||
|
this.cambioDiviScad = cambioDiviScad;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<CtbScad> getCtbScad() {
|
public List<CtbScad> getCtbScad() {
|
||||||
return ctbScad;
|
return ctbScad;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ public class CtbPart extends EntityBase {
|
|||||||
@SqlField(value = "flag_verificata", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
@SqlField(value = "flag_verificata", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||||
private String flagVerificata;
|
private String flagVerificata;
|
||||||
|
|
||||||
|
@ImportFromParent
|
||||||
@SqlField(value = "num_doc_forn", maxLength = 40, nullable = true)
|
@SqlField(value = "num_doc_forn", maxLength = 40, nullable = true)
|
||||||
private String numDocForn;
|
private String numDocForn;
|
||||||
|
|
||||||
|
|||||||
@@ -376,10 +376,12 @@ public class CtbScad extends EntityBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void insertChilds() throws Exception {
|
protected void insertChilds() throws Exception {
|
||||||
for (CrlScadParr crlScadParr: getCrlScadParr()) {
|
if ( getCrlScadParr() != null ) {
|
||||||
if ( crlScadParr.getIdRigaScad() == null ) crlScadParr.setIdRigaScad(getIdRiga());
|
for (CrlScadParr crlScadParr : getCrlScadParr()) {
|
||||||
if ( crlScadParr.getIdRigaMov() == null ) crlScadParr.setIdRigaMov(getIdRigaMov());
|
if (crlScadParr.getIdRigaScad() == null) crlScadParr.setIdRigaScad(getIdRiga());
|
||||||
crlScadParr.manageWithParentConnection(connection, crlScadParr.getOperation(), dataCompleting, entityHolder);
|
if (crlScadParr.getIdRigaMov() == null) crlScadParr.setIdRigaMov(getIdRigaMov());
|
||||||
|
crlScadParr.manageWithParentConnection(connection, crlScadParr.getOperation(), dataCompleting, entityHolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,6 +316,9 @@ public class DtbDoct extends DtbBaseDocT {
|
|||||||
|
|
||||||
@SqlField(value = "cod_lingua", nullable = true)
|
@SqlField(value = "cod_lingua", nullable = true)
|
||||||
private String codLingua;
|
private String codLingua;
|
||||||
|
|
||||||
|
@SqlField(value = "id_lotto", nullable = true)
|
||||||
|
private Integer idLotto;
|
||||||
@JsonProperty(value = "explodeKit")
|
@JsonProperty(value = "explodeKit")
|
||||||
private String explodeKit;
|
private String explodeKit;
|
||||||
|
|
||||||
@@ -1206,6 +1209,14 @@ public class DtbDoct extends DtbBaseDocT {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIdLotto() {
|
||||||
|
return idLotto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdLotto(Integer idLotto) {
|
||||||
|
this.idLotto = idLotto;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExplodeKit() {
|
public String getExplodeKit() {
|
||||||
return explodeKit;
|
return explodeKit;
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ public class DtbOrdt extends DtbDocOrdT {
|
|||||||
|
|
||||||
private VtbDest vtbDest;
|
private VtbDest vtbDest;
|
||||||
|
|
||||||
|
private Boolean flagScollegaPartitaMag = false;
|
||||||
public DtbOrdt() {
|
public DtbOrdt() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -1720,6 +1721,14 @@ public class DtbOrdt extends DtbDocOrdT {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getFlagScollegaPartitaMag() {
|
||||||
|
return flagScollegaPartitaMag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlagScollegaPartitaMag(Boolean flagScollegaPartitaMag) {
|
||||||
|
this.flagScollegaPartitaMag = flagScollegaPartitaMag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkPreSave() throws Exception {
|
public void checkPreSave() throws Exception {
|
||||||
switch (getOperation()) {
|
switch (getOperation()) {
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import it.integry.ems_model.base.EntityBase;
|
|||||||
import it.integry.ems_model.entity._enum.IBaseEnum;
|
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.kie.api.definition.type.PropertyReactive;
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@PropertyReactive
|
@PropertyReactive
|
||||||
@Table(MtbColr.ENTITY)
|
@Table(MtbColr.ENTITY)
|
||||||
@@ -561,7 +561,7 @@ public class MtbColr extends EntityBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void insertChilds() throws Exception {
|
protected void insertChilds() throws Exception {
|
||||||
if ( getMtbColrInfoProd() != null ) {
|
if (getMtbColrInfoProd() != null) {
|
||||||
getMtbColrInfoProd().setRiga(riga);
|
getMtbColrInfoProd().setRiga(riga);
|
||||||
getMtbColrInfoProd().manageWithParentConnection(connection, getMtbColrInfoProd().getOperation(), dataCompleting, entityHolder);
|
getMtbColrInfoProd().manageWithParentConnection(connection, getMtbColrInfoProd().getOperation(), dataCompleting, entityHolder);
|
||||||
}
|
}
|
||||||
@@ -579,18 +579,18 @@ public class MtbColr extends EntityBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum Causale implements IBaseEnum {
|
public enum Causale implements IBaseEnum<Causale> {
|
||||||
|
|
||||||
DEFAULT(0), RETTIFICA(1), VERSAMENTO(2);
|
DEFAULT((short) 0), RETTIFICA((short) 1), VERSAMENTO((short) 2);
|
||||||
|
|
||||||
private final int value;
|
private final short value;
|
||||||
|
|
||||||
Causale(int value) {
|
Causale(short value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Causale from(Object value) {
|
public static Causale from(Object value) {
|
||||||
int castValue = (int) value;
|
short castValue = (short) value;
|
||||||
for (Causale b : Causale.values()) {
|
for (Causale b : Causale.values()) {
|
||||||
if (b.value == castValue)
|
if (b.value == castValue)
|
||||||
return b;
|
return b;
|
||||||
@@ -599,7 +599,7 @@ public class MtbColr extends EntityBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonValue
|
@JsonValue
|
||||||
public int getValue() {
|
public short getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,7 +609,7 @@ public class MtbColr extends EntityBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object fromInternal(Object val) {
|
public Causale fromInternal(Object val) {
|
||||||
return from(val);
|
return from(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import it.integry.ems_model.types.OperationType;
|
|||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityHashMap;
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.kie.api.definition.type.PropertyReactive;
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -162,6 +161,9 @@ public class MtbColt extends EntityBase {
|
|||||||
@SqlField("id_lotto")
|
@SqlField("id_lotto")
|
||||||
private Integer idLotto;
|
private Integer idLotto;
|
||||||
|
|
||||||
|
@SqlField(value = "barcode_ul", nullable = true, maxLength = 20)
|
||||||
|
private String barcodeUl;
|
||||||
|
|
||||||
private String insPartitaMag;
|
private String insPartitaMag;
|
||||||
|
|
||||||
private transient String stpPrz;
|
private transient String stpPrz;
|
||||||
@@ -610,6 +612,15 @@ public class MtbColt extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBarcodeUl() {
|
||||||
|
return barcodeUl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtbColt setBarcodeUl(String barcodeUl) {
|
||||||
|
this.barcodeUl = barcodeUl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<MtbColr> getMtbColr() {
|
public List<MtbColr> getMtbColr() {
|
||||||
return mtbColr;
|
return mtbColr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,10 +92,10 @@ public class StbFilesAttached extends EntityBase {
|
|||||||
@EntityChild
|
@EntityChild
|
||||||
private GrlAnagNoteFiles grlAnagNoteFiles;
|
private GrlAnagNoteFiles grlAnagNoteFiles;
|
||||||
|
|
||||||
@EntityChild
|
@EntityChild(copyPk = false)
|
||||||
private MrlSartAttached mrlSartAttached;
|
private MrlSartAttached mrlSartAttached;
|
||||||
|
|
||||||
@EntityChild
|
@EntityChild(copyPk = false)
|
||||||
private CtbAmacHistory ctbAmacHistory;
|
private CtbAmacHistory ctbAmacHistory;
|
||||||
|
|
||||||
public StbFilesAttached() {
|
public StbFilesAttached() {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import it.integry.ems_model.annotation.SqlField;
|
|||||||
import it.integry.ems_model.annotation.Table;
|
import it.integry.ems_model.annotation.Table;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import org.kie.api.definition.type.PropertyReactive;
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
import it.integry.ems_model.annotation.FK;
|
|
||||||
|
|
||||||
@PropertyReactive
|
@PropertyReactive
|
||||||
@Table(StbMenuOpz.ENTITY)
|
@Table(StbMenuOpz.ENTITY)
|
||||||
@@ -30,7 +29,7 @@ public class StbMenuOpz extends EntityBase {
|
|||||||
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||||
private String flagPrinterSetup;
|
private String flagPrinterSetup;
|
||||||
|
|
||||||
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
@SqlField(value = "gest_name", maxLength = 80, nullable = true)
|
||||||
private String gestName;
|
private String gestName;
|
||||||
|
|
||||||
@SqlField(value = "is_deprecated", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
@SqlField(value = "is_deprecated", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package it.integry.ems_model.entity;
|
|||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import it.integry.ems_model.annotation.*;
|
import it.integry.ems_model.annotation.*;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
import org.kie.api.definition.type.PropertyReactive;
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -20,20 +21,20 @@ public class StbPublications extends EntityBase {
|
|||||||
@PK
|
@PK
|
||||||
@Identity
|
@Identity
|
||||||
@SqlField(value = "id", nullable = false)
|
@SqlField(value = "id", nullable = false)
|
||||||
private long id;
|
private Long id;
|
||||||
|
|
||||||
@SqlField(value = "publication_description")
|
@SqlField(value = "publication_description")
|
||||||
private String publicationDescription;
|
private String publicationDescription;
|
||||||
|
|
||||||
@EntityChild
|
@EntityChild(copyPk = false)
|
||||||
private List<StbPublicationsDetail> stbPublicationsDetails = new ArrayList<>();
|
private List<StbPublicationsDetail> stbPublicationsDetails = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StbPublications setId(long id) {
|
public StbPublications setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,7 @@ public class StbPublications extends EntityBase {
|
|||||||
@Override
|
@Override
|
||||||
protected void deleteChilds() throws Exception {
|
protected void deleteChilds() throws Exception {
|
||||||
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail();
|
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail();
|
||||||
stbPublicationsDetail.deleteAllEntities(connection, this);
|
stbPublicationsDetail.deleteAllEntities(connection, Query.format("stb_publication_id = %s", getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class StbPublicationsDetail extends EntityBase {
|
|||||||
@PK
|
@PK
|
||||||
@Identity
|
@Identity
|
||||||
@SqlField(value = "id", nullable = false)
|
@SqlField(value = "id", nullable = false)
|
||||||
private long id;
|
private Long id;
|
||||||
|
|
||||||
@FK(tableName = StbPublications.ENTITY, columnName = "id")
|
@FK(tableName = StbPublications.ENTITY, columnName = "id")
|
||||||
@SqlField(value = "stb_publication_id", nullable = false)
|
@SqlField(value = "stb_publication_id", nullable = false)
|
||||||
@@ -27,13 +27,13 @@ public class StbPublicationsDetail extends EntityBase {
|
|||||||
private String entityName;
|
private String entityName;
|
||||||
|
|
||||||
@SqlField(value = "active", defaultObjectValue="1", nullable = false)
|
@SqlField(value = "active", defaultObjectValue="1", nullable = false)
|
||||||
private boolean active;
|
private Boolean active;
|
||||||
|
|
||||||
@SqlField(value = "export_history", defaultObjectValue="0", nullable = false)
|
@SqlField(value = "export_history", defaultObjectValue="0", nullable = false)
|
||||||
private boolean exportHistory;
|
private Boolean exportHistory;
|
||||||
|
|
||||||
@SqlField(value = "ready_to_transmit", defaultObjectValue="0", nullable = false)
|
@SqlField(value = "ready_to_transmit", defaultObjectValue="0", nullable = false)
|
||||||
private boolean readyToTransmit;
|
private Boolean readyToTransmit;
|
||||||
|
|
||||||
@SqlField(value = "recalc_columns")
|
@SqlField(value = "recalc_columns")
|
||||||
private String recalcColumnsField;
|
private String recalcColumnsField;
|
||||||
@@ -48,7 +48,7 @@ public class StbPublicationsDetail extends EntityBase {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StbPublicationsDetail setId(long id) {
|
public StbPublicationsDetail setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -70,29 +70,29 @@ public class StbPublicationsDetail extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public Boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StbPublicationsDetail setActive(boolean active) {
|
public StbPublicationsDetail setActive(Boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExportHistory() {
|
public Boolean isExportHistory() {
|
||||||
return exportHistory;
|
return exportHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StbPublicationsDetail setExportHistory(boolean exportHistory) {
|
public StbPublicationsDetail setExportHistory(Boolean exportHistory) {
|
||||||
this.exportHistory = exportHistory;
|
this.exportHistory = exportHistory;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReadyToTransmit() {
|
public Boolean isReadyToTransmit() {
|
||||||
return readyToTransmit;
|
return readyToTransmit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StbPublicationsDetail setReadyToTransmit(boolean readyToTransmit) {
|
public StbPublicationsDetail setReadyToTransmit(Boolean readyToTransmit) {
|
||||||
this.readyToTransmit = readyToTransmit;
|
this.readyToTransmit = readyToTransmit;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
package it.integry.ems_model.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import it.integry.ems_model.annotation.*;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
|
@Master
|
||||||
|
@PropertyReactive
|
||||||
|
@Table(StbRemoteSubscription.ENTITY)
|
||||||
|
@JsonTypeName(StbRemoteSubscription.ENTITY)
|
||||||
|
public class StbRemoteSubscription extends EntityBase {
|
||||||
|
|
||||||
|
public static final String ENTITY = "stb_remote_subscription";
|
||||||
|
|
||||||
|
private static final long serialVerionUID = 1L;
|
||||||
|
|
||||||
|
@PK
|
||||||
|
@Identity
|
||||||
|
@SqlField(value = "id", nullable = false)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@SqlField(value = "publication_id", nullable = false)
|
||||||
|
private Long publicationId;
|
||||||
|
|
||||||
|
@SqlField(value = "publication_description")
|
||||||
|
private String publicationDescription;
|
||||||
|
|
||||||
|
@SqlField(value = "endpoint_protocol", nullable = false, defaultObjectValue = "HTTP")
|
||||||
|
private String endpointProtocol;
|
||||||
|
|
||||||
|
@SqlField(value = "endpoint_host", nullable = false)
|
||||||
|
private String endpointHost;
|
||||||
|
|
||||||
|
@SqlField(value = "endpoint_port", nullable = false, defaultObjectValue = "80")
|
||||||
|
private int endpointPort;
|
||||||
|
|
||||||
|
@SqlField(value = "username", nullable = false)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@SqlField(value = "password", nullable = false)
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@SqlField(value = "profile_db", nullable = false)
|
||||||
|
private String profileDb;
|
||||||
|
|
||||||
|
@SqlField(value = "last_transaction_id")
|
||||||
|
private Long lastTransactionId;
|
||||||
|
|
||||||
|
@SqlField(value = "last_transaction_id_imported")
|
||||||
|
private Long lastTransactionIdImported;
|
||||||
|
|
||||||
|
@SqlField(value = "active", nullable = false, defaultObjectValue = "0")
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
|
|
||||||
|
public String getEndpointUrl() {
|
||||||
|
return endpointProtocol.toLowerCase() + "://" + endpointHost + ":" + endpointPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPublicationId() {
|
||||||
|
return publicationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setPublicationId(Long publicationId) {
|
||||||
|
this.publicationId = publicationId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicationDescription() {
|
||||||
|
return publicationDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setPublicationDescription(String publicationDescription) {
|
||||||
|
this.publicationDescription = publicationDescription;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndpointProtocol() {
|
||||||
|
return endpointProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setEndpointProtocol(String endpointProtocol) {
|
||||||
|
this.endpointProtocol = endpointProtocol;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndpointHost() {
|
||||||
|
return endpointHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setEndpointHost(String endpointHost) {
|
||||||
|
this.endpointHost = endpointHost;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEndpointPort() {
|
||||||
|
return endpointPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setEndpointPort(int endpointPort) {
|
||||||
|
this.endpointPort = endpointPort;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsernameField() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setUsernameField(String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileDb() {
|
||||||
|
return profileDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setProfileDb(String profileDb) {
|
||||||
|
this.profileDb = profileDb;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLastTransactionId() {
|
||||||
|
return lastTransactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setLastTransactionId(Long lastTransactionId) {
|
||||||
|
this.lastTransactionId = lastTransactionId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLastTransactionIdImported() {
|
||||||
|
return lastTransactionIdImported;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setLastTransactionIdImported(Long lastTransactionIdImported) {
|
||||||
|
this.lastTransactionIdImported = lastTransactionIdImported;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbRemoteSubscription setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package it.integry.ems_model.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import it.integry.ems_model.annotation.Master;
|
||||||
|
import it.integry.ems_model.annotation.PK;
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.annotation.Table;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
|
@Master
|
||||||
|
@PropertyReactive
|
||||||
|
@Table(StbTipoAzienda.ENTITY)
|
||||||
|
@JsonTypeName(StbTipoAzienda.ENTITY)
|
||||||
|
public class StbTipoAzienda extends EntityBase {
|
||||||
|
|
||||||
|
public static final String ENTITY = "stb_tipo_azienda";
|
||||||
|
private static final long serialVerionUID = 1L;
|
||||||
|
@PK
|
||||||
|
@SqlField(value = "tipo_azienda", maxLength = 40, nullable = false)
|
||||||
|
private String tipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 1024)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
|
||||||
|
public String getTipoAzienda() {
|
||||||
|
return tipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAzienda setTipoAzienda(String tipoAzienda) {
|
||||||
|
this.tipoAzienda = tipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAzienda setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ public class StbTransactionLog extends EntityBase {
|
|||||||
private String entitiesJson;
|
private String entitiesJson;
|
||||||
|
|
||||||
@SqlField(value = "group_id", nullable = false)
|
@SqlField(value = "group_id", nullable = false)
|
||||||
private int groupId;
|
private long groupId;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -95,11 +95,11 @@ public class StbTransactionLog extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGroupId() {
|
public long getGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StbTransactionLog setGroupId(int groupId) {
|
public StbTransactionLog setGroupId(long groupId) {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,192 +111,193 @@ public class VtbList extends EntityBase {
|
|||||||
@EntityChild
|
@EntityChild
|
||||||
private List<VtbListPremi> vtbListPremi;
|
private List<VtbListPremi> vtbListPremi;
|
||||||
|
|
||||||
public VtbList() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCodVlis() {
|
public String getCodVlis() {
|
||||||
return codVlis;
|
return codVlis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodVlis(String codVlis) {
|
public VtbList setCodVlis(String codVlis) {
|
||||||
this.codVlis = codVlis;
|
this.codVlis = codVlis;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescrizione() {
|
public String getDescrizione() {
|
||||||
return descrizione;
|
return descrizione;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescrizione(String descrizione) {
|
public VtbList setDescrizione(String descrizione) {
|
||||||
this.descrizione = descrizione;
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getRicarica() {
|
public BigDecimal getRicarica() {
|
||||||
return ricarica;
|
return ricarica;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRicarica(BigDecimal ricarica) {
|
public VtbList setRicarica(BigDecimal ricarica) {
|
||||||
this.ricarica = ricarica;
|
this.ricarica = ricarica;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getArrRic() {
|
public BigDecimal getArrRic() {
|
||||||
return arrRic;
|
return arrRic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArrRic(BigDecimal arrRic) {
|
public VtbList setArrRic(BigDecimal arrRic) {
|
||||||
this.arrRic = arrRic;
|
this.arrRic = arrRic;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodDivi() {
|
public String getCodDivi() {
|
||||||
return codDivi;
|
return codDivi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodDivi(String codDivi) {
|
public VtbList setCodDivi(String codDivi) {
|
||||||
this.codDivi = codDivi;
|
this.codDivi = codDivi;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getCambio() {
|
public BigDecimal getCambio() {
|
||||||
return cambio;
|
return cambio;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCambio(BigDecimal cambio) {
|
public VtbList setCambio(BigDecimal cambio) {
|
||||||
this.cambio = cambio;
|
this.cambio = cambio;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getArrCam() {
|
public BigDecimal getArrCam() {
|
||||||
return arrCam;
|
return arrCam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArrCam(BigDecimal arrCam) {
|
public VtbList setArrCam(BigDecimal arrCam) {
|
||||||
this.arrCam = arrCam;
|
this.arrCam = arrCam;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagAttivo() {
|
public String getFlagAttivo() {
|
||||||
return flagAttivo;
|
return flagAttivo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagAttivo(String flagAttivo) {
|
public VtbList setFlagAttivo(String flagAttivo) {
|
||||||
this.flagAttivo = flagAttivo;
|
this.flagAttivo = flagAttivo;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagRicScatto() {
|
public String getFlagRicScatto() {
|
||||||
return flagRicScatto;
|
return flagRicScatto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagRicScatto(String flagRicScatto) {
|
public VtbList setFlagRicScatto(String flagRicScatto) {
|
||||||
this.flagRicScatto = flagRicScatto;
|
this.flagRicScatto = flagRicScatto;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPercRecSpese() {
|
public BigDecimal getPercRecSpese() {
|
||||||
return percRecSpese;
|
return percRecSpese;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercRecSpese(BigDecimal percRecSpese) {
|
public VtbList setPercRecSpese(BigDecimal percRecSpese) {
|
||||||
this.percRecSpese = percRecSpese;
|
this.percRecSpese = percRecSpese;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPercProv() {
|
public BigDecimal getPercProv() {
|
||||||
return percProv;
|
return percProv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercProv(BigDecimal percProv) {
|
public VtbList setPercProv(BigDecimal percProv) {
|
||||||
this.percProv = percProv;
|
this.percProv = percProv;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPercGest() {
|
public BigDecimal getPercGest() {
|
||||||
return percGest;
|
return percGest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercGest(BigDecimal percGest) {
|
public VtbList setPercGest(BigDecimal percGest) {
|
||||||
this.percGest = percGest;
|
this.percGest = percGest;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagCalcoloPrz() {
|
public String getFlagCalcoloPrz() {
|
||||||
return flagCalcoloPrz;
|
return flagCalcoloPrz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagCalcoloPrz(String flagCalcoloPrz) {
|
public VtbList setFlagCalcoloPrz(String flagCalcoloPrz) {
|
||||||
this.flagCalcoloPrz = flagCalcoloPrz;
|
this.flagCalcoloPrz = flagCalcoloPrz;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPercIspe() {
|
public BigDecimal getPercIspe() {
|
||||||
return percIspe;
|
return percIspe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercIspe(BigDecimal percIspe) {
|
public VtbList setPercIspe(BigDecimal percIspe) {
|
||||||
this.percIspe = percIspe;
|
this.percIspe = percIspe;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPercPromo() {
|
public BigDecimal getPercPromo() {
|
||||||
return percPromo;
|
return percPromo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercPromo(BigDecimal percPromo) {
|
public VtbList setPercPromo(BigDecimal percPromo) {
|
||||||
this.percPromo = percPromo;
|
this.percPromo = percPromo;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPercOneri() {
|
public BigDecimal getPercOneri() {
|
||||||
return percOneri;
|
return percOneri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercOneri(BigDecimal percOneri) {
|
public VtbList setPercOneri(BigDecimal percOneri) {
|
||||||
this.percOneri = percOneri;
|
this.percOneri = percOneri;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodVlisRif() {
|
public String getCodVlisRif() {
|
||||||
return codVlisRif;
|
return codVlisRif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodVlisRif(String codVlisRif) {
|
public VtbList setCodVlisRif(String codVlisRif) {
|
||||||
this.codVlisRif = codVlisRif;
|
this.codVlisRif = codVlisRif;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagArrPrzIva() {
|
public String getFlagArrPrzIva() {
|
||||||
return flagArrPrzIva;
|
return flagArrPrzIva;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagArrPrzIva(String flagArrPrzIva) {
|
public VtbList setFlagArrPrzIva(String flagArrPrzIva) {
|
||||||
this.flagArrPrzIva = flagArrPrzIva;
|
this.flagArrPrzIva = flagArrPrzIva;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagListIvaInclusa() {
|
public String getFlagListIvaInclusa() {
|
||||||
return flagListIvaInclusa;
|
return flagListIvaInclusa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagListIvaInclusa(String flagListIvaInclusa) {
|
public VtbList setFlagListIvaInclusa(String flagListIvaInclusa) {
|
||||||
this.flagListIvaInclusa = flagListIvaInclusa;
|
this.flagListIvaInclusa = flagListIvaInclusa;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagLisvMargine() {
|
public String getFlagLisvMargine() {
|
||||||
return flagLisvMargine;
|
return flagLisvMargine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagLisvMargine(String flagLisvMargine) {
|
public VtbList setFlagLisvMargine(String flagLisvMargine) {
|
||||||
this.flagLisvMargine = flagLisvMargine;
|
this.flagLisvMargine = flagLisvMargine;
|
||||||
}
|
return this;
|
||||||
|
|
||||||
public List<VtbList> getVtbList() {
|
|
||||||
return vtbList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVtbList(List<VtbList> vtbList) {
|
|
||||||
this.vtbList = vtbList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VtbListPremi> getVtbListPremi() {
|
|
||||||
return vtbListPremi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVtbListPremi(List<VtbListPremi> vtbListPremi) {
|
|
||||||
this.vtbListPremi = vtbListPremi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagECommerce() {
|
public String getFlagECommerce() {
|
||||||
return flagECommerce;
|
return flagECommerce;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagECommerce(String flagECommerce) {
|
public VtbList setFlagECommerce(String flagECommerce) {
|
||||||
this.flagECommerce = flagECommerce;
|
this.flagECommerce = flagECommerce;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getFlagAddSfrido() {
|
public Boolean getFlagAddSfrido() {
|
||||||
@@ -317,6 +318,24 @@ public class VtbList extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VtbList> getVtbList() {
|
||||||
|
return vtbList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VtbList setVtbList(List<VtbList> vtbList) {
|
||||||
|
this.vtbList = vtbList;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VtbListPremi> getVtbListPremi() {
|
||||||
|
return vtbListPremi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VtbList setVtbListPremi(List<VtbListPremi> vtbListPremi) {
|
||||||
|
this.vtbListPremi = vtbListPremi;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkPreSave() throws Exception {
|
public void checkPreSave() throws Exception {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems_model.entity;
|
package it.integry.ems_model.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.ems.rules.completing.SalesRules;
|
import it.integry.ems.rules.completing.SalesRules;
|
||||||
@@ -77,6 +78,12 @@ public class VtbListData extends EntityBase {
|
|||||||
@MapToTable("descr_promo")
|
@MapToTable("descr_promo")
|
||||||
private String descrPromo;
|
private String descrPromo;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
@JsonProperty("cod_divi")
|
||||||
|
private String codDivi;
|
||||||
|
|
||||||
private Boolean datiLogistici;
|
private Boolean datiLogistici;
|
||||||
|
|
||||||
private Boolean checkDataIniz;
|
private Boolean checkDataIniz;
|
||||||
@@ -84,6 +91,9 @@ public class VtbListData extends EntityBase {
|
|||||||
private Boolean checkDataFine;
|
private Boolean checkDataFine;
|
||||||
|
|
||||||
@Priority(1)
|
@Priority(1)
|
||||||
|
private VtbList vtbList;
|
||||||
|
|
||||||
|
@Priority(2)
|
||||||
private VtbPromo vtbPromo;
|
private VtbPromo vtbPromo;
|
||||||
|
|
||||||
@Priority(value = 101, copyPk = false)
|
@Priority(value = 101, copyPk = false)
|
||||||
@@ -243,6 +253,24 @@ public class VtbListData extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VtbListData setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodDivi() {
|
||||||
|
return codDivi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VtbListData setCodDivi(String codDivi) {
|
||||||
|
this.codDivi = codDivi;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getDatiLogistici() {
|
public Boolean getDatiLogistici() {
|
||||||
return datiLogistici;
|
return datiLogistici;
|
||||||
}
|
}
|
||||||
@@ -301,6 +329,15 @@ public class VtbListData extends EntityBase {
|
|||||||
SalesRules.checkArtEquiLisv(this);
|
SalesRules.checkArtEquiLisv(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VtbList getVtbList() {
|
||||||
|
return vtbList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VtbListData setVtbList(VtbList vtbList) {
|
||||||
|
this.vtbList = vtbList;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public VtbPromo getVtbPromo() {
|
public VtbPromo getVtbPromo() {
|
||||||
return vtbPromo;
|
return vtbPromo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ public class WtbJreptSetup extends EntityBase {
|
|||||||
ETICHETTA_SSCC_ACCETTAZIONE(0),
|
ETICHETTA_SSCC_ACCETTAZIONE(0),
|
||||||
ETICHETTA_SSCC_LAVORAZIONE(1),
|
ETICHETTA_SSCC_LAVORAZIONE(1),
|
||||||
ETICHETTA_SSCC_SPEDIZIONE(2),
|
ETICHETTA_SSCC_SPEDIZIONE(2),
|
||||||
WMS_SPEDIZIONE_ETICHETTE_SSCC_ORD(3),
|
|
||||||
WMS_SPEDIZIONE_PACKING_LIST_ORD(4),
|
WMS_SPEDIZIONE_PACKING_LIST_ORD(4),
|
||||||
STAMPA_LISTINI_VENDITA(5);
|
STAMPA_LISTINI_VENDITA(5);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ import java.math.BigInteger;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.*;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -766,12 +769,12 @@ public class SqlFieldHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Object getSqlValueField(Object obj) {
|
public static String getSqlValueFieldAsString(Object obj) {
|
||||||
return getSqlValueField(obj, false);
|
return getSqlValueFieldAsString(obj, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getSqlValueField(Object obj, boolean removeSpace) {
|
public static String getSqlValueFieldAsString(Object obj, boolean removeSpace) {
|
||||||
Object dato = null;
|
String dato = null;
|
||||||
if (obj != null && obj.getClass().isEnum()) {
|
if (obj != null && obj.getClass().isEnum()) {
|
||||||
if (IBaseEnum.class.isAssignableFrom(obj.getClass())) {
|
if (IBaseEnum.class.isAssignableFrom(obj.getClass())) {
|
||||||
obj = ((IBaseEnum) obj).get();
|
obj = ((IBaseEnum) obj).get();
|
||||||
@@ -860,4 +863,97 @@ public class SqlFieldHolder {
|
|||||||
return dato;
|
return dato;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Object getSqlValueFieldAsObject(Object obj, boolean removeSpace) {
|
||||||
|
Object dato = 0;
|
||||||
|
|
||||||
|
if (obj != null && obj.getClass().isEnum()) {
|
||||||
|
if (IBaseEnum.class.isAssignableFrom(obj.getClass())) {
|
||||||
|
obj = ((IBaseEnum) obj).get();
|
||||||
|
} else {
|
||||||
|
obj = obj.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj instanceof String) {
|
||||||
|
String string = (String) obj;
|
||||||
|
if (removeSpace)
|
||||||
|
string = string.trim();
|
||||||
|
|
||||||
|
if (EmsRestConstants.NIL.equals(string))
|
||||||
|
dato = "";
|
||||||
|
else if (EmsRestConstants.NULL.equals(string))
|
||||||
|
dato = null;
|
||||||
|
else
|
||||||
|
dato = string;
|
||||||
|
}
|
||||||
|
else if (obj instanceof Date) {
|
||||||
|
Date date = (Date) obj;
|
||||||
|
if (date.equals(EmsRestConstants.DATE_NULL)) {
|
||||||
|
dato = null;
|
||||||
|
} else {
|
||||||
|
dato = date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj instanceof LocalDate) {
|
||||||
|
LocalDate localDate = (LocalDate) obj;
|
||||||
|
if (localDate.equals(LocalDate.MIN)) {
|
||||||
|
dato = null;
|
||||||
|
} else {
|
||||||
|
dato = localDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj instanceof LocalTime) {
|
||||||
|
LocalTime localTime = (LocalTime) obj;
|
||||||
|
if (localTime.equals(LocalTime.MIN)) {
|
||||||
|
dato = null;
|
||||||
|
} else {
|
||||||
|
dato = localTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj instanceof LocalDateTime) {
|
||||||
|
LocalDateTime localDateTime = (LocalDateTime) obj;
|
||||||
|
if (localDateTime.equals(LocalDateTime.MIN)) {
|
||||||
|
dato = null;
|
||||||
|
} else {
|
||||||
|
dato = localDateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj instanceof Integer) {
|
||||||
|
if (obj.equals(EmsRestConstants.INTEGER_NULL)) {
|
||||||
|
dato = null;
|
||||||
|
} else
|
||||||
|
dato = obj;
|
||||||
|
}
|
||||||
|
else if (obj instanceof BigDecimal) {
|
||||||
|
if (obj.equals(EmsRestConstants.BIGDECIMAL_NULL)) {
|
||||||
|
dato = null;
|
||||||
|
} else
|
||||||
|
dato = obj;
|
||||||
|
}
|
||||||
|
else if (obj instanceof LatLng) {
|
||||||
|
LatLng point = (LatLng) obj;
|
||||||
|
|
||||||
|
dato = "geography::STGeomFromText('POINT(" + point.getLng() + " " + point.getLat() + ")', 4326)";
|
||||||
|
}
|
||||||
|
else if (obj instanceof Boolean) {
|
||||||
|
dato = obj;
|
||||||
|
}
|
||||||
|
else if (obj instanceof Instant) {
|
||||||
|
Instant instant = (Instant) obj;
|
||||||
|
if (instant.equals(Instant.MIN)) {
|
||||||
|
dato = null;
|
||||||
|
} else {
|
||||||
|
dato = instant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj != null) {
|
||||||
|
dato = obj;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dato = null;
|
||||||
|
}
|
||||||
|
return dato;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
package it.integry.ems_model.utility;
|
package it.integry.ems_model.utility;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerResultSet;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerStatement;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.expansion.RunnableArgs;
|
||||||
|
import it.integry.ems_model.annotation.EntityChild;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
|
import it.integry.ems_model.db.AsyncResultSetMapper;
|
||||||
import it.integry.ems_model.db.ResultSetMapper;
|
import it.integry.ems_model.db.ResultSetMapper;
|
||||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
@@ -40,22 +45,19 @@ public class UtilityDB {
|
|||||||
|
|
||||||
public static void createIndex(Connection conn, IndexTableDTO indexTableDTO) throws Exception {
|
public static void createIndex(Connection conn, IndexTableDTO indexTableDTO) throws Exception {
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(indexTableDTO.getTableName()))
|
if (UtilityString.isNullOrEmpty(indexTableDTO.getTableName())) throw new Exception("Nome tabella non trovato");
|
||||||
throw new Exception("Nome tabella non trovato");
|
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(indexTableDTO.getIndexName()))
|
if (UtilityString.isNullOrEmpty(indexTableDTO.getIndexName())) throw new Exception("Nome indice non trovato");
|
||||||
throw new Exception("Nome indice non trovato");
|
|
||||||
|
|
||||||
if (indexTableDTO.getColumnsIndex() == null || indexTableDTO.getColumnsIndex().size() == 0 )
|
if (indexTableDTO.getColumnsIndex() == null || indexTableDTO.getColumnsIndex().size() == 0)
|
||||||
throw new Exception("Inserire l'elenco delle colonne su ci creare l'indice");
|
throw new Exception("Inserire l'elenco delle colonne su ci creare l'indice");
|
||||||
|
|
||||||
String sql =
|
String sql = Query.format("SELECT CAST(Count(*) as bit) from sys.sysindexes where name = %s", indexTableDTO.getIndexName());
|
||||||
Query.format( "SELECT CAST(Count(*) as bit) from sys.sysindexes where name = %s", indexTableDTO.getIndexName());
|
|
||||||
|
|
||||||
boolean existIndex = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
boolean existIndex = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
List<String> sqls = new ArrayList<>();
|
List<String> sqls = new ArrayList<>();
|
||||||
if ( existIndex) {
|
if (existIndex) {
|
||||||
if (indexTableDTO.isOverride()) {
|
if (indexTableDTO.isOverride()) {
|
||||||
sql = String.format("DROP INDEX %s ON dbo.%s", indexTableDTO.getIndexName(), indexTableDTO.getTableName());
|
sql = String.format("DROP INDEX %s ON dbo.%s", indexTableDTO.getIndexName(), indexTableDTO.getTableName());
|
||||||
sqls.add(sql);
|
sqls.add(sql);
|
||||||
@@ -64,34 +66,13 @@ public class UtilityDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql =
|
sql = Query.format("SELECT f.name\n" + "FROM sys.indexes i\n" + " INNER JOIN sys.filegroups f\n" + " ON i.data_space_id = f.data_space_id\n" + " INNER JOIN sys.all_objects o\n" + " ON i.[object_id] = o.[object_id]\n" + "WHERE i.data_space_id = f.data_space_id\n" + " AND o.type = 'U'\n" + " AND i.is_primary_key = 1\n" + " AND o.name = %s\n" + " AND f.name <> 'PRIMARY'\n", indexTableDTO.getTableName());
|
||||||
Query.format(
|
|
||||||
"SELECT f.name\n" +
|
|
||||||
"FROM sys.indexes i\n" +
|
|
||||||
" INNER JOIN sys.filegroups f\n" +
|
|
||||||
" ON i.data_space_id = f.data_space_id\n" +
|
|
||||||
" INNER JOIN sys.all_objects o\n" +
|
|
||||||
" ON i.[object_id] = o.[object_id]\n" +
|
|
||||||
"WHERE i.data_space_id = f.data_space_id\n" +
|
|
||||||
" AND o.type = 'U'\n" +
|
|
||||||
" AND i.is_primary_key = 1\n" +
|
|
||||||
" AND o.name = %s\n" +
|
|
||||||
" AND f.name <> 'PRIMARY'\n", indexTableDTO.getTableName());
|
|
||||||
|
|
||||||
String fileGroup = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
String fileGroup = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(fileGroup))
|
if (!UtilityString.isNullOrEmpty(fileGroup)) fileGroup = " ON " + fileGroup.replace("_DATA", "_INDEX");
|
||||||
fileGroup = " ON " + fileGroup.replace("_DATA", "_INDEX");
|
|
||||||
|
|
||||||
sql =
|
sql = String.format("CREATE %s INDEX %s ON dbo.%s ( %s ) %s %s", indexTableDTO.isClustered() ? "CLUSTERED" : "NONCLUSTERED", indexTableDTO.getIndexName(), indexTableDTO.getTableName(), indexTableDTO.getColumnsIndexString(), indexTableDTO.getColumnsIncludeString(), UtilityString.streNull(fileGroup));
|
||||||
String.format(
|
|
||||||
"CREATE %s INDEX %s ON dbo.%s ( %s ) %s %s",
|
|
||||||
indexTableDTO.isClustered()?"CLUSTERED":"NONCLUSTERED",
|
|
||||||
indexTableDTO.getIndexName(),
|
|
||||||
indexTableDTO.getTableName(),
|
|
||||||
indexTableDTO.getColumnsIndexString(),
|
|
||||||
indexTableDTO.getColumnsIncludeString(),
|
|
||||||
UtilityString.streNull(fileGroup));
|
|
||||||
sqls.add(sql);
|
sqls.add(sql);
|
||||||
|
|
||||||
Statement statement = conn.createStatement();
|
Statement statement = conn.createStatement();
|
||||||
@@ -103,8 +84,7 @@ public class UtilityDB {
|
|||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<? extends EntityBase> reloadOnlyDbRow(Connection conn, EntityBase testata,
|
public static List<? extends EntityBase> reloadOnlyDbRow(Connection conn, EntityBase testata, List<? extends EntityBase> rows, Field field) throws Exception {
|
||||||
List<? extends EntityBase> rows, Field field) throws Exception {
|
|
||||||
|
|
||||||
ParameterizedType pType = (ParameterizedType) field.getGenericType();
|
ParameterizedType pType = (ParameterizedType) field.getGenericType();
|
||||||
Class<? extends EntityBase> rowClass = (Class<? extends EntityBase>) pType.getActualTypeArguments()[0];
|
Class<? extends EntityBase> rowClass = (Class<? extends EntityBase>) pType.getActualTypeArguments()[0];
|
||||||
@@ -171,17 +151,21 @@ public class UtilityDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final EntityBase tmpChildEntity = rowClass.newInstance();
|
EntityChild childConstraintDetails = field.getAnnotation(EntityChild.class);
|
||||||
tmpChildEntity.setImportFromParent(testata, true);
|
if (childConstraintDetails.copyPk()) {
|
||||||
list = tmpChildEntity.select(conn, whereCond);
|
list = testata.selectEntityRowList(conn, testata, rowClass, keyType, whereCond);
|
||||||
|
} else {
|
||||||
|
final EntityBase tmpChildEntity = rowClass.newInstance();
|
||||||
|
tmpChildEntity.setImportFromParent(testata, true);
|
||||||
|
list = tmpChildEntity.select(conn, whereCond);
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean existDatabaseObject(Connection conn, String name, TypeDbObject typeObject) throws Exception {
|
public static Boolean existDatabaseObject(Connection conn, String name, TypeDbObject typeObject) throws Exception {
|
||||||
|
|
||||||
String sqlExist = "SELECT Cast(count(*) as bit) FROM sys.objects"
|
String sqlExist = "SELECT Cast(count(*) as bit) FROM sys.objects" + " WHERE object_id = OBJECT_ID(N'dbo." + name + "') AND type in (N'" + typeObject.value() + "')";
|
||||||
+ " WHERE object_id = OBJECT_ID(N'dbo." + name + "') AND type in (N'" + typeObject.value() + "')";
|
|
||||||
Boolean exist = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sqlExist);
|
Boolean exist = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sqlExist);
|
||||||
return exist;
|
return exist;
|
||||||
}
|
}
|
||||||
@@ -216,13 +200,7 @@ public class UtilityDB {
|
|||||||
whereCond = "(" + whereCond + ")";
|
whereCond = "(" + whereCond + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlString = sqlString.replaceAll("(?i)where", "WHERE")
|
sqlString = sqlString.replaceAll("(?i)where", "WHERE").replaceAll("(?i)union all", "UNION ALL").replaceAll("(?i)union", "UNION").replaceAll("(?i)group by", "GROUP BY").replaceAll("(?i)order by", "ORDER BY").replaceAll("(?i)having", "HAVING").replaceAll("(?i)limit", "LIMIT");
|
||||||
.replaceAll("(?i)union all", "UNION ALL")
|
|
||||||
.replaceAll("(?i)union", "UNION")
|
|
||||||
.replaceAll("(?i)group by", "GROUP BY")
|
|
||||||
.replaceAll("(?i)order by", "ORDER BY")
|
|
||||||
.replaceAll("(?i)having", "HAVING")
|
|
||||||
.replaceAll("(?i)limit", "LIMIT");
|
|
||||||
String[] listQuery;
|
String[] listQuery;
|
||||||
if (!ignoreUnion) {
|
if (!ignoreUnion) {
|
||||||
listQuery = sqlString.split(unionAll);
|
listQuery = sqlString.split(unionAll);
|
||||||
@@ -253,11 +231,9 @@ public class UtilityDB {
|
|||||||
do {
|
do {
|
||||||
posInizWhere = subQuery.indexOf(wordAfterWhere[i]);
|
posInizWhere = subQuery.indexOf(wordAfterWhere[i]);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
} while (posInizWhere == -1 && i <= 2);
|
||||||
while (posInizWhere == -1 && i <= 2);
|
|
||||||
|
|
||||||
if (posInizWhere == -1)
|
if (posInizWhere == -1) posInizWhere = subQuery.length();
|
||||||
posInizWhere = subQuery.length();
|
|
||||||
|
|
||||||
posFineWhere = posInizWhere;
|
posFineWhere = posInizWhere;
|
||||||
whereConstructed = whereCond;
|
whereConstructed = whereCond;
|
||||||
@@ -268,8 +244,7 @@ public class UtilityDB {
|
|||||||
|
|
||||||
String preWhere = "", postWhere = "";
|
String preWhere = "", postWhere = "";
|
||||||
|
|
||||||
if (posInizWhere == subQuery.length())
|
if (posInizWhere == subQuery.length()) preWhere = subQuery;
|
||||||
preWhere = subQuery;
|
|
||||||
else {
|
else {
|
||||||
preWhere = subQuery.substring(0, posInizWhere - 1);
|
preWhere = subQuery.substring(0, posInizWhere - 1);
|
||||||
postWhere = subQuery.substring(posFineWhere);
|
postWhere = subQuery.substring(posFineWhere);
|
||||||
@@ -325,10 +300,7 @@ public class UtilityDB {
|
|||||||
} else {
|
} else {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "STRING":
|
case "STRING":
|
||||||
valueString = "'" + valueString
|
valueString = "'" + valueString.replaceAll("'", "''").replaceAll("’", "''") + "'";
|
||||||
.replaceAll("'", "''")
|
|
||||||
.replaceAll("’", "''")
|
|
||||||
+ "'";
|
|
||||||
break;
|
break;
|
||||||
case "DATE": {
|
case "DATE": {
|
||||||
SimpleDateFormat dateFormatFile = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat dateFormatFile = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
@@ -384,7 +356,7 @@ public class UtilityDB {
|
|||||||
|
|
||||||
public static String listValueToString(List<String> lista) {
|
public static String listValueToString(List<String> lista) {
|
||||||
lista = Stream.of(lista).map(UtilityDB::valueToString).toList();
|
lista = Stream.of(lista).map(UtilityDB::valueToString).toList();
|
||||||
return StringUtils.join(lista,",");
|
return StringUtils.join(lista, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int countRow(ResultSet res) {
|
public static int countRow(ResultSet res) {
|
||||||
@@ -453,10 +425,19 @@ public class UtilityDB {
|
|||||||
return stringXML;
|
return stringXML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void executeStatement(Connection connection, String... sqls) throws SQLException {
|
||||||
|
Statement statement = connection.createStatement();
|
||||||
|
|
||||||
|
for (String sql : sqls) {
|
||||||
|
statement.execute(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<HashMap<String, Object>> executeSimpleQuery(Connection conn, String querySql) throws SQLException {
|
public static List<HashMap<String, Object>> executeSimpleQuery(Connection conn, String querySql) throws SQLException {
|
||||||
try (PreparedStatement ps = conn.prepareStatement(querySql);
|
try (PreparedStatement ps = conn.prepareStatement(querySql); ResultSet rs = ps.executeQuery()) {
|
||||||
ResultSet rs = ps.executeQuery()) {
|
|
||||||
|
|
||||||
return ResultSetMapper.mapResultSetToHashMap(rs);
|
return ResultSetMapper.mapResultSetToHashMap(rs);
|
||||||
}
|
}
|
||||||
@@ -513,11 +494,32 @@ public class UtilityDB {
|
|||||||
return executeSimpleQueryDTO(conn, querySql, clazz, null);
|
return executeSimpleQueryDTO(conn, querySql, clazz, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> void executeSimpleQueryDTOAsync(Connection conn, String querySql, Class<T> clazz, RunnableArgs<T> onElementRetrieved) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
try (SQLServerStatement ps = (SQLServerStatement) conn.createStatement()) {
|
||||||
|
ps.setResponseBuffering("adaptive");
|
||||||
|
|
||||||
|
try (SQLServerResultSet rs = (SQLServerResultSet) ps.executeQuery(querySql)) {
|
||||||
|
new AsyncResultSetMapper().mapResultSetToList(rs, clazz, OperationType.SELECT_OBJECT, onElementRetrieved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T> List<T> executeSimpleQueryDTO(Connection conn, String querySql, Class<T> clazz, Integer timeout) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
public static <T> List<T> executeSimpleQueryDTO(Connection conn, String querySql, Class<T> clazz, Integer timeout) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
try (PreparedStatement ps = conn.prepareStatement(querySql);
|
PreparedStatement ps = conn.prepareStatement(querySql);
|
||||||
ResultSet rs = ps.executeQuery()) {
|
List<T> results = executePreparedStatementDTO(conn, ps, clazz, timeout);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static <T> List<T> executePreparedStatementDTO(Connection conn, PreparedStatement ps, Class<T> clazz) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
return executePreparedStatementDTO(conn, ps, clazz, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static <T> List<T> executePreparedStatementDTO(Connection conn, PreparedStatement ps, Class<T> clazz, Integer timeout) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
|
|
||||||
if (timeout != null) {
|
if (timeout != null) {
|
||||||
ps.setQueryTimeout(timeout);
|
ps.setQueryTimeout(timeout);
|
||||||
@@ -527,6 +529,7 @@ public class UtilityDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String addTableFrom(String sqlString, String listTable) {
|
public static String addTableFrom(String sqlString, String listTable) {
|
||||||
int li_subQuery;
|
int li_subQuery;
|
||||||
String ls_stringFromOld, ls_stringFromNew;
|
String ls_stringFromOld, ls_stringFromNew;
|
||||||
|
|||||||
@@ -81,7 +81,11 @@ public class UtilityQuery {
|
|||||||
return sbWhereCond.toString();
|
return sbWhereCond.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String concatFieldsWithSeparator(List<String> inputData, String separator) {
|
public static String concatStringFieldsWithSeparator(List<String> inputData, String separator) {
|
||||||
|
return UtilityQuery.concatObjectFieldsWithSeparator(Stream.of(inputData).map(x -> (Object) x).toList(), separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String concatLongFieldsWithSeparator(List<Long> inputData, String separator) {
|
||||||
return UtilityQuery.concatObjectFieldsWithSeparator(Stream.of(inputData).map(x -> (Object) x).toList(), separator);
|
return UtilityQuery.concatObjectFieldsWithSeparator(Stream.of(inputData).map(x -> (Object) x).toList(), separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
ems-core/src/main/resources/menus/menu_config.json
Normal file
1
ems-core/src/main/resources/menus/menu_config.json
Normal file
File diff suppressed because one or more lines are too long
@@ -412,6 +412,18 @@ then
|
|||||||
modify ( $entity ) { setDatiLogistici(setDatiLogistici) }
|
modify ( $entity ) { setDatiLogistici(setDatiLogistici) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rule "insertVtbList"
|
||||||
|
no-loop
|
||||||
|
when
|
||||||
|
eval(completeRulesEnabled)
|
||||||
|
$entity : VtbListData(codVlis != null && operation != OperationType.DELETE)
|
||||||
|
then
|
||||||
|
VtbList vtbList = SalesRules.insertVtbList(conn, $entity);
|
||||||
|
modify($entity){
|
||||||
|
setVtbList(vtbList)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
rule "completePromoVend"
|
rule "completePromoVend"
|
||||||
no-loop
|
no-loop
|
||||||
when
|
when
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ end
|
|||||||
rule "completeDatiListinoOrdV"
|
rule "completeDatiListinoOrdV"
|
||||||
when
|
when
|
||||||
eval(completeRulesEnabled)
|
eval(completeRulesEnabled)
|
||||||
$entity : DtbOrdr( codMart != null && listino != null && listino != "ULTC" && percAliq != null && gestione == "V" )
|
$entity : DtbOrdr( codMart != null && listino != null && listino != "ULTC" && gestione == "V" )
|
||||||
then
|
then
|
||||||
HashMap<String, Object> dati = SalesRules.completeDatiArtOrdDocV(conn, $entity);
|
HashMap<String, Object> dati = SalesRules.completeDatiArtOrdDocV(conn, $entity);
|
||||||
modify ( $entity ) {
|
modify ( $entity ) {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ end
|
|||||||
rule "completeCtbMovrCoan"
|
rule "completeCtbMovrCoan"
|
||||||
when
|
when
|
||||||
eval(completeRulesEnabled)
|
eval(completeRulesEnabled)
|
||||||
$entity : CtbMovr(ctbMovrCoan.size() == 0 && (tipo == "5" || tipo == "4"))
|
$entity : CtbMovr((ctbMovrCoan == null || ctbMovrCoan.size() == 0) && (tipo == "5" || tipo == "4"))
|
||||||
then
|
then
|
||||||
List<CtbMovrCoan> list = AccountingRules.completeCtbMovrCoan(conn, $entity);
|
List<CtbMovrCoan> list = AccountingRules.completeCtbMovrCoan(conn, $entity);
|
||||||
modify($entity){
|
modify($entity){
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public class StampaSchedaCostiDTO {
|
|||||||
private BigDecimal qtaProd;
|
private BigDecimal qtaProd;
|
||||||
private BigDecimal costoUnit;
|
private BigDecimal costoUnit;
|
||||||
private BigDecimal valore;
|
private BigDecimal valore;
|
||||||
|
private String note;
|
||||||
|
private BigDecimal przVend;
|
||||||
|
private BigDecimal przVendKg;
|
||||||
|
private String untMisVen;
|
||||||
|
|
||||||
public String getCodMart() {
|
public String getCodMart() {
|
||||||
return codMart;
|
return codMart;
|
||||||
@@ -144,5 +148,41 @@ public class StampaSchedaCostiDTO {
|
|||||||
this.descrCosto = descrCosto;
|
this.descrCosto = descrCosto;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StampaSchedaCostiDTO setNote(String note) {
|
||||||
|
this.note = note;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPrzVend() {
|
||||||
|
return przVend;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StampaSchedaCostiDTO setPrzVend(BigDecimal przVend) {
|
||||||
|
this.przVend = przVend;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPrzVendKg() {
|
||||||
|
return przVendKg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StampaSchedaCostiDTO setPrzVendKg(BigDecimal przVendKg) {
|
||||||
|
this.przVendKg = przVendKg;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUntMisVen() {
|
||||||
|
return untMisVen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StampaSchedaCostiDTO setUntMisVen(String untMisVen) {
|
||||||
|
this.untMisVen = untMisVen;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,11 +77,15 @@ public class StampaSchedaCostiJavabean extends BaseReportJavabean implements IRe
|
|||||||
" mtb_lisv_data.system_note,\n" +
|
" mtb_lisv_data.system_note,\n" +
|
||||||
" mtb_lisv_data.unt_mis_ven,\n" +
|
" mtb_lisv_data.unt_mis_ven,\n" +
|
||||||
" mtb_lisv_data.cod_vlis,\n" +
|
" mtb_lisv_data.cod_vlis,\n" +
|
||||||
|
" mtb_lisv_data.note,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend,\n" +
|
||||||
|
" (mtb_lisv_data.prz_vend / mtb_lisv_data.rap_conv) / mtb_aart.peso_kg AS prz_vend_kg,\n" +
|
||||||
" vtb_list.descrizione AS descr_lisv\n" +
|
" vtb_list.descrizione AS descr_lisv\n" +
|
||||||
"FROM mtb_lisv_data\n" +
|
"FROM mtb_lisv_data\n" +
|
||||||
" INNER JOIN mtb_aart ON mtb_lisv_data.cod_mart = mtb_aart.cod_mart\n" +
|
" INNER JOIN mtb_aart ON mtb_lisv_data.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
" INNER JOIN vtb_list ON mtb_lisv_data.cod_vlis = vtb_list.cod_vlis\n" +
|
" INNER JOIN vtb_list ON mtb_lisv_data.cod_vlis = vtb_list.cod_vlis\n" +
|
||||||
" INNER JOIN vtb_list_data ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND mtb_lisv_data.versione = vtb_list_data.versione\n" +
|
" INNER JOIN vtb_list_data ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||||
|
" mtb_lisv_data.versione = vtb_list_data.versione\n" +
|
||||||
"WHERE system_note IS NOT NULL\n" +
|
"WHERE system_note IS NOT NULL\n" +
|
||||||
" AND mtb_lisv_data.cod_mart = %s\n" +
|
" AND mtb_lisv_data.cod_mart = %s\n" +
|
||||||
" AND mtb_lisv_data.cod_vlis = %s\n" +
|
" AND mtb_lisv_data.cod_vlis = %s\n" +
|
||||||
@@ -95,6 +99,9 @@ public class StampaSchedaCostiJavabean extends BaseReportJavabean implements IRe
|
|||||||
" ISNULL(vtb_offr.descrizione_html, ISNULL(mtb_aart.descrizione_estesa, mtb_aart.descrizione)) AS descr_art,\n" +
|
" ISNULL(vtb_offr.descrizione_html, ISNULL(mtb_aart.descrizione_estesa, mtb_aart.descrizione)) AS descr_art,\n" +
|
||||||
" vtb_offr.json_costi AS system_note,\n" +
|
" vtb_offr.json_costi AS system_note,\n" +
|
||||||
" vtb_offr.unt_mis_vend,\n" +
|
" vtb_offr.unt_mis_vend,\n" +
|
||||||
|
" vtb_offr.note,\n" +
|
||||||
|
" vtb_offr.prz_vend,\n" +
|
||||||
|
" (vtb_offr.prz_vend / vtb_offr.rap_conv) / vtb_offr.peso_kg AS prz_vend_kg,\n" +
|
||||||
" id_offerta\n" +
|
" id_offerta\n" +
|
||||||
"FROM vtb_offr\n" +
|
"FROM vtb_offr\n" +
|
||||||
" INNER JOIN mtb_aart ON vtb_offr.cod_mart = mtb_aart.cod_mart\n" +
|
" INNER JOIN mtb_aart ON vtb_offr.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
@@ -135,6 +142,10 @@ public class StampaSchedaCostiJavabean extends BaseReportJavabean implements IRe
|
|||||||
.setDescrArt(UtilityHashMap.getValueIfExists(dati, "descr_art"))
|
.setDescrArt(UtilityHashMap.getValueIfExists(dati, "descr_art"))
|
||||||
.setCodVlis(UtilityHashMap.getValueIfExists(dati, "cod_vlis"))
|
.setCodVlis(UtilityHashMap.getValueIfExists(dati, "cod_vlis"))
|
||||||
.setDescrLisv(UtilityHashMap.getValueIfExists(dati, "descr_lisv"))
|
.setDescrLisv(UtilityHashMap.getValueIfExists(dati, "descr_lisv"))
|
||||||
|
.setPrzVend(UtilityHashMap.getValueIfExists(dati, "prz_vend"))
|
||||||
|
.setPrzVendKg(UtilityHashMap.getValueIfExists(dati, "prz_vend_kg"))
|
||||||
|
.setUntMisVen(UtilityHashMap.getValueIfExists(dati, "unt_mis_ven"))
|
||||||
|
.setNote(UtilityHashMap.getValueIfExists(dati, "note"))
|
||||||
.setGruppo(idGruppo)
|
.setGruppo(idGruppo)
|
||||||
.setDescrizioneGruppo(descrizioneGruppo)
|
.setDescrizioneGruppo(descrizioneGruppo)
|
||||||
.setIdCategoria(idCategoria)
|
.setIdCategoria(idCategoria)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user