ready for rpa

This commit is contained in:
ctengiz
2024-03-26 10:55:22 +03:00
parent 465aae3710
commit f2939d6c4d
17 changed files with 1362 additions and 90 deletions

View File

@@ -0,0 +1,9 @@
package runtime
import _ "embed"
//go:embed runtime.js
var RuntimeJS []byte
//go:embed runtime.debug.js
var RuntimeDebugJS []byte

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,25 +0,0 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {Call} from '@wailsio/runtime';
/**
* @function Companies
* @returns {Promise<Company[], void>}
**/
export async function Companies() {
return Call.ByName("dbsrv.Srv.Companies", ...Array.prototype.slice.call(arguments, 0));
}
/**
* @function CreateCompany
* @param name {string}
* @param memberNumber {string}
* @param username {string}
* @param password {string}
* @returns {Promise<void>}
**/
export async function CreateCompany(name, memberNumber, username, password) {
return Call.ByName("dbsrv.Srv.CreateCompany", ...Array.prototype.slice.call(arguments, 0));
}

View File

@@ -0,0 +1,43 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {Call} from '@wailsio/runtime';
/**
* @function Companies
* @returns {Promise<Company[], void>}
**/
export async function Companies() {
return Call.ByName("srv.Srv.Companies", ...Array.prototype.slice.call(arguments, 0));
}
/**
* @function CreateCompany
* @param name {string}
* @param memberNumber {string}
* @param username {string}
* @param password {string}
* @returns {Promise<void>}
**/
export async function CreateCompany(name, memberNumber, username, password) {
return Call.ByName("srv.Srv.CreateCompany", ...Array.prototype.slice.call(arguments, 0));
}
/**
* @function Rpa
* @param month {number}
* @param year {number}
* @returns {Promise<void>}
**/
export async function Rpa(month, year) {
return Call.ByName("srv.Srv.Rpa", ...Array.prototype.slice.call(arguments, 0));
}
/**
* @function UploadExcel
* @returns {Promise<string>}
**/
export async function UploadExcel() {
return Call.ByName("srv.Srv.UploadExcel", ...Array.prototype.slice.call(arguments, 0));
}

View File

@@ -2,15 +2,6 @@
<q-layout view="lHh Lpr lFf">
<q-header elevated style="margin-top: 40px;">
<q-toolbar>
<q-btn
flat
dense
round
icon="menu"
aria-label="Menu"
@click="toggleLeftDrawer"
/>
<q-toolbar-title>
Bordro Robotu
</q-toolbar-title>

View File

