| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package controller
- import (
- "bswas/utilities"
- "strconv"
- )
- func ProcessFormat(data []map[string]string) ([]interface{}, [][]interface{}, map[string]string) {
- row := []interface{}{
- "任务号","货主","加工类型","预期数量","实际数量","状态","加工备注",
- "单价","提交日期","单据类型","单据号","商品编码","商品名称","商品条码","本次数量","结算备注",
- }
- column := map[string]int{
- "code" : 0,
- "owner_name" : 1,
- "process_method_name" : 2,
- "amount" : 3,
- "completed_amount" : 4,
- "status" : 5,
- "remark" : 6,
- "unit_price" : 7,
- "created_at" : 8,
- "content_bill_type" : 9,
- "content_wms_code" : 10,
- "commodity_sku" : 11,
- "commodity_name" : 12,
- "commodity_barcode_code" : 13,
- "content_amount" : 14,
- "process_balance_remark" : 15,
- }
- list := make([][]interface{},len(data))
- mergeRow := make(map[string]string)
- var columnName string
- var startIndex int
- rowAmount := 0
- for k,v := range data{
- if columnName == v["code"]{
- rowAmount++
- }else{
- if rowAmount != 0 {
- mergeRow[strconv.Itoa(startIndex+2)] = strconv.Itoa(startIndex+2+rowAmount)
- }
- columnName = v["code"]
- startIndex = k
- rowAmount = 0
- }
- if rowAmount != 0 {
- mergeRow[strconv.Itoa(startIndex+2)] = strconv.Itoa(startIndex+2+rowAmount)
- }
- line := make([]interface{},len(row))
- for key,value := range column {
- val := v[key]
- if key == "commodity_sku" && v["sign_commodity_sku_mark"] != "" {
- val = v["sign_commodity_sku_mark"]
- }
- if key == "commodity_name" && v["sign_commodity_name_mark"] != "" {
- val = v["sign_commodity_name_mark"]
- }
- if key == "commodity_barcode_code" && v["sign_commodity_barcode_mark"] != "" {
- val = v["sign_commodity_barcode_mark"]
- }
- if key == "created_at"{
- val = utilities.DateFormat(v[key],"2006-01-02T15:04:05Z")
- }
- line[value] = val
- }
- list[k] = line
- }
- return row,list,mergeRow
- }
|