|
|
@@ -705,6 +705,7 @@ func GetReportform(c *gin.Context) {
|
|
|
pagecount := fsion.Get("pagecount").ValueDefaultInt(0)
|
|
|
parammaps := fsion.Get("parammaps")
|
|
|
typea := parammaps.Get("typea").ValueDefaultInt(0) //0 全部 1 理论, 2实际
|
|
|
+ mode := parammaps.Get("mode").ValueDefaultInt(0)
|
|
|
logging.Info("GetReportform ", c.Keys, sqlnamestr, parammaps)
|
|
|
tx := restful.Engine.NewSession()
|
|
|
err := tx.Begin()
|
|
|
@@ -724,7 +725,7 @@ func GetReportform(c *gin.Context) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- queryData, err := praseReportform(sqlnamestr, parammaps, tx, checked, offset, pagecount, typea)
|
|
|
+ queryData, err := praseReportform(sqlnamestr, parammaps, tx, checked, offset, pagecount, typea, mode)
|
|
|
if err != nil {
|
|
|
appG.Response(http.StatusOK, e.ERROR, err.Error())
|
|
|
} else {
|
|
|
@@ -1144,15 +1145,15 @@ func GetRJSBData(c *gin.Context) {
|
|
|
arr, _ := tx.SQL(sql1, s_params1...).QueryString() //获取
|
|
|
queryData.(map[string]interface{})["list"].([]map[string]interface{})[index]["arrList"] = arr
|
|
|
}
|
|
|
- // var wg sync.WaitGroup
|
|
|
- // for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
- // wg.Add(1)
|
|
|
- // go func(value map[string]interface{}) {
|
|
|
- // defer wg.Done()
|
|
|
- // _, err = tx.SQL(`update downloadedplan set havebutton = 1 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
|
|
|
- // }(value)
|
|
|
- // }
|
|
|
- // wg.Wait()
|
|
|
+ var wg sync.WaitGroup
|
|
|
+ for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
+ wg.Add(1)
|
|
|
+ go func(value map[string]interface{}) {
|
|
|
+ defer wg.Done()
|
|
|
+ _, err = tx.SQL(`update downloadedplan set artificial = 2 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
|
|
|
+ }(value)
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
|
}
|
|
|
} else {
|
|
|
@@ -1203,7 +1204,8 @@ func PostRJSBData(c *gin.Context) {
|
|
|
if err != nil {
|
|
|
logging.Error("PostRJSBData err: ", err)
|
|
|
msg := geterrmsg(err.Error())
|
|
|
- appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, msg)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -1327,6 +1329,11 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
parammaps := fsion.Get("parammaps")
|
|
|
+ ID := parammaps.Get("ID").ValueStr()
|
|
|
+ if ID == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
s_params := make([]interface{}, 0)
|
|
|
paramslist := strings.Split(p, ",")
|
|
|
if len(paramslist) > 0 && p != "" {
|
|
|
@@ -1339,7 +1346,8 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
if err != nil {
|
|
|
logging.Error("PostRJSBData err: ", err)
|
|
|
msg := geterrmsg(err.Error())
|
|
|
- appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, msg)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -5718,7 +5726,7 @@ join lpplan lpp on lpp.id = lppland.lppid where lppland.barname = ? and lppland
|
|
|
for _, history1 := range historyList {
|
|
|
if history1["createdate"].(string) == nextcreatedate && history1["id"].(int64) == history["id"].(int64) &&
|
|
|
history1["times"].(int64) == history["times"].(int64) {
|
|
|
- data[fmt.Sprintf("a%d", times[history["times"]])] = fmt.Sprintf("%v/%v", data[fmt.Sprintf("a%d", times[history["times"]])], history["lweight"])
|
|
|
+ data[fmt.Sprintf("a%d", times[history["times"]])] = fmt.Sprintf("%v/%v", history1["lweight"], history["lweight"])
|
|
|
break
|
|
|
// exist = true
|
|
|
}
|
|
|
@@ -6715,6 +6723,19 @@ func UpdateDailyData(c *gin.Context) {
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
+
|
|
|
+ count, err := tx.SQL(`select count(1) from downloadedplan where pid in(select pid from downloadedplan where id= ? ) and havebutton = 1 and mydate = ?`, pid, date).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("UpdateDailyData-error-0:", err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("该计划已开始执行,禁止修改!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count > 0 {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("该计划已开始执行,禁止修改!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
tx.Begin()
|
|
|
|
|
|
if location == 0 {
|
|
|
@@ -7007,7 +7028,7 @@ func UpdateDailyData(c *gin.Context) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- err := tx.Commit()
|
|
|
+ err = tx.Commit()
|
|
|
if err != nil {
|
|
|
logs.Error("UpdateDailyData-error-20:", err)
|
|
|
tx.Rollback()
|
|
|
@@ -8521,8 +8542,27 @@ func checkPlan(tx *xorm.Session, fasion map[string]interface{}, CommonParamMap m
|
|
|
data := fasion["parammaps"].(map[string]interface{})
|
|
|
plancount, err := tx.Table("downloadedplan").Where(" mydate = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype in(0,1,2) ").Count()
|
|
|
fmt.Println(err)
|
|
|
- plancount1, err := tx.SQL(`select count(1) from (select d.id from downloadedplan d join downloadplandtl1 d1 on d1.pid = d.id
|
|
|
- join downloadplandtl1_exec d1e on d1e.pid = d.id join downloadplandtl2 d2 on d2.pid = d.id where d.mydate = ? and d.havebutton = 0 and lpplantype in(0,1,2) group by d.id )d `,
|
|
|
+ plancount1, err := tx.SQL(`SELECT
|
|
|
+ count( 1 )
|
|
|
+FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ d.id
|
|
|
+ FROM
|
|
|
+ downloadedplan d
|
|
|
+ JOIN downloadplandtl1 d1 ON d1.pid = d.id
|
|
|
+ JOIN downloadplandtl1_exec d1e ON d1e.pid = d.id
|
|
|
+ JOIN downloadplandtl2 d2 ON d2.pid = d.id
|
|
|
+ WHERE
|
|
|
+ d.mydate = ?
|
|
|
+ AND d.havebutton = 0
|
|
|
+ AND lpplantype IN ( 0, 1, 2 )
|
|
|
+ AND ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.id ) =
|
|
|
+ ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.pid and (select count(1) from downloadplandtl2 where pid = dd2.pid and fname = dd2.fname ) = 1 )
|
|
|
+ GROUP BY
|
|
|
+ d.id
|
|
|
+ ) d
|
|
|
+ `,
|
|
|
data["startTime"]).Count()
|
|
|
fmt.Println(err)
|
|
|
if plancount != plancount1 && number < 10 {
|
|
|
@@ -8531,3 +8571,300 @@ func checkPlan(tx *xorm.Session, fasion map[string]interface{}, CommonParamMap m
|
|
|
checkPlan(tx, fasion, CommonParamMap, ParamMap, number)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func EditPlanSort(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ planIdStr := fsions.Get("planId").ValueStr()
|
|
|
+ mydate := fsions.Get("mydate").ValueStr()
|
|
|
+ sort := fsions.Get("sort").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ tx.Begin()
|
|
|
+
|
|
|
+ type downloadedplan struct {
|
|
|
+ Id int64 `xorm:"id"`
|
|
|
+ Sort int `xorm:"sort"`
|
|
|
+ Pid int64 `xorm:"pid"`
|
|
|
+ }
|
|
|
+ planInfo := new(downloadedplan)
|
|
|
+ err := tx.SQL(`select d.id,d.sort,d.pid from downloadedplan d where d.id = ? `, planIdStr).GetFirst(planInfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sort1, _ := strconv.Atoi(sort)
|
|
|
+ if sort1 == planInfo.Sort {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "计划顺序一致修改失败!")
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ count1, err := tx.SQL(` select count(1) from downloadedplan where pid = (select pid from downloadedplan where sort = ? and mydate = ? ) and mydate = ? `, sort, mydate, mydate).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count1 == 0 {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "您所排序的数值不存在!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ count, err := tx.SQL(` select count(1) from downloadedplan where pid = (select pid from downloadedplan where sort = ? and mydate = ? ) and havebutton = 1 and mydate = ? `, sort, mydate, mydate).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count > 0 {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败,该计划已执行!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if planInfo.Sort > sort1 {
|
|
|
+ minSortList, err := tx.SQL(`select min(d.sort) sort from downloadedplan d where d.mydate = ? and d.pid = (select pid from downloadedplan where sort = ? and mydate = ? ) `, mydate, sort, mydate).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var minSort, pidCount int
|
|
|
+ for _, sort := range minSortList {
|
|
|
+ minSort, _ = strconv.Atoi(sort["sort"])
|
|
|
+ }
|
|
|
+
|
|
|
+ planList := make([]*downloadedplan, 0)
|
|
|
+ err = tx.SQL(`select id,d.sort sort,d.pid from downloadedplan d where d.mydate = ? and sort >= ? order by sort`, mydate, minSort).Find(&planList)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ planPid := planInfo.Pid
|
|
|
+ planList1 := make([]*downloadedplan, 0)
|
|
|
+ planList2 := make([]*downloadedplan, 0)
|
|
|
+
|
|
|
+ for _, plan := range planList {
|
|
|
+ if plan.Pid == planPid {
|
|
|
+ pidCount++
|
|
|
+ planList1 = append(planList1, plan)
|
|
|
+ } else {
|
|
|
+ planList2 = append(planList2, plan)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ planList1 = append(planList1, planList2...)
|
|
|
+
|
|
|
+ for i, plan := range planList1 {
|
|
|
+ _, err := tx.Exec(` update downloadedplan set sort = ? where id = ? `, minSort+i, plan.Id)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ maxSortList, err := tx.SQL(`select max(d.sort) sort from downloadedplan d where d.mydate = ? and d.pid = (select pid from downloadedplan where sort = ? and mydate = ? ) `, mydate, sort, mydate).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var maxSort int
|
|
|
+ for _, sort := range maxSortList {
|
|
|
+ maxSort, _ = strconv.Atoi(sort["sort"])
|
|
|
+ }
|
|
|
+
|
|
|
+ planList := make([]*downloadedplan, 0)
|
|
|
+ err = tx.SQL(`select id,d.sort sort,d.pid from downloadedplan d where d.mydate = ? and sort <= ? order by sort`, mydate, maxSort).Find(&planList)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ planPid := planInfo.Pid
|
|
|
+ planList1 := make([]*downloadedplan, 0)
|
|
|
+ planList2 := make([]*downloadedplan, 0)
|
|
|
+
|
|
|
+ for _, plan := range planList {
|
|
|
+ if plan.Pid == planPid {
|
|
|
+ // pidCount++
|
|
|
+ planList1 = append(planList1, plan)
|
|
|
+ } else {
|
|
|
+ planList2 = append(planList2, plan)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ planList2 = append(planList2, planList1...)
|
|
|
+
|
|
|
+ for i, plan := range planList2 {
|
|
|
+ _, err := tx.Exec(` update downloadedplan set sort = ? where id = ? `, i+1, plan.Id)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ err = tx.Commit()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func EditDownloadedplanArtificial(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ planIdStr := fsions.Get("planId").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+ tx.Begin()
|
|
|
+
|
|
|
+ planIdList := strings.Split(planIdStr, ",")
|
|
|
+
|
|
|
+ for _, planId := range planIdList {
|
|
|
+ _, err := tx.Exec(` update downloadedplan set artificial = 1 ,havebutton = 1,iscompleted = 1 where id = ? and havebutton != 1`, planId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划状态失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ err := tx.Commit()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划状态失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+type PlanRFID struct {
|
|
|
+ RFID string `json:"RFID"`
|
|
|
+ Lweight string `json:"lweight"`
|
|
|
+ Gear string `json:"gear"`
|
|
|
+ Speed string `json:"speed"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetPlanRFID(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ RFIDStr := c.Query("RFID")
|
|
|
+
|
|
|
+ planRFIDList := make([]*PlanRFID, 0)
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1411.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1322.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1904.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1870.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "2041.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, planRFIDList)
|
|
|
+}
|
|
|
+
|
|
|
+type tmrEquipmentMuster struct {
|
|
|
+ A string
|
|
|
+ N string
|
|
|
+}
|
|
|
+
|
|
|
+func GetTmrEquipmentMuster(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ id := c.Query("id")
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ dataList, err := tx.SQL(` select * from tmr_equipment_muster where pid = ? `, id).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, err.Error())
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ tmrEquipmentMusterList := make([]*tmrEquipmentMuster, 0)
|
|
|
+
|
|
|
+ for _, data := range dataList {
|
|
|
+ json.Unmarshal([]byte(data["gptjson"]), &tmrEquipmentMusterList)
|
|
|
+ for _, g := range tmrEquipmentMusterList {
|
|
|
+ a, _ := strconv.ParseFloat(g.A, 64)
|
|
|
+ n, _ := strconv.ParseFloat(g.N, 64)
|
|
|
+ a1, n1 := ddmmtoddd(a, n)
|
|
|
+ g.A = fmt.Sprintf("%f", a1)
|
|
|
+ g.N = fmt.Sprintf("%f", n1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, tmrEquipmentMusterList)
|
|
|
+}
|
|
|
+
|
|
|
+func ddmmtoddd(lng, lat float64) (float64, float64) {
|
|
|
+ // 计算度
|
|
|
+ lngDegree := int(lng / 100)
|
|
|
+ latDegree := int(lat / 100)
|
|
|
+
|
|
|
+ // 计算分
|
|
|
+ lngMinute := lng - float64(lngDegree*100)
|
|
|
+ latMinute := lat - float64(latDegree*100)
|
|
|
+
|
|
|
+ // 转换为度.dddd格式
|
|
|
+ newLng := float64(lngDegree) + lngMinute/60.0
|
|
|
+ newLat := float64(latDegree) + latMinute/60.0
|
|
|
+
|
|
|
+ return newLng, newLat
|
|
|
+}
|