main
parent dad32c7846
commit 00c8b5d800

@ -9,3 +9,11 @@
- 04-10-2025 Добавил структуру проекта в figma
- 05-10-2025 Добавил программу конвертации Excel -> JSON
- 05-10-2025 Добавил дизайн страниц дашборда поликлиники и терапевтического отделения
- 13-10-2025 Изменил программу конвертации (версия 0.1.0)
- Добавил в обработку столбцы от A до Z
- Запуск программы: tsa.exe <CONFIG>, где файл конфигурации сордержит всю
необходимую информацию по конвертации, включая входнойи выходной файл.
- Не используемые столбцы в excel при конвертации можно просто не указывать или указать
не существующий столбец в таблице базы данных.
- Допускается указание для имен файлов относительные пути и использование русских букв.
- Для примера см. Стационар.yaml - корректность распределения столбцов не проверял!

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

@ -17,17 +17,17 @@ type Config struct {
Columns map[string]string `yaml:"columns"`
}
var VERSION = "0.0.1"
var VERSION = "0.1.0"
// Чтение конфига
func readConfig() Config {
f := os.Open("tsa.yaml")!
func readConfig(filename string) (Config, error) {
f := os.Open(filename)?
defer f.Close()
cfg := Config{}
decoder := yaml.NewDecoder(f)
decoder.Decode(&cfg)!
return cfg
decoder.Decode(&cfg)?
return cfg, nil
}
// Получаем все строки листа
@ -40,8 +40,8 @@ func readExcel(filename, sheetname string) [][]string {
}
func getColumnName(cols map[string]string, col int) string {
if col < 1 || col > 21 {
echo `Столбец: ${col} вне диапазона столбцов`
if col < 1 || col > 26 {
echo `Столбец: ${col} вне диапазона столбцов: A-Z`
os.Exit(0)
}
@ -52,7 +52,7 @@ func getColumnName(cols map[string]string, col int) string {
colsmap := []string {
" ","A","B","C","D","E","F","G","H","I",
"J","K","L","M","N","O","P","Q","R","S",
"T", "U"}
"T", "U", "V", "W", "X", "Y", "Z"}
return cols[colsmap[col]]
}
@ -85,7 +85,10 @@ func json2file(dbValues []map[string]string, outfile string) {
}
// ====================== основная программа ====================
cfg := readConfig()
if len(os.Args) < 2 {
panic "Используй: tsa.exe <CONFIG>"
}
cfg := readConfig(os.Args[1])!
rows := readExcel(cfg.FileName, cfg.SheetName)
echo "Программа конвертации excel -> json. Версия ${VERSION}"
echo "Файл ${cfg.FileName} содержит записей: ${len(rows)}"

@ -1,6 +1,6 @@
inputFile: tsa.xlsx
outputFile: tsa.json
inputFile: ../.docs/Дневной стационар 07-25дс.xlsx
outputFile: Стационар.json
sheet: Лист1
startRow: 2
columns:

@ -23,26 +23,38 @@ type Config struct {
Columns map[string]string `yaml:"columns"`
}
var VERSION = "0.0.1"
var VERSION = "0.0.2"
//line tsa.xgo:22:1
// Чтение конфига
func readConfig() Config {
func readConfig(filename string) (Config, error) {
//line tsa.xgo:24:1
f := func() (_xgo_ret *os.File) {
var _autoGo_1 *os.File
//line tsa.xgo:24:1
{
//line tsa.xgo:24:1
var _xgo_err error
//line tsa.xgo:24:1
_xgo_ret, _xgo_err = os.Open("tsa.yaml")
_autoGo_1, _xgo_err = os.Open(filename)
//line tsa.xgo:24:1
if _xgo_err != nil {
//line tsa.xgo:24:1
_xgo_err = errors.NewFrame(_xgo_err, "os.Open(\"tsa.yaml\")", "tsa.xgo", 24, "main.readConfig")
_xgo_err = errors.NewFrame(_xgo_err, "os.Open(filename)", "tsa.xgo", 24, "main.readConfig")
//line tsa.xgo:24:1
panic(_xgo_err)
return struct {
FileName string `yaml:"inputFile"`
JsonFile string `yaml:"outputFile"`
SheetName string `yaml:"sheet"`
StartRow int `yaml:"startRow"`
Columns map[string]string `yaml:"columns"`
}{}, _xgo_err
}
//line tsa.xgo:24:1
return
}()
goto _autoGo_2
_autoGo_2:
//line tsa.xgo:24:1
}
//line tsa.xgo:24:1
f := _autoGo_1
//line tsa.xgo:25:1
defer f.Close()
//line tsa.xgo:27:1
@ -50,7 +62,7 @@ func readConfig() Config {
//line tsa.xgo:28:1
decoder := yaml.NewDecoder(f)
//line tsa.xgo:29:1
func() {
{
//line tsa.xgo:29:1
var _xgo_err error
//line tsa.xgo:29:1
@ -60,13 +72,21 @@ func readConfig() Config {
//line tsa.xgo:29:1
_xgo_err = errors.NewFrame(_xgo_err, "decoder.Decode(&cfg)", "tsa.xgo", 29, "main.readConfig")
//line tsa.xgo:29:1
panic(_xgo_err)
return struct {
FileName string `yaml:"inputFile"`
JsonFile string `yaml:"outputFile"`
SheetName string `yaml:"sheet"`
StartRow int `yaml:"startRow"`
Columns map[string]string `yaml:"columns"`
}{}, _xgo_err
}
//line tsa.xgo:29:1
return
}()
goto _autoGo_3
_autoGo_3:
//line tsa.xgo:29:1
}
//line tsa.xgo:30:1
return cfg
return cfg, nil
}
//line tsa.xgo:33:1
// Получаем все строки листа
@ -111,9 +131,9 @@ func readExcel(filename string, sheetname string) [][]string {
//line tsa.xgo:42:1
func getColumnName(cols map[string]string, col int) string {
//line tsa.xgo:43:1
if col < 1 || col > 21 {
if col < 1 || col > 26 {
//line tsa.xgo:44:1
fmt.Println(stringutil.Concat(`Столбец: `, strconv.Itoa(col), ` вне диапазона столбцов`))
fmt.Println(stringutil.Concat(`Столбец: `, strconv.Itoa(col), ` вне диапазона столбцов: A-Z`))
//line tsa.xgo:45:1
os.Exit(0)
}
@ -123,7 +143,7 @@ func getColumnName(cols map[string]string, col int) string {
str string
}
//line tsa.xgo:52:1
colsmap := []string{" ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U"}
colsmap := []string{" ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
//line tsa.xgo:56:1
return cols[colsmap[col]]
}
@ -219,39 +239,58 @@ func json2file(dbValues []map[string]string, outfile string) {
// ====================== основная программа ====================
func main() {
//line tsa.xgo:88:1
cfg := readConfig()
if len(os.Args) < 2 {
//line tsa.xgo:89:1
panic("Используй: tsa.exe <CONFIG>")
}
//line tsa.xgo:91:1
cfg := func() (_xgo_ret Config) {
//line tsa.xgo:91:1
var _xgo_err error
//line tsa.xgo:91:1
_xgo_ret, _xgo_err = readConfig(os.Args[1])
//line tsa.xgo:91:1
if _xgo_err != nil {
//line tsa.xgo:91:1
_xgo_err = errors.NewFrame(_xgo_err, "readConfig(os.Args[1])", "tsa.xgo", 91, "main.main")
//line tsa.xgo:91:1
panic(_xgo_err)
}
//line tsa.xgo:91:1
return
}()
//line tsa.xgo:92:1
rows := readExcel(cfg.FileName, cfg.SheetName)
//line tsa.xgo:90:1
//line tsa.xgo:93:1
fmt.Println(stringutil.Concat("Программа конвертации excel -> json. Версия ", VERSION))
//line tsa.xgo:91:1
//line tsa.xgo:94:1
fmt.Println(stringutil.Concat("Файл ", cfg.FileName, " содержит записей: ", strconv.Itoa(len(rows))))
//line tsa.xgo:93:1
//line tsa.xgo:96:1
var dbValues = []map[string]string{}
for
//line tsa.xgo:94:1
//line tsa.xgo:97:1
_, row := range rows[cfg.StartRow-1:] {
//line tsa.xgo:95:1
//line tsa.xgo:98:1
rowValues := make(map[string]string)
for
//line tsa.xgo:96:1
//line tsa.xgo:99:1
col, val := range row {
//line tsa.xgo:97:1
colname := getColumnName(cfg.Columns, col+1)
//line tsa.xgo:100:1
colname := getColumnName(cfg.Columns, col+1)
//line tsa.xgo:103:1
if colname == "caseId" || colname == "policyNumber" {
//line tsa.xgo:101:1
//line tsa.xgo:104:1
val = fmt.Sprintf("%d", convert2int(val))
}
//line tsa.xgo:105:1
//line tsa.xgo:108:1
if colname != "" {
//line tsa.xgo:106:1
//line tsa.xgo:109:1
rowValues[colname] = val
}
}
//line tsa.xgo:111:1
//line tsa.xgo:114:1
dbValues = append(dbValues, rowValues)
}
//line tsa.xgo:116:1
//line tsa.xgo:119:1
json2file(dbValues, cfg.JsonFile)
}

@ -1 +1 @@
pocketbase serve --dir "D:\projects\tsa\database"
pocketbase serve --dir "e:\projects\board\database"

Loading…
Cancel
Save