first commit
commit
49b584f635
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="cut-to-pack" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="JavacSettings">
|
||||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
<module name="cut-to-pack" options="-parameters" />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="in-project" />
|
||||||
|
<option name="name" value="In project repo" />
|
||||||
|
<option name="url" value="file:///D:\Projects\uind-cut-to-pack\cut-to-pack/libs" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectTasksOptions">
|
||||||
|
<enabled-global>
|
||||||
|
<option value="SCSS" />
|
||||||
|
</enabled-global>
|
||||||
|
</component>
|
||||||
|
</project>
|
Binary file not shown.
|
@ -0,0 +1,376 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.2.2.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.utopiaindustries</groupId>
|
||||||
|
<artifactId>cut-to-pack</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>cut-to-pack</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
<description>Management System for Utopia Industries</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>in-project</id>
|
||||||
|
<name>In project repo</name>
|
||||||
|
<url>file:///${project.basedir}/libs</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
|
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
|
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
<version>2.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-tx</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spring Websocket dependency-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>sockjs-client</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>stomp-websocket</artifactId>
|
||||||
|
<version>2.3.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-examples</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjrt</artifactId>
|
||||||
|
<version>1.9.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjtools</artifactId>
|
||||||
|
<version>1.9.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20090211</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.7</version>
|
||||||
|
</dependency>
|
||||||
|
<!--jsch-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jcraft</groupId>
|
||||||
|
<artifactId>jsch</artifactId>
|
||||||
|
<version>0.1.55</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
|
<artifactId>json-path</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
<version>3.4.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.8.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>1.15</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- jackson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>2.11.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.11.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- aws -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.mail</groupId>
|
||||||
|
<artifactId>javax.mail-api</artifactId>
|
||||||
|
<version>1.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-ses</artifactId>
|
||||||
|
<version>1.11.847</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
|
<artifactId>workmail</artifactId>
|
||||||
|
<version>2.27.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk</artifactId>
|
||||||
|
<version>1.12.490</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-workmail</artifactId>
|
||||||
|
<version>1.12.490</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-core</artifactId>
|
||||||
|
<version>1.12.490</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- itext7 dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itextpdf</artifactId>
|
||||||
|
<version>5.5.9</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itext7-core</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>kernel</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>io</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>layout</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>html2pdf</artifactId>
|
||||||
|
<version>2.1.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>barcodes</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>sign</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>forms</artifactId>
|
||||||
|
<version>7.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- misc. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zebra</groupId>
|
||||||
|
<artifactId>zebra-sdk</artifactId>
|
||||||
|
<version>2.14</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.samstevens.totp</groupId>
|
||||||
|
<artifactId>totp-spring-boot-starter</artifactId>
|
||||||
|
<version>1.7.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.aerogear</groupId>
|
||||||
|
<artifactId>aerogear-otp-java</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javatuples</groupId>
|
||||||
|
<artifactId>javatuples</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.opencsv</groupId>
|
||||||
|
<artifactId>opencsv</artifactId>
|
||||||
|
<version>5.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>4.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>4.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>1.13.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.jtidy</groupId>
|
||||||
|
<artifactId>jtidy</artifactId>
|
||||||
|
<version>r938</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>javase</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.junit.vintage</groupId>
|
||||||
|
<artifactId>junit-vintage-engine</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ibm.icu</groupId>
|
||||||
|
<artifactId>icu4j</artifactId>
|
||||||
|
<version>69.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cronutils</groupId>
|
||||||
|
<artifactId>cron-utils</artifactId>
|
||||||
|
<version>9.1.2</version> <!-- Use the latest version -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-ec2</artifactId>
|
||||||
|
<version>1.12.524</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-rds</artifactId>
|
||||||
|
<version>1.12.524</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<executable>true</executable>
|
||||||
|
<jvmArguments>-Xms1024m</jvmArguments>
|
||||||
|
<jvmArguments>-Xmx8g</jvmArguments>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.utopiaindustries;
|
||||||
|
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CutToPackApplication implements CommandLineRunner {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main( String[] args ) {
|
||||||
|
SpringApplication.run( CutToPackApplication.class, args );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.utopiaindustries.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableTransactionManagement
|
||||||
|
public class DataSourceConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
@Bean(name = "dataSourceUind")
|
||||||
|
@ConfigurationProperties(prefix = "spring.uinddatasource")
|
||||||
|
public DataSource uindDataSource() {
|
||||||
|
return DataSourceBuilder.create().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "jdbcTemplateUind")
|
||||||
|
public JdbcTemplate uindJdbcTemplate(@Qualifier("dataSourceUind") DataSource ds ) {
|
||||||
|
return new JdbcTemplate( ds );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "namedParameterJdbcTemplateUind")
|
||||||
|
public NamedParameterJdbcTemplate uindNamedParameterJdbcTemplate(@Qualifier( "dataSourceUind" ) DataSource ds ) {
|
||||||
|
return new NamedParameterJdbcTemplate( ds );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* COSMOS */
|
||||||
|
|
||||||
|
@Bean(name = "dataSourceCosmos")
|
||||||
|
@ConfigurationProperties(prefix = "spring.cosmosdatasource")
|
||||||
|
public DataSource cosmosDataSource() {
|
||||||
|
return DataSourceBuilder.create().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean(name = "jdbcTemplateCosmos")
|
||||||
|
public JdbcTemplate cosmosJdbcTemplate( @Qualifier( "dataSourceCosmos" ) DataSource ds ) {
|
||||||
|
return new JdbcTemplate( ds );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "namedParameterJdbcTemplateCosmos")
|
||||||
|
public NamedParameterJdbcTemplate cosmosNamedParameterJdbcTemplate( @Qualifier( "dataSourceCosmos" ) DataSource ds ) {
|
||||||
|
return new NamedParameterJdbcTemplate( ds );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LOCAL */
|
||||||
|
|
||||||
|
@Primary
|
||||||
|
@Bean(name = "dataSourceLocal")
|
||||||
|
@ConfigurationProperties(prefix = "spring.localdatasource")
|
||||||
|
public DataSource localDataSource() {
|
||||||
|
return DataSourceBuilder.create().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Primary
|
||||||
|
@Bean(name = "jdbcTemplateLocal")
|
||||||
|
public JdbcTemplate localJdbcTemplate( @Qualifier( "dataSourceLocal" ) DataSource ds ) {
|
||||||
|
return new JdbcTemplate( ds );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Primary
|
||||||
|
@Bean(name = "namedParameterJdbcTemplateLocal")
|
||||||
|
public NamedParameterJdbcTemplate localNamedParameterJdbcTemplate( @Qualifier( "dataSourceLocal" ) DataSource ds ) {
|
||||||
|
return new NamedParameterJdbcTemplate( ds );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.utopiaindustries.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.config.BeanIds;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.provisioning.JdbcUserDetailsManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
@EnableGlobalMethodSecurity( prePostEnabled = true )
|
||||||
|
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(WebSecurity webSecurity) throws Exception {
|
||||||
|
webSecurity.ignoring()
|
||||||
|
.antMatchers("/css/**")
|
||||||
|
.antMatchers("/js/**")
|
||||||
|
.antMatchers("/img/**")
|
||||||
|
.antMatchers("/employee-photo/**")
|
||||||
|
.antMatchers("/error")
|
||||||
|
.antMatchers("/forgot-password/**")
|
||||||
|
.antMatchers( "/hrms/job-applications/new" )
|
||||||
|
.antMatchers( "/candidate-photo/**" )
|
||||||
|
.antMatchers( "/hrms/employee-directory/**" )
|
||||||
|
.antMatchers( "/actuator/scheduledtasks" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.csrf().disable()
|
||||||
|
.authorizeRequests()
|
||||||
|
.antMatchers("/login", "/rest/**")
|
||||||
|
.permitAll()
|
||||||
|
.antMatchers("/**")
|
||||||
|
.hasAnyRole("USER", "ADMIN")
|
||||||
|
.and()
|
||||||
|
.formLogin()
|
||||||
|
.loginPage("/login")
|
||||||
|
.and()
|
||||||
|
.logout()
|
||||||
|
.invalidateHttpSession(true)
|
||||||
|
.deleteCookies("JSESSIONID");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BCryptPasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public JdbcUserDetailsManager jdbcUserDetailsManager() {
|
||||||
|
return new JdbcUserDetailsManager(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean( name = BeanIds.AUTHENTICATION_MANAGER )
|
||||||
|
@Override
|
||||||
|
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||||
|
return super.authenticationManagerBean();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.utopiaindustries.config;
|
||||||
|
|
||||||
|
import com.utopiaindustries.dialect.CTPDialect;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
|
||||||
|
import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect;
|
||||||
|
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||||
|
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
|
||||||
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class WebConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClassLoaderTemplateResolver templateResolver() {
|
||||||
|
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
|
||||||
|
templateResolver.setPrefix( "templates/" );
|
||||||
|
templateResolver.setCacheable( false );
|
||||||
|
templateResolver.setSuffix( ".html" );
|
||||||
|
templateResolver.setTemplateMode( "HTML" );
|
||||||
|
templateResolver.setCharacterEncoding( "UTF-8" );
|
||||||
|
return templateResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SpringTemplateEngine templateEngine() {
|
||||||
|
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
||||||
|
templateEngine.setEnableSpringELCompiler( true );
|
||||||
|
templateEngine.setTemplateResolver( templateResolver() );
|
||||||
|
templateEngine.addDialect( new SpringSecurityDialect() );
|
||||||
|
templateEngine.addDialect( new Java8TimeDialect() );
|
||||||
|
templateEngine.addDialect( new CTPDialect() );
|
||||||
|
return templateEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ViewResolver viewResolver() {
|
||||||
|
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
|
||||||
|
viewResolver.setTemplateEngine( templateEngine() );
|
||||||
|
viewResolver.setCharacterEncoding( "UTF-8" );
|
||||||
|
return viewResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate(){
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class AuthLoginController {
|
||||||
|
|
||||||
|
@GetMapping("/login")
|
||||||
|
public String showLoginPage( Model model ){
|
||||||
|
return "auth/login";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,154 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.dao.ctp.BundleWrapper;
|
||||||
|
import com.utopiaindustries.service.*;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/cutting" )
|
||||||
|
public class CuttingController {
|
||||||
|
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
private final JobCardService jobCardService;
|
||||||
|
private final InventoryService inventoryService;
|
||||||
|
private final LocationService locationService;
|
||||||
|
private final BundleService bundleService;
|
||||||
|
private final BarcodeService barcodeService;
|
||||||
|
|
||||||
|
public CuttingController(InventoryAccountService inventoryAccountService, JobCardService jobCardService, InventoryService inventoryService, LocationService locationService, BundleService bundleService, BarcodeService barcodeService) {
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
this.jobCardService = jobCardService;
|
||||||
|
this.inventoryService = inventoryService;
|
||||||
|
this.locationService = locationService;
|
||||||
|
this.bundleService = bundleService;
|
||||||
|
this.barcodeService = barcodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String homePage( Model model ){
|
||||||
|
return "redirect:/cutting/receive-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/receive-inventory" )
|
||||||
|
public String receiveInventoryForm( Model model ){
|
||||||
|
// 1 for cutting accounts
|
||||||
|
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 1L ) );
|
||||||
|
model.addAttribute("cutPieceTypes", jobCardService.getAllPieceTypes() );
|
||||||
|
return "/cutting/receive-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get cutting inventory accounts
|
||||||
|
* */
|
||||||
|
@GetMapping( "/inventory-accounts" )
|
||||||
|
public String getInventoryAccounts( @RequestParam( value = "id", required = false ) String id,
|
||||||
|
@RequestParam( value = "title", required = false) String title,
|
||||||
|
@RequestParam( value = "active", required = false ) String active,
|
||||||
|
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||||
|
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts( id, title, active, createdBy, startDate, endDate, siteId, count , "PROCESS", "1", false) );
|
||||||
|
model.addAttribute("locations", locationService.findAll() );
|
||||||
|
return "/cutting/inventory-accounts";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/receive-inventory" )
|
||||||
|
public String receiveInventoryToCuttingAccount( Model model,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
@RequestParam( "job-card-id" ) long jobCardId,
|
||||||
|
@RequestParam( "account-id" ) long accountId ){
|
||||||
|
try {
|
||||||
|
inventoryService.receiveJobCardInventory( jobCardId, accountId );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Inventory Success Received" );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/cutting/receive-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping( "/inventory-transactions" )
|
||||||
|
public String getInventoryTransactionsByAccount( @RequestParam( value = "account-id", required = true) long accountId,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("transactions", inventoryService.findTransactionByAccountId( accountId ));
|
||||||
|
return "/cutting/inventory-transactions";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/inventory-summary" )
|
||||||
|
public String getInventorySummaryByAccount( @RequestParam( value = "account-id", required = true) long accountId, Model model ){
|
||||||
|
model.addAttribute("summaries", inventoryService.findItemSummaryByAccountId( accountId ));
|
||||||
|
return "/cutting/inventory-summary";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/generate-master-barcode" )
|
||||||
|
public String showMasterBundleForm( Model model ){
|
||||||
|
model.addAttribute("wrapper", new BundleWrapper() );
|
||||||
|
return "/cutting/generate-master-barcode";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/generate-master-barcode" )
|
||||||
|
public String generateMasterBarcode( @ModelAttribute BundleWrapper wrapper,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
try {
|
||||||
|
long id = bundleService.createMasterBundle( wrapper );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Successfully Created Master Bundle : " + id );
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/cutting/generate-master-barcode";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/bundles" )
|
||||||
|
public String showBundles( @RequestParam( value = "id", required = false ) String id,
|
||||||
|
@RequestParam( value = "sku", required = false) String sku,
|
||||||
|
@RequestParam( value = "jc-id", required = false) String jobCardId,
|
||||||
|
@RequestParam( value = "master-id" , required = false ) String masterId,
|
||||||
|
@RequestParam( value = "type", required = false) String type,
|
||||||
|
@RequestParam( value = "status", required = false) String status,
|
||||||
|
@RequestParam( value = "start-date", required = false) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false) String endDate,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("bundles", bundleService.getBundles( id, sku, jobCardId, masterId, type, status, startDate, endDate ,count ) );
|
||||||
|
model.addAttribute("types", jobCardService.getAllPieceTypes() );
|
||||||
|
return "/cutting/bundles";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping( "/master-bundles")
|
||||||
|
public String showMasterBundles( @RequestParam(value = "id" , required = false) String id,
|
||||||
|
@RequestParam(value = "jc-id", required = false ) String jobCardId,
|
||||||
|
@RequestParam(value = "start-date", required = false) String startDate,
|
||||||
|
@RequestParam(value = "end-date", required = false) String endDate,
|
||||||
|
@RequestParam(value = "count", required = false) Long count,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("masterBundles", bundleService.getMasterBundles( id, jobCardId, startDate, endDate, count ) );
|
||||||
|
return "/cutting/master-bundles";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/get-child-bundles" )
|
||||||
|
public String showBundlesFromMaster( @RequestParam( "master-id" ) long masterId ,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("bundles", bundleService.findBundlesByMasterId( masterId ));
|
||||||
|
return "/cutting/child-bundles";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping( "/generate-barcodes" )
|
||||||
|
public ResponseEntity<InputStreamResource> generateBarcode(@RequestParam( name = "ids", required = true ) Long[] ids,
|
||||||
|
@RequestParam( name = "artifactType", required = true ) String artifactType ) throws Exception {
|
||||||
|
|
||||||
|
return barcodeService.generateBarcodes( Arrays.asList( ids ), artifactType );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.dao.ctp.FinishedItemDAO;
|
||||||
|
import com.utopiaindustries.model.ctp.FinishedItem;
|
||||||
|
import com.utopiaindustries.model.ctp.FinishedItemWrapper;
|
||||||
|
import com.utopiaindustries.service.BundleService;
|
||||||
|
import com.utopiaindustries.service.InventoryAccountService;
|
||||||
|
import com.utopiaindustries.service.InventoryService;
|
||||||
|
import com.utopiaindustries.service.LocationService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/finishing" )
|
||||||
|
public class FinishingController {
|
||||||
|
|
||||||
|
private final FinishedItemDAO finishedItemDAO;
|
||||||
|
private final BundleService bundleService;
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
private final LocationService locationService;
|
||||||
|
private final InventoryService inventoryService;
|
||||||
|
|
||||||
|
public FinishingController(FinishedItemDAO finishedItemDAO, BundleService bundleService, InventoryAccountService inventoryAccountService, LocationService locationService, InventoryService inventoryService) {
|
||||||
|
this.finishedItemDAO = finishedItemDAO;
|
||||||
|
this.bundleService = bundleService;
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
this.locationService = locationService;
|
||||||
|
this.inventoryService = inventoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String showHome(Model model ){
|
||||||
|
return "redirect:/finishing/finished-items";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/finished-items" )
|
||||||
|
public String showFinishedItems( @RequestParam(value = "id", required = false ) String id,
|
||||||
|
@RequestParam(value = "item-id", required = false ) String itemId,
|
||||||
|
@RequestParam( value = "sku", required = false ) String sku,
|
||||||
|
@RequestParam( value = "start-date", required = false) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "job-card-id", required = false ) String jobCardId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ){
|
||||||
|
List<FinishedItem> itemList = bundleService.getFinishedItem( id, itemId, sku, startDate, endDate, jobCardId ,count );
|
||||||
|
model.addAttribute("items", itemList ) ;
|
||||||
|
return "finishing/finished-item-list";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get finishing inventory accounts
|
||||||
|
* */
|
||||||
|
@GetMapping( "/inventory-accounts" )
|
||||||
|
public String getInventoryAccounts( @RequestParam( value = "id", required = false ) String id,
|
||||||
|
@RequestParam( value = "title", required = false) String title,
|
||||||
|
@RequestParam( value = "active", required = false ) String active,
|
||||||
|
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||||
|
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ) {
|
||||||
|
// 5 for Finishing
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts( id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "5" , false ));
|
||||||
|
model.addAttribute("locations", locationService.findAll() );
|
||||||
|
return "/finishing/inventory-accounts";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "segregate-inventory" )
|
||||||
|
public String segregateFinishedItems( Model model ){
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.findInventoryAccountsForFinishedItems() );
|
||||||
|
model.addAttribute("wrapper", new FinishedItemWrapper() );
|
||||||
|
return "/finishing/segregate-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping( "segregate-inventory" )
|
||||||
|
public String segregateFinishItemsInventory( @ModelAttribute FinishedItemWrapper wrapper,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
try {
|
||||||
|
inventoryService.segregateFinishedItems( wrapper );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Items Successfully saved !" );
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/finishing/finished-items";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class HomeController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show home
|
||||||
|
*/
|
||||||
|
@GetMapping
|
||||||
|
public String showHome( Model model ) {
|
||||||
|
return "home";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryAccount;
|
||||||
|
import com.utopiaindustries.service.InventoryAccountService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/inventory-accounts" )
|
||||||
|
public class InventoryAccountController {
|
||||||
|
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
|
||||||
|
public InventoryAccountController(InventoryAccountService inventoryAccountService) {
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String showInventoryAccounts( Model model ){
|
||||||
|
model.addAttribute( "accounts", inventoryAccountService.findInventoryAccounts() );
|
||||||
|
return "inventory-account-list";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping( "/new" )
|
||||||
|
public String showNewForm( Model model ){
|
||||||
|
model.addAttribute( "account", inventoryAccountService.createNewAccount() );
|
||||||
|
model.addAttribute("processes", inventoryAccountService.getAllProcess() );
|
||||||
|
return "inventory-account-add";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/edit/{id}" )
|
||||||
|
public String showEditForm( @PathVariable long id,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("account", inventoryAccountService.find(id) );
|
||||||
|
model.addAttribute("processes", inventoryAccountService.getAllProcess() );
|
||||||
|
return "inventory-account-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/edit" )
|
||||||
|
public String saveNewForm( @ModelAttribute InventoryAccount inventoryAccount,
|
||||||
|
RedirectAttributes redirectAttributes ){
|
||||||
|
try {
|
||||||
|
inventoryAccountService.saveAccount( inventoryAccount );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Inventory Account Successfully Added" );
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/inventory-accounts";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/edit/{id}" )
|
||||||
|
public String saveNewForm( @ModelAttribute InventoryAccount inventoryAccount,
|
||||||
|
@PathVariable long id,
|
||||||
|
RedirectAttributes redirectAttributes ){
|
||||||
|
try {
|
||||||
|
inventoryAccountService.saveAccount( inventoryAccount );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Inventory Account Successfully Added" );
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/inventory-accounts";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.service.InventoryArtifactService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/inventory-artifacts" )
|
||||||
|
public class InventoryArtifactController {
|
||||||
|
|
||||||
|
|
||||||
|
private final InventoryArtifactService inventoryArtifactService;
|
||||||
|
|
||||||
|
public InventoryArtifactController(InventoryArtifactService inventoryArtifactService) {
|
||||||
|
this.inventoryArtifactService = inventoryArtifactService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/bundle/{id}" )
|
||||||
|
public String getBundleViewId( @PathVariable( "id") long id,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("bundle", inventoryArtifactService.findBundleById( id) );
|
||||||
|
return "bundle-view";
|
||||||
|
}
|
||||||
|
|
||||||
|
// @GetMapping( "/master-bundle/{id}" )
|
||||||
|
// public String getMasterBundleById( @PathVariable( "id") long id,
|
||||||
|
// Model model ){
|
||||||
|
// model.addAttribute("masterBundle", inventoryArtifactService.findMasterBundleById( id ) );
|
||||||
|
// return "master-bundle-view";
|
||||||
|
// }
|
||||||
|
|
||||||
|
@GetMapping( "/finished-item/{id}" )
|
||||||
|
public String getFinishItemById( @PathVariable( "id" ) long id,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("finishedItem", inventoryArtifactService.findFinishedItemById( id ) );
|
||||||
|
return "finished-item-view";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.JobCard;
|
||||||
|
import com.utopiaindustries.service.JobCardService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/job-cards" )
|
||||||
|
public class JobCardController {
|
||||||
|
|
||||||
|
private final JobCardService jobCardService;
|
||||||
|
|
||||||
|
public JobCardController(JobCardService jobCardService){
|
||||||
|
this.jobCardService = jobCardService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get all job cards
|
||||||
|
* */
|
||||||
|
@GetMapping
|
||||||
|
public String showJobCardList( Model model ){
|
||||||
|
model.addAttribute("cards", jobCardService.getCards() );
|
||||||
|
return "job-card-list";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/new" )
|
||||||
|
public String showJobCardForm( Model model ){
|
||||||
|
model.addAttribute("jobCard", jobCardService.createNewJobCard() );
|
||||||
|
model.addAttribute("cutPieceTypes", jobCardService.getAllPieceTypes() );
|
||||||
|
return "job-card-add";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( value = "/edit/{id}" )
|
||||||
|
public String showJobCardEditForm( @PathVariable("id") long id,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("jobCard", jobCardService.findCardRecursively( id ) );
|
||||||
|
model.addAttribute("cutPieceTypes", jobCardService.getAllPieceTypes() );
|
||||||
|
return "job-card-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* draft
|
||||||
|
* */
|
||||||
|
@PostMapping( value ="/edit" , params = "user=draft" )
|
||||||
|
public String saveJobCard( @ModelAttribute JobCard jobCard,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
|
||||||
|
try {
|
||||||
|
jobCard.setStatus( JobCard.Status.DRAFT.name() );
|
||||||
|
jobCard.setInventoryStatus( JobCard.InventoryStatus.NOT_RECEIVED_YET.name() );
|
||||||
|
jobCardService.save( jobCard );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Successfully saved!" );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/job-cards";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* draft after save
|
||||||
|
* */
|
||||||
|
@PostMapping( value ="/edit/{id}" , params = "user=draft" )
|
||||||
|
public String saveJobCardEdit( @ModelAttribute JobCard jobCard,
|
||||||
|
@PathVariable long id,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
|
||||||
|
try {
|
||||||
|
jobCard.setStatus( JobCard.Status.DRAFT.name() );
|
||||||
|
jobCard.setInventoryStatus( JobCard.InventoryStatus.NOT_RECEIVED_YET.name() );
|
||||||
|
jobCardService.save( jobCard );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Successfully saved!" );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/job-cards";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( value ="/edit" , params = "user=post" )
|
||||||
|
public String postJobCard( @ModelAttribute JobCard jobCard,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
|
||||||
|
try {
|
||||||
|
jobCard.setStatus(JobCard.Status.POSTED.name() );
|
||||||
|
jobCardService.save( jobCard );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Successfully saved!" );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/job-cards";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* post after draft
|
||||||
|
* */
|
||||||
|
@PostMapping( value ="/edit/{id}" , params = "user=post" )
|
||||||
|
public String postJobCardEdit( @ModelAttribute JobCard jobCard,
|
||||||
|
@PathVariable long id,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
|
||||||
|
try {
|
||||||
|
jobCard.setStatus(JobCard.Status.POSTED.name() );
|
||||||
|
jobCardService.save( jobCard );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Successfully saved!" );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/job-cards";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.service.InventoryAccountService;
|
||||||
|
import com.utopiaindustries.service.LocationService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/packaging" )
|
||||||
|
public class PackagingController {
|
||||||
|
|
||||||
|
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
private final LocationService locationService;
|
||||||
|
|
||||||
|
public PackagingController(InventoryAccountService inventoryAccountService, LocationService locationService) {
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
this.locationService = locationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String showHome( Model model ){
|
||||||
|
return "redirect:/packaging/inventory-accounts";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/inventory-accounts" )
|
||||||
|
public String showInventoryAccounts(@RequestParam( value = "id", required = false ) String id,
|
||||||
|
@RequestParam( value = "title", required = false) String title,
|
||||||
|
@RequestParam( value = "active", required = false ) String active,
|
||||||
|
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||||
|
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ){
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts( id, title, active, createdBy, startDate, endDate, siteId, count , null, null,true ) );
|
||||||
|
model.addAttribute("locations", locationService.findAll() );
|
||||||
|
return "/packaging/inventory-accounts";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.service.ProcessService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/processes" )
|
||||||
|
public class ProcessController {
|
||||||
|
|
||||||
|
private final ProcessService processService;
|
||||||
|
|
||||||
|
public ProcessController(ProcessService processService) {
|
||||||
|
this.processService = processService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String showProcesses( Model model ){
|
||||||
|
model.addAttribute("processes", processService.findAllProcesses() );
|
||||||
|
return "process-list";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/edit" )
|
||||||
|
public String editProcesses(Model model ){
|
||||||
|
model.addAttribute("processWrapper", processService.getAllProcessWrapper() );
|
||||||
|
return "_process-fragment";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/edit" )
|
||||||
|
public String saveProcesses(@ModelAttribute ProcessListWrapper processWrapper,
|
||||||
|
RedirectAttributes redirectAttributes ){
|
||||||
|
try {
|
||||||
|
processService.saveAll( processWrapper );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Process saved");
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/processes";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Process;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProcessListWrapper {
|
||||||
|
|
||||||
|
public List<Process> processes;
|
||||||
|
|
||||||
|
public List<Process> getProcesses() {
|
||||||
|
return processes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcesses(List<Process> processes) {
|
||||||
|
this.processes = processes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ProcessListWrapper{" +
|
||||||
|
"processes=" + processes +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.FinishedItem;
|
||||||
|
import com.utopiaindustries.model.ctp.StitchedItemWrapper;
|
||||||
|
import com.utopiaindustries.service.BundleService;
|
||||||
|
import com.utopiaindustries.service.InventoryAccountService;
|
||||||
|
import com.utopiaindustries.service.InventoryService;
|
||||||
|
import com.utopiaindustries.service.LocationService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/quality-control" )
|
||||||
|
public class QualityControlController {
|
||||||
|
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
private final BundleService bundleService;
|
||||||
|
private final LocationService locationService;
|
||||||
|
private final InventoryService inventoryService;
|
||||||
|
|
||||||
|
public QualityControlController(InventoryAccountService inventoryAccountService, BundleService bundleService, LocationService locationService, InventoryService inventoryService) {
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
this.bundleService = bundleService;
|
||||||
|
this.locationService = locationService;
|
||||||
|
this.inventoryService = inventoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String homePage( Model model ){
|
||||||
|
return "redirect:/quality-control/qc-finished-items";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get stitching inventory accounts
|
||||||
|
* */
|
||||||
|
@GetMapping( "/inventory-accounts" )
|
||||||
|
public String getInventoryAccounts( @RequestParam( value = "id", required = false ) String id,
|
||||||
|
@RequestParam( value = "title", required = false) String title,
|
||||||
|
@RequestParam( value = "active", required = false ) String active,
|
||||||
|
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||||
|
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ) {
|
||||||
|
// 24 for Packaging
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts(id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "4", false));
|
||||||
|
model.addAttribute("locations", locationService.findAll() );
|
||||||
|
return "/quality-control/inventory-accounts";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/qc-finished-items" )
|
||||||
|
public String getFinishedItems( @RequestParam(value = "id", required = false ) String id,
|
||||||
|
@RequestParam(value = "item-id", required = false ) String itemId,
|
||||||
|
@RequestParam( value = "sku", required = false ) String sku,
|
||||||
|
@RequestParam( value = "start-date", required = false) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "job-card-id", required = false ) String jobCardId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ){
|
||||||
|
List<FinishedItem> itemList = bundleService.getFinishedItem( id, itemId, sku, startDate, endDate, jobCardId ,count );
|
||||||
|
model.addAttribute("items", itemList ) ;
|
||||||
|
return "/quality-control/qc-items-list";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/qc-finished-item" )
|
||||||
|
public String getAddFinishedItemForQCForm( Model model ){
|
||||||
|
// 4 for packaging
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts(5L) );
|
||||||
|
model.addAttribute("wrapper", new StitchedItemWrapper() );
|
||||||
|
return "/quality-control/qc-items-form";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/qc-finished-item" )
|
||||||
|
public String postFinishedItemsAfterQc( @ModelAttribute StitchedItemWrapper wrapper,
|
||||||
|
RedirectAttributes redirectAttributes ){
|
||||||
|
try {
|
||||||
|
inventoryService.createFinishedItemsAgainstStitchedItems( wrapper );
|
||||||
|
redirectAttributes.addFlashAttribute("success", " Finished Items Are Generated Against Stitched Items" );
|
||||||
|
}catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/quality-control/qc-finished-items";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.JobCard;
|
||||||
|
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
||||||
|
import com.utopiaindustries.service.*;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/stitching" )
|
||||||
|
public class StitchingController {
|
||||||
|
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
private final JobCardService jobCardService;
|
||||||
|
private final InventoryService inventoryService;
|
||||||
|
private final BundleService bundleService;
|
||||||
|
private final BarcodeService barcodeService;
|
||||||
|
private final LocationService locationService;
|
||||||
|
|
||||||
|
public StitchingController(InventoryAccountService inventoryAccountService, JobCardService jobCardService, InventoryService inventoryService, BundleService bundleService, BarcodeService barcodeService, LocationService locationService) {
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
this.jobCardService = jobCardService;
|
||||||
|
this.inventoryService = inventoryService;
|
||||||
|
this.bundleService = bundleService;
|
||||||
|
this.barcodeService = barcodeService;
|
||||||
|
this.locationService = locationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String homePage( Model model ){
|
||||||
|
return "redirect:/stitching/receive-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/receive-inventory" )
|
||||||
|
public String receiveInventoryForm( Model model ){
|
||||||
|
// 2 for stitching
|
||||||
|
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
||||||
|
model.addAttribute("cutPieceTypes", jobCardService.getAllPieceTypes() );
|
||||||
|
return "/stitching/receive-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/receive-inventory" )
|
||||||
|
public String receiveInventoryToCuttingAccount( RedirectAttributes redirectAttributes,
|
||||||
|
@RequestParam( "master-id" ) long masterId,
|
||||||
|
@RequestParam( "account-id" ) long accountId ){
|
||||||
|
try {
|
||||||
|
inventoryService.receiveInventoryFromMasterBarcode( masterId, accountId );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Inventory Success Received" );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/stitching/receive-inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get stitching inventory accounts
|
||||||
|
* */
|
||||||
|
@GetMapping( "/inventory-accounts" )
|
||||||
|
public String getInventoryAccounts( @RequestParam( value = "id", required = false ) String id,
|
||||||
|
@RequestParam( value = "title", required = false) String title,
|
||||||
|
@RequestParam( value = "active", required = false ) String active,
|
||||||
|
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||||
|
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ) {
|
||||||
|
// 2 for stitching
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts(id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "2", false));
|
||||||
|
model.addAttribute("locations", locationService.findAll() );
|
||||||
|
return "/stitching/inventory-accounts";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get finished items
|
||||||
|
* */
|
||||||
|
@GetMapping( "/stitching-offline-items" )
|
||||||
|
public String getStitchingOfflineItems( @RequestParam(value = "id", required = false ) String id,
|
||||||
|
@RequestParam(value = "item-id", required = false ) String itemId,
|
||||||
|
@RequestParam( value = "sku", required = false ) String sku,
|
||||||
|
@RequestParam( value = "start-date", required = false) String startDate,
|
||||||
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
|
@RequestParam( value = "job-card-id", required = false ) String jobCardId,
|
||||||
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
|
Model model ){
|
||||||
|
List<StitchingOfflineItem> itemList = bundleService.getStitchedOfflineItems( id, itemId, sku, startDate, endDate, jobCardId ,count );
|
||||||
|
model.addAttribute("items", itemList ) ;
|
||||||
|
return "/stitching/stitched-offline-items";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/create-stitching-items")
|
||||||
|
public String createFinishItems( Model model ){
|
||||||
|
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
||||||
|
model.addAttribute("jobCard", jobCardService.createNewJobCard() );
|
||||||
|
return "/stitching/stitching-item-form";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/create-stitching-items" )
|
||||||
|
public String createStitchedOfflineItems( @ModelAttribute JobCard jobCard,
|
||||||
|
RedirectAttributes redirectAttributes,
|
||||||
|
Model model ){
|
||||||
|
try {
|
||||||
|
inventoryService.createStitchingOfflineItemsFromJobCard( jobCard );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "Finished Item Created Successfully");
|
||||||
|
} catch ( Exception exception ){
|
||||||
|
redirectAttributes.addFlashAttribute( "error", exception.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/stitching/stitching-offline-items";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/generate-barcodes" )
|
||||||
|
public ResponseEntity<InputStreamResource> generateBarcode(@RequestParam( name = "ids" ) Long[] ids,
|
||||||
|
@RequestParam( name = "artifactType" ) String artifactType ) throws Exception {
|
||||||
|
|
||||||
|
return barcodeService.generateBarcodes( Arrays.asList( ids ), artifactType );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.Roles;
|
||||||
|
import com.utopiaindustries.model.ctp.User;
|
||||||
|
import com.utopiaindustries.service.InventoryAccountService;
|
||||||
|
import com.utopiaindustries.service.UserService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping( "/users" )
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
private final InventoryAccountService inventoryAccountService;
|
||||||
|
|
||||||
|
public UserController(UserService userService, InventoryAccountService inventoryAccountService) {
|
||||||
|
this.userService = userService;
|
||||||
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String getAllUsers( Model model ){
|
||||||
|
model.addAttribute( "users", userService.findAllUsers() );
|
||||||
|
return "users";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping( "/new" )
|
||||||
|
public String addUserForm( Model model ){
|
||||||
|
model.addAttribute("user", userService.createEmptyUser() );
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts() );
|
||||||
|
model.addAttribute("roles", Roles.values() );
|
||||||
|
return "_user-fragment";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping( "/edit/{username}" )
|
||||||
|
public String addUserForm(Model model, @PathVariable String username ){
|
||||||
|
model.addAttribute("user", userService.getUser( username ) );
|
||||||
|
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts() );
|
||||||
|
model.addAttribute("roles", Roles.values() );
|
||||||
|
return "_user-fragment";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/edit" )
|
||||||
|
public String saveUser( Model model,
|
||||||
|
@ModelAttribute User user ,
|
||||||
|
RedirectAttributes redirectAttributes ){
|
||||||
|
try {
|
||||||
|
userService.saveUser( user );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "User Successfully Saved!" );
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/users";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping( "/edit/{username}" )
|
||||||
|
public String saveUser( @PathVariable String username,
|
||||||
|
@ModelAttribute User user,
|
||||||
|
RedirectAttributes redirectAttributes ){
|
||||||
|
try {
|
||||||
|
userService.saveUser( user );
|
||||||
|
redirectAttributes.addFlashAttribute("success", "User Successfully Edited!" );
|
||||||
|
} catch ( Exception e ){
|
||||||
|
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||||
|
}
|
||||||
|
return "redirect:/users";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Authority;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class AuthorityDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.authorities";
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY username DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_USERNAME_QUERY = String.format( "SELECT * FROM %s WHERE username = :username ORDER BY username DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_AUTHORITY_QUERY = String.format( "SELECT * FROM %s WHERE authority = :authority ORDER BY username DESC", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY =String.format("INSERT INTO %s (username,authority) VALUES (:username,:authority)",TABLE_NAME);
|
||||||
|
private final String DELETE_QUERY=String.format("DELETE FROM %s WHERE username = :username",TABLE_NAME);
|
||||||
|
private final String SELECT_BY_USERNAMES = String.format("SELECT * FROM %s WHERE username IN (:usernames)" , TABLE_NAME );
|
||||||
|
|
||||||
|
public AuthorityDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prepare query params
|
||||||
|
* */
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( Authority authority ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("username", authority.getUsername() );
|
||||||
|
params.addValue("authority", authority.getAuthority() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find all
|
||||||
|
*/
|
||||||
|
public List<Authority> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new AuthorityRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find by username
|
||||||
|
*/
|
||||||
|
public List<Authority> findByUsername( String username ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "username", username );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_USERNAME_QUERY, params, new AuthorityRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find by authority
|
||||||
|
*/
|
||||||
|
public List<Authority> findByAuthority( String authority) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "authority", authority );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_AUTHORITY_QUERY, params, new AuthorityRowMapper() );
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* find by username
|
||||||
|
* */
|
||||||
|
public List<Authority> findByUsernames(List<String> usernames ) {
|
||||||
|
if( usernames == null || usernames.isEmpty() ) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "usernames", usernames );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_USERNAMES, params, new AuthorityRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteByUsername( String username ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "username", username );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<Authority> authorities ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( Authority authority: authorities ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( authority );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[authorities.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Authority;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class AuthorityRowMapper implements RowMapper<Authority> {
|
||||||
|
public Authority mapRow(ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
Authority userAuthority = new Authority();
|
||||||
|
userAuthority.setUsername( rs.getString( "username" ) );
|
||||||
|
userAuthority.setAuthority( rs.getString( "authority" ) );
|
||||||
|
return userAuthority;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Bundle;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import com.utopiaindustries.util.StringUtils;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class BundleDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.bundle";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, wrap_quantity, barcode, type, created_by, created_at, job_card_id, master_bundle_id) VALUES (:id, :item_id, :sku, :wrap_quantity, :barcode, :type, :created_by, :created_at, :job_card_id, :master_bundle_id) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), wrap_quantity = VALUES(wrap_quantity), barcode = VALUES(barcode), type = VALUES(type), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), master_bundle_id = VALUES(master_bundle_id)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_TERM_QUERY = String.format( "SELECT * FROM %s WHERE (id = :id OR sku LIKE :sku OR type LIKE :type OR barcode LIKE :barcode) AND master_bundle_id =0", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE master_bundle_id = :master_bundle_id ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_ITEM_ID_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id = :item_id AND job_card_id = :job_card_id", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_ITEM_IDS_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id IN (:item_ids) AND job_card_id = :job_card_id", TABLE_NAME );
|
||||||
|
|
||||||
|
|
||||||
|
public BundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( Bundle bundle ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", bundle.getId() )
|
||||||
|
.addValue( "item_id", bundle.getItemId() )
|
||||||
|
.addValue( "sku", bundle.getSku() )
|
||||||
|
.addValue( "wrap_quantity", bundle.getWrapQuantity() )
|
||||||
|
.addValue( "barcode", bundle.getBarcode() )
|
||||||
|
.addValue( "type", bundle.getType() )
|
||||||
|
.addValue( "created_by", bundle.getCreatedBy() )
|
||||||
|
.addValue( "created_at", bundle.getCreatedAt() )
|
||||||
|
.addValue( "job_card_id", bundle.getJobCardId() )
|
||||||
|
.addValue( "master_bundle_id", bundle.getMasterBundleId() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public Bundle find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new BundleRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new Bundle() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<Bundle> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( Bundle bundle ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( bundle );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( bundle.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<Bundle> bundles ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( Bundle bundle: bundles ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( bundle );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[bundles.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByTerm( String term ){
|
||||||
|
if( StringUtils.isNullOrEmpty( term ) ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id",term );
|
||||||
|
params.addValue( "sku","%" + term + "%" );
|
||||||
|
params.addValue( "type","%" + term + "%" );
|
||||||
|
params.addValue("barcode", "%" + term + "%" );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_TERM_QUERY, params , new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByQuery( String query ){
|
||||||
|
return namedParameterJdbcTemplate.query( query, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByLimit( Long count ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "limit",count );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT , params, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByMasterId( long masterId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("master_bundle_id", masterId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_MASTER_ID, params, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByIds( List<Long> ids ){
|
||||||
|
if( ids == null || ids.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByItemIdAndCardId( long itemId, long cardId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("item_id", itemId );
|
||||||
|
params.addValue("job_card_id", cardId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_ITEM_ID_AND_JOB_CARD, params, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> findByItemIdsAndCardId( List<Long> itemIds, long cardId ){
|
||||||
|
if( itemIds == null || itemIds.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("item_ids", itemIds );
|
||||||
|
params.addValue("job_card_id", cardId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_ITEM_IDS_AND_JOB_CARD, params, new BundleRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Bundle;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class BundleRowMapper implements RowMapper<Bundle> {
|
||||||
|
public Bundle mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.setId( rs.getLong( "id" ) );
|
||||||
|
bundle.setItemId( rs.getLong( "item_id" ) );
|
||||||
|
bundle.setSku( rs.getString( "sku" ) );
|
||||||
|
bundle.setWrapQuantity( rs.getBigDecimal( "wrap_quantity" ) );
|
||||||
|
bundle.setBarcode( rs.getString( "barcode" ) );
|
||||||
|
bundle.setType( rs.getString( "type" ) );
|
||||||
|
bundle.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
|
bundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
bundle.setJobCardId( rs.getLong( "job_card_id" ) );
|
||||||
|
bundle.setMasterBundleId( rs.getLong( "master_bundle_id" ) );
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Bundle;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BundleWrapper {
|
||||||
|
|
||||||
|
private List<Bundle> bundles;
|
||||||
|
|
||||||
|
public BundleWrapper(){
|
||||||
|
this.bundles = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Bundle> getBundles() {
|
||||||
|
return bundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBundles(List<Bundle> bundles) {
|
||||||
|
this.bundles = bundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BundleWrapper{" +
|
||||||
|
"bundles=" + bundles +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.CutPiece;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class CutPieceDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.cut_piece";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_ITEM_IDS = String.format( "SELECT * FROM %s WHERE job_card_item_id IN (:item_ids)", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, job_card_item_id, type, quantity) VALUES (:id, :job_card_item_id, :type, :quantity) ON DUPLICATE KEY UPDATE job_card_item_id = VALUES(job_card_item_id), type = VALUES(type), quantity = VALUES(quantity)", TABLE_NAME );
|
||||||
|
private final String DELETE_BY_ITEM_ID = String.format( "DELETE FROM %s WHERE job_card_item_id = :job_card_item_id", TABLE_NAME );
|
||||||
|
|
||||||
|
public CutPieceDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( CutPiece cutPiece ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", cutPiece.getId() )
|
||||||
|
.addValue( "job_card_item_id", cutPiece.getJobCardItemId() )
|
||||||
|
.addValue( "type", cutPiece.getType() )
|
||||||
|
.addValue( "quantity", cutPiece.getQuantity() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public CutPiece find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new CutPieceRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new CutPiece() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<CutPiece> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( CutPiece cutPiece ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( cutPiece );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( cutPiece.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<CutPiece> cutPieces ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( CutPiece cutPiece: cutPieces ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( cutPiece );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[cutPieces.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CutPiece> findByJobCardItemIds( List<Long> itemIds ){
|
||||||
|
if( itemIds == null || itemIds.isEmpty() )
|
||||||
|
return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("item_ids", itemIds );
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_ITEM_IDS, params, new CutPieceRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteByItemId( long jobCardItemId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("job_card_item_id", jobCardItemId );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_BY_ITEM_ID , params ) > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.CutPiece;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class CutPieceRowMapper implements RowMapper<CutPiece>{
|
||||||
|
public CutPiece mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
CutPiece cutPiece = new CutPiece();
|
||||||
|
cutPiece.setId( rs.getLong( "id" ) );
|
||||||
|
cutPiece.setJobCardItemId( rs.getLong( "job_card_item_id" ) );
|
||||||
|
cutPiece.setType( rs.getString( "type" ) );
|
||||||
|
cutPiece.setQuantity( rs.getBigDecimal( "quantity" ) );
|
||||||
|
return cutPiece;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.CutPieceType;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class CutPieceTypeDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.cut_piece_type";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title) VALUES (:id, :title) ON DUPLICATE KEY UPDATE title = VALUES(title)", TABLE_NAME );
|
||||||
|
|
||||||
|
public CutPieceTypeDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( CutPieceType cutPieceType ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", cutPieceType.getId() )
|
||||||
|
.addValue( "title", cutPieceType.getTitle() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public CutPieceType find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new CutPieceTypeRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new CutPieceType() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<CutPieceType> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( CutPieceType cutPieceType ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( cutPieceType );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( cutPieceType.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<CutPieceType> cutPieceTypes ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( CutPieceType cutPieceType: cutPieceTypes ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( cutPieceType );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[cutPieceTypes.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.CutPieceType;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class CutPieceTypeRowMapper implements RowMapper<CutPieceType> {
|
||||||
|
public CutPieceType mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
CutPieceType cutPieceType = new CutPieceType();
|
||||||
|
cutPieceType.setId( rs.getLong( "id" ) );
|
||||||
|
cutPieceType.setTitle( rs.getString( "title" ) );
|
||||||
|
return cutPieceType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.FinishedItem;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class FinishedItemDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.finished_item";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, stitched_item_id, is_segregated, qa_status) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :stitched_item_id, :is_segregated, :qa_status) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), stitched_item_id = VALUES(stitched_item_id), is_segregated = VALUES(is_segregated), qa_status = VALUES(qa_status)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated ORDER BY ID DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_STITCHED_ITEM_ID = String.format( "SELECT * FROM %s WHERE stitched_item_id = :stitched_item_id", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_STITCHED_ITEM_IDS = String.format( "SELECT * FROM %s WHERE stitched_item_id IN (:stitched_item_ids)", TABLE_NAME );
|
||||||
|
|
||||||
|
public FinishedItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( FinishedItem finishedItem ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", finishedItem.getId() )
|
||||||
|
.addValue( "item_id", finishedItem.getItemId() )
|
||||||
|
.addValue( "sku", finishedItem.getSku() )
|
||||||
|
.addValue( "barcode", finishedItem.getBarcode() )
|
||||||
|
.addValue( "created_at", finishedItem.getCreatedAt() )
|
||||||
|
.addValue( "created_by", finishedItem.getCreatedBy() )
|
||||||
|
.addValue("job_card_id", finishedItem.getJobCardId() )
|
||||||
|
.addValue("is_qa", finishedItem.getIsQa() )
|
||||||
|
.addValue("stitched_item_id", finishedItem.getStitchedItemId() )
|
||||||
|
.addValue("is_segregated", finishedItem.getIsSegregated() )
|
||||||
|
.addValue("qa_status", finishedItem.getQaStatus() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public FinishedItem find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new FinishedItemRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new FinishedItem() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<FinishedItem> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new FinishedItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( FinishedItem finishedItem ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( finishedItem );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( finishedItem.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<FinishedItem> finishedItems ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( FinishedItem finishedItem: finishedItems ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( finishedItem );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[finishedItems.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinishedItem> findByLimit(Long count ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "limit",count );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT , params, new FinishedItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinishedItem> findByQuery(String query ){
|
||||||
|
return namedParameterJdbcTemplate.query( query, new FinishedItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinishedItem> findByIds(List<Long> ids ){
|
||||||
|
if( ids == null || ids.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new FinishedItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinishedItem> findByTerm( String term , boolean isSegregated ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("term", "%" + term + "%" );
|
||||||
|
params.addValue("is_segregated", isSegregated );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_TERM , params, new FinishedItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public FinishedItem findByStitchedItem( long stitchedItemId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("stitched_item_id", stitchedItemId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_STITCHED_ITEM_ID , params, new FinishedItemRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( null );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinishedItem> findByStitchedItemIds( List<Long> stitchedItemIds ){
|
||||||
|
if( stitchedItemIds == null || stitchedItemIds.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("stitched_item_ids", stitchedItemIds );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_STITCHED_ITEM_IDS, params, new FinishedItemRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.FinishedItem;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class FinishedItemRowMapper implements RowMapper<FinishedItem> {
|
||||||
|
public FinishedItem mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
FinishedItem finishedItem = new FinishedItem();
|
||||||
|
finishedItem.setId( rs.getLong( "id" ) );
|
||||||
|
finishedItem.setItemId( rs.getLong( "item_id" ) );
|
||||||
|
finishedItem.setSku( rs.getString( "sku" ) );
|
||||||
|
finishedItem.setBarcode( rs.getString( "barcode" ) );
|
||||||
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
|
finishedItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
finishedItem.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
finishedItem.setJobCardId( rs.getLong("job_card_id") );
|
||||||
|
finishedItem.setIsQa( rs.getBoolean("is_qa"));
|
||||||
|
finishedItem.setStitchedItemId( rs.getLong("stitched_item_id" ) );
|
||||||
|
finishedItem.setIsSegregated( rs.getBoolean( "is_segregated") );
|
||||||
|
finishedItem.setQaStatus( rs.getString("qa_status" ) );
|
||||||
|
return finishedItem;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryAccount;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class InventoryAccountDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.inventory_account";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title, parent_entity_type, parent_entity_id, active, created_by, created_at, location_site_id, notes, is_packaging) VALUES (:id, :title, :parent_entity_type, :parent_entity_id, :active, :created_by, :created_at, :location_site_id, :notes, :is_packaging) ON DUPLICATE KEY UPDATE title = VALUES(title), parent_entity_type = VALUES(parent_entity_type), parent_entity_id = VALUES(parent_entity_id), active = VALUES(active), created_by = VALUES(created_by), created_at = VALUES(created_at), location_site_id = VALUES(location_site_id), notes = VALUES(notes), is_packaging = VALUES(is_packaging)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS_AND_PARENT_ID = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND parent_entity_id = :parent_entity_id", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS_AND_PARENT_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND parent_entity_id IN (:parent_entity_ids)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS_AND_PARENT_ENTITY_TYPE_AND_PARENT_ID_AND_COUNT = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND parent_entity_id = :parent_entity_id AND parent_entity_type = :parent_entity_type LIMIT :limit", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS_PACKAGING_AND_COUNT = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND is_packaging = :is_packaging LIMIT :limit", TABLE_NAME );
|
||||||
|
|
||||||
|
public InventoryAccountDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( InventoryAccount inventoryAccount ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", inventoryAccount.getId() )
|
||||||
|
.addValue( "title", inventoryAccount.getTitle() )
|
||||||
|
.addValue( "parent_entity_type", inventoryAccount.getParentEntityType() )
|
||||||
|
.addValue( "parent_entity_id", inventoryAccount.getParentEntityId() )
|
||||||
|
.addValue( "active", inventoryAccount.getActive() )
|
||||||
|
.addValue( "created_by", inventoryAccount.getCreatedBy() )
|
||||||
|
.addValue( "created_at", inventoryAccount.getCreatedAt() )
|
||||||
|
.addValue( "location_site_id", inventoryAccount.getLocationSiteId() )
|
||||||
|
.addValue( "notes", inventoryAccount.getNotes() )
|
||||||
|
.addValue("is_packaging", inventoryAccount.getIsPackaging() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public InventoryAccount find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new InventoryAccountRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new InventoryAccount() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<InventoryAccount> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( InventoryAccount inventoryAccount ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( inventoryAccount );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( inventoryAccount.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<InventoryAccount> inventoryAccounts ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( InventoryAccount inventoryAccount: inventoryAccounts ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( inventoryAccount );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[inventoryAccounts.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryAccount> findByIds( List<Long> accountIds ){
|
||||||
|
if( accountIds == null || accountIds.isEmpty() ){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "ids", accountIds );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS, params, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryAccount> findByIdsAndProcessId( List<Long> accountIds, Long processId ){
|
||||||
|
if( accountIds == null || accountIds.isEmpty() ){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "ids", accountIds );
|
||||||
|
params.addValue( "parent_entity_id", processId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS_AND_PARENT_ID, params, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryAccount> findByIdsAndProcessIds( List<Long> accountIds, List<Long> processIds ){
|
||||||
|
if( accountIds == null || accountIds.isEmpty() || processIds == null || processIds.isEmpty() ){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "ids", accountIds );
|
||||||
|
params.addValue( "parent_entity_ids", processIds );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS_AND_PARENT_IDS, params, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryAccount> findByIdsAndParentTypeAndIdAndLimit( List<Long> accountIds, Long count , String parentEntityType, String parentEntityId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids" , accountIds );
|
||||||
|
params.addValue("limit", count );
|
||||||
|
params.addValue("parent_entity_type", parentEntityType );
|
||||||
|
params.addValue("parent_entity_id", parentEntityId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS_AND_PARENT_ENTITY_TYPE_AND_PARENT_ID_AND_COUNT, params, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryAccount> findByIdsAndPackagingAndIdAndLimit( List<Long> accountIds, Long count, boolean isPackaging ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids" , accountIds );
|
||||||
|
params.addValue("is_packaging", isPackaging );
|
||||||
|
params.addValue("limit", count );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS_PACKAGING_AND_COUNT, params, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryAccount> findByQuery( String query ){
|
||||||
|
return namedParameterJdbcTemplate.query( query, new InventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryAccount;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InventoryAccountRowMapper implements RowMapper<InventoryAccount> {
|
||||||
|
public InventoryAccount mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
InventoryAccount inventoryAccount = new InventoryAccount();
|
||||||
|
inventoryAccount.setId( rs.getLong( "id" ) );
|
||||||
|
inventoryAccount.setTitle( rs.getString( "title" ) );
|
||||||
|
inventoryAccount.setParentEntityType( rs.getString( "parent_entity_type" ) );
|
||||||
|
inventoryAccount.setParentEntityId( rs.getLong( "parent_entity_id" ) );
|
||||||
|
inventoryAccount.setActive( rs.getBoolean( "active" ) );
|
||||||
|
inventoryAccount.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
|
inventoryAccount.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
inventoryAccount.setLocationSiteId( rs.getInt( "location_site_id" ) );
|
||||||
|
inventoryAccount.setNotes( rs.getString( "notes" ) );
|
||||||
|
inventoryAccount.setIsPackaging( rs.getBoolean("is_packaging" ) );
|
||||||
|
return inventoryAccount;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryTransaction;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class InventoryTransactionDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.inventory_transaction";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, transaction_datetime, generated_by, notes) VALUES (:id, :transaction_datetime, :generated_by, :notes) ON DUPLICATE KEY UPDATE transaction_datetime = VALUES(transaction_datetime), generated_by = VALUES(generated_by), notes = VALUES(notes)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
|
||||||
|
public InventoryTransactionDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( InventoryTransaction inventoryTransaction ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", inventoryTransaction.getId() )
|
||||||
|
.addValue( "transaction_datetime", inventoryTransaction.getTransactionDateTime() )
|
||||||
|
.addValue( "generated_by", inventoryTransaction.getGeneratedBy() )
|
||||||
|
.addValue( "notes", inventoryTransaction.getNotes() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public InventoryTransaction find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new InventoryTransactionRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new InventoryTransaction() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<InventoryTransaction> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new InventoryTransactionRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( InventoryTransaction inventoryTransaction ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( inventoryTransaction );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( inventoryTransaction.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<InventoryTransaction> inventoryTransactions ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( InventoryTransaction inventoryTransaction: inventoryTransactions ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( inventoryTransaction );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[inventoryTransactions.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryTransaction> findByIds( List<Long> ids ){
|
||||||
|
if( ids == null || ids.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS, params, new InventoryTransactionRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,156 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventorySummary;
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryTransactionLeg;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class InventoryTransactionLegDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.inventory_transaction_leg";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, transaction_id, item_id, sku, type, quantity, account_id, balance, transaction_leg_datetime, parent_document_type, parent_document_id, parent_document_piece_type) VALUES (:id, :transaction_id, :item_id, :sku, :type, :quantity, :account_id, :balance, :transaction_leg_datetime, :parent_document_type, :parent_document_id, :parent_document_piece_type) ON DUPLICATE KEY UPDATE transaction_id = VALUES(transaction_id), item_id = VALUES(item_id), sku = VALUES(sku), type = VALUES(type), quantity = VALUES(quantity), account_id = VALUES(account_id), balance = VALUES(balance), transaction_leg_datetime = VALUES(transaction_leg_datetime), parent_document_type = VALUES(parent_document_type), parent_document_id = VALUES(parent_document_id), parent_document_piece_type = VALUES(parent_document_piece_type)", TABLE_NAME );
|
||||||
|
private final String SELECT_LAST_ACCOUNT_ID_AND_ITEM_ID = String.format( "SELECT * FROM %s WHERE account_id = :account_id AND item_id = :item_id AND parent_document_type= :parent_document_type AND parent_document_piece_type = :parent_document_piece_type ORDER BY id DESC LIMIT 1", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_ACCOUNT_ID = String.format( "SELECT * FROM %s WHERE account_id = :account_id ORDER BY id DESC" , TABLE_NAME );
|
||||||
|
private final String SELECT_SUMMARY_BY_ACCOUNT_ID = String.format( "SELECT item_id, sku, parent_document_type,parent_document_piece_type," +
|
||||||
|
" SUM(CASE WHEN type = 'IN' THEN quantity WHEN type = 'OUT' THEN -quantity ELSE 0 END) AS balance" +
|
||||||
|
" FROM %s" +
|
||||||
|
" WHERE account_id = :account_id" +
|
||||||
|
" GROUP BY item_id, parent_document_type, parent_document_piece_type", TABLE_NAME );
|
||||||
|
|
||||||
|
private final String SELECT_LAST_LEG_BY_TYPE_AND_PARENT_ID = String.format( "SELECT itl.* FROM %s itl" +
|
||||||
|
" JOIN (" +
|
||||||
|
" SELECT parent_document_id, parent_document_type, MAX(id) AS max_id" +
|
||||||
|
" FROM %s" +
|
||||||
|
" WHERE type = :type" +
|
||||||
|
" AND parent_document_id IN (:parent_ids)" +
|
||||||
|
" GROUP BY parent_document_id,parent_document_type )" +
|
||||||
|
" last_in_transaction" +
|
||||||
|
" ON itl.parent_document_id = last_in_transaction.parent_document_id" +
|
||||||
|
" AND itl.id = last_in_transaction.max_id" +
|
||||||
|
" AND itl.parent_document_type = last_in_transaction.parent_document_type" +
|
||||||
|
" WHERE itl.type = :type" +
|
||||||
|
" AND itl.parent_document_type = :parent_document_type"
|
||||||
|
, TABLE_NAME, TABLE_NAME );
|
||||||
|
|
||||||
|
public InventoryTransactionLegDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( InventoryTransactionLeg inventoryTransactionLeg ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", inventoryTransactionLeg.getId() )
|
||||||
|
.addValue( "transaction_id", inventoryTransactionLeg.getTransactionId() )
|
||||||
|
.addValue( "item_id", inventoryTransactionLeg.getItemId() )
|
||||||
|
.addValue( "sku", inventoryTransactionLeg.getSku() )
|
||||||
|
.addValue( "type", inventoryTransactionLeg.getType() )
|
||||||
|
.addValue( "quantity", inventoryTransactionLeg.getQuantity() )
|
||||||
|
.addValue( "account_id", inventoryTransactionLeg.getAccountId() )
|
||||||
|
.addValue( "balance", inventoryTransactionLeg.getBalance() )
|
||||||
|
.addValue( "transaction_leg_datetime", inventoryTransactionLeg.getTransactionLegDateTime() )
|
||||||
|
.addValue( "parent_document_type", inventoryTransactionLeg.getParentDocumentType() )
|
||||||
|
.addValue( "parent_document_id", inventoryTransactionLeg.getParentDocumentId() )
|
||||||
|
.addValue("parent_document_piece_type", inventoryTransactionLeg.getParentDocumentPieceType() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public InventoryTransactionLeg find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new InventoryTransactionLegRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new InventoryTransactionLeg() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<InventoryTransactionLeg> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new InventoryTransactionLegRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( InventoryTransactionLeg inventoryTransactionLeg ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( inventoryTransactionLeg );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( inventoryTransactionLeg.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<InventoryTransactionLeg> inventoryTransactionLegs ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( InventoryTransactionLeg inventoryTransactionLeg: inventoryTransactionLegs ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( inventoryTransactionLeg );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[inventoryTransactionLegs.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryTransactionLeg findLastByAccountIdAndItemIdAndParentType( long accountId,
|
||||||
|
long itemId,
|
||||||
|
String parentType,
|
||||||
|
String pieceType ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "account_id", accountId );
|
||||||
|
params.addValue("item_id", itemId );
|
||||||
|
params.addValue("parent_document_type", parentType );
|
||||||
|
params.addValue("parent_document_piece_type", pieceType );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_LAST_ACCOUNT_ID_AND_ITEM_ID, params, new InventoryTransactionLegRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new InventoryTransactionLeg() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryTransactionLeg> findByAccountId( long accountId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "account_id", accountId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_ACCOUNT_ID, params, new InventoryTransactionLegRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventorySummary> findSummaryByAccountId( long accountId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("account_id", accountId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_SUMMARY_BY_ACCOUNT_ID, params, (rs, i) -> {
|
||||||
|
InventorySummary summary = new InventorySummary();
|
||||||
|
summary.setItemId( rs.getLong("item_id" ) );
|
||||||
|
summary.setSku( rs.getString( "sku") );
|
||||||
|
summary.setParentDocumentType( rs.getString("parent_document_type" ) );
|
||||||
|
summary.setParentDocumentType( rs.getString("parent_document_type" ) );
|
||||||
|
summary.setPieceType( rs.getString("parent_document_piece_type") );
|
||||||
|
summary.setBalance( rs.getBigDecimal( "balance" ));
|
||||||
|
return summary;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryTransactionLeg> findLastTransactionByParentIdAndParentType( String type , List<Long> parentIds , String parentType){
|
||||||
|
if ( parentIds == null || parentIds.isEmpty() ){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("type", type );
|
||||||
|
params.addValue("parent_ids", parentIds );
|
||||||
|
params.addValue("parent_document_type", parentType );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_LAST_LEG_BY_TYPE_AND_PARENT_ID , params, new InventoryTransactionLegRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryTransactionLeg;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InventoryTransactionLegRowMapper implements RowMapper<InventoryTransactionLeg> {
|
||||||
|
public InventoryTransactionLeg mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
InventoryTransactionLeg inventoryTransactionLeg = new InventoryTransactionLeg();
|
||||||
|
inventoryTransactionLeg.setId( rs.getLong( "id" ) );
|
||||||
|
inventoryTransactionLeg.setTransactionId( rs.getLong( "transaction_id" ) );
|
||||||
|
inventoryTransactionLeg.setItemId( rs.getLong( "item_id" ) );
|
||||||
|
inventoryTransactionLeg.setSku( rs.getString( "sku" ) );
|
||||||
|
inventoryTransactionLeg.setType( rs.getString( "type" ) );
|
||||||
|
inventoryTransactionLeg.setQuantity( rs.getBigDecimal( "quantity" ) );
|
||||||
|
inventoryTransactionLeg.setAccountId( rs.getInt( "account_id" ) );
|
||||||
|
inventoryTransactionLeg.setBalance( rs.getBigDecimal( "balance" ) );
|
||||||
|
if ( rs.getTimestamp( "transaction_leg_datetime" ) != null ) {
|
||||||
|
inventoryTransactionLeg.setTransactionLegDateTime( rs.getTimestamp( "transaction_leg_datetime" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
inventoryTransactionLeg.setParentDocumentType( rs.getString( "parent_document_type" ) );
|
||||||
|
inventoryTransactionLeg.setParentDocumentId( rs.getLong( "parent_document_id" ) );
|
||||||
|
inventoryTransactionLeg.setParentDocumentPieceType( rs.getString("parent_document_piece_type"));
|
||||||
|
return inventoryTransactionLeg;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.InventoryTransaction;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InventoryTransactionRowMapper implements RowMapper<InventoryTransaction> {
|
||||||
|
public InventoryTransaction mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
InventoryTransaction inventoryTransaction = new InventoryTransaction();
|
||||||
|
inventoryTransaction.setId( rs.getLong( "id" ) );
|
||||||
|
if ( rs.getTimestamp( "transaction_datetime" ) != null ) {
|
||||||
|
inventoryTransaction.setTransactionDateTime( rs.getTimestamp( "transaction_datetime" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
inventoryTransaction.setGeneratedBy( rs.getString( "generated_by" ) );
|
||||||
|
inventoryTransaction.setNotes( rs.getString( "notes" ) );
|
||||||
|
return inventoryTransaction;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.JobCard;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class JobCardDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.job_card";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, code, job_order_id, created_at, created_by, status, inventory_status, customer, lot_number, purchase_order_id, location_site_id, description) VALUES (:id, :code, :job_order_id, :created_at, :created_by, :status, :inventory_status, :customer, :lot_number, :purchase_order_id, :location_site_id, :description) ON DUPLICATE KEY UPDATE code = VALUES(code), job_order_id = VALUES(job_order_id), created_at = VALUES(created_at), created_by = VALUES(created_by), status = VALUES(status), inventory_status = VALUES(inventory_status), customer = VALUES(customer), lot_number = VALUES(lot_number), purchase_order_id = VALUES(purchase_order_id), location_site_id = VALUES(location_site_id), description = VALUES(description)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_LIKE_CODE_AND_INV_STATUS_AND_STATUS = String.format( "SELECT * FROM %s WHERE code like :code AND status = :status AND inventory_status = :inventory_status", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_LIKE_CODE = String.format( "SELECT * FROM %s WHERE code like :code", TABLE_NAME );
|
||||||
|
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( JobCard jobCard ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", jobCard.getId() )
|
||||||
|
.addValue("code", jobCard.getCode() )
|
||||||
|
.addValue( "job_order_id", jobCard.getJobOrderId() )
|
||||||
|
.addValue( "created_at", jobCard.getCreatedAt() )
|
||||||
|
.addValue( "created_by", jobCard.getCreatedBy() )
|
||||||
|
.addValue("status", jobCard.getStatus() )
|
||||||
|
.addValue("inventory_status", jobCard.getInventoryStatus() )
|
||||||
|
.addValue("customer", jobCard.getCustomer() )
|
||||||
|
.addValue("lot_number", jobCard.getLotNumber() )
|
||||||
|
.addValue("purchase_order_id", jobCard.getPurchaseOrderId() )
|
||||||
|
.addValue("location_site_id", jobCard.getLocationSiteId() )
|
||||||
|
.addValue("description", jobCard.getDescription() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public JobCard find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new JobCardRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new JobCard() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<JobCard> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new JobCardRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( JobCard jobCard ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( jobCard );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( jobCard.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<JobCard> jobCards ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( JobCard jobCard: jobCards ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( jobCard );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[jobCards.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobCard> findLikeCode( String code ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("code", "%" + code + "%");
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_LIKE_CODE, params, new JobCardRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobCard> findLikeCode( String code , String inventoryStatus, String status ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "code", "%" + code + "%" );
|
||||||
|
params.addValue("inventory_status", inventoryStatus );
|
||||||
|
params.addValue("status", status );
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_LIKE_CODE_AND_INV_STATUS_AND_STATUS, params, new JobCardRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.JobCardItem;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class JobCardItemDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.job_card_item";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_CARD_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :card_id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, job_card_id, item_id, sku, expected_production_quantity, total_production) VALUES (:id, :job_card_id, :item_id, :sku, :expected_production_quantity, :total_production) ON DUPLICATE KEY UPDATE job_card_id = VALUES(job_card_id), item_id = VALUES(item_id), sku = VALUES(sku), expected_production_quantity = VALUES(expected_production_quantity), total_production = VALUES(total_production)", TABLE_NAME );
|
||||||
|
|
||||||
|
public JobCardItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( JobCardItem jobCardItem ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", jobCardItem.getId() )
|
||||||
|
.addValue( "job_card_id", jobCardItem.getJobCardId() )
|
||||||
|
.addValue( "item_id", jobCardItem.getItemId() )
|
||||||
|
.addValue( "sku", jobCardItem.getSku() )
|
||||||
|
.addValue( "expected_production_quantity", jobCardItem.getExpectedProductionQuantity() )
|
||||||
|
.addValue("total_production", jobCardItem.getTotalProduction() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public JobCardItem find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new JobCardItemRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new JobCardItem() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<JobCardItem> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new JobCardItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( JobCardItem jobCardItem ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( jobCardItem );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( jobCardItem.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<JobCardItem> jobCardItems ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( JobCardItem jobCardItem: jobCardItems ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( jobCardItem );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[jobCardItems.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobCardItem> findByCardId( long cardId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "card_id", cardId );
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_CARD_ID, params, new JobCardItemRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.JobCardItem;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class JobCardItemRowMapper implements RowMapper<JobCardItem> {
|
||||||
|
public JobCardItem mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
JobCardItem jobCardItem = new JobCardItem();
|
||||||
|
jobCardItem.setId( rs.getLong( "id" ) );
|
||||||
|
jobCardItem.setJobCardId( rs.getLong( "job_card_id" ) );
|
||||||
|
jobCardItem.setItemId( rs.getLong( "item_id" ) );
|
||||||
|
jobCardItem.setSku( rs.getString( "sku" ) );
|
||||||
|
jobCardItem.setExpectedProductionQuantity( rs.getBigDecimal( "expected_production_quantity" ) );
|
||||||
|
jobCardItem.setTotalProduction( rs.getBigDecimal("total_production" ) );
|
||||||
|
return jobCardItem;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.JobCard;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class JobCardRowMapper implements RowMapper<JobCard> {
|
||||||
|
public JobCard mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
JobCard jobCard = new JobCard();
|
||||||
|
jobCard.setId( rs.getLong( "id" ) );
|
||||||
|
jobCard.setCode( rs.getString("code" ));
|
||||||
|
jobCard.setJobOrderId( rs.getLong( "job_order_id" ) );
|
||||||
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
|
jobCard.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
jobCard.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
jobCard.setStatus( rs.getString("status" ));
|
||||||
|
jobCard.setInventoryStatus( rs.getString("inventory_status"));
|
||||||
|
jobCard.setCustomer( rs.getString("customer") );
|
||||||
|
jobCard.setLotNumber( rs.getString("lot_number") );
|
||||||
|
jobCard.setPurchaseOrderId( rs.getLong("purchase_order_id") );
|
||||||
|
jobCard.setLocationSiteId( rs.getLong("location_site_id" ) );
|
||||||
|
jobCard.setDescription( rs.getString("description" ) );
|
||||||
|
return jobCard;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.MasterBundle;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class MasterBundleDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.master_bundle";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, barcode,item_id, sku, created_by, created_at, job_card_id, is_received) VALUES (:id, :barcode, :item_id, :sku, :created_by, :created_at, :job_card_id, :is_received) ON DUPLICATE KEY UPDATE barcode = VALUES(barcode), item_id = VALUES(item_id), sku = VALUES(sku), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), is_received = VALUES(is_received)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_TERM_AND_RECEIVED = String.format( "SELECT * FROM %s WHERE is_received = :is_received AND ( id LIKE :id OR barcode LIKE :barcode ) ", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
|
||||||
|
|
||||||
|
public MasterBundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( MasterBundle masterBundle ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", masterBundle.getId() )
|
||||||
|
.addValue( "barcode", masterBundle.getBarcode() )
|
||||||
|
.addValue( "item_id", masterBundle.getItemId() )
|
||||||
|
.addValue( "sku", masterBundle.getSku() )
|
||||||
|
.addValue( "created_by", masterBundle.getCreatedBy() )
|
||||||
|
.addValue( "created_at", masterBundle.getCreatedAt() )
|
||||||
|
.addValue( "job_card_id", masterBundle.getJobCardId() )
|
||||||
|
.addValue("is_received", masterBundle.getIsReceived() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public MasterBundle find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new MasterBundleRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new MasterBundle() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<MasterBundle> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new MasterBundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( MasterBundle masterBundle ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( masterBundle );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( masterBundle.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<MasterBundle> masterBundles ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( MasterBundle masterBundle: masterBundles ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( masterBundle );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[masterBundles.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MasterBundle> findByQuery(String query ){
|
||||||
|
return namedParameterJdbcTemplate.query( query, new MasterBundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MasterBundle> findByLimit( Long count ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "limit",count );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT , params, new MasterBundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MasterBundle> findByTermAndNotReceived( String term , boolean received ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id" , term );
|
||||||
|
params.addValue("barcode", "%" + term + "%" );
|
||||||
|
params.addValue("is_received", received );
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_TERM_AND_RECEIVED, params, new MasterBundleRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MasterBundle> findByIds( List<Long> ids ){
|
||||||
|
if( ids == null || ids.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new MasterBundleRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.MasterBundle;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class MasterBundleRowMapper implements RowMapper<MasterBundle> {
|
||||||
|
public MasterBundle mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
MasterBundle masterBundle = new MasterBundle();
|
||||||
|
masterBundle.setId( rs.getLong( "id" ) );
|
||||||
|
masterBundle.setBarcode( rs.getString( "barcode" ) );
|
||||||
|
masterBundle.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
masterBundle.setItemId( rs.getLong("item_id" ));
|
||||||
|
masterBundle.setSku( rs.getString("sku" ) );
|
||||||
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
|
masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
masterBundle.setJobCardId( rs.getLong( "job_card_id" ) );
|
||||||
|
masterBundle.setIsReceived( rs.getBoolean("is_received" ));
|
||||||
|
return masterBundle;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Process;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ProcessDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.process";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id ASC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title, notes) VALUES (:id, :title, :notes) ON DUPLICATE KEY UPDATE title = VALUES(title), notes = VALUES(notes)", TABLE_NAME );
|
||||||
|
|
||||||
|
public ProcessDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( Process process ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", process.getId() )
|
||||||
|
.addValue( "title", process.getTitle() )
|
||||||
|
.addValue( "notes", process.getNotes() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public Process find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new ProcessRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new Process() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<Process> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new ProcessRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( Process process ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( process );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( process.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<Process> processs ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( Process process: processs ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( process );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[processs.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.Process;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class ProcessRowMapper implements RowMapper<Process> {
|
||||||
|
public Process mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
Process process = new Process();
|
||||||
|
process.setId( rs.getLong( "id" ) );
|
||||||
|
process.setTitle( rs.getString( "title" ) );
|
||||||
|
process.setNotes( rs.getString( "notes" ) );
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class StitchingOfflineItemDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.stitching_offline_item";
|
||||||
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, qa_remarks, qa_status) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), qa_remarks = VALUES(qa_remarks), qa_status = VALUES(qa_status)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term ORDER BY ID DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
||||||
|
|
||||||
|
public StitchingOfflineItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams(StitchingOfflineItem stitchingOfflineItem ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", stitchingOfflineItem.getId() )
|
||||||
|
.addValue( "item_id", stitchingOfflineItem.getItemId() )
|
||||||
|
.addValue( "sku", stitchingOfflineItem.getSku() )
|
||||||
|
.addValue( "barcode", stitchingOfflineItem.getBarcode() )
|
||||||
|
.addValue( "created_at", stitchingOfflineItem.getCreatedAt() )
|
||||||
|
.addValue( "created_by", stitchingOfflineItem.getCreatedBy() )
|
||||||
|
.addValue("job_card_id", stitchingOfflineItem.getJobCardId() )
|
||||||
|
.addValue("is_qa", stitchingOfflineItem.getIsQa() )
|
||||||
|
.addValue("qa_remarks", stitchingOfflineItem.getQaRemarks() )
|
||||||
|
.addValue("qa_status", stitchingOfflineItem.getQaStatus() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public StitchingOfflineItem find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new StitchingOfflineItemRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new StitchingOfflineItem() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<StitchingOfflineItem> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new StitchingOfflineItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( StitchingOfflineItem finishedItem ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( finishedItem );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( finishedItem.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<StitchingOfflineItem> stitchingOfflineItems ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( StitchingOfflineItem stitchingOfflineItem: stitchingOfflineItems ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( stitchingOfflineItem );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[stitchingOfflineItems.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StitchingOfflineItem> findByLimit(Long count ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "limit",count );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT , params, new StitchingOfflineItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StitchingOfflineItem> findByQuery(String query ){
|
||||||
|
return namedParameterJdbcTemplate.query( query, new StitchingOfflineItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StitchingOfflineItem> findByIds(List<Long> ids ){
|
||||||
|
if( ids == null || ids.isEmpty() ) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new StitchingOfflineItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StitchingOfflineItem> findByTerm( String term ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("term", "%" + term + "%" );
|
||||||
|
// params.addValue("is_qa", isQa );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_TERM , params, new StitchingOfflineItemRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StitchingOfflineItem> findByMasterId( long masterId ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("job_card_id", masterId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_MASTER_ID , params, new StitchingOfflineItemRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class StitchingOfflineItemRowMapper implements RowMapper<StitchingOfflineItem> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StitchingOfflineItem mapRow(ResultSet rs, int i) throws SQLException {
|
||||||
|
StitchingOfflineItem stitchingOfflineItem = new StitchingOfflineItem();
|
||||||
|
stitchingOfflineItem.setId( rs.getLong( "id" ) );
|
||||||
|
stitchingOfflineItem.setItemId( rs.getLong( "item_id" ) );
|
||||||
|
stitchingOfflineItem.setSku( rs.getString( "sku" ) );
|
||||||
|
stitchingOfflineItem.setBarcode( rs.getString( "barcode" ) );
|
||||||
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
|
stitchingOfflineItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
stitchingOfflineItem.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
stitchingOfflineItem.setJobCardId( rs.getLong("job_card_id") );
|
||||||
|
stitchingOfflineItem.setIsQa( rs.getBoolean("is_qa"));
|
||||||
|
stitchingOfflineItem.setQaStatus( rs.getString("qa_status" ) );
|
||||||
|
stitchingOfflineItem.setQaRemarks( rs.getString("qa_remarks") );
|
||||||
|
return stitchingOfflineItem;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.User;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class UserDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.users";
|
||||||
|
private final String SELECT_BY_USERNAME = String.format( "SELECT * FROM %s WHERE username = :username", TABLE_NAME );
|
||||||
|
private final String FIND_ALL_QUERY = String.format( "SELECT * FROM %s", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (username, password, enabled) VALUES (:username, :password, :enabled ) ON DUPLICATE KEY UPDATE username = :username, password = :password, enabled = :enabled", TABLE_NAME );
|
||||||
|
|
||||||
|
public UserDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams(User user ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "username", user.getUsername() )
|
||||||
|
.addValue( "password", user.getPassword() )
|
||||||
|
.addValue( "enabled", user.getEnabled() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User findByUsername(String username ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "username", username );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_USERNAME, params, new UserRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findAny()
|
||||||
|
.orElse( new User() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<User> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( FIND_ALL_QUERY, new UserRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public int save( User user ){
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( user );
|
||||||
|
return namedParameterJdbcTemplate.update( INSERT_QUERY, params );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<User> userss ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( User users: userss ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( users );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[userss.size()]) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.UserInventoryAccount;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class UserInventoryAccountDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.user_inventory_account";
|
||||||
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY username DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_USERNAME_QUERY = String.format( "SELECT * FROM %s WHERE username = :username ORDER BY username DESC", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_AUTHORITY_QUERY = String.format( "SELECT * FROM %s WHERE account_id = :account_id ORDER BY username DESC", TABLE_NAME );
|
||||||
|
private final String INSERT_QUERY =String.format("INSERT INTO %s (username,account_id) VALUES (:username,:account_id)",TABLE_NAME);
|
||||||
|
private final String DELETE_QUERY=String.format("DELETE FROM %s WHERE username = :username",TABLE_NAME);
|
||||||
|
private final String SELECT_BY_USERNAMES = String.format("SELECT * FROM %s WHERE username IN (:usernames)" , TABLE_NAME );
|
||||||
|
|
||||||
|
public UserInventoryAccountDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prepare query params
|
||||||
|
* */
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams( UserInventoryAccount userInventoryAccount ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("username", userInventoryAccount.getUsername() );
|
||||||
|
params.addValue("account_id", userInventoryAccount.getAccountId() );
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find all
|
||||||
|
*/
|
||||||
|
public List<UserInventoryAccount> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new UserInventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find by username
|
||||||
|
*/
|
||||||
|
public List<UserInventoryAccount> findByUsername( String username ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "username", username );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_USERNAME_QUERY, params, new UserInventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find by authority
|
||||||
|
*/
|
||||||
|
public List<UserInventoryAccount> findByAccountId( long accountId ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "account_id", accountId );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_AUTHORITY_QUERY, params, new UserInventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find by username
|
||||||
|
* */
|
||||||
|
public List<UserInventoryAccount> findByUsernames( List<String> usernames ) {
|
||||||
|
if( usernames == null || usernames.isEmpty() ) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "usernames", usernames );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_USERNAMES, params, new UserInventoryAccountRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* delete by username
|
||||||
|
* */
|
||||||
|
public boolean deleteByUsername( String username ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "username", username );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<UserInventoryAccount> userInventoryAccounts ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( UserInventoryAccount userInventoryAccount: userInventoryAccounts ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( userInventoryAccount );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[userInventoryAccounts.size()]) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.UserInventoryAccount;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class UserInventoryAccountRowMapper implements RowMapper<UserInventoryAccount> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserInventoryAccount mapRow(ResultSet resultSet, int i) throws SQLException {
|
||||||
|
UserInventoryAccount userInventoryAccount = new UserInventoryAccount();
|
||||||
|
userInventoryAccount.setUsername( resultSet.getString("username") );
|
||||||
|
userInventoryAccount.setAccountId( resultSet.getInt("account_id" ) );
|
||||||
|
return userInventoryAccount;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.User;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class UserRowMapper implements RowMapper<User> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User mapRow(ResultSet rs, int i ) throws SQLException {
|
||||||
|
User user = new User();
|
||||||
|
user.setUsername( rs.getString( "username" ) );
|
||||||
|
user.setPassword( rs.getString( "password" ) );
|
||||||
|
user.setEnabled( rs.getBoolean( "enabled" ) );
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,401 @@
|
||||||
|
package com.utopiaindustries.dao.uind;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import com.utopiaindustries.model.uind.Item;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ItemDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "inventory.item";
|
||||||
|
private final String SELECT_QUERY = String.format("SELECT * FROM %s WHERE id = :id", TABLE_NAME);
|
||||||
|
private final String SELECT_NOT_IN_IDS = String.format("SELECT * FROM %s WHERE id NOT IN (:ids)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_TYPE_QUERY = String.format("SELECT * FROM %s WHERE type_id IN (:type_id)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_SKU_TITLE_TYPE_QUERY_AND_IS_ACTIVE = String.format("SELECT * FROM %s WHERE (title LIKE :title OR sku LIKE :title) AND is_active = :is_active AND type_id IN (:type_ids)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_CATEGORY_QUERY =
|
||||||
|
String.format("SELECT * FROM %s WHERE category_id = :category_id OR subcategory_one_id = :category_id OR subcategory_two_id = :category_id", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_POSITION_CATEGORIES_QUERY =
|
||||||
|
String.format("SELECT * FROM %s WHERE category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_POSITION_CATEGORIES_QUERY_TOP_N_ROWS =
|
||||||
|
String.format("SELECT * FROM %s WHERE category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids) ORDER BY id DESC LIMIT :no_rows ",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_BY_POSITION_CATEGORIES_AND_ITEM_REQUEST_ID_QUERY_TOP_N_ROWS = String.format(
|
||||||
|
"SELECT * FROM %s WHERE (category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids)) AND item_request_id != 0 ORDER BY id DESC LIMIT :no_rows ",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_BY_POSITION_CATEGORIES_AND_ITEM_IDS_QUERY =
|
||||||
|
String.format("SELECT * FROM %s WHERE category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids) AND id IN (:ids) ORDER BY id DESC",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_BY_CATEGORY_IDS = String.format("SELECT * FROM %s WHERE category_id IN (:category_ids)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_CATEGORY_DEPARTMENT_QUERY = String.format(
|
||||||
|
"SELECT * FROM %s WHERE department_id = :department_id AND (category_id = :category_id OR subcategory_one_id = :category_id OR subcategory_two_id = :category_id)",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_IDS_AND_ACTIVE = String.format("SELECT * FROM %s WHERE id IN (:ids) AND is_active = 1 ", TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_TITLE_AND_STATUS_QUERY = String.format("SELECT * FROM %s WHERE is_active = :is_active AND title LIKE :title ORDER BY title ASC", TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_TITLE_BY_DEPARTMENT_QUERY =
|
||||||
|
String.format("SELECT * FROM %s WHERE department_id = :department_id AND title LIKE :title ORDER BY title ASC", TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_TITLE = String.format("SELECT * FROM %s WHERE title LIKE :item_title", TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_TITLE_BY_POSITION_CATEGORIES_QUERY = String.format(
|
||||||
|
"SELECT * FROM %s WHERE title LIKE :title AND (category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids)) ORDER BY title ASC",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_TITLE_SKU_BY_POSITION_CATEGORIES_AND_ACTIVE_QUERY = String.format(
|
||||||
|
"SELECT * FROM %s WHERE is_active = :is_active AND (title LIKE :title OR sku LIKE :title) AND (category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids)) ORDER BY title ASC",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_TITLE_SKU_BY_POSITION_CATEGORIES_AND_ACTIVE_AND_TYPE_IDS_QUERY = String.format(
|
||||||
|
"SELECT * FROM %s WHERE is_active = :is_active AND (title LIKE :title OR sku LIKE :title) AND (category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids)) AND type_id IN (:type_ids) ORDER BY title ASC LIMIT :limit",
|
||||||
|
TABLE_NAME);
|
||||||
|
private final String SELECT_EQUALS_SKU_QUERY = String.format("SELECT * FROM %s WHERE sku = :sku ORDER BY title ASC", TABLE_NAME);
|
||||||
|
private final String SELECT_EQUALS_IN_SKU_QUERY = String.format("SELECT * FROM %s WHERE sku IN (:skus) ORDER BY title ASC", TABLE_NAME);
|
||||||
|
private final String SELECT_ALL_QUERY = String.format("SELECT * FROM %s ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String DELETE_QUERY = String.format("DELETE FROM %s WHERE id = :id", TABLE_NAME);
|
||||||
|
private final String INSERT_QUERY = String.format(
|
||||||
|
"INSERT INTO %s (id, title, short_title, description, spec1, spec2, spec3, spec4, spec5, brand, year, model, unit_id, company_id, function_id, department_id, section_id, type_id, category_id, subcategory_one_id, subcategory_two_id, code, item_request_id, minimum_level, dead_level, storage_location_site_id, storage_location_unit_id, storage_location_floor_id, storage_location_store_id, storage_location_shelf_id, date_added, requested_by_user, added_by_user, is_active, hs_code, image_url, approval_status, approved_by, approved_date, remarks, request_date_time, material_type, measurement, origin, is_sku_system_generated, sku, is_updated, last_audit_date, last_audit_updated_by) VALUES (:id, :title, :short_title, :description, :spec1, :spec2, :spec3, :spec4, :spec5, :brand, :year, :model, :unit_id, :company_id, :function_id, :department_id, :section_id, :type_id, :category_id, :subcategory_one_id, :subcategory_two_id, :code, :item_request_id, :minimum_level, :dead_level, :storage_location_site_id, :storage_location_unit_id, :storage_location_floor_id, :storage_location_store_id, :storage_location_shelf_id, :date_added, :requested_by_user, :added_by_user, :is_active, :hs_code, :image_url, :approval_status, :approved_by, :approved_date, :remarks, :request_date_time, :material_type, :measurement, :origin, :is_sku_system_generated, :sku, :is_updated, :last_audit_date, :last_audit_updated_by) ON DUPLICATE KEY UPDATE title = :title, short_title = :short_title, description = :description, spec1 = :spec1, spec2 = :spec2, spec3 = :spec3, spec4 = :spec4, spec5 = :spec5, brand = :brand, year = :year, model = :model, unit_id = :unit_id, company_id = :company_id, function_id = :function_id, department_id = :department_id, section_id = :section_id, type_id = :type_id, category_id = :category_id, subcategory_one_id = :subcategory_one_id, subcategory_two_id = :subcategory_two_id, code = :code, item_request_id = :item_request_id, minimum_level = :minimum_level, dead_level = :dead_level, storage_location_site_id = :storage_location_site_id, storage_location_unit_id = :storage_location_unit_id, storage_location_floor_id = :storage_location_floor_id, storage_location_store_id = :storage_location_store_id, storage_location_shelf_id = :storage_location_shelf_id, date_added = :date_added, requested_by_user = :requested_by_user, added_by_user = :added_by_user, is_active = :is_active, hs_code = :hs_code, image_url = :image_url, approval_status = :approval_status, approved_by = :approved_by, approved_date = :approved_date, remarks = :remarks, request_date_time = :request_date_time, material_type = :material_type, measurement = :measurement, origin = :origin, is_sku_system_generated = :is_sku_system_generated, sku = :sku, is_updated = :is_updated, last_audit_date = :last_audit_date, last_audit_updated_by = :last_audit_updated_by", TABLE_NAME);
|
||||||
|
|
||||||
|
private final String SELECT_LIKE_TITLE_AND_SITE_ID_BY_POSITION_CATEGORIES_QUERY = String.format(
|
||||||
|
"SELECT * FROM %s WHERE title LIKE :title AND storage_location_site_id =:storage_location_site_id AND (category_id IN (:position_category_ids) OR subcategory_one_id IN (:position_category_ids)) ORDER BY title ASC",
|
||||||
|
TABLE_NAME);
|
||||||
|
|
||||||
|
public ItemDAO(@Qualifier("namedParameterJdbcTemplateUind") NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams(Item item) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", item.getId())
|
||||||
|
.addValue("title", item.getTitle())
|
||||||
|
.addValue("short_title", item.getShortTitle())
|
||||||
|
.addValue("description", item.getDescription())
|
||||||
|
.addValue("spec1", item.getSpec1())
|
||||||
|
.addValue("spec2", item.getSpec2())
|
||||||
|
.addValue("spec3", item.getSpec3())
|
||||||
|
.addValue("spec4", item.getSpec4())
|
||||||
|
.addValue("spec5", item.getSpec5())
|
||||||
|
.addValue("brand", item.getBrand())
|
||||||
|
.addValue("year", item.getYear())
|
||||||
|
.addValue("model", item.getModel())
|
||||||
|
.addValue("unit_id", item.getUnitId())
|
||||||
|
.addValue("company_id", item.getCompanyId())
|
||||||
|
.addValue("function_id", item.getFunctionId())
|
||||||
|
.addValue("department_id", item.getDepartmentId())
|
||||||
|
.addValue("section_id", item.getSectionId())
|
||||||
|
.addValue("type_id", item.getTypeId())
|
||||||
|
.addValue("category_id", item.getCategoryId())
|
||||||
|
.addValue("subcategory_one_id", item.getSubcategoryOneId())
|
||||||
|
.addValue("subcategory_two_id", item.getSubcategoryTwoId())
|
||||||
|
.addValue("code", item.getCode())
|
||||||
|
.addValue("item_request_id", item.getItemRequestId())
|
||||||
|
.addValue("minimum_level", item.getMinimumLevel())
|
||||||
|
.addValue("dead_level", item.getDeadLevel())
|
||||||
|
.addValue("storage_location_site_id", item.getStorageLocationSiteId())
|
||||||
|
.addValue("storage_location_unit_id", item.getStorageLocationUnitId())
|
||||||
|
.addValue("storage_location_floor_id", item.getStorageLocationFloorId())
|
||||||
|
.addValue("storage_location_store_id", item.getStorageLocationStoreId())
|
||||||
|
.addValue("storage_location_shelf_id", item.getStorageLocationShelfId())
|
||||||
|
.addValue("date_added", item.getDateAdded())
|
||||||
|
.addValue("requested_by_user", item.getRequestedByUser())
|
||||||
|
.addValue("added_by_user", item.getAddedByUser())
|
||||||
|
.addValue("is_active", item.getIsActive())
|
||||||
|
.addValue("hs_code", item.getHsCode())
|
||||||
|
.addValue("image_url", item.getImageUrl())
|
||||||
|
.addValue("approval_status", item.getApprovalStatus())
|
||||||
|
.addValue("approved_by", item.getApprovedBy())
|
||||||
|
.addValue("approved_date", item.getApprovedDate())
|
||||||
|
.addValue("remarks", item.getRemarks())
|
||||||
|
.addValue("request_date_time", item.getRequestDateTime())
|
||||||
|
.addValue("material_type", item.getMaterialType())
|
||||||
|
.addValue("measurement", item.getMeasurement())
|
||||||
|
.addValue("origin", item.getOrigin())
|
||||||
|
.addValue("is_sku_system_generated", item.getIsSkuSystemGenerated())
|
||||||
|
.addValue("is_updated", item.getIsUpdated())
|
||||||
|
.addValue("sku", item.getSku())
|
||||||
|
.addValue("last_audit_date", item.getLastAuditDate())
|
||||||
|
.addValue("last_audit_updated_by", item.getLastAuditUpdateBy());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public Item find(long id) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", id);
|
||||||
|
List<Item> items = namedParameterJdbcTemplate.query(SELECT_QUERY, params, new ItemRowMapper());
|
||||||
|
if (items.size() > 0) {
|
||||||
|
return items.get(0);
|
||||||
|
} else {
|
||||||
|
return new Item();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find not in
|
||||||
|
public List<Item> findNotIn(List<Long> ids) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_NOT_IN_IDS, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<Item> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_ALL_QUERY, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by ids
|
||||||
|
public List<Item> findByIds(Collection<Long> ids) {
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
Map params = Collections.singletonMap("ids", ids);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_IDS, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by type
|
||||||
|
public List<Item> findByTypeId(long typeId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("type_id", typeId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_TYPE_QUERY, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by category
|
||||||
|
public List<Item> findByCategoryId(long categoryId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("category_id", categoryId);
|
||||||
|
params.addValue("subcategory_one_id", categoryId);
|
||||||
|
params.addValue("subcategory_two_id", categoryId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_CATEGORY_QUERY, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by category ids
|
||||||
|
public List<Item> findByCategoryIds(List<Long> categoryIds) {
|
||||||
|
if (!categoryIds.isEmpty()) {
|
||||||
|
Map params = Collections.singletonMap("category_ids", categoryIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_CATEGORY_IDS, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by position category ids
|
||||||
|
public List<Item> findByByPositionCategories(List<Long> positionCategoryIds) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_POSITION_CATEGORIES_QUERY, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by position category ids with row limit
|
||||||
|
public List<Item> findByByPositionCategoriesRowLimit(List<Long> positionCategoryIds, long rowLimit) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
params.addValue("no_rows", rowLimit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_POSITION_CATEGORIES_QUERY_TOP_N_ROWS, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by position category ids and item request id with row limit
|
||||||
|
public List<Item> findByByPositionCategoriesAndItemRequestIdRowLimit(List<Long> positionCategoryIds, long rowLimit) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
params.addValue("no_rows", rowLimit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_POSITION_CATEGORIES_AND_ITEM_REQUEST_ID_QUERY_TOP_N_ROWS, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find by department
|
||||||
|
public List<Item> findByCategoryAndDepartmentId(long categoryId, long department) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("department_id", department);
|
||||||
|
params.addValue("category_id", categoryId);
|
||||||
|
params.addValue("subcategory_one_id", categoryId);
|
||||||
|
params.addValue("subcategory_two_id", categoryId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_CATEGORY_DEPARTMENT_QUERY, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all like title (active only)
|
||||||
|
public List<Item> findLikeTitleAndStatus(String title, boolean active) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("is_active", active);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_AND_STATUS_QUERY, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all like title and department
|
||||||
|
public List<Item> findLikeTitleAndDepartmentId(String title, long departmentId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("department_id", departmentId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_BY_DEPARTMENT_QUERY, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Item> findLikeTitle(String title) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("item_title", "%" + title + "%");
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all like title and departmental categories
|
||||||
|
public List<Item> findLikeTitleByPositionAuthorizedCategories(String title, List<Long> positionCategoryIds) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_BY_POSITION_CATEGORIES_QUERY, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Item> findLikeTitleByPositionAuthorizedCategories(String title, List<Long> positionCategoryIds, String isActive) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("sku", "%" + title + "%");
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
params.addValue("is_active", isActive);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_SKU_BY_POSITION_CATEGORIES_AND_ACTIVE_QUERY, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Item> findLikeTitleByPositionAuthorizedCategoriesAndTypeIds(String title, List<Long> positionCategoryIds, String isActive, List<Long> itemTypeIds, Long limit) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("sku", "%" + title + "%");
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
params.addValue("is_active", isActive);
|
||||||
|
params.addValue("type_ids", itemTypeIds);
|
||||||
|
params.addValue("limit", limit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_SKU_BY_POSITION_CATEGORIES_AND_ACTIVE_AND_TYPE_IDS_QUERY, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//find by type id and active
|
||||||
|
public List<Item> findBySkuOrTitleAndTypeIdAndActive(String title, List<Long> itemTypeIds, String isActive) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("sku", "%" + title + "%");
|
||||||
|
params.addValue("is_active", isActive);
|
||||||
|
params.addValue("type_ids", itemTypeIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_SKU_TITLE_TYPE_QUERY_AND_IS_ACTIVE, params, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by query
|
||||||
|
public List<Item> findByQuery(String customQuery) {
|
||||||
|
return namedParameterJdbcTemplate.query(customQuery, new ItemRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save(Item item) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams(item);
|
||||||
|
namedParameterJdbcTemplate.update(INSERT_QUERY, params, keyHolder);
|
||||||
|
return KeyHolderFunctions.getKey(item.getId(), keyHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll(List<Item> items) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for (Item item : items) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams(item);
|
||||||
|
batchArgs.add(params);
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate(INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[items.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete(long id) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", id);
|
||||||
|
return namedParameterJdbcTemplate.update(DELETE_QUERY, params) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by position category ids with row limit and item ids
|
||||||
|
public List<Item> findByByPositionCategoriesAndItemIdsRowLimit(List<Long> positionCategoryIds, List<Long> itemIds) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
params.addValue("ids", itemIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_POSITION_CATEGORIES_AND_ITEM_IDS_QUERY, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all equals title
|
||||||
|
public Item findEqualsSkuAndActiveOrNot(String sku, boolean active) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("sku", sku);
|
||||||
|
params.addValue("is_active", active);
|
||||||
|
List<Item> items = namedParameterJdbcTemplate.query(SELECT_EQUALS_SKU_QUERY, params, new ItemRowMapper());
|
||||||
|
if (items.size() > 0) {
|
||||||
|
return items.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all equals title
|
||||||
|
public List<Item> findEqualsINSkus(List<String> skus, boolean active) {
|
||||||
|
if (skus.size() > 0) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("skus", skus);
|
||||||
|
params.addValue("is_active", active);
|
||||||
|
List<Item> items = namedParameterJdbcTemplate.query(SELECT_EQUALS_IN_SKU_QUERY, params, new ItemRowMapper());
|
||||||
|
if (items.size() > 0) {
|
||||||
|
return items;
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// find By Title and SiteId
|
||||||
|
public List<Item> findLikeTitleByPositionAuthorizedCategoriesAndSiteId(String title, List<Long> positionCategoryIds, Long siteId) {
|
||||||
|
if (positionCategoryIds != null && !positionCategoryIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", "%" + title + "%");
|
||||||
|
params.addValue("position_category_ids", positionCategoryIds);
|
||||||
|
params.addValue("storage_location_site_id", siteId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_AND_SITE_ID_BY_POSITION_CATEGORIES_QUERY, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find only active Items
|
||||||
|
public List<Item> findItemsActiveOnly(Collection<Long> ids) {
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
Map params = Collections.singletonMap("ids", ids);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_IDS_AND_ACTIVE, params, new ItemRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.utopiaindustries.dao.uind;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.uind.Item;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
|
||||||
|
public class ItemRowMapper implements RowMapper<Item> {
|
||||||
|
public Item mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
|
||||||
|
Item item = new Item();
|
||||||
|
item.setId(rs.getLong("id"));
|
||||||
|
item.setTitle(rs.getString("title"));
|
||||||
|
item.setShortTitle(rs.getString("short_title"));
|
||||||
|
item.setDescription(rs.getString("description"));
|
||||||
|
item.setSpec1(rs.getString("spec1"));
|
||||||
|
item.setSpec2(rs.getString("spec2"));
|
||||||
|
item.setSpec3(rs.getString("spec3"));
|
||||||
|
item.setSpec4(rs.getString("spec4"));
|
||||||
|
item.setSpec5(rs.getString("spec5"));
|
||||||
|
item.setBrand(rs.getString("brand"));
|
||||||
|
item.setYear(rs.getString("year"));
|
||||||
|
item.setModel(rs.getString("model"));
|
||||||
|
item.setUnitId(rs.getLong("unit_id"));
|
||||||
|
item.setCompanyId(rs.getLong("company_id"));
|
||||||
|
item.setFunctionId(rs.getLong("function_id"));
|
||||||
|
item.setDepartmentId(rs.getLong("department_id"));
|
||||||
|
Long sectionId = rs.getLong("section_id");
|
||||||
|
if (rs.wasNull()) {
|
||||||
|
sectionId = null;
|
||||||
|
}
|
||||||
|
item.setSectionId(sectionId);
|
||||||
|
item.setTypeId(rs.getLong("type_id"));
|
||||||
|
item.setCategoryId(rs.getLong("category_id"));
|
||||||
|
item.setSubcategoryOneId(rs.getLong("subcategory_one_id"));
|
||||||
|
item.setSubcategoryTwoId(rs.getLong("subcategory_two_id"));
|
||||||
|
item.setCode(rs.getString("code"));
|
||||||
|
item.setItemRequestId(rs.getLong("item_request_id"));
|
||||||
|
item.setMinimumLevel(rs.getLong("minimum_level"));
|
||||||
|
item.setDeadLevel(rs.getLong("dead_level"));
|
||||||
|
item.setStorageLocationSiteId(rs.getLong("storage_location_site_id"));
|
||||||
|
item.setStorageLocationUnitId(rs.getLong("storage_location_unit_id"));
|
||||||
|
item.setStorageLocationFloorId(rs.getLong("storage_location_floor_id"));
|
||||||
|
item.setStorageLocationStoreId(rs.getLong("storage_location_store_id"));
|
||||||
|
Long locationShelfId = rs.getLong("storage_location_shelf_id");
|
||||||
|
if (rs.wasNull()) {
|
||||||
|
locationShelfId = null;
|
||||||
|
}
|
||||||
|
item.setStorageLocationShelfId(locationShelfId);
|
||||||
|
if (rs.getDate("date_added") != null) {
|
||||||
|
item.setDateAdded(rs.getDate("date_added").toLocalDate());
|
||||||
|
}
|
||||||
|
item.setRequestedByUser(rs.getString("requested_by_user"));
|
||||||
|
item.setAddedByUser(rs.getString("added_by_user"));
|
||||||
|
item.setIsActive(rs.getBoolean("is_active"));
|
||||||
|
item.setHsCode(rs.getString("hs_code"));
|
||||||
|
item.setImageUrl(rs.getString("image_url"));
|
||||||
|
item.setApprovalStatus(rs.getString("approval_status"));
|
||||||
|
item.setApprovedBy(rs.getString("approved_by"));
|
||||||
|
if (rs.getTimestamp("approved_date") != null) {
|
||||||
|
item.setApprovedDate(rs.getTimestamp("approved_date").toLocalDateTime());
|
||||||
|
}
|
||||||
|
item.setRemarks(rs.getString("remarks"));
|
||||||
|
if (rs.getTimestamp("request_date_time") != null) {
|
||||||
|
item.setRequestDateTime(rs.getTimestamp("request_date_time").toLocalDateTime());
|
||||||
|
}
|
||||||
|
item.setMaterialType(rs.getString("material_type"));
|
||||||
|
item.setMeasurement(rs.getString("measurement"));
|
||||||
|
item.setOrigin(rs.getString("origin"));
|
||||||
|
item.setIsSkuSystemGenerated(rs.getBoolean("is_sku_system_generated"));
|
||||||
|
item.setIsUpdated(rs.getBoolean("is_updated"));
|
||||||
|
item.setSku(rs.getString("sku"));
|
||||||
|
if (rs.getTimestamp("last_audit_date") != null) {
|
||||||
|
item.setLastAuditDate(rs.getTimestamp("last_audit_date").toLocalDateTime());
|
||||||
|
}
|
||||||
|
item.setLastAuditUpdateBy(rs.getString("last_audit_updated_by"));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.utopiaindustries.dao.uind;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import com.utopiaindustries.model.uind.LocationSite;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class LocationSiteDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "inventory.location_site";
|
||||||
|
private final String SELECT_QUERY = String.format("SELECT * FROM %s WHERE id = :id", TABLE_NAME);
|
||||||
|
private final String SELECT_ALL_QUERY = String.format("SELECT * FROM %s ORDER BY title ASC", TABLE_NAME);
|
||||||
|
private final String DELETE_QUERY = String.format("DELETE FROM %s WHERE id = :id", TABLE_NAME);
|
||||||
|
private final String INSERT_QUERY = String.format("INSERT INTO %s (id, title, short_title, address, has_colony) VALUES (:id, :title, :short_title, :address, :has_colony) ON DUPLICATE KEY UPDATE title = :title, short_title = :short_title, address = :address, has_colony = :has_colony", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_IDS_QUERY = String.format("SELECT * FROM %s WHERE id IN ( :ids ) order by id asc", TABLE_NAME);
|
||||||
|
|
||||||
|
public LocationSiteDAO(@Qualifier("namedParameterJdbcTemplateUind") NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams(LocationSite locationSite) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", locationSite.getId())
|
||||||
|
.addValue("title", locationSite.getTitle())
|
||||||
|
.addValue("short_title", locationSite.getShortTitle())
|
||||||
|
.addValue("address", locationSite.getAddress())
|
||||||
|
.addValue("has_colony", locationSite.getHasColony());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public LocationSite find(long id) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", id);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_QUERY, params, new LocationSiteRowMapper())
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new LocationSite() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<LocationSite> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_ALL_QUERY, new LocationSiteRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save(LocationSite locationSite) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams(locationSite);
|
||||||
|
namedParameterJdbcTemplate.update(INSERT_QUERY, params, keyHolder);
|
||||||
|
return KeyHolderFunctions.getKey(locationSite.getId(), keyHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll(List<LocationSite> locationSites) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for (LocationSite locationSite : locationSites) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams(locationSite);
|
||||||
|
batchArgs.add(params);
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate(INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[locationSites.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete(long id) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", id);
|
||||||
|
return namedParameterJdbcTemplate.update(DELETE_QUERY, params) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by ids
|
||||||
|
public List<LocationSite> findByIds(Set<Long> ids) {
|
||||||
|
if (ids != null && !ids.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_IDS_QUERY, params, new LocationSiteRowMapper());
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by ids
|
||||||
|
public List<LocationSite> findByLongIds(List<Long> ids) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_IDS_QUERY, params, new LocationSiteRowMapper());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.utopiaindustries.dao.uind;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.uind.LocationSite;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class LocationSiteRowMapper implements RowMapper<LocationSite> {
|
||||||
|
public LocationSite mapRow(ResultSet rs, int rowNum ) throws SQLException {
|
||||||
|
LocationSite locationSite = new LocationSite();
|
||||||
|
locationSite.setId( rs.getLong( "id" ) );
|
||||||
|
locationSite.setTitle( rs.getString( "title" ) );
|
||||||
|
locationSite.setShortTitle( rs.getString( "short_title" ) );
|
||||||
|
locationSite.setAddress( rs.getString( "address" ) );
|
||||||
|
locationSite.setHasColony( rs.getBoolean("has_colony") );
|
||||||
|
return locationSite;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,411 @@
|
||||||
|
package com.utopiaindustries.dao.uind;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.uind.PurchaseOrder;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class PurchaseOrderDAO {
|
||||||
|
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "inventory.purchase_order";
|
||||||
|
private final String SELECT_QUERY = String.format("SELECT * FROM %s WHERE id = :id", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_SUPPLIER_QUERY = String.format("SELECT * FROM %s WHERE supplier_id = :supplier_id", TABLE_NAME);
|
||||||
|
private final String SELECT_WITH_MAIN_PAYMENT_TERM_IDS_AND_NOT_IN_ID_QUERY = String.format("SELECT * FROM %s WHERE id NOT IN (:ids) AND main_payment_term_id IN (:payment_term_ids) and management_status = :management_status AND user_status != :user_status", TABLE_NAME);
|
||||||
|
private final String SELECT_LATEST_PO_NON_DRAFTED = String.format("SELECT * FROM %s WHERE id IN (:ids) AND user_status != :user_status ORDER BY id DESC LIMIT 1", TABLE_NAME);
|
||||||
|
private final String SELECT_WITH_MAIN_PAYMENT_TERM_IDS_AND_NOT_IN_ID_QUERY_ADVANCE_PAYMENT = String.format("SELECT * FROM %s WHERE id NOT IN (:ids) AND main_payment_term_id IN (:payment_term_ids) and management_status = :management_status AND user_status != :user_status AND DATE(date_generated) >= :st_date AND DATE(date_generated) <= :ed_date", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_SUPPLIER_AND_USER_STATUS_QUERY = String.format("SELECT * FROM %s WHERE supplier_id = :supplier_id AND user_status = :user_status", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_IDS_AND_MANAGEMENT_STATUS = String.format("SELECT * FROM %s WHERE id IN (:ids) AND management_status = :management_status", TABLE_NAME);
|
||||||
|
private final String SELECT_WITH_UNBILLED_CHARGES_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids) AND are_charges_paid = false", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_DEPARTMENT_QUERY = String.format("SELECT * FROM %s WHERE department_id = :department_id", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_FUNCTION_QUERY = String.format("SELECT * FROM %s WHERE function_id = :function_id", TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_CODE_QUERY = String.format("SELECT * FROM %s WHERE code LIKE :code", TABLE_NAME);
|
||||||
|
private final String SELECT_LIKE_CODE_BY_MANAGEMENT_STATUS_QUERY = String.format("SELECT * FROM %s WHERE code LIKE :code AND management_status = :management_status", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_USER_STATUS_QUERY = String.format("SELECT * FROM %s WHERE user_status = :user_status", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_USER_STATUS_AND_COMPLETED_QUERY = String.format("SELECT * FROM %s WHERE user_status = :user_status AND completed = :completed", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_MANAGEMENT_STATUS_QUERY = String.format("SELECT * FROM %s WHERE management_status = :management_status", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_MANAGEMENT_STATUS_QUERY_TOP_N = String.format("SELECT * FROM %s WHERE management_status = :management_status ORDER BY id DESC LIMIT :no_rows", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_INDENT_DIV_APPROVAL_QUERY_TOP_N = String.format("SELECT * FROM %s WHERE indenter_div_head_status = :indenter_div_head_status ORDER BY id DESC LIMIT :no_rows", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_MANAGEMENT_STATUS_AND_DATE_QUERY = String.format("SELECT * FROM %s WHERE management_status = :management_status AND date_generated >= :date_generated", TABLE_NAME);
|
||||||
|
private final String SELECT_APPROVAL_REQUESTS_QUERY = String.format("SELECT * FROM %s WHERE management_status = 'REVIEWING' OR management_status = 'ONHOLD'", TABLE_NAME);
|
||||||
|
private final String SELECT_APPROVAL_REQUESTS_QUERY_TOP_N = String.format("SELECT * FROM %s WHERE management_status = 'REVIEWING' OR management_status = 'ONHOLD' LIMIT :no_rows", TABLE_NAME);
|
||||||
|
private final String SELECT_INDENT_PO_APPROVAL_REQUESTS_QUERY_TOP_N = String.format("SELECT * FROM %s WHERE indenter_div_head_status = 'REVIEWING' OR indenter_div_head_status = 'ONHOLD' LIMIT :no_rows", TABLE_NAME);
|
||||||
|
private final String SELECT_COMPLETED_BY_SUPPLIER_QUERY = String.format("SELECT * FROM %s WHERE supplier_id = :supplier_id AND completed = 1", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_START_DATE_USER_STATUS_IN_PAYMENT_TERM_STATUS_QUERY = String.format("SELECT * FROM %s WHERE physical_date >= :start_date AND user_status = :user_status AND main_payment_term_id IN (:main_payment_term_ids) ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_USER_STATUS_IN_PAYMENT_TERM_STATUS_QUERY = String.format("SELECT * FROM %s WHERE user_status = :user_status AND main_payment_term_id IN (:main_payment_term_ids) ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_PAYMENT_TERMS_STATUS_QUERY = String.format("SELECT * FROM %s WHERE main_payment_term_id IN (:main_payment_term_ids) ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_PARENT_DOCUMENT_QUERY = String.format("SELECT * FROM %s WHERE parent_document_type = :parent_document_type AND parent_document_id = :parent_document_id", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_PARENT_DOCUMENTS_QUERY = String.format("SELECT * FROM %s WHERE parent_document_type = :parent_document_type AND parent_document_id IN (:parent_document_id)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_APPROVAL_DATE_RANGE_QUERY = String.format("SELECT * FROM %s WHERE DATE(approval_date) >= :start_date AND DATE(approval_date) <= :end_date ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String SELECT_ALL_QUERY = String.format("SELECT * FROM %s ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String SELECT_ALL_QUERY_TOP_N = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :no_rows", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_INDENT_GENERAL_IDS = String.format("SELECT * FROM %s WHERE parent_document_id IN (:parent_document_id)", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_INDENT_GENERAL_IDS_AND_LIMIT = String.format("SELECT * FROM %s WHERE parent_document_id IN (:parent_document_id) ORDER BY id ASC", TABLE_NAME);
|
||||||
|
private final String DELETE_QUERY = String.format("DELETE FROM %s WHERE id = :id", TABLE_NAME);
|
||||||
|
private final String INSERT_QUERY = String.format(
|
||||||
|
"INSERT INTO %s (id, code, date_generated, physical_date, approval_date, indenter_div_approval_date, generated_by_user, approved_by_user, indenter_div_approved_by, company_id, function_id, department_id, section_id, quotation_reference_number, quotation_date, supplier_id, broker_id, delivery_location_site_id, user_remarks, user_status, management_status, management_remarks, indenter_div_head_status, indenter_div_head_remarks, shipment_mode, currency_symbol, currency_conversion_rate, gst_amount, gst_amount_in_pkr, total_cost, total_cost_in_pkr, total_cost_in_words, total_cost_in_words_in_pkr, outstanding_advance_amount, amount_paid, main_payment_term_id, date_completed, termination_reason, parent_document_type, parent_document_code, parent_document_id, indent_id, completed, is_rated, is_locked, are_charges_paid, is_urgent, is_flagged) VALUES (:id, :code, :date_generated, :physical_date, :approval_date, :indenter_div_approval_date, :generated_by_user, :approved_by_user, :indenter_div_approved_by, :company_id, :function_id, :department_id, :section_id, :quotation_reference_number, :quotation_date, :supplier_id, :broker_id, :delivery_location_site_id, :user_remarks, :user_status, :management_status, :management_remarks, :indenter_div_head_status, :indenter_div_head_remarks, :shipment_mode, :currency_symbol, :currency_conversion_rate, :gst_amount, :gst_amount_in_pkr, :total_cost, :total_cost_in_pkr, :total_cost_in_words, :total_cost_in_words_in_pkr, :outstanding_advance_amount, :amount_paid, :main_payment_term_id, :date_completed, :termination_reason, :parent_document_type, :parent_document_code, :parent_document_id, :indent_id, :completed, :is_rated, :is_locked, :are_charges_paid, :is_urgent, :is_flagged) ON DUPLICATE KEY UPDATE code = :code, date_generated = :date_generated, physical_date = :physical_date, approval_date = :approval_date, indenter_div_approval_date = :indenter_div_approval_date, generated_by_user = :generated_by_user, approved_by_user = :approved_by_user, indenter_div_approved_by = :indenter_div_approved_by, company_id = :company_id, function_id = :function_id, department_id = :department_id, section_id = :section_id, quotation_reference_number = :quotation_reference_number, quotation_date = :quotation_date, supplier_id = :supplier_id, broker_id = :broker_id, delivery_location_site_id = :delivery_location_site_id, user_remarks = :user_remarks, user_status = :user_status, management_status = :management_status, management_remarks = :management_remarks, indenter_div_head_status = :indenter_div_head_status, indenter_div_head_remarks = :indenter_div_head_remarks, shipment_mode = :shipment_mode, currency_symbol = :currency_symbol, currency_conversion_rate = :currency_conversion_rate, gst_amount = :gst_amount, gst_amount_in_pkr = :gst_amount_in_pkr, total_cost = :total_cost, total_cost_in_pkr = :total_cost_in_pkr, total_cost_in_words = :total_cost_in_words, total_cost_in_words_in_pkr = :total_cost_in_words_in_pkr, outstanding_advance_amount = :outstanding_advance_amount, amount_paid = :amount_paid, main_payment_term_id = :main_payment_term_id, date_completed = :date_completed, termination_reason = :termination_reason, parent_document_type = :parent_document_type, parent_document_code = :parent_document_code, parent_document_id = :parent_document_id, indent_id = :indent_id, completed = :completed, is_rated = :is_rated, is_locked = :is_locked, are_charges_paid = :are_charges_paid, is_urgent = :is_urgent, is_flagged = :is_flagged",
|
||||||
|
TABLE_NAME
|
||||||
|
);
|
||||||
|
private final String SELECT_PURCHASE_ORDER_BY_INDENT_GENERAL_NOT_EXITS = String.format("SELECT * FROM %s WHERE parent_document_id IS NULL AND management_status = :management_status AND user_status != :user_status", TABLE_NAME);
|
||||||
|
// sum by supplier
|
||||||
|
private final String SELECT_ITEM_SUBTOTAL_SUM_BY_SUPPLIER_QUERY = String.format("SELECT po.supplier_id, SUM((item.unit_price_in_pkr * item.quantity) + item.gst_in_pkr) AS total FROM %s item LEFT JOIN %s po ON item.purchase_order_id = po.id GROUP BY po.supplier_id", "inventory.purchase_order_item", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_PO_IDS_AND_ISCOMPLETED = String.format("SELECT * FROM %s WHERE id IN (:id) AND completed = :completed AND management_status = :management_status ORDER BY id DESC", TABLE_NAME);
|
||||||
|
private final String SELECT_BY_GENERATED_BY_USER_AND_COMPANY_DETAILS_QUERY = String.format("SELECT * FROM %s WHERE generated_by_user = :generated_by_user AND company_id = :company_id AND function_id = :function_id AND department_id = :department_id AND section_id = :section_id", TABLE_NAME);
|
||||||
|
|
||||||
|
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE code LIKE :term", TABLE_NAME );
|
||||||
|
|
||||||
|
public PurchaseOrderDAO(@Qualifier("namedParameterJdbcTemplateUind") NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams(PurchaseOrder purchaseOrder) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", purchaseOrder.getId())
|
||||||
|
.addValue("code", purchaseOrder.getCode())
|
||||||
|
.addValue("date_generated", purchaseOrder.getDateGenerated())
|
||||||
|
.addValue("physical_date", purchaseOrder.getPhysicalDate())
|
||||||
|
.addValue("approval_date", purchaseOrder.getApprovalDate())
|
||||||
|
.addValue("indenter_div_approval_date", purchaseOrder.getIndentDivApprovalDate())
|
||||||
|
.addValue("generated_by_user", purchaseOrder.getGeneratedByUser())
|
||||||
|
.addValue("approved_by_user", purchaseOrder.getApprovedByUser())
|
||||||
|
.addValue("indenter_div_approved_by", purchaseOrder.getIndenterDivApprovedByUser())
|
||||||
|
.addValue("company_id", purchaseOrder.getCompanyId())
|
||||||
|
.addValue("function_id", purchaseOrder.getFunctionId())
|
||||||
|
.addValue("department_id", purchaseOrder.getDepartmentId())
|
||||||
|
.addValue("section_id", purchaseOrder.getSectionId())
|
||||||
|
.addValue("quotation_reference_number", purchaseOrder.getQuotationReferenceNumber())
|
||||||
|
.addValue("quotation_date", purchaseOrder.getQuotationDate())
|
||||||
|
.addValue("supplier_id", purchaseOrder.getSupplierId())
|
||||||
|
.addValue("broker_id", purchaseOrder.getBrokerId())
|
||||||
|
.addValue("delivery_location_site_id", purchaseOrder.getDeliveryLocationSiteId())
|
||||||
|
.addValue("user_remarks", purchaseOrder.getUserRemarks())
|
||||||
|
.addValue("user_status", purchaseOrder.getUserStatus())
|
||||||
|
.addValue("management_status", purchaseOrder.getManagementStatus())
|
||||||
|
.addValue("management_remarks", purchaseOrder.getManagementRemarks())
|
||||||
|
.addValue("indenter_div_head_status", purchaseOrder.getIndenterDivPoStatus())
|
||||||
|
.addValue("indenter_div_head_remarks", purchaseOrder.getIndenterDivPoRemarks())
|
||||||
|
.addValue("shipment_mode", purchaseOrder.getShipmentMode())
|
||||||
|
.addValue("currency_symbol", purchaseOrder.getCurrencySymbol())
|
||||||
|
.addValue("currency_conversion_rate", purchaseOrder.getCurrencyConversionRate())
|
||||||
|
.addValue("gst_amount", purchaseOrder.getGstAmount())
|
||||||
|
.addValue("gst_amount_in_pkr", purchaseOrder.getGstAmountInPkr())
|
||||||
|
.addValue("total_cost", purchaseOrder.getTotalCost())
|
||||||
|
.addValue("total_cost_in_pkr", purchaseOrder.getTotalCostInPkr())
|
||||||
|
.addValue("total_cost_in_words", purchaseOrder.getTotalCostInWords())
|
||||||
|
.addValue("total_cost_in_words_in_pkr", purchaseOrder.getTotalCostInWordsInPkr())
|
||||||
|
.addValue("outstanding_advance_amount", purchaseOrder.getOutstandingAdvanceAmount())
|
||||||
|
.addValue("amount_paid", purchaseOrder.getAmountPaid())
|
||||||
|
.addValue("main_payment_term_id", purchaseOrder.getMainPaymentTermId())
|
||||||
|
.addValue("date_completed", purchaseOrder.getDateCompleted())
|
||||||
|
.addValue("termination_reason", purchaseOrder.getTerminationReason())
|
||||||
|
.addValue("parent_document_type", purchaseOrder.getParentDocumentType())
|
||||||
|
.addValue("parent_document_code", purchaseOrder.getParentDocumentCode())
|
||||||
|
.addValue("parent_document_id", purchaseOrder.getParentDocumentId())
|
||||||
|
.addValue("indent_id", purchaseOrder.getIndentId())
|
||||||
|
.addValue("is_flagged", purchaseOrder.getIsFlagged());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public PurchaseOrder find(long id) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", id);
|
||||||
|
List<PurchaseOrder> purchaseOrders = namedParameterJdbcTemplate.query(SELECT_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
if (purchaseOrders.size() > 0) {
|
||||||
|
return purchaseOrders.get(0);
|
||||||
|
} else {
|
||||||
|
return new PurchaseOrder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by ids
|
||||||
|
public List<PurchaseOrder> findByIds(List<Long> ids) {
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
Map params = Collections.singletonMap("ids", ids);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_IDS, params, new PurchaseOrderRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// select by supplier
|
||||||
|
public List<PurchaseOrder> findBySupplierId(long supplierId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("supplier_id", supplierId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_SUPPLIER_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// select by supplier and user status
|
||||||
|
public List<PurchaseOrder> findBySupplierId(long supplierId, String userStatus) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("supplier_id", supplierId);
|
||||||
|
params.addValue("user_status", userStatus);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_SUPPLIER_AND_USER_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by ids
|
||||||
|
public List<PurchaseOrder> findByIdsAndManagementStatus(List<Long> ids, String managementStatus) {
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("ids", ids);
|
||||||
|
params.addValue("management_status", managementStatus);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_IDS_AND_MANAGEMENT_STATUS, params, new PurchaseOrderRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<PurchaseOrder> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_ALL_QUERY, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all by row limit
|
||||||
|
public List<PurchaseOrder> findAllByRowLimit(long row_limit) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("no_rows", row_limit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_ALL_QUERY_TOP_N, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by department id
|
||||||
|
public List<PurchaseOrder> findByDepartmentId(long departmentId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("department_id", departmentId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_DEPARTMENT_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by function id
|
||||||
|
public List<PurchaseOrder> findByFunctionId(long functionId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("function_id", functionId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_FUNCTION_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by management status
|
||||||
|
public List<PurchaseOrder> findByManagementStatus(String managementStatus) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("management_status", managementStatus);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_MANAGEMENT_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by management status limit by rows
|
||||||
|
public List<PurchaseOrder> findByManagementStatusRowLimit(String managementStatus, long row_limit) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("management_status", managementStatus);
|
||||||
|
params.addValue("no_rows", row_limit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_MANAGEMENT_STATUS_QUERY_TOP_N, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by management status limit by rows
|
||||||
|
public List<PurchaseOrder> findByIndentDivApprovalStatusRowLimit(String indenterDivStatus, long row_limit) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("indenter_div_head_status", indenterDivStatus);
|
||||||
|
params.addValue("no_rows", row_limit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_INDENT_DIV_APPROVAL_QUERY_TOP_N, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find PO by management status 'APPROVED' and greater equals date generated
|
||||||
|
public List<PurchaseOrder> findByManagementStatusAndDateGenerated(String managementStatus, String date) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("management_status", managementStatus);
|
||||||
|
params.addValue("date_generated", date);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_MANAGEMENT_STATUS_AND_DATE_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by user status
|
||||||
|
public List<PurchaseOrder> findByUserStatus(String userStatus) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("user_status", userStatus);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_USER_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by user status and completed status
|
||||||
|
public List<PurchaseOrder> findByUserStatusAndCompletedStatus(String userStatus, boolean completed) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("user_status", userStatus);
|
||||||
|
params.addValue("completed", completed);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_USER_STATUS_AND_COMPLETED_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by supplier id
|
||||||
|
public List<PurchaseOrder> findCompletedBySupplierId(long supplierId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("supplier_id", supplierId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_COMPLETED_BY_SUPPLIER_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find approval requests
|
||||||
|
public List<PurchaseOrder> findApprovalRequests() {
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_APPROVAL_REQUESTS_QUERY, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find approval requests by row limit
|
||||||
|
public List<PurchaseOrder> findApprovalRequestsByRowLimit(long row_limit) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("no_rows", row_limit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_APPROVAL_REQUESTS_QUERY_TOP_N, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find approval requests by row limit
|
||||||
|
public List<PurchaseOrder> findIndentPOApprovalRequestsByRowLimit(long row_limit) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("no_rows", row_limit);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_INDENT_PO_APPROVAL_REQUESTS_QUERY_TOP_N, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find like code
|
||||||
|
public List<PurchaseOrder> findLikeCode(String code) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("code", "%" + code + "%");
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_CODE_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find like code by management status
|
||||||
|
public List<PurchaseOrder> findLikeCodeByManagementStatus(String code, String managementStatus) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("code", "%" + code + "%");
|
||||||
|
params.addValue("management_status", managementStatus);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_CODE_BY_MANAGEMENT_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by query
|
||||||
|
public List<PurchaseOrder> findByQuery(String customQuery) {
|
||||||
|
return namedParameterJdbcTemplate.query(customQuery, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by user status in payment term
|
||||||
|
public List<PurchaseOrder> findByUserStatusInPaymentTerm(String userStatus, List<Long> paymentTermIds) {
|
||||||
|
if (!paymentTermIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("user_status", userStatus);
|
||||||
|
params.addValue("main_payment_term_ids", paymentTermIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_USER_STATUS_IN_PAYMENT_TERM_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by payment term
|
||||||
|
public List<PurchaseOrder> findByPaymentTerms(List<Long> paymentTermIds) {
|
||||||
|
if (!paymentTermIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("main_payment_term_ids", paymentTermIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_PAYMENT_TERMS_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by start date and user status in payment term
|
||||||
|
public List<PurchaseOrder> findByStartDateAndUserStatusInPaymentTerm(String startDate, String userStatus, List<Long> paymentTermIds) {
|
||||||
|
if (!paymentTermIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("start_date", startDate);
|
||||||
|
params.addValue("user_status", userStatus);
|
||||||
|
params.addValue("main_payment_term_ids", paymentTermIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_START_DATE_USER_STATUS_IN_PAYMENT_TERM_STATUS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find by parent documents
|
||||||
|
public List<PurchaseOrder> findByParentDocument(String parentDocumentType, long parentDocumentId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("parent_document_type", parentDocumentType);
|
||||||
|
params.addValue("parent_document_id", parentDocumentId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_PARENT_DOCUMENT_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PurchaseOrder> findByParentDocuments(String parentDocumentType, List<Long> parentIds) {
|
||||||
|
if (parentIds.isEmpty()) return new ArrayList<>();
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("parent_document_type", parentDocumentType);
|
||||||
|
params.addValue("parent_document_id", parentIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_PARENT_DOCUMENTS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by approval date range and management status
|
||||||
|
public List<PurchaseOrder> findByApprovalDateRange(String startDate, String endDate) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("start_date", startDate);
|
||||||
|
params.addValue("end_date", endDate);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_APPROVAL_DATE_RANGE_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save(PurchaseOrder purchaseOrder) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams(purchaseOrder);
|
||||||
|
namedParameterJdbcTemplate.update(INSERT_QUERY, params, keyHolder);
|
||||||
|
return KeyHolderFunctions.getKey(purchaseOrder.getId(), keyHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll(List<PurchaseOrder> purchaseOrders) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for (PurchaseOrder purchaseOrder : purchaseOrders) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams(purchaseOrder);
|
||||||
|
batchArgs.add(params);
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate(INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[purchaseOrders.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete(long id) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("id", id);
|
||||||
|
return namedParameterJdbcTemplate.update(DELETE_QUERY, params) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//get PO from indent general ids
|
||||||
|
public List<PurchaseOrder> findByIndentGeneralIds(List<Long> indentGeneralIds) {
|
||||||
|
if (!indentGeneralIds.isEmpty()) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("parent_document_id", indentGeneralIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_INDENT_GENERAL_IDS, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//get PO from indent general ids
|
||||||
|
public List<PurchaseOrder> findByIndentIds(List<Long> indentGeneralIds) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("parent_document_id", indentGeneralIds);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_INDENT_GENERAL_IDS_AND_LIMIT, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find by generated by user and company details
|
||||||
|
public List<PurchaseOrder> findByGeneratedByUserAndCompanyDetails(String username, long companyId, long functionId, long departmentId, long sectionId) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("generated_by_user", username)
|
||||||
|
.addValue("company_id", companyId)
|
||||||
|
.addValue("function_id", functionId)
|
||||||
|
.addValue("department_id", departmentId)
|
||||||
|
.addValue("section_id", sectionId);
|
||||||
|
return namedParameterJdbcTemplate.query(SELECT_BY_GENERATED_BY_USER_AND_COMPANY_DETAILS_QUERY, params, new PurchaseOrderRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find by term
|
||||||
|
* */
|
||||||
|
public List<PurchaseOrder> findByTerm( String term ){
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("term", "%" + term + "%" );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_TERM, params, new PurchaseOrderRowMapper() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.utopiaindustries.dao.uind;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.uind.PurchaseOrder;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class PurchaseOrderRowMapper implements RowMapper<PurchaseOrder> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PurchaseOrder mapRow(ResultSet rs, int i) throws SQLException {
|
||||||
|
PurchaseOrder purchaseOrder = new PurchaseOrder();
|
||||||
|
purchaseOrder.setId( rs.getLong( "id" ) );
|
||||||
|
purchaseOrder.setCode( rs.getString( "code" ) );
|
||||||
|
purchaseOrder.setDateGenerated( rs.getTimestamp( "date_generated" ).toLocalDateTime() );
|
||||||
|
if ( rs.getDate( "physical_date" ) != null ) {
|
||||||
|
purchaseOrder.setPhysicalDate( rs.getDate( "physical_date" ).toLocalDate() );
|
||||||
|
}
|
||||||
|
if ( rs.getTimestamp( "approval_date" ) != null ) {
|
||||||
|
purchaseOrder.setApprovalDate( rs.getTimestamp( "approval_date" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
if ( rs.getTimestamp( "indenter_div_approval_date" ) != null ) {
|
||||||
|
purchaseOrder.setIndentDivApprovalDate( rs.getTimestamp( "indenter_div_approval_date" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
purchaseOrder.setGeneratedByUser( rs.getString( "generated_by_user" ) );
|
||||||
|
purchaseOrder.setApprovedByUser( rs.getString( "approved_by_user" ) );
|
||||||
|
purchaseOrder.setIndenterDivApprovedByUser( rs.getString( "indenter_div_approved_by" ) );
|
||||||
|
purchaseOrder.setCompanyId( rs.getLong( "company_id" ) );
|
||||||
|
purchaseOrder.setFunctionId( rs.getLong( "function_id" ) );
|
||||||
|
purchaseOrder.setDepartmentId( rs.getLong( "department_id" ) );
|
||||||
|
purchaseOrder.setSectionId( rs.getLong( "section_id" ) );
|
||||||
|
purchaseOrder.setQuotationReferenceNumber( rs.getString( "quotation_reference_number" ) );
|
||||||
|
purchaseOrder.setQuotationDate( rs.getDate( "quotation_date" ).toLocalDate() );
|
||||||
|
purchaseOrder.setCurrencySymbol( rs.getString( "currency_symbol" ) );
|
||||||
|
Float currencyConversionRate = rs.getFloat( "currency_conversion_rate" );
|
||||||
|
if ( rs.wasNull() ) {
|
||||||
|
currencyConversionRate = null;
|
||||||
|
}
|
||||||
|
purchaseOrder.setCurrencyConversionRate( currencyConversionRate );
|
||||||
|
purchaseOrder.setGstAmount( rs.getFloat( "gst_amount" ) );
|
||||||
|
purchaseOrder.setGstAmountInPkr( rs.getFloat( "gst_amount_in_pkr" ) );
|
||||||
|
purchaseOrder.setTotalCost( rs.getFloat( "total_cost" ) );
|
||||||
|
purchaseOrder.setTotalCostInPkr( rs.getFloat( "total_cost_in_pkr" ) );
|
||||||
|
purchaseOrder.setTotalCostInWords( rs.getString( "total_cost_in_words" ) );
|
||||||
|
purchaseOrder.setTotalCostInWordsInPkr( rs.getString( "total_cost_in_words_in_pkr" ) );
|
||||||
|
purchaseOrder.setOutstandingAdvanceAmount( rs.getFloat( "outstanding_advance_amount" ) );
|
||||||
|
purchaseOrder.setAmountPaid( rs.getFloat( "amount_paid" ) );
|
||||||
|
purchaseOrder.setSupplierId( rs.getLong( "supplier_id" ) );
|
||||||
|
Long brokerId = rs.getLong( "broker_id" );
|
||||||
|
if ( rs.wasNull() ) {
|
||||||
|
brokerId = null;
|
||||||
|
}
|
||||||
|
purchaseOrder.setBrokerId( brokerId );
|
||||||
|
Long deliverySiteId = rs.getLong( "delivery_location_site_id" );
|
||||||
|
if ( rs.wasNull() ) {
|
||||||
|
deliverySiteId = null;
|
||||||
|
}
|
||||||
|
purchaseOrder.setDeliveryLocationSiteId( deliverySiteId );
|
||||||
|
purchaseOrder.setUserStatus( rs.getString( "user_status" ) );
|
||||||
|
purchaseOrder.setUserRemarks( rs.getString( "user_remarks" ) );
|
||||||
|
Long mainPaymentTermId = rs.getLong( "main_payment_term_id" );
|
||||||
|
if ( rs.wasNull() ) {
|
||||||
|
mainPaymentTermId = null;
|
||||||
|
}
|
||||||
|
purchaseOrder.setMainPaymentTermId( mainPaymentTermId );
|
||||||
|
purchaseOrder.setShipmentMode( rs.getString( "shipment_mode" ) );
|
||||||
|
purchaseOrder.setManagementStatus( rs.getString( "management_status" ) );
|
||||||
|
purchaseOrder.setManagementRemarks( rs.getString( "management_remarks" ) );
|
||||||
|
purchaseOrder.setIndenterDivPoStatus( rs.getString( "indenter_div_head_status" ) );
|
||||||
|
purchaseOrder.setIndenterDivPoRemarks( rs.getString( "indenter_div_head_remarks" ) );
|
||||||
|
purchaseOrder.setCompleted( rs.getBoolean( "completed" ) );
|
||||||
|
if ( rs.getTimestamp( "date_completed" ) != null ) {
|
||||||
|
purchaseOrder.setDateCompleted( rs.getTimestamp( "date_completed" ).toLocalDateTime() );
|
||||||
|
}
|
||||||
|
purchaseOrder.setTerminationReason( rs.getString( "termination_reason" ) );
|
||||||
|
purchaseOrder.setParentDocumentType( rs.getString( "parent_document_type" ) );
|
||||||
|
purchaseOrder.setParentDocumentCode( rs.getString( "parent_document_code" ) );
|
||||||
|
Long parentDocumentId = rs.getLong( "parent_document_id" );
|
||||||
|
if ( rs.wasNull() ) {
|
||||||
|
parentDocumentId = null;
|
||||||
|
}
|
||||||
|
purchaseOrder.setParentDocumentId( parentDocumentId );
|
||||||
|
Long indentId = rs.getLong( "indent_id" );
|
||||||
|
if ( rs.wasNull() ) {
|
||||||
|
indentId = null;
|
||||||
|
}
|
||||||
|
purchaseOrder.setIndentId( indentId );
|
||||||
|
purchaseOrder.setIsLocked( rs.getBoolean( "is_locked" ) );
|
||||||
|
purchaseOrder.setAreChargesPaid( rs.getBoolean( "are_charges_paid" ) );
|
||||||
|
purchaseOrder.setIsFlagged( rs.getBoolean( "is_flagged" ) );
|
||||||
|
return purchaseOrder;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import org.thymeleaf.dialect.AbstractProcessorDialect;
|
||||||
|
import org.thymeleaf.processor.IProcessor;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class CTPDialect extends AbstractProcessorDialect {
|
||||||
|
|
||||||
|
public CTPDialect() {
|
||||||
|
super(
|
||||||
|
"Utopia Industries",
|
||||||
|
"ctp",
|
||||||
|
1000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<IProcessor> getProcessors( final String dialectPrefix ) {
|
||||||
|
final Set<IProcessor> processors = new HashSet<IProcessor>();
|
||||||
|
processors.add( new FormatCurrencyTagProcessor( dialectPrefix ) );
|
||||||
|
processors.add( new FormatDateTagProcessor( dialectPrefix ) );
|
||||||
|
processors.add( new FormatDateTimeTagProcessor( dialectPrefix ) );
|
||||||
|
processors.add( new FormatTimePeriodHumanReadableSince( dialectPrefix ) );
|
||||||
|
processors.add( new FormatTimePeriodHumanReadableBetween( dialectPrefix ) );
|
||||||
|
processors.add( new IsOnPathTagProcessor( dialectPrefix ) );
|
||||||
|
processors.add( new FormatTimeTagProcessor( dialectPrefix ) );
|
||||||
|
processors.add( new FormatNumberTagProcessor( dialectPrefix ) );
|
||||||
|
return processors;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.CurrencySymbol;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
// https://docs.oracle.com/javase/tutorial/i18n/format/numberFormat.html
|
||||||
|
// https://www.localeplanet.com/icu/en-PK/index.html
|
||||||
|
public class FormatCurrencyTagProcessor extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "formatcurrency";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatCurrencyTagProcessor( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final String attributeValueParsed = ( String ) expression.execute( iTemplateContext );
|
||||||
|
// get arguments from comma separated list
|
||||||
|
String[] args = attributeValueParsed.split( "," );
|
||||||
|
double amount = Double.parseDouble( args[0] == null ? "0" : args[0] );
|
||||||
|
String currencyCode = args[1];
|
||||||
|
// create locale
|
||||||
|
Locale locale = new Locale( CurrencySymbol.valueOf( currencyCode ).getLanguage(), CurrencySymbol.valueOf( currencyCode ).getLocation() );
|
||||||
|
// formatted amount in the specified locale
|
||||||
|
NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance( locale );
|
||||||
|
// check if decimals required
|
||||||
|
int fractionDigits;
|
||||||
|
if ( args.length == 3 ) {
|
||||||
|
fractionDigits = Integer.parseInt( args[2] );
|
||||||
|
} else {
|
||||||
|
fractionDigits = 2;
|
||||||
|
}
|
||||||
|
currencyFormatter.setMaximumFractionDigits( fractionDigits );
|
||||||
|
// format
|
||||||
|
String formattedAmount = currencyFormatter.format( Math.abs( amount ) );
|
||||||
|
// if amount is less than zero, add brackets
|
||||||
|
if ( amount < 0 ) {
|
||||||
|
formattedAmount = "(" + formattedAmount + ")";
|
||||||
|
}
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedAmount, false );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.CTPDateTimeFormat;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class FormatDateTagProcessor extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "formatdate";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatDateTagProcessor( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final LocalDate attributeValueParsed = ( LocalDate ) expression.execute( iTemplateContext );
|
||||||
|
iElementTagStructureHandler.setBody( "", false );
|
||||||
|
if( attributeValueParsed != null ){
|
||||||
|
// format zoned date time
|
||||||
|
String formattedDateTime = attributeValueParsed.format( DateTimeFormatter.ofPattern( CTPDateTimeFormat.TEMPLATE_DATE_FORMAT ) );
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedDateTime, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.CTPDateTimeFormat;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class FormatDateTimeTagProcessor extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "formatdatetime";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatDateTimeTagProcessor( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final LocalDateTime attributeValueParsed = ( LocalDateTime ) expression.execute( iTemplateContext );
|
||||||
|
iElementTagStructureHandler.setBody( "", false );
|
||||||
|
// format zoned date time
|
||||||
|
if( attributeValueParsed != null ){
|
||||||
|
String formattedDateTime = attributeValueParsed.format( DateTimeFormatter.ofPattern( CTPDateTimeFormat.TEMPLATE_DATE_TIME_FORMAT ) );
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedDateTime, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.CurrencySymbol;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
// https://docs.oracle.com/javase/tutorial/i18n/format/numberFormat.html
|
||||||
|
// https://www.localeplanet.com/icu/en-PK/index.html
|
||||||
|
public class FormatNumberTagProcessor extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "formatnumber";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatNumberTagProcessor( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final String attributeValueParsed = ( String ) expression.execute( iTemplateContext );
|
||||||
|
// get arguments from comma separated list
|
||||||
|
String[] args = attributeValueParsed.split( "," );
|
||||||
|
double amount = Double.parseDouble( args[0] );
|
||||||
|
String currencyCode = args[1];
|
||||||
|
// create locale
|
||||||
|
Locale locale = new Locale( CurrencySymbol.valueOf( currencyCode ).getLanguage(), CurrencySymbol.valueOf( currencyCode ).getLocation() );
|
||||||
|
// formatted amount in the specified locale
|
||||||
|
NumberFormat formatter = NumberFormat.getNumberInstance( locale );
|
||||||
|
// check if decimals required
|
||||||
|
int fractionDigits;
|
||||||
|
if ( args.length == 3 ) {
|
||||||
|
fractionDigits = Integer.parseInt( args[2] );
|
||||||
|
} else {
|
||||||
|
fractionDigits = 0;
|
||||||
|
}
|
||||||
|
formatter.setMaximumFractionDigits( fractionDigits );
|
||||||
|
// if amount is less than zero, add brackets
|
||||||
|
String formattedAmount = formatter.format( Math.abs( amount ) );
|
||||||
|
if ( amount < 0 ) {
|
||||||
|
formattedAmount = "(" + formattedAmount + ")";
|
||||||
|
}
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedAmount, false );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.TimePeriodFormatter;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class FormatTimePeriodHumanReadableBetween extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "humanreadableperiodbetween";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatTimePeriodHumanReadableBetween( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final String attributeValueParsed = ( String ) expression.execute( iTemplateContext );
|
||||||
|
// get arguments from comma separated list
|
||||||
|
String[] args = attributeValueParsed.split( "," );
|
||||||
|
LocalDateTime from = LocalDateTime.parse( args[0] );
|
||||||
|
LocalDateTime to = LocalDateTime.parse( args[1] );
|
||||||
|
// formatted time period
|
||||||
|
String formattedPeriod = ( new TimePeriodFormatter() )
|
||||||
|
.from( from )
|
||||||
|
.to( to )
|
||||||
|
.format();
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedPeriod, false );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.TimePeriodFormatter;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class FormatTimePeriodHumanReadableSince extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "humanreadableperiodsince";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatTimePeriodHumanReadableSince( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final LocalDateTime from = ( LocalDateTime ) expression.execute( iTemplateContext );
|
||||||
|
// formatted time period
|
||||||
|
String formattedPeriod = ( new TimePeriodFormatter() )
|
||||||
|
.from( from )
|
||||||
|
.to( LocalDateTime.now() )
|
||||||
|
.format();
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedPeriod, false );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import com.utopiaindustries.util.CTPDateTimeFormat;
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class FormatTimeTagProcessor extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "formattime";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public FormatTimeTagProcessor( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final LocalDateTime attributeValueParsed = ( LocalDateTime ) expression.execute( iTemplateContext );
|
||||||
|
// format zoned date time
|
||||||
|
String formattedDateTime = attributeValueParsed.format( DateTimeFormatter.ofPattern( CTPDateTimeFormat.HTML5_TIME_INPUT_FORMAT_ATTENDANCE ) );
|
||||||
|
// render the body
|
||||||
|
iElementTagStructureHandler.setBody( formattedDateTime, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.utopiaindustries.dialect;
|
||||||
|
|
||||||
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
import org.thymeleaf.context.ITemplateContext;
|
||||||
|
import org.thymeleaf.engine.AttributeName;
|
||||||
|
import org.thymeleaf.model.IProcessableElementTag;
|
||||||
|
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||||
|
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||||
|
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||||
|
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
|
||||||
|
public class IsOnPathTagProcessor extends AbstractAttributeTagProcessor {
|
||||||
|
private static final String ATTR_NAME = "is-on-path";
|
||||||
|
private static final int PRECEDENCE = 100000;
|
||||||
|
|
||||||
|
public IsOnPathTagProcessor( final String dialectPrefix ) {
|
||||||
|
super(
|
||||||
|
TemplateMode.HTML,
|
||||||
|
dialectPrefix,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
ATTR_NAME,
|
||||||
|
true,
|
||||||
|
PRECEDENCE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this tag accepts paths as params with the path to check against as the last argument
|
||||||
|
*/
|
||||||
|
protected void doProcess( ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler ) {
|
||||||
|
final IEngineConfiguration configuration = iTemplateContext.getConfiguration();
|
||||||
|
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser( configuration );
|
||||||
|
final IStandardExpression expression = parser.parseExpression( iTemplateContext, attributeValue );
|
||||||
|
final String[] attributeValueParsed = ( ( String ) expression.execute( iTemplateContext ) ).split( "," );
|
||||||
|
// the target path is the last argument
|
||||||
|
final String targetPath = attributeValueParsed[attributeValueParsed.length - 1];
|
||||||
|
boolean matched = false;
|
||||||
|
// iterate over paths (except the last one, since thats the target path)
|
||||||
|
// and check if any thing matched
|
||||||
|
for ( int i = 0; i < attributeValueParsed.length - 1; i++ ) {
|
||||||
|
if ( targetPath.contains( attributeValueParsed[i] ) ) {
|
||||||
|
matched = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// remove body if didn't match
|
||||||
|
if ( ! matched ) {
|
||||||
|
iElementTagStructureHandler.removeElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.utopiaindustries.model;
|
||||||
|
|
||||||
|
public enum CurrencySymbol {
|
||||||
|
AUD("en", "AU"),
|
||||||
|
BRL("por", "BR"),
|
||||||
|
CAD("en", "CA"),
|
||||||
|
CNY("en", "CN"),
|
||||||
|
EUR("de", "DE"),
|
||||||
|
GBP("en", "GB"),
|
||||||
|
JPY("jpn", "JP"),
|
||||||
|
MXN("spa", "MX"),
|
||||||
|
PKR("ur", "PK"),
|
||||||
|
AED("en", "AE"),
|
||||||
|
USD("en", "US");
|
||||||
|
|
||||||
|
private final String language;
|
||||||
|
private final String location;
|
||||||
|
|
||||||
|
CurrencySymbol( String language, String location ) {
|
||||||
|
this.language = language;
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.utopiaindustries.model;
|
||||||
|
|
||||||
|
public enum Granularity {
|
||||||
|
DAILY,
|
||||||
|
WEEKLY,
|
||||||
|
MONTHLY,
|
||||||
|
YEARLY
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.utopiaindustries.model;
|
||||||
|
|
||||||
|
public enum Roles {
|
||||||
|
ROLE_ADMIN,
|
||||||
|
ROLE_USER,
|
||||||
|
ROLE_CUTTING,
|
||||||
|
ROLE_STITCHING,
|
||||||
|
ROLE_QUALITY_CONTROL,
|
||||||
|
ROLE_PACKAGING
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public class Authority {
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private String authority;
|
||||||
|
|
||||||
|
public Authority() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Authority(String authority) {
|
||||||
|
this.authority = authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthority() {
|
||||||
|
return authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthority(String authority) {
|
||||||
|
this.authority = authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return authority ;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public class BarcodeSpecs {
|
||||||
|
|
||||||
|
public enum Format {
|
||||||
|
QR_CODE,
|
||||||
|
CODE_128
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public enum BarcodeStickerSize {
|
||||||
|
|
||||||
|
SIZE_1_5_X_3( 3 * 72, 1.5f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||||
|
SIZE_2_X_3( 3 * 72, 2 * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||||
|
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
||||||
|
SIZE_1_75_X_3_5( 3.5f * 72, 1.75f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7);
|
||||||
|
|
||||||
|
|
||||||
|
private final float width;
|
||||||
|
private final float height;
|
||||||
|
private final int marginLeft;
|
||||||
|
private final int marginRight;
|
||||||
|
private final int marginTop;
|
||||||
|
private final int marginBottom;
|
||||||
|
private final int imageWidthBarcode;
|
||||||
|
private final int imageHeightBarcode;
|
||||||
|
private final int imageWidthQrCode;
|
||||||
|
private final int imageHeightQrCode;
|
||||||
|
private final int textSize;
|
||||||
|
private final int textSizeSmall;
|
||||||
|
private final int textSizeExtraSmall;
|
||||||
|
|
||||||
|
BarcodeStickerSize(float width, float height, int marginLeft, int marginRight, int marginTop, int marginBottom, int imageWidthBarcode, int imageHeightBarcode, int imageWidthQrCode, int imageHeightQrCode, int textSize, int textSizeSmall, int textSizeExtraSmall) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.marginLeft = marginLeft;
|
||||||
|
this.marginRight = marginRight;
|
||||||
|
this.marginTop = marginTop;
|
||||||
|
this.marginBottom = marginBottom;
|
||||||
|
this.imageWidthBarcode = imageWidthBarcode;
|
||||||
|
this.imageHeightBarcode = imageHeightBarcode;
|
||||||
|
this.imageWidthQrCode = imageWidthQrCode;
|
||||||
|
this.imageHeightQrCode = imageHeightQrCode;
|
||||||
|
this.textSize = textSize;
|
||||||
|
this.textSizeSmall = textSizeSmall;
|
||||||
|
this.textSizeExtraSmall = textSizeExtraSmall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarginLeft() {
|
||||||
|
return marginLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarginRight() {
|
||||||
|
return marginRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarginTop() {
|
||||||
|
return marginTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarginBottom() {
|
||||||
|
return marginBottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageWidthBarcode() {
|
||||||
|
return imageWidthBarcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageHeightBarcode() {
|
||||||
|
return imageHeightBarcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageWidthQrCode() {
|
||||||
|
return imageWidthQrCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageHeightQrCode() {
|
||||||
|
return imageHeightQrCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextSize() {
|
||||||
|
return textSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextSizeSmall() {
|
||||||
|
return textSizeSmall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextSizeExtraSmall() {
|
||||||
|
return textSizeExtraSmall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BarcodeStickerSize getSize(String sizeName ) {
|
||||||
|
for ( BarcodeStickerSize stickerSize: values() ) {
|
||||||
|
if ( stickerSize.name().equalsIgnoreCase( sizeName ) ) {
|
||||||
|
return stickerSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class Bundle implements InventoryArtifact {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private BigDecimal wrapQuantity;
|
||||||
|
private String barcode;
|
||||||
|
private String type;
|
||||||
|
private String createdBy;
|
||||||
|
@DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private long jobCardId;
|
||||||
|
private long masterBundleId;
|
||||||
|
|
||||||
|
// wrapper
|
||||||
|
private MasterBundle masterBundle;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getWrapQuantity() {
|
||||||
|
return wrapQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWrapQuantity(BigDecimal wrapQuantity) {
|
||||||
|
this.wrapQuantity = wrapQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBarcode() {
|
||||||
|
return barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBarcode(String barcode) {
|
||||||
|
this.barcode = barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobCardId() {
|
||||||
|
return jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCardId(long jobCardId) {
|
||||||
|
this.jobCardId = jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMasterBundleId() {
|
||||||
|
return masterBundleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMasterBundleId(long masterBundleId) {
|
||||||
|
this.masterBundleId = masterBundleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MasterBundle getMasterBundle() {
|
||||||
|
return masterBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMasterBundle(MasterBundle masterBundle) {
|
||||||
|
this.masterBundle = masterBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Bundle{" +
|
||||||
|
"id=" + id +
|
||||||
|
", itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", wrapQuantity=" + wrapQuantity +
|
||||||
|
", barcode='" + barcode + '\'' +
|
||||||
|
", type='" + type + '\'' +
|
||||||
|
", createdBy='" + createdBy + '\'' +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", jobCardId=" + jobCardId +
|
||||||
|
", masterBundleId=" + masterBundleId +
|
||||||
|
", masterBundle=" + masterBundle +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class CutPiece {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private long jobCardItemId;
|
||||||
|
private String type;
|
||||||
|
private BigDecimal quantity;
|
||||||
|
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobCardItemId() {
|
||||||
|
return jobCardItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCardItemId(long jobCardItemId) {
|
||||||
|
this.jobCardItemId = jobCardItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(BigDecimal quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CutPiece{" +
|
||||||
|
"id=" + id +
|
||||||
|
", jobCardItemId=" + jobCardItemId +
|
||||||
|
", type='" + type + '\'' +
|
||||||
|
", quantity=" + quantity +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public class CutPieceType {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CutPieceType{" +
|
||||||
|
"id=" + id +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class FinishedItem implements InventoryArtifact {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private String barcode;
|
||||||
|
private long jobCardId;
|
||||||
|
@DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private boolean isQa;
|
||||||
|
private long stitchedItemId;
|
||||||
|
private boolean isSegregated;
|
||||||
|
private String qaRemarks;
|
||||||
|
// wrapper
|
||||||
|
private JobCard jobCard;
|
||||||
|
private long accountId;
|
||||||
|
private String qaStatus;
|
||||||
|
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBarcode() {
|
||||||
|
return barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBarcode(String barcode) {
|
||||||
|
this.barcode = barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobCardId() {
|
||||||
|
return jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCardId(long jobCardId) {
|
||||||
|
this.jobCardId = jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsQa() {
|
||||||
|
return isQa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsQa(boolean qa) {
|
||||||
|
isQa = qa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStitchedItemId() {
|
||||||
|
return stitchedItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStitchedItemId(long stitchedItemId) {
|
||||||
|
this.stitchedItemId = stitchedItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobCard getJobCard() {
|
||||||
|
return jobCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCard(JobCard jobCard) {
|
||||||
|
this.jobCard = jobCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsSegregated() {
|
||||||
|
return isSegregated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsSegregated(boolean segregated) {
|
||||||
|
isSegregated = segregated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQaRemarks() {
|
||||||
|
return qaRemarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQaRemarks(String qaRemarks) {
|
||||||
|
this.qaRemarks = qaRemarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(long accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQaStatus() {
|
||||||
|
return qaStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQaStatus(String qaStatus) {
|
||||||
|
this.qaStatus = qaStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FinishedItem{" +
|
||||||
|
"id=" + id +
|
||||||
|
", itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", barcode='" + barcode + '\'' +
|
||||||
|
", jobCardId=" + jobCardId +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", createdBy='" + createdBy + '\'' +
|
||||||
|
", isQa=" + isQa +
|
||||||
|
", stitchedItemId=" + stitchedItemId +
|
||||||
|
", isSegregated=" + isSegregated +
|
||||||
|
", qaRemarks='" + qaRemarks + '\'' +
|
||||||
|
", jobCard=" + jobCard +
|
||||||
|
", accountId=" + accountId +
|
||||||
|
", qaStatus='" + qaStatus + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FinishedItemWrapper {
|
||||||
|
|
||||||
|
private List<FinishedItem> items;
|
||||||
|
|
||||||
|
public List<FinishedItem> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<FinishedItem> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FinishedItemWrapper{" +
|
||||||
|
"items=" + items +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class InventoryAccount {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String title;
|
||||||
|
private String parentEntityType;
|
||||||
|
private long parentEntityId;
|
||||||
|
private Boolean active;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private Integer locationSiteId;
|
||||||
|
private String notes;
|
||||||
|
private Boolean isPackaging;
|
||||||
|
//wrapper
|
||||||
|
private String locationTitle;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentEntityType() {
|
||||||
|
return parentEntityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentEntityType(String parentEntityType) {
|
||||||
|
this.parentEntityType = parentEntityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getParentEntityId() {
|
||||||
|
return parentEntityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentEntityId(long parentEntityId) {
|
||||||
|
this.parentEntityId = parentEntityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(Boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLocationSiteId() {
|
||||||
|
return locationSiteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocationSiteId(Integer locationSiteId) {
|
||||||
|
this.locationSiteId = locationSiteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsPackaging() {
|
||||||
|
return isPackaging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPackaging(Boolean isPackaging) {
|
||||||
|
this.isPackaging = isPackaging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocationTitle() {
|
||||||
|
return locationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocationTitle(String locationTitle) {
|
||||||
|
this.locationTitle = locationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InventoryAccount{" +
|
||||||
|
"id=" + id +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
", parentEntityType='" + parentEntityType + '\'' +
|
||||||
|
", parentEntityId=" + parentEntityId +
|
||||||
|
", active=" + active +
|
||||||
|
", createdBy='" + createdBy + '\'' +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", locationSiteId=" + locationSiteId +
|
||||||
|
", notes='" + notes + '\'' +
|
||||||
|
", isPackaging=" + isPackaging +
|
||||||
|
", locationTitle='" + locationTitle + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public interface InventoryArtifact {
|
||||||
|
|
||||||
|
long getId();
|
||||||
|
long getItemId();
|
||||||
|
String getSku();
|
||||||
|
String getType();
|
||||||
|
String getBarcode();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public enum InventoryArtifactType {
|
||||||
|
BUNDLE,
|
||||||
|
STITCHING_OFFLINE,
|
||||||
|
FINISHED_ITEM
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class InventorySummary {
|
||||||
|
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private String parentDocumentType;
|
||||||
|
private String pieceType;
|
||||||
|
private BigDecimal balance;
|
||||||
|
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentDocumentType() {
|
||||||
|
return parentDocumentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentDocumentType(String parentDocumentType) {
|
||||||
|
this.parentDocumentType = parentDocumentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getBalance() {
|
||||||
|
return balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBalance(BigDecimal balance) {
|
||||||
|
this.balance = balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPieceType() {
|
||||||
|
return pieceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPieceType(String pieceType) {
|
||||||
|
this.pieceType = pieceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InventorySummary{" +
|
||||||
|
"itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", parentDocumentType='" + parentDocumentType + '\'' +
|
||||||
|
", pieceType='" + pieceType + '\'' +
|
||||||
|
", balance=" + balance +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InventoryTransaction {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private LocalDateTime transactionDateTime;
|
||||||
|
private String generatedBy;
|
||||||
|
private String notes;
|
||||||
|
// wrapper
|
||||||
|
private List<InventoryTransactionLeg> inventoryTransactionLegs;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getTransactionDateTime() {
|
||||||
|
return transactionDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionDateTime(LocalDateTime transactionDateTime) {
|
||||||
|
this.transactionDateTime = transactionDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGeneratedBy() {
|
||||||
|
return generatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGeneratedBy(String generatedBy) {
|
||||||
|
this.generatedBy = generatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryTransactionLeg> getInventoryTransactionLegs() {
|
||||||
|
return inventoryTransactionLegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInventoryTransactionLegs(List<InventoryTransactionLeg> inventoryTransactionLegs) {
|
||||||
|
this.inventoryTransactionLegs = inventoryTransactionLegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InventoryTransaction{" +
|
||||||
|
"id=" + id +
|
||||||
|
", transactionDateTime=" + transactionDateTime +
|
||||||
|
", generatedBy='" + generatedBy + '\'' +
|
||||||
|
", notes='" + notes + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class InventoryTransactionLeg {
|
||||||
|
|
||||||
|
public enum Type{
|
||||||
|
IN,
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private long transactionId;
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private String type;
|
||||||
|
private BigDecimal quantity;
|
||||||
|
private Integer accountId;
|
||||||
|
private BigDecimal balance;
|
||||||
|
private LocalDateTime transactionLegDateTime;
|
||||||
|
private String parentDocumentType;
|
||||||
|
private long parentDocumentId;
|
||||||
|
private String parentDocumentPieceType;
|
||||||
|
|
||||||
|
//wrapper
|
||||||
|
private InventoryTransaction transaction;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTransactionId() {
|
||||||
|
return transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionId(long transactionId) {
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(BigDecimal quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(Integer accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getBalance() {
|
||||||
|
return balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBalance(BigDecimal balance) {
|
||||||
|
this.balance = balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getTransactionLegDateTime() {
|
||||||
|
return transactionLegDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionLegDateTime(LocalDateTime transactionLegDateTime) {
|
||||||
|
this.transactionLegDateTime = transactionLegDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentDocumentType() {
|
||||||
|
return parentDocumentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentDocumentType(String parentDocumentType) {
|
||||||
|
this.parentDocumentType = parentDocumentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getParentDocumentId() {
|
||||||
|
return parentDocumentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentDocumentId(long parentDocumentId) {
|
||||||
|
this.parentDocumentId = parentDocumentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentDocumentPieceType() {
|
||||||
|
return parentDocumentPieceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentDocumentPieceType(String parentDocumentPieceType) {
|
||||||
|
this.parentDocumentPieceType = parentDocumentPieceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryTransaction getTransaction() {
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransaction(InventoryTransaction transaction) {
|
||||||
|
this.transaction = transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InventoryTransactionLeg{" +
|
||||||
|
"id=" + id +
|
||||||
|
", transactionId=" + transactionId +
|
||||||
|
", itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", type='" + type + '\'' +
|
||||||
|
", quantity=" + quantity +
|
||||||
|
", accountId=" + accountId +
|
||||||
|
", balance=" + balance +
|
||||||
|
", transactionLegDateTime=" + transactionLegDateTime +
|
||||||
|
", parentDocumentType='" + parentDocumentType + '\'' +
|
||||||
|
", parentDocumentId=" + parentDocumentId +
|
||||||
|
", parentDocumentPieceType='" + parentDocumentPieceType + '\'' +
|
||||||
|
", transaction=" + transaction +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,186 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JobCard {
|
||||||
|
|
||||||
|
public enum Status{
|
||||||
|
DRAFT,
|
||||||
|
POSTED,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum InventoryStatus {
|
||||||
|
NOT_RECEIVED_YET,
|
||||||
|
RECEIVED
|
||||||
|
}
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String code;
|
||||||
|
private long jobOrderId;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private String status;
|
||||||
|
private String inventoryStatus;
|
||||||
|
private String customer;
|
||||||
|
private String lotNumber;
|
||||||
|
private long purchaseOrderId;
|
||||||
|
private long locationSiteId;
|
||||||
|
private String description;
|
||||||
|
// wrapper
|
||||||
|
private List<JobCardItem> items;
|
||||||
|
private long toAccountId;
|
||||||
|
private String purchaseOrderTitle;
|
||||||
|
private String locationTitle;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobOrderId() {
|
||||||
|
return jobOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobOrderId(long jobOrderId) {
|
||||||
|
this.jobOrderId = jobOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInventoryStatus() {
|
||||||
|
return inventoryStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInventoryStatus(String inventoryStatus) {
|
||||||
|
this.inventoryStatus = inventoryStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomer(String customer) {
|
||||||
|
this.customer = customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLotNumber() {
|
||||||
|
return lotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLotNumber(String lotNumber) {
|
||||||
|
this.lotNumber = lotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPurchaseOrderId() {
|
||||||
|
return purchaseOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPurchaseOrderId(long purchaseOrderId) {
|
||||||
|
this.purchaseOrderId = purchaseOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLocationSiteId() {
|
||||||
|
return locationSiteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocationSiteId(long locationSiteId) {
|
||||||
|
this.locationSiteId = locationSiteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobCardItem> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<JobCardItem> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getToAccountId() {
|
||||||
|
return toAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToAccountId(long toAccountId) {
|
||||||
|
this.toAccountId = toAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPurchaseOrderTitle() {
|
||||||
|
return purchaseOrderTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPurchaseOrderTitle(String purchaseOrderTitle) {
|
||||||
|
this.purchaseOrderTitle = purchaseOrderTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocationTitle() {
|
||||||
|
return locationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocationTitle(String locationTitle) {
|
||||||
|
this.locationTitle = locationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JobCard{" +
|
||||||
|
"id=" + id +
|
||||||
|
", code='" + code + '\'' +
|
||||||
|
", jobOrderId=" + jobOrderId +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", createdBy='" + createdBy + '\'' +
|
||||||
|
", status='" + status + '\'' +
|
||||||
|
", inventoryStatus='" + inventoryStatus + '\'' +
|
||||||
|
", customer='" + customer + '\'' +
|
||||||
|
", lotNumber='" + lotNumber + '\'' +
|
||||||
|
", purchaseOrderId=" + purchaseOrderId +
|
||||||
|
", locationSiteId=" + locationSiteId +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", items=" + items +
|
||||||
|
", toAccountId=" + toAccountId +
|
||||||
|
", purchaseOrderTitle='" + purchaseOrderTitle + '\'' +
|
||||||
|
", locationTitle='" + locationTitle + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class JobCardItem {
|
||||||
|
private long id;
|
||||||
|
private long jobCardId;
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private BigDecimal expectedProductionQuantity;
|
||||||
|
private BigDecimal totalProduction;
|
||||||
|
private BigDecimal production;
|
||||||
|
// wrapper
|
||||||
|
private List<CutPiece> cutPieces;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public JobCardItem() {
|
||||||
|
this.expectedProductionQuantity = BigDecimal.ZERO;
|
||||||
|
this.totalProduction = BigDecimal.ZERO;
|
||||||
|
this.production = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobCardId() {
|
||||||
|
return jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCardId(long jobCardId) {
|
||||||
|
this.jobCardId = jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getExpectedProductionQuantity() {
|
||||||
|
return expectedProductionQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpectedProductionQuantity(BigDecimal expectedProductionQuantity) {
|
||||||
|
this.expectedProductionQuantity = expectedProductionQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CutPiece> getCutPieces() {
|
||||||
|
return cutPieces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCutPieces(List<CutPiece> cutPieces) {
|
||||||
|
this.cutPieces = cutPieces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalProduction() {
|
||||||
|
return totalProduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalProduction(BigDecimal totalProduction) {
|
||||||
|
this.totalProduction = totalProduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getProduction() {
|
||||||
|
return production;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduction(BigDecimal production) {
|
||||||
|
this.production = production;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
JobCardItem item = (JobCardItem) o;
|
||||||
|
return id == item.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JobCardItem{" +
|
||||||
|
"id=" + id +
|
||||||
|
", jobCardId=" + jobCardId +
|
||||||
|
", itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", expectedProductionQuantity=" + expectedProductionQuantity +
|
||||||
|
", cutPieces=" + cutPieces +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MasterBundle implements InventoryArtifact{
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String barcode;
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private boolean isReceived;
|
||||||
|
private long jobCardId;
|
||||||
|
// wrapper
|
||||||
|
private List<Bundle> bundles;
|
||||||
|
private List<FinishedItem> items;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBarcode() {
|
||||||
|
return barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBarcode(String barcode) {
|
||||||
|
this.barcode = barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobCardId() {
|
||||||
|
return jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCardId(long jobCardId) {
|
||||||
|
this.jobCardId = jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsReceived() {
|
||||||
|
return isReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsReceived(boolean received) {
|
||||||
|
isReceived = received;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Bundle> getBundles() {
|
||||||
|
return bundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBundles(List<Bundle> bundles) {
|
||||||
|
this.bundles = bundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinishedItem> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<FinishedItem> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MasterBundle{" +
|
||||||
|
"id=" + id +
|
||||||
|
", barcode='" + barcode + '\'' +
|
||||||
|
", itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", createdBy='" + createdBy + '\'' +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", isReceived=" + isReceived +
|
||||||
|
", jobCardId=" + jobCardId +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public class Process {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String title;
|
||||||
|
private String notes;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Process{" +
|
||||||
|
"id=" + id +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
", notes='" + notes + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
public class StitchedItemWrapper {
|
||||||
|
|
||||||
|
|
||||||
|
private List<StitchingOfflineItem> items;
|
||||||
|
private Long finishedAccountId;
|
||||||
|
|
||||||
|
|
||||||
|
public List<StitchingOfflineItem> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<StitchingOfflineItem> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getFinishedAccountId() {
|
||||||
|
return finishedAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinishedAccountId(Long finishedAccountId) {
|
||||||
|
this.finishedAccountId = finishedAccountId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private long itemId;
|
||||||
|
private String sku;
|
||||||
|
private String barcode;
|
||||||
|
private long jobCardId;
|
||||||
|
@DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private boolean isQa;
|
||||||
|
private String qaRemarks;
|
||||||
|
private String qaStatus;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBarcode() {
|
||||||
|
return barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBarcode(String barcode) {
|
||||||
|
this.barcode = barcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getJobCardId() {
|
||||||
|
return jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobCardId(long jobCardId) {
|
||||||
|
this.jobCardId = jobCardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsQa() {
|
||||||
|
return isQa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsQa(boolean qa) {
|
||||||
|
isQa = qa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQaRemarks() {
|
||||||
|
return qaRemarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQaRemarks(String qaRemarks) {
|
||||||
|
this.qaRemarks = qaRemarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQaStatus() {
|
||||||
|
return qaStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQaStatus(String qaStatus) {
|
||||||
|
this.qaStatus = qaStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StitchingOfflineItem{" +
|
||||||
|
"id=" + id +
|
||||||
|
", itemId=" + itemId +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", barcode='" + barcode + '\'' +
|
||||||
|
", jobCardId=" + jobCardId +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", createdBy='" + createdBy + '\'' +
|
||||||
|
", isQa=" + isQa +
|
||||||
|
", qaRemarks='" + qaRemarks + '\'' +
|
||||||
|
", qaStatus='" + qaStatus + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private boolean enabled;
|
||||||
|
//wrapper
|
||||||
|
private List<Authority> authorities;
|
||||||
|
private List<UserInventoryAccount> inventoryAccounts;
|
||||||
|
private String newPassword;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Authority> getAuthorities() {
|
||||||
|
return authorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthorities(List<Authority> authorities) {
|
||||||
|
this.authorities = authorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserInventoryAccount> getInventoryAccounts() {
|
||||||
|
return inventoryAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInventoryAccounts(List<UserInventoryAccount> inventoryAccounts) {
|
||||||
|
this.inventoryAccounts = inventoryAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewPassword() {
|
||||||
|
return newPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewPassword(String newPassword) {
|
||||||
|
this.newPassword = newPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "User{" +
|
||||||
|
"username='" + username + '\'' +
|
||||||
|
", password='" + password + '\'' +
|
||||||
|
", enabled=" + enabled +
|
||||||
|
", authorities=" + authorities +
|
||||||
|
", inventoryAccounts=" + inventoryAccounts +
|
||||||
|
", newPassword='" + newPassword + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
public class UserInventoryAccount {
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private long accountId;
|
||||||
|
// wrapper
|
||||||
|
private String accountTitle;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(long accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountTitle() {
|
||||||
|
return accountTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountTitle(String accountTitle) {
|
||||||
|
this.accountTitle = accountTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return accountTitle;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,505 @@
|
||||||
|
package com.utopiaindustries.model.uind;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class Item {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String title;
|
||||||
|
private String shortTitle;
|
||||||
|
private String description;
|
||||||
|
private String spec1;
|
||||||
|
private String spec2;
|
||||||
|
private String spec3;
|
||||||
|
private String spec4;
|
||||||
|
private String spec5;
|
||||||
|
private String brand;
|
||||||
|
private String year;
|
||||||
|
private String model;
|
||||||
|
private long unitId;
|
||||||
|
private long companyId;
|
||||||
|
private long functionId;
|
||||||
|
private long departmentId;
|
||||||
|
private Long sectionId;
|
||||||
|
private long typeId;
|
||||||
|
private long categoryId;
|
||||||
|
private Long subcategoryOneId;
|
||||||
|
private Long subcategoryTwoId;
|
||||||
|
private String code;
|
||||||
|
private String sku;
|
||||||
|
private long itemRequestId;
|
||||||
|
private long minimumLevel;
|
||||||
|
private long deadLevel;
|
||||||
|
private long storageLocationSiteId;
|
||||||
|
private long storageLocationUnitId;
|
||||||
|
private Long storageLocationFloorId;
|
||||||
|
private Long storageLocationStoreId;
|
||||||
|
private Long storageLocationShelfId;
|
||||||
|
private LocalDate dateAdded;
|
||||||
|
|
||||||
|
private String lastAuditUpdateBy;
|
||||||
|
private LocalDateTime lastAuditDate;
|
||||||
|
private String requestedByUser;
|
||||||
|
private String addedByUser;
|
||||||
|
private boolean isActive;
|
||||||
|
private String hsCode;
|
||||||
|
private String imageUrl;
|
||||||
|
private String approvalStatus;
|
||||||
|
private String approvedBy;
|
||||||
|
private LocalDateTime approvedDate;
|
||||||
|
private String remarks;
|
||||||
|
private LocalDateTime requestDateTime;
|
||||||
|
private String materialType;
|
||||||
|
private String measurement;
|
||||||
|
private String origin;
|
||||||
|
private boolean isSkuSystemGenerated;
|
||||||
|
private boolean isUpdated;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShortTitle() {
|
||||||
|
return shortTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShortTitle(String shortTitle) {
|
||||||
|
this.shortTitle = shortTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpec1() {
|
||||||
|
return spec1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpec1(String spec1) {
|
||||||
|
this.spec1 = spec1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpec2() {
|
||||||
|
return spec2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpec2(String spec2) {
|
||||||
|
this.spec2 = spec2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpec3() {
|
||||||
|
return spec3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpec3(String spec3) {
|
||||||
|
this.spec3 = spec3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpec4() {
|
||||||
|
return spec4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpec4(String spec4) {
|
||||||
|
this.spec4 = spec4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpec5() {
|
||||||
|
return spec5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpec5(String spec5) {
|
||||||
|
this.spec5 = spec5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBrand() {
|
||||||
|
return brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrand(String brand) {
|
||||||
|
this.brand = brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(String year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUnitId() {
|
||||||
|
return unitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitId(long unitId) {
|
||||||
|
this.unitId = unitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCompanyId() {
|
||||||
|
return companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyId(long companyId) {
|
||||||
|
this.companyId = companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFunctionId() {
|
||||||
|
return functionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFunctionId(long functionId) {
|
||||||
|
this.functionId = functionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDepartmentId() {
|
||||||
|
return departmentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDepartmentId(long departmentId) {
|
||||||
|
this.departmentId = departmentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSectionId() {
|
||||||
|
return sectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSectionId(Long sectionId) {
|
||||||
|
this.sectionId = sectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTypeId() {
|
||||||
|
return typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeId(long typeId) {
|
||||||
|
this.typeId = typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCategoryId() {
|
||||||
|
return categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(long categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSubcategoryOneId() {
|
||||||
|
return subcategoryOneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubcategoryOneId(Long subcategoryOneId) {
|
||||||
|
this.subcategoryOneId = subcategoryOneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSubcategoryTwoId() {
|
||||||
|
return subcategoryTwoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubcategoryTwoId(Long subcategoryTwoId) {
|
||||||
|
this.subcategoryTwoId = subcategoryTwoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemRequestId() {
|
||||||
|
return itemRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemRequestId(long itemRequestId) {
|
||||||
|
this.itemRequestId = itemRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMinimumLevel() {
|
||||||
|
return minimumLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinimumLevel(long minimumLevel) {
|
||||||
|
this.minimumLevel = minimumLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDeadLevel() {
|
||||||
|
return deadLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadLevel(long deadLevel) {
|
||||||
|
this.deadLevel = deadLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStorageLocationSiteId() {
|
||||||
|
return storageLocationSiteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageLocationSiteId(long storageLocationSiteId) {
|
||||||
|
this.storageLocationSiteId = storageLocationSiteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStorageLocationUnitId() {
|
||||||
|
return storageLocationUnitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageLocationUnitId(long storageLocationUnitId) {
|
||||||
|
this.storageLocationUnitId = storageLocationUnitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStorageLocationFloorId() {
|
||||||
|
return storageLocationFloorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageLocationFloorId(Long storageLocationFloorId) {
|
||||||
|
this.storageLocationFloorId = storageLocationFloorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStorageLocationStoreId() {
|
||||||
|
return storageLocationStoreId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageLocationStoreId(Long storageLocationStoreId) {
|
||||||
|
this.storageLocationStoreId = storageLocationStoreId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStorageLocationShelfId() {
|
||||||
|
return storageLocationShelfId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageLocationShelfId(Long storageLocationShelfId) {
|
||||||
|
this.storageLocationShelfId = storageLocationShelfId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateAdded() {
|
||||||
|
return dateAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateAdded(LocalDate dateAdded) {
|
||||||
|
this.dateAdded = dateAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastAuditUpdateBy() {
|
||||||
|
return lastAuditUpdateBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastAuditUpdateBy(String lastAuditUpdateBy) {
|
||||||
|
this.lastAuditUpdateBy = lastAuditUpdateBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getLastAuditDate() {
|
||||||
|
return lastAuditDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastAuditDate(LocalDateTime lastAuditDate) {
|
||||||
|
this.lastAuditDate = lastAuditDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestedByUser() {
|
||||||
|
return requestedByUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestedByUser(String requestedByUser) {
|
||||||
|
this.requestedByUser = requestedByUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddedByUser() {
|
||||||
|
return addedByUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddedByUser(String addedByUser) {
|
||||||
|
this.addedByUser = addedByUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(boolean active) {
|
||||||
|
isActive = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHsCode() {
|
||||||
|
return hsCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHsCode(String hsCode) {
|
||||||
|
this.hsCode = hsCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageUrl() {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageUrl(String imageUrl) {
|
||||||
|
this.imageUrl = imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApprovalStatus() {
|
||||||
|
return approvalStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApprovalStatus(String approvalStatus) {
|
||||||
|
this.approvalStatus = approvalStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApprovedBy() {
|
||||||
|
return approvedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApprovedBy(String approvedBy) {
|
||||||
|
this.approvedBy = approvedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getApprovedDate() {
|
||||||
|
return approvedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApprovedDate(LocalDateTime approvedDate) {
|
||||||
|
this.approvedDate = approvedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemarks() {
|
||||||
|
return remarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemarks(String remarks) {
|
||||||
|
this.remarks = remarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getRequestDateTime() {
|
||||||
|
return requestDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestDateTime(LocalDateTime requestDateTime) {
|
||||||
|
this.requestDateTime = requestDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMaterialType() {
|
||||||
|
return materialType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaterialType(String materialType) {
|
||||||
|
this.materialType = materialType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMeasurement() {
|
||||||
|
return measurement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeasurement(String measurement) {
|
||||||
|
this.measurement = measurement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrigin() {
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigin(String origin) {
|
||||||
|
this.origin = origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsSkuSystemGenerated() {
|
||||||
|
return isSkuSystemGenerated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsSkuSystemGenerated(boolean skuSystemGenerated) {
|
||||||
|
isSkuSystemGenerated = skuSystemGenerated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsUpdated() {
|
||||||
|
return isUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsUpdated(boolean updated) {
|
||||||
|
isUpdated = updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Item{" +
|
||||||
|
"id=" + id +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
", shortTitle='" + shortTitle + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", spec1='" + spec1 + '\'' +
|
||||||
|
", spec2='" + spec2 + '\'' +
|
||||||
|
", spec3='" + spec3 + '\'' +
|
||||||
|
", spec4='" + spec4 + '\'' +
|
||||||
|
", spec5='" + spec5 + '\'' +
|
||||||
|
", brand='" + brand + '\'' +
|
||||||
|
", year='" + year + '\'' +
|
||||||
|
", model='" + model + '\'' +
|
||||||
|
", unitId=" + unitId +
|
||||||
|
", companyId=" + companyId +
|
||||||
|
", functionId=" + functionId +
|
||||||
|
", departmentId=" + departmentId +
|
||||||
|
", sectionId=" + sectionId +
|
||||||
|
", typeId=" + typeId +
|
||||||
|
", categoryId=" + categoryId +
|
||||||
|
", subcategoryOneId=" + subcategoryOneId +
|
||||||
|
", subcategoryTwoId=" + subcategoryTwoId +
|
||||||
|
", code='" + code + '\'' +
|
||||||
|
", sku='" + sku + '\'' +
|
||||||
|
", itemRequestId=" + itemRequestId +
|
||||||
|
", minimumLevel=" + minimumLevel +
|
||||||
|
", deadLevel=" + deadLevel +
|
||||||
|
", storageLocationSiteId=" + storageLocationSiteId +
|
||||||
|
", storageLocationUnitId=" + storageLocationUnitId +
|
||||||
|
", storageLocationFloorId=" + storageLocationFloorId +
|
||||||
|
", storageLocationStoreId=" + storageLocationStoreId +
|
||||||
|
", storageLocationShelfId=" + storageLocationShelfId +
|
||||||
|
", dateAdded=" + dateAdded +
|
||||||
|
", lastAuditUpdateBy='" + lastAuditUpdateBy + '\'' +
|
||||||
|
", lastAuditDate=" + lastAuditDate +
|
||||||
|
", requestedByUser='" + requestedByUser + '\'' +
|
||||||
|
", addedByUser='" + addedByUser + '\'' +
|
||||||
|
", isActive=" + isActive +
|
||||||
|
", hsCode='" + hsCode + '\'' +
|
||||||
|
", imageUrl='" + imageUrl + '\'' +
|
||||||
|
", approvalStatus='" + approvalStatus + '\'' +
|
||||||
|
", approvedBy='" + approvedBy + '\'' +
|
||||||
|
", approvedDate=" + approvedDate +
|
||||||
|
", remarks='" + remarks + '\'' +
|
||||||
|
", requestDateTime=" + requestDateTime +
|
||||||
|
", materialType='" + materialType + '\'' +
|
||||||
|
", measurement='" + measurement + '\'' +
|
||||||
|
", origin='" + origin + '\'' +
|
||||||
|
", isSkuSystemGenerated=" + isSkuSystemGenerated +
|
||||||
|
", isUpdated=" + isUpdated +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue