Merge branch 'master' of 10.10.14.250:huanghai/dsMin

master
wubin 5 years ago
commit 4e998f4868

@ -0,0 +1,34 @@
{
"font": {
"family": "宋体",
"size": 14,
"color": "#000000"
},
"alignment": {
"horizontal": "center",
"vertical": "center"
},
"number_format": 49,
"border": [
{
"type": "left",
"color": "000000",
"style": 1
},
{
"type": "right",
"color": "000000",
"style": 1
},
{
"type": "top",
"color": "000000",
"style": 1
},
{
"type": "bottom",
"color": "000000",
"style": 1
}
]
}

@ -26,6 +26,7 @@ import (
"github.com/xormplus/builder"
"regexp"
"strconv"
"strings"
"time"
)
@ -193,7 +194,7 @@ func ExportStudentInfoExcel(targetPath string, bureauId string, ExportExcelStatu
for k := 2 + ExcelUtil.HiddenRows; k <= 5000+ExcelUtil.HiddenRows; k++ {
//设置单元格格式
cName:="B"+CommonUtil.ConvertIntToString(k)
cName := "B" + CommonUtil.ConvertIntToString(k)
f.SetCellStyle(SheetName, cName, cName, tableStyleIntStyle)
//入学年份
@ -204,7 +205,7 @@ func ExportStudentInfoExcel(targetPath string, bureauId string, ExportExcelStatu
_ = f.AddDataValidation(SheetName, dvRange)
//设置单元格格式
cName="C"+CommonUtil.ConvertIntToString(k)
cName = "C" + CommonUtil.ConvertIntToString(k)
f.SetCellStyle(SheetName, cName, cName, tableStyleIntStyle)
//班号
@ -341,7 +342,10 @@ func ImportStudentInfoExcel(excelPath string, bureauId string, actionPersonId st
}
//2、对excel的合法性进行检查
excelSuccess = checkExcel(excelPath, s1, MapClass, MapStage)
//两个有一个不成功,则提示
if !excelSuccess {
return false, "02", nil //02:在excel检测中发现问题请检查后重新上传
}
//将excel文件读取到mysql的临时数据表中
err := readToTable(excelPath, s1, MapClass, bureauId, batchId, MapStage)
if err != nil {
@ -351,7 +355,7 @@ func ImportStudentInfoExcel(excelPath string, bureauId string, actionPersonId st
mysqlSuccess = checkTempTable(excelPath, s1, batchId, bureauId)
//两个有一个不成功,则提示
if !excelSuccess || !mysqlSuccess {
if !mysqlSuccess {
return false, "02", nil //02:在excel检测中发现问题请检查后重新上传
}
@ -413,6 +417,8 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
//当前年份
CurrentYear := time.Now().Year()
RedStyle, _ := f.GetCellStyle(s1.Title, Const.RedCell)
WhiteStyle, _ := f.GetCellStyle(s1.Title, Const.WhiteCell)
for i, row := range rows {
//放过表头
@ -467,6 +473,8 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
pass = false
}
}
} else {
pass = false
}
}
}
@ -488,6 +496,13 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
if !DateUtil.CheckDateStr(row[j]) {
pass = false
}
//是合法日期
//尝试转一下整数
s := row[j]
_, err := strconv.Atoi(s)
if err == nil { //如果可以转为整数那么可能是距离1900-01-01的天数
row[j] = DateUtil.ConvertToFormatDay(row[j]) //转为合法日期格式
}
}
//(6)民族
@ -522,36 +537,42 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
}
//(10)独生子女
if j == 10 {
row[j] = strings.Replace(row[j], " ", "", -1)
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
pass = false
}
}
//(11)随迁子女
if j == 11 {
row[j] = strings.Replace(row[j], " ", "", -1)
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
pass = false
}
}
//(12)务工子女
if j == 12 {
row[j] = strings.Replace(row[j], " ", "", -1)
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
pass = false
}
}
//(13)孤儿
if j == 13 {
row[j] = strings.Replace(row[j], " ", "", -1)
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
pass = false
}
}
//(14)留守儿童
if j == 14 {
row[j] = strings.Replace(row[j], " ", "", -1)
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
pass = false
}
}
//(15)残疾儿童
if j == 15 {
row[j] = strings.Replace(row[j], " ", "", -1)
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
pass = false
}
@ -559,14 +580,18 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
//标红
cName, _ := excelize.ColumnNumberToName(j + 1)
cell := cName + CommonUtil.ConvertIntToString(i+1)
nowStyle, _ := f.GetCellStyle(s1.Title, cell)
if !pass {
//红色
style, _ := f.GetCellStyle(s1.Title, Const.RedCell)
_ = f.SetCellStyle(s1.Title, cell, cell, style)
if nowStyle != RedStyle {
_ = f.SetCellStyle(s1.Title, cell, cell, RedStyle)
}
firstSuccess = false
} else {
style, _ := f.GetCellStyle(s1.Title, Const.WhiteCell)
_ = f.SetCellStyle(s1.Title, cell, cell, style)
if nowStyle != WhiteStyle {
_ = f.SetCellStyle(s1.Title, cell, cell, WhiteStyle)
}
}
}
}
@ -707,7 +732,7 @@ func checkTempTable(excelPath string, s1 ExcelUtil.TemplateStruct, batchId strin
/****************************************************************************/
//检查学生的身份证号重复
sql = `select t1.sfzjh,t2.row_number from t_base_student as t1 inner join t_base_student_import_excel as t2
on t1.sfzjh=t2.sfzjh where t2.batch_id=? and t1.bureau_id<>?`
on t1.sfzjh=t2.sfzjh where t2.batch_id=? and t1.bureau_id<>? and t1.sfzjh<>''`
listIdCardStudent, err := db.SQL(sql, batchId, bureauId).Query().List()
if err != nil {
LogUtil.Error(Const.DataBaseActionError, "在查询学生的身份证号重复时发生严重错误!")
@ -716,7 +741,7 @@ func checkTempTable(excelPath string, s1 ExcelUtil.TemplateStruct, batchId strin
//存在学生身份证号检查重复
for i := range listIdCardStudent {
rowNumber := listIdCardStudent[i]["row_number"].(int64)
cell := "H" + CommonUtil.ConvertInt64ToString(rowNumber)
cell := "J" + CommonUtil.ConvertInt64ToString(rowNumber)
style, _ := f.GetCellStyle(s1.Title, Const.YellowCell)
_ = f.SetCellStyle(s1.Title, cell, cell, style)
//设计二级检查失败

@ -0,0 +1,15 @@
package main
import (
"dsBaseRpc/Utils/DateUtil"
"fmt"
)
func main(){
s:=DateUtil.ConvertToFormatDay("66666")
fmt.Println(s)
s=DateUtil.ConvertToFormatDay("10000")
fmt.Println(s)
}

@ -1,6 +1,9 @@
package DateUtil
import "time"
import (
"strconv"
"time"
)
/**
@ -23,6 +26,12 @@ func ConvertDateTime(ts string) time.Time {
}
func ConvertDate(ts string) time.Time {
//如果是整数并且是5位的
_, err := strconv.Atoi(ts)
if err == nil { //如果可以转为整数那么可能是距离1900-01-01的天数
return ConvertDateTime(ConvertToFormatDay(ts)+ " 00:00:00")
}
//如果是带时分秒的
if len(TimeLayoutStr) == len(ts) {
return ConvertDateTime(ts)
@ -35,8 +44,17 @@ func ConvertDate(ts string) time.Time {
2020-08-18
*/
*/
func CheckDateStr(s string) bool {
//转一下整数
dateInt, err := strconv.Atoi(s)
if err == nil { //如果可以转为整数那么可能是距离1900-01-01的天数
//能转成整数那么是不是在10000--->66666,代表1927-05-18--->2082-07-09
if dateInt < 10000 || dateInt > 66666 {
return false
}
return true
}
//这种情况下time.Parse会转成时间2014-03-01 00:00:00有一个办法是转换后如果没有报错你再Format
//跟原来的的对比一下,如果不同,那就可以是说是错误的。
t, err := time.Parse("2006-01-02", s)
@ -49,3 +67,21 @@ func CheckDateStr(s string) bool {
return false
}
}
// excel日期字段格式化 yyyy-mm-dd
func ConvertToFormatDay(excelDaysString string) string {
// 2006-01-02 距离 1900-01-01的天数
baseDiffDay := 38719 //在网上工具计算的天数需要加2天什么原因没弄清楚
curDiffDay := excelDaysString
b, _ := strconv.Atoi(curDiffDay)
// 获取excel的日期距离2006-01-02的天数
realDiffDay := b - baseDiffDay
//fmt.Println("realDiffDay:",realDiffDay)
// 距离2006-01-02 秒数
realDiffSecond := realDiffDay * 24 * 3600
//fmt.Println("realDiffSecond:",realDiffSecond)
// 2006-01-02 15:04:05距离1970-01-01 08:00:00的秒数 网上工具可查出
baseOriginSecond := 1136185445
resultTime := time.Unix(int64(baseOriginSecond+realDiffSecond), 0).Format("2006-01-02")
return resultTime
}

@ -24,11 +24,11 @@ type CurrentUserInfo struct {
Signature string `json:"signature" example:"海纳百川,有容乃大"`
Title string `json:"title" example:"大数据专家"`
Group string `json:"group" example:"东北师大理想股份有限公司-数智创新中心"`
Tags string `json:"tags" example:"[{key:0,label:大数据},{key:1,label:人工智能},{key:2,label:物联网},{key:3,label:架构},{key:4,label:数据分析},{key:5,label:海纳百川}]"`
Tags []map[string]interface{} `json:"tags" example:"[{key:0,label:大数据},{key:1,label:人工智能},{key:2,label:物联网},{key:3,label:架构},{key:4,label:数据分析},{key:5,label:海纳百川}]"`
NotifyCount int `json:"notifyCount" example:"12"`
UnreadCount int `json:"unreadCount" example:"11"`
Country string `json:"country" example:"China"`
Geographic string `json:"geographic" example:"{province:{label:吉林省,key:130000},city:{label:长春市,key:130000}}"`
Geographic map[string]interface{} `json:"geographic" example:"{province:{label:吉林省,key:130000},city:{label:长春市,key:130000}}"`
Address string `json:"address" example:"净月开发区"`
Phone string `json:"phone" example:"400-0400-662"`
}
@ -90,26 +90,56 @@ func Login(c *gin.Context) {
func CurrentUser(c *gin.Context) {
success, _ := AccountService.CurrentUser()
tags := make([]map[string]interface{}, 6)
tags[0] = make(map[string]interface{}, 1)
tags[0]["key"] = 0
tags[0]["label"] = "大数据"
tags[1] = make(map[string]interface{}, 2)
tags[1]["key"] = 1
tags[1]["label"] = "人工智能"
tags[2] = make(map[string]interface{}, 3)
tags[2]["key"] = 2
tags[2]["label"] = "物联网"
tags[3] = make(map[string]interface{}, 4)
tags[3]["key"] = 3
tags[3]["label"] = "架构"
tags[4] = make(map[string]interface{}, 5)
tags[4]["key"] = 4
tags[4]["label"] = "数据分析"
tags[5] = make(map[string]interface{}, 6)
tags[5]["key"] = 5
tags[5]["label"] = "海纳百川"
geographic := make(map[string]interface{})
geographic["province"] = make(map[string]interface{})
province := make(map[string]interface{})
province["label"] = "吉林省"
province["key"] = "130000"
geographic["province"] = province
geographic["city"] = make(map[string]interface{})
city := make(map[string]interface{})
city["label"] = "长春市"
city["key"] = "130000"
geographic["city"] = city
if success {
c.JSON(http.StatusOK, gin.H{
"status" : "ok",
"message" : CurrentUserInfo{
Name: "管理员",
Avatar: "admin.png",
Userid: "00000001",
Email: "admin@edusoa.com",
Signature: "海纳百川,有容乃大",
Title: "大数据专家",
Group: "东北师大理想股份有限公司-数智创新中心",
Tags: "[{key:0,label:大数据},{key:1,label:人工智能},{key:2,label:物联网},{key:3,label:架构},{key:4,label:数据分析},{key:5,label:海纳百川}]",
NotifyCount: 12,
UnreadCount: 11,
Country: "China",
Geographic: "{province:{label:吉林省,key:130000},city:{label:长春市,key:130000}}",
Address: "净月开发区",
Phone: "400-0400-662",
},
c.JSON(http.StatusOK, CurrentUserInfo{
Name: "管理员",
Avatar: "admin.png",
Userid: "00000001",
Email: "admin@edusoa.com",
Signature: "海纳百川,有容乃大",
Title: "大数据专家",
Group: "东北师大理想股份有限公司-数智创新中心",
Tags: tags,
NotifyCount: 12,
UnreadCount: 11,
Country: "China",
Geographic: geographic,
Address: "净月开发区",
Phone: "400-0400-662",
})
return

@ -50,71 +50,36 @@ func GetDataaccessResults(query MySwagger.DataaccessQuery) (bool, string, int, [
listJson, _ :=json.Marshal(list)
sql1 := "SELECT * FROM t_dataex_datasource WHERE 1 = 1"
//var offset1 = (query.Page - 1) * 10
//conditionSql1 := fmt.Sprintf("%s", " limit ? offset ? ")
//pageSql1 := fmt.Sprintf("%s %s", sql1, conditionSql1)
joinList1, _ := DbUtil.Engine.SQL(sql1).Query().List()
joinListJson1, _ := json.Marshal(joinList1)
mergedList1 := CommonUtil.ListMerge(string(listJson), string(joinListJson1), "datasource_id", "id", "source_systemid", "system_id")
sql2 := "SELECT * FROM t_dataex_datasource WHERE 1 = 1"
//var offset2 = (query.Page - 1) * 10
//conditionSql2 := fmt.Sprintf("%s", " limit ? offset ? ")
//pageSql2 := fmt.Sprintf("%s %s", sql2, conditionSql2)
joinList2, _ := DbUtil.Engine.SQL(sql2).Query().List()
joinListJson2, _ := json.Marshal(joinList2)
mergedList2 := CommonUtil.ListMerge(mergedList1, string(joinListJson2), "datasource_id", "id", "datasource_name", "datasource_name")
sql3 := "SELECT * FROM t_app_base WHERE 1 = 1"
//var offset3 = (query.Page - 1) * 10
//conditionSql3 := fmt.Sprintf("%s", " limit ? offset ? ")
//pageSql3 := fmt.Sprintf("%s %s", sql3, conditionSql3)
joinList3, _ := DbUtil.Engine.SQL(sql3).Query().List()
joinListJson3, _ := json.Marshal(joinList3)
mergedList3 := CommonUtil.ListMerge(mergedList2, string(joinListJson3), "source_systemid", "app_code", "source_systemname", "app_name")
sql4 := "SELECT * FROM t_app_base WHERE 1 = 1"
//var offset4 = (query.Page - 1) * 10
//conditionSql4 := fmt.Sprintf("%s", " limit ? offset ? ")
//pageSql4 := fmt.Sprintf("%s %s", sql4, conditionSql4)
joinList4, _ := DbUtil.Engine.SQL(sql4).Query().List()
joinListJson4, _ := json.Marshal(joinList4)
mergedList4 := CommonUtil.ListMerge(mergedList3, string(joinListJson4), "consume_systemid", "app_code", "consume_systemname", "app_name")
sql5 := "SELECT * FROM t_dataex_orgtree WHERE id IN (SELECT consume_orgid FROM t_dataex_dataaccess WHERE 1 = 1" + query.Conditions + ")"
joinList5, _ := DbUtil.Engine.SQL(sql5).Query().List()
joinListJson5, _ := json.Marshal(joinList5)
mergedList5 := CommonUtil.ListMerge(mergedList4, string(joinListJson5), "consume_orgid", "id", "consume_orgname", "org_name")
//通过SQL获取带缓存的数据
/*
list, count, _ := CacheUtil.Page(sql, 100, query.Page)
listJson, _ :=json.Marshal(list)
sql1 := "SELECT id FROM t_dataex_datasource WHERE 1 = 1"
joinList1, _, _ := CacheUtil.Page(sql1, 10000, 0)
joinListJson1, _ := json.Marshal(joinList1)
mergedList1 := CommonUtil.ListMerge(string(listJson), string(joinListJson1), "datasource_id", "id", "source_systemid", "system_id")
sql2 := "SELECT id FROM t_dataex_datasource WHERE 1 = 1"
joinList2, _, _ := CacheUtil.Page(sql2, 10000, 0)
joinListJson2, _ := json.Marshal(joinList2)
mergedList2 := CommonUtil.ListMerge(mergedList1, string(joinListJson2), "datasource_id", "id", "datasource_name", "datasource_name")
sql3 := "SELECT app_id FROM t_app_base WHERE 1 = 1"
joinList3, _, _ := CacheUtil.Page(sql3, 10000, 0)
joinListJson3, _ := json.Marshal(joinList3)
mergedList3 := CommonUtil.ListMerge(mergedList2, string(joinListJson3), "source_systemid", "app_id", "source_systemname", "app_name")
sql4 := "SELECT app_id FROM t_app_base WHERE 1 = 1"
joinList4, _, _ := CacheUtil.Page(sql4, 10000, 0)
joinListJson4, _ := json.Marshal(joinList4)
mergedList4 := CommonUtil.ListMerge(mergedList3, string(joinListJson4), "consume_systemid", "app_id", "consume_systemname", "app_name")
*/
fmt.Println(mergedList4)
//fmt.Println(mergedList5)
var datas []map[string]interface{}
json.Unmarshal([]byte(mergedList4), &datas)
fmt.Println(datas)
json.Unmarshal([]byte(mergedList5), &datas)
//fmt.Println(datas)
return true, "数据获取成功", count, datas, nil
} else {

@ -16,7 +16,6 @@ var db = DbUtil.Engine
func GetDatasourceRow(query string) (bool, string, map[string]interface{}, error) {
sql := "SELECT * FROM t_dataex_datasource WHERE 1 = 1 " + query
fmt.Println("sql::", sql)
var datasource models.TDataexDatasource
has, _ := DbUtil.Engine.SQL(sql).Get(&datasource)
@ -47,7 +46,7 @@ func GetDatasourceResults(query MySwagger.DatasourceQuery) (bool, string, int, [
if list != nil {
listJson, _ :=json.Marshal(list)
sql1 := "SELECT * FROM t_dataex_orgtree"
sql1 := "SELECT * FROM t_dataex_orgtree WHERE id IN (SELECT provide_orgid FROM t_dataex_datasource WHERE 1 = 1" + query.Conditions + ")"
//var offset1 = (query.Page - 1) * 10
//conditionSql1 := fmt.Sprintf("%s", " limit ? offset ? ")
//pageSql1 := fmt.Sprintf("%s %s", sql1, conditionSql1)

@ -4,6 +4,7 @@ import (
"dsSupport/MyModel/AccessSystem/AccessSystemDao"
"dsSupport/MyModel/DataSource/DatasourceService"
"dsSupport/MyModel/MySwagger"
"dsSupport/Utils/CommonUtil"
"dsSupport/Utils/ES7Util"
"fmt"
)
@ -49,6 +50,7 @@ func GetESDocCount() (bool, string, int, []map[string]interface{}) {
_, _, esdata := ES7Util.GetLatestDoc(vv["datasource_code"].(string))
data = make(map[string]interface{})
data["uuid"] = CommonUtil.GetUUID()
data["system_name"] = v["app_name"]
data["system_id"] = v["app_id"]
data["datasource_code"] = vv["datasource_code"]

Loading…
Cancel
Save