|
@@ -432,13 +432,15 @@ func (c *StockController) StockIn_List_Product() {
|
|
T_name := c.GetString("T_name")
|
|
T_name := c.GetString("T_name")
|
|
T_start_date := c.GetString("T_start_date")
|
|
T_start_date := c.GetString("T_start_date")
|
|
T_end_date := c.GetString("T_end_date")
|
|
T_end_date := c.GetString("T_end_date")
|
|
|
|
+ T_product_name := c.GetString("T_product_name") // 产品名称
|
|
|
|
+ T_product_model := c.GetString("T_product_model") // 产品型号
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
Account.Read_User_All_Map(userList)
|
|
Account.Read_User_All_Map(userList)
|
|
Basic.Read_Depot_All_Map()
|
|
Basic.Read_Depot_All_Map()
|
|
|
|
|
|
StockInDao := Stock.NewStockIn(orm.NewOrm())
|
|
StockInDao := Stock.NewStockIn(orm.NewOrm())
|
|
- R_List, R_cnt := StockInDao.Read_StockInProduct_List(T_name, T_start_date, T_end_date, T_depot_id, page, page_z)
|
|
|
|
|
|
+ R_List, R_cnt := StockInDao.Read_StockInProduct_List(T_name, T_start_date, T_end_date, T_depot_id, T_product_name, T_product_model, page, page_z)
|
|
|
|
|
|
var r_jsons lib.R_JSONS
|
|
var r_jsons lib.R_JSONS
|
|
r_jsons.Num = R_cnt
|
|
r_jsons.Num = R_cnt
|
|
@@ -450,6 +452,134 @@ func (c *StockController) StockIn_List_Product() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+func (c *StockController) StockIn_List_Product_Excel() {
|
|
|
|
+ // 查询
|
|
|
|
+ T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
|
+ T_start_date := c.GetString("T_start_date")
|
|
|
|
+ T_end_date := c.GetString("T_end_date")
|
|
|
|
+ T_product_name := c.GetString("T_product_name") // 产品名称
|
|
|
|
+ T_product_model := c.GetString("T_product_model") // 产品型号
|
|
|
|
+
|
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
|
+ Account.Read_User_All_Map(userList)
|
|
|
|
+ Basic.Read_Depot_All_Map()
|
|
|
|
+
|
|
|
|
+ StockInDao := Stock.NewStockIn(orm.NewOrm())
|
|
|
|
+ R_List, _ := StockInDao.Read_StockInProduct_List(T_name, T_start_date, T_end_date, T_depot_id, T_product_name, T_product_model, 0, 9999)
|
|
|
|
+
|
|
|
|
+ filename := fmt.Sprintf("入库明细单(%s)", lib.GetRandstring(6, "0123456789", 0))
|
|
|
|
+
|
|
|
|
+ f := excelize.NewFile() // 设置单元格的值
|
|
|
|
+ Style1, _ := f.NewStyle(
|
|
|
|
+ &excelize.Style{
|
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
|
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
|
+ })
|
|
|
|
+ Style2, _ := f.NewStyle(
|
|
|
|
+ &excelize.Style{
|
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 11, Family: "宋体"},
|
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
|
+ Border: []excelize.Border{
|
|
|
|
+ {Type: "left", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "top", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "bottom", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "right", Color: "000000", Style: 1},
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ Style3, _ := f.NewStyle(
|
|
|
|
+ &excelize.Style{
|
|
|
|
+ Font: &excelize.Font{Size: 11, Family: "宋体"},
|
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center", WrapText: true},
|
|
|
|
+ Border: []excelize.Border{
|
|
|
|
+ {Type: "left", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "top", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "bottom", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "right", Color: "000000", Style: 1},
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ f.MergeCell("Sheet1", "A1", "K1")
|
|
|
|
+ f.SetRowStyle("Sheet1", 1, 1, Style1)
|
|
|
|
+ f.SetCellValue("Sheet1", "A1", fmt.Sprintf("入库明细单"))
|
|
|
|
+ f.SetRowHeight("Sheet1", 1, 30)
|
|
|
|
+ // 这里设置表头
|
|
|
|
+ f.SetCellStyle("Sheet1", "A2", "K2", Style2)
|
|
|
|
+ f.SetRowHeight("Sheet1", 2, 20)
|
|
|
|
+
|
|
|
|
+ f.SetCellValue("Sheet1", "A2", "序号")
|
|
|
|
+ f.SetCellValue("Sheet1", "B2", "入库单号")
|
|
|
|
+ f.SetCellValue("Sheet1", "C2", "经办人")
|
|
|
|
+ f.SetCellValue("Sheet1", "D2", "入库日期")
|
|
|
|
+ f.SetCellValue("Sheet1", "E2", "入库仓库")
|
|
|
|
+ f.SetCellValue("Sheet1", "F2", "产品名称")
|
|
|
|
+ f.SetCellValue("Sheet1", "G2", "产品型号")
|
|
|
|
+ f.SetCellValue("Sheet1", "H2", "数量")
|
|
|
|
+ f.SetCellValue("Sheet1", "I2", "是否关联SN")
|
|
|
|
+ f.SetCellValue("Sheet1", "J2", "备注")
|
|
|
|
+ f.SetCellValue("Sheet1", "K2", "SN")
|
|
|
|
+ // 设置列宽
|
|
|
|
+ f.SetColWidth("Sheet1", "A", "A", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "B", "B", 15)
|
|
|
|
+ f.SetColWidth("Sheet1", "C", "D", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "D", "D", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "E", "E", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "F", "F", 20)
|
|
|
|
+ f.SetColWidth("Sheet1", "G", "G", 15)
|
|
|
|
+ f.SetColWidth("Sheet1", "H", "H", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "I", "I", 12)
|
|
|
|
+ f.SetColWidth("Sheet1", "J", "J", 30)
|
|
|
|
+ f.SetColWidth("Sheet1", "K", "K", 100)
|
|
|
|
+ line := 2
|
|
|
|
+
|
|
|
|
+ for _, product := range R_List {
|
|
|
|
+ line += 1
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), line-2)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), product.T_number)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), product.T_submit_name)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), product.T_date)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), product.T_depot_name)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), product.T_product_name)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), product.T_product_model)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), product.T_num)
|
|
|
|
+ var relation_sn string
|
|
|
|
+ if product.T_product_relation_sn == 1 {
|
|
|
|
+ relation_sn = "是"
|
|
|
|
+ } else {
|
|
|
|
+ relation_sn = "否"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), relation_sn)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), product.T_remark)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), product.T_relation_sn)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ f.SetCellStyle("Sheet1", "A3", fmt.Sprintf("K%d", line), Style3)
|
|
|
|
+
|
|
|
|
+ // 保存文件
|
|
|
|
+ if err := f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ }
|
|
|
|
+ var url string
|
|
|
|
+ //// 上传 OSS
|
|
|
|
+ nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
|
|
|
|
+ url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".xlsx", "ofile/"+filename+".xlsx")
|
|
|
|
+ if !is {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //删除目录
|
|
|
|
+ err := os.Remove("ofile/" + filename + ".xlsx")
|
|
|
|
+ if err != nil {
|
|
|
|
+ logs.Error(lib.FuncName(), err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
|
|
func (c *StockController) StockIn_Get() {
|
|
func (c *StockController) StockIn_Get() {
|
|
|
|
|
|
@@ -1366,13 +1496,15 @@ func (c *StockController) StockOut_List_Product() {
|
|
T_name := c.GetString("T_name")
|
|
T_name := c.GetString("T_name")
|
|
T_start_date := c.GetString("T_start_date")
|
|
T_start_date := c.GetString("T_start_date")
|
|
T_end_date := c.GetString("T_end_date")
|
|
T_end_date := c.GetString("T_end_date")
|
|
|
|
+ T_product_name := c.GetString("T_product_name") // 产品名称
|
|
|
|
+ T_product_model := c.GetString("T_product_model") // 产品型号
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
Account.Read_User_All_Map(userList)
|
|
Account.Read_User_All_Map(userList)
|
|
Basic.Read_Depot_All_Map()
|
|
Basic.Read_Depot_All_Map()
|
|
|
|
|
|
StockOutDao := Stock.NewStockOut(orm.NewOrm())
|
|
StockOutDao := Stock.NewStockOut(orm.NewOrm())
|
|
- R_List, R_cnt := StockOutDao.Read_StockOutProduct_List(T_name, T_start_date, T_end_date, T_depot_id, page, page_z)
|
|
|
|
|
|
+ R_List, R_cnt := StockOutDao.Read_StockOutProduct_List(T_name, T_start_date, T_end_date, T_depot_id, T_product_name, T_product_model, page, page_z)
|
|
|
|
|
|
var r_jsons lib.R_JSONS
|
|
var r_jsons lib.R_JSONS
|
|
r_jsons.Num = R_cnt
|
|
r_jsons.Num = R_cnt
|
|
@@ -1384,6 +1516,138 @@ func (c *StockController) StockOut_List_Product() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+func (c *StockController) StockOut_List_Product_Excel() {
|
|
|
|
+
|
|
|
|
+ // 查询
|
|
|
|
+ T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
|
+ T_start_date := c.GetString("T_start_date")
|
|
|
|
+ T_end_date := c.GetString("T_end_date")
|
|
|
|
+ T_product_name := c.GetString("T_product_name") // 产品名称
|
|
|
|
+ T_product_model := c.GetString("T_product_model") // 产品型号
|
|
|
|
+
|
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
|
+ Account.Read_User_All_Map(userList)
|
|
|
|
+ Basic.Read_Depot_All_Map()
|
|
|
|
+
|
|
|
|
+ StockOutDao := Stock.NewStockOut(orm.NewOrm())
|
|
|
|
+ R_List, _ := StockOutDao.Read_StockOutProduct_List(T_name, T_start_date, T_end_date, T_depot_id, T_product_name, T_product_model, 0, 9999)
|
|
|
|
+
|
|
|
|
+ filename := fmt.Sprintf("出库明细单(%s)", lib.GetRandstring(6, "0123456789", 0))
|
|
|
|
+
|
|
|
|
+ f := excelize.NewFile() // 设置单元格的值
|
|
|
|
+ Style1, _ := f.NewStyle(
|
|
|
|
+ &excelize.Style{
|
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
|
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
|
+ })
|
|
|
|
+ Style2, _ := f.NewStyle(
|
|
|
|
+ &excelize.Style{
|
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 11, Family: "宋体"},
|
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
|
|
+ Border: []excelize.Border{
|
|
|
|
+ {Type: "left", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "top", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "bottom", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "right", Color: "000000", Style: 1},
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ Style3, _ := f.NewStyle(
|
|
|
|
+ &excelize.Style{
|
|
|
|
+ Font: &excelize.Font{Size: 11, Family: "宋体"},
|
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center", WrapText: true},
|
|
|
|
+ Border: []excelize.Border{
|
|
|
|
+ {Type: "left", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "top", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "bottom", Color: "000000", Style: 1},
|
|
|
|
+ {Type: "right", Color: "000000", Style: 1},
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ f.MergeCell("Sheet1", "A1", "L1")
|
|
|
|
+ f.SetRowStyle("Sheet1", 1, 1, Style1)
|
|
|
|
+ f.SetCellValue("Sheet1", "A1", fmt.Sprintf("出库明细单"))
|
|
|
|
+ f.SetRowHeight("Sheet1", 1, 30)
|
|
|
|
+ // 这里设置表头
|
|
|
|
+ f.SetCellStyle("Sheet1", "A2", "L2", Style2)
|
|
|
|
+ f.SetRowHeight("Sheet1", 2, 20)
|
|
|
|
+
|
|
|
|
+ f.SetCellValue("Sheet1", "A2", "序号")
|
|
|
|
+ f.SetCellValue("Sheet1", "B2", "出库单号")
|
|
|
|
+ f.SetCellValue("Sheet1", "C2", "领取人")
|
|
|
|
+ f.SetCellValue("Sheet1", "D2", "出库日期")
|
|
|
|
+ f.SetCellValue("Sheet1", "E2", "出库仓库")
|
|
|
|
+ f.SetCellValue("Sheet1", "F2", "关联项目")
|
|
|
|
+ f.SetCellValue("Sheet1", "G2", "产品名称")
|
|
|
|
+ f.SetCellValue("Sheet1", "H2", "产品型号")
|
|
|
|
+ f.SetCellValue("Sheet1", "I2", "数量")
|
|
|
|
+ f.SetCellValue("Sheet1", "J2", "是否关联SN")
|
|
|
|
+ f.SetCellValue("Sheet1", "K2", "备注")
|
|
|
|
+ f.SetCellValue("Sheet1", "L2", "SN")
|
|
|
|
+ // 设置列宽
|
|
|
|
+ f.SetColWidth("Sheet1", "A", "A", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "B", "B", 15)
|
|
|
|
+ f.SetColWidth("Sheet1", "C", "D", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "D", "D", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "E", "E", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "F", "F", 20)
|
|
|
|
+ f.SetColWidth("Sheet1", "G", "G", 20)
|
|
|
|
+ f.SetColWidth("Sheet1", "H", "H", 15)
|
|
|
|
+ f.SetColWidth("Sheet1", "I", "I", 10)
|
|
|
|
+ f.SetColWidth("Sheet1", "J", "J", 12)
|
|
|
|
+ f.SetColWidth("Sheet1", "K", "K", 30)
|
|
|
|
+ f.SetColWidth("Sheet1", "L", "L", 100)
|
|
|
|
+ line := 2
|
|
|
|
+
|
|
|
|
+ for _, product := range R_List {
|
|
|
|
+ line += 1
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), line-2)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), product.T_number)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), product.T_receive_name)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), product.T_date)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), product.T_depot_name)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), product.T_project)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), product.T_product_name)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), product.T_product_model)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), product.T_num)
|
|
|
|
+ var relation_sn string
|
|
|
|
+ if product.T_product_relation_sn == 1 {
|
|
|
|
+ relation_sn = "是"
|
|
|
|
+ } else {
|
|
|
|
+ relation_sn = "否"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), relation_sn)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), product.T_remark)
|
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), product.T_relation_sn)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ f.SetCellStyle("Sheet1", "A3", fmt.Sprintf("L%d", line), Style3)
|
|
|
|
+
|
|
|
|
+ // 保存文件
|
|
|
|
+ if err := f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ }
|
|
|
|
+ var url string
|
|
|
|
+ //// 上传 OSS
|
|
|
|
+ nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
|
|
|
|
+ url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".xlsx", "ofile/"+filename+".xlsx")
|
|
|
|
+ if !is {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //删除目录
|
|
|
|
+ err := os.Remove("ofile/" + filename + ".xlsx")
|
|
|
|
+ if err != nil {
|
|
|
|
+ logs.Error(lib.FuncName(), err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
|
|
func (c *StockController) StockOut_Get() {
|
|
func (c *StockController) StockOut_Get() {
|
|
|
|
|