Monday, June 21, 2021

Autosys: Reporting

 Installer Downloads

1) Download Apache tomcat 9.0.48 Service Installer in the page.

   https://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.48/bin/apache-tomcat-9.0.48.exe

2) Download JDK from JAVA SE downloads. JDK 16.0.1

   https://download.oracle.com/otn-pub/java/jdk/16.0.1+9/7147401fd7354114ac51ef3e1328291f/jdk-16.0.1_windows-x64_bin.exe

3) Download mysql msi community installer.  (No need for login)

   https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.25.0.msi


Installation order

1) Install JDK first as default Path

2) Test installation by javac command in command prompt.

3) Install Service Installer.

   Select Full.

   It should detect JDK path automatically.

   Next Specify your own (C:/Autosys) Tomcat Install Path.

4) Now, copy the webapps\AUTOBATCHING

5) Test http://localhost:8080/AUTOBATCHING should work now.

6) Needs to install mysql.

   (It needs manual installation of Visual studio 2019. Only for Win apps??)

   Create only root with sa123 password.

7) Copy C:\Program Files (x86)\MySQL\Connector J 8.0\mysql-connector-java-8.0.25.jar to C:\Autosys\Tomcat9\lib

8) Now, if you create database autobatch, it should ask for the table in the webpage.

9) execute command source autobatchdb.sql.


Compilation:

C:\myAnalysis\Tomcat 9.0\webapps\AUTOBATCHING\WEB-INF\classes\Autobatch\Master\RecipeDownload>javac -cp .;"C:\myAnalysis\Tomcat 9.0\lib\servlet-api.jar";"C:\myAnalysis\Tomcat 9.0\webapps\AUTOBATCHING\WEB-INF\lib\EasyModbusJava.jar";"C:\myAnalysis\Tomcat 9.0\webapps\AUTOBATCHING\WEB-INF\classes" DownloadRecipe.java

I kept the source in the same directory where the class file existed, changed to that directory in the command prompt and built from that directory.

Database Creation

create database if not exists autobatch;
http://www.javadecompilers.com/result

show databases;


mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';
mysql> FLUSH PRIVILEGES;
mysql> quit

copied mysql-connector-java-8.0.24.jar to C:\myAnalysis\Tomcat 9.0\lib.

SHOW TABLES;


mysql> describe tbl_materialmaster;

CREATE TABLE tbl_materialmaster (Pkey INT AUTO_INCREMENT, MaterialCode INT, MaterialName Varchar(64), LogTime DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (Pkey))

5 tables;
=========

CREATE TABLE `tbl_materialloc` (
`Pkey`         INT NOT NULL AUTO_INCREMENT,
`SiloNum`      INT NOT NULL,
`MaterialCode` Varchar(45),
`MaterialName` Varchar(45),
`MaterialDesc` Varchar(145),
`Active`       BIT(1) DEFAULT 1,
`LogTime`      DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Pkey`));

describe `tbl_materialloc`;
drop table `tbl_materialloc`;
------

CREATE TABLE `tbl_materialmaster` (
`Pkey`         INT NOT NULL AUTO_INCREMENT,
`MaterialCode` INT NOT NULL,
`MaterialName` Varchar(45) NOT NULL,
`MaterialDesc` Varchar(145),
`Active`       BIT(1) DEFAULT 1,
`UnitPrice`    FLOAT,
`LogTime`      DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Pkey`));

describe `tbl_materialmaster`;
drop table `tbl_materialmaster`;
------

CREATE TABLE `tbl_recipedownload` (
`Pkey`         INT NOT NULL AUTO_INCREMENT,
`SiloNum`      INT NOT NULL,
`MaterialKey`  Varchar(45) NOT NULL,
`MaterialCode` Varchar(45) NOT NULL,
`MaterialName` Varchar(45) NOT NULL,
`SetWt`        FLOAT,
`FineWt`       FLOAT,
`InflightWt`   FLOAT,
`TollarenceWt` FLOAT,
`Active`       BIT(1) DEFAULT 1,
`LogTime`      DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Pkey`));

describe `tbl_recipedownload`;
drop table `tbl_materialmaster`;
------

CREATE TABLE `tbl_recipemaster` (
`Pkey`         INT NOT NULL AUTO_INCREMENT,
`SiloNum`      INT DEFAULT 0,
`RecipeCode`   INT,
`RecipeName`   Varchar(45),
`MaterialKey`  Varchar(45),
`MaterialCode` Varchar(45),
`MaterialName` Varchar(45),
`SetWt`        FLOAT,
`FineWt`       FLOAT,
`InflightWt`   FLOAT,
`TollarenceWt` FLOAT,
`Active`       BIT(1) DEFAULT 1,
`LogTime`      DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Pkey`));

describe `tbl_recipemaster`;
drop table `tbl_recipemaster`;
------

CREATE TABLE `tbl_reportmaster` (
`Pkey`         INT NOT NULL AUTO_INCREMENT,
`BatchID`      Varchar(45),
`LotNo`        INT,
`lngBatchDate` INT,
`lngBatchTime` INT,
`RecipeCode`   Varchar(45),
`RecipeName`   Varchar(45),
`WHNum`        INT,
`SiloNum`      INT,
`MaterialKey`  Varchar(45),
`MaterialCode` Varchar(45),
`MaterialName` Varchar(45),
`SetWt`        FLOAT,
`FineWt`       FLOAT,
`InflightWt`   FLOAT,
`TolrWt`       FLOAT,
`ActualWt`     FLOAT,
`Active`       BIT(1) DEFAULT 1,
`LogTime`      TIME,
`LogDate`      DATE,
`LogDateTime`  DATETIME,
`SysDateTime`  DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Pkey`));

describe `tbl_reportmaster`;
drop table `tbl_reportmaster`;
---

Creating 8 Silos;

INSERT INTO tbl_materialloc (SiloNum) VALUES (1);
INSERT INTO tbl_materialloc (SiloNum) VALUES (2);
:
INSERT INTO tbl_materialloc (SiloNum) VALUES (8);

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Howto Get a Database


-- Start a NEW "cmd"
c:
cd \myWebProject\mysql\bin
mysqldump -u myuser -p --databases studentdb > "c:\myWebProject\backup_studentdb.sql"

----
c:
cd \myWebProject\mysql\bin
mysql -u myuser -p
-- Run the backup script to recreate the database
mysql> drop database if exists studentdb;
mysql> source c:\myWebProject\backup_studentdb.sql
F