baishaojie 9 months ago
parent
commit
92dda6390c

BIN
TMRWatchComm


BIN
__debug_bin.exe


+ 1 - 1
conf/app.ini

@@ -73,7 +73,7 @@ Host = 192.168.1.93:3326
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = tmrwatch5
+Name = yq2
 TablePrefix =
 
 ShowXormlog = false

+ 7 - 6
http/handle/api/ops.go

@@ -8975,8 +8975,8 @@ func FtdetailSurplus(fasion *gofasion.Fasion) {
 		ftList := make([]*ftdetail, 0)
 		for _, data := range dataList {
 			ft := new(ftdetail)
-			ft.Fname = data["id"]
-			ft.Id = data["fname"]
+			ft.Fname = data["fname"]
+			ft.Id = data["id"]
 
 			sort, err := strconv.ParseInt(data["sort"], 10, 64)
 			if err != nil {
@@ -8991,9 +8991,10 @@ func FtdetailSurplus(fasion *gofasion.Fasion) {
 			for _, ft := range ftList {
 				tx.Exec(` update ftdetail set sort = ? where id = ? `, ft.Sort+1, ft.Id)
 			}
-			tx.Exec(` insert into ftdetail(ftid,fid,fname,sort,is_surplus,is_show,feedgroup,fweight)
- values(?,(select id from feed where backup3 = ? ),(select fname from feed where backup3 = ? ),1,1,2,(select fname from feed where backup3 = ? ),0)`,
-				params.Get("id").ValueStr(), surplusId, surplusId, surplusId)
+			_, err = tx.Exec(` insert into ftdetail(pastureid,ftid,fid,fname,sort,is_surplus,is_show,feedgroup,fweight)
+ values(?,?,(select id from feed where backup3 = ? ),(select fname from feed where backup3 = ? ),0,1,2,(select fname from feed where backup3 = ? ),0)`,
+				params.Get("pastureid").ValueStr(), params.Get("id").ValueStr(), surplusId, surplusId, surplusId)
+			fmt.Println(err)
 		} else {
 			var sort int64
 			for _, ft := range ftList {
@@ -9008,7 +9009,7 @@ func FtdetailSurplus(fasion *gofasion.Fasion) {
 				}
 			} else {
 				for _, ft := range ftList {
-					if ft.Sort > sort {
+					if ft.Sort >= sort {
 						ft.Sort = ft.Sort + 1
 					}
 				}

+ 2 - 2
http/handle/api/scheduled.go

@@ -136,10 +136,10 @@ func CronScheduled(ctx context.Context) {
 	// xdmy := cron.New()
 	// err = xdmy.AddFunc("0 30 4 * * *", func() {
 	// 	// 	//现代牧业sap同步
-	// 	// sap.SyncMaterialOutbound()
+	// 	sap.SyncMaterialOutbound()
 	// 	// 	// 光明ud同步
 	// 	// 	fmt.Println(time.Now())
-	// 	gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
+	// 	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// })
 	// xdmy.Start()
 	// InitMqttClient()

+ 5 - 1
http/handle/api/upload.go

@@ -762,7 +762,7 @@ func GetBarfeedremainExcel(c *gin.Context) {
 	cell.SetStyle(style)
 	cell = row.AddCell()
 
-	cell.SetValue("班次(第一班/第二班/第三班)")
+	cell.SetValue("班次(一天/第一班/第二班/第三班)")
 	cell.SetStyle(style)
 	cell = row.AddCell()
 
@@ -770,6 +770,10 @@ func GetBarfeedremainExcel(c *gin.Context) {
 	cell.SetStyle(style)
 	cell = row.AddCell()
 
+	cell.SetValue("原料所属时间")
+	cell.SetStyle(style)
+	cell = row.AddCell()
+
 	cell.SetValue("操作人")
 	cell.SetStyle(style)
 	cell = row.AddCell()

+ 54 - 0
http/handle/api/user.go

@@ -294,3 +294,57 @@ func GetWxCode(c *gin.Context) {
 	}
 	appG.Response(http.StatusOK, e.SUCCESS, dataMap)
 }
+
+func GetYqWxCode(c *gin.Context) {
+	appG := app.Gin{C: c}
+	code := c.Query("code")
+
+	url := "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=%s"
+	var appid, secret, jsCode, grantType string
+	jsCode = code
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	wxConfigList, err := tx.SQL(" select * from wx_config where system = ? ", "yq").Query().List()
+	if err != nil {
+		logs.Error("GetWxCode-error1:", err)
+		appG.Response(http.StatusInternalServerError, e.ERROR, false)
+		return
+	}
+
+	for _, wx := range wxConfigList {
+		grantType = wx["grantType"].(string)
+		appid = wx["appid"].(string)
+		secret = wx["secret"].(string)
+	}
+	url = fmt.Sprintf(url, appid, secret, jsCode, grantType)
+
+	client := &http.Client{Timeout: 5 * time.Second}
+	payload := strings.NewReader(``)
+	req, err := http.NewRequest(http.MethodGet, url, payload)
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH_TOKEN, err)
+		return
+	}
+	res, err := client.Do(req)
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH_TOKEN, err)
+		return
+	}
+	defer res.Body.Close()
+
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH_TOKEN, err)
+		return
+	}
+
+	var data interface{}
+	json.Unmarshal(body, &data)
+	dataMap := data.(map[string]interface{})
+	if _, ok := dataMap["code"]; !ok {
+		dataMap["code"] = ""
+	}
+	appG.Response(http.StatusOK, e.SUCCESS, dataMap)
+}

+ 14 - 13
http/handle/sap/sap.go

@@ -174,18 +174,18 @@ func materialOutbound(pastureId, date string) error {
 	 d2.fname,IFNULL(ftd.fname,d1.fname ) feedname,
 	SUM(
 	  d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
-	  d1.lweight*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE ftd2.pastureid =d1.pastureid AND ftd2.ftid = d1.fid and ftd2.date= ftp.date ))
+	  d1.lweight*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE ftd2.pastureid =d1.pastureid AND ftd2.ftid = d1.fid and ftd2.date= ftd1.date ))
 	 )lweight,
 	d1.sort sort,
 		  SUM(
-		 if ( (SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date) > 0 ,
-	  d2.actualweightminus/(SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
-	  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE ftd2.pastureid =d1.pastureid AND ftd2.ftid = d1.fid and ftd2.date= ftp.date  )),
-		
-		 d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
-	  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetail ftd2 WHERE ftd2.pastureid =d1.pastureid AND ftd2.ftid = d1.fid ))
-		)
-	 )actualweightminus,b.sort as d2sort,b.bname,b.sapcode, b.cattlecode ,f.sapCode MATNR,f.sapGoods ,(select cattle from feedtemplet where id = d.tempid) cattle
+ if ( (SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)  > 0 ,
+  d2.actualweightminus/(SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetail ftd2 WHERE ftd2.pastureid =d1.pastureid AND ftd2.ftid = d1.fid )),
+	
+	 d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd1.version and ftd1.id = ftd2.ftid  ))
+	)
+ )actualweightminus,b.sort as d2sort,b.bname,b.sapcode, b.cattlecode ,f.sapCode MATNR,f.sapGoods ,(select cattle from feedtemplet where id = d.tempid) cattle
 	 
 	 FROM 
 	downloadedplan d
