|
@@ -260,6 +260,29 @@ func (c *StockController) Stock_Detail_Excel() {
|
|
|
},
|
|
|
})
|
|
|
|
|
|
+ Style3, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Bold: true, Size: 10, Family: "宋体", Color: "FF0000"},
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", 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},
|
|
|
+ },
|
|
|
+ })
|
|
|
+ Style4, _ := f.NewStyle(
|
|
|
+ &excelize.Style{
|
|
|
+ Font: &excelize.Font{Size: 10, Family: "宋体"},
|
|
|
+ Alignment: &excelize.Alignment{Horizontal: "center", 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},
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
StockMonthDao := Stock.NewStockMonth(orm.NewOrm())
|
|
|
StockOutDao := Stock.NewStockOut(orm.NewOrm())
|
|
|
|
|
@@ -323,24 +346,19 @@ func (c *StockController) Stock_Detail_Excel() {
|
|
|
f.SetCellValue(r.T_name, fmt.Sprintf("G%d", line), v.T_in)
|
|
|
f.SetCellValue(r.T_name, fmt.Sprintf("H%d", line), v.T_out)
|
|
|
f.SetCellValue(r.T_name, fmt.Sprintf("I%d", line), v.T_ending)
|
|
|
+ if product.T_early_warning > v.T_ending {
|
|
|
+ f.SetCellStyle(r.T_name, fmt.Sprintf("I%d", line), fmt.Sprintf("I%d", line), Style3)
|
|
|
+ } else {
|
|
|
+ f.SetCellStyle(r.T_name, fmt.Sprintf("I%d", line), fmt.Sprintf("I%d", line), Style4)
|
|
|
+
|
|
|
+ }
|
|
|
T_project := StockOutDao.Read_StockOut_T_project(T_depot_id, product.Id, v.T_month)
|
|
|
//f.SetCellValue(r.T_name, fmt.Sprintf("J%d", line), v.T_project)
|
|
|
f.SetCellValue(r.T_name, fmt.Sprintf("J%d", line), strings.Join(T_project, "\r\n"))
|
|
|
|
|
|
}
|
|
|
- Style4, _ := f.NewStyle(
|
|
|
- &excelize.Style{
|
|
|
- Font: &excelize.Font{Size: 10, Family: "宋体"},
|
|
|
- Alignment: &excelize.Alignment{Horizontal: "center", 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.SetCellStyle(r.T_name, "A2", fmt.Sprintf("I%d", line), Style4)
|
|
|
+ f.SetCellStyle(r.T_name, "A2", fmt.Sprintf("H%d", line), Style4)
|
|
|
|
|
|
Style5, _ := f.NewStyle(
|
|
|
&excelize.Style{
|
|
@@ -500,12 +518,12 @@ func (c *StockController) StockIn_List_Product_Excel() {
|
|
|
},
|
|
|
})
|
|
|
|
|
|
- f.MergeCell("Sheet1", "A1", "K1")
|
|
|
+ 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", "K2", Style2)
|
|
|
+ f.SetCellStyle("Sheet1", "A2", "L2", Style2)
|
|
|
f.SetRowHeight("Sheet1", 2, 20)
|
|
|
|
|
|
f.SetCellValue("Sheet1", "A2", "序号")
|
|
@@ -513,24 +531,26 @@ func (c *StockController) StockIn_List_Product_Excel() {
|
|
|
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.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", 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)
|
|
|
+ f.SetColWidth("Sheet1", "F", "F", 10)
|
|
|
+ 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 {
|
|
@@ -540,9 +560,16 @@ func (c *StockController) StockIn_List_Product_Excel() {
|
|
|
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 type_str string
|
|
|
+ if product.T_type == 1 {
|
|
|
+ type_str = "入库"
|
|
|
+ } else {
|
|
|
+ type_str = "退库"
|
|
|
+ }
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), type_str)
|
|
|
+ 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 = "是"
|
|
@@ -550,12 +577,12 @@ func (c *StockController) StockIn_List_Product_Excel() {
|
|
|
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.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("K%d", line), Style3)
|
|
|
+ f.SetCellStyle("Sheet1", "A3", fmt.Sprintf("L%d", line), Style3)
|
|
|
|
|
|
// 保存文件
|
|
|
if err := f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
|
|
@@ -629,10 +656,11 @@ func (c *StockController) StockIn_Add() {
|
|
|
}
|
|
|
|
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
+ T_type, _ := c.GetInt("T_type") // 1-入库 2-退库
|
|
|
T_date := c.GetString("T_date")
|
|
|
T_product := c.GetString("T_product")
|
|
|
T_remark := c.GetString("T_remark")
|
|
|
- _, is := lib.DateStrToTime(T_date)
|
|
|
+ date, is := lib.DateStrToTime(T_date)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -643,6 +671,7 @@ func (c *StockController) StockIn_Add() {
|
|
|
var_ := Stock.StockIn{
|
|
|
T_number: T_number,
|
|
|
T_depot_id: T_depot_id,
|
|
|
+ T_type: T_type,
|
|
|
T_date: T_date,
|
|
|
T_remark: T_remark,
|
|
|
T_submit: c.User.T_uuid,
|
|
@@ -697,6 +726,7 @@ func (c *StockController) StockIn_Add() {
|
|
|
T_iccid: mqtt.Iccid,
|
|
|
T_imei: mqtt.Imei,
|
|
|
T_State: 2,
|
|
|
+ CreateTime: date,
|
|
|
}
|
|
|
_, err = DeviceDao.AddOrUpdate_Device(device, 2)
|
|
|
if err != nil {
|
|
@@ -963,7 +993,7 @@ func (c *StockController) StockIn_Edit() {
|
|
|
T_iccid: mqtt.Iccid,
|
|
|
T_imei: mqtt.Imei,
|
|
|
T_State: 2,
|
|
|
- CreateTime: stockIn.CreateTime,
|
|
|
+ CreateTime: date,
|
|
|
UpdateTime: stockIn.UpdateTime,
|
|
|
}
|
|
|
_, err = DeviceDao.AddOrUpdate_Device(device, 2)
|
|
@@ -1095,7 +1125,7 @@ func (c *StockController) StockIn_Edit() {
|
|
|
T_iccid: mqtt.Iccid,
|
|
|
T_imei: mqtt.Imei,
|
|
|
T_State: 2,
|
|
|
- CreateTime: stockIn.CreateTime,
|
|
|
+ CreateTime: date,
|
|
|
UpdateTime: stockIn.UpdateTime,
|
|
|
}
|
|
|
_, err = DeviceDao.AddOrUpdate_Device(device, 2)
|
|
@@ -1711,6 +1741,12 @@ func (c *StockController) StockOut_Add() {
|
|
|
T_signer_phone := c.GetString("T_signer_phone")
|
|
|
T_signer_date := c.GetString("T_signer_date")
|
|
|
T_courier_number := c.GetString("T_courier_number")
|
|
|
+ date, is := lib.DateStrToTime(T_date)
|
|
|
+ if !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
var_ := Stock.StockOut{
|
|
|
T_number: T_number,
|
|
@@ -1790,6 +1826,7 @@ func (c *StockController) StockOut_Add() {
|
|
|
T_imei: mqtt.Imei,
|
|
|
T_State: 1,
|
|
|
T_project: T_project,
|
|
|
+ CreateTime: date,
|
|
|
}
|
|
|
_, err = DeviceDao.AddOrUpdate_Device(device, 1)
|
|
|
if err != nil {
|
|
@@ -2095,7 +2132,7 @@ func (c *StockController) StockOut_Edit() {
|
|
|
T_iccid: mqtt.Iccid,
|
|
|
T_imei: mqtt.Imei,
|
|
|
T_State: 1,
|
|
|
- CreateTime: StockOut.CreateTime,
|
|
|
+ CreateTime: date,
|
|
|
UpdateTime: StockOut.UpdateTime,
|
|
|
}
|
|
|
_, err = DeviceDao.AddOrUpdate_Device(device, 1)
|
|
@@ -2227,7 +2264,7 @@ func (c *StockController) StockOut_Edit() {
|
|
|
T_iccid: mqtt.Iccid,
|
|
|
T_imei: mqtt.Imei,
|
|
|
T_State: 1,
|
|
|
- CreateTime: StockOut.CreateTime,
|
|
|
+ CreateTime: date,
|
|
|
UpdateTime: StockOut.UpdateTime,
|
|
|
}
|
|
|
_, err = DeviceDao.AddOrUpdate_Device(device, 1)
|
|
@@ -2733,87 +2770,6 @@ func Cron_StockMonth_Add() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// 重写设备出入库记录
|
|
|
-func Cron_Device_Add() {
|
|
|
-
|
|
|
- logs.Info("开始统计写入设备出入库数据")
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Begin()
|
|
|
- DeviceDao := Stock.NewDevice(o)
|
|
|
- StockOutDao := Stock.NewStockOut(o)
|
|
|
- StockInDao := Stock.NewStockIn(o)
|
|
|
- StockOutProductDao := Stock.NewStockOutProduct(o)
|
|
|
- StockInProductDao := Stock.NewStockInProduct(o)
|
|
|
- // 添加入库设备信息
|
|
|
- StockInList, _ := StockInDao.Read_StockIn_List(0, "", "", 0, 9999)
|
|
|
- for _, stockIn := range StockInList {
|
|
|
- productList := StockInProductDao.Read_StockInProduct_List_ByT_number(stockIn.T_number)
|
|
|
- for _, product := range productList {
|
|
|
- if len(product.T_relation_sn) == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- for _, sn := range lib.SplitString(product.T_relation_sn, ",") {
|
|
|
- mqtt := Stock.Read_MqttUser(sn)
|
|
|
- // 添加设备
|
|
|
- device := Stock.Device{
|
|
|
- T_contract_number: "",
|
|
|
- T_out_number: "",
|
|
|
- T_product_id: product.T_product_id,
|
|
|
- T_in_number: stockIn.T_number,
|
|
|
- T_sn: sn,
|
|
|
- T_iccid: mqtt.Iccid,
|
|
|
- T_imei: mqtt.Imei,
|
|
|
- T_State: 2,
|
|
|
- CreateTime: product.CreateTime,
|
|
|
- UpdateTime: product.UpdateTime,
|
|
|
- }
|
|
|
- _, err := DeviceDao.AddOrUpdate_Device(device, 2)
|
|
|
- if err != nil {
|
|
|
- o.Rollback()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- // 添加出库设备信息
|
|
|
- StockOutList, _ := StockOutDao.Read_StockOut_List(0, "", "", "", 0, 9999)
|
|
|
- for _, stockOut := range StockOutList {
|
|
|
- productList := StockOutProductDao.Read_StockOutProduct_List(stockOut.T_number)
|
|
|
- for _, product := range productList {
|
|
|
- if len(product.T_relation_sn) == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- for _, sn := range lib.SplitString(product.T_relation_sn, ",") {
|
|
|
- mqtt := Stock.Read_MqttUser(sn)
|
|
|
- // 添加设备
|
|
|
- device := Stock.Device{
|
|
|
- T_contract_number: stockOut.T_contract_number,
|
|
|
- T_product_id: product.T_product_id,
|
|
|
- T_out_number: stockOut.T_number,
|
|
|
- T_sn: sn,
|
|
|
- T_iccid: mqtt.Iccid,
|
|
|
- T_imei: mqtt.Imei,
|
|
|
- T_State: 1,
|
|
|
- T_project: stockOut.T_project,
|
|
|
- CreateTime: product.CreateTime,
|
|
|
- UpdateTime: product.UpdateTime,
|
|
|
- }
|
|
|
- _, err := DeviceDao.AddOrUpdate_Device(device, 1)
|
|
|
- if err != nil {
|
|
|
- o.Rollback()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- o.Commit()
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
func generateMonthList(startMonth time.Time) []string {
|
|
|
var months []string
|
|
|
endMonth := time.Now().AddDate(0, 0, 0)
|