|
@@ -3497,38 +3497,51 @@ func GetWaterAndElectricity(context *gin.Context) {
|
|
|
dataByte, _ := ioutil.ReadAll(context.Request.Body)
|
|
|
fsion := gofasion.NewFasion(string(dataByte))
|
|
|
//filename := context.Param("filename")
|
|
|
- sqlnamestr := fsion.Get("name").ValueStr()
|
|
|
+ //sqlnamestr := parammap.Get("name").ValueStr()
|
|
|
pastureName := fsion.Get("pastureId").ValueStr()
|
|
|
//pastureName := fsion.Get("pasture").ValueStr()
|
|
|
//date := fsion.Get("date").ValueStr()
|
|
|
- parammap := fsion.Get("parammaps")
|
|
|
- logging.Info("DownloadMailReport ", context.Keys, sqlnamestr, pastureName)
|
|
|
+ //parammap := fsion.Get("parammaps")
|
|
|
+ //logging.Info("DownloadMailReport ", context.Keys, sqlnamestr, pastureName)
|
|
|
+ parammap := make(map[string]string, 0)
|
|
|
+ //layout := "2006-01-02"
|
|
|
+ //date, err := time.Parse(layout, "2023-06-01")
|
|
|
+ //if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ //}
|
|
|
+
|
|
|
+ //获取当月第一天
|
|
|
+ //firstOfMonth := time.Date(date.Year(), date.Month(), 1, 0, 0, 0, 0, date.Location())
|
|
|
+ //fmt.Println("当月第一天:", firstOfMonth)
|
|
|
+
|
|
|
+ //获取下个月第一天,然后减去一天即为当月最后一天
|
|
|
+ //nextMonth := firstOfMonth.AddDate(0, 1, 0)
|
|
|
+ //lastOfMonth := nextMonth.AddDate(0, 0, -1)
|
|
|
+
|
|
|
+ //parammap["startTime"] = firstOfMonth.Format("2006-01-02")
|
|
|
+ //parammap["endTime"] = lastOfMonth.Format("2006-01-02")
|
|
|
+ parammap["startTime"] = fsion.Get("startTime").ValueStr()
|
|
|
+ parammap["endTime"] = fsion.Get("endTime").ValueStr()
|
|
|
+ //if fsion.Get("pastureId").ValueStr() == "现代牧业" {
|
|
|
+ // parammap["pastureId"] = ""
|
|
|
+ //} else {
|
|
|
+ parammap["pastureId"] = fsion.Get("pastureId").ValueStr()
|
|
|
+ //}
|
|
|
+
|
|
|
sqlnamesDepartment := []string{}
|
|
|
- ///"维修费","水费","电费","柴油费","水量","电量","柴油用量"
|
|
|
if pastureName == "现代牧业" {
|
|
|
sqlnamesDepartment = []string{
|
|
|
- "getChooseWaterPrice",
|
|
|
- "getChooseElectricityPrice",
|
|
|
- "getChooseMonthiolPrice"}
|
|
|
+ "getChooseMonthWater",
|
|
|
+ "getChooseMonthElectricity",
|
|
|
+ "getChooseMonthOilT"}
|
|
|
} else {
|
|
|
sqlnamesDepartment = []string{
|
|
|
- "getChooseWaterPriceByPasture",
|
|
|
- "getChooseElectricityPriceByPasture",
|
|
|
- "getChooseMonthiolPriceByPasture"}
|
|
|
+ "getChooseMonthWaterByPasture",
|
|
|
+ "getChooseMonthElectricityByPasture",
|
|
|
+ "getChooseMonthOilTByPasture"}
|
|
|
}
|
|
|
|
|
|
- //if pastureId == "现代牧业" {
|
|
|
- // sqlnames = []string{"getChooseEqMonthBudgetListSumAll", "getChooseMonthWX", "getChooseWaterPrice", "getChooseElectricityPrice", "getChooseMonthiolPrice",
|
|
|
- // "getChooseMonthWater", "getChooseMonthElectricity", "getChooseMonthOilT", "getLgnitionChargePrice", "getChooseBiomassPrice", "getChooseGasolinePrice",
|
|
|
- // "getChooseCoalPrice"}
|
|
|
- //} else {
|
|
|
- // sqlnames = []string{"getChooseEqMonthBudgetListSumAllByPasture", "getChooseMonthWXByPasture", "getChooseWaterPriceByPasture", "getChooseElectricityPriceByPasture", "getChooseMonthiolPriceByPasture",
|
|
|
- // "getChooseMonthWaterByPasture", "getChooseMonthElectricityByPasture", "getChooseMonthOilTByPasture", "getLgnitionChargePriceByPasture", "getChooseBiomassPriceByPasture", "getChooseGasolinePriceByPasture",
|
|
|
- // "getChooseCoalPriceByPasture"}
|
|
|
- //}
|
|
|
-
|
|
|
respMapList := make([]map[string]string, 0)
|
|
|
-
|
|
|
for _, sqlname := range sqlnamesDepartment {
|
|
|
valuesMap, err := restful.MapStr("SELECT sqlstr,params FROM apisql WHERE sqlname = ? AND ENABLE>0 ", sqlname)
|
|
|
//parammap := make(map[string]interface{}, 0)
|
|
@@ -3537,11 +3550,11 @@ func GetWaterAndElectricity(context *gin.Context) {
|
|
|
paramslist := strings.Split(valuesMap["params"], ",")
|
|
|
if len(paramslist) > 0 && valuesMap["params"] != "" {
|
|
|
for _, value := range paramslist {
|
|
|
- if value == "pastureId" && parammap.Get("pastureId").ValueStr() == "" {
|
|
|
+ if value == "pastureId" && parammap["pastureId"] == "" {
|
|
|
s_params = append(s_params, "现代牧业")
|
|
|
continue
|
|
|
}
|
|
|
- s_params = append(s_params, parammap.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ s_params = append(s_params, parammap[strings.Trim(value, " ")])
|
|
|
}
|
|
|
}
|
|
|
values, err := restful.MapStrList(valuesMap["sqlstr"], s_params...)
|
|
@@ -3553,13 +3566,13 @@ func GetWaterAndElectricity(context *gin.Context) {
|
|
|
for _, item := range respMapList {
|
|
|
if item["pastureName"] == v["pastureName"] {
|
|
|
exist = true
|
|
|
- if sqlname == "getChooseWaterPrice" || sqlname == "getChooseWaterPriceByPasture" {
|
|
|
+ if sqlname == "getChooseMonthWater" || sqlname == "getChooseMonthWaterByPasture" {
|
|
|
item["waterOneCowSumPrice"] = v["oneCowSumPrice"]
|
|
|
item["waterSumPrice"] = v["sumPrice"]
|
|
|
- } else if sqlname == "getChooseElectricityPrice" || sqlname == "getChooseElectricityPriceByPasture" {
|
|
|
+ } else if sqlname == "getChooseMonthElectricity" || sqlname == "getChooseMonthElectricityByPasture" {
|
|
|
item["electricityOneCowSumPrice"] = v["oneCowSumPrice"]
|
|
|
item["electricitySumPrice"] = v["sumPrice"]
|
|
|
- } else if sqlname == "getChooseMonthiolPrice" || sqlname == "getChooseMonthiolPriceByPasture" {
|
|
|
+ } else if sqlname == "getChooseMonthOilT" || sqlname == "getChooseMonthOilTByPasture" {
|
|
|
item["monthiolOneCowSumPrice"] = v["oneCowSumPrice"]
|
|
|
item["monthiolSumPrice"] = v["sumPrice"]
|
|
|
}
|
|
@@ -3569,13 +3582,13 @@ func GetWaterAndElectricity(context *gin.Context) {
|
|
|
if !exist {
|
|
|
respMap := make(map[string]string, 0)
|
|
|
respMap["pastureName"] = v["pastureName"]
|
|
|
- if sqlname == "getChooseWaterPrice" || sqlname == "getChooseWaterPriceByPasture" {
|
|
|
+ if sqlname == "getChooseMonthWater" || sqlname == "getChooseMonthWaterByPasture" {
|
|
|
respMap["waterOneCowSumPrice"] = v["oneCowSumPrice"]
|
|
|
respMap["waterSumPrice"] = v["sumPrice"]
|
|
|
- } else if sqlname == "getChooseElectricityPrice" || sqlname == "getChooseElectricityPriceByPasture" {
|
|
|
+ } else if sqlname == "getChooseMonthElectricity" || sqlname == "getChooseMonthElectricityByPasture" {
|
|
|
respMap["electricityOneCowSumPrice"] = v["oneCowSumPrice"]
|
|
|
respMap["electricitySumPrice"] = v["sumPrice"]
|
|
|
- } else if sqlname == "getChooseMonthiolPrice" || sqlname == "getChooseMonthiolPriceByPasture" {
|
|
|
+ } else if sqlname == "getChooseMonthOilT" || sqlname == "getChooseMonthOilTByPasture" {
|
|
|
respMap["monthiolOneCowSumPrice"] = v["oneCowSumPrice"]
|
|
|
respMap["monthiolSumPrice"] = v["sumPrice"]
|
|
|
}
|