| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- 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
- }
- func ProcessStatisticFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
- row := []interface{}{
- "任务号", "货主", "开始日期", "完成日期", "单价", "预期数量", "完成数量", "收入合计",
- "完成时间(天)'", "总工时", "加工类型", "最高日产能", "最低日产能", "日均产能", "合计成本", "毛利润",
- "毛利率", "状态","加工备注","结算备注",
- }
- column := map[string]int{
- "process_code" : 0,
- "owner_name" : 1,
- "started_at" : 2,
- "ended_at" : 3,
- "process_unit_price" : 4,
- "process_amount" : 5,
- "process_completed_amount" : 6,
- "revenue" : 7,
- "duration_days" : 8,
- "duration_man_hours" : 9,
- "process_method_name" : 10,
- "top_capacity" : 11,
- "bottom_capacity" : 12,
- "average_capacity" : 13,
- "total_cost" : 14,
- "gross_profit" : 15,
- "gross_profit_rate" : 16,
- "process_status" : 17,
- "process_remark" : 18,
- "process_balance_remark" : 19,
- }
- list := make([][]interface{},len(data))
- for k,v := range data{
- line := make([]interface{},len(row))
- for key,value := range column {
- if key == "gross_profit_rate" {
- rate,_ := strconv.ParseFloat(v[key],64)
- if rate != 0 {
- line[value] = strconv.FormatFloat(rate * 100, 'f', 2, 64)+"%"
- }
- continue
- }
- if key == "started_at" || key == "ended_at" {
- line[value] = utilities.DateFormat(v[key],"2006-01-02T15:04:05Z");
- continue
- }
- line[value] = v[key]
- }
- list[k] = line
- }
- return row,list
- }
|