@@ -17,12 +17,56 @@
label="Yeni Şirket Ekle"
color="primary"
@click="createCompany"
no-caps
/>
</template>
</q-select>
</div>
</div>
</q-card-section>
<q-card-section>
<div class="row q-col-gutter-sm items-center">
<div class="col-shrink">
<q-btn label="Excel Yükle"
@click="upload"
no-caps
color="secondary"
/>
</div>
<div class="col-11 text-right">
{{ ld.xlsFile }}
</div>
<div class="col-6">
<q-select v-model="ld.year" :options="[2024, 2025, 2026, 2027, 2028]"
label="Aktarım Yıl"
/>
</div>
<div class="col-6">
<q-select v-model="ld.month" :options="[1,2,3,4,5,6,7,8,9,10,11,12]"
label="Aktarım Ay"
/>
</div>
<div class="col-12">
<q-btn
no-caps
label="Aktarıma Başla"
color="warning"
class="full-width"
@click="doRpa"
:disable="!ld.xlsFile || !ld.companyID"
/>
</div>
</div>
</q-card-section>
<q-card-section>
<div style="max-height: 200px; overflow: scroll; border: 1px gray solid;" class="q-pa-xs">
<span v-for="(ln, ndx) in ld.logProcess" :key="ndx">
{{ ndx }} {{ ln }}
</span>
</div>
</q-card-section>
</q-card>
</q-page>
@@ -32,17 +76,26 @@
import { onMounted, reactive } from 'vue'
import Company from 'components/dlg/Company.vue'
import { useQuasar } from 'quasar'
import { Companies, CreateCompany } from 'app/bindings/lib/dbsrv/Srv'
import { Companies, CreateCompany, Rpa, UploadExcel } from 'app/bindings/lib/srv/Srv'
import * as wails from '@wailsio/runtime'
const $q = useQuasar()
const ld = reactive({
companyID: null,
companies: [],
xlsFile: '',
logProcess: [],
year: 2024,
month: 1,
})
onMounted(()=> {
onMounted(() => {
getCompanies()
wails.Events.On('logProcess', function (ev) {
ld.logProcess.push(ev.data)
})
})
const createCompany = function () {
@@ -50,7 +103,7 @@ const createCompany = function () {
component: Company,
parent: this,
// ----------------------
// props that are passed to component instancde
// props that are passed to component instance
}).onOk(data => {
CreateCompany(data.name, data.memberNumber, data.username, data.password)
})
@@ -61,7 +114,16 @@ const getCompanies = function () {
Companies().then(res => {
ld.companies.push(...res)
})
}
const upload = function () {
UploadExcel().then(res => {
ld.xlsFile = res
})
}
const doRpa = function () {
Rpa(Math.trunc(ld.month), Math.trunc(ld.year)).catch(err => console.log(err))
}
</script>

View File

@@ -7,6 +7,7 @@ toolchain go1.22.1
require (
github.com/jmoiron/sqlx v1.3.5
github.com/wailsapp/wails/v3 v3.0.0-alpha.0
github.com/xuri/excelize/v2 v2.8.1
modernc.org/sqlite v1.29.5
)
@@ -17,12 +18,19 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/leaanthony/slicer v1.5.0 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 // indirect
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 // indirect
github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.41.0 // indirect
modernc.org/mathutil v1.6.0 // indirect

View File

@@ -1,3 +1,5 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
@@ -23,18 +25,37 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 h1:Wn+nhnS+VytzE0PegUzSh4T3hXJCtggKGD/4U5H9+wQ=
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6/go.mod h1:zlNLI0E2c2qA6miiuAHtp0Bac8FaGH0tlhA19OssR/8=
github.com/wailsapp/wails/v3 v3.0.0-alpha.0 h1:T5gqG98Xr8LBf69oxlPkhpsFD59w2SnqUZk6XHj8Zoc=
github.com/wailsapp/wails/v3 v3.0.0-alpha.0/go.mod h1:OAfO5bP0TSUvCIHZYc6Dqfow/9RqxzHvYtmhWPpo1c0=
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 h1:Chd9DkqERQQuHpXjR/HSV1jLZA6uaoiwwH3vSuF3IW0=
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/excelize/v2 v2.8.1 h1:pZLMEwK8ep+CLIUWpWmvW8IWE/yxqG0I1xcN6cVMGuQ=
github.com/xuri/excelize/v2 v2.8.1/go.mod h1:oli1E4C3Pa5RXg1TBXn4ENCXDV5JUMlBluUhG7c+CEE=
github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05 h1:qhbILQo1K3mphbwKh1vNm4oGezE1eF9fQWmNiIpSfI4=
github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
@@ -47,12 +68,16 @@ golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=

View File

@@ -1,7 +1,7 @@
package company
import (
"bordrobot/lib/db"
"bordrobot/lib/run"
)
type Company struct {
@@ -16,6 +16,6 @@ func (c *Company) Create() error {
insert into company (name, member_number, username, password)
VALUES (:name, :member_number, :username, :password)
`
_, err := db.DB.NamedExec(sq, &c)
_, err := run.DB.NamedExec(sq, &c)
return err
}

View File

@@ -1,12 +1,12 @@
package company
import (
"bordrobot/lib/db"
"bordrobot/lib/run"
"testing"
)
func TestCompany_Create(t *testing.T) {
err := db.InitDB("../..")
err := run.InitDB("../..")
if err != nil {
t.Fatal(err)
}
@@ -23,5 +23,5 @@ func TestCompany_Create(t *testing.T) {
t.Fatal(err)
}
db.DB.Close()
run.DB.Close()
}

View File

@@ -1,25 +0,0 @@
package dbsrv
import (
"bordrobot/lib/company"
"bordrobot/lib/db"
)
type Srv struct{}
func (ds *Srv) Companies() ([]company.Company, error) {
var res []company.Company
err := db.DB.Select(&res, "SELECT * FROM company order by 1")
return res, err
}
func (ds *Srv) CreateCompany(name, memberNumber, username, password string) error {
c := &company.Company{
Name: name,
MemberNumber: memberNumber,
Username: username,
Password: password,
}
return c.Create()
}

5
app/lib/run/app.go Normal file
View File

@@ -0,0 +1,5 @@
package run
import "github.com/wailsapp/wails/v3/pkg/application"
var APP *application.App

View File

@@ -1,4 +1,4 @@
package db
package run
import (
"database/sql"

76
app/lib/srv/srv.go Normal file
View File

@@ -0,0 +1,76 @@
package srv
import (
"bordrobot/lib/company"
"bordrobot/lib/run"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/xuri/excelize/v2"
"log/slog"
)
type Srv struct {
xlsFileName string
}
func (s *Srv) Companies() ([]company.Company, error) {
var res []company.Company
err := run.DB.Select(&res, "SELECT * FROM company order by 1")
return res, err
}
func (s *Srv) CreateCompany(name, memberNumber, username, password string) error {
c := &company.Company{
Name: name,
MemberNumber: memberNumber,
Username: username,
Password: password,
}
return c.Create()
}
func (s *Srv) UploadExcel() string {
dialog := application.OpenFileDialog()
dialog.AddFilter("Excel Dosyaları", "*.xls;*.xlsx")
dialog.SetTitle("Bordro Excel Dosyası Yükleme")
file, err := dialog.PromptForSingleSelection()
if err != nil {
return ""
}
s.xlsFileName = file
return file
}
func (s *Srv) Rpa(month float64, year float64) error {
//wails nümerik değerleri float gönderiyor.. int gönderimi araştırılmalı
slog.Debug("inputs", "year", year, "month", month)
f, err := excelize.OpenFile(s.xlsFileName)
if err != nil {
slog.Error(err.Error())
return err
}
defer func() {
// Close the spreadsheet.
if err := f.Close(); err != nil {
slog.Error(err.Error())
//return err
}
}()
sheets := f.GetSheetList()
cols, err := f.GetCols(sheets[0])
if err != nil {
slog.Error(err.Error())
return err
}
for _, row := range cols {
run.APP.Events.Emit(&application.WailsEvent{
Name: "logProcess",
Data: row[1],
})
}
return nil
}

View File

@@ -2,13 +2,11 @@ package main
import (
"bordrobot/lib/company"
"bordrobot/lib/db"
"bordrobot/lib/dbsrv"
"bordrobot/lib/run"
"bordrobot/lib/srv"
"embed"
"log"
"time"
"github.com/wailsapp/wails/v3/pkg/application"
"log"
)
// Wails uses Go's `embed` package to embed the frontend files into the binary.
@@ -25,7 +23,7 @@ var assets embed.FS
func main() {
//Init SqLite database
err := db.InitDB(".")
err := run.InitDB(".")
if err != nil {
log.Fatal(err)
}
@@ -35,12 +33,12 @@ func main() {
// 'Assets' configures the asset server with the 'FS' variable pointing to the frontend files.
// 'Bind' is a list of Go struct instances. The frontend has access to the methods of these instances.
// 'Mac' options tailor the application when running an macOS.
app := application.New(application.Options{
run.APP = application.New(application.Options{
Name: "bordro-robotu",
Description: "A demo of using raw HTML & CSS",
Bind: []any{
&company.Company{},
&dbsrv.Srv{},
&srv.Srv{},
},
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets),
@@ -55,7 +53,7 @@ func main() {
// 'Mac' options tailor the window when running on macOS.
// 'BackgroundColour' is the background colour of the window.
// 'URL' is the URL that will be loaded into the webview.
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
run.APP.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Luca Bordro Robotu",
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
@@ -66,20 +64,8 @@ func main() {
URL: "/",
})
// Create a goroutine that emits an event containing the current time every second.
// The frontend can listen to this event and update the UI accordingly.
go func() {
for {
now := time.Now().Format(time.RFC1123)
app.Events.Emit(&application.WailsEvent{
Name: "time",
Data: now,
})
time.Sleep(time.Second)
}
}()
// Run the application. This blocks until the application has been exited.
err = app.Run()
err = run.APP.Run()
// If an error occurred while running the application, log it and exit.
if err != nil {