Browse Source

feat: #2第二次提交

SongZihuan 4 tháng trước cách đây
mục cha
commit
a8d26d97c5
7 tập tin đã thay đổi với 346 bổ sung109 xóa
  1. 5 7
      go.mod
  2. 0 16
      go.sum
  3. 57 35
      src/excelio/readerfile.go
  4. 120 5
      src/model/action_file.go
  5. 41 37
      src/model/action_file_record.go
  6. 28 6
      src/systeminit/init.go
  7. 95 3
      src/v1main/new.go

+ 5 - 7
go.mod

@@ -4,15 +4,18 @@ go 1.19
 
 require (
 	fyne.io/fyne/v2 v2.5.2
-	github.com/flopp/go-findfont v0.1.0
+	github.com/iwdgo/fileattributes v0.0.0-20230520061604-fa928cf8ee85
+	github.com/sdassow/fyne-datepicker v0.0.0-20241102094721-b3dc166af042
+	github.com/xuri/excelize/v2 v2.9.0
 	gopkg.in/yaml.v3 v3.0.1
+	gorm.io/driver/sqlite v1.5.6
+	gorm.io/gorm v1.25.12
 )
 
 require (
 	fyne.io/systray v1.11.0 // indirect
 	github.com/BurntSushi/toml v1.4.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
-	github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 // indirect
 	github.com/fredbi/uri v1.1.0 // indirect
 	github.com/fsnotify/fsnotify v1.7.0 // indirect
 	github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
@@ -24,7 +27,6 @@ require (
 	github.com/go-text/typesetting v0.2.0 // indirect
 	github.com/godbus/dbus/v5 v5.1.0 // indirect
 	github.com/gopherjs/gopherjs v1.17.2 // indirect
-	github.com/iwdgo/fileattributes v0.0.0-20230520061604-fa928cf8ee85 // indirect
 	github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.5 // indirect
@@ -36,12 +38,10 @@ require (
 	github.com/richardlehane/mscfb v1.0.4 // indirect
 	github.com/richardlehane/msoleps v1.0.4 // indirect
 	github.com/rymdport/portal v0.2.6 // indirect
-	github.com/sdassow/fyne-datepicker v0.0.0-20241102094721-b3dc166af042 // indirect
 	github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
 	github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
 	github.com/stretchr/testify v1.8.4 // indirect
 	github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect
-	github.com/xuri/excelize/v2 v2.9.0 // indirect
 	github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect
 	github.com/yuin/goldmark v1.7.1 // indirect
 	golang.org/x/crypto v0.28.0 // indirect
@@ -50,8 +50,6 @@ require (
 	golang.org/x/net v0.30.0 // indirect
 	golang.org/x/sys v0.27.0 // indirect
 	golang.org/x/text v0.20.0 // indirect
-	gorm.io/driver/sqlite v1.5.6 // indirect
-	gorm.io/gorm v1.25.12 // indirect
 )
 
 replace github.com/go-gl/glfw/v3.3/glfw => github.com/SuperH-0630/go-glfw-im/v3.4/glfw v0.0.0-20241124173121-c79406163117

+ 0 - 16
go.sum

@@ -67,8 +67,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 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/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 h1:XBBHcIb256gUJtLmY22n99HaZTz+r2Z51xUPi01m3wg=
-github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203/go.mod h1:E1jcSv8FaEny+OP/5k9UxZVw9YFWGj7eI4KR/iOBqCg=
 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -78,9 +76,6 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m
 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
 github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
-github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
-github.com/flopp/go-findfont v0.1.0 h1:lPn0BymDUtJo+ZkV01VS3661HL6F4qFlkhcJN55u6mU=
-github.com/flopp/go-findfont v0.1.0/go.mod h1:wKKxRDjD024Rh7VMwoU90i6ikQRCr+JTHB5n4Ejkqvw=
 github.com/fredbi/uri v1.1.0 h1:OqLpTXtyRg9ABReqvDGdJPqZUxs8cyBDOMXBbskCaB8=
 github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/iW4=
 github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
@@ -101,7 +96,6 @@ github.com/go-text/render v0.2.0/go.mod h1:CkiqfukRGKJA5vZZISkjSYrcdtgKQWRa2HIzv
 github.com/go-text/typesetting v0.2.0 h1:fbzsgbmk04KiWtE+c3ZD4W2nmCRzBqrqQOvYlwAOdho=
 github.com/go-text/typesetting v0.2.0/go.mod h1:2+owI/sxa73XA581LAzVuEBZ3WEEV2pXeDswCH/3i1I=
 github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66 h1:GUrm65PQPlhFSKjLPGOZNPNxLCybjzjYBzjfoBGaDUY=
-github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
 github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
 github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@@ -165,7 +159,6 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe
 github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
-github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
@@ -244,12 +237,10 @@ github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c/go.mod h1:Qr6/a
 github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM=
 github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
-github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
-github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
 github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -411,8 +402,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
 golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
 golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
-golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
 golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
 golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -483,8 +472,6 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
-golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
 golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -496,8 +483,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
-golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
 golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
 golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -665,7 +650,6 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
-gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
 gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

+ 57 - 35
src/excelio/readerfile.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/SuperH-0630/hdangan/src/model"
 	"github.com/SuperH-0630/hdangan/src/runtime"
+	"github.com/SuperH-0630/hdangan/src/systeminit"
 	"github.com/xuri/excelize/v2"
 	"io"
 	"strconv"
@@ -13,15 +14,15 @@ import (
 )
 
 var InputTitle = map[model.FileSetType][]string{
-	model.QianRu:               {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "旧地址", "新地址", "办理时间", "备考", "材料页数", "材料"},
-	model.ChuSheng:             {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
-	model.QianChu:              {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "新地址", "办理时间", "备考", "材料页数", "材料"},
-	model.SiWang:               {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
-	model.BianGeng:             {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
-	model.SuoNeiYiJu:           {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
-	model.SuoJianYiJu:          {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
-	model.NongZiZhuanFei:       {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
-	model.YiZhanShiQianYiZheng: {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料"},
+	model.QianRu:               {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "旧地址", "新地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.ChuSheng:             {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.QianChu:              {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "新地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.SiWang:               {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.BianGeng:             {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.SuoNeiYiJu:           {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.SuoJianYiJu:          {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.NongZiZhuanFei:       {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
+	model.YiZhanShiQianYiZheng: {"档案ID", "姓名", "曾用名", "身份证", "性别", "出生日期", "是否同上", "备注", "类型", "地址", "办理时间", "备考", "材料页数", "材料", "录入人", "录入单位"},
 }
 
 var Header = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S"}
@@ -114,12 +115,12 @@ func checkTitle(t []string, tit []string) bool {
 
 func makeFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []string) int {
 	if t[0] == "" {
-		file, err := makeNewFile(rt, fst, t, tit)
+		file, record, err := makeNewFile(rt, fst, t, tit)
 		if err != nil {
 			return fail
 		}
 
-		err = model.CreateFile(rt, file.GetFile().FileSetType, file)
+		err = model.CreateFile(rt, file.GetFile().FileSetType, file, record)
 		if err != nil {
 			return fail
 		}
@@ -143,10 +144,15 @@ func makeFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []strin
 	}
 }
 
-func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []string) (model.File, error) {
+func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []string) (model.File, *model.FileMoveRecord, error) {
+	config, err := systeminit.GetInit()
+	if err != nil {
+		return nil, nil, err
+	}
+
 	name := t[1]
 	if len(name) == 0 {
-		return nil, fmt.Errorf("must has name")
+		return nil, nil, fmt.Errorf("must has name")
 	}
 
 	oldName := sql.NullString{
@@ -166,7 +172,7 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 		var err error
 		birthday, err = timeReader(time.Now(), t[5])
 		if err != nil {
-			return nil, err
+			return nil, nil, err
 		}
 	}
 
@@ -190,7 +196,7 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 		var err error
 		fileTime, err = timeReader(time.Now(), t[fileTimeIndex])
 		if err != nil {
-			return nil, err
+			return nil, nil, err
 		}
 	}
 
@@ -201,7 +207,7 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 
 	page, err := strconv.ParseInt(t[fileTimeIndex+2], 10, 64)
 	if err != nil {
-		return nil, err
+		return nil, nil, err
 	}
 
 	material := sql.NullString{
@@ -209,6 +215,16 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 		String: t[fileTimeIndex+3],
 	}
 
+	moveInPeople := sql.NullString{
+		Valid:  len(t[fileTimeIndex+4]) != 0,
+		String: t[fileTimeIndex+4],
+	}
+
+	moveInUnit := sql.NullString{
+		Valid:  len(t[fileTimeIndex+5]) != 0,
+		String: t[fileTimeIndex+5],
+	}
+
 	var res model.File
 
 	abs := model.FileAbs{
@@ -234,17 +250,17 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.QianRu:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		oldLoc := t[9]
 		if len(oldLoc) == 0 {
-			return nil, fmt.Errorf("must has old location")
+			return nil, nil, fmt.Errorf("must has old location")
 		}
 
 		newLoc := t[10]
 		if len(newLoc) == 0 {
-			return nil, fmt.Errorf("must has new location")
+			return nil, nil, fmt.Errorf("must has new location")
 		}
 
 		res = &model.FileQianRu{
@@ -256,12 +272,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.ChuSheng:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has location")
+			return nil, nil, fmt.Errorf("must has location")
 		}
 
 		res = &model.FileChuSheng{
@@ -272,12 +288,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.SiWang:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has new location")
+			return nil, nil, fmt.Errorf("must has new location")
 		}
 
 		res = &model.FileSiWang{
@@ -288,12 +304,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.BianGeng:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has location")
+			return nil, nil, fmt.Errorf("must has location")
 		}
 
 		res = &model.FileBianGeng{
@@ -304,12 +320,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.SuoNeiYiJu:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has location")
+			return nil, nil, fmt.Errorf("must has location")
 		}
 
 		res = &model.FileSuoNeiYiJu{
@@ -320,12 +336,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.SuoJianYiJu:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has new location")
+			return nil, nil, fmt.Errorf("must has new location")
 		}
 
 		res = &model.FileSuoJianYiJu{
@@ -336,12 +352,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.NongZiZhuanFei:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has location")
+			return nil, nil, fmt.Errorf("must has location")
 		}
 
 		res = &model.FileNongZiZhuanFei{
@@ -352,12 +368,12 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 	case model.YiZhanShiQianYiZheng:
 		fileType := t[8]
 		if len(fileType) == 0 {
-			return nil, fmt.Errorf("must has file type")
+			return nil, nil, fmt.Errorf("must has file type")
 		}
 
 		loc := t[9]
 		if len(loc) == 0 {
-			return nil, fmt.Errorf("must has location")
+			return nil, nil, fmt.Errorf("must has location")
 		}
 
 		res = &model.FileYiZhanShiQianYiZheng{
@@ -366,10 +382,16 @@ func makeNewFile(rt runtime.RunTime, fst model.FileSetType, t []string, tit []st
 			Location: loc,
 		}
 	default:
-		return nil, fmt.Errorf("file set type error")
+		return nil, nil, fmt.Errorf("file set type error")
+	}
+
+	record := &model.FileMoveRecord{
+		MoveStatus:       config.Yaml.Move.MoveInStatus,
+		MoveInPeopleName: moveInPeople,
+		MoveInPeopleUnit: moveInUnit,
 	}
 
-	return res, nil
+	return res, record, nil
 }
 
 func makeUpdateFile(rt runtime.RunTime, fileID int64, fst model.FileSetType, t []string, tit []string) (model.File, error) {

+ 120 - 5
src/model/action_file.go

@@ -4,6 +4,7 @@ import (
 	"errors"
 	"fmt"
 	"github.com/SuperH-0630/hdangan/src/runtime"
+	"github.com/SuperH-0630/hdangan/src/systeminit"
 	"gorm.io/gorm"
 )
 
@@ -194,7 +195,12 @@ func DeleteFile(rt runtime.RunTime, f File) error {
 	return db.Delete(f).Error
 }
 
-func CreateFile(rt runtime.RunTime, fst FileSetType, fc File) error {
+func CreateFile(rt runtime.RunTime, fst FileSetType, fc File, record *FileMoveRecord) error {
+	config, err := systeminit.GetInit()
+	if err != nil {
+		return err
+	}
+
 	db, err := GetDB(rt)
 	if err != nil {
 		return err
@@ -214,24 +220,113 @@ func CreateFile(rt runtime.RunTime, fst FileSetType, fc File) error {
 		nf.FileSetID = fs.FileSetID
 		nf.FileSetType = fs.FileSetType
 		nf.FileSetSQLID = int64(fs.ID)
-		nf.PageStart = fs.PageCount + 1
-		nf.PageEnd = fs.PageCount + nf.PageCount
 
 		fs.PageCount += nf.PageEnd
 
 		if nf.SameAsAbove {
 			lf.PeopleCount += 1
 			nf.PeopleCount = lf.PeopleCount
+
+			nf.Time = lf.Time
+			nf.PageCount = lf.PageCount
+			nf.PageStart = lf.PageStart
+			nf.PageEnd = lf.PageEnd
+			nf.PeopleCount = lf.PeopleCount
+
+			nf.LastMoveRecordID = lf.LastMoveRecordID
+
+			switch ff := fc.(type) {
+			case *FileQianRu:
+				lff, ok := lastf.(*FileQianRu)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.OldLocation = lff.OldLocation
+				ff.NewLocation = lff.NewLocation
+			case *FileChuSheng:
+				lff, ok := lastf.(*FileChuSheng)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.NewLocation = lff.NewLocation
+			case *FileQianChu:
+				lff, ok := lastf.(*FileQianChu)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.NewLocation = lff.NewLocation
+			case *FileSiWang:
+				lff, ok := lastf.(*FileSiWang)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.Location = lff.Location
+			case *FileBianGeng:
+				lff, ok := lastf.(*FileBianGeng)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.Location = lff.Location
+			case *FileSuoNeiYiJu:
+				lff, ok := lastf.(*FileSuoNeiYiJu)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.Location = lff.Location
+			case *FileSuoJianYiJu:
+				lff, ok := lastf.(*FileSuoJianYiJu)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.Location = lff.Location
+			case *FileNongZiZhuanFei:
+				lff, ok := lastf.(*FileNongZiZhuanFei)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.Location = lff.Location
+			case *FileYiZhanShiQianYiZheng:
+				lff, ok := lastf.(*FileYiZhanShiQianYiZheng)
+				if !ok {
+					return fmt.Errorf("file set type error")
+				}
+
+				ff.Type = lff.Type
+				ff.Location = lff.Location
+			}
+
 		} else {
 			nf.PeopleCount = 1
+			nf.PageStart = fs.PageCount + 1
+			nf.PageEnd = fs.PageCount + nf.PageCount
 		}
 
-		err = tx.Create(nf).Error
+		err = tx.Create(fc).Error
 		if err != nil {
 			return err
 		}
 
-		err = tx.Update("peoplecount", lf.PeopleCount).Error
+		modelMaker, ok := FileSetTypeMaker[fst]
+		if !ok {
+			return fmt.Errorf("bad file set type")
+		}
+		err = tx.Model(modelMaker()).Update("peoplecount", lf.PeopleCount).Where("fileunionid = ?", lf.FileUnionID).Error
 		if err != nil {
 			return err
 		}
@@ -241,6 +336,26 @@ func CreateFile(rt runtime.RunTime, fst FileSetType, fc File) error {
 			return err
 		}
 
+		if record != nil && !nf.SameAsAbove {
+			record.MoveStatus = config.Yaml.Move.MoveInStatus
+			record.MoveTime = nf.Time
+
+			if !record.MoveInPeopleName.Valid || len(record.MoveInPeopleName.String) == 0 {
+				record.MoveInPeopleName.Valid = true
+				record.MoveInPeopleName.String = config.Yaml.Move.MoveInPeopleDefault
+			}
+
+			if !record.MoveInPeopleUnit.Valid || len(record.MoveInPeopleUnit.String) == 0 {
+				record.MoveInPeopleUnit.Valid = true
+				record.MoveInPeopleUnit.String = config.Yaml.Move.MoveInUnitDefault
+			}
+
+			err := createFileRecord(rt, tx, fc, record)
+			if err != nil {
+				return err
+			}
+		}
+
 		return nil
 	})
 }

+ 41 - 37
src/model/action_file_record.go

@@ -205,55 +205,59 @@ func CreateFileRecord(rt runtime.RunTime, fc File, record *FileMoveRecord) error
 		return err
 	}
 
+	return db.Transaction(func(tx *gorm.DB) error {
+		return createFileRecord(rt, tx, fc, record)
+	})
+}
+
+func createFileRecord(rt runtime.RunTime, tx *gorm.DB, fc File, record *FileMoveRecord) error {
 	f := fc.GetFile()
 	if f.ID <= 0 {
 		return fmt.Errorf("file not save")
 	}
 
-	return db.Transaction(func(tx *gorm.DB) error {
-		var file1 FileAbs
-		var oldRecord *FileMoveRecord
+	var file1 FileAbs
+	var oldRecord *FileMoveRecord
 
-		oldRecord, err := FindMoveRecord(rt, fc)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			oldRecord = nil
-		} else {
-			return err
-		}
+	oldRecord, err := FindMoveRecord(rt, fc)
+	if errors.Is(err, gorm.ErrRecordNotFound) {
+		oldRecord = nil
+	} else {
+		return err
+	}
 
-		err = tx.Where("fileunionid = ?", f.FileUnionID).Order("filegroupid asc").First(&file1).Error
-		err = tx.Save(record).Error
-		if err != nil {
-			return err
-		}
+	err = tx.Where("fileunionid = ?", f.FileUnionID).Order("filegroupid asc").First(&file1).Error
+	err = tx.Save(record).Error
+	if err != nil {
+		return err
+	}
 
-		record.FileSetSQLID = file1.FileSetSQLID
-		record.FileSetID = file1.FileSetID
-		record.FileSetType = file1.FileSetType
+	record.FileSetSQLID = file1.FileSetSQLID
+	record.FileSetID = file1.FileSetID
+	record.FileSetType = file1.FileSetType
 
-		record.FileSQLID = int64(file1.ID)
-		record.FileUnionID = int64(file1.ID)
+	record.FileSQLID = int64(file1.ID)
+	record.FileUnionID = int64(file1.ID)
 
-		if oldRecord != nil {
-			record.UpRecord = sql.NullInt64{Valid: true, Int64: int64(oldRecord.ID)}
-		}
-		err = tx.Save(record).Error
-		if err != nil {
-			return err
-		}
+	if oldRecord != nil {
+		record.UpRecord = sql.NullInt64{Valid: true, Int64: int64(oldRecord.ID)}
+	}
+	err = tx.Save(record).Error
+	if err != nil {
+		return err
+	}
 
-		err = tx.Update("lastmoverecordid", sql.NullInt64{Valid: true, Int64: int64(record.ID)}).Where("fileunionid = ?", file1.FileUnionID).Error
+	err = tx.Update("lastmoverecordid", sql.NullInt64{Valid: true, Int64: int64(record.ID)}).Where("fileunionid = ?", file1.FileUnionID).Error
+	if err != nil {
+		return err
+	}
+
+	if oldRecord != nil {
+		oldRecord.NextRecord = sql.NullInt64{Valid: true, Int64: int64(record.ID)}
+		err = tx.Save(oldRecord).Error
 		if err != nil {
 			return err
 		}
-
-		if oldRecord != nil {
-			oldRecord.NextRecord = sql.NullInt64{Valid: true, Int64: int64(record.ID)}
-			err = tx.Save(oldRecord).Error
-			if err != nil {
-				return err
-			}
-		}
-		return nil
-	})
+	}
+	return nil
 }

+ 28 - 6
src/systeminit/init.go

@@ -38,14 +38,24 @@ func (r *Report) init() error {
 }
 
 type Move struct {
-	MoveInStatus string   `yaml:"moveInStatus"`
-	MoveStatus   []string `yaml:"moveStatus"`
-	MoveUnit     []string `yaml:"moveUnit"`
+	MoveInStatus        string   `yaml:"moveInStatus"`
+	MoveStatus          []string `yaml:"moveStatus"`
+	MoveUnit            []string `yaml:"moveUnit"`
+	MoveInPeopleDefault string   `yaml:"moveInPeopleDefault"`
+	MoveInUnitDefault   string   `yaml:"moveInUnitDefault"`
 }
 
 func (m *Move) init() error {
 	if len(m.MoveInStatus) == 0 {
-		m.MoveInStatus = "在档"
+		m.MoveInStatus = "初次录入"
+	}
+
+	if len(m.MoveInPeopleDefault) == 0 {
+		m.MoveInPeopleDefault = "管理员"
+	}
+
+	if len(m.MoveInUnitDefault) == 0 {
+		m.MoveInUnitDefault = "管理局"
 	}
 
 	func() {
@@ -57,6 +67,15 @@ func (m *Move) init() error {
 		m.MoveStatus = append(m.MoveStatus, m.MoveInStatus)
 	}()
 
+	func() {
+		for _, s := range m.MoveStatus {
+			if s == m.MoveInUnitDefault {
+				return
+			}
+		}
+		m.MoveStatus = append(m.MoveStatus, m.MoveInUnitDefault)
+	}()
+
 	for _, s := range m.MoveStatus {
 		if s == "无" || s == "暂无" {
 			return fmt.Errorf("不允许的部门")
@@ -226,15 +245,18 @@ func GetInit() (InitConfig, error) {
 					Email: "songzihuan@song-zh.com",
 				},
 				Move: Move{
-					MoveInStatus: "归档",
+					MoveInStatus: "初次录入",
 					MoveStatus: []string{
-						"归档", "借出",
+						"初次录入", "借出", "归还",
 					},
 					MoveUnit: []string{
+						"管理局",
 						"一中队",
 						"二中队",
 						"三中队",
 					},
+					MoveInPeopleDefault: "管理员",
+					MoveInUnitDefault:   "管理局",
 				},
 				File: File{},
 				FileSet: FileSet{

+ 95 - 3
src/v1main/new.go

@@ -2,6 +2,7 @@ package v1main
 
 import (
 	"database/sql"
+	"errors"
 	"fmt"
 	"fyne.io/fyne/v2"
 	"fyne.io/fyne/v2/container"
@@ -18,6 +19,15 @@ import (
 )
 
 func ShowNew(rt runtime.RunTime, w *CtrlWindow, refresh func(rt runtime.RunTime)) {
+	config, err := systeminit.GetInit()
+	if errors.Is(err, systeminit.LuckyError) {
+		rt.DBConnectError(err)
+		return
+	} else if err != nil {
+		rt.DBConnectError(fmt.Errorf("配置文件错误,请检查配置文件状态。"))
+		return
+	}
+
 	newWindow := rt.App().NewWindow("创建记录")
 
 	newWindow.SetOnClosed(func() {
@@ -37,6 +47,9 @@ func ShowNew(rt runtime.RunTime, w *CtrlWindow, refresh func(rt runtime.RunTime)
 	}
 
 	fm := maker()
+	record := &model.FileMoveRecord{
+		MoveStatus: config.Yaml.Move.MoveInStatus,
+	}
 	f := fm.GetFile()
 
 	f.PeopleCount = 1
@@ -50,11 +63,11 @@ func ShowNew(rt runtime.RunTime, w *CtrlWindow, refresh func(rt runtime.RunTime)
 	}
 
 	material := widget.NewMultiLineEntry()
-	material.Text = strToStr(f.Comment, "")
+	material.Text = strToStr(f.Material, "")
 	material.Wrapping = fyne.TextWrapWord
 	material.OnChanged = func(s string) {
 		rt.Action()
-		material.Text = strToStr(f.Comment, "")
+		material.Text = strToStr(f.Material, "")
 	}
 
 	if !f.OldName.Valid {
@@ -187,6 +200,12 @@ func ShowNew(rt runtime.RunTime, w *CtrlWindow, refresh func(rt runtime.RunTime)
 
 		widget.NewLabel("材料:"),
 		material,
+
+		widget.NewLabel("记录人:"),
+		newEntryWithNULL4(config.Yaml.Move.MoveInPeopleDefault, &record.MoveInPeopleName, &sameAboveDisableList),
+
+		widget.NewLabel("记录单位:"),
+		newMoveUnitSelectWithNULL4(config.Yaml.Move.MoveInUnitDefault, config.Yaml.Move.MoveUnit, &record.MoveInPeopleUnit, &sameAboveDisableList),
 	)
 
 	rightLayout := layout.NewFormLayout()
@@ -205,7 +224,7 @@ func ShowNew(rt runtime.RunTime, w *CtrlWindow, refresh func(rt runtime.RunTime)
 		dialog.ShowConfirm("创建?", "你确定要新增档案嘛?", func(b bool) {
 			rt.Action()
 			if b {
-				err := model.CreateFile(rt, w.table.fileSetType, fm)
+				err := model.CreateFile(rt, w.table.fileSetType, fm, record)
 				if err != nil {
 					dialog.ShowError(fmt.Errorf("数据库错误: %s", err.Error()), newWindow)
 				}
@@ -268,6 +287,75 @@ func newEntry4(data string, input *string, disableLst *[]fyne.Disableable) *widg
 	return entry
 }
 
+func newEntryWithNULL4(data string, input *sql.NullString, disableLst *[]fyne.Disableable) *widget.Entry {
+	entry := widget.NewEntry()
+	entry.Text = data
+
+	entry.OnChanged = func(s string) {
+		if entry.Validate() == nil {
+			if len(s) == 0 {
+				*input = sql.NullString{
+					Valid:  false,
+					String: "",
+				}
+			} else {
+				*input = sql.NullString{
+					Valid:  true,
+					String: s,
+				}
+			}
+		}
+	}
+
+	entryList4 = append(entryList4, entry)
+
+	if disableLst != nil {
+		*disableLst = append(*disableLst, entry)
+	}
+
+	return entry
+}
+
+func newMoveUnitSelectWithNULL4(data string, firstOptions []string, input *sql.NullString, disableLst *[]fyne.Disableable) *widget.Select {
+	const emptySelectItem = "暂无"
+
+	if data == "" {
+		data = emptySelectItem
+	}
+
+	options := make([]string, 0, len(firstOptions)+1)
+	options = append(options, emptySelectItem)
+
+	for _, fo := range firstOptions {
+		if fo != emptySelectItem && fo != "" {
+			options = append(options, fo)
+		}
+	}
+
+	sel := widget.NewSelect(options, func(s string) {
+		if len(s) == 0 || s == emptySelectItem {
+			*input = sql.NullString{
+				Valid:  false,
+				String: "",
+			}
+		} else {
+			*input = sql.NullString{
+				Valid:  true,
+				String: s,
+			}
+		}
+	})
+
+	sel.PlaceHolder = ""
+	sel.Selected = data
+
+	if disableLst != nil {
+		*disableLst = append(*disableLst, sel)
+	}
+
+	return sel
+}
+
 func newEntryPage4(data int64, input *int64, disableLst *[]fyne.Disableable) *widget.Entry {
 	entry := widget.NewEntry()
 	entry.Text = fmt.Sprintf("%d", data)
@@ -480,6 +568,10 @@ func newSameAboveCheck4(data string, input *bool, disableLst *[]fyne.Disableable
 
 func checkAllInputRight4() error {
 	for _, e := range entryList4 {
+		if e.Disabled() {
+			continue
+		}
+
 		err := e.Validate()
 		if err != nil {
 			return err