Commit 48f0d1f4 by mushishixian

加上同步状态判断

parent a6aa2bb2
......@@ -54,8 +54,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//判断操作类型
switch message.Type {
case "save":
//先去查询是否存在,不存在才去插入,已经存在即是修改
if logic.CheckGoodsExist(goods.ErpId) {
//先去查询是否存在已经同步完成的记录
if logic.CheckGoodsSyncStatus(goods.ErpId) {
operateType = "update"
if err = logic.UpdateGoods(goods); err != nil {
goto ERR
......
......@@ -194,7 +194,6 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
for key, value := range responseData {
//金蝶判断成功的标志
if key == "0000" {
fmt.Println("OK")
return
}
//金额判断失败的标志
......
......@@ -52,8 +52,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//判断操作类型
switch message.Type {
case "save":
//先去查询是否存在,不存在才去插入,已经存在即是修改
if logic.CheckSupplierExist(supplier.ErpId) {
//先去查询是否存在已经同步完成的记录
if logic.CheckSupplierSyncStatus(supplier.ErpId) {
operateType = "update"
if err = logic.UpdateSupplier(supplier); err != nil {
goto ERR
......
......@@ -6,7 +6,9 @@ import (
"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 (?,?,?,?,?,?)"
......@@ -25,10 +27,19 @@ func CheckGoodsExist(erpId string) (exist bool) {
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) {
_, err = dao.GetDb().Exec(InsertGoodsSql, goods.GoodsName, goods.GoodsCnName,
goods.BrandName, goods.ErpId, time.Now().Unix(), 0)
if !CheckGoodsExist(goods.ErpId) {
_, err = dao.GetDb().Exec(InsertGoodsSql, goods.GoodsName, goods.GoodsCnName,
goods.BrandName, goods.ErpId, time.Now().Unix(), 0)
}
return
}
......
......@@ -8,6 +8,8 @@ import (
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 UpdateSupplierSql = "UPDATE `lie_supplier` SET `erp_supplier_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?"
......@@ -25,9 +27,18 @@ func CheckSupplierExist(erpId string) (exist bool) {
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) {
_, err = dao.GetDb().Exec(InsertSupplierSql, supplier.ErpSupplierCode, supplier.Name, supplier.ErpId, time.Now().Unix(), 0)
if !CheckSupplierExist(supplier.ErpId) {
_, err = dao.GetDb().Exec(InsertSupplierSql, supplier.ErpSupplierCode, supplier.Name, supplier.ErpId, time.Now().Unix(), 0)
}
return
}
......
......@@ -52,6 +52,10 @@ type DingDingRequest struct {
}
func SendDingTalkRobotToApi(content string) {
fmt.Println(content)
}
func SendDingTalkRobotToApi1(content string) {
var (
requestData DingDingRequest
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