@@ -194,11 +194,12 @@ func materialOutbound(pastureId, date string) error {
 	ON d.pastureid = d2.pastureid AND d2.pid = d.id   and d2.type = 0
 	JOIN downloadplandtl1 d1
 	ON d.pastureid = d1.pastureid AND d1.flpid = d2.flpid AND d1.type = 0 AND d2.date = d1.date
--- 	LEFT JOIN ftdetaildate ftd ON  ftd.pastureid =d1.pastureid AND ftd.ftid = d1.fid AND d1.feedcode = '-1' AND ftd.date = d.mydate AND ftd.version = d.tversion
 	left join bar b  on b.pastureid =d1.pastureid and b.id = d2.fbarid 
 	
-	left join feedtempletdate ftp  on ftp.id = d1.fid  and ftp.date = ?
-	left join ftdetaildate ftd on  ftd.ftid = ftp.id   and ftd.date = ?
+	left join feedtempletdate  ftd1 on   d1.feedcode = '-1'  and ftd1.date = d1.date and ftd1.id = d1.fid 
+LEFT JOIN ftdetaildate ftd ON  ftd.pastureid =d1.pastureid AND ftd.ftid = ftd1.id AND d1.feedcode = '-1' AND ftd.date =d1.date AND ftd.version = ftd1.version
+
+
 left join feed f on f.id = ftd.fid
 	WHERE d.pastureid = ? AND  d.mydate = ? and d1.feedcode  = -1   and  b.sapCode is not null  and  f.sapCode is not null 
 	GROUP BY d2.fbarid,IFNULL(ftd.fname,d1.fname )
@@ -206,7 +207,7 @@ left join feed f on f.id = ftd.fid
 	
 	) tem
 	
-	ORDER BY tem.d2sort,tem.feedname   `, pastureId, pastureId, pastureId, date, date, date, pastureId, date).Query().List()
+	ORDER BY tem.d2sort,tem.feedname  `, pastureId, pastureId, pastureId, date, pastureId, date).Query().List()
 	if err != nil {
 		logs.Error(err)
 		return err

+ 5 - 1
update.sql

@@ -356,4 +356,8 @@ ALTER TABLE `feedtemplet`
 ADD COLUMN `surplus` int NULL COMMENT '剩料配置' AFTER `autozone`;
 
 ALTER TABLE `ftdetail` 
-ADD COLUMN `is_surplus` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0 不是剩料' AFTER `shutdown`;
+ADD COLUMN `is_surplus` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0 不是剩料' AFTER `shutdown`;
+
+
+ALTER TABLE `downloadplandtl1_exec` 
+ADD COLUMN `surplus` decimal(10, 2) NULL COMMENT '剩料重量' AFTER `xxwFeedCode`;