Commit 48f0d1f4 by mushishixian

加上同步状态判断

parent a6aa2bb2
...@@ -54,8 +54,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -54,8 +54,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//判断操作类型 //判断操作类型
switch message.Type { switch message.Type {
case "save": case "save":
//先去查询是否存在,不存在才去插入,已经存在即是修改 //先去查询是否存在已经同步完成的记录
if logic.CheckGoodsExist(goods.ErpId) { if logic.CheckGoodsSyncStatus(goods.ErpId) {
operateType = "update" operateType = "update"
if err = logic.UpdateGoods(goods); err != nil { if err = logic.UpdateGoods(goods); err != nil {
goto ERR goto ERR
......
...@@ -194,7 +194,6 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) { ...@@ -194,7 +194,6 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
for key, value := range responseData { for key, value := range responseData {
//金蝶判断成功的标志 //金蝶判断成功的标志
if key == "0000" { if key == "0000" {
fmt.Println("OK")
return return
} }
//金额判断失败的标志 //金额判断失败的标志
......
...@@ -52,8 +52,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -52,8 +52,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//判断操作类型 //判断操作类型
switch message.Type { switch message.Type {
case "save": case "save":
//先去查询是否存在,不存在才去插入,已经存在即是修改 //先去查询是否存在已经同步完成的记录
if logic.CheckSupplierExist(supplier.ErpId) { if logic.CheckSupplierSyncStatus(supplier.ErpId) {
operateType = "update" operateType = "update"
if err = logic.UpdateSupplier(supplier); err != nil { if err = logic.UpdateSupplier(supplier); err != nil {
goto ERR goto ERR
......
...@@ -6,7 +6,9 @@ import ( ...@@ -6,7 +6,9 @@ import (
"time" "time"
) )
const CheckGoodsExistSql = "SELECT goods_id FROM lie_goods WHERE erp_id = ? AND sync_status = 1" const CheckGoodsExistSql = "SELECT goods_id FROM lie_goods WHERE erp_id = ?"
const CheckGoodsSyncStatusSql = "SELECT sync_status FROM lie_goods WHERE erp_id = ?"
const InsertGoodsSql = "INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`brand_name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?,?)" const InsertGoodsSql = "INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`brand_name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?,?)"
...@@ -25,10 +27,19 @@ func CheckGoodsExist(erpId string) (exist bool) { ...@@ -25,10 +27,19 @@ func CheckGoodsExist(erpId string) (exist bool) {
return goodsId > 0 return goodsId > 0
} }
//获取后端同步状态
func CheckGoodsSyncStatus(erpId string) (status bool) {
var statusInt int
dao.GetDb().QueryRowx(CheckGoodsSyncStatusSql, erpId).Scan(&statusInt)
return statusInt > 0
}
//插入物料 //插入物料
func InsertGoods(goods model.Goods) (err error) { func InsertGoods(goods model.Goods) (err error) {
if !CheckGoodsExist(goods.ErpId) {
_, err = dao.GetDb().Exec(InsertGoodsSql, goods.GoodsName, goods.GoodsCnName, _, err = dao.GetDb().Exec(InsertGoodsSql, goods.GoodsName, goods.GoodsCnName,
goods.BrandName, goods.ErpId, time.Now().Unix(), 0) goods.BrandName, goods.ErpId, time.Now().Unix(), 0)
}
return return
} }
......
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
const CheckSupplierExistSql = "SELECT supplier_id FROM lie_supplier WHERE erp_id = ?" const CheckSupplierExistSql = "SELECT supplier_id FROM lie_supplier WHERE erp_id = ?"
const CheckSupplierSyncStatusSql = "SELECT sync_status FROM lie_supplier WHERE erp_id = ?"
const InsertSupplierSql = "Insert INTO `lie_supplier` (`erp_supplier_code`,`name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?)" const InsertSupplierSql = "Insert INTO `lie_supplier` (`erp_supplier_code`,`name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?)"
const UpdateSupplierSql = "UPDATE `lie_supplier` SET `erp_supplier_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?" const UpdateSupplierSql = "UPDATE `lie_supplier` SET `erp_supplier_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?"
...@@ -25,9 +27,18 @@ func CheckSupplierExist(erpId string) (exist bool) { ...@@ -25,9 +27,18 @@ func CheckSupplierExist(erpId string) (exist bool) {
return supplierId > 0 return supplierId > 0
} }
//获取后端同步状态
func CheckSupplierSyncStatus(erpId string) (status bool) {
var statusInt int
dao.GetDb().QueryRowx(CheckSupplierSyncStatusSql, erpId).Scan(&statusInt)
return statusInt > 0
}
//插入供应商 //插入供应商
func InsertSupplier(supplier model.Supplier) (err error) { func InsertSupplier(supplier model.Supplier) (err error) {
if !CheckSupplierExist(supplier.ErpId) {
_, err = dao.GetDb().Exec(InsertSupplierSql, supplier.ErpSupplierCode, supplier.Name, supplier.ErpId, time.Now().Unix(), 0) _, err = dao.GetDb().Exec(InsertSupplierSql, supplier.ErpSupplierCode, supplier.Name, supplier.ErpId, time.Now().Unix(), 0)
}
return return
} }
......
...@@ -52,6 +52,10 @@ type DingDingRequest struct { ...@@ -52,6 +52,10 @@ type DingDingRequest struct {
} }
func SendDingTalkRobotToApi(content string) { func SendDingTalkRobotToApi(content string) {
fmt.Println(content)
}
func SendDingTalkRobotToApi1(content string) {
var ( var (
requestData DingDingRequest requestData DingDingRequest
apiUrl, token string apiUrl, token string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment