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 (
|
||||
"bordrobot/lib/company"
|
||||
"bordrobot/lib/helper"
|
||||
"bordrobot/lib/model"
|
||||
"bordrobot/lib/ocr"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -19,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var pageErrors []string
|
||||
var scriptIndexArray []BordroPageScript
|
||||
|
||||
type Luca struct {
|
||||
Page *rod.Page
|
||||
@@ -28,6 +27,10 @@ type errorInfo struct {
|
||||
Error string
|
||||
Index int
|
||||
}
|
||||
type BordroPageScript struct {
|
||||
Index string
|
||||
Value string
|
||||
}
|
||||
|
||||
func VerifyCaptcha(page *rod.Page) error {
|
||||
captcha := "#captcha"
|
||||
@@ -153,7 +156,7 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
page.Timeout(500)
|
||||
page.Timeout(1000)
|
||||
loginDialog := "body > div.swal2-container.swal2-fade.swal2-in > div > div.swal2-content"
|
||||
|
||||
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ı")
|
||||
|
||||
}
|
||||
err = WaitLoad(page)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
getUrl := page.MustInfo().URL
|
||||
splitUrl := strings.Split(getUrl, "/")
|
||||
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)
|
||||
}
|
||||
fmt.Println(result)
|
||||
wait := page.WaitRequestIdle(500*time.Millisecond, nil, nil, nil)
|
||||
wait := page.WaitRequestIdle(1000*time.Millisecond, nil, nil, nil)
|
||||
wait()
|
||||
|
||||
_, 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
|
||||
}
|
||||
|
||||
Wait(page, 1500)
|
||||
Wait(page, 2000)
|
||||
|
||||
allPages, err := page.Browser().Pages()
|
||||
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")
|
||||
Wait(newPage, 1500)
|
||||
err = WaitLoad(newPage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
frm4, err := newPage.Element("#frm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -279,20 +294,90 @@ func (l *Luca) Login(company company.Company, month float64, year float64) error
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
}
|
||||
|
||||
func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) error {
|
||||
page := l.Page
|
||||
allPages, err := page.Browser().Pages()
|
||||
func (l *Luca) GetPageByUrl(url string) (*rod.Page, error) {
|
||||
allPages, err := l.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 {
|
||||
return err
|
||||
}
|
||||
|
||||
newPage, err := allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
|
||||
fs2, err := newPage.Element("#frm2")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
frame, err := fs2.Frame()
|
||||
fs3, err := newPage.Element("#frm3")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -302,174 +387,450 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
|
||||
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
|
||||
|
||||
}
|
||||
err = ClickItem(frame, "#apy1000m0i1ITD", 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
CloseBrowser(l.Browser)
|
||||
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)
|
||||
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, " ") == b.Sube { //.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, " ") == b.Bolum { //.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
|
||||
}
|
||||
err = ClickItem(frame3, "#tr"+strconv.FormatFloat(float64(month), 'f', -1, 64)+" > td:nth-child(1)", 2) //aktarım ayı
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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: 1,
|
||||
}
|
||||
pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
||||
}
|
||||
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 == b.TcNo { //.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: 1,
|
||||
}
|
||||
pageErrors = append(pageErrors, isEmptyError.Error+", Index: "+strconv.Itoa(isEmptyError.Index))
|
||||
}
|
||||
if foundIndex != -1 {
|
||||
|
||||
trs[foundIndex].Click(proto.InputMouseButtonLeft, 2)
|
||||
}
|
||||
Wait(newPage, 1500)
|
||||
err = WaitLoad(frame3)
|
||||
if err != nil {
|
||||
return 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
|
||||
}
|
||||
rsp, err := l.BordroTableMaping(frame3, b)
|
||||
fmt.Print(rsp)
|
||||
//rsp den dönden değerler ile matchlencek ve yazılcak
|
||||
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
|
||||
// }
|
||||
}
|
||||
|
||||
// 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){
|
||||
|
||||
// }
|
||||
|
||||
@@ -3,11 +3,11 @@ package srv
|
||||
import (
|
||||
"bordrobot/lib/bot"
|
||||
"bordrobot/lib/company"
|
||||
"bordrobot/lib/model"
|
||||
"bordrobot/lib/run"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
@@ -51,16 +51,6 @@ type userInfo struct {
|
||||
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 {
|
||||
type CompanyInfo struct {
|
||||
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] == "" {
|
||||
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++ {
|
||||
bordroSatiri, err := model.NewFromExcelLine(rows[i])
|
||||
data = append(data, bordroSatiri)
|
||||
//
|
||||
fmt.Println(bordroSatiri, err)
|
||||
brd := &bot.LucaBordro{
|
||||
Sube: rows[i][0],
|
||||
Bolum: rows[i][1],
|
||||
TcNo: rows[i][2],
|
||||
AdSoyad: rows[i][3],
|
||||
Ucretler: make(map[string]decimal.Decimal),
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
err = b.BordroYaz(data, month, year)
|
||||
|
||||
if err != nil {
|
||||
//emitLog(err.message)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user