page mapping was done
This commit is contained in:
11
app/lib/bot/bordro.go
Normal file
11
app/lib/bot/bordro.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package bot
|
||||||
|
|
||||||
|
import "github.com/shopspring/decimal"
|
||||||
|
|
||||||
|
type LucaBordro struct {
|
||||||
|
Sube string
|
||||||
|
Bolum string
|
||||||
|
TcNo string
|
||||||
|
AdSoyad string
|
||||||
|
Ucretler map[string]decimal.Decimal
|
||||||
|
}
|
||||||
@@ -3,12 +3,10 @@ package bot
|
|||||||
import (
|
import (
|
||||||
"bordrobot/lib/company"
|
"bordrobot/lib/company"
|
||||||
"bordrobot/lib/helper"
|
"bordrobot/lib/helper"
|
||||||
"bordrobot/lib/model"
|
|
||||||
"bordrobot/lib/ocr"
|
"bordrobot/lib/ocr"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -19,6 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var pageErrors []string
|
var pageErrors []string
|
||||||
|
var scriptIndexArray []BordroPageScript
|
||||||
|
|
||||||
type Luca struct {
|
type Luca struct {
|
||||||
Page *rod.Page
|
Page *rod.Page
|
||||||
@@ -28,6 +27,10 @@ type errorInfo struct {
|
|||||||
Error string
|
Error string
|
||||||
Index int
|
Index int
|
||||||
}
|
}
|
||||||
|
type BordroPageScript struct {
|
||||||
|
Index string
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
func VerifyCaptcha(page *rod.Page) error {
|
func VerifyCaptcha(page *rod.Page) error {
|
||||||
captcha := "#captcha"
|
captcha := "#captcha"
|
||||||
@@ -153,7 +156,7 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
page.Timeout(500)
|
page.Timeout(1000)
|
||||||
loginDialog := "body > div.swal2-container.swal2-fade.swal2-in > div > div.swal2-content"
|
loginDialog := "body > div.swal2-container.swal2-fade.swal2-in > div > div.swal2-content"
|
||||||
|
|
||||||
loginDialogMessage, err := ReceiveDOMMessages(page, loginDialog, "innerText")
|
loginDialogMessage, err := ReceiveDOMMessages(page, loginDialog, "innerText")
|
||||||
@@ -167,6 +170,10 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
|||||||
return errors.New("Şifre hatalı")
|
return errors.New("Şifre hatalı")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
err = WaitLoad(page)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
getUrl := page.MustInfo().URL
|
getUrl := page.MustInfo().URL
|
||||||
splitUrl := strings.Split(getUrl, "/")
|
splitUrl := strings.Split(getUrl, "/")
|
||||||
splitUrlPage := strings.Split(splitUrl[len(splitUrl)-1], ";")[0]
|
splitUrlPage := strings.Split(splitUrl[len(splitUrl)-1], ";")[0]
|
||||||
@@ -174,7 +181,7 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
|||||||
VerifyCaptcha(page)
|
VerifyCaptcha(page)
|
||||||
}
|
}
|
||||||
fmt.Println(result)
|
fmt.Println(result)
|
||||||
wait := page.WaitRequestIdle(500*time.Millisecond, nil, nil, nil)
|
wait := page.WaitRequestIdle(1000*time.Millisecond, nil, nil, nil)
|
||||||
wait()
|
wait()
|
||||||
|
|
||||||
_, err = page.Evaluate(rod.Eval(`()=>{gonder('formTarget');}`))
|
_, err = page.Evaluate(rod.Eval(`()=>{gonder('formTarget');}`))
|
||||||
@@ -182,7 +189,7 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
Wait(page, 1500)
|
Wait(page, 2000)
|
||||||
|
|
||||||
allPages, err := page.Browser().Pages()
|
allPages, err := page.Browser().Pages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -190,21 +197,29 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
newPage, err := allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
|
newPage, err := allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
|
||||||
Wait(newPage, 1500)
|
|
||||||
err = WaitLoad(newPage)
|
err = WaitLoad(newPage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
frm4, err := newPage.Element("#frm4")
|
frm4, err := newPage.Element("#frm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
frame4, err := frm4.Frame()
|
frame4, err := frm4.Frame()
|
||||||
|
Wait(frame4, 1500)
|
||||||
|
err = WaitLoad(newPage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
companiesSelectBoxWait, err := frame4.Element("#SirketCombo > option")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = companiesSelectBoxWait.WaitLoad()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
companiesSelectBox, err := frame4.Elements("#SirketCombo > option")
|
companiesSelectBox, err := frame4.Elements("#SirketCombo > option")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -279,20 +294,90 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) error {
|
func (l *Luca) GetPageByUrl(url string) (*rod.Page, error) {
|
||||||
page := l.Page
|
allPages, err := l.Page.Browser().Pages()
|
||||||
allPages, err := page.Browser().Pages()
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
|
||||||
|
}
|
||||||
|
func (l *Luca) BordroTableMaping(frame *rod.Page, b *LucaBordro) (string, error) {
|
||||||
|
table := frame.MustElements(".i2")
|
||||||
|
for t := 2; t < len(table); t += 2 {
|
||||||
|
// Satırın özelliklerini al
|
||||||
|
class, _ := table[t].Attribute("class")
|
||||||
|
if t == 89 {
|
||||||
|
fmt.Print("asda")
|
||||||
|
}
|
||||||
|
id, _ := table[t+1].Attribute("id")
|
||||||
|
|
||||||
|
// Satırın textini al
|
||||||
|
text, err := table[t].Text()
|
||||||
|
|
||||||
|
fmt.Print(err)
|
||||||
|
|
||||||
|
// for k, v := range b.Ucretler {
|
||||||
|
// fmt.Print(v, k)
|
||||||
|
// //table'da key--> k i bul,
|
||||||
|
// //takip eden ilk td'deki ilk input'a v'yi yaz
|
||||||
|
// //table'da k'yi bulmazsan ve v de değer varsa hata dön
|
||||||
|
// if strings.Contains(text, k) {
|
||||||
|
// Id := ""
|
||||||
|
// if id != nil {
|
||||||
|
// Id = *id
|
||||||
|
// fmt.Println("ID:", *id)
|
||||||
|
// } else {
|
||||||
|
// Id = ""
|
||||||
|
// }
|
||||||
|
// pageScript := BordroPageScript{
|
||||||
|
// Value: text,
|
||||||
|
// Index: Id,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// Sonuçları yazdır ///text boşsa id de boş oluyo
|
||||||
|
|
||||||
|
Id := ""
|
||||||
|
if id != nil {
|
||||||
|
Id = *id
|
||||||
|
fmt.Println("ID:", *id)
|
||||||
|
} else {
|
||||||
|
Id = ""
|
||||||
|
}
|
||||||
|
if text == "" {
|
||||||
|
text = "boş Text"
|
||||||
|
}
|
||||||
|
pageScript := BordroPageScript{
|
||||||
|
Value: text,
|
||||||
|
Index: Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||||
|
fmt.Println("Text:", text)
|
||||||
|
fmt.Println("Class:", class)
|
||||||
|
fmt.Println("ID:", Id)
|
||||||
|
fmt.Println("--------------------")
|
||||||
|
}
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Luca) BordroYazPage(month, year int, b *LucaBordro) error {
|
||||||
|
newPage, err := l.GetPageByUrl("https://auygs.luca.com.tr/Luca/luca.do")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
newPage, err := allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
|
fs2, err := newPage.Element("#frm2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
frame, err := fs2.Frame()
|
||||||
fs3, err := newPage.Element("#frm3")
|
fs3, err := newPage.Element("#frm3")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -302,14 +387,21 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = ClickItem(frame, "#apy1000m0i1ITD", 1)
|
||||||
for i := 0; i < len(data); i++ {
|
|
||||||
if i != 0 {
|
|
||||||
err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(3)", 1)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
fmt.Println(err)
|
||||||
|
err = ClickItem(frame3, "#apy1000m33i4ITX", 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
err = newPage.WaitLoad()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
Wait(newPage, 1500)
|
||||||
|
|
||||||
err = WaitLoad(frame3)
|
err = WaitLoad(frame3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -323,7 +415,7 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if strings.Trim(text, " ") == data[i].Sube.Value {
|
if strings.Trim(text, " ") == b.Sube { //.Sube.Value
|
||||||
isyeriId = value.String()
|
isyeriId = value.String()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -353,7 +445,7 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if strings.Trim(text, " ") == data[i].Bolum.Value {
|
if strings.Trim(text, " ") == b.Bolum { //.Bolum.Value
|
||||||
bolumId = value.String()
|
bolumId = value.String()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -373,13 +465,10 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
aktarimDonem := strconv.FormatFloat(month, 'f', -1, 64)
|
err = ClickItem(frame3, "#tr"+strconv.FormatFloat(float64(month), 'f', -1, 64)+" > td:nth-child(1)", 2) //aktarım ayı
|
||||||
err = ClickItem(frame3, "#tr"+aktarimDonem+" > td:nth-child(1)", 2)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
personel := data[i].TCKimlikNo //"54853109724"
|
|
||||||
fmt.Println(personel)
|
|
||||||
err = WaitLoad(frame3)
|
err = WaitLoad(frame3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -403,10 +492,9 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if len(elems) == 0 {
|
if len(elems) == 0 {
|
||||||
isEmptyError := errorInfo{
|
isEmptyError := errorInfo{
|
||||||
Error: "Böyle Bir Kullanıcı Bulunamadı",
|
Error: "Böyle Bir Kullanıcı Bulunamadı",
|
||||||
Index: i,
|
Index: 1,
|
||||||
}
|
}
|
||||||
pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
for j := 0; j < len(elems); j++ {
|
for j := 0; j < len(elems); j++ {
|
||||||
tex, err := elems[j].Text()
|
tex, err := elems[j].Text()
|
||||||
@@ -417,7 +505,7 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if tex == data[i].TCKimlikNo.Value {
|
if tex == b.TcNo { //.TCKimlikNo.Value
|
||||||
foundIndex = j
|
foundIndex = j
|
||||||
if process == "Bordro Sil" {
|
if process == "Bordro Sil" {
|
||||||
isEmpty = true
|
isEmpty = true
|
||||||
@@ -429,47 +517,320 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
|||||||
if isEmpty == true {
|
if isEmpty == true {
|
||||||
isEmptyError := errorInfo{
|
isEmptyError := errorInfo{
|
||||||
Error: "Yazılı Bordro Var Lütfen Siliniz",
|
Error: "Yazılı Bordro Var Lütfen Siliniz",
|
||||||
Index: i,
|
Index: 1,
|
||||||
}
|
}
|
||||||
pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
if foundIndex != -1 {
|
if foundIndex != -1 {
|
||||||
|
|
||||||
trs[foundIndex].Click(proto.InputMouseButtonLeft, 2)
|
trs[foundIndex].Click(proto.InputMouseButtonLeft, 2)
|
||||||
}
|
}
|
||||||
|
Wait(newPage, 1500)
|
||||||
err = WaitLoad(frame3)
|
err = WaitLoad(frame3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
data[i].FillBordroForm(frame3)
|
for k, v := range b.Ucretler {
|
||||||
//err yoksa hesapla ba
|
fmt.Print(v, k)
|
||||||
err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td.right > button", 1)
|
//table'da key--> k i bul,
|
||||||
if err != nil {
|
//takip eden ilk td'deki ilk input'a v'yi yaz
|
||||||
log.Fatal(err)
|
//table'da k'yi bulmazsan ve v de değer varsa hata dön
|
||||||
}
|
}
|
||||||
err = WaitLoad(frame3)
|
rsp, err := l.BordroTableMaping(frame3, b)
|
||||||
if err != nil {
|
fmt.Print(rsp)
|
||||||
return err
|
//rsp den dönden değerler ile matchlencek ve yazılcak
|
||||||
}
|
for k, v := range b.Ucretler {
|
||||||
newBordroPage, err := frame3.Element("body > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(4)")
|
fmt.Print(v, k)
|
||||||
if err != nil {
|
//table'da key--> k i bul,
|
||||||
return err
|
//takip eden ilk td'deki ilk input'a v'yi yaz
|
||||||
}
|
//table'da k'yi bulmazsan ve v de değer varsa hata dön
|
||||||
newBordroPage.Click(proto.InputMouseButtonLeft, 1)
|
// if strings.Contains(text, k) {
|
||||||
err = WaitLoad(frame3)
|
// Id := ""
|
||||||
if err != nil {
|
// if id != nil {
|
||||||
return err
|
// Id = *id
|
||||||
|
// fmt.Println("ID:", *id)
|
||||||
|
// } else {
|
||||||
|
// Id = ""
|
||||||
|
// }
|
||||||
|
// pageScript := BordroPageScript{
|
||||||
|
// Value: text,
|
||||||
|
// Index: Id,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||||
|
// break
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CloseBrowser(l.Browser)
|
|
||||||
return err
|
|
||||||
|
|
||||||
|
// for i := 0; i < len(row); i++ {
|
||||||
|
// if i != 0 {
|
||||||
|
// err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(3)", 1)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// table := frame3.MustElements(".i2")
|
||||||
|
|
||||||
|
// // Tablodaki tüm satırları al
|
||||||
|
// // trss := table.MustElements("tr")
|
||||||
|
|
||||||
|
// // Satırları döngü ile işleyerek textleri ve diğer özellikleri al
|
||||||
|
// // for t := 0; t < len(table); t++ {
|
||||||
|
// // // Satırın özelliklerini al
|
||||||
|
// // class, _ := table[t].Attribute("class")
|
||||||
|
// // id, _ := table[t+1].Attribute("id")
|
||||||
|
|
||||||
|
// // // Satırın textini al
|
||||||
|
// // text := table[t].MustText()
|
||||||
|
// // fmt.Println("Text:", text)
|
||||||
|
// // fmt.Println("Class:", *class)
|
||||||
|
// // if id != nil {
|
||||||
|
// // fmt.Println("ID:", *id)
|
||||||
|
// // }
|
||||||
|
// // fmt.Println("-----------------------------")
|
||||||
|
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// elements := frame3.MustElements(".i2")
|
||||||
|
|
||||||
|
// // Elementleri döngü ile işleyerek metinleri ve selectorları al
|
||||||
|
// var textsAndSelectors [][]string
|
||||||
|
// for _, el := range elements {
|
||||||
|
// // Elementin metnini al
|
||||||
|
// text := el.MustText()
|
||||||
|
// // Elementin selectorunu al
|
||||||
|
// selector := el.MustEval(`s => {
|
||||||
|
// var path = "";
|
||||||
|
// for (; s && s.nodeType == Node.ELEMENT_NODE; s = s.parentNode)
|
||||||
|
// {
|
||||||
|
// idx = getElementIdx(s);
|
||||||
|
// xname = s.localName.toLowerCase();
|
||||||
|
// path = "/" + xname + "[" + idx + "]" + path;
|
||||||
|
// }
|
||||||
|
// return path;
|
||||||
|
// }`).String()
|
||||||
|
// textsAndSelectors = append(textsAndSelectors, []string{text, selector})
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Sonuçları yazdır
|
||||||
|
// for _, item := range textsAndSelectors {
|
||||||
|
// fmt.Println("Text:", item[0])
|
||||||
|
// fmt.Println("Selector:", item[1])
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //row[i].FillBordroForm(frame3)
|
||||||
|
// //err yoksa hesapla ba
|
||||||
|
// err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td.right > button", 1)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// newBordroPage, err := frame3.Element("body > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(4)")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// newBordroPage.Click(proto.InputMouseButtonLeft, 1)
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) error {
|
||||||
|
// page := l.Page
|
||||||
|
// allPages, err := page.Browser().Pages()
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// newPage, err := allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// fs3, err := newPage.Element("#frm3")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// frame3, err := fs3.Frame()
|
||||||
|
// err = newPage.WaitLoad()
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for i := 0; i < len(data); i++ {
|
||||||
|
// if i != 0 {
|
||||||
|
// err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(3)", 1)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// isyeriId := ""
|
||||||
|
// bolumId := ""
|
||||||
|
// bordroCompanySelectBox, err := frame3.Elements("#isyeriId > option")
|
||||||
|
// for j := 0; j < len(bordroCompanySelectBox); j++ {
|
||||||
|
// text, err := bordroCompanySelectBox[j].Text()
|
||||||
|
// value, err := bordroCompanySelectBox[j].Property("value")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if strings.Trim(text, " ") == data[i].Sube.Value {
|
||||||
|
// isyeriId = value.String()
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// fmt.Print(text, value)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// element, err := frame3.Element("#isyeriId")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// selectInput := Select{Element: element, Selector: "#isyeriId"}
|
||||||
|
// err = selectInput.SelectItem(isyeriId)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// bordroDepartmentSelectBox, err := frame3.Elements("#bolumId > option")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// for j := 0; j < len(bordroDepartmentSelectBox); j++ {
|
||||||
|
// text, err := bordroDepartmentSelectBox[j].Text()
|
||||||
|
// value, err := bordroDepartmentSelectBox[j].Property("value")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if strings.Trim(text, " ") == data[i].Bolum.Value {
|
||||||
|
// bolumId = value.String()
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// fmt.Print(text, value)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// element, err = frame3.Element("#bolumId")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// selectInput = Select{Element: element, Selector: "#bolumId"}
|
||||||
|
// err = selectInput.SelectItem(bolumId)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// aktarimDonem := strconv.FormatFloat(month, 'f', -1, 64)
|
||||||
|
// err = ClickItem(frame3, "#tr"+aktarimDonem+" > td:nth-child(1)", 2)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
// personel := data[i].TCKimlikNo //"54853109724"
|
||||||
|
// fmt.Println(personel)
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var isEmpty bool = false
|
||||||
|
// //var targetID string
|
||||||
|
// elems, err := frame3.Elements("#scroll > table > tbody > tr > td[id^='tcKimlikNo']")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// elemsProcess, err := frame3.Elements("#scroll > table > tbody > tr > td > a")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// trs, err := frame3.Elements("#scroll > table > tbody > tr")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// var foundIndex int = -1
|
||||||
|
// if len(elems) == 0 {
|
||||||
|
// isEmptyError := errorInfo{
|
||||||
|
// Error: "Böyle Bir Kullanıcı Bulunamadı",
|
||||||
|
// Index: i,
|
||||||
|
// }
|
||||||
|
// pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
// for j := 0; j < len(elems); j++ {
|
||||||
|
// tex, err := elems[j].Text()
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// process, err := elemsProcess[j].Text()
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if tex == data[i].TCKimlikNo.Value {
|
||||||
|
// foundIndex = j
|
||||||
|
// if process == "Bordro Sil" {
|
||||||
|
// isEmpty = true
|
||||||
|
// }
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// fmt.Print(elems, tex)
|
||||||
|
// }
|
||||||
|
// if isEmpty == true {
|
||||||
|
// isEmptyError := errorInfo{
|
||||||
|
// Error: "Yazılı Bordro Var Lütfen Siliniz",
|
||||||
|
// Index: i,
|
||||||
|
// }
|
||||||
|
// pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
||||||
|
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
// if foundIndex != -1 {
|
||||||
|
|
||||||
|
// trs[foundIndex].Click(proto.InputMouseButtonLeft, 2)
|
||||||
|
// }
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
|
||||||
|
// }
|
||||||
|
// data[i].FillBordroForm(frame3)
|
||||||
|
// //err yoksa hesapla ba
|
||||||
|
// err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td.right > button", 1)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// newBordroPage, err := frame3.Element("body > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(4)")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// newBordroPage.Click(proto.InputMouseButtonLeft, 1)
|
||||||
|
// err = WaitLoad(frame3)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// CloseBrowser(l.Browser)
|
||||||
|
// return err
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
// func (l *Luca)pageInsert(data, b* model.PageStruct){
|
// func (l *Luca)pageInsert(data, b* model.PageStruct){
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package srv
|
|||||||
import (
|
import (
|
||||||
"bordrobot/lib/bot"
|
"bordrobot/lib/bot"
|
||||||
"bordrobot/lib/company"
|
"bordrobot/lib/company"
|
||||||
"bordrobot/lib/model"
|
|
||||||
"bordrobot/lib/run"
|
"bordrobot/lib/run"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
|
"github.com/shopspring/decimal"
|
||||||
"github.com/wailsapp/wails/v3/pkg/application"
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
"github.com/xuri/excelize/v2"
|
"github.com/xuri/excelize/v2"
|
||||||
)
|
)
|
||||||
@@ -51,16 +51,6 @@ type userInfo struct {
|
|||||||
accountNo string
|
accountNo string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUser(userId string) *userInfo {
|
|
||||||
// user, ok := userDB[userId]
|
|
||||||
//
|
|
||||||
// if !ok {
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
info := userInfo{accountNo: "3197485", userName: "NOTİTEK01", password: "Notitek2025."}
|
|
||||||
//info := userInfo{accountNo: "3197485", userName: "NOTİTEK01", password: "sdaasd."}
|
|
||||||
return &info
|
|
||||||
}
|
|
||||||
func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
||||||
type CompanyInfo struct {
|
type CompanyInfo struct {
|
||||||
company *company.Company // float64.Company türünü gömme
|
company *company.Company // float64.Company türünü gömme
|
||||||
@@ -112,14 +102,33 @@ func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
|||||||
if rows[0][0] == "" {
|
if rows[0][0] == "" {
|
||||||
rows = rows[1:]
|
rows = rows[1:]
|
||||||
}
|
}
|
||||||
data := make([]*model.Bordro, 0) // []*Bordro türünde bir dilim oluştur
|
|
||||||
|
// data := make([]*model.Bordro, 0) // []*Bordro türünde bir dilim oluştur
|
||||||
for i := 1; i < len(rows); i++ {
|
for i := 1; i < len(rows); i++ {
|
||||||
bordroSatiri, err := model.NewFromExcelLine(rows[i])
|
brd := &bot.LucaBordro{
|
||||||
data = append(data, bordroSatiri)
|
Sube: rows[i][0],
|
||||||
//
|
Bolum: rows[i][1],
|
||||||
fmt.Println(bordroSatiri, err)
|
TcNo: rows[i][2],
|
||||||
|
AdSoyad: rows[i][3],
|
||||||
|
Ucretler: make(map[string]decimal.Decimal),
|
||||||
}
|
}
|
||||||
err = b.BordroYaz(data, month, year)
|
|
||||||
|
for ndx, col := range rows[i] {
|
||||||
|
if ndx > 3 {
|
||||||
|
key := rows[0][ndx]
|
||||||
|
brd.Ucretler[key], err = decimal.NewFromString(col)
|
||||||
|
if err != nil {
|
||||||
|
//todo: kullanıcıya hata logu ver
|
||||||
|
//veya tekrar okuma denebilinir
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = b.BordroYazPage(int(month), int(year), brd)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//emitLog(err.message)
|
//emitLog(err.message)
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user