|
|
@ -1,6 +1,7 @@ |
|
|
|
package service |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"github.com/go-xorm/xorm" |
|
|
|
"leit.com/leit_seat_aps/common" |
|
|
@ -331,6 +332,7 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPickOrder(session *xorm.Session, |
|
|
|
printdetailtab.Finr = db.G_FINR |
|
|
|
printdetailtab.Printheadid = printheadid |
|
|
|
printdetailtab.Varname = bl_picktmp.Picktemplatetab.Printlst[j].Varname |
|
|
|
|
|
|
|
switch bl_picktmp.Picktemplatetab.Printlst[j].Vartype { |
|
|
|
case common.PRN_VAR_TYP_2DCOL: // 二维表列变量
|
|
|
|
// 获取拣料单项额外的内存数据,包括生产订单、客户订单和属性
|
|
|
@ -663,9 +665,10 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrder(session *xorm.Session, |
|
|
|
if err = printheadtab.Insert(session); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 遍历打印设置条码
|
|
|
|
idx = 1 |
|
|
|
detailmap := make(map[string]string) |
|
|
|
|
|
|
|
for i = 0; i < len(bl_packtmp.Paktmpltab.Printlst); i++ { |
|
|
|
// 定义暂存数据的map
|
|
|
|
bufdata := []interface{}{} |
|
|
@ -678,9 +681,10 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrder(session *xorm.Session, |
|
|
|
Pos: idx, |
|
|
|
Varname: bl_packtmp.Paktmpltab.Printlst[i].Varname, |
|
|
|
Varpos: bl_packtmp.Paktmpltab.Printlst[i].Varpos} |
|
|
|
|
|
|
|
val = "" |
|
|
|
if len(packordtab.Itemlst) == 0{ |
|
|
|
glog.InfoExtln("packordtab","packordtab.orderid",packordtab.Packorderid) |
|
|
|
if len(packordtab.Itemlst) == 0 { |
|
|
|
glog.InfoExtln("packordtab", "packordtab.orderid", packordtab.Packorderid) |
|
|
|
continue |
|
|
|
} |
|
|
|
if packordtab.Itemlst[0].Workordernr != "" { |
|
|
@ -705,11 +709,6 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrder(session *xorm.Session, |
|
|
|
val = "" |
|
|
|
} |
|
|
|
case common.PRN_VAR_TYP_VARSET: // 动态变量集
|
|
|
|
for k, v := range detailmap { |
|
|
|
key := strings.TrimSpace(k) |
|
|
|
value := strings.TrimSpace(v) |
|
|
|
kvmap[key] = value |
|
|
|
} |
|
|
|
// 获取变量集
|
|
|
|
varlst = strings.Split(bl_packtmp.Paktmpltab.Printlst[i].Varvalue, ";") |
|
|
|
if len(varlst) <= 0 { |
|
|
@ -722,6 +721,7 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrder(session *xorm.Session, |
|
|
|
} |
|
|
|
} |
|
|
|
case common.PRN_VAR_TYP_LOOPVAR: // 循环变量
|
|
|
|
|
|
|
|
for j = 0; j < len(packordtab.Itemlst); j++ { |
|
|
|
//加载模板
|
|
|
|
bufdata = append(bufdata, bl_packtmp.Paktmpltab) |
|
|
@ -785,8 +785,10 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrder(session *xorm.Session, |
|
|
|
if err = printdetailtab.Insert(session); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
idx++ |
|
|
|
} |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
case common.PRN_VAR_TYP_SYSVAR: // 系统参数2
|
|
|
@ -814,14 +816,205 @@ func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrder(session *xorm.Session, |
|
|
|
if err = printdetailtab.Insert(session); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
varname := strings.TrimSpace(bl_packtmp.Paktmpltab.Printlst[i].Varname) |
|
|
|
detailmap[varname] = val |
|
|
|
idx++ |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 为包装单生成打印数据
|
|
|
|
func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForPackOrderToJson(session *xorm.Session, salvesession *xorm.Session, packordtab db.Jit_packorder, pe *BL_PrintEngine) (err error) { |
|
|
|
var ( |
|
|
|
bl_packtmp BL_Package |
|
|
|
salveprintheadtab db.Printheadtab |
|
|
|
printitem db.Printitem |
|
|
|
wotab db.Pln_workorder |
|
|
|
cotab db.Pln_custorder |
|
|
|
supplygroup db.Me_supplygroup |
|
|
|
printheadid, val, tmp string |
|
|
|
varlst []string |
|
|
|
ok bool |
|
|
|
i, j, icopy, icopies int |
|
|
|
) |
|
|
|
|
|
|
|
// 获取模板
|
|
|
|
if bl_packtmp, ok = pe.PackTmpDict[packordtab.Packtemplateid]; !ok { |
|
|
|
return |
|
|
|
} |
|
|
|
// 如果打印多份
|
|
|
|
icopies = common.Max(bl_ordmsg.Ordmsgtab.Printcopies, bl_packtmp.Paktmpltab.Printqty, 1) |
|
|
|
for icopy = 0; icopy < icopies; icopy++ { |
|
|
|
// 获取打印头流水号
|
|
|
|
if strings.TrimSpace(bl_ordmsg.Ordmsgtab.Printheadsn) != "" { |
|
|
|
if printheadid, err = SN_GetNextSnrBySession(strings.TrimSpace(bl_ordmsg.Ordmsgtab.Printheadsn), session); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
if printheadid, err = SN_GetNextSnrBySession("PRNSHEETHEAD", session); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
// 创建打印头
|
|
|
|
salveprintheadtab = db.Printheadtab{} |
|
|
|
salveprintheadtab.Finr = db.G_FINR |
|
|
|
salveprintheadtab.Printheadid = printheadid |
|
|
|
salveprintheadtab.Status = common.PRN_HEAD_STATUS_NEW |
|
|
|
salveprintheadtab.Printerid = bl_packtmp.Paktmpltab.Printerid |
|
|
|
salveprintheadtab.Printobjtype = common.MSG_TYPE_PACK |
|
|
|
salveprintheadtab.Printobjid = packordtab.Packorderid |
|
|
|
salveprintheadtab.Printfiletype = "EXCEL" |
|
|
|
if strings.TrimSpace(packordtab.Templatefile) == "" { |
|
|
|
salveprintheadtab.Templatefile = bl_packtmp.Paktmpltab.Templatefile |
|
|
|
} else { |
|
|
|
salveprintheadtab.Templatefile = packordtab.Templatefile |
|
|
|
} |
|
|
|
salveprintheadtab.Orientation = bl_packtmp.Paktmpltab.Orientation |
|
|
|
salveprintheadtab.Printcopies = common.Max(bl_ordmsg.Ordmsgtab.Printcopies, bl_packtmp.Paktmpltab.Printqty, 1) |
|
|
|
salveprintheadtab.Credatuz = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") |
|
|
|
salveprintheadtab.Lastmodif = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") |
|
|
|
salveprintheadtab.Lastuser = "service" |
|
|
|
if err = salveprintheadtab.Insert(salvesession); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
printitem = db.Printitem{ |
|
|
|
Finr: db.G_FINR, |
|
|
|
Printheadid: printheadid} |
|
|
|
|
|
|
|
dataMap := db.PackPrintItem{} |
|
|
|
headMap := make(map[string]interface{}) |
|
|
|
detailMap := make([]map[string]interface{}, 0) |
|
|
|
|
|
|
|
//获取常量设置信息 //构建headMap
|
|
|
|
for i = 0; i < len(bl_packtmp.Paktmpltab.Printlst); i++ { |
|
|
|
|
|
|
|
if bl_packtmp.Paktmpltab.Printlst[i].Vartype == common.PRN_VAR_TYP_LOOPVAR{ |
|
|
|
continue |
|
|
|
} |
|
|
|
// 定义暂存数据的map
|
|
|
|
bufdata := []interface{}{} |
|
|
|
bufdata = append(bufdata, packordtab) |
|
|
|
kvmap := common.StructToMap(bufdata) |
|
|
|
val = "" |
|
|
|
if len(packordtab.Itemlst) == 0 { |
|
|
|
glog.InfoExtln("packordtab", "packordtab.orderid", packordtab.Packorderid) |
|
|
|
continue |
|
|
|
} |
|
|
|
if packordtab.Itemlst[0].Workordernr != "" { |
|
|
|
wotab = db.Pln_workorder{Finr: db.G_FINR, Workordernr: packordtab.Itemlst[0].Workordernr} |
|
|
|
if wotab, err = wotab.SelectOne(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
bufdata = append(bufdata, wotab) |
|
|
|
co := db.Pln_custorder{Finr: db.G_FINR, Custordernr: wotab.Custordernr} |
|
|
|
if cotab, err = co.SelectOne(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
bufdata = append(bufdata, cotab) |
|
|
|
kvmap = common.StructToMap(bufdata) |
|
|
|
} |
|
|
|
switch bl_packtmp.Paktmpltab.Printlst[i].Vartype { |
|
|
|
case common.PRN_VAR_TYP_VALUE: // 静态值
|
|
|
|
val = bl_packtmp.Paktmpltab.Printlst[i].Varvalue |
|
|
|
|
|
|
|
case common.PRN_VAR_TYP_VARIABLE: // 动态变量
|
|
|
|
if val, ok = kvmap[bl_packtmp.Paktmpltab.Printlst[i].Varvalue]; !ok { |
|
|
|
val = "" |
|
|
|
} |
|
|
|
case common.PRN_VAR_TYP_VARSET: // 动态变量集
|
|
|
|
// 获取变量集
|
|
|
|
varlst = strings.Split(bl_packtmp.Paktmpltab.Printlst[i].Varvalue, ";") |
|
|
|
if len(varlst) <= 0 { |
|
|
|
continue |
|
|
|
} else { |
|
|
|
for j = 0; j < len(varlst); j++ { |
|
|
|
if tmp, ok = kvmap[varlst[j]]; ok { |
|
|
|
val = val + tmp |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
case common.PRN_VAR_TYP_SYSVAR: // 系统参数2
|
|
|
|
switch bl_packtmp.Paktmpltab.Printlst[i].Varvalue { |
|
|
|
case "DATE()": |
|
|
|
val = common.Date(time.Now().Unix(), "YYYYMMDD") |
|
|
|
case "TIME()": |
|
|
|
val = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") |
|
|
|
case "COPY": |
|
|
|
val = GetPrintSysCopyValue(icopy+1, bl_packtmp.Paktmpltab.Printlst[i].Picture) |
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
if val, err = GetValueByPicture(val, bl_packtmp.Paktmpltab.Printlst[i].Picture, bl_packtmp.Paktmpltab.Printlst[i].Varpos); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
varname := strings.TrimSpace(bl_packtmp.Paktmpltab.Printlst[i].Varname) |
|
|
|
headMap[varname] = val |
|
|
|
} |
|
|
|
|
|
|
|
//构建detailMap
|
|
|
|
for j = 0; j < len(packordtab.Itemlst); j++ { |
|
|
|
onedetailMap := make(map[string]interface{}) |
|
|
|
|
|
|
|
wotab = db.Pln_workorder{Finr: db.G_FINR, Workordernr: packordtab.Itemlst[j].Workordernr} |
|
|
|
if wotab, err = wotab.SelectOne(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
glog.InfoExtln("pack打印消息", "wotab is:", wotab) |
|
|
|
|
|
|
|
supplygroup = db.Me_supplygroup{Finr: db.G_FINR, Supplygroupid: wotab.Supplygroupid} |
|
|
|
if supplygroup, err = supplygroup.SelectOne(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
glog.InfoExtln("pack打印消息", "supplygroup is:", supplygroup) |
|
|
|
|
|
|
|
co := db.Pln_custorder{Finr: db.G_FINR, Custordernr: wotab.Custordernr} |
|
|
|
if cotab, err = co.SelectOne(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
glog.InfoExtln("pack打印消息", "cotab is:", cotab) |
|
|
|
|
|
|
|
onedetailMap["pos"] = packordtab.Itemlst[j].Pos |
|
|
|
onedetailMap["oemseq"] = common.ValueToInt(wotab.Oemseq,0) |
|
|
|
if common.ValueIsEmpty(packordtab.Itemlst[j].Workordernr) { |
|
|
|
onedetailMap["oemordernr"] = "" |
|
|
|
} else { |
|
|
|
onedetailMap["oemordernr"] = strings.TrimSpace(cotab.Oemordernr) |
|
|
|
} |
|
|
|
onedetailMap["description"] = strings.TrimSpace(supplygroup.Descr) |
|
|
|
onedetailMap["swet"] = strings.TrimSpace(cotab.Calloffswet) |
|
|
|
|
|
|
|
fmt.Println(onedetailMap) |
|
|
|
detailMap = append(detailMap, onedetailMap) |
|
|
|
} |
|
|
|
|
|
|
|
dataMap.HeadData = headMap |
|
|
|
dataMap.DetailData = detailMap |
|
|
|
|
|
|
|
fmt.Println(dataMap) |
|
|
|
|
|
|
|
glog.InfoExtln("pack打印消息", "dataMap is:", dataMap) |
|
|
|
detailStrJson, _ := json.Marshal(dataMap) |
|
|
|
printitem.Detail = string(detailStrJson) |
|
|
|
|
|
|
|
glog.InfoExtln("pack打印消息", "detailStrJson is:", detailStrJson) |
|
|
|
|
|
|
|
printitem.Credatuz = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") |
|
|
|
printitem.Lastmodif = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") |
|
|
|
printitem.Lastuser = "service" |
|
|
|
if err = printitem.Insertlab(salvesession); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 为发运单生成打印数据
|
|
|
|
func (bl_ordmsg *BL_Ordmsg) GeneratePrintDataForShipOrder(session *xorm.Session, shipordtab db.Jit_shiporder, pe *BL_PrintEngine) (err error) { |
|
|
|
var ( |
|
|